scope HurlBolderTriggered initializer Init
globals
trigger Example
endglobals
private struct Missile extends xehomingmissile
private unit caster
private unit target
private real damage
static method create takes unit caster, unit target, real damage, string fxpath, real x, real y, real z returns Missile
// Creates a missile from the caster position with an offset of +60 in the z axis that will seek the target
local Missile this = Missile.allocate(x, y, z, target, BlzGetUnitZ(target) + 60.0)
set this.caster = caster
set this.target = target
set this.damage = damage
set this.fxpath = fxpath //xefx library required
set this.scale = 1.0 // the scale
call this.launch(1000.0, 0.1) // Launches the missile with 1000 as Missile Speed and 0.1 Arc
return this
endmethod
method onHit takes nothing returns nothing
//When the Missile reaches its target, it will deal the amount of passed as parameter to the create method
//Note: ATTACK_TYPE_NORMAL means Spell Damage
call UnitDamageTarget(this.caster, this.target, this.damage, true, false, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_MAGIC, null)
//To prevent local handle leaks
set this.target = null
set this.caster = null
endmethod
endstruct
private function Conditions takes nothing returns nothing
local unit caster = GetTriggerUnit() // the caster
local unit target = GetSpellTargetUnit() // the target
local real x = GetUnitX(caster) // x of the caster
local real y = GetUnitY(caster) // y of the caster
local real z = BlzGetUnitZ(caster) // z of the caster
local boolean HurlBolder = GetSpellAbilityId() == 'A000' //Your custom ability code
local real damage = 1000 //The desired amount of damage to be applied OnHit
local Missile m // the missile instance
// if ability being cast is your custom ability then create the missile
if HurlBolder then
//creates the missile instance
set m = Missile.create(caster, target, damage, "Abilities\\Weapons\\RockBoltMissile\\RockBoltMissile.mdl", x, y, z)
//Uses the original Hurl Bolde Missile, but you can use any model you want
endif
set target = null
set caster = null
endfunction
//===========================================================================
private function Init takes nothing returns nothing
set Example = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(Example, EVENT_PLAYER_UNIT_SPELL_EFFECT)
call TriggerAddCondition(Example, Condition(function Conditions))
endfunction
endscope