Author: boucman
Date: Sun May 18 17:51:27 2008
New Revision: 26702
URL: http://svn.gna.org/viewcvs/wesnoth?rev=26702&view=rev
Log:
add a heal_unit action, patch by segfault
Modified:
trunk/changelog
trunk/src/game_events.cpp
Modified: trunk/changelog
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/changelog?rev=26702&r1=26701&r2=26702&view=diff
==============================================================================
--- trunk/changelog (original)
+++ trunk/changelog Sun May 18 17:51:27 2008
@@ -57,6 +57,7 @@
with the new key faction_from_recruit=yes
* add "default_base" parameter to overlay terrains, which specifies the
base terrain the editor draws by default.
+ * New [heal_unit] action.
* wesnothd
* added expiration time to bans
* added restart command to server that does gracefull restart
Modified: trunk/src/game_events.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/game_events.cpp?rev=26702&r1=26701&r2=26702&view=diff
==============================================================================
--- trunk/src/game_events.cpp (original)
+++ trunk/src/game_events.cpp Sun May 18 17:51:27 2008
@@ -2769,6 +2769,35 @@
label.colour());
}
+ else if(cmd== "heal_unit") {
+
+ const vconfig filter = cfg.child("filter");
+ unit_map::iterator u;
+
+ if (filter.null()) {
+ // Try to take the unit at loc1
+ u = units->find(event_info.loc1);
+ }
+ else {
+ for(u = units->begin(); u != units->end(); ++u) {
+ if(game_events::unit_matches_filter(u, filter))
+ break;
+ }
+ }
+
+ // We have found a unit
+ if(u != units->end()) {
+ int amount = lexical_cast_default<int>(cfg["amount"],1);
+ int real_amount = u->second.hitpoints();
+ u->second.heal(amount);
+ real_amount = u->second.hitpoints() - real_amount;
+ gamemap::location healed_loc =
u->second.get_interrupted_move();
+
unit_display::unit_healing(u->second,u->first,std::vector<unit_map::iterator>(),real_amount);
+ state_of_game->set_variable("heal_amount",
+ str_cast<int>(real_amount));
+ }
+ }
+
DBG_NG << "done handling command...\n";
}
_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits