diff --git a/changelog b/changelog index a05bbfe3e76..4c404c8bce3 100644 --- a/changelog +++ b/changelog @@ -9,7 +9,7 @@ Version 1.3.12+svn: * language and i18n: * updated translations: Chinese, Danish, Finnish, French, Italian * WML engine: - * new event trigger: pre_die, will be triggered when a unit dies, but + * new event "last breath" will be triggered when a unit dies, but before the animation is played * allow ThemeWML to display the race. * new "random_gender=" key (boolean) to single units declarations in WML; diff --git a/src/actions.cpp b/src/actions.cpp index d8548bad556..b1d4f225c8f 100644 --- a/src/actions.cpp +++ b/src/actions.cpp @@ -742,7 +742,9 @@ void attack::fire_event(const std::string& n) std::pair to_insert("weapon", d_weap); tempcfg->values.insert(to_insert); } - game_events::fire(n,attacker_,defender_,dat); + game_events::fire(n, + game_events::entity_location(a_), + game_events::entity_location(d_), dat); a_ = units_.find(attacker_); d_ = units_.find(defender_); return; @@ -1037,24 +1039,31 @@ attack::attack(game_display& gui, const gamemap& map, std::string undead_variation = d_->second.undead_variation(); const int defender_side = d_->second.side(); fire_event("attack_end"); - game_events::fire("pre_die",death_loc,attacker_loc); + game_events::fire("last breath", death_loc, attacker_loc); d_ = units_.find(death_loc); a_ = units_.find(attacker_loc); - if(d_ == units_.end() || !death_loc.matches_unit(d_->second)) { + if(d_ == units_.end() || !death_loc.matches_unit(d_->second) + || d_->second.hitpoints() > 0) { // WML has invalidated the dying unit, abort break; } + bool attacker_invalid = false; if(a_ == units_.end() || !attacker_loc.matches_unit(a_->second)) { if(d_->second.hitpoints() <= 0) { units_.erase(d_); d_ = units_.end(); } - // WML has invalidated the killing unit, abort - break; + // WML has invalidated the killing unit + attacker_invalid = true; } refresh_bc(); - unit_display::unit_die(d_->first,d_->second,a_stats_->weapon,d_stats_->weapon, &(a_->second)); + if(attacker_invalid) { + unit_display::unit_die(d_->first, d_->second, NULL, d_stats_->weapon, NULL); + } else { + unit_display::unit_die(d_->first, d_->second,a_stats_->weapon,d_stats_->weapon, &(a_->second)); + } + game_events::fire("die",death_loc,attacker_loc); d_ = units_.find(death_loc); @@ -1067,7 +1076,8 @@ attack::attack(game_display& gui, const gamemap& map, d_ = units_.end(); } - if(a_ == units_.end() || !attacker_loc.matches_unit(a_->second)) { + if(attacker_invalid || a_ == units_.end() + || !attacker_loc.matches_unit(a_->second)) { // WML has invalidated the killing unit, abort break; }