scope MagicProjectile initializer init
private keyword spell
private struct spellMissile extends CustomMissile
private spell spellInst = 0
private unit source = null
public static method new takes spell ins, unit caster, real spellx, real spelly returns thistype
local real x = GetUnitX(caster)
local real y = GetUnitY(caster)
local real angle = Atan2(spelly - y, spellx - x)
local real xloc = x + 1500. * Cos(angle)
local real yloc = y + 1500. * Sin(angle)
local thistype this = thistype.create(x, y, GetLocZ(x, y) + 75., angle)
set .source = caster
set .spellInst = ins
call .setTargetPosZ(xloc, yloc, 75.)
return this
endmethod
method onCreate takes nothing returns nothing
set .sfx = "Abilities\\Weapons\\SpiritOfVengeanceMissile\\SpiritOfVengeanceMissile.mdl"
set .movespeed = 800.
set .hitrange = 32.
set .decay = 15.
set .height = 75.
set .hitunits = true
set .hitdests = true
set .autoface = true
set .checkheight = false
set .hitwalls = true
endmethod
method onStart takes nothing returns nothing
call DestroyEffect(AddSpecialEffectTarget("Abilities\\Weapons\\SpiritOfVengeanceMissile\\SpiritOfVengeanceMissile.mdl", .getEffUnit(), "origin"))
endmethod
method onLoop takes nothing returns nothing
set .scale = GetRandomReal(1.,3.)
endmethod
method onDestTouch takes destructable theDestructable returns nothing
set .hitunits = false
set .hitwalls = false
set .hitdests = false
set .alive = false
call BJDebugMsg("Miss!!!")
endmethod
method onWallHit takes nothing returns nothing
set .hitunits = false
set .hitwalls = false
set .hitdests = false
set .alive = false
call BJDebugMsg("Miss!!!")
endmethod
method onTargetReach takes nothing returns nothing
set .hitunits = false
set .hitwalls = false
set .hitdests = false
set .alive = false
call BJDebugMsg("Miss!!!")
endmethod
method onUnitTouch takes unit theUnit returns nothing
local real realhigh = GetUnitFlyHeight(.getEffUnit())
if GetUnitState(theUnit, UNIT_STATE_LIFE) <= 0 then
return
endif
if theUnit == .source then
return
endif
if realhigh < 100 and realhigh > GetUnitFlyHeight(theUnit) then
set .hitunits = false
set .hitwalls = false
set .hitdests = false
call BJDebugMsg("Hit!!!")
call DestroyEffect(AddSpecialEffectTarget("Abilities\\Weapons\\SpiritOfVengeanceMissile\\SpiritOfVengeanceMissile.mdl", .getEffUnit(), "origin"))
call UnitDamageTarget(.source, theUnit, 100., false, false, ATTACK_TYPE_MAGIC, DAMAGE_TYPE_MAGIC, WEAPON_TYPE_WHOKNOWS)
set .alive = false
endif
endmethod
endstruct
private struct spell
private spellMissile missile = 0
public static method create takes unit caster, real x, real y returns thistype
local thistype this = thistype.allocate()
set .missile = spellMissile.new(this, caster, x, y)
return this
endmethod
endstruct
private function cast takes nothing returns boolean
if GetSpellAbilityId() != 'A00B' then
return false
endif
call spell.create(GetTriggerUnit(), GetSpellTargetX(), GetSpellTargetY())
return false
endfunction
private function init takes nothing returns nothing
local trigger t = CreateTrigger()
local integer i = 0
call TriggerAddCondition(t, Condition(function cast))
loop
exitwhen i >= bj_MAX_PLAYERS
call TriggerRegisterPlayerUnitEvent(t, Player(i), EVENT_PLAYER_UNIT_SPELL_CAST, null)
set i = i +1
endloop
endfunction
endscope