[Trigger] Help with a multi-shot trigger

Status
Not open for further replies.
Level 3
Joined
Aug 22, 2010
Messages
34
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.

  • 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
          • 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)
      • Unit Group - Pick every unit in MultishotGroup and do (Actions)
        • Loop - Actions
          • Unit - Set the custom value of (Triggering unit) to TempIntB
      • Unit Group - Remove all units from MultishotGroup
      • Custom script: call DestroyGroup ( udg_MultishotGroup )
      • Custom script: call RemoveLocation ( udg_TempPoint )
I'm aware there are more leaks, I'll fix those when I get it working.
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.
 
Level 14
Joined
Aug 30, 2004
Messages
909
I'll try to help you until one of the better people comes along...

The trigger seems more complicated than it needs to be. Your goal is to get a group of the targets you want to hit into a unit-group variable. Then you can just pick every unit in there and do your attack thingy. So why don't you set the group to all enemy units in range matching enemy = to whatever. Then if there are more enemies than the hero has levels of multi-shot, then remove them (you could use the remove unit group from unit group action).

I wasn't sure what you wanted to do with the original target, but if you wanted him in you could make sure he's in by checking before you remove units from the group. If you want him out you can obviously just take him out.

In any case, once you have the unit group with the targets you want, you can just use the Pick every unit in Unit group, action and it will handle that without doubling up on anyone.
 
Level 3
Joined
Aug 22, 2010
Messages
34
it is best to use Damage Detection System by weep with this kind of setup...

as far as I understand from what you're doing;
Level 1 = 2 hits
Level 2 = 3 hits
Level 3 = 4 hits
Level 4 = 5 hits
Level 5 = 6 hits

Level 1 = 1 hits
Level 2 = 2 hits
Level 3 = 3 hits
Level 4 = 4 hits
Level 5 = 5 hits
 
Status
Not open for further replies.
Top