tuantai120
Cool Member
- Reaction score
- 1
I've just made this spell , i have a problem in my code that picked unit doesn't move or be damaged
this is my code :
this is my code :
JASS:
scope tornado initializer Init
globals
private constant integer SID = 039;A001039;
private constant integer DID = 039;h000039;
private constant string SFX = "Abilities\\Weapons\\AncientProtectorMissile\\AncientProtectorMissile.mdl"
private constant real Period = 0.04
endglobals
private function Damage_dealt takes integer lvl returns real
return 100.00 * lvl
endfunction
private function Conditions takes nothing returns boolean
return GetSpellAbilityId() == SID
endfunction
private struct tor
unit cast
unit c
real angle
integer tick
real distance
string sfx
group g
endstruct
private function TornadoT takes nothing returns nothing
local timer ti = GetExpiredTimer()
local tor data = GetTimerData( ti )
local unit p
local real x = GetUnitX(data.c)
local real y = GetUnitY(data.c)
local real xx = GetPPX( x, data.distance, data.angle )
local real yy = GetPPY( y, data.distance, data.angle )
local real px
local real py
local real pxx
local real pyy
call DestroyEffect(AddSpecialEffect(SFX,xx,yy))
call SetUnitPosition(data.c,xx,yy)
call GroupEnumUnitsInRange(data.g,x,y,200,null)
loop
set p = FirstOfGroup(data.g)
exitwhen p == null
call GroupRemoveUnit(data.g,p)
if IsUnitEnemy(p,GetOwningPlayer(data.cast)) == true then
set px = GetUnitX(p)
set py = GetUnitY(p)
set pxx = GetPPY( px , data.distance , data.angle)
set pyy = GetPPY( py , data.distance , data.angle )
call SetUnitPosition(p,pxx,pyy)
call UnitDamageTarget(data.c,p,Damage_dealt,false,false,ATTACK_TYPE_CHAOS,DAMAGE_TYPE_UNIVERSAL,WEAPON_TYPE_WHOKNOWS)
endif
endloop
set data.tick = data.tick - 1
if data.tick <= 0 then
call RemoveUnit(data.c)
call ReleaseTimer(ti)
call data.destroy()
endif
set p = null
set ti = null
endfunction
private function Actions takes nothing returns nothing
local tor data = tor.create()
local timer ti = NewTimer()
local unit u = GetTriggerUnit()
local unit du
local real x = GetUnitX(u)
local real y = GetUnitY(u)
local real xx = GetSpellTargetX()
local real yy = GetSpellTargetY()
local real angle = AngleXY(x,y,xx,yy)
local real distance = 40
set du = CreateUnit(GetOwningPlayer(u),DID,x,y,angle)
call SetTimerData(ti,data)
set data.cast = u
set data.c = du
set data.angle = angle
set data.tick = 25
set data.distance = distance
call TimerStart(ti,Period,true,function TornadoT)
set u = null
set du = null
endfunction
private function Init takes nothing returns nothing
local trigger use = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ( use , EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( use , Condition( function Conditions ) )
call TriggerAddAction( use , function Actions )
set use = null
endfunction
endscope