Author: cycholka
Date: Sat May 24 16:50:58 2008
New Revision: 26829

URL: http://svn.gna.org/viewcvs/wesnoth?rev=26829&view=rev
Log:
Fix a number of issues related to event spawned off a loop
*Fix variable-by-value usage in macro calls (thx Sapient)
*Replace troublesome boolean-based array validity checking with a separate set 
of flags
*Fix completely screwed event filter in one logic branch
*Fix bad WML in one condition check
*Remove noncritical [+unit] clauses that seem to be treated as separate [unit] 
each
(End of List. I must have had a mind blank when writing this stuff :P )

Modified:
    
trunk/data/campaigns/Under_the_Burning_Suns/scenarios/scen1/outer_villages.cfg

Modified: 
trunk/data/campaigns/Under_the_Burning_Suns/scenarios/scen1/outer_villages.cfg
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/data/campaigns/Under_the_Burning_Suns/scenarios/scen1/outer_villages.cfg?rev=26829&r1=26828&r2=26829&view=diff
==============================================================================
--- 
trunk/data/campaigns/Under_the_Burning_Suns/scenarios/scen1/outer_villages.cfg 
(original)
+++ 
trunk/data/campaigns/Under_the_Burning_Suns/scenarios/scen1/outer_villages.cfg 
Sat May 24 16:50:58 2008
@@ -17,14 +17,14 @@
     name=start
 
     # There is a number of houses inside the oasis and even more tents by the 
necromancers fort, we need to make sure
-    # that these are ignored. To do this we store coordinates 
([store_locations]) of all desert villages (Dd^Vdt) that
+    # that these are ignored. To do this we store coordinates 
([store_locations]) of all desert villages (Dd^Vt) that
     # are not ([not]) within rectangle defined by points 40,1 60,12 (x=40-60, 
y=1-12) or ([or]) rectangle defined by 22,24 43,34 .
     # First rectangle includes all villages near necromancer, the second 
covers whole oasis. These coordinates are stored to
     # array called outer_villages (variable=outer_villages).
 
     [store_locations]
         variable=outer_villages
-        terrain=Dd^Vdt
+        terrain=Dd^Vdt,Dd^Vda
         [not]
             x=40-60
             y=1-12
@@ -34,7 +34,6 @@
             [/or]
         [/not]
     [/store_locations]
-
     # Now for each stored set of coordinates we need to prepare a capture 
event that can be triggered both by good and bad guys.
     # To do this we declare an iterator.
     {VARIABLE i 0}
@@ -62,21 +61,21 @@
             [/variable]
             [then]
                 # We generate a random number between 1 and 100
-                {RANDOM 1..100}
-
+                {VARIABLE_OP fate random 1..100}
+                               {DEBUG_MSG $|fate}
                 # And check if it's lower than a treshold of finding an unit 
that's dependent on diffficulty level
                 # 60% on easy, 50% on normal, 40% on hard. We use preprocesor 
to choose apropriate chance
                 [if]
                     [variable]
-                        name=random
+                        name=fate
 #ifdef EASY
-                        less_than_equal=60
+                        less_than_equal_to=60
 #endif
 #ifdef NORMAL
-                        less_than_equal=50
+                        less_than_equal_to=50
 #endif
 #ifdef HARD
-                        less_than_equal=40
+                        less_than_equal_to=40
 #endif
                     [/variable]
                     [then]
@@ -84,47 +83,39 @@
                         # but we have keep drawing until we hit a nonblank 
record, since some of them will be cleared already
                         # so we prepare a loop that's going to run until our 
check on random variable evaluates to ture.
                         # For this we need to set random to a value that will 
evaluate as false to guarantee at least one loop pass.
-                        {VARIABLE random $elf_pool_counter}
+                        {VARIABLE fate $|elf_pool_counter}
 
                         [while]
                             [variable]
-                                name=elf_pool[$random].type
-                                equals=""
+                                name=fate
+                                                               
equals=$elf_pool_counter
                             [/variable]
                             [do]
                                 # Now we can draw an elf. It's important to 
remember that even though we have $elf_pool_counter
                                 # units, they are indexed from 0 so we need to 
substract 1 from drawn number
-                                {RANDOM 1..$elf_pool_counter}
-                                {VARIABLE_OP random add -1}
-
+                                {VARIABLE_OP fate random 1..$|elf_pool_counter}
+                                {VARIABLE_OP fate add -1}
                                 # Create an unit with data drawn and place it 
on an empty hex by the village, since he village itself is occupied
-                                [unit]
-                                    side=1
-                                    type=$elf_pool[$random].type
-                                    id=$elf_pool[$random].id
-                                    name=$elf_pool[$random].name
-                                    gender=$elf_pool[$random].gender
-                                    x=$x1
-                                    y=$y1
-                                    animate=yes
-
-                                    # Make the unit loyal on easy
-#ifdef EASY
-                                    [modifications]
-                                        {TRAIT_LOYAL}
-                                    [/modifications]
-#endif
-
-                                    # And have it start with 0hp on hard
-#ifdef HARD
-                                    moves=0
-#endif
-                                [/unit]
+                                                               [if]
+                                                                       
[variable]
+                                                                               
name=flagset[$fate].flag
+                                                                               
equals=set
+                                                                       
[/variable]
+                                                                       [then]
+                                                                               
{DEBUG_MSG "skipping"}
+                                                                               
{VARIABLE fate $|elf_pool_counter}
+                                                                       [/then]
+                                                                       [else]
+                                                                               
{VARIABLE flagset[$|fate].flag set}
+                                                                               
{DEBUG_MSG "creating"}
+                                                                               
{LOYAL_UNIT 1 $|elf_pool[$|fate].type $|x1 $|y1 $|elf_pool[$|fate].id 
$|elf_pool[$|fate].name}
+                                                                       [/else]
+                                                               [/if]
                             [/do]
                         [/while]
 
                         # When done remove uniit from the pool
-                        {CLEAR_VARIABLE elf_pool[$random]}
+                        {CLEAR_VARIABLE elf_pool[$|fate]}
 
                         # And write joyful message
                         [message]
@@ -149,8 +140,8 @@
                     name=capture
                     [filter]
                         side=1
-                        x=$outer_villages[$i].x
-                        y=$outer_villages[$i].y
+                        x=$x1
+                        y=$y1
                     [/filter]
                     [message]
                         speaker=unit
@@ -178,7 +169,7 @@
     [if]
         [variable]
             name=elf_pool[$i].type
-            not_equals=""
+            not_equals=$empty
         [/variable]
         [then]
             [unit]


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

Reply via email to