Trigger spawning help

xKxIxNxGx

New Member
Reaction score
3
In this TD we want the spawn to be based off of the bounty you can get per round. lets say 20... We have different units that have different values.. It would randomly pick those units and those values would add up to 20.
Example.
Boss=3
Tanks=2
Flying=2
others=1
so maybe one round a boss(+3) no tanks 5 flying (+10) and 7 other (+7) would equal 20. But. for some reason it works like a charm for the first couple rounds but after words they spawn in groups. So we started to see if we did the trigger right. So we maybe it after the round starts it would tell us exactly what spawned.. but after that few couple rounds the numbers say this, but the spawn doesn't look like what was just said. So we think the actuall getting the group to spawn is correct but the part of spawning gets messed up or something... It's complicated to say, but I hope this helps... Here is the code

Trigger:
  • TRIGGER 004
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Ability being cast) Equal to Next round
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Number of units in (Units in PLYR_Region[(Player number of (Owner of (Casting unit)))] owned by Player 12 (Brown))) Equal to 0
            • Then - Actions
              • Set SPWN_Active[(Player number of (Owner of (Casting unit)))] = True
            • Else - Actions
              • Set SPWN_Active[(Player number of (Owner of (Casting unit)))] = False
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • SPWN_Active[(Player number of (Owner of (Casting unit)))] Equal to False
            • Then - Actions
              • Game - Display to (Player group((Owner of (Casting unit)))) the text: (|cffCC0000Round |cffBCAC00 + ((String(PLYR_ROUND[(Player number of (Owner of (Casting unit)))])) + |r|cffCC0000 is already in progress|r))
              • Skip remaining actions
            • Else - Actions
          • Trigger - Turn off (This trigger)
          • Set SPWN_Active[(Player number of (Owner of (Casting unit)))] = False
          • Set PLYR_ROUND[(Player number of (Owner of (Casting unit)))] = (PLYR_ROUND[(Player number of (Owner of (Casting unit)))] + 1)
          • Set SPWN_Health[(Player number of (Owner of (Casting unit)))] = (((Power((Real(PLYR_ROUND[(Player number of (Owner of (Casting unit)))])), 2.00)) + 4.00) x DIFF_Health[(Player number of (Owner of (Casting unit)))])
          • Multiboard - Set the text for (Last created multiboard) item in column 4, row MLTI_Player_placement[(Player number of (Owner of (Casting unit)))] to (PLYR_Color[(Player number of (Owner of (Casting unit)))] + (String(PLYR_ROUND[(Player number of (Owner of (Casting unit)))])))
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (PLYR_ROUND[(Player number of (Owner of (Casting unit)))] mod Levls_per_BNTY_increese) Equal to 0
            • Then - Actions
              • Set BNTY_Multi[(Player number of (Owner of (Casting unit)))] = (BNTY_Multi[(Player number of (Owner of (Casting unit)))] + 1)
              • Set SPAWN_Extra_Zombies[(Player number of (Owner of (Casting unit)))] = (SPAWN_Extra_Zombies[(Player number of (Owner of (Casting unit)))] + 1)
            • Else - Actions
          • Set SPWN_Total = (SPWN_Gold_per_Round[(Player number of (Owner of (Casting unit)))] + SPAWN_Extra_Zombies[(Player number of (Owner of (Casting unit)))])
          • Game - Display to (All players) the text: (String(SPWN_Total))
          • Set SPWN_Queen_int[1] = (Random integer number between 0 and 1)
          • Set SPWN_Total = (SPWN_Total - (SPWN_Queen_int[1] x SPWN_Type_gold[5]))
          • Set SPWN_Crawler_int[1] = (Random integer number between 0 and ((SPWN_Total / 4) / SPWN_Type_gold[3]))
          • Set SPWN_Total = (SPWN_Total - (SPWN_Crawler_int[1] x SPWN_Type_gold[3]))
          • Set SPWN_Runner_int[1] = (Random integer number between 0 and ((SPWN_Total / 2) / SPWN_Type_gold[2]))
          • Set SPWN_Total = (SPWN_Total - (SPWN_Runner_int[1] x SPWN_Type_gold[2]))
          • Set SPWN_Tank_int[1] = (Random integer number between 0 and ((SPWN_Total / 2) / SPWN_Type_gold[4]))
          • Set SPWN_Total = (SPWN_Total - (SPWN_Tank_int[1] x SPWN_Type_gold[4]))
          • Set SPWN_Flying_int[1] = (Random integer number between 0 and (SPWN_Total / SPWN_Type_gold[6]))
          • Set SPWN_Total = (SPWN_Total - (SPWN_Flying_int[1] x SPWN_Type_gold[6]))
          • Set SPWN_Normal_int[1] = SPWN_Total
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • SPWN_Normal_int[1] Greater than or equal to 1
            • Then - Actions
              • For each (Integer A) from 1 to SPWN_Normal_int[1], do (Actions)
                • Loop - Actions
                  • Unit - Create 1 SPWN_Normal[(Random integer number between 1 and SPWN_Normal_int[0])] for (Owner of (Casting unit)) at SPWN_Start_pt[(Player number of (Owner of (Casting unit)))] facing Default building facing degrees
                  • Unit - Change ownership of (Last created unit) to Player 12 (Brown) and Retain color
                  • Unit - Order (Last created unit) to Move To SPWN_End_pt[(Player number of (Owner of (Casting unit)))]
                  • Unit - Set life of (Last created unit) to SPWN_Health[(Player number of (Owner of (Casting unit)))]
                  • Unit - Set the custom value of (Last created unit) to ((1000 x (Player number of (Owner of (Casting unit)))) + (100 x 1))
              • Set ABT_Number = SPWN_Normal_int[1]
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • SPWN_Runner_int[1] Greater than or equal to 1
            • Then - Actions
              • Wait 0.25 seconds
              • For each (Integer A) from 1 to SPWN_Runner_int[1], do (Actions)
                • Loop - Actions
                  • Unit - Create 1 SPWN_Runner[(Random integer number between 1 and SPWN_Runner_int[0])] for (Owner of (Casting unit)) at SPWN_Start_pt[(Player number of (Owner of (Casting unit)))] facing Default building facing degrees
                  • Unit - Change ownership of (Last created unit) to Player 12 (Brown) and Retain color
                  • Unit - Order (Last created unit) to Move To SPWN_End_pt[(Player number of (Owner of (Casting unit)))]
                  • Unit - Set life of (Last created unit) to SPWN_Health[(Player number of (Owner of (Casting unit)))]
                  • Unit - Set the custom value of (Last created unit) to ((1000 x (Player number of (Owner of (Casting unit)))) + (100 x 2))
              • Set ABT_Number = (ABT_Number + SPWN_Runner_int[1])
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • SPWN_Crawler_int[1] Greater than or equal to 1
            • Then - Actions
              • Wait 0.25 seconds
              • For each (Integer A) from 1 to SPWN_Crawler_int[1], do (Actions)
                • Loop - Actions
                  • Unit - Create 1 SPWN_Crawler[(Random integer number between 1 and SPWN_Crawler_int[0])] for (Owner of (Casting unit)) at SPWN_Start_pt[(Player number of (Owner of (Casting unit)))] facing Default building facing degrees
                  • Unit - Change ownership of (Last created unit) to Player 12 (Brown) and Retain color
                  • Unit - Order (Last created unit) to Move To SPWN_End_pt[(Player number of (Owner of (Casting unit)))]
                  • Unit - Set life of (Last created unit) to SPWN_Health[(Player number of (Owner of (Casting unit)))]
                  • Unit - Set the custom value of (Last created unit) to ((1000 x (Player number of (Owner of (Casting unit)))) + (100 x 3))
              • Set ABT_Number = (ABT_Number + SPWN_Crawler_int[1])
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • SPWN_Flying_int[1] Greater than or equal to 1
            • Then - Actions
              • For each (Integer A) from 1 to SPWN_Flying_int[1], do (Actions)
                • Loop - Actions
                  • Unit - Create 1 SPWN_Flying[(Random integer number between 1 and SPWN_Flying_int[0])] for (Owner of (Casting unit)) at (SPWN_Start_pt[(Player number of (Owner of (Casting unit)))] offset by (-256.00 + (32.00 x (Real((Integer A))))) towards 0.00 degrees) facing Default building facing degrees
                  • Unit - Change ownership of (Last created unit) to Player 12 (Brown) and Retain color
                  • Unit - Order (Last created unit) to Move To SPWN_End_pt[(Player number of (Owner of (Casting unit)))]
                  • Unit - Set life of (Last created unit) to (SPWN_Health[(Player number of (Owner of (Casting unit)))] x 0.85)
                  • Unit - Set the custom value of (Last created unit) to ((1000 x (Player number of (Owner of (Casting unit)))) + (100 x 6))
              • Set ABT_Number = (ABT_Number + SPWN_Flying_int[1])
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • SPWN_Tank_int[1] Greater than or equal to 1
            • Then - Actions
              • Wait 0.25 seconds
              • For each (Integer A) from 1 to SPWN_Tank_int[1], do (Actions)
                • Loop - Actions
                  • Unit - Create 1 SPWN_Tank[(Random integer number between 1 and SPWN_Tank_int[0])] for (Owner of (Casting unit)) at SPWN_Start_pt[(Player number of (Owner of (Casting unit)))] facing Default building facing degrees
                  • Unit - Change ownership of (Last created unit) to Player 12 (Brown) and Retain color
                  • Unit - Order (Last created unit) to Move To SPWN_End_pt[(Player number of (Owner of (Casting unit)))]
                  • Unit - Set life of (Last created unit) to (SPWN_Health[(Player number of (Owner of (Casting unit)))] x 1.50)
                  • Unit - Set the custom value of (Last created unit) to ((1000 x (Player number of (Owner of (Casting unit)))) + (100 x 4))
              • Set ABT_Number = (ABT_Number + SPWN_Tank_int[1])
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • SPWN_Queen_int[1] Greater than or equal to 1
            • Then - Actions
              • Wait 0.25 seconds
              • For each (Integer A) from 1 to SPWN_Queen_int[1], do (Actions)
                • Loop - Actions
                  • Unit - Create 1 SPWN_Queen[(Random integer number between 1 and SPWN_Queen_int[0])] for (Owner of (Casting unit)) at SPWN_Start_pt[(Player number of (Owner of (Casting unit)))] facing Default building facing degrees
                  • Unit - Change ownership of (Last created unit) to Player 12 (Brown) and Retain color
                  • Unit - Set life of (Last created unit) to (SPWN_Health[(Player number of (Owner of (Casting unit)))] x 3.00)
                  • Unit - Order (Last created unit) to Move To SPWN_End_pt[(Player number of (Owner of (Casting unit)))]
                  • Unit - Set the custom value of (Last created unit) to ((1000 x (Player number of (Owner of (Casting unit)))) + (100 x 1))
            • Else - Actions
          • Trigger - Turn on (This trigger)
        • Else - Actions


The Variable ABT_number or w/e is useless so ignore it... We don't think it's the problem either...

The screen shots..
http://img189.imageshack.us/gal.php?g=wc3scrnshot071509232325.jpg
 

Weegee

Go Weegee!
Reaction score
102
Are the units supposed to spawn in groups?

And can you post a picture of it or maybe your map? Or just change your code to wc3 tags? :p
 

xKxIxNxGx

New Member
Reaction score
3
There are suppose to be a mixed amount of units.. not all flying or all one type.. A mixed variety.. and I know randomness does get the all grouped together, that's really not the problem.. The problem is the spawn doesn't match the randomness we did...
Okay, I will get a screen shot.. That should help...

Well when I went to get the screen shot.. It never happnened.. So it must be really rare... I will come back if it occurs again...
 

xKxIxNxGx

New Member
Reaction score
3
two days later. My friend and I have been trying to fix this problem. But we don't see it.. It would be very greatly appreciated if this could be looked at. If anyone has anymore questions please feel free to ask.
 

asipo

New Member
Reaction score
15
Usually...weird problem cause by the loop is because of the Integer A loop

Try to create an integer variable called counter123

Then change the
For each (Integer A) from 1 to SPWN_Tank_int[1], do (Actions)
into
For each (counter123) from 1 to SPWN_Tank_int[1], do (Actions)

Please remember each loop require one unique variable
So if the trigger use 2 loop
Then you need to create counter123 and counter456

Why need to have unique variable for each loop?
The Integer A will collide with each other if there is 2 trigger using it

Hope this help
p/s: I didnt read all the code you put since its too long, just some personal exp from developing with GUI.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top