Ask a simple question, get a simple answer

Ask for help about creating mods and scripts for Grimrock 2 or share your tips, scripts, tools and assets with other modders here. Warning: forum contains spoilers!
User avatar
Adrageron
Posts: 203
Joined: Thu Nov 08, 2012 1:22 pm

Re: Ask a simple question, get a simple answer

Post by Adrageron »

@Isaac
You have both submerged and adjacent open-air tiles in your maps? (...with no barriers between?)
Yes, I use underwater tiles with different heights, the party can stand open-air knee-deep in water (height 0) when the adjacent tile is considered underwater (height -2), without unnatural boundaries in-between. So you can dive and emerge by simple walking, without jumps and ladders.
Is there a reason not to flag all of the map tiles as underwater?
This didn't help. Apparently, the sound is blocked if it comes from an object below the water level at the moment when the party is not considered "diving". Eeven if you stand knee-deep in water next to the sound source.

I have no "fake" air tiles, just playing with different heihgts and slightly raised water surface.
User avatar
Isaac
Posts: 3172
Joined: Fri Mar 02, 2012 10:02 pm

Re: Ask a simple question, get a simple answer

Post by Isaac »

Watch the first few seconds of this demo map.

https://vimeo.com/335643649

Is this similar to the water interaction you are trying to have?

This map accomplishes underwater wading using the heightmap, and using a transformed water mesh. This allows attacks from adjacent squares.

*There is no sound in the video, but it plays the water/plunge sounds as expected in the game.
User avatar
Adrageron
Posts: 203
Joined: Thu Nov 08, 2012 1:22 pm

Re: Ask a simple question, get a simple answer

Post by Adrageron »

Yes, this is exactly what I did. Movement sounds of the party works fine. But if there will be a monster in the deepest tile in the pond here, you will not hear it from adjacent tiles.
User avatar
Isaac
Posts: 3172
Joined: Fri Mar 02, 2012 10:02 pm

Re: Ask a simple question, get a simple answer

Post by Isaac »

In the video, all tiles are on elevation zero.

I don't have the map source with me, and I am working on a tablet PC while I am away from home [for a few days].

I can demonstrate it later tonight, if the tablet runs the game okay.

The gist of it is that the water mesh can be transformed via script, so that you don't get wild sharp peaks on the waves when you change the hightmap under the water plane. IIRC... The plunge/wading sounds were handled by floor_triggers.
User avatar
Adrageron
Posts: 203
Joined: Thu Nov 08, 2012 1:22 pm

Re: Ask a simple question, get a simple answer

Post by Adrageron »

I did all of this. Waves are fine, party movement sounds too. The only problem is with underwater objects sounds. For example, try to place a destructible object at the bottom of the pond and hit it from an adjacent tile. Your attacks will be silent.
User avatar
Isaac
Posts: 3172
Joined: Fri Mar 02, 2012 10:02 pm

Re: Ask a simple question, get a simple answer

Post by Isaac »

I think the solution is to not have underwater tiles where the water is only waist deep. The background drone of the under water sound would seem [logically I mean] to dampen all other sounds outside of the water.

For special case (or creatures), you might use a floor trigger to activate combat sounds called from brain events; by activate I mean enabled only while standing on the trigger.

*Such triggers could be added to the map tile itself.
User avatar
Adrageron
Posts: 203
Joined: Thu Nov 08, 2012 1:22 pm

Re: Ask a simple question, get a simple answer

Post by Adrageron »

Well, this is what I'm afraid of :) So, there is no way to shut down that "drone" or at least fool it somehow? :roll:
I was thinking about the script hooked on monster animation event that forcefully plays action sound when monster and party Y positions are on different sides of the logical waterline. But I'm really don't want to do that :mrgreen:

I've just done a couple of experiments. Interestingly, sound blocking does not apply to ambient sounds (force field, for example). I can hear force field's noise, but not the monster inside it :)
User avatar
Isaac
Posts: 3172
Joined: Fri Mar 02, 2012 10:02 pm

Re: Ask a simple question, get a simple answer

Post by Isaac »

Adrageron wrote: Mon Nov 29, 2021 12:50 am I was thinking about the script hooked on monster animation event that forcefully plays action sound when monster and party Y positions are on different sides of the logical waterline. But I'm really don't want to do that :mrgreen:
This is sort of what I meant; that the monster definition be changed to play the combat sounds from the events —if— a conditon is met. Conditions like the monster is standing on a tile where they need to be heard (floor_trigger boolean), or perhaps the monster event checks if the party is standing where those sounds need to be played from the combat events.

*This latter case might need an additional condition to stop close range sounds from long range projectile attacks.
minmay
Posts: 2768
Joined: Mon Sep 23, 2013 2:24 am

Re: Ask a simple question, get a simple answer

Post by minmay »

GameObject:playSound() checks if the object's underwaterness matches the party's underwaterness, and if it doesn't, it doesn't play the sound. Other things that play sound don't have this check.
The following things use GameObject:playSound():
- AnimationComponent plays sounds when it encounters a playSound: animation event
- ButtonComponent plays its sound field when it starts
- ChestComponent plays "chest_close" and "chest_open" when it closes and opens, respectively
- CloudSpellComponent plays its sound field when it initializes
- FloorTriggerComponent plays its activateSound field and deactivateSound field
- ForceFieldComponent plays "force_field_cast" when its duration expires
- GoromorgShieldComponent plays "goromorg_shield_hit" and "goromorg_shield_break" when hit
- HealthComponent plays its dieSound field when it dies
- ItemComponent plays "impact_blunt" if it collides with a monster but misses the attack
- LeverComponent plays its sound field when toggled
- LindwormBrainComponent plays "lindworm_shield_break" when it deactivates the shield
- LockComponent plays its sound field when unlocked
- MonsterActionComponents play their sound field when they start
- MonsterAttackComponent plays its impactSound field when it hits
- MonsterComponent plays its footstepSound on "footstep" animation events, plays its hitSound when damaged with DamageFlags.Impact (or plays "ice_hit" instead if it's frozen), and plays its dieSound when it dies
- ObstacleComponent plays its hitSound field when hit, unless the hitSound field is "$weapon" (the sound played for "$weapon" does NOT use GameObject:playSound() and will be audible even if the obstacle is underwater and the party is not!)
- PitComponent plays "pit_close" and "pit_open" when closed and opened
- PushableBlockComponent when it rises, falls, or is pushed
- TentacleHideComponent plays "tentacles_retreat" when it starts and "tentacles_rise" when it starts rising
- TileDamagerComponent plays its sound field every time it triggers

If you can't easily avoid/workaround these, I'd suggest finding a design that doesn't involve things being logically underwater at all. Don't forget that entering/exiting water changes the current ambient track, and even if your level's ambient track is named "underwater", it will still annoyingly restart whenever the party exits water, so it's hard for entering/exiting water to be a smooth experience anyway...
Grimrock 1 dungeon
Grimrock 2 resources
I no longer answer scripting questions in private messages. Please ask in a forum topic or this Discord server.
User avatar
Adrageron
Posts: 203
Joined: Thu Nov 08, 2012 1:22 pm

Re: Ask a simple question, get a simple answer

Post by Adrageron »

Isaac, minmay, thank you, guys! I'm understand the problem much better now. I'll try to find not very shameful workaround :mrgreen:
Post Reply