• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[Trigger] How to pick units infront of hero

Status
Not open for further replies.
Level 16
Joined
Mar 26, 2004
Messages
569
Example 1: Shows my current trigger.
  • Set Point B = ((Position of H) offset by 100.00 towards (Facing of Hero) degrees)
  • Unit Group - Pick every unit in (Units within 80.00 range of Point B) and do (Actions)

Example 2: Is how i want it.
  • Unit Group - Pick every unit in (Units from -45.00 to +45.00 degrees facing of Hero) and do (Actions)
EDIT: Further explanation.
Imagine that your hero swings whatever weapon, and hits a few targets standing infront of him/her.
 

Attachments

  • Untitled-1.gif
    Untitled-1.gif
    3.1 KB · Views: 123
Last edited:
Level 23
Joined
Nov 29, 2006
Messages
2,482
You could do it by using the Pit Lord's Cleaving Attack? It works like this...
However it wont work when you attack ranged units. So if that's the reason I
totally understand you.
-----------------------------------------------------------------------------
The other way I can see working would be to create small circular "regions" (since
rectangular wont work in some angles), and then accept it as an approximation.
approximateba7.jpg

EDIT: The last two circles farest away from the hero is not used...

Then I would do:
  • Destructive Chop
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Destructive Chop //Well just change the Event/Conditions/Triggering Unit codes to whatever you want.
    • Actions
      • Set PointA = (Position of (Triggering unit))
      • For each (Integer Count) from 0 to 5, do (Actions)
        • Loop - Actions
          • Set PointB = (PointA offset by ((Real((Count + 1))) x 32.00) towards (Facing of (Triggering unit)) degrees)
          • Set UnitGroupA = (Units within ((Real((Count + 1))) x 32.00) of PointB matching ((((Matching unit) is alive) Equal to True) and (((((Matching unit) is A structure) Equal to False) and (((Matching unit) is in UnitGroupB) Equal to False)) and (((Matching unit) belongs to an ene
          • Unit Group - Add all units of UnitGroupA to UnitGroupB
          • Custom script: call DestroyGroup( udg_UnitGroupA )
      • Unit Group - Pick every unit in UnitGroupB and do (Actions)
        • Loop - Actions
          • Unit - Cause (Triggering unit) to damage (Picked unit), dealing 50.00 damage of attack type Chaos and damage type Normal
          • Special Effect - Create a special effect attached to the chest of (Picked unit) using Objects\Spawnmodels\Undead\UndeadBlood\UndeadBloodNecromancer.mdl
          • Special Effect - Destroy (Last created special effect)
      • Custom script: call DestroyGroup( udg_UnitGroupB )
      • Set UnitGroupB = (Units of type No unit-type)
Well it appears the whole matching code didn't get any room. It should consist following:
  • ((Matching unit) is alive) Equal to True
  • ((Matching unit) is A structure) Equal to False
  • ((Matching unit) is in UnitGroupB) Equal to False
  • ((Matching unit) belongs to an enemy of (Owner of (Triggering unit))) Equal to True
I tested it myself, and it seems to work. (It is not exactly 45 degrees though, but not close from it either). Hope you have any use of it. Feel free to ask if you have something in mind.
/Regards
 
Level 9
Joined
May 27, 2006
Messages
498
Well, instead of picking unit groups, you could just use modified Backstab spell...
Since it's a bit too complicated for me to explain everything by words, here's trigger:

  • blah1
    • Events
      • Unit - A unit does something
    • Conditions
    • Actions
      • Set TempPoint = (Position of (Triggering unit))
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units within 250.00 of TempPoint matching (((Integer((Angle from TempPoint to (Position of (Matching unit))))) Greater than ((Integer((Facing of (Triggering unit)))) - 45)) and (((Integer((Angle from TempPoint to (Position of (Matching unit))))) Lower than (Integer((Facing of (Triggering unit)))) + 45 )))) and do (Actions)
        • Loop - Actions
          • whatever you want to do with picked units
      • Custom script: call RemoveLocation(udg_TempPoint)
This trigger picks all units in range 250 from position of triggering unit in 90 degrees angle.

Sadly, it's impossbie to set the position of matching unit to a variable - it will leak :/
Also, when i used this trigger in my spells, it did not always pick units that were very close to the caster, but it's maybe because it was a unit with great collision using the ability against a unit with very small collision...

An example on how it works:
12099235781421.jpg


EDIT:
Oh, and btw, is there anyone that could explain me how the Angle from PointA to PointB works? I know how to use it, but dont understand how it works xD
 
Level 16
Joined
Mar 26, 2004
Messages
569
Not sure if it's flawless enough, but by the looks, it's just as i wanted ^^ TY!
Ty for trying eccho. :>

EDIT!!:
Encountered an issue. For some reason, it only works when the triggering unit is facing east. :s

  • Unit Group - Pick every unit in (Units within 200.00 of TempPoint matching (((Angle from TempPoint to (Position of (Matching unit))) Greater than ((Facing of Hero) - 45.00)) and ((Angle from TempPoint to (Position of (Matching unit))) Less than ((Facing of Hero) + 45.00)))) and do (Actions)
EDIT2!!:
Seems like it wasn't east, now im uncertain at all of this... only in some random directions this works.
 
Last edited:
Level 23
Joined
Nov 29, 2006
Messages
2,482
Eccho is back with the solution :D
First, and explanation of the Angle calculation, and the reason why it didn't work
Edit: PLease note that the second picture should be rotated 90 degrees to the left
mathzu6.jpg


The trigger should also be in this way to avoid all possible leaks.
  • Angle Trigger
    • Events
      • Unit - A unit Starts the effect of an ability //whatever you want
    • Conditions
      • (Ability being cast) Equal to Holy Light //whatever you want
    • Actions
      • Set PointA = (Position of (Triggering unit))
      • Set UnitGroup = (Units within 200.00 of PointA matching ((((Matching unit) is alive) Equal to True) and ((((Matching unit) is A structure) Equal to False) and (((Matching unit) belongs to an enemy of (Owner of (Triggering unit))) Equal to True))))
      • Unit Group - Pick every unit in UnitGroup and do (Actions)
        • Loop - Actions
          • Set PointB = (Position of (Picked unit))
          • Set Angle = (Angle from PointA to PointB)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Angle Less than 0.00
            • Then - Actions
              • Set Angle = (360.00 + Angle)
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Angle Less than ((Facing of (Triggering unit)) + 45.00)
              • Angle Greater than ((Facing of (Triggering unit)) - 45.00)
            • Then - Actions
              • Special Effect - Create a special effect attached to the chest of (Picked unit) using Objects\Spawnmodels\Naga\NagaBlood\NagaBloodWindserpent.mdl // Do your further codes here
              • Special Effect - Destroy (Last created special effect)
            • Else - Actions
          • Custom script: call RemoveLocation( udg_PointB )
      • Custom script: call RemoveLocation( udg_PointA )
      • Custom script: set udg_PointA = null
      • Custom script: set udg_PointB = null
      • Custom script: call DestroyGroup( udg_UnitGroup )
This worked 100% for me, but if you need anything just ask =)
/Regards
 
Last edited:
Level 9
Joined
May 27, 2006
Messages
498
Damn you, Eccho, now you pwned me :p
Oh and btw, i had similar problem with my ability - your trigger solved it ;O

EDIT:
"You must spread some reputation around before giving it to Eccho again" ...darn. Im too grudgy in giving reps... :p
 
Status
Not open for further replies.
Top