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.
  • Ghan Ghan:
    Howdy
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though
  • Ghan Ghan:
    Heard Houston got hit pretty bad by storms last night. Hope all is well with TH.
  • The Helper The Helper:
    Power back on finally - all is good here no damage
    +1
  • V-SNES V-SNES:
    Happy Friday!
    +1

      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