Author: noyga
Date: Fri Mar 28 00:20:50 2008
New Revision: 25215

URL: http://svn.gna.org/viewcvs/wesnoth?rev=25215&view=rev
Log:
New [fire_event] tag to fire any (possibly custom) event from an event.
In short, it works like this :
[fire_event]
        name=event name
        [primary_unit]
                x=x1
                y=y1
                weapon=attack_weapon
        [/primary_unit]
        [secondary_unit]
                x=x2
                y=y2
                weapon=defend_weapon
        [/secondary_unit]
[/fire_event]


Modified:
    trunk/changelog
    trunk/src/game_events.cpp

Modified: trunk/changelog
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/changelog?rev=25215&r1=25214&r2=25215&view=diff
==============================================================================
--- trunk/changelog (original)
+++ trunk/changelog Fri Mar 28 00:20:50 2008
@@ -58,6 +58,7 @@
    * it's now possible to specify with loop= how many times a sample
      associated with a sound source should be played
    * new [switch] conditional command
+   * new [fire_event] event tag to fire any custom event
    * new [unit_side] theme element : this is the side of the current unit 
(flag)
  * miscellaneous and bug fixes:
    * Removed spurious -R linker switch from command line generated by the Boost

Modified: trunk/src/game_events.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/game_events.cpp?rev=25215&r1=25214&r2=25215&view=diff
==============================================================================
--- trunk/src/game_events.cpp (original)
+++ trunk/src/game_events.cpp Fri Mar 28 00:20:50 2008
@@ -2227,6 +2227,31 @@
        // Adding of new events
        else if(cmd == "event") {
                new_handlers.push_back(event_handler(cfg.get_config()));
+       }
+       
+       // Fire any events
+       else if(cmd == "fire_event") {
+               gamemap::location loc1,loc2;
+               config data;            
+               if (cfg.has_child("primary_unit")) {
+                       vconfig u = cfg.child("primary_unit");
+                       if (u.has_attribute("x") && u.has_attribute("y"))
+                               loc1 = cfg_to_loc(u);
+                       if (u.has_attribute("weapon")) {
+                               config& f = data.add_child("first");
+                               f["weapon"] = u.get_attribute("weapon");
+                       }
+               }
+               if (cfg.has_child("secondary_unit")) {
+                       vconfig u = cfg.child("secondary_unit");
+                       if (u.has_attribute("x") && u.has_attribute("y"))
+                               loc2 = cfg_to_loc(u);
+                       if (u.has_attribute("weapon")) {
+                               config& s = data.add_child("second");
+                               s["weapon"] = u.get_attribute("weapon");
+                       }
+               }
+               game_events::fire(cfg["name"],loc1,loc2,data);
        }
        
        // Setting of menu items


_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits

Reply via email to