Timer Arrays

zaqer50

TH.net Regular
Reaction score
3
Here's my problem: I've got an integer (CopterNumber) that keeps track of how many times my spell has been cast so that it makes sure it's always giving the commands to the proper variables. All the variables are arrays that use CopterNumber as their Index(I think this is what I should be doing).

So it works for all the code, besides when it comes to the timers. It lets me use CopterNumber when I'm creating the timer, but not to detect when that timer expires(The lines of code are bolded). I have no idea. I tried making CopterNumber a Real variable, and then converting it to an integer, but it won't let me do that either.

Any help is much appreciated and I'll give some rep to anyone who manages to help me

Code:
Fly In
    Events
        Time - Elapsed game time is 5.00 seconds
    Conditions
    Actions
        -------- Setup Variables and Create Copter --------
        Unit - Create 1 Flying Machine for CopterOwner[CopterNumber] at (Target[CopterNumber] offset by 1000.00 towards (Random real number between 0.00 and 360.00) degrees) facing Target[CopterNumber]
        Set Copter[CopterNumber] = (Last created unit)
        Unit - Turn collision for Copter[CopterNumber] Off
        Set Angle[CopterNumber] = (Angle from Target[CopterNumber] to (Position of Copter[CopterNumber]))
        Animation - Change Copter[CopterNumber] flying height to 1000.00 at 0.00
        -------- Attack Run --------
        Unit - Order Copter[CopterNumber] to Move To Target[CopterNumber]
        Animation - Change Copter[CopterNumber] flying height to 280.00 at 500.00
        [B]Countdown Timer - Start StartFlyOff as a One-shot timer that will expire in 1.50 seconds[/B]


Code:
Fly Out
    Events
        [B]Time - StartFlyOff[Index] expires[/B]
    Conditions
    Actions
        Unit - Order Copter[CopterNumber] to Move To (Target[CopterNumber] offset by 1000.00 towards (Angle[CopterNumber] + 180.00) degrees)
        Animation - Change Copter[CopterNumber] flying height to 1000.00 at 400.00
 

insaneownage

New Member
Reaction score
6
StartFlyOff is an array, right?

Are the different timers in the array for different players? If so, you will probably need a separate trigger for each player.
 

zaqer50

TH.net Regular
Reaction score
3
> StartFlyOff is an array, right?

Yep.

>Are the different timers in the array for different players? If so, you will probably need a separate trigger for each player.

I'm using arrays so that if more then one unit casts the spell at once, the orders won't start mixing up and whatnot.
 

AceHart

Your Friendly Neighborhood Admin
Reaction score
1,497
> Time - StartFlyOff[Index] expires

Events aren't dynamic.
This registers exactly one timer, the one with whatever value "Index" starts with when the map loads.
 

zaqer50

TH.net Regular
Reaction score
3
So something like...

Code:
Fly In
    Events
        Time - Elapsed game time is 5.00 seconds
    Conditions
    Actions
        -------- Setup Variables and Create Copter --------
        Unit - Create 1 Flying Machine for CopterOwner[CopterNumber] at (Target[CopterNumber] offset by 1000.00 towards (Random real number between 0.00 and 360.00) degrees) facing Target[CopterNumber]
        Set Copter[CopterNumber] = (Last created unit)
        Unit - Turn collision for Copter[CopterNumber] Off
        Set Angle[CopterNumber] = (Angle from Target[CopterNumber] to (Position of Copter[CopterNumber]))
        Animation - Change Copter[CopterNumber] flying height to 1000.00 at 0.00
        -------- Attack Run --------
        Unit - Order Copter[CopterNumber] to Move To Target[CopterNumber]
        Animation - Change Copter[CopterNumber] flying height to 280.00 at 500.00
        [B]Trigger - Turn on Fly Out <gen>[/B]


Fly Out is initially off.

Code:
Fly Out
    Events
        Time - Every 0.50 seconds of game time
    Conditions
    Actions
        Set StartFlyOff[CopterNumber] = (StartFlyOff[CopterNumber] + 1.00)
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                StartFlyOff[CopterNumber] Equal to 3.00
            Then - Actions
                Unit - Order Copter[CopterNumber] to Move To (Target[CopterNumber] offset by 1000.00 towards (Angle[CopterNumber] + 180.00) degrees)
                Animation - Change Copter[CopterNumber] flying height to 1000.00 at 400.00
                Trigger - Turn off (This trigger)
            Else - Actions
                Do nothing


This works fine everytime except the first time the spell is cast. For some reason, the first time it's cast, two Copter's are created, the first one follows the actions of the first trigger and the second one follows the actions of the second
 
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