SC2Mapster Forums

Development > Triggers

[Closed] Unit Spawning Trigger

This thread has been locked by iMisu.

Closed thread - Adequate help received!

  • 11 posts
    #1 Jan 06, 2013 at 07:02 UTC - 0 likes

    need some help with trigger idea.
    I am looking to have a unit created after 5 minutes into the game, and every 15 seconds an additional unit will be spawned, and multiplied by 2 for every player so example.
    if 1 player
    5 min in 1 unit 15 seconds 2 unit 15 seconds 3 unit
    if 2 player
    5 min in 2 unit 15 seconds 4 unit 15 seconds 6 unit

    I know it would be something like

    Events - Time lapse - Elapsed Time is x game seconds
    -
    -
    Actions - Unit - Create Unit facing angle at point x

    How do I keep the trigger running and creating new units with an increasing value ?

    Can some one point me in the right direction for some trigger help and or guides.

    Last edited Jan 07, 2013 by iMisu

    http://img577.imageshack.us/img577/9202/mirr.png
    1/12/2013 Misu

    #2 Jan 06, 2013 at 07:18 UTC - 0 likes

    Make the time elapsed trigger start a timer trigger that spawns units using a variable for the amount of units and increment the variable by the number of players in the game every the periodic trigger runs.

    Assistant Team Leader of "Generic Code" and User of the All-Mighty Data Editor.

    My Amazing Cutscenes

    #3 Jan 06, 2013 at 11:05 UTC - 0 likes

    @Spoolofwhool: Go

    That not the best way really. You'll want a threaded action definition with the 5 minute wait and then a loop (forever i presume or however long you want it to run) that spawns a unit with the amount being arithmetic of 2 times a local integer. Then mod an integer after and a 15 sec wait. You don't need a local integer if your using a pick loop instead the forever.

    Last edited Jan 06, 2013 by hobbidude

    When I want your opinion...I'll give it to you!

    http://www.sc2pod.com/achievement.php?id=13361

    #4 Jan 06, 2013 at 16:33 UTC - 0 likes

    What does that look like in the trigger editor?

    Here is what I am looking for the trigger to do exactly, Sorry I should have been more clear.

    At 5 minutes the trigger will get to work.
    Every 15 seconds a new unit will be added to the amount of units that spawn starting at 1
    For example , 1 unit spawns 15 seconds lapse 2 units spawn 15 seconds lapse 3...
    at 15 Minute the trigger will stop.

    Sorry I havent worked with triggers in a long time and trying to relearn what I have lost. ^.^

    If you could quickly just arrange it in the trigger editor fashion I could understand it a bit better.

    Events - Time lapse 5 minute
    Locals
    Actions - spawn unit

    This sort of arrangement would help alot for me.

    Also I am looking to make this the most resource efficient to run the trigger? I have heard that triggers that run for an extended period of time cause some maps to become sluggish.

    Thanks for the help in advanced

    Misu - <3

    Last edited Jan 06, 2013 by iMisu
    #5 Jan 07, 2013 at 01:55 UTC - 0 likes

    I know some one has seen this thread with an answer to my post, Please a little help would be kindly appreciated.

    #6 Jan 07, 2013 at 02:26 UTC - 0 likes

    @iMisu: Go

    Umm, I think something like this:

    Melee Initialization
        Events
            Timer - Elapsed time is 300.0 Game Time seconds
        Local Variables
            Unit Count = 0 <Integer>
        Conditions
        Actions
            Variable - Set Unit Count = (1 * (Number of players in (Active Players)))
            Player Group - Pick each player in (Active Players) and do (Actions)
                Actions
                    Unit - Create Unit Count (Commentator Bot 1) - Artosis Bot 2000 for player (Picked player) at YOURPOINT facing YOURFACING (No Options)
                    General - Repeat (Actions) forever
                        Actions
                            Variable - Modify Unit Count: + (Number of players in (Active Players))
                            General - Wait 15.0 Game Time seconds
                            Unit - Create Unit Count (Commentator Bot 1) - Artosis Bot 2000 for player (Picked player) at YOURPOINT facing YOURFACING (No Options)
    

    ?

    #7 Jan 07, 2013 at 03:27 UTC - 0 likes

    That wouldn't work, the pick each play action would only run through once, and would stop at the repeat forever loop.

    I would suggest doing a periodic event that works kind of like the above trigger. I'm too lazy to actually make it for u tho :( sorry

    #8 Jan 07, 2013 at 04:21 UTC - 0 likes

    This makes me sad.

    #9 Jan 07, 2013 at 04:46 UTC - 0 likes
    Quote from Oparcus: Go

    That wouldn't work, the pick each play action would only run through once, and would stop at the repeat forever loop.

    I've actually used while loops in a pick each units function and it worked fine, but all you really need to do otherwise is make a pick each player function in the forever loop if this is the case.

    Although having the number of players in a variable as well as only running the modify variable function once is crucial, I didn't really feel it was necessary though as this was a "rough draft" if you will.

    Last edited Jan 07, 2013 by Yaksmanofage
    #10 Jan 07, 2013 at 05:28 UTC - 0 likes

    I have an error with the trigger but it is working properly. Can we fix the error? The error is.

    00:00:15.00 Scri: Trigger Error in 'gt_Hakitmatisua_Func': Event response function 'EventUnit' has no matching event    Near line 64 in gt_Hakitmatisua_Func() in MapScript.galaxy

    It happens right when the trigger is fired.

    Thank for you for the trigger by the way. Much appreciated.

    Last edited Jan 07, 2013 by iMisu
    • trig.png
      Trig
    #11 Jan 07, 2013 at 05:57 UTC - 0 likes

    @iMisu: Go

    Well first of all I thought you wanted to to start at 5 minutes? 300 seconds.

    Regardless make sure you pick all players in active players, and then MOVE the repeating function out and pick all players in the repeating function.

    As well, make sure you move the modification of the variable out of the pick each player in the repeating so it is only changed once.

    Past that I'll have to get back to it later.

  • 11 posts