Spawn Limit Trigger Problem

captainrads

New Member
Reaction score
14
EDIT: Fixed, Tom Jones was right; I changed the Integer A in the tankspawnlimit variable to the player number of the triggering unit's owner.

I've got a system where buildings spawn tanks every two minutes with a spawn max of three. The problem is, when a tank dies, the trigger that's supposed to detect it isn't working and the units aren't being replaced. I've tweaked the trigger and the spawn trigger multiple times and I cannot figure out what's wrong...here's the spawn trigger:
Code:
Tank Spawn
    Events
        Time - Every 120.00 seconds of game time
    Conditions
    Actions
        For each (Integer A) from 1 to 12, do (Actions)
            Loop - Actions
                Unit Group - Pick every unit in (Units of type twominspawnbuildingtypearray[(Integer A)]) and do (Actions)
                    Loop - Actions
                        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            If - Conditions
                                ((Picked unit) is in xspawngroup) Equal to True
                            Then - Actions
                                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                    If - Conditions
                                        tankspawnlimit[(Integer A)] Less than 3
                                    Then - Actions
                                        Unit - Create 1 twominspawntype[(Integer A)] for (Owner of (Picked unit)) at (Position of (Picked unit)) facing Default building facing degrees
                                        Unit Group - Add (Last created unit) to twominspawngroup
                                        Set tankspawnlimit[(Integer A)] = (tankspawnlimit[(Integer A)] + 1)
                                    Else - Actions
                            Else - Actions
                                Do nothing
And the dying trigger:
Code:
Destroyed tanks
    Events
        Unit - A unit Dies
    Conditions
    Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                ((Dying unit) is in twominspawngroup) Equal to True
            Then - Actions
                Unit Group - Remove (Dying unit) from twominspawngroup
                Set tankspawnlimit[(Integer A)] = (tankspawnlimit[(Integer A)] - 1)
            Else - Actions
                Do nothing

Anyone see any flaws? The variables are predefined in another trigger and they should work since the units are spawning, but not being replaced.
 

captainrads

New Member
Reaction score
14
In second trigger, this is null.

You need to make a loop for this trigger aswell :3
Do you mean put
For each (Integer A) from 1 to 12, do (Actions)
in the second trigger? If so, it didn't work, another building just spawned an extra fourth tank and the original destroyed still didn't spawn anymore.
 

Tom Jones

N/A
Reaction score
437
In your second trigger, change Integer A to Player number of (Triggering Player).

*Edit*

Trigger:
  • tankspawnlimit[(Integer A)] Less than 3
You do know that it'll only spawn if tankspawnlimit is 0, 1, or 2?
 

captainrads

New Member
Reaction score
14
In your second trigger, change Integer A to Player number of (Triggering Player).

*Edit*

Trigger:
  • tankspawnlimit[(Integer A)] Less than 3
You do know that it'll only spawn if tankspawnlimit is 0, 1, or 2?
You mean change integer A in the added
For each (Integer A) from 1 to 12, do (Actions)
or in the
Set tankspawnlimit[(Integer A)] = (tankspawnlimit[(Integer A)] - 1)
?

Actually, it does spawn up to three tanks...the variable is set to 0 originally.
 

RaiJin

New Member
Reaction score
40
In second trigger, this is null.

You need to make a loop for this trigger aswell :3

an integer can not be nulled o-o-o-o

since integer a is a global variable it might actually be a proper integer o_o unless that was a mistake o-o
 

Tom Jones

N/A
Reaction score
437
You mean change integer A in the added or in the ?

Actually, it does spawn up to three tanks...the variable is set to 0 originally.
What added? All I can see is the originally posted trigger, in that trigger do what I posted and it works. And lastly I just wanted to be sure you were aware of, that it'll only spawn for value 0, 1, and 2.
 

Emu.Man00

New Member
Reaction score
41
an integer can not be nulled o-o-o-o

since integer a is a global variable it might actually be a proper integer o_o unless that was a mistake o-o

Integer A is the predefined variable the WE uses for loops...

It has no value until you give it one..
 

captainrads

New Member
Reaction score
14
What added? All I can see is the originally posted trigger, in that trigger do what I posted and it works. And lastly I just wanted to be sure you were aware of, that it'll only spawn for value 0, 1, and 2.
I wasn't sure if you were referring to the original post or Emu's suggestion...I'll try it when I get to my home computer, I'm not there right now.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top