I'm trying to make a missile system, everything works fine but after the very first missile that I shoot gets removed then all missiles that I try to shoot just gets removed at the very first time they spawn...
Code:
When unit uses the ability:
Initially turned-off)
Please help...
Code:
When unit uses the ability:
-
Machine Gun
-
Events
-
Unit - A unit Begins casting an ability
-
-
Conditions
-
(Ability being cast) Equal to Machine Gun
-
-
Actions
-
Set MS_Index = (MS_Index + 1)
-
Set MS_Missile_Type[MS_Index] = 1
-
Set MS_MaxTravel_Distance[MS_Index] = 3000.00
-
Set MS_ProjectileSpeed[MS_Index] = 35.00
-
Set MS_CollisionSize[MS_Index] = 10.00
-
Set MS_Shooter[MS_Index] = (Triggering unit)
-
Set MS_Damage[MS_Index] = (Random real number between 3.00 and 10.00)
-
Set MS_DamageAreaRange[MS_Index] = 10.00
-
Set MS_FlyHeight[MS_Index] = (Current flying height of (Triggering unit))
-
Set Unit_Pos = (Position of (Triggering unit))
-
Unit - Create 1 Bullet for (Owner of (Triggering unit)) at Unit_Pos facing (Facing of (Triggering unit)) degrees
-
Set MS_Missile[MS_Index] = (Last created unit)
-
Set MS_OwnerOfMissile[MS_Index] = (Owner of (Last created unit))
-
Custom script: call RemoveLocation(udg_Unit_Pos)
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
MS_Index Greater than or equal to 1
-
-
Then - Actions
-
Trigger - Turn on System <gen>
-
-
Else - Actions
-
-
-
-
System
-
Events
-
Time - Every 0.03 seconds of game time
-
-
Conditions
-
Actions
-
For each (Integer MS_Integer) from 1 to MS_Index, do (Actions)
-
Loop - Actions
-
Set Temp_Point[1] = (Position of MS_Missile[MS_Integer])
-
Set Temp_Point[2] = (Temp_Point[1] offset by MS_ProjectileSpeed[MS_Integer] towards (Facing of MS_Missile[MS_Integer]) degrees)
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
MS_Traveled_Distance[MS_Integer] Greater than or equal to MS_MaxTravel_Distance[MS_Integer]
-
-
Then - Actions
-
Unit - Cause MS_Missile[MS_Integer] to damage circular area after 0.00 seconds of radius MS_DamageAreaRange[MS_Integer] at Temp_Point[1], dealing MS_Damage[MS_Integer] damage of attack type Pierce and damage type Normal
-
Unit - Remove MS_Missile[MS_Integer] from the game
-
-------- ==========Recycle Indexes========== --------
-
Set MS_CollisionSize[MS_Integer] = MS_CollisionSize[MS_Index]
-
Set MS_Damage[MS_Integer] = MS_Damage[MS_Index]
-
Set MS_DamageAreaRange[MS_Integer] = MS_DamageAreaRange[MS_Index]
-
Set MS_FlyHeight[MS_Integer] = MS_FlyHeight[MS_Index]
-
Set MS_Traveled_Distance[MS_Integer] = MS_Traveled_Distance[MS_Index]
-
Set MS_MaxTravel_Distance[MS_Integer] = MS_MaxTravel_Distance[MS_Index]
-
Set MS_Missile[MS_Integer] = MS_Missile[MS_Index]
-
Set MS_Missile_Type[MS_Integer] = MS_Missile_Type[MS_Index]
-
Set MS_OwnerOfMissile[MS_Integer] = MS_OwnerOfMissile[MS_Index]
-
Set MS_ProjectileSpeed[MS_Integer] = MS_ProjectileSpeed[MS_Index]
-
Set MS_Shooter[MS_Integer] = MS_Shooter[MS_Index]
-
Set MS_Integer = (MS_Integer - 1)
-
Set MS_Index = (MS_Index - 1)
-
-------- ========End Recycle Indexes======== --------
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
MS_Index Less than or equal to 0
-
-
Then - Actions
-
Set MS_Index = 0
-
Set MS_Integer = 0
-
Trigger - Turn off (This trigger)
-
-
Else - Actions
-
-
-
Else - Actions
-
Unit - Move MS_Missile[MS_Integer] instantly to Temp_Point[2]
-
Animation - Change MS_Missile[MS_Integer] flying height to MS_FlyHeight[MS_Integer] at 500.00
-
Set MS_Traveled_Distance[MS_Integer] = (MS_Traveled_Distance[MS_Integer] + MS_ProjectileSpeed[MS_Integer])
-
-
-
Set TempGroup = (Units within MS_CollisionSize[MS_Integer] of Temp_Point[2] matching (((((Matching unit) is A structure) Equal to False) and (((Matching unit) is Mechanical) Equal to False)) and (((((Matching unit) is Magic Immune) Equal to False) and (((Matching unit) is de
-
Unit Group - Pick every unit in (Random 1 units from TempGroup) and do (Actions)
-
Loop - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
(Number of units in TempGroup) Greater than 0
-
-
Then - Actions
-
Unit - Cause MS_Missile[MS_Integer] to damage circular area after 0.00 seconds of radius MS_DamageAreaRange[MS_Integer] at Temp_Point[1], dealing MS_Damage[MS_Integer] damage of attack type Pierce and damage type Normal
-
Unit - Remove MS_Missile[MS_Integer] from the game
-
-
Else - Actions
-
-
-
-
-
-
-
