Enemies drowning animation?

Started by Max, March 02, 2018, 10:14:06 PM

Previous topic - Next topic
Hey all.

So when you knock an enemy or throw a carried item into a hazard (water, pit, probably lava too), the engine recognizes this and will remove it and play an appropriate sound. However, it doesn't show any animation. I'm not sure if I just need to create one in the right location or what, but is there a default animation for items or enemies to fall into hazards?

I'm sure one could code a script that checks for enemies or items tossed into hazards, but I'm really just curious for now if that's something the engine can already do that I'm just missing resources for.

You can use the event "on_position_changed" to check the "ground position" (NOT the normal position) when necessary. If the enemy is over bad ground, make it fall or sink; you will need to code some special effects somehow (use custom entities and other stuff to make cool things). If your code is general for most enemies, then use the enemy metatable to define things once; then from each enemy script you can decide if a particular enemy can fall on bad grounds or not by calling that general function (flying enemies will not fall on holes, for instance). Check some of my custom enemies in the project Children of Solarus and also in the Sample Quest, and read their code.
"If you make people think they're thinking, they'll love you. But if you really make them think, they'll hate you."

You can code it, using entity:on_removed I guess and then do what Diarandor tell

Cool! I knew it'd be straightforward to write a script that does this. But, since the engine is already checking every enemy's ground to remove them and make a sound effect, I thought it might also inherently have the ability to pull a "drowning" or "falling" animation for every enemy already, similar to how the engine pulls the "enemy_killed" sprite automatically from "sprites/enemies/enemy_killed".

I thought maybe if I put an animation in "sprites/enemies/enemy_drown" or "sprites/entities/entity_fall", the engine might automatically pull from that when it is already checking for that circumstance to make the appropriate sound effect. If not, that's fine, I don't necessarily want to spend time coding something the engine is already doing part of, :p

IMO it makes no sense to make that from the engine part because that is something too specific of your game. And making a general script for that is not so complicated if you have experience with Lua.
"If you make people think they're thinking, they'll love you. But if you really make them think, they'll hate you."

idk, I figure if the engine is automatically playing a "falling into a hole" sound effect when enemies fall into a hole, it doesn't seem too specialized to automatically play an accompanying animation-- and as for specificity, the engine requires sound effects for things like "cane", "boomerang", "hookshot", which I'd argue are even more specific.

But point taken, and I agree, it's not a very complicated script. But not at the top of my priority list either, so I just thought I'd check to see if it was a built-in function : )
Thanks for the info!

If I am not wrong, there are 3 built-in behaviors for enemies, and the normal one does not allow enemies to traverse (and fall by themselves) on bad grounds, unless you push them. The solution is to initialize them with the flying behavior (to allow them traverse or jump over bad grounds) and check the ground with your script to create the behaviors that you want (fall on holes, etc).
"If you make people think they're thinking, they'll love you. But if you really make them think, they'll hate you."