Set unit hitpoints to 0 during [kill] (#9164)

This commit is contained in:
Toom 2024-08-10 17:20:12 +03:00 committed by GitHub
parent e9a6761484
commit 31658e2587
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 4 additions and 0 deletions

View file

@ -22,6 +22,7 @@ function wesnoth.wml_actions.kill(cfg)
end
local dead_men_walking = wesnoth.units.find_on_map(cfg)
for i,unit in ipairs(dead_men_walking) do
unit.hitpoints = 0
local death_loc = {x = tonumber(unit.x) or 0, y = tonumber(unit.y) or 0}
if not secondary_unit then killer_loc = death_loc end
local can_fire = false

View file

@ -8,11 +8,13 @@
##
# Expected end state:
# A last breath event and a die event are triggered for Bob but not for Alice.
# During both events primary unit has 0 or less hitpoints
#####
{GENERIC_UNIT_TEST "kill_fires_events" (
[event]
name=last_breath
first_time_only=no
{ASSERT ({VARIABLE_CONDITIONAL unit.hitpoints less_than_equal_to 0})}
[set_variable]
name=$unit.id|_breath
value=yes
@ -21,6 +23,7 @@
[event]
name=die
first_time_only=no
{ASSERT ({VARIABLE_CONDITIONAL unit.hitpoints less_than_equal_to 0})}
[set_variable]
name=$unit.id|_die
value=yes