• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Line of Sight

Status
Not open for further replies.
Level 40
Joined
Dec 14, 2005
Messages
10,532
Acos(Cos(A-B)), where A and B are in radians, will return the angle between them (again in radians).

Therefore (the example uses 90 degrees each way, for a total of 180 degrees),

JASS:
globals
    unit tempUnit //for passing to the enum
    group enumGrp = CreateGroup() //global groups rock
endglobals

function SimpleWindowEnumFilter takes nothing returns boolean
    return Acos(Cos(GetUnitFacing(tempUnit)*bj_DEGTORAD-Atan2(GetUnitY(GetFilterUnit()) - GetUnitY(tempUnit),GetUnitX(GetFilterUnit()) - GetUnitX(tempUnit)))) <= bj_PI/2
endfunction

function SimpleWindowEnum takes nothing returns nothing
    set tempUnit = //your unit
    call GroupEnumUnitsInRange(enumGrp,GetUnitX(tempUnit),GetUnitY(tempUnit),<enum range>,Filter(function SomeWindowEnumFilter))
endfunction
 
Level 14
Joined
Dec 9, 2006
Messages
1,091
Acos(Cos(A-B)), where A and B are in radians, will return the angle between them (again in radians).

Therefore (the example uses 90 degrees each way, for a total of 180 degrees),

JASS:
globals
    unit tempUnit //for passing to the enum
    group enumGrp = CreateGroup() //global groups rock
endglobals

function SimpleWindowEnumFilter takes nothing returns boolean
    return Acos(Cos(GetUnitFacing(tempUnit)*bj_DEGTORAD-Atan2(GetUnitY(GetFilterUnit()) - GetUnitY(tempUnit),GetUnitX(GetFilterUnit()) - GetUnitX(tempUnit)))) <= bj_PI/2
endfunction

function SimpleWindowEnum takes nothing returns nothing
    set tempUnit = //your unit
    call GroupEnumUnitsInRange(enumGrp,GetUnitX(tempUnit),GetUnitY(tempUnit),<enum range>,Filter(function SomeWindowEnumFilter))
endfunction

Alright, though it is in Jass, (And I have no idea to do it) I can read up on it. So, there is no way to detect Line Of Sight through GUI?

~Asomath
 
Status
Not open for further replies.
Top