Spawn unit question

tachiKC

New Member
Reaction score
3
Code:
Untitled Trigger 003
    Events
        Time - Every 10.00 seconds of game time
    Conditions
    Actions
        Unit Group - Pick every unit in (Units in spawn_region <gen> owned by Neutral Hostile) and do (Actions)
            Loop - Actions
                Unit Group - Add (Picked unit) to Hostile_Creep_Group
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        (Hostile_Creep_Group is empty) Equal to True
                    Then - Actions
                        Unit - Create 1 Footman for Neutral Hostile at (Center of spawn_region <gen>) facing Default building facing degrees
                    Else - Actions
My idea for this is that if there are units in the region owned by neutral hostile, then nothing happens. However, if there are no creeps owned by neutral hostile (ie they are all dead) then it will create a new set of creeps. However the trigger does not seem to work.

Help would be appreciated. Thanks!
 

Fluffball

Well-Known Member
Reaction score
35
Are you using Hostile_Unit_Group for any other triggers?

Btw, it leaks, and if you're making an rpg that lasts about an hour, this will start to lag a bit. Especially if you're doing the same trigger many times.

Set a Temp_Unit_Group variable = Units in spawn_region owned my neutral hostile.

Just set a Temp_Unit_Group2 variable = units in (Units in spawn_region <gen> owned by Neutral Hostile) and do (Actions).

Then destroy them both with custom code Custom script: call DestroyGroup (udg_Temp_Unit_Group), do the same for the second one.
 
Reaction score
456
Why don't you set the group to a variable, then check if it is empty (Integer Comparison). If it is empty, create a new set of units.
Code:
Picking
    Events
    Conditions
    Actions
        -------- Set the unit group to a variable --------
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                (Number of units in yourGroup) Equal to 0
            Then - Actions
                -------- It's empty --------
            Else - Actions
                -------- It's not empty --------
        -------- Destroy the group --------
        Custom script:   call DestroyGroup(udg_yourGroup)
 

tachiKC

New Member
Reaction score
3
Well I tried that and it doesnt work. If I kill the units inside the region the new units still dont spawn.
Code:
Untitled Trigger 003 Copy
    Events
        Time - Every 10.00 seconds of game time
    Conditions
    Actions
        Set Temp_Unit_Group = (Units in spawn_region <gen> owned by Neutral Hostile)
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                (Number of units in Temp_Unit_Group) Equal to 0
            Then - Actions
                Unit - Create 1 Footman for Neutral Hostile at (Center of spawn_region <gen>) facing Default building facing degrees
                Custom script:   call DestroyGroup (udg_Temp_Unit_Group)
            Else - Actions
 

AceHart

Your Friendly Neighborhood Admin
Reaction score
1,495
How long did you wait?

Dead units may be dead, but they are still units and counted.
Unless you use the "units in ... matching" to get only those that are not dead yet.

The group should be destroyed at the end, not inside the if.
 

tachiKC

New Member
Reaction score
3
Well I figured that yesterday, and set the Decay time to a second just to test things, but that still doesnt seem to do the trick.

*nvm I had set it to 10 seconds. I changed it to 1 second and it worked. So basically the decay time has to be less then the time in the *Every X seconds of game* time I think.

Thanks alot everyone. Although I may have more questions relating to this issue in the future.
 
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