• 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 can i trigger THIS out? (probably easy)

Status
Not open for further replies.
Level 9
Joined
Jan 14, 2008
Messages
366
how do you pick all units standing in a line ??

say you have poin1 and point2. how do i pick all units standing in the line of these points?

definition of "standing in the line" :

their collision size must be upon the line.


anyone can help ??
 
Level 12
Joined
Mar 16, 2006
Messages
992
You could pick points along the line, checking X distance from those points to find units in the path.

More details about what you're trying to do would be helpful.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,258
say you have poin1 and point2. how do i pick all units standing in the line of these points?
Easy with some maths.

their collision size must be upon the line.
Impossiable as far as I know unless you use a database system to allow you to return the collision redius of a unit as there is no native to do that.

Firstly you need to get the distance of the line.
d = SquareRoot((x1-x2)(x1-x2)+(y1-y2)(y1-y2))
Then get the mid point
xm = (x1+x2)/2
ym = (y1+y2)/2

Then enum all units within d/2 radius of the mid point (xm and ym).

This is the most efficent way to get the smallest possiable scoop of units which could lie on the line.

You then need to filter them out, even in the enum conditions to check if they are on the line.

For that algerthim, I would think you would have to check the perpindicular distance of the unit away from the line and if it is less than the collision radius, it is on the line.

This would require you to get the gradient of the line, calculate its position, repeate for the prepindicular line to intersect with it and then work out the point of intersection and then calculate the distance between the point of intersection and the unit.
This overall could be quite recource intensive unless you optimize it heavily so be warned.

Also the unit pick may not pick all the units on the line right at the edges of it or not work at all if the line is too short, but its accuracy should be fine for most of the length of the line ( 98+% of line length).
 
Level 16
Joined
Jul 21, 2008
Messages
1,121
If above solutions were hard try using this:

  • Line detection
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
    • Actions
      • -------- Set events and conditions in the way that most suits you --------
      • -------- First we set points --------
      • Set Point1 = (Position of (Triggering unit))
      • Set Point2 = (Target point of ability being cast)
      • -------- Secondly, we set angles and distance --------
      • Set Angle = (Angle from Point1 to Point2)
      • Set Distance = (Distance between Point1 and Point2)
      • -------- We don't need point2 anymore so we can remove it and use later --------
      • Custom script: call RemoveLocation (udg_Point2)
      • -------- Now detecting units in a line --------
      • For each (Integer A) from 1 to ((Integer(Distance)) / 75), do (Actions)
        • Loop - Actions
          • -------- Reusing Point2 --------
          • Set Point2 = (Point1 offset by ((Real((Integer A))) x 75.00) towards Angle degrees)
          • -------- Picking every unit that stands within 75 distance of the line --------
          • Set TempGroup = (Units within 75.00 of Point2 matching (YourConditions) Equal to True))
          • Custom script: call RemoveLocation (udg_Point2)
          • Unit Group - Add all units of TempGroup to Group
          • Custom script: call DestroyGroup (udg_TempGroup)
      • -------- Now we have all units that stand in line --------
      • -------- They are stored in variable named Group --------
      • Unit Group - Pick every unit in Group and do (Actions)
        • Loop - Actions
          • -------- Your actions here --------
 
Level 7
Joined
Jul 20, 2008
Messages
377
Another way you could do it is to pick every unit within [the line's] range of the point. Next, check for the units that are within say, +5 degrees of the angle of the line and add them to another group. Although that would work more like a cone than a line.

If I come up with another solution, I'll keep you posted.
 
Status
Not open for further replies.
Top