Author: fendrin
Date: Sun Dec  7 17:59:20 2008
New Revision: 31344

URL: http://svn.gna.org/viewcvs/wesnoth?rev=31344&view=rev
Log:
Added macros for handling persistent ai sides.

Modified:
    trunk/data/core/macros/side-utils.cfg

Modified: trunk/data/core/macros/side-utils.cfg
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/data/core/macros/side-utils.cfg?rev=31344&r1=31343&r2=31344&view=diff
==============================================================================
--- trunk/data/core/macros/side-utils.cfg (original)
+++ trunk/data/core/macros/side-utils.cfg Sun Dec  7 17:59:20 2008
@@ -246,3 +246,99 @@
 
     {CLEAR_VARIABLE TRANSFER_VILLAGE_OWNERSHIP_villages}
 #enddef
+
+# Persistant macros
+
+#define MAKE_AI_SIDE_PERSISTENT SIDE
+    #Macro to make a ai controlled side persistent. 
+    #Needs to be placed below the side definition.
+    [+side]
+        controller=human
+        persistent=yes
+    [/side]
+
+    [event]
+        name=prestart
+        [modify_side]
+            side={SIDE}
+            controller=ai
+        [/modify_side]
+    [/event]
+    [event]
+        name=victory
+        [modify_side]
+            side={SIDE}
+            controller=human
+        [/modify_side]
+    [/event]
+#enddef
+
+#define RECALL_AI_SIDE SIDE
+    #Recalls an ai side that is persistent (MAKE_AI_SIDE_PERSISTENT)
+    #Needs to be placed below the side definition.
+    {MAKE_AI_SIDE_PERSISTENT {SIDE}}
+    [event]
+        name=prestart
+
+        [store_unit]
+            variable=recall_ai_side_units_{SIDE}
+            [filter]
+                side={SIDE}
+            [/filter]
+        [/store_unit]
+    [/event]
+    [event]
+        name=victory
+        {CLEAR_VARIABLE recall_ai_side_units_{SIDE}}
+    [/event]
+    [event]
+        name=ai turn
+
+        [if]
+            [variable]
+                name=side_number
+                equals={SIDE}
+            [/variable]
+            [and]
+                [have_unit]
+                    canrecruit=yes
+                    side={SIDE}
+                    [filter_location]
+                        terrain=K*
+                    [/filter_location]
+                [/have_unit]
+            [/and]
+        
+            [then]
+                [store_gold]
+                    side={SIDE}
+                [/store_gold]
+
+                [while]
+                    [variable]
+                        name=gold
+                        greater_than=19
+                    [/variable]
+                    [variable]
+                        name=recall_ai_side_units_{SIDE}.length
+                        greater_than=0
+                    [/variable]
+                    [do]
+                        [gold]
+                            side=2
+                            amount=-20
+                        [/gold]
+                        [store_gold]
+                            side={SIDE}
+                        [/store_gold]
+                        [recall]
+                            id=$recall_ai_side_units_{SIDE}[0].id
+                        [/recall]
+                        {CLEAR_VARIABLE recall_ai_side_units_{SIDE}[0]}
+                    [/do]
+                [/while]
+                {CLEAR_VARIABLE gold}
+            [/then]
+        [/if]
+    [/event]
+#enddef


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

Reply via email to