//TESH.scrollpos=0
//TESH.alwaysfold=0
scope StrygwyrsThirst initializer Init
globals
private constant integer AbilId = 'A00C'
private constant integer DumAbilId = 'S001'
private constant integer BuffId = 'B005'
private group G = null
private unit U
private boolexpr B
private boolean Bool
private unit array Dum
endglobals
private function Filt takes nothing returns boolean
local unit u = U
local unit t = GetFilterUnit()
local real dist
local integer id
if IsUnitType(t,UNIT_TYPE_HERO)==true and IsUnitEnemy(t,GetOwningPlayer(u)) then
if GetWidgetLife(t)/GetUnitState(t,ConvertUnitState(1))>.4 or GetWidgetLife(t)<.405 then
call UnitShareVision(t,GetOwningPlayer(u),false)
return false
endif
set dist = DBU(u,t)
if dist<GetUnitAbilityLevel(u,AbilId)*1500. then
set Bool = true
set id = GetPlayerId(GetOwningPlayer(u))
call UnitShareVision(t,GetOwningPlayer(u),true)
if GetUnitAbilityLevel(Dum[id],DumAbilId)==0 then
call UnitAddAbility(Dum[id],DumAbilId)
endif
call SetUnitAbilityLevel(Dum[id],DumAbilId,GetUnitAbilityLevel(u,AbilId))
else
call UnitShareVision(t,GetOwningPlayer(u),false)
endif
endif
set u = null
set t = null
return false
endfunction
private function Effects takes nothing returns nothing
local unit u=GetEnumUnit()
local group g=NewGroup()
set Bool = false
set U = u
call GroupEnumUnitsInRect(g,bj_mapInitialPlayableArea,B)
if not Bool then
call UnitRemoveAbility(Dum[GetPlayerId(GetOwningPlayer(u))],DumAbilId)
call UnitRemoveAbility(u,BuffId)
endif
set u = null
call ReleaseGroup(g)
endfunction
private function Update takes nothing returns nothing
call ForGroup(G,function Effects)
endfunction
private function Actions takes nothing returns nothing
local timer t
local unit u = GetTriggerUnit()
local integer id = GetPlayerId(GetOwningPlayer(u))
if G==null then
set G = CreateGroup()
set t = CreateTimer()
call TimerStart(t,.5,true,function Update)
endif
call GroupAddUnit(G,u)
set Dum[id] = CreateUnit(GetOwningPlayer(u),CasterId,0.,0.,0.)
call SetUnitInvulnerable(Dum[id],true)
endfunction
private function Conds takes nothing returns boolean
if GetLearnedSkill()==AbilId and not IsUnitIllusion(GetTriggerUnit()) and GetUnitAbilityLevel(GetTriggerUnit(),AbilId)==1 then
call Actions()
endif
return false
endfunction
private function Init takes nothing returns nothing
local trigger t=CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(t,EVENT_PLAYER_HERO_SKILL)
call TriggerAddCondition(t,Condition(function Conds))
set B = Condition(function Filt)
call PreloadAbil(DumAbilId)
endfunction
endscope