or other creatures react to water ? This is no trivial game design decision and here are my musing and thoughts about this issue.
First off, what options do you have when you detect that a creature is in water ?
1. You can kill it immediatly.
Well, that would be little bit too harsh, wouldn't it ?
2. It would float helpless on the water, swinging wildly its arms and die after a certain time from exhaustion.
Thought you could try to drain the area, it would be very harsh too. There's no option to help your minion if you can't reach the lever to drain the area and it would be a too easy way to kill of invading enemies.
3. The creature can swim around, but will not be able to do any other actions like fighting or operating a lever.
Hmmm... sounds better, thought you can't operate with your environment or fight off any danger.
4. The creature can swim around and do most actions and still is able to fight to some degree.
Well, we are approaching a game design zone where swimming is more or less just a visual effect and don't have such a strong impact on the game play. So, what would be a good solution ?
After some musing I choose to continue with 3. Creatures can swim, but will not be able to interact with its environment while swimming.
Done ? No, we need to check the game mechanism in more detail. Here are some questions:
1. Can a creature reach a goal by swimming through a pool of water or does it always try to avoid water ?
The option to avoid water sounds easy, but what would happen if one of your creatures is trapped on a island ? You have no option to help it.
2. What is the behavior of a creature, if it is suddenly in water ?
It should try to reach dry ground, shouldn't it ? But this could interference with commanding your minion to reach a certain point:
entering water..eehh..water..leaving..ahh I need to reach my goal..entering water...eeehhh water...
3. Should it be allowed to have a goal in water ?
This would result, that a minion would try to reach an area to execute an action, which can't be executed because it is under water. A movement
command on the other hand would be valid. But what happen, when you start your movement at the time where the goal is not under water, but
at the time when you reach your goal, it is suddenly flooded ?
4. Should doors work in water ?
It is already hard to detect if a door is actually in water, there are floodgates, so on one side there's water, on the other side none. Not being
able to interact with your environment could be deadly for your creatures, especially if you are not able to operate doors. Do we need a special rule for doors ?
5. What about flying creatures ?
Hmmm.. flying creatures can ignore water, can't they ? What about interacting with the environment ? They should be able to fight swimming creatures, but can the interact with objects under water ?
6. Is water a safe haven from enemies ?
Ok, most creatures can't fight when swimming. So, just command your minions to enter water to avoid some strong enemies ? This would be too easy. Water must be dangerous if you linger too long in it, so we need to drain your power during swimming resulting in exhaustion after some time.
Hmmm..I need some ruleset for the behavior of creatures and water. This ruleset should answer all the questions from above in a satisfying way.
Here's my first attempt:
Rule 1: A none-flying creature will not fight when it is currently in water.
Rule 2: All other commands and tasks, which are planned by a creature do not depend on the creature being currently in water.
Rule 3: Planing does ignore goals being in water (exception: flying creatures targeting swimming creatures).
Rule 4: Planing adds a penalty to ways leading through water, but it does not completely avoid water.
Rule 5: Doors can be opened by a creature being in water.
Rule 6: Creatures can't interact with any other object in water.
Rule 7: When idleing/roaming a creature try to reach dry ground.
Rule 8: When in water a creature will exhaust much faster.
Eventually I need to think about how to implement all this rules.
Impl 1: The engine needs to sample the water level at a given position.
Impl 2: The pathfinding system needs to consider the water level at each waypoint.
Impl 3: A parameter to modify the way costs.
Impl 4: Each creature needs a swimming animation.
Impl 5: No automatic swimming detection in the animation system, the game logic should add an animation overlay when the creatures body is deep enough in water.
Impl 6: Creatures in water needs to exhaust much faster.
Impl 7: Lax animation boundaries to avoid animation flipping all the time at the water threshold (eg. enter swimming animation when water is 1m deep, exit animation when water is less then 80cm deep).
Impl 8: Sound overloading, we don't want to hear any footstep sounds when swimming.
Impl 9: Target planing, check if a target is in water at the time of planing to avoid unnessary decisions.
Impl 10: A in_water state at the entity to quickly check it in game logic.
Impl 11: When executing an action, abort it once the creature detects, that it is in water.
Impl 12: Physics: no change in the physics part, the entities will still be grounded. This way I will avoid trouble with doors etc.
Impl 13: Rendering, add a visual flag to indicate, that the rendered object is floating at the water surface (Performance bonus, only rendered objects needs a detailed evaluation of the surface)
Sounds solid, enough to start a first implementation. Coding time
It sounds like your creatures are not under the player's direct control. Almost sounds like a Dwarf Fortress or Dungeon Keeper type of control. If that's the case I had some ideas.
Have the choice of whether a create enters the water to achieve it's goal vary from creature to creature. Some creatures can be petrified of water (instantly cancelling any order given to it that would lead to water) while others give it no mind at all (will go right in!) This may add to a creatures over all personality, and maybe even the drama for the player ("please open that door! Come on! WHAT DO YOU MEAN YOU DON'T LIKE WATER?!")
You mention flying creatures aren't effected by water... but what if they're in an enclosed space (like DF or DK)? Couldn't the water reach the ceiling? If it does, wouldn't the flying creature need to be effected by it?
Why limit the underwater actions to just doors? If the creature can open a door, can't they pull a lever or press a switch as well?
Maybe the creatures can even "rescue" other panicking creatures. If you have the petrified creature, who is suddenly engulfed in water, maybe he panics and flails. On the shore, a "brave" creature (who is otherwise idle) may see his panicked comrade and decide to save him.
I don't know how feasible any of that is with your system, but just some thoughts that came to mind.