[harm_unit]: moved the harmer advancement check inside the for cycle/valid check

This commit is contained in:
Elvish_Hunter 2013-06-14 23:20:05 +02:00
parent e74471eaf6
commit 6c4f81edba

View file

@ -931,17 +931,19 @@ function wml_actions.harm_unit(cfg)
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 { { "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 }
wesnoth.set_variable ( "Lua_store_unit", nil )
end
end
if experience ~= false and harmer and harmer.valid and harmer.experience >= harmer.max_experience then
wml_actions.store_unit { { "filter", { id = harmer.id } }, variable = "Lua_store_unit", kill = true }
wml_actions.unstore_unit { variable = "Lua_store_unit", find_vacant = false, advance = true }
wesnoth.set_variable ( "Lua_store_unit", nil )
-- 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 { { "filter", { id = harmer.id } }, variable = "Lua_store_unit", kill = true }
wml_actions.unstore_unit { variable = "Lua_store_unit", find_vacant = false, advance = true }
wesnoth.set_variable ( "Lua_store_unit", nil )
end
end
wml_actions.redraw {}