Ok so I'm working on a spell that will spawn a unit which, after 15 seconds, damages 7 enemy nearest to it.
In the trigger below I can't seems to get the 7 closest one correctly, it sometimes chooses the one that is further away.
Please help me check if I made any mistakes or done anything wrong.
Thanks in advance
In the trigger below I can't seems to get the 7 closest one correctly, it sometimes chooses the one that is further away.
-
B1 Resonating Crystal Loop
-
Events
- Time - Every 0.10 seconds of game time
- Conditions
-
Actions
- Set Boss1_RC_Timer1 = (Boss1_RC_Timer1 + 1)
- Set Boss1_RC_TempPos1 = (Position of Boss1_RC_Crystal1)
- Cinematic - Ping minimap for (All players) at Boss1_RC_TempPos1 for 0.10 seconds, using a Warning ping of color (100.00%, 100.00%, 100.00%)
-
For each (Integer A) from 1 to 7, do (Actions)
-
Loop - Actions
- Set Boss1_RC_Real1[(Integer A)] = 99999.00
-
Loop - Actions
-
Unit Group - Pick every unit in Game_HeroGroup and do (Actions)
-
Loop - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- ((Picked unit) is alive) Equal to True
-
Then - Actions
- Set Boss1_RC_TempPos2 = (Position of (Picked unit))
- Set Boss1_RC_Real1[0] = (Distance between Boss1_RC_TempPos1 and Boss1_RC_TempPos2)
- Set Boss1_RC_Index = 1
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- Boss1_RC_Real1[0] Less than Boss1_RC_Real1[Boss1_RC_Index]
- Boss1_RC_Target1[Boss1_RC_Index] Not equal to (Picked unit)
-
Then - Actions
- Set Boss1_RC_Real1[Boss1_RC_Index] = Boss1_RC_Real1[0]
- Set Boss1_RC_Target1[Boss1_RC_Index] = (Picked unit)
-
Else - Actions
- Set Boss1_RC_Index = 2
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- Boss1_RC_Real1[0] Less than Boss1_RC_Real1[Boss1_RC_Index]
- Boss1_RC_Target1[Boss1_RC_Index] Not equal to (Picked unit)
-
Then - Actions
- Set Boss1_RC_Real1[Boss1_RC_Index] = Boss1_RC_Real1[0]
- Set Boss1_RC_Target1[Boss1_RC_Index] = (Picked unit)
-
Else - Actions
- Set Boss1_RC_Index = 3
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- Boss1_RC_Real1[0] Less than Boss1_RC_Real1[Boss1_RC_Index]
- Boss1_RC_Target1[Boss1_RC_Index] Not equal to (Picked unit)
-
Then - Actions
- Set Boss1_RC_Real1[Boss1_RC_Index] = Boss1_RC_Real1[0]
- Set Boss1_RC_Target1[Boss1_RC_Index] = (Picked unit)
-
Else - Actions
- Set Boss1_RC_Index = 4
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- Boss1_RC_Real1[0] Less than Boss1_RC_Real1[Boss1_RC_Index]
- Boss1_RC_Target1[Boss1_RC_Index] Not equal to (Picked unit)
-
Then - Actions
- Set Boss1_RC_Real1[Boss1_RC_Index] = Boss1_RC_Real1[0]
- Set Boss1_RC_Target1[Boss1_RC_Index] = (Picked unit)
-
Else - Actions
- Set Boss1_RC_Index = 5
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- Boss1_RC_Real1[0] Less than Boss1_RC_Real1[Boss1_RC_Index]
- Boss1_RC_Target1[Boss1_RC_Index] Not equal to (Picked unit)
-
Then - Actions
- Set Boss1_RC_Real1[Boss1_RC_Index] = Boss1_RC_Real1[0]
- Set Boss1_RC_Target1[Boss1_RC_Index] = (Picked unit)
-
Else - Actions
- Set Boss1_RC_Index = 6
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- Boss1_RC_Real1[0] Less than Boss1_RC_Real1[Boss1_RC_Index]
- Boss1_RC_Target1[Boss1_RC_Index] Not equal to (Picked unit)
-
Then - Actions
- Set Boss1_RC_Real1[Boss1_RC_Index] = Boss1_RC_Real1[0]
- Set Boss1_RC_Target1[Boss1_RC_Index] = (Picked unit)
-
Else - Actions
- Set Boss1_RC_Index = 7
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- Boss1_RC_Real1[0] Less than Boss1_RC_Real1[Boss1_RC_Index]
- Boss1_RC_Target1[Boss1_RC_Index] Not equal to (Picked unit)
-
Then - Actions
- Set Boss1_RC_Real1[Boss1_RC_Index] = Boss1_RC_Real1[0]
- Set Boss1_RC_Target1[Boss1_RC_Index] = (Picked unit)
- Else - Actions
-
If - Conditions
-
If - Conditions
-
If - Conditions
-
If - Conditions
-
If - Conditions
-
If - Conditions
-
If - Conditions
- Else - Actions
-
If - Conditions
- Custom script: call RemoveLocation(udg_Boss1_RC_TempPos2)
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
Loop - Actions
- Custom script: call RemoveLocation(udg_Boss1_RC_TempPos1)
-
For each (Integer B) from 1 to 7, do (Actions)
-
Loop - Actions
- Set Boss1_RC_Real1[(Integer B)] = 0.00
- Unit Group - Add Boss1_RC_Target1[(Integer B)] to Boss1_RC_Group1
-
Loop - Actions
- Set Boss1_RC_Int = 0
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- Boss1_RC_Timer1 Equal to 150
-
Then - Actions
- Set Boss1_RC_TempPos1 = (Position of Boss1_RC_Crystal1)
- Special Effect - Create a special effect at Boss1_RC_TempPos1 using war3mapImported\Arcane Explosion.mdx
- Special Effect - Destroy (Last created special effect)
- Special Effect - Create a special effect at Boss1_RC_TempPos1 using war3mapImported\NewDirtEXNofire.mdx
- Special Effect - Destroy (Last created special effect)
-
Unit Group - Pick every unit in Boss1_RC_Group1 and do (Actions)
-
Loop - Actions
- Special Effect - Create a special effect attached to the origin of (Picked unit) using war3mapImported\NewDirtEXNofire.mdx
- Special Effect - Destroy (Last created special effect)
- Set Boss1_RC_TempPos2 = (Position of (Picked unit))
- Set Boss1_RC_Real1[0] = (Distance between Boss1_RC_TempPos1 and Boss1_RC_TempPos2)
- Unit - Cause Morchok 0026 <gen> to damage (Picked unit), dealing (23000.00 + (180.00 x Boss1_RC_Real1[0])) damage of attack type Spells and damage type Normal
- Custom script: call RemoveLocation(udg_Boss1_RC_TempPos2)
-
Loop - Actions
-
For each (Integer B) from 1 to 7, do (Actions)
-
Loop - Actions
- Custom script: set udg_Boss1_RC_Target1[bj_forLoopBIndex] = null
-
Loop - Actions
- Unit - Remove Boss1_RC_Crystal1 from the game
- Custom script: call RemoveLocation(udg_Boss1_RC_TempPos1)
- Trigger - Turn off (This trigger)
-
Else - Actions
-
Unit Group - Pick every unit in Boss1_RC_Group1 and do (Actions)
-
Loop - Actions
- Special Effect - Create a special effect attached to the origin of (Picked unit) using Abilities\Spells\Human\DispelMagic\DispelMagicTarget.mdl
- Special Effect - Destroy (Last created special effect)
-
Loop - Actions
-
Unit Group - Pick every unit in Boss1_RC_Group1 and do (Actions)
-
If - Conditions
- Unit Group - Remove all units from Boss1_RC_Group1
-
Events
Thanks in advance