- Joined
- Aug 27, 2013
- Messages
- 3,973
-
FoV Config
-
Events
- Map initialization
- Conditions
-
Actions
- -------- ---------------------------- --------
- Set FoV_Observer = Peasant 0001 <gen>
- -------- ---------------------------- --------
- Set FoV_Target = Peasant 0002 <gen>
- -------- ---------------------------- --------
- Set FoV_VisionField = 67.50
- -------- ---------------------------- --------
- Set FoV_BehindField = 90.00
- -------- ---------------------------- --------
-
Events
JASS:
function IsUnitInSightOfUnit takes unit observer, unit target, real fov returns boolean
local real face = GetUnitFacing(observer)
local real angle = bj_RADTODEG*Atan2(GetUnitY(target)-GetUnitY(observer), GetUnitX(target)-GetUnitX(observer))
return not(RAbsBJ(face-angle) > fov and RAbsBJ(face-angle-360) > fov)
endfunction
function IsUnitBehindUnit takes unit attacker, unit target, real fov returns boolean
local real face = GetUnitFacing(target)
local real angle = bj_RADTODEG*Atan2(GetUnitY(target)-GetUnitY(attacker),GetUnitX(target)-GetUnitX(attacker))
return not(RAbsBJ(face-angle) > fov and RAbsBJ(face-angle-360) > fov)
endfunction
function Trig_Field_of_View_Actions takes nothing returns nothing
if IsUnitInSightOfUnit(udg_FoV_Observer, udg_FoV_Target, udg_FoV_VisionField) then
call SetUnitVertexColor(udg_FoV_Observer, 255, 0, 0, 255)
elseif IsUnitBehindUnit(udg_FoV_Target, udg_FoV_Observer, udg_FoV_BehindField) then
call SetUnitVertexColor(udg_FoV_Observer, 0, 0, 255, 255)
else
call SetUnitVertexColor(udg_FoV_Observer, 255, 255, 255, 255)
endif
endfunction
//===========================================================================
function InitTrig_Field_of_View takes nothing returns nothing
local trigger t = CreateTrigger( )
call TriggerRegisterTimerEventPeriodic( t, 0.25 )
call TriggerAddAction( t, function Trig_Field_of_View_Actions )
endfunction
Attachments
Last edited: