solarus-games / solarus

This repository was moved to GitLab: https://gitlab.com/solarus-games/solarus
http://www.solarus-games.org
Other
710 stars 134 forks source link

enemy:on_custom_attack_received(attack, enemy_sprite) does not allow to call enemy:hurt() #1181

Closed Diarandor closed 6 years ago

Diarandor commented 6 years ago

I used "function enemy:on_custom_attack_received(attack, enemy_sprite)" for the sword ("custom" effect for an enemy). Then I try to call "enemy:hurt()" inside that event and nothing happens. (I've used "print" functions and I confirm that that line is being called, but the enemy is not hurt.)

Diarandor commented 6 years ago

I have to test if I can do it in a different way with https://github.com/solarus-games/solarus/issues/1062. That would avoid this bug (but the bug has to be fixed someday anyway).

Diarandor commented 6 years ago

I have exactly the same problem when I call something like:

enemy:set_attack_consequence_sprite(head_sprite, "sword", function()
   self:hurt(100)
end) 

And using a timer does not work. The damage is still being ignored. I need this to be fixed to finish flying combat with enemies.

christopho commented 6 years ago

This is now fixed, but only for the callback version. The legacy way (event on_custom_attacked_received()) will remain unchanged to avoid breaking existing games.