Author: anonymissimus
Date: Mon Sep 13 17:58:58 2010
New Revision: 46461
URL: http://svn.gna.org/viewcvs/wesnoth?rev=46461&view=rev
Log: (empty)
Modified:
trunk/src/game_events.cpp
Modified: trunk/src/game_events.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/game_events.cpp?rev=46461&r1=46460&r2=46461&view=diff
==============================================================================
--- trunk/src/game_events.cpp (original)
+++ trunk/src/game_events.cpp Mon Sep 13 17:58:58 2010
@@ -1857,6 +1857,25 @@
WML_HANDLER_FUNCTION(kill, event_info, cfg)
{
+ bool secondary_unit = cfg.has_child("secondary_unit");
+ game_events::entity_location killer_loc(map_location(0, 0));
+ if(cfg["fire_event"].to_bool() && secondary_unit)
+ {
+ secondary_unit = false;
+ for(unit_map::const_unit_iterator unit =
resources::units->begin();
+ unit != resources::units->end(); ++unit) {
+ if(game_events::unit_matches_filter(*unit,
cfg.child("secondary_unit")))
+ {
+ killer_loc =
game_events::entity_location(*unit);
+ secondary_unit = true;
+ break;
+ }
+ }
+ if(!secondary_unit) {
+ WRN_NG << "failed to match [secondary_unit] in [kill]
with a single on-board unit\n";
+ }
+ }
+
// Use (x,y) iteration, because firing events ruins unit_map iteration
for (map_location loc(0,0); loc.x < resources::game_map->w(); ++loc.x)
{
@@ -1867,6 +1886,9 @@
{
bool fire_event = false;
game_events::entity_location death_loc(*un);
+ if(!secondary_unit) {
+ killer_loc =
game_events::entity_location(*un);
+ }
if (cfg["fire_event"].to_bool())
{
// Prevent infinite recursion of 'die'
events
@@ -1886,7 +1908,7 @@
}
}
if (fire_event) {
- game_events::fire("last breath",
death_loc, death_loc);
+ game_events::fire("last breath",
death_loc, killer_loc);
}
if (cfg["animate"].to_bool()) {
resources::screen->scroll_to_tile(loc);
@@ -1896,7 +1918,7 @@
}
if (fire_event)
{
- game_events::fire("die", death_loc,
death_loc);
+ game_events::fire("die", death_loc,
killer_loc);
un = resources::units->find(death_loc);
if (un != resources::units->end() &&
death_loc.matches_unit(*un)) {
resources::units->erase(un);
_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits