Solarus-Games English Forum

Solarus => Bugs & Feature requests => Topic started by: polyglot762 on July 17, 2015, 08:28:20 PM

Title: Feature request: Custom death Animations
Post by: polyglot762 on July 17, 2015, 08:28:20 PM
Hello Dev team,
I would like the ability to select the death animation for various enemies or custom entities.
As far as I have searched through the source code I haven't found anything exactly like this.
in the enemy.cpp there is a section kind of like what I am hoping to do but I would like to make it more customizable to the breed or custom entity.

Some solutions... (I thought of in lieu of the feature)
remove the general death animation...
then create items for each enemy that are looped after the item death animation.
I am not sure though how well this type of jerryrigging would affect performance.

Observation... looping the death animation creates some hilarious results.

Thanks for the consideration,
PG
Title: Re: Feature request: Custom death Animations
Post by: Diarandor on July 17, 2015, 09:22:33 PM
Hi!

I would use your solution too. I would try to change the animation in the event enemy:on_dying(), but I am not sure if it would work correctly since the sprites are replaced by "enemies/enemy_killed", but I don't know if that replacement is before or after the event (if it is before you should not have problems).

If that does not work, you can always use that event to remove the enemy and create other entity (temporarily) showing the dying animation you want or whatever. On the other hand, for custom entities everything is scripted, so you should not have any problem to show what you want (almost anything is possible with custom entities if you have patience to program).

It should also be possible to set an animation on an enemy depending on which weapon you use to kill it (so it would have several dying animations). One way to do this is to save in some variable (for instance, enemy.last_weapon) the name of the weapon you use to hit him each time, so that when it dies, you have in the variable the name of the last weapon that has hit the enemy, and then select the animation using the event enemy:on_dying().

Good luck with this!
Title: Re: Feature request: Custom death Animations
Post by: Zeror on July 20, 2015, 09:23:17 PM
Can't you do something with the directions. Add a new direction for each dying animation. And then change the direction to it when the fatal blow hits for each enemy/projectile type.

For example:
Killed by regular enemy -> default Direction 0
killed by magic -> Direction 1
killed by projectile -> Direction 2
etc..