if somebody else doesn't take over, that is.
I am evil and cunning, and thus I shall take over.
Anyhow, you basically make a few arrays. One is the actual array of units which are the projectiles, and then a new array for each attribute you want to "link" to them.
For example, movement velocities and the owner.
Now, each time a new projectile is created (when a unit casts a spell, for example), you fill a new slot of your projectiles with a new unit, and fill in all your other linked arrays with the needed info.
Each time a projectile is destroyed (if it hit the target, for example), you need to do something with the space it takes in the arrays, else you'll just go over garbage data and your array will also get bigger and bigger for no reason.
The easiest way to solve it is to take the last index in the array and move it into the one that is now garbage.
To make everything actually work (moving projectiles, for example), every time that a projectile is created, you check if the sum of "active" projectiles is 0, if it is you start a global timer, if it isn't, you do nothing.
You will also check if the sum of the active projectiles is 0 when destroying a projectile, because if it is, you can pause the timer.
In the timer's trigger, you loop through all your active projectiles and use whatever linked arrays you want.
Now since this is probably a bit weird, here's a basic example:
Variables (if it isn't too obvious):
Projectile - unit array
Proj_Owner - player array
Proj_Vel_X - real array
Proj_Vel_Y - real array
Proj_Timer - timer
Total - integer
Location - point
-
Create
-
Events
-
Unit - A unit Begins casting an ability
-
Conditions
-
Actions
-
Unit - Create 1 Footman for (Owner of (Triggering unit)) at (Center of (Playable map area)) facing Default building facing degrees
-
Set Projectile[Total] = (Last created unit)
-
Set Proj_Owner[Total] = (Owner of (Triggering unit))
-
-------- In case you don't know what velocity is, it's the distance the unit will move every time the timer runs --------
-
Set Proj_Vel_X[Total] = 3.00
-
Set Proj_Vel_Y[Total] = 2.00
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
Then - Actions
-
Countdown Timer - Start Proj_Timer as a Repeating timer that will expire in 0.04 seconds
-
Else - Actions
-
Set Total = (Total + 1)
-
Loop
-
Events
-
Time - Proj_Timer expires
-
Conditions
-
Actions
-
-------- Arrays start at 0, not 1 as shown in *cough* lame */cough* GUI --------
-
For each (Integer A) from 0 to (Total - 1), do (Actions)
-
Loop - Actions
-
Set Location = (Position of Projectile[(Integer A)])
-
Unit - Move Projectile[(Integer A)] instantly to (Location offset by (Proj_Vel_X[(Integer A)], Proj_Vel_Y[(Integer A)]))
-
Custom script: call RemoveLocation(udg_Location)
-
-------- The next condition will run if a collision is detected, although I'm not going to write here how to check for one (too lazy) --------
-
-------- It can also run based on any other condition you want, of course (time, for example) --------
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
Then - Actions
-
-------- We are replacing all the current projectile's slot with the last projectile's info --------
-
-------- The next time a projectile is created, this last slot will be over-written because we set Total = Total - 1 --------
-
Set Total = (Total - 1)
-
Set Projectile[(Integer A)] = Projectile[Total]
-
Set Proj_Owner[(Integer A)] = Proj_Owner[Total]
-
Set Proj_Vel_X[(Integer A)] = Proj_Vel_X[Total]
-
Set Proj_Vel_Y[(Integer A)] = Proj_Vel_X[Total]
-
Else - Actions
And after writing this, I remember why GUI sucks.