//===========================
//=== SpellPredatorSpirit ===
//========= v1.000 ==========
library SpellPredatorSpirit requires Assist, Cast, SpellSpiritScout, Teams
//=== Settings ===
globals
private constant integer ABILCODE = 'X122'
private constant integer SFX_ABILITY = 'X123'
private constant string SFX_ABILITY_ORDER = "bloodlust"
//----------------
private constant real DETONATE_RANGE = 100
private constant real CASTER_LIFETIME = 1
endglobals
struct SpellPredatorSpirit extends array
private static real array AOE
static if LIBRARY_ManaLoss then
private static real array MANA_COST
endif
private static method onInit takes nothing returns nothing
set AOE[1] = 12000
set AOE[2] = 1600
set AOE[3] = 2000
static if LIBRARY_ManaLoss then
set MANA_COST[1] = 80
set MANA_COST[2] = 80
set MANA_COST[3] = 80
endif
//================
set selfdestruct = selfdestruct.create()
endmethod
readonly static integer abilcode = ABILCODE
private static unit target
private static indexCarrier selfdestruct
private static unit array spirit
private static trigger array t[10]
private static method contact takes nothing returns boolean
local trigger t = GetTriggeringTrigger()
set Assist.workInteger = 0
call BJDebugMsg("A")
if thistype.t[0] == GetTriggeringTrigger() then
call BJDebugMsg("YES")
endif
loop
exitwhen thistype.t[Assist.workInteger] == t
call BJDebugMsg("FUCK")
set Assist.workInteger = Assist.workInteger + 1
endloop
call BJDebugMsg(I2S(Assist.workInteger))
set Assist.workUnit = GetTriggerUnit()
if Assist.workUnit == UnitData.Unit[GetUnitUserData(spirit[Assist.workInteger])] then
call BJDebugMsg("B")
set Assist.workInteger = 0
call selfdestruct.unregister(Assist.workInteger)
set spirit[Assist.workInteger] = null
set thistype.t[Assist.workInteger] = null
call DealDamage(UnitData.Unit[Assist.workInteger], Assist.workUnit, 99999, PURE)
call DestroyTrigger(t)
endif
set t = null
return false
endmethod
private static method commitSuicide takes nothing returns nothing
call IssueTargetOrder(target, "move", UnitData.Unit[Assist.workInteger])
call TimedLife.apply(target, INFINITE)
call CastUnit(Assist.workUnit, target, CASTER_LIFETIME, SFX_ABILITY, 1, SFX_ABILITY_ORDER)
set Assist.workInteger = selfdestruct.register()
set spirit[Assist.workInteger] = target
set t[Assist.workInteger] = CreateTrigger()
call BJDebugMsg("SUICIDE "+I2S(Assist.workInteger))
call TriggerRegisterUnitInRange(t[Assist.workInteger], target, 350, function thistype.contact)
if t[1] != null then
call BJDebugMsg("DAFUQ")
endif
endmethod
static method onSpellEffect takes nothing returns nothing
local unit u
set Assist.workInteger = GetSpellAbilityId()
if Assist.workInteger == ABILCODE then
set Assist.workPlayer = GetTriggerPlayer()
set Assist.workUnit = GetTriggerUnit()
set target = GetSpellTargetUnit()
set Assist.workInteger = GetUnitUserData(target)
if UnitData.Unit[Assist.workInteger] == null then
set u = GetClosestUnit(GetUnitX(target), GetUnitY(target), AOE[GetUnitAbilityLevel(Assist.workUnit, ABILCODE)], function SpellSpiritScout.closestHeroFilter)
if u != null then
set UnitData.Unit[Assist.workInteger] = u
call commitSuicide()
endif
else
call commitSuicide()
endif
set u = null
set target = null
elseif Assist.workInteger == SFX_ABILITY then
call UnitAddAbility(GetSpellTargetUnit(), 'Avul')
endif
endmethod
endstruct
endlibrary