MasterOfRa
New Member
- Reaction score
- 10
JASS:
library CS uses Dummy, Recycler, Filter, Constants
globals
private constant real DELTA = 16.
endglobals
//===========================================================================
public struct Data
unit whichUnit
unit target
static method create takes unit whichUnit returns Data
local Data data = Data.allocate()
set data.whichUnit = whichUnit
return data
endmethod
//===========================================================================
private method IsLineClear takes nothing returns boolean
local real x1 = GetUnitX(.whichUnit)
local real y1 = GetUnitY(.whichUnit)
local real x2 = GetUnitX(.target)
local real y2 = GetUnitY(.target)
local real dy = y2-y1
local real dx = x2-x1
local real angle = Atan2(dy, dx)
local real distance = SquareRoot(dx*dx+dy*dy)
local real d = 0
loop
set d = d + DELTA
exitwhen d>=distance
set x2 = x1 + d*Cos(angle)
set y2 = y1 + d*Sin(angle)
if IsTerrainPathable(x2, y2, PATHING_TYPE_WALKABILITY) == true then
return false
endif
endloop
return true
endmethod
//===========================================================================
method GetClearTarget takes real area returns unit
local group g = NewGroup()
call GroupEnumUnitsInRange(g, GetUnitX(.whichUnit), GetUnitY(.whichUnit), area, Filter_VisibleAliveEnemy(GetOwningPlayer(.whichUnit)))
if .target != null then
if IsUnitInGroup(.target,g)then
if .IsLineClear() then
call ReleaseGroup(g)
return .target
endif
endif
endif
loop
set .target = FirstOfGroup(g)
if .IsLineClear() then
call ReleaseGroup(g)
return .target
endif
call GroupRemoveUnit(g, .target)
exitwhen .target == null
endloop
call ReleaseGroup(g)
return null
endmethod
//===========================================================================
method GetTarget takes real area returns unit
local group g = NewGroup()
call GroupEnumUnitsInRange(g, GetUnitX(.whichUnit), GetUnitY(.whichUnit), area, Filter_VisibleAliveEnemy(GetOwningPlayer(.whichUnit)))
if .target != null then
if IsUnitInGroup(.target,g)then
if .IsLineClear() then
call ReleaseGroup(g)
return .target
endif
endif
endif
//call GroupEnumUnitsInRange(g, GetUnitX(.whichUnit), GetUnitY(.whichUnit), area, null)
set .target = FirstOfGroup(g)
call ReleaseGroup(g)
return .target
endmethod
method onDestroy takes nothing returns nothing
set .whichUnit = null
set .target = null
endmethod
endstruct
//===========================================================================
//public function FrostBoltEffect takes unit caster, unit target, integer level returns nothing
// call Dummy_create(caster, AID_FROSTBOLT_EFFECT, level, 0.0)
// call IssueTargetOrderById(bj_lastCreatedUnit, OID_frostnova, target)
//endfunction
//===========================================================================
endlibrary