- Joined
- Mar 23, 2008
- Messages
- 942
This trigger don't run when my unit cast the spell.
(Nothing happen, even the debug msg are not shown)
(Nothing happen, even the debug msg are not shown)
JASS:
scope Hirenkyaku initializer In_Hirenkyaku
globals
private constant real move = 100.00
endglobals
private struct HIR
unit caster
location target
real tx
real ty
real x
real y
real angle
integer times
endstruct
//===========================================================================
private function Hirenkyaku_Move takes nothing returns nothing
local HIR h = GetTimerData(GetExpiredTimer())
if h.times > 0 then
call BJDebugMsg("3-4")
set h.x = h.x + move * Cos(h.angle * bj_DEGTORAD)
set h.y = h.y + move * Sin(h.angle * bj_DEGTORAD)
call SetUnitX(h.caster, h.x)
call SetUnitY(h.caster, h.y)
set h.times = h.times - 1
else
call BJDebugMsg("3-5")
call SetUnitPosition(h.caster, h.tx, h.ty)
call UnitRemoveAbility(h.caster, 'A03Y')
call UnitRemoveAbility(h.caster, 'A03Z')
call ReleaseTimer(GetExpiredTimer())
call h.destroy()
endif
endfunction
//===========================================================================
private function Hirenkyaku_Actions takes nothing returns boolean
local HIR h
local timer t
local real dx
local real dy
if (GetSpellAbilityId() == 'A03W') then
set h.target = GetSpellTargetLoc()
set h.caster = GetTriggerUnit()
set h.tx = GetLocationX(h.target)
set h.ty = GetLocationY(h.target)
call BJDebugMsg("1")
if IsTerrainPathable(h.tx, h.ty, PATHING_TYPE_WALKABILITY) then
set h.x = GetUnitX(h.caster)
set h.y = GetUnitY(h.caster)
set h.angle = bj_RADTODEG * Atan2(h.ty - h.y, h.tx - h.x)
set t = NewTimer()
call SetTimerData(t,h)
set dx = h.tx - h.x
set dy = h.ty - h.y
call UnitAddAbility(h.caster, 'A03Y')
call UnitAddAbility(h.caster, 'A03Z')
set h.times = R2I(SquareRoot(dx * dx + dy * dy) / 100)
call TimerStart(t, 0.05, true, function Hirenkyaku_Move)
call BJDebugMsg("2")
else
call IssueImmediateOrder(h.caster, "stop")
call h.destroy()
call BJDebugMsg("3")
endif
endif
return false
endfunction
//===========================================================================
private function In_Hirenkyaku takes nothing returns nothing
local trigger t_Hirenkyaku = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ( t_Hirenkyaku, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( t_Hirenkyaku, Condition(function Hirenkyaku_Actions) )
set t_Hirenkyaku = null
endfunction
endscope