mail[Wesnoth-commits] r20582 - in /trunk/data/campaigns/Under_the_Burning_Suns: scenarios/02_Harsh_Sands.cfg utils/macros.cfg


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

Header


Content

Posted by ravanrooke on September 18, 2007 - 23:49:
Author: rhuvaen
Date: Tue Sep 18 23:48:36 2007
New Revision: 20582

URL: http://svn.gna.org/viewcvs/wesnoth?rev=20582&view=rev
Log:
Cleaned up the unit creation macros (esp random placement), and removed all 
references to the CREATE_UNIT macro from scenario 2.

Modified:
    trunk/data/campaigns/Under_the_Burning_Suns/scenarios/02_Harsh_Sands.cfg
    trunk/data/campaigns/Under_the_Burning_Suns/utils/macros.cfg

Modified: 
trunk/data/campaigns/Under_the_Burning_Suns/scenarios/02_Harsh_Sands.cfg
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/data/campaigns/Under_the_Burning_Suns/scenarios/02_Harsh_Sands.cfg?rev=20582&r1=20581&r2=20582&view=diff
==============================================================================
--- trunk/data/campaigns/Under_the_Burning_Suns/scenarios/02_Harsh_Sands.cfg 
(original)
+++ trunk/data/campaigns/Under_the_Burning_Suns/scenarios/02_Harsh_Sands.cfg 
Tue Sep 18 23:48:36 2007
@@ -396,31 +396,22 @@
 
 #define SCORPION_PLACEMENT
 
-    {RANDOM_PLACEMENT 29 62 2 ({CREATE_UNIT 3 "Giant Scorpion" 1 1 
"Scorpion" (user_description=_"Scorpion"
-    ai_special="guardian")})}
-    {RANDOM_PLACEMENT 29 62 2 ({CREATE_UNIT 3 "Giant Scorpion" 1 1 
"Scorpion" (user_description=_"Scorpion"
-    ai_special="guardian")})}
-    {RANDOM_PLACEMENT 29 62 2 ({CREATE_UNIT 3 "Giant Scorpion" 1 1 
"Scorpion" (user_description=_"Scorpion"
-    ai_special="guardian")})}
-    {RANDOM_PLACEMENT 29 62 2 ({CREATE_UNIT 3 "Giant Scorpion" 1 1 
"Scorpion" (user_description=_"Scorpion"
-    ai_special="guardian")})}
-
+    {RANDOM_PLACEMENT_AREA 29 62 2}
+#ifdef EASY
+    {VARIABLE number_of_scorpions 4}
+#endif
 #ifdef NORMAL
-
-    {RANDOM_PLACEMENT 29 62 2 ({CREATE_UNIT 3 "Giant Scorpion" 1 1 
"Scorpion" (user_description=_"Scorpion"
-    ai_special="guardian")})}
-    {RANDOM_PLACEMENT 29 62 2 ({CREATE_UNIT 3 "Giant Scorpion" 1 1 
"Scorpion" (user_description=_"Scorpion"
-    ai_special="guardian")})}
-
+    {VARIABLE number_of_scorpions 6}
 #endif
 #ifdef HARD
-
-    {RANDOM_PLACEMENT 29 62 2 ({CREATE_UNIT 3 "Giant Scorpion" 1 1 
"Scorpion" (user_description=_"Scorpion"
-    ai_special="guardian")})}
-    {RANDOM_PLACEMENT 29 62 2 ({CREATE_UNIT 3 "Giant Scorpion" 1 1 
"Scorpion" (user_description=_"Scorpion"
-    ai_special="guardian")})}
-
-#endif
+    {VARIABLE number_of_scorpions 8}
+#endif
+    
+    {PLACE_UNITS_RANDOMLY $number_of_scorpions 3 "Giant Scorpion" "Scorpion" 
(ai_special="guardian")}
+
+    {CLEAR_VARIABLE number_of_scorpions}
+    
+    {CLEAR_PLACEMENT_AREA}
 
 #enddef
 
@@ -528,10 +519,6 @@
                     description=Scorpion
                 [/have_unit]
 
-                #!***Some scorpions alive, do nothing***
-                [then]
-                [/then]
-
                 [else]
 
                     [item]
@@ -590,26 +577,12 @@
 
 #define OGRE_PLACEMENT
 
-    {RANDOM_PLACEMENT 17 49 2 ({CREATE_UNIT 3 "Ogre" 1 1 "Hunting Ogre" 
(user_description=_"Hunting Ogre"
-      role="Hunting Ogre"
-      random_traits="no"
-      ai_special="guardian")})}
-    {RANDOM_PLACEMENT 17 49 2 ({CREATE_UNIT 3 "Young Ogre" 1 1 "Hunting 
Ogre" (user_description=_"Hunting Ogre"
-      role="Hunting Ogre"
-      random_traits="no"
-      ai_special="guardian")})}
-    {RANDOM_PLACEMENT 17 49 2 ({CREATE_UNIT 3 "Young Ogre" 1 1 "Hunting 
Ogre" (user_description=_"Hunting Ogre"
-      role="Hunting Ogre"
-      random_traits="no"
-      ai_special="guardian")})}
-    {RANDOM_PLACEMENT 17 49 2 ({CREATE_UNIT 3 "Young Ogre" 1 1 "Hunting 
Ogre" (user_description=_"Hunting Ogre"
-      role="Hunting Ogre"
-      random_traits="no"
-      ai_special="guardian")})}
-    {RANDOM_PLACEMENT 17 49 2 ({CREATE_UNIT 3 "Ogre" 1 1 "Hunting Ogre" 
(user_description=_"Hunting Ogre"
-      role="Hunting Ogre"
-      random_traits="no"
-      ai_special="guardian")})}
+    {RANDOM_PLACEMENT_AREA 17 49 2}
+    
+    {PLACE_UNITS_RANDOMLY 3 3 "Young Ogre" "Hunting Ogre" 
(ai_special="guardian")}
+    {PLACE_UNITS_RANDOMLY 2 3 "Ogre"       "Hunting Ogre" 
(ai_special="guardian")}
+    
+    {CLEAR_PLACEMENT_AREA}
 
 #enddef
 
@@ -691,6 +664,8 @@
         {VARIABLE ogre_thirst 0}
 #endif
         {SETUP_ENEMY_THIRST 3 $ogre_thirst}
+        
+        {VARIABLE ogres_killed 0}
         
         [event]
           name=attack
@@ -838,63 +813,41 @@
     [event]
         name=turn 5
 
-        {RANDOM_PLACEMENT 6 43 3 ({CREATE_UNIT 2 "Trapper" 1 1 "Black 
Lieutenant" (user_description=_"Black Lieutenant"
-          role="Black Lieutenant"
-          random_traits="no"
-          ai_special="guardian")})}
-        {RANDOM_PLACEMENT 6 43 3 ({CREATE_UNIT 2 "Thug" 1 1 "Patrol Bandit" 
(user_description=_"Black Hand Bandit"
-          random_traits="no"
-          ai_special="guardian")})}
-        {RANDOM_PLACEMENT 6 43 3 ({CREATE_UNIT 2 "Thug" 1 1 "Patrol Bandit" 
(user_description=_"Black Hand Bandit"
-          random_traits="no"
-          ai_special="guardian")})}
-        {RANDOM_PLACEMENT 6 43 3 ({CREATE_UNIT 2 "Poacher" 1 1 "Patrol 
Bandit" (user_description=_"Black Hand Bandit"
-          random_traits="no"
-          ai_special="guardian")})}
-        {RANDOM_PLACEMENT 6 43 3 ({CREATE_UNIT 2 "Poacher" 1 1 "Patrol 
Bandit" (user_description=_"Black Hand Bandit"
-          random_traits="no"
-          ai_special="guardian")})}
-
+        {RANDOM_PLACEMENT_AREA 6 43 3}
+        
 #ifdef EASY
-
-        {RANDOM_PLACEMENT 6 43 3 ({CREATE_UNIT 2 "Thug" 1 1 "Patrol Bandit" 
(user_description=_"Black Hand Bandit"
-          random_traits="no"
-          ai_special="guardian")})}
-        {RANDOM_PLACEMENT 6 43 3 ({CREATE_UNIT 2 "Poacher" 1 1 "Patrol 
Bandit" (user_description=_"Black Hand Bandit"
-          random_traits="no"
-          ai_special="guardian")})}
-
-#endif
-
+        {VARIABLE trappers 1}
+        {VARIABLE thugs    3}
+        {VARIABLE poachers 3}
+        {VARIABLE bandits  0}
+#endif
 #ifdef NORMAL
-
-        {RANDOM_PLACEMENT 6 43 3 ({CREATE_UNIT 2 "Bandit" 1 1 "Patrol 
Bandit" (user_description=_"Black Hand Bandit"
-          random_traits="no"
-          ai_special="guardian")})}
-        {RANDOM_PLACEMENT 6 43 3 ({CREATE_UNIT 2 "Thug" 1 1 "Patrol Bandit" 
(user_description=_"Black Hand Bandit"
-          random_traits="no"
-          ai_special="guardian")})}
-        {RANDOM_PLACEMENT 6 43 3 ({CREATE_UNIT 2 "Poacher" 1 1 "Patrol 
Bandit" (user_description=_"Black Hand Bandit"
-          random_traits="no"
-          ai_special="guardian")})}
-
-#endif
-
+        {VARIABLE trappers 1}
+        {VARIABLE thugs    3}
+        {VARIABLE poachers 3}
+        {VARIABLE bandits  1}
+#endif
 #ifdef HARD
-
-        {RANDOM_PLACEMENT 6 43 3 ({CREATE_UNIT 2 "Trapper" 1 1 "Patrol 
Bandit" (user_description=_"Black Hand Bandit"
-          random_traits="no"
-          ai_special="guardian")})}
-        {RANDOM_PLACEMENT 6 43 3 ({CREATE_UNIT 2 "Bandit" 1 1 "Patrol 
Bandit" (user_description=_"Black Hand Bandit"
-          random_traits="no"
-          ai_special="guardian")})}
-        {RANDOM_PLACEMENT 6 43 3 ({CREATE_UNIT 2 "Bandit" 1 1 "Patrol 
Bandit" (user_description=_"Black Hand Bandit"
-          random_traits="no"
-          ai_special="guardian")})}
-
-#endif
+        {VARIABLE trappers 2}
+        {VARIABLE thugs    2}
+        {VARIABLE poachers 2}
+        {VARIABLE bandits  2}
+#endif
+    
+        {PLACE_UNITS_RANDOMLY $trappers 2 "Trapper" "Black Lieutenant"  
(ai_special="guardian")}
+        {PLACE_UNITS_RANDOMLY $thugs    2 "Thug"    "Black Hand Bandit" 
(ai_special="guardian")}
+        {PLACE_UNITS_RANDOMLY $poachers 2 "Poacher" "Black Hand Bandit" 
(ai_special="guardian")}
+        {PLACE_UNITS_RANDOMLY $bandits  2 "Bandit"  "Black Hand Bandit" 
(ai_special="guardian")}
+        
+        {CLEAR_VARIABLE trappers}
+        {CLEAR_VARIABLE thugs}
+        {CLEAR_VARIABLE poachers}
+        {CLEAR_VARIABLE bandits}
+    
+        {CLEAR_PLACEMENT_AREA}
+
         {SETUP_ENEMY_THIRST 2 0}
-        {VARIABLE ogres_killed 0}
+
         [if]
             [have_unit]
                 side=1
@@ -1096,40 +1049,40 @@
 
         {ADD x_coord 7}
         {ADD y_coord -1}
-
-        {RANDOM_PLACEMENT $x_coord $y_coord 3 ({CREATE_UNIT 4 "Skeleton" 1 1 
"Undead Raider" (user_description=_"Undead Raider"
-        role="ElyssaUndead")})}
-        {RANDOM_PLACEMENT $x_coord $y_coord 3 ({CREATE_UNIT 4 "Revenant" 1 1 
"Go'hag" (user_description=_"Go'hag"
-        role="ElyssaUndead")})}
-        {RANDOM_PLACEMENT $x_coord $y_coord 3 ({CREATE_UNIT 4 "Skeleton 
Archer" 1 1 "Undead Raider" (user_description=_"Undead Raider"
-        role="ElyssaUndead")})}
-        {RANDOM_PLACEMENT $x_coord $y_coord 3 ({CREATE_UNIT 4 "Bone Shooter" 
1 1 "Undead Raider" (user_description=_"Undead Raider"
-        role="ElyssaUndead")})}
-
-#ifdef EASY
-
-        {RANDOM_PLACEMENT $x_coord $y_coord 3 ({CREATE_UNIT 4 "Skeleton" 1 1 
"Undead Raider" (user_description=_"Undead Raider"
-        role="ElyssaUndead")})}
-        {RANDOM_PLACEMENT $x_coord $y_coord 3 ({CREATE_UNIT 4 "Skeleton 
Archer" 1 1 "Undead Raider" (user_description=_"Undead Raider"
-        role="ElyssaUndead")})}
-
+        
+        {RANDOM_PLACEMENT_AREA $x_coord $y_coord 3}
+        
+#ifdef EASY        
+        {VARIABLE skeletons 2}
+        {VARIABLE archers   2}
+        {VARIABLE shooters  1}
+        {VARIABLE revenants 0}
 #endif
 #ifdef NORMAL
-
-        {RANDOM_PLACEMENT $x_coord $y_coord 3 ({CREATE_UNIT 4 "Revenant" 1 1 
"Undead Raider" (user_description=_"Undead Raider"
-        role="ElyssaUndead")})}
-        {RANDOM_PLACEMENT $x_coord $y_coord 3 ({CREATE_UNIT 4 "Skeleton 
Archer" 1 1 "Undead Raider" (user_description=_"Undead Raider"
-        role="ElyssaUndead")})}
-
+        {VARIABLE skeletons 1}
+        {VARIABLE archers   2}
+        {VARIABLE shooters  1}
+        {VARIABLE revenants 1}
 #endif
 #ifdef HARD
-
-        {RANDOM_PLACEMENT $x_coord $y_coord 3 ({CREATE_UNIT 4 "Revenant" 1 1 
"Undead Raider" (user_description=_"Undead Raider"
-        role="ElyssaUndead")})}
-        {RANDOM_PLACEMENT $x_coord $y_coord 3 ({CREATE_UNIT 4 "Bone Shooter" 
1 1 "Undead Raider" (user_description=_"Undead Raider"
-        role="ElyssaUndead")})}
-
-#endif
+        {VARIABLE skeletons 1}
+        {VARIABLE archers   1}
+        {VARIABLE shooters  2}
+        {VARIABLE revenants 1}
+#endif
+
+        {PLACE_UNITS_RANDOMLY 1          4 "Revenant"         "Go'hag"       
 (role="ElyssaUndead")}
+        {PLACE_UNITS_RANDOMLY $skeletons 4 "Skeleton"         "Undead 
Raider" (role="ElyssaUndead")}
+        {PLACE_UNITS_RANDOMLY $archers   4 "Skeleton Archer"  "Undead 
Raider" (role="ElyssaUndead")}
+        {PLACE_UNITS_RANDOMLY $revenants 4 "Revenant"         "Undead 
Raider" (role="ElyssaUndead")}
+        {PLACE_UNITS_RANDOMLY $shooters  4 "Bone Shooter"     "Undead 
Raider" (role="ElyssaUndead")}
+
+        {CLEAR_VARIABLE skeletons}
+        {CLEAR_VARIABLE archers}
+        {CLEAR_VARIABLE shooters}
+        {CLEAR_VARIABLE revenants}
+        
+        {CLEAR_PLACEMENT_AREA}
 
         {CLEAR_VARIABLE x_coord}
         {CLEAR_VARIABLE y_coord}
@@ -1322,17 +1275,13 @@
                     role=wraith
                 [/unit]
 
-                {CREATE_UNIT 4 "Ghost" 33 25 "Honor Guard" 
(user_description=_"Honor Guard"
-                role=Wraith)}
-                {CREATE_UNIT 4 "Ghost" 35 25 "Honor Guard" 
(user_description=_"Honor Guard"
-                role=Wraith)}
+                {RANDOM_TRAIT_UNIT 4 "Ghost" 33 25 "Honor Guard" 
(role=Wraith)}
+                {RANDOM_TRAIT_UNIT 4 "Ghost" 35 25 "Honor Guard" 
(role=Wraith)}
 
 #ifdef EASY
 #else
-                {CREATE_UNIT 4 "Ghost" 33 26 "Honor Guard" 
(user_description=_"Honor Guard"
-                role=Wraith)}
-                {CREATE_UNIT 4 "Ghost" 35 26 "Honor Guard" 
(user_description=_"Honor Guard"
-                role=Wraith)}
+                {RANDOM_TRAIT_UNIT 4 "Ghost" 33 26 "Honor Guard" 
(role=Wraith)}
+                {RANDOM_TRAIT_UNIT 4 "Ghost" 35 26 "Honor Guard" 
(role=Wraith)}
 #endif
 
                 [message]
@@ -1389,38 +1338,27 @@
 
             #!***Do ogre event***
             [else]
-
-                {RANDOM_PLACEMENT 34 27 3 ({CREATE_UNIT 3 "Ogre" 1 1 "Ogre 
Nomad" (user_description=_"Ogre Nomad"
-                  random_traits="no")})}
-                {RANDOM_PLACEMENT 34 27 3 ({CREATE_UNIT 3 "Young Ogre" 1 1 
"Ogre Nomad" (user_description=_"Ogre Nomad"
-                  random_traits="no")})}
-
+            
+                {RANDOM_PLACEMENT_AREA 34 27 3}
 #ifdef EASY
-
-                {RANDOM_PLACEMENT 34 27 3 ({CREATE_UNIT 3 "Young Ogre" 1 1 
"Ogre Nomad" (user_description=_"Ogre Nomad"
-                  random_traits="no")})}
-                {RANDOM_PLACEMENT 34 27 3 ({CREATE_UNIT 3 "Young Ogre" 1 1 
"Ogre Nomad" (user_description=_"Ogre Nomad"
-                  random_traits="no")})}
-
-#endif
-
+                {VARIABLE ogres 1}
+                {VARIABLE young_ogres 3}
+#endif
 #ifdef NORMAL
-
-                {RANDOM_PLACEMENT 34 27 3 ({CREATE_UNIT 3 "Young Ogre" 1 1 
"Ogre Nomad" (user_description=_"Ogre Nomad"
-                  random_traits="no")})}
-                {RANDOM_PLACEMENT 34 27 3 ({CREATE_UNIT 3 "Ogre" 1 1 "Ogre 
Nomad" (user_description=_"Ogre Nomad"
-                  random_traits="no")})}
-
-#endif
-
+                {VARIABLE ogres 2}
+                {VARIABLE young_ogres 2}
+#endif
 #ifdef HARD
-
-                {RANDOM_PLACEMENT 34 27 3 ({CREATE_UNIT 3 "Ogre" 1 1 "Ogre 
Nomad" (user_description=_"Ogre Nomad"
-                  random_traits="no")})}
-                {RANDOM_PLACEMENT 34 27 3 ({CREATE_UNIT 3 "Ogre" 1 1 "Ogre 
Nomad" (user_description=_"Ogre Nomad"
-                  random_traits="no")})}
-
-#endif
+                {VARIABLE ogres 3}
+                {VARIABLE young_ogres 1}
+#endif
+                {PLACE_UNITS_RANDOMLY $ogres        3 "Ogre"        "Ogre 
Nomad" (random_traits="no")}
+                {PLACE_UNITS_RANDOMLY $young_ogres  3 "Young Ogre"  "Ogre 
Nomad" (random_traits="no")}
+
+                {CLEAR_VARIABLE ogres}
+                {CLEAR_VARIABLE young_ogres}
+                
+                {CLEAR_PLACEMENT_AREA}
 
                 [message]
                     type=Ogre
@@ -2387,8 +2325,7 @@
                      [/filter_adjacent_location]
                    [/have_location]
                    [else]
-                     {CREATE_UNIT 4 "Ghost" $spawn[$random].x 
$spawn[$random].y "Lost Soul" (user_description=_"Lost Soul"
-                         role=LostSoul)}
+                     {RANDOM_TRAIT_UNIT 4 "Ghost" $spawn[$random].x 
$spawn[$random].y "Lost Soul" (role="Lost Soul")}
                      {VARIABLE_OP ghosts_already_spawned add 1}
                    [/else]
                  [/if]

Modified: trunk/data/campaigns/Under_the_Burning_Suns/utils/macros.cfg
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/data/campaigns/Under_the_Burning_Suns/utils/macros.cfg?rev=20582&r1=20581&r2=20582&view=diff
==============================================================================
--- trunk/data/campaigns/Under_the_Burning_Suns/utils/macros.cfg (original)
+++ trunk/data/campaigns/Under_the_Burning_Suns/utils/macros.cfg Tue Sep 18 
23:48:36 2007
@@ -1,5 +1,68 @@
 #textdomain wesnoth-utbs
 # The file contains useful macros I use within the campaign
+
+#define RANDOM_TRAIT_UNIT SIDE TYPE X Y NAME OTHER
+    [unit]
+        side={SIDE}
+        type={TYPE}
+        x={X}
+        y={Y}
+        description={NAME}
+        user_description=_{NAME}
+        upkeep=full
+        animate=yes
+        {OTHER}
+    [/unit]
+#enddef
+
+#define RANDOM_PLACEMENT_AREA X Y RADIUS
+# set a placement area for subsequent random placement of units
+    [store_locations]
+        x,y={X},{Y}
+        radius={RADIUS}
+        variable=random_placement_locations
+    [/store_locations]
+    {VARIABLE_OP random_string format 
"0..$random_placement_locations.length"}
+#enddef
+
+#define PLACE_UNITS_RANDOMLY NUM SIDE TYPE NAME OTHER
+    {VARIABLE number {NUM}}
+    {VARIABLE i 0}
+    [while]
+      [variable]
+        name=i
+        less_than=$number
+      [/variable]
+      [do]
+        {RANDOM $random_string}
+        {VARIABLE random_placement_x $random_placement_locations[$random].x}
+        {VARIABLE random_placement_y $random_placement_locations[$random].y}
+
+        [unit]
+          side={SIDE}
+          type={TYPE}
+          x=$random_placement_x
+          y=$random_placement_y
+          description={NAME}
+          role={NAME}
+          user_description=_{NAME}
+          upkeep=full
+          animate=yes
+          {OTHER}
+        [/unit]
+        
+        {VARIABLE_OP i add 1}
+      [/do]
+    [/while]
+#enddef
+
+#define CLEAR_PLACEMENT_AREA
+    {CLEAR_VARIABLE random_string}
+    {CLEAR_VARIABLE random_placement_x}
+    {CLEAR_VARIABLE random_placement_y}
+    {CLEAR_VARIABLE random_placement_locations}
+#enddef
+
 
 #!***Macro to random place unit within area***
 #define RANDOM_PLACEMENT X Y RADIUS UNIT




Related Messages


Powered by MHonArc, Updated Wed Sep 19 00:40:19 2007