From 9110e49760e40d9856b96f884f3c1636e034768c Mon Sep 17 00:00:00 2001 From: Jyrki Vesterinen Date: Wed, 16 May 2018 05:12:32 +0300 Subject: [PATCH] Allow modifying dead units in more event handlers Namely attacker_hits, attacker_misses, defender_hits and defender_misses. --- src/actions/attack.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/actions/attack.cpp b/src/actions/attack.cpp index a4f7ad4da96f..9129803fc212 100644 --- a/src/actions/attack.cpp +++ b/src/actions/attack.cpp @@ -1199,10 +1199,16 @@ bool attack::perform_hit(bool attacker_turn, statistics::attack_context& stats) OOS_error_ = true; } + if(dies) { + // Will be reset in unit_killed() later. + unit::dying_unit_loc = defender.loc_; + } + if(hits) { try { fire_event(attacker_turn ? "attacker_hits" : "defender_hits"); } catch(const attack_end_exception&) { + unit::dying_unit_loc = map_location::null_location(); refresh_bc(); return false; } @@ -1210,6 +1216,7 @@ bool attack::perform_hit(bool attacker_turn, statistics::attack_context& stats) try { fire_event(attacker_turn ? "attacker_misses" : "defender_misses"); } catch(const attack_end_exception&) { + unit::dying_unit_loc = map_location::null_location(); refresh_bc(); return false; }