Pereodic Spawn

Status
Not open for further replies.
Level 7
Joined
Feb 26, 2005
Messages
210
I want to set up a game where when you build a structure, it starts spawning units automatically via the 'create new unit' action. How do I set the spawn up to spawn every x seconds after the building is constructed?

Ie. Say x is five seconds. After you built the building which spawns you must wait exactly five seconds for it to produce a new unit. After that, it will produce a new unit every five seconds periodically.

I do NOT mean 'all units spawn every x seconds of game time'; I mean a unit spawns every five seconds after it was built.
 
Level 37
Joined
Mar 6, 2006
Messages
9,240
Unit finishes constructing

Unit type of constructed unit equal to...

Set Building Location to location of constructed unit
Turn on trigger that spawns units


Then the trigger that has been turned on spawns the units at the location the building was constructed at.



Something like that. I can do the trigger when I get home if you have troubles with it.
 
Level 3
Joined
Jul 17, 2007
Messages
24
Prob with that maker is no arrays and such since need it to be able to be MUI right :p.
Also i did it spitting into two triggers, i know there is ways to do it in 1.
There are 3 variables in this:
1. X = Integer, this is used to get the default amount of farms built (u will edit the farm to the building you want ofcourse)
2. FarmLoc = Point, this has an array, used to find each seperate point for each farm built, helps enable MUI
3. Owner = Integer, this has an array again, helps find out for each farm who owns it :).

I did this quickly so dont hate me for leaks and such :p.
  • Build
    • Events
      • Unit - A unit Finishes construction
    • Conditions
      • (Unit-type of (Constructed structure)) Equal to Farm
    • Actions
      • Set X = (X + 1)
      • Set FarmLoc[X] = (Position of (Constructed structure))
      • Set Owner[X] = (Player number of (Owner of (Constructed structure)))
The second one would be:
  • Periodic Event
    • Events
      • Time - Every 5.00 seconds of game time
    • Conditions
    • Actions
      • For each (Integer A) from 1 to X, do (Actions)
        • Loop - Actions
          • Unit - Create 1 Footman for (Player(Owner[(Integer A)])) at FarmLoc[(Integer A)] facing Default building facing degrees
 
Level 9
Joined
Apr 28, 2009
Messages
538
if you didn't know how to do that, it means you haven't heard of leaks too.

You should be carefull not to have any.
In those kind of triggers are the biggest leaks.
 
Level 7
Joined
Feb 26, 2005
Messages
210
Actually, I am fully aware of leaks and my problem is a little more complicated than people at the moment are assuming. Thanks for posting your concerns anyway.
Prob with that maker is no arrays and such since need it to be able to be MUI right :p.
Also i did it spitting into two triggers, i know there is ways to do it in 1.
There are 3 variables in this:
1. X = Integer, this is used to get the default amount of farms built (u will edit the farm to the building you want ofcourse)
2. FarmLoc = Point, this has an array, used to find each seperate point for each farm built, helps enable MUI
3. Owner = Integer, this has an array again, helps find out for each farm who owns it :).

I did this quickly so dont hate me for leaks and such :p.
  • Build
    • Events
      • Unit - A unit Finishes construction
    • Conditions
      • (Unit-type of (Constructed structure)) Equal to Farm
    • Actions
      • Set X = (X + 1)
      • Set FarmLoc[X] = (Position of (Constructed structure))
      • Set Owner[X] = (Player number of (Owner of (Constructed structure)))
The second one would be:
  • Periodic Event
    • Events
      • Time - Every 5.00 seconds of game time
    • Conditions
    • Actions
      • For each (Integer A) from 1 to X, do (Actions)
        • Loop - Actions
          • Unit - Create 1 Footman for (Player(Owner[(Integer A)])) at FarmLoc[(Integer A)] facing Default building facing degrees
Thanks, but this is not what I want. You have it half-right in that only constructed buildings spawn; but instead of spawning every x seconds for each building; buildings spawn every x standard seconds of game time. I want the player to wait a precise interval after the building is constructed before the first spawn and the same amount of time for each new spawn after the first.

Under your system, if a player builds a structure between standard five second intervals he will receive his first spawn earlier than I want (ie. waiting two-and-a-half seconds after construction instead of five seconds).
 
Status
Not open for further replies.
Top