• 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.
  • 💡 We're thrilled to announce that our upcoming texturing contest is in the works, and we're eager to hear your suggestions! Please take this opportunity to share your ideas in this theme discussion thread for the Texturing Contest #34!
  • 🏆 Hive's 7th HD Modeling Contest: Icecrown Creature is now open! The frozen wastes of Icecrown are home to some of Azeroth’s most terrifying and resilient creatures. For this contest, your challenge is to design and model a HD 3D monster that embodies the cold, undead, and sinister essence of Icecrown! 📅 Submissions close on April 13, 2025. Don't miss this opportunity to let your creativity shine! Enter now and show us your frozen masterpiece! 🔗 Click here to enter!

Pick all units in a line?

Status
Not open for further replies.
Level 4
Joined
Jul 22, 2010
Messages
74
Hey,

how can i pick every unit behind (for example) a "point" or "unit" in a "line", not an AoE pick, just all units in a row behind it...?

i would prefer GUI ..


thats what i try to say/ask ^^

C => caster
P => point of ability being cast (or position of a unit)
>>>>> => casting a spell

---- => (that should be the units i want)

I want to pick all this units behind the P, in a row



C >>>> P--------------


....................................
Thank you for helping =)
 
Level 37
Joined
Mar 6, 2006
Messages
9,243
Well, you could copy and paste this library:

JASS:
library PointInRect

    // Returns a boolean that tells whether the point is inside a rectangle.
    // (px , py) = Point to check
    // (cx , cy) = lower left corner of the rect
    // (ax , ay) = upper left corner
    // (bx , by) = lower right corner
    function IsPointInRect takes real px , real py , real cx , real cy , real ax , real ay , real bx , real by returns boolean        
        local real dot1 = (px-cx)*(ax-cx) + (py-cy)*(ay-cy)
        local real dot2 = (ax-cx)*(ax-cx) + (ay-cy)*(ay-cy)
        local real dot3 = (px-cx)*(bx-cx) + (py-cy)*(by-cy)
        local real dot4 = (bx-cx)*(bx-cx) + (by-cy)*(by-cy)
        
        return dot1 >= 0 and dot1 <= dot2 and dot3 >= 0 and dot3 <= dot4
    endfunction
    
endlibrary

You can pick all units in range, where range is the length of the "line".

Upper left corner is position of caster offset by x towards facing of caster + 90.
Lower left corner is upper left corner offset by y towards facing of caster + 180.
Lower right corner is lower left corner offset by 2x towards facing of caster - 90.

You'll be picking units inside a box:
help1.jpg


Save the coordinates of each point into variables and save the result into a boolean
  • Custom script: set udg_SF_Boolean = IsPointInRect(GetUnitX(GetEnumUnit()) , GetUnitY(GetEnumUnit) , udg_r5 , udg_r6 , udg_r7 , udg_r8 , udg_r3 , udg_r4 )
 
Well you know.. or meaby you do not.. but rectangle has 4 corners..
Using 2 points create just line, so I don't how you would pick units within given area.
It'd much differend if we used dummy unit and move towards destination point. Then 2 points are enought, but we would need also a loop for checking units within small area around dummy to make proper spell.
 
Status
Not open for further replies.
Top