Unit Creating Trigger Problem

Joccaren

You can change this now in User CP.
Reaction score
54
Could someone please help me find what I did wrong in this trigger? I want this trigger to spawn the appropriate number of units of the appropriate type of each players chosen race for each player, however, when I test the map it comes up with the error:
parameter in 'sUnitCreate' (value: 0)
Trigger Error in 'gt_Spawn_Func'.
Could not get 'unit type' from
parameter in 'sUnitCreate' (value: 0)
Thanks to anyone who helps.
Code:
Spawn
    Events
        Game - Map initialization
    Local Variables
        Spawn Number = 0 <Integer[3][3]>
        Player Race = 0 <Integer[6]>
        Spawn Type = No Game Link <Game Link - Unit[3][3]>
        Loop Integer = 0 <Integer[2]>
        Start Point = No Point <Point[6]>
    Conditions
    Actions
        Variable - Set Spawn Number[1][1] = 1
        Variable - Set Spawn Number[1][2] = 11
        Variable - Set Spawn Number[1][3] = 6
        Variable - Set Spawn Number[2][1] = 3
        Variable - Set Spawn Number[2][2] = 8
        Variable - Set Spawn Number[2][3] = 3
        Variable - Set Spawn Number[3][1] = 1
        Variable - Set Spawn Number[3][2] = 3
        Variable - Set Spawn Number[3][3] = 4
        Variable - Set Spawn Type[1][1] = Terran Battlecruiser
        Variable - Set Spawn Type[1][2] = Viking
        Variable - Set Spawn Type[1][3] = Terran Raven
        Variable - Set Spawn Type[2][1] = Zerg Leviathan
        Variable - Set Spawn Type[2][2] = Zerg Corruptor
        Variable - Set Spawn Type[2][3] = Zerg Mutalisk
        Variable - Set Spawn Type[3][1] = Protoss Mothership
        Variable - Set Spawn Type[3][2] = Protoss Pheonix
        Variable - Set Spawn Type[3][3] = Protoss Carrier
        General - For each integer Loop Integer[1] from 1 to 6 with increment 1, do (Actions)
            Actions
                Variable - Set Start Point[Loop Integer[1]] = (Random point in (Playable map area) between 200.0 and 200.0 distance from enemy units of player Loop Integer[1] (prefer points within 200.0 of an enemy building))
                General - If (Conditions) then do (Actions) else do (Actions)
                    If
                        (Race of player Loop Integer[1]) == Protoss
                    Then
                        Variable - Set Player Race[Loop Integer[1]] = 1
                    Else
                        General - If (Conditions) then do (Actions) else do (Actions)
                            If
                                (Race of player Loop Integer[1]) == Terran
                            Then
                                Variable - Set Player Race[Loop Integer[1]] = 2
                            Else
                                General - If (Conditions) then do (Actions) else do (Actions)
                                    If
                                        (Race of player Loop Integer[1]) == Zerg
                                    Then
                                        Variable - Set Player Race[Loop Integer[1]] = 3
                                    Else
                General - For each integer Loop Integer[2] from 1 to 3 with increment 1, do (Actions)
                    Actions
                        Unit - Create Spawn Number[Player Race[Loop Integer[1]]][Loop Integer[2]] Spawn Type[Player Race[Player Race[Loop Integer[1]]]][Loop Integer[2]] for player Loop Integer[1] at Start Point[Loop Integer[1]] facing (Random angle) degrees (No Options)
 

Rusty

New Member
Reaction score
5
your spawn type variable declaration looks messed up. = No Game Link <Game Link - Unit [3] [3] >
just make it a plain unit type array, this looks weird so there might be something wrong here

you should use an if-then-else-if for your race selection instead of nested if statements


it looks like you have an error in the last line, you have Spawn type[Player Race[Payer race[Loop Integer[1]]]]
this will give you the unit type of( race number of the race number of the player number), and i have a feeling that isnt what youre going for here

i dont even know why this isnt giving you an array overflow error
 

Joccaren

You can change this now in User CP.
Reaction score
54
Hmm, what do you mean by a plain unit type array? I have just created a Unit-Type Variable and made it into an array. The 'No Game Link' was the default selection that came up when I created the variable. What do you suggest I change it to?

Thanks for the tip with the If/Then/Else/If, I've only just starting triggering with SCII and have yet to learn the new functions and such.

Thanks for pointing that out, I've fixed that now, but it still pops up with the same error.

What's an array overflow error XD?

Thanks for the help anyway
 

eXirrah

New Member
Reaction score
51
you should do it for active players only. Empty player slots doesn't have
race...

Except of looping through all the payers, loop through only the active one like this:

Player Group - Pick each player in (Active Players) and do (Actions)

@Rusty: When you create array in GUI it creates the array with 1 more element.
It basicly creates 1-based array.

EDIT: I'm not sure but maybe empty slots have race and it is neutral.
The problem with your trigger is that you loop through players 1-6, so
when you test the map only player 1 (you) is there and players 1-6
don't have races, so Player Race[2..6] = 0.
When you create the units you try to access
Spawn Number[Player Race[Loop Integer[1]]][Loop Integer[2]]
which is Spawn Number[0][Loop Integer[2]] for players 2-6 which is
No Game Link and the game must create an unit, it cannot create
nothing and pops the error.
 

Joccaren

You can change this now in User CP.
Reaction score
54
Shouldn't I get my units though? I get none and the eroor just pops up. Thanks for the tip though, I'll add that in.
 

eXirrah

New Member
Reaction score
51
Your second for loop is outside the first for loop so Loop Integer[1] = 6 and
this happens:

Unit - Create Spawn Number[Player Race[6]][Loop Integer[2]] Spawn Type[Player Race[Player Race[6]]][Loop Integer[2]] for player 6 at Start Point[6] facing (Random angle) degrees (No Options)

You try to create the units for player 6.
Bu there is more to it...
Player Race[6] = 0 --> Spawn Number[0][Loop Integer[2] = 0

Spawn Type[Player Race[Player Race[6]]][Loop Integer[2]]

Player Race[Player Race[Loop Integer[1]]] ??? why is that shouldn't it be
Player Race[Loop Integer[1]]

Player Race[Player Race[6]] = Player Race[0] = 0

Spawn Type[0][Loop Integer[2] = No Game Link

So you want the game to spawn three times this:

Unit - Create 0 (No Game Link) for player 6 at Start Point[6] facing (Random angle) degrees (No Options)

and it can't ...

you should put the second loop into the first loop , fix Player
Race[Player Race] thing, make the first loop loop through active players
only.
 

Joccaren

You can change this now in User CP.
Reaction score
54
The second loop is in the first loop, its just a bit hard to tell with the code tags. I can't wait for SCII Tags for GUI as I don't feel the WC3 tags quite fit in.

Also, I have fixed the PlayerRace(PlayerRace(LoopInteger(1))) and it still does not want to work. I'm thinking of taking out all the variables and re-arranging everything and seeing if that works.

Edit:
Yeah, Now it works. I removed all the variables (Except the loop variables and start point variable) and moved the if/then/else/if into the loop and made it spawn the specific units based directly on what the players race was without the variables. Thanks for helping everyone.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top