Is it possible to trow a boomerang at a bubble and get a fairy?
Yes. It is possible to make almost anything if you know how to code it (but not easy).
To do what you want, I would use a custom entity for the bubble. You can use a collision test on the bubble script to detect the collision with the boomerang. (I have done something similar to make trees that throw leaves when hit with the sword, and it works.) You can use something like this:
entity:add_collision_test("sprite", function(entity, other_entity, sprite, other_sprite)
if other_sprite:get_animation() ~= "boomerang" then return end
-- Here goes your code...
end
It is even possible to keep the bubble as a normal enemy.
Define the enemy:on_hurt(attack) event on bubble, and if attack == "boomerang", call enemy:set_treasure("fairy").
See http://www.solarus-games.org/doc/latest/lua_api_enemy.html#lua_api_enemy_on_hurt
Quote from: Christopho on June 13, 2015, 11:57:26 PM
It is even possible to keep the bubble as a normal enemy.
Define the enemy:on_hurt(attack) event on bubble, and if attack == "boomerang", call enemy:set_treasure("fairy").
See http://www.solarus-games.org/doc/latest/lua_api_enemy.html#lua_api_enemy_on_hurt
After that I think we would want to remove the bubble.
If you have played link's awakening, or the oracle games,
Trowing a boomerang at a bubble will cause it to "transform" into a fairy.
That's probably why the are called anti-fairys.
That's right!
function enemy:on_hurt(attack)
if attack == "boomerang" then
local layer, x, y = enemy:get_position()
map:create_pickable({
layer = layer,
x = x,
y = y,
treasure_name = "fairy"
})
enemy:remove()
end
end
But, This works beater, at least, for me anyways.
function enemy:on_created()
self:set_life(1)
self:create_sprite("enemies/bubble")
self:set_size(8, 8)
self:set_origin(4, 4)
self:set_can_hurt_hero_running(true)
self:set_attack_consequence("sword", "ignored")
self:set_attack_consequence("hookshot", "ignored")
self:set_attack_consequence("arrow", "ignored")
self:set_attack_consequence("fire", "ignored")
self:set_attack_consequence("explosion", "ignored")
self:set_attack_consequence("thrown_item", "ignored")
self:set_attack_consequence("boomerang", 10)
self:set_treasure("fairy")
end
You're result Gave some useless and humorous results. The bubble could be hit,
It just couldn't be killed. even by boomerang.