tuantai120
Cool Member
- Reaction score
- 1
Please help me , problem is when cast spell into target , it makes target move but never stop
JASS:
scope lk initializer Init
globals
private constant integer SID = 039;A003039;
private constant integer DID = 039;h000039;
private constant string SFX = "Abilities\\Spells\\Undead\\AnimateDead\\AnimateDeadTarget.mdl"
private constant string Order = "firebolt"
private constant real Interval = 0.04
private constant real DamageBase = 150.
endglobals
private function Conditions takes nothing returns boolean
return GetSpellAbilityId() == SID
endfunction
private function Damage takes integer lvl returns real
return lvl * DamageBase
endfunction
//==========================
private function TJGetPPX takes real x, real dist, real angle returns real
return x + dist * Cos(angle * bj_DEGTORAD)
endfunction
private function TJGetPPY takes real y, real dist, real angle returns real
return y + dist * Sin(angle * bj_DEGTORAD)
endfunction
private struct knockback
unit u
unit target
real dist
real angle
real tick
timer t
integer lvl
endstruct
private function LightKnock takes nothing returns nothing
local knockback d = GetTimerData(GetExpiredTimer())
local real x
local real y
local real kx
local real ky
if d.tick > 0 or GetWidgetLife(d.target) > 0 then
set x = GetUnitX(d.target)
set y = GetUnitY(d.target)
set kx = TJGetPPX(x,d.dist,d.angle)
set ky = TJGetPPY(y,d.dist,d.angle)
call SetUnitPosition(d.target,kx,ky)
call DestroyEffect(AddSpecialEffect(SFX,x,y))
set d.tick = d.tick -1
elseif d.tick <= 0 or GetWidgetLife(d.target) <= 0 then
call ReleaseTimer(d.t)
call knockback.destroy(d)
endif
endfunction
private function LightKnockU takes nothing returns nothing
local knockback d
local unit u = GetTriggerUnit()
local unit target = GetSpellTargetUnit()
local real x = GetUnitX(target)
local real y = GetUnitY(target)
local unit dummy = CreateUnit(GetOwningPlayer(u),DID,x,y,0)
local real dur = 1.
local real angle = GetUnitFacing(u)
local real dist = 400
local real tick = 25
if dur == 0. or dist == 0. then
set u = null
set target = null
set dummy = null
return
endif
call IssueTargetOrder(dummy,Order,target)
call UnitApplyTimedLife(dummy,039;BLTF039;,1.)
call UnitDamageTarget(dummy,target,DamageBase,false,true,ATTACK_TYPE_HERO,DAMAGE_TYPE_UNIVERSAL,WEAPON_TYPE_WHOKNOWS)
set d = knockback.create()
set d.u = u
set d.target = target
set d.tick = R2I(dur/Interval)
set d.dist = dist/d.tick
set d.angle = angle
set d.lvl = GetUnitAbilityLevel(u,SID)
set d.t = NewTimer()
call SetTimerData(d.t,d)
call TimerStart( d.t,Interval,true, function LightKnock)
set u = null
set target = null
set dummy = null
endfunction
private function Init takes nothing returns nothing
local trigger light = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ( light , EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( light , Condition ( function Conditions ) )
call TriggerAddAction ( light , function LightKnockU )
endfunction
endscope