• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Need help with spawn system!

Status
Not open for further replies.
spawning is easy. it depends how u want units to spawn. u should really explain how u want it to be done so ppl can better help u.

u can spawn units in a region every xx seconds. ill use 1 second in this.
there are many other ways. it depends on what u want.
in this u need to change the thing that says no region to ur region variable.
  • spawn
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • Set tempPoint = (Center of No region)
      • Unit - Create 1 Footman for Player 1 (Red) at tempPoint facing 0.00 degrees
      • Custom script: call RemoveLocation( udg_tempPoint)
      • Custom script: set udg_tempPoint = null
 
here is first trigger one sec and ill post the second.
  • spawn
    • Events
      • Time - Every 5.00 seconds of game time
    • Conditions
    • Actions
      • Set tempPoint = (Center of region1)
      • Unit - Create 1 Footman for Neutral Hostile at tempPoint facing 0.00 degrees
      • Unit Group - Add (Last created unit) to unitSpawnGroup
      • Custom script: call RemoveLocation( udg_tempPoint)
      • Custom script: set udg_tempPoint = null
      • Set tempPoint = (Center of region2)
      • Unit - Create 1 Footman for Neutral Hostile at tempPoint facing 0.00 degrees
      • Unit Group - Add (Last created unit) to unitSpawnGroup
      • Custom script: call RemoveLocation( udg_tempPoint)
      • Custom script: set udg_tempPoint = null
      • Set tempPoint = (Center of region3)
      • Unit - Create 1 Footman for Neutral Hostile at tempPoint facing 0.00 degrees
      • Unit Group - Add (Last created unit) to unitSpawnGroup
      • Custom script: call RemoveLocation( udg_tempPoint)
      • Custom script: set udg_tempPoint = null
this trigger orders the unit to attack a random unit in the entire map that is not owned by the neutral hostile units.
  • attack nearby enemies
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • Set tempGroup = (Units in (Playable map area) matching ((Owner of (Matching unit)) Not equal to Neutral Passive))
      • Unit Group - Pick every unit in unitSpawnGroup and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Issued order) Equal to (Order(stop))
            • Then - Actions
              • Unit - Order (Picked unit) to Attack (Random unit from tempGroup)
            • Else - Actions
      • Custom script: call DestroyGroup( udg_tempGroup)
      • Custom script: set udg_tempGroup = null
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
If you can picture the way you want the spawn to work, then we can help you find a way to achieve it.

If the places to build are fixed, you can check if there are Buildings in the area, store regions into an array, and order creeps to attack a random region of those which have buildings in it.

If they're not fixed, you may have to store the buildings inside a UnitGroup and order the creeps to attack a random point around a random unit in the UnitGrup (wich are the buildings). Notice: RANDOM POINT around, and not the building itself.

You may also want to add the creeps to a unit group and check every 10 seconds or so if their current order is "null" or "stop" and order those to attack one of the buildings (as suggested above). This would prevent them to stack up somewhere.
 
If you can picture the way you want the spawn to work, then we can help you find a way to achieve it.

If the places to build are fixed, you can check if there are Buildings in the area, store regions into an array, and order creeps to attack a random region of those which have buildings in it.

If they're not fixed, you may have to store the buildings inside a UnitGroup and order the creeps to attack a random point around a random unit in the UnitGrup (wich are the buildings). Notice: RANDOM POINT around, and not the building itself.

You may also want to add the creeps to a unit group and check every 10 seconds or so if their current order is "null" or "stop" and order those to attack one of the buildings (as suggested above). This would prevent them to stack up somewhere.

i made some triggers for him but he never got back to us yet lol. from what i understand there is 3 regions and he wants the units to spawn there every 5 seconds. then he wants the units to randomly attack enemy units on the map. thats what the second trigger i made does
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
I noticed, we ussualy find some user wich doesn't really know what they want, neither the Wc3 coding capabilities and limits. That's why I commonly try to encourage them to think a bit further and tell us what they need, after that I try to expand what they said, because there's no use in working on triggers for "something" that "wasn't exactly" what they wanted, or that are what they want, but just because they never though about a differente and better way.
 
I noticed, we ussualy find some user wich doesn't really know what they want, neither the Wc3 coding capabilities and limits. That's why I commonly try to encourage them to think a bit further and tell us what they need, after that I try to expand what they said, because there's no use in working on triggers for "something" that "wasn't exactly" what they wanted, or that are what they want, but just because they never though about a differente and better way.

true lol thats a good thing to remember ive made so many triggers that ppl are like no i meant this way. or can u do it this way instead lol.

i tried to explain a little in one of my earlier posts but didnt really get into an in depth description lol
 
Level 12
Joined
Mar 30, 2013
Messages
664
  • Spawning
    • Events
      • Time - Every 5.00 seconds of game time
    • Conditions
    • Actions
      • Set tempPoint = (Center of EVIL SPAWN 1 <gen>)
      • Unit - Create 2 Commandre for Player 1 (Red) at (Center of EVIL SPAWN 1 <gen>) facing 0.00 degrees
      • Unit Group - Add (Last created unit) to UnitSpawnGroup
      • Custom script: call RemoveLocation( udg_tempPoint)
      • Custom script: set udg_tempPoint = null
      • Set tempPoint = (Center of EVIL SPAWN 2 <gen>)
      • Unit - Create 2 Dark Iron Knight for Player 1 (Red) at tempPoint facing 0.00 degrees
      • Unit Group - Add (Last created unit) to UnitSpawnGroup
      • Custom script: call RemoveLocation( udg_tempPoint)
      • Custom script: set udg_tempPoint = null
      • Set tempPoint = (Center of EVIL SPAWN 3 <gen>)
      • Unit - Create 2 Demon Beast Rider for Player 1 (Red) at tempPoint facing 0.00 degrees
      • Unit Group - Add (Last created unit) to UnitSpawnGroup
      • Custom script: call RemoveLocation( udg_tempPoint)
      • Custom script: set udg_tempPoint = null






  • Attacking
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • Set tempGroup = (Units in (Playable map area) matching ((Owner of (Matching unit)) Not equal to Player 1 (Red)))
      • Unit Group - Pick every unit in (Units in (Playable map area)) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Issued order) Equal to (Order(stop))
            • Then - Actions
              • Unit - Order (Picked unit) to Attack (Random unit from tempGroup)
            • Else - Actions
              • Custom script: call DestroyGroup( udg_tempGroup)
              • Custom script: set udg_tempGroup = null
 
problem is here look
  • Spawning
    • Events
      • Time - Every 5.00 seconds of game time
    • Conditions
    • Actions
      • Set tempPoint = (Center of EVIL SPAWN 1 <gen>)
      • Unit - Create 2 Commandre for Player 1 (Red) at (Center of EVIL SPAWN 1 <gen>) facing 0.00 degrees
problem is here...................................................................... ^
change (Center of EVIL SPAWN 1 <gen>) to tempPoint
  • Attacking
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • Set tempGroup = (Units in (Playable map area) matching ((Owner of (Matching unit)) Not equal to Player 1 (Red)))
      • Unit Group - Pick every unit in (Units in (Playable map area)) and do (Actions)
problem is here............................................ ^
change this (Units in (Playable map area)) to UnitSpawnGroup
 
Last edited:
Level 12
Joined
Mar 30, 2013
Messages
664
  • Spawning
    • Events
      • Time - Every 5.00 seconds of game time
    • Conditions
    • Actions
      • Set tempPoint = (Center of EVIL SPAWN 1 <gen>)
      • Unit - Create 2 Commandre for Player 1 (Red) at tempPoint facing 0.00 degrees
      • Unit Group - Add (Last created unit) to UnitSpawnGroup
      • Custom script: call RemoveLocation( udg_tempPoint)
      • Custom script: set udg_tempPoint = null
      • Set tempPoint = (Center of EVIL SPAWN 2 <gen>)
      • Unit - Create 2 Dullahan for Player 1 (Red) at tempPoint facing 0.00 degrees
      • Unit Group - Add (Last created unit) to UnitSpawnGroup
      • Custom script: call RemoveLocation( udg_tempPoint)
      • Custom script: set udg_tempPoint = null
      • Set tempPoint = (Center of EVIL SPAWN 3 <gen>)
      • Unit - Create 2 Demon Beast Rider for Player 1 (Red) at tempPoint facing 0.00 degrees
      • Unit Group - Add (Last created unit) to UnitSpawnGroup
      • Custom script: call RemoveLocation( udg_tempPoint)
      • Custom script: set udg_tempPoint = null
  • Attacking
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • Set tempGroup = (Units in (Playable map area) matching ((Owner of (Matching unit)) Not equal to Player 1 (Red)))
      • Unit Group - Pick every unit in UnitSpawnGroup and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Issued order) Equal to (Order(stop))
            • Then - Actions
              • Unit - Order (Picked unit) to Attack (Random unit from tempGroup)
            • Else - Actions
              • Custom script: call DestroyGroup( udg_tempGroup)
              • Custom script: set udg_tempGroup = null
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
you are doing

Custom script: set udg_tempPoint = null

everytime you remove it (call RemoveLocation(udg_temPoint).

There's no need to null the variable if you're going to set another value to it in the following actions, so, just null just once it at the end of the trigger.
 
Level 12
Joined
Mar 30, 2013
Messages
664
OK!
  • Spawning
    • Events
      • Time - Every 5.00 seconds of game time
    • Conditions
    • Actions
      • Set tempPoint = (Center of EVIL SPAWN 1 <gen>)
      • Unit - Create 2 Commandre for Player 1 (Red) at tempPoint facing 0.00 degrees
      • Unit Group - Add (Last created unit) to UnitSpawnGroup
      • Custom script: call RemoveLocation( udg_tempPoint)
      • Custom script: set udg_tempPoint = null
      • Set tempPoint = (Center of EVIL SPAWN 2 <gen>)
      • Unit - Create 2 Dullahan for Player 1 (Red) at tempPoint facing 0.00 degrees
      • Unit Group - Add (Last created unit) to UnitSpawnGroup
      • Custom script: call RemoveLocation( udg_tempPoint)
      • Custom script: set udg_tempPoint = null
      • Set tempPoint = (Center of EVIL SPAWN 3 <gen>)
      • Unit - Create 2 Demon Beast Rider for Player 1 (Red) at tempPoint facing 0.00 degrees
      • Unit Group - Add (Last created unit) to UnitSpawnGroup
      • Custom script: call RemoveLocation( udg_tempPoint)

  • Spawning
    • Events
      • Time - Every 5.00 seconds of game time
    • Conditions
    • Actions
      • Set tempPoint = (Center of EVIL SPAWN 1 <gen>)
      • Unit - Create 2 Commandre for Player 1 (Red) at tempPoint facing 0.00 degrees
      • Unit Group - Add (Last created unit) to UnitSpawnGroup
      • Custom script: call RemoveLocation( udg_tempPoint)
      • Custom script: set udg_tempPoint = null
      • Set tempPoint = (Center of EVIL SPAWN 2 <gen>)
      • Unit - Create 2 Dullahan for Player 1 (Red) at tempPoint facing 0.00 degrees
      • Unit Group - Add (Last created unit) to UnitSpawnGroup
      • Custom script: call RemoveLocation( udg_tempPoint)
      • Custom script: set udg_tempPoint = null
      • Set tempPoint = (Center of EVIL SPAWN 3 <gen>)
      • Unit - Create 2 Demon Beast Rider for Player 1 (Red) at tempPoint facing 0.00 degrees
      • Unit Group - Add (Last created unit) to UnitSpawnGroup
      • Custom script: call RemoveLocation( udg_tempPoint)

They are spawning... But they dont MOVE.....
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
  • Custom script: set udg_tempPoint = null
You should do that JUST ONCE AT THE END OF THE TRIGGER.

You are creating 2 units but only adding one of them to the group, the last of them. And you never order them to attack anywhere...
 
Level 12
Joined
Mar 30, 2013
Messages
664
  • Spawning
    • Events
      • Time - Every 5.00 seconds of game time
    • Conditions
    • Actions
      • Set tempPoint = (Center of EVIL SPAWN 1 <gen>)
      • Unit - Create 2 Commandre for Player 1 (Red) at tempPoint facing 0.00 degrees
      • Unit Group - Add (Last created unit) to UnitSpawnGroup
      • Custom script: call RemoveLocation( udg_tempPoint)
      • Custom script: set udg_tempPoint = null
      • Set tempPoint = (Center of EVIL SPAWN 2 <gen>)
      • Unit - Create 2 Dullahan for Player 1 (Red) at tempPoint facing 0.00 degrees
      • Unit Group - Add (Last created unit) to UnitSpawnGroup
      • Custom script: call RemoveLocation( udg_tempPoint)
      • Custom script: set udg_tempPoint = null
      • Set tempPoint = (Center of EVIL SPAWN 3 <gen>)
      • Unit - Create 2 Demon Beast Rider for Player 1 (Red) at tempPoint facing 0.00 degrees
      • Unit Group - Add (Last created unit) to UnitSpawnGroup
      • Custom script: call RemoveLocation( udg_tempPoint)

  • Attacking
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • Set tempGroup = (Units in (Playable map area) matching ((Owner of (Matching unit)) Not equal to Player 1 (Red)))
      • Unit Group - Pick every unit in UnitSpawnGroup and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Issued order) Not equal to (Order(stop))
            • Then - Actions
              • Unit - Order (Picked unit) to Attack (Random unit from tempGroup)
            • Else - Actions
              • Custom script: call DestroyGroup( udg_tempGroup)
              • Custom script: set udg_tempPoint = null

Here you go. :vw_death:
 
try to change the attack trigger to this.

and pay more attention to the trigger u messed up this also
  • Custom script: set udg_tempPoint = null
i put the fix in the trigger below.

  • Attacking
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • Set tempGroup = (Units in (Playable map area) matching ((Owner of (Matching unit)) Not equal to Player 1 (Red)))
      • Unit Group - Pick every unit in UnitSpawnGroup and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Issued order) Not equal to (Order(stop))
            • Then - Actions
              • Set tempPoint = (Position of (Random unit from tempGroup))
              • Unit - Order (Picked unit) to Attack-Move To tempPoint
              • Custom script: call RemoveLocation( udg_tempPoint)
              • Custom script: set udg_tempPoint = null
            • Else - Actions
      • Custom script: call DestroyGroup( udg_tempGroup)
      • Custom script: set udg_tempGroup = null
 
Last edited:
Level 20
Joined
Jul 14, 2011
Messages
3,213
The problem lies in HE creating 2 units and adding just THE LAST CREATED UNIT to the Unit Group. If he wants 2 units, he has to loop twice the creation of one unit and adding (last created unit) to the group.

@deathismyfrind you're destroying the group X times inside the Unit Group Loop. You shouldn't. The group destruction and the variable nullying should be done just once at the end of the trigger OUTSIDE any loop, otherwise, you would be destroying and nullying the variable 100 times, if there are 100 units in the unit group.
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
He isn't.

He's creating 2 units, and adding (Last created unit) so, only one of the 2 created units is added to the group.
 
Level 12
Joined
Mar 30, 2013
Messages
664
  • Attacking
  • Events
  • Time - Every 1.00 seconds of game time
  • Conditions
  • Actions
  • Set tempGroup = (Units in (Playable map area) matching ((Owner of (Matching unit)) Not equal to Player 1 (Red)))
  • Unit Group - Pick every unit in UnitSpawnGroup and do (Actions)
  • Loop - Actions
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
  • If - Conditions
  • (Issued order) Not equal to (Order(stop))
  • Then - Actions
  • Set tempPoint = (Position of (Random unit from buildingGroup))
  • Unit - Order (Picked unit) to Attack-Move To tempPoint
  • Custom script: call RemoveLocation( udg_tempPoint)
  • Custom script: set udg_tempPoint = null
  • Else - Actions
  • Custom script: call DestroyGroup( udg_tempGroup)
  • Custom script: set udg_tempGroup = null
should i change to this then?
 
Level 12
Joined
Mar 30, 2013
Messages
664
ok

  • Spawning
    • Events
      • Time - Every 5.00 seconds of game time
    • Conditions
    • Actions
      • Set tempPoint = (Center of EVIL SPAWN 1 <gen>)
      • Unit - Create 2 Commandre for Player 1 (Red) at tempPoint facing 0.00 degrees
      • Unit Group - Add (Last created unit) to UnitSpawnGroup
      • Custom script: call RemoveLocation( udg_tempPoint)
      • Custom script: set udg_tempPoint = null
      • Set tempPoint = (Center of EVIL SPAWN 2 <gen>)
      • Unit - Create 2 Dullahan for Player 1 (Red) at tempPoint facing 0.00 degrees
      • Unit Group - Add (Last created unit) to UnitSpawnGroup
      • Custom script: call RemoveLocation( udg_tempPoint)
      • Custom script: set udg_tempPoint = null
      • Set tempPoint = (Center of EVIL SPAWN 3 <gen>)
      • Unit - Create 2 Demon Beast Rider for Player 1 (Red) at tempPoint facing 0.00 degrees
      • Unit Group - Add (Last created unit) to UnitSpawnGroup
      • Custom script: call RemoveLocation( udg_tempPoint)

  • Attacking
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • Set tempGroup = (Units in (Playable map area) matching ((Owner of (Matching unit)) Not equal to Player 1 (Red)))
      • Unit Group - Pick every unit in UnitSpawnGroup and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Issued order) Not equal to (Order(stop))
            • Then - Actions
              • Set tempPoint = (Position of (Random unit from tempGroup))
              • Unit - Order (Picked unit) to Attack (Random unit from tempGroup)
              • Custom script: call RemoveLocation( udg_tempPoint)
              • Custom script: set udg_tempPoint = null
            • Else - Actions
              • Custom script: call DestroyGroup( udg_tempGroup)
              • Custom script: set udg_tempPoint = null

:fp::goblin_boom:
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
in the Attacking Trigger, put the 2 last functions (call DestroyGroup and set udg_tempPoint = null) OUTSIDE the ELSE block, OUTSIDE the Unit Group loop actions.
 
Also u still never fixed the Spawning trigger. You have to create one unit at a time and add it to the group then create the next and add it to the group.
Like this
Also like previously stated pay attention to the changes we say to do

  • Spawning
    • Events
      • Time - Every 5.00 seconds of game time
    • Conditions
    • Actions
      • Set tempPoint = (Center of EVIL SPAWN 1 <gen>)
      • Unit - Create 1 Commandre for Player 1 (Red) at tempPoint facing 0.00 degrees
      • Unit Group - Add (Last created unit) to UnitSpawnGroup
      • Unit - Create 1 Commandre for Player 1 (Red) at tempPoint facing 0.00 degrees
      • Unit Group - Add (Last created unit) to UnitSpawnGroup
      • Custom script: call RemoveLocation( udg_tempPoint)
      • Custom script: set udg_tempPoint = null
      • Set tempPoint = (Center of EVIL SPAWN 2 <gen>)
      • Unit - Create 1 Dullahan for Player 1 (Red) at tempPoint facing 0.00 degrees
      • Unit Group - Add (Last created unit) to UnitSpawnGroup
      • Unit - Create 1 Dullahan for Player 1 (Red) at tempPoint facing 0.00 degrees
      • Unit Group - Add (Last created unit) to UnitSpawnGroup
      • Custom script: call RemoveLocation( udg_tempPoint)
      • Custom script: set udg_tempPoint = null
      • Set tempPoint = (Center of EVIL SPAWN 3 <gen>)
      • Unit - Create 1 Demon Beast Rider for Player 1 (Red) at tempPoint facing 0.00 degrees
      • Unit Group - Add (Last created unit) to UnitSpawnGroup
      • Unit - Create 1 Demon Beast Rider for Player 1 (Red) at tempPoint facing 0.00 degrees
      • Unit Group - Add (Last created unit) to UnitSpawnGroup
      • Custom script: call RemoveLocation( udg_tempPoint)

  • Attacking
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • Set tempGroup = (Units in (Playable map area) matching ((Owner of (Matching unit)) Not equal to Player 1 (Red)))
      • Unit Group - Pick every unit in UnitSpawnGroup and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Issued order) Not equal to (Order(stop))
            • Then - Actions
              • Set tempPoint = (Position of (Random unit from tempGroup))
              • Unit - Order (Picked unit) to Attack (Random unit from tempGroup)
              • Custom script: call RemoveLocation( udg_tempPoint)
              • Custom script: set udg_tempPoint = null
            • Else - Actions
      • Custom script: call DestroyGroup( udg_tempGroup)
      • Custom script: set udg_tempPoint = null
 
Status
Not open for further replies.
Top