Skip to content

Commit

Permalink
use wesnoth.advance_unit to advance units in [harm_unit]
Browse files Browse the repository at this point in the history
  • Loading branch information
gfgtdf committed Dec 21, 2015
1 parent b4e5f16 commit 1eefcdd
Showing 1 changed file with 5 additions and 31 deletions.
36 changes: 5 additions & 31 deletions data/lua/wml-tags.lua
Expand Up @@ -1114,39 +1114,13 @@ function wml_actions.harm_unit(cfg)
wesnoth.set_variable(string.format("%s[%d]", variable, index - 1), { harm_amount = damage })
end

-- both may no longer be alive at this point, so double check
-- this blocks handles the harmed units advancing
if experience ~= false and harmer and unit_to_harm.valid and unit_to_harm.experience >= unit_to_harm.max_experience then
wml_actions.store_unit {
T.filter { id = unit_to_harm.id },
variable = "Lua_store_unit",
kill = true,
}
wml_actions.unstore_unit {
variable = "Lua_store_unit",
find_vacant = false,
advance = true,
animate = toboolean( animate ),
fire_event = fire_event,
}
wesnoth.set_variable ( "Lua_store_unit", nil )
-- both units may no longer be alive at this point, so double check
if experience ~= false and unit_to_harm and unit_to_harm.valid then
unit_to_harm:advance(toboolean(animate), fire_event ~= false)
end

-- this block handles the harmer advancing
if experience ~= false and harmer and harmer.valid and harmer.experience >= harmer.max_experience then
wml_actions.store_unit {
T.filter { id = harmer.id },
variable = "Lua_store_unit",
kill = true,
}
wml_actions.unstore_unit {
variable = "Lua_store_unit",
find_vacant = false,
advance = true,
animate = toboolean( animate ),
fire_event = fire_event,
}
wesnoth.set_variable ( "Lua_store_unit", nil )
if experience ~= false and harmer and harmer.valid then
harmer:advance(toboolean(animate), fire_event ~= false)
end
end

Expand Down

0 comments on commit 1eefcdd

Please sign in to comment.