What is "script" in set_attack_consequence ?

Started by MetalZelda, January 28, 2016, 04:48:59 PM

Previous topic - Next topic
Hi

I was working on some enemies and I am facing a little problem.
I want a sprite of this enemy to react to a thrown bomb, but "thrown_item" in as attack_consequence doesn't seems to work, tried with "explosion'' and it worked, but that's not the wanted effect.

Then, I was playing with set attak consequence and the console show me something that isn't documented in the API
http://www.solarus-games.org/doc/latest/lua_api_enemy.html#lua_api_enemy_set_attack_consequence_sprite

"Invalid name'attack', valid name are" blabla ""script""


Loading it in game does nothing, the enemy still move.

this is the current script, I want a thrown bomb to interract with this particular sprite, but it is not working, as said above, "explosion" work.
There is nothing much, the local variable is set to true when it is needed for the collision.

Code (lua) Select
-- Part in on_created
self:set_attack_consequence_sprite(head_sprite, "thrown_item", "custom")
self:set_attack_consequence_sprite(head_sprite, "explosion", "custom")


Code (lua) Select

  function enemy:on_custom_attack_received(attack, sprite)
  if attack == "sword" and sprite == sprite then
if can_attack then
sol.audio.play_sound("ennemies/_boss/king_dodongo/hit")
self:get_sprite():set_direction(1)
self:remove_life(enemy:get_game():get_ability('sword'))
sol.timer.start(250, function()
self:get_sprite():set_direction(0)
end)
else
sol.audio.play_sound("sword_tapping")
end
  end
 
  if attack == "thrown_item" and sprite == head_sprite then
     if can_damage then
      print("damaged")
end
  end

  if self:get_life() <= 5 then
start_dying_cutscene()
  end 
end
end

Apparently, sprite collisions don't work for thrown items. This is a bug, could you report it on github? I can fix it for 1.5.

Then I don't understand your problem the console showing you something undocumented, can you be more specific? And paste the exact message you have?

I did open a issue on Github.

For the undocumented thing, there is no "script" as attack consequence in the API, while the console show that it exist.

Just wanna point that bombs aren't counted as "thrown item", which is kinda weird, but I do see that thrown items collision only work if the destructible can exerce any damage on a enemy.

Anyway, I managed to counter this bug by a little trick in the carried object metatable, nice to see that bugs can be bypassed