Follow-up Comment #1, bug #14163 (project wesnoth):
Note that you can emulate the behavior of the [kill] tag with WML if it
doesn't fit your needs. For instance, with Wesnoth trunk, the following
snippet (hardly tested) will improve the [kill] tag so that it sets the
second unit accordingly to the [killer] subtag.
local function improved_kill(cfg, kill)
-- Eliminate the cases for which the standard behavior is sufficient.
local x,y = cfg.x or "", cfg.y or ""
if not cfg.fire_event or x == "recall" or y == "recall" then return
kill(cfg) end
local killer = get_child(cfg, "killer")
if not killer then return kill(cfg) end
-- Set the [killer] as the second unit in event data.
local ev_pos = {}
local ev = { { "primary_unit", ev_pos } }
killer = wesnoth.get_units(killer)[1]
if killer then
ev[2] = { "secondary_unit", { x = killer.x, y = killer.y } }
end
-- Emulate the behavior of the [kill] tag for units on the map.
for i,u in ipairs(wesnoth.get_units(cfg)) do
ev_pos.x = u.x; ev_pos.y = u.y
ev.name = "last_breath"; wesnoth.fire("fire_event", ev)
if cfg.animate then
wesnoth.fire("animate_unit", { flag = "death", { "filter", ev_pos } })
end
ev.name = "die"; wesnoth.fire("fire_event", ev)
kill(ev_pos)
end
-- Emulate the behavior of the [kill] tag for recallable units.
if (x == "" or x == "recall") and (y == "" or y == "recall") then
cfg.x = "recall"
cfg.y = "recall"
kill(cfg)
end
end
wesnoth.register_wml_action("kill", improved_kill)
_______________________________________________________
Reply to this item at:
<http://gna.org/bugs/?14163>
_______________________________________________
Message posté via/par Gna!
http://gna.org/
_______________________________________________
Wesnoth-bugs mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-bugs