mail[Wesnoth-commits] r20783 - in /trunk/data: campaigns/Descent_Into_Darkness/scenarios/02_Peaceful_Valley.cfg core/macros/utils.cfg


Others Months | Index by Date | Thread Index
>>   [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Header


Content

Posted by lari . nieminen on September 30, 2007 - 23:10:
Author: zookeeper
Date: Sun Sep 30 23:09:58 2007
New Revision: 20783

URL: http://svn.gna.org/viewcvs/wesnoth?rev=20783&view=rev
Log:
Changed Peaceful Valley so that goblins spawn on random adjacent hexes 
(instead of always on the same ones) and that there are no spawns if you 
recapture a village. Also added a new REPEAT macro.

Modified:
    
trunk/data/campaigns/Descent_Into_Darkness/scenarios/02_Peaceful_Valley.cfg
    trunk/data/core/macros/utils.cfg

Modified: 
trunk/data/campaigns/Descent_Into_Darkness/scenarios/02_Peaceful_Valley.cfg
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/data/campaigns/Descent_Into_Darkness/scenarios/02_Peaceful_Valley.cfg?rev=20783&r1=20782&r2=20783&view=diff
==============================================================================
--- 
trunk/data/campaigns/Descent_Into_Darkness/scenarios/02_Peaceful_Valley.cfg 
(original)
+++ 
trunk/data/campaigns/Descent_Into_Darkness/scenarios/02_Peaceful_Valley.cfg 
Sun Sep 30 23:09:58 2007
@@ -103,9 +103,9 @@
             random_traits=no
             [modifications]
                 [trait]
-                        id=loyal
-                        male_name= _ "loyal"
-                        description= _ "to himself"
+                    id=loyal
+                    male_name= _ "loyal"
+                    description= _ "to himself"
                     [effect]
                         apply_to=loyal
                     [/effect]
@@ -126,28 +126,48 @@
     # Generate a random number of guards between 0 and 2 near X,Y
     # Note that this uses BfW's default behavior to shift unit placement 
when you try to place on top of another unit
 #define RANDOM_GUARDS TYPE DESCRIPTION UDESCRIPTION SIDE X Y
-    {RANDOM 0..2}
-    {VARIABLE i 0}
-    [while]
-        [variable]
-            name=i
-            less_than=$random
-        [/variable]
-        [do]
-            [unit]
-                description={DESCRIPTION}
-                user_description={UDESCRIPTION}
-                type={TYPE}
-                upkeep=loyal
-                side={SIDE}
-                x={X}
-                y={Y}
-                animate=yes
-            [/unit]
-            {VARIABLE_OP i add 1}
-        [/do]
-    [/while]
-    {CLEAR_VARIABLE i}
+    {VARIABLE_OP number_of_guards random 0..2}
+
+    {REPEAT $number_of_guards (
+        [store_locations]
+            [filter_adjacent_location]
+                x,y={X},{Y}
+            [/filter_adjacent_location]
+
+            [not]
+                [filter]
+                [/filter]
+            [/not]
+
+            variable=possible_guard_locations
+        [/store_locations]
+
+        {IF_VAR possible_guard_locations.length greater_than 0 (
+            [then]
+                {VARIABLE_OP random_location_index random 
0..$possible_guard_locations.length}
+
+                [move_unit_fake]
+                    side={SIDE}
+                    type={TYPE}
+                    x={X},$possible_guard_locations[$random_location_index].x
+                    y={Y},$possible_guard_locations[$random_location_index].y
+                [/move_unit_fake]
+
+                [unit]
+                    description={DESCRIPTION}
+                    user_description={UDESCRIPTION}
+                    type={TYPE}
+                    side={SIDE}
+                    
x,y=$possible_guard_locations[$random_location_index].x,$possible_guard_locations[$random_location_index].y
+                    random_traits=yes
+                [/unit]
+            [/then]
+        )}
+    )}
+
+    {CLEAR_VARIABLE number_of_guards}
+    {CLEAR_VARIABLE possible_guard_locations}
+    {CLEAR_VARIABLE random_location_index}
 #enddef
 
     # In-scenario events
@@ -166,7 +186,18 @@
         [filter]
             side=1
         [/filter]
-        {RANDOM_GUARDS (Goblin Spearman) Villager (_ "Villager") 2 $x1 $y1}
+
+        {IF_VAR village_$x1,$y1|_cleared not_equals yes (
+            [then]
+                {RANDOM_GUARDS (Goblin Spearman) Villager (_ "Villager") 2 
$x1 $y1}
+
+                {VARIABLE village_$x1,$y1|_cleared yes}
+            [/then]
+
+            [else]
+                [allow_undo][/allow_undo]
+            [/else]
+        )}
     [/event]
 
     [event]
@@ -234,7 +265,6 @@
         [/store_villages]
         [if]
             [variable]
-                #                      name=villages_owned
                 name=villages.length
                 numerical_equals=$number_villages
             [/variable]
@@ -250,9 +280,20 @@
 
     [event]
         name=victory
+
+        [store_villages]
+            variable=villages
+        [/store_villages]
+
+        {FOREACH villages i}
+            {VARIABLE_OP village_var format 
"village_$villages[$i].x,$villages[$i].y|_cleared"}
+
+            {CLEAR_VARIABLE $village_var}
+        {NEXT i}
+
         {CLEAR_VARIABLE number_villages}
-        #{CLEAR_VARIABLE villages_owned}
         {CLEAR_VARIABLE villages}
+        {CLEAR_VARIABLE village_var}
     [/event]
 
     {@campaigns/Descent_Into_Darkness/utils/global-events.cfg}

Modified: trunk/data/core/macros/utils.cfg
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/data/core/macros/utils.cfg?rev=20783&r1=20782&r2=20783&view=diff
==============================================================================
--- trunk/data/core/macros/utils.cfg (original)
+++ trunk/data/core/macros/utils.cfg Sun Sep 30 23:09:58 2007
@@ -102,6 +102,25 @@
 {CLEAR_VARIABLE {VAR}}
 #enddef
 # wmlindent: stop ignoring
+
+#define REPEAT NUM CONTENT
+    {VARIABLE REPEAT_i 0}
+
+    [while]
+        [variable]
+            name=REPEAT_i
+            less_than={NUM}
+        [/variable]
+
+        [do]
+            {CONTENT}
+
+            {VARIABLE_OP REPEAT_i add 1}
+        [/do]
+    [/while]
+
+    {CLEAR_VARIABLE REPEAT_i}
+#enddef
 
 #define DEBUG_MSG MSG
     # Emit a debug message.  Meant to be overridden with no-op definition




Related Messages


Powered by MHonArc, Updated Sun Sep 30 23:20:56 2007