Okay, so I'm trying to make an ability where when a unit is hit by Ranger, arrows fly out of it and hit other enemies. I want it to only hit each enemy once (original target included). What happens right now is it just randomly shoots the correct number of targets. For example, it can do anything from all bonus arrows hitting the original target to none of them.
So this is what I had before I gave up:
Set up variables
Add original target to the "do not shoot" group.
Count how many units are within range of original target
If it's less than the level of the ability (number of potential arrows), set number of extra arrows to that
While 1 < # of arrows
- Attack picked unit, my attempts to make them unique.
Clean up some of the leaks.
I'd love for it to target the 1/2/3/4/5 nearest targets within 800, but I'll settle for a random 1/2/3/4/5 targets. I also want it to only shoot as many arrows as there are targets, so if there are three enemies near the original target and the ability is level 5, it would still only shoot 3 arrows.
Thanks.
So this is what I had before I gave up:
Set up variables
Add original target to the "do not shoot" group.
Count how many units are within range of original target
If it's less than the level of the ability (number of potential arrows), set number of extra arrows to that
While 1 < # of arrows
- Attack picked unit, my attempts to make them unique.
Clean up some of the leaks.
-
Multishot
- Events
-
Conditions
- (Unit-type of (Damage source)) Equal to Ranger (Human)
-
Actions
- Set TempPoint = (Position of (Triggering unit))
- Set TempInt = (Level of Multishot (Human) for (Damage source))
- Set TempIntB = (Custom value of (Triggering unit))
- Unit Group - Add (Triggering unit) to MultishotGroup
- Unit - Set the custom value of (Triggering unit) to 20
- Set TempIntA = 0
- Unit Group - Pick every unit in (Units within 800.00 of TempPoint matching (((Matching unit) belongs to an enemy of (Owner of (Damage source))) Equal to True)) and do (Set TempIntA = (TempIntA + 1))
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- TempInt Equal to 0
- Then - Actions
-
Else - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- TempIntA Less than TempInt
-
Then - Actions
- Set TempInt = TempIntA
- Else - Actions
-
If - Conditions
-
For each (Integer A) from 1 to TempInt, do (Actions)
-
Loop - Actions
-
Unit Group - Pick every unit in (Random 1 units from (Units within 800.00 of TempPoint matching ((Custom value of (Matching unit)) Not equal to 20))) and do (Actions)
-
Loop - Actions
- Unit - Set the custom value of (Picked unit) to 20
- Unit Group - Add (Picked unit) to MultishotGroup
- Unit - Create 1 Dummy (A9) for (Owner of (Damage source)) at TempPoint facing Default building facing degrees
- Unit - Order (Last created unit) to Attack (Picked unit)
- Unit - Add a 0.75 second Generic expiration timer to (Last created unit)
-
Loop - Actions
-
Unit Group - Pick every unit in (Random 1 units from (Units within 800.00 of TempPoint matching ((Custom value of (Matching unit)) Not equal to 20))) and do (Actions)
-
Loop - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
Unit Group - Pick every unit in MultishotGroup and do (Actions)
-
Loop - Actions
- Unit - Set the custom value of (Triggering unit) to TempIntB
-
Loop - Actions
- Unit Group - Remove all units from MultishotGroup
- Custom script: call DestroyGroup ( udg_MultishotGroup )
- Custom script: call RemoveLocation ( udg_TempPoint )
I'd love for it to target the 1/2/3/4/5 nearest targets within 800, but I'll settle for a random 1/2/3/4/5 targets. I also want it to only shoot as many arrows as there are targets, so if there are three enemies near the original target and the ability is level 5, it would still only shoot 3 arrows.
Thanks.