Hello!
I am trying to learn JASS and I've currently created this simple spell (using TT). It's basically just a ball rolling forward. What I want is that if an enemy comes withing the ball (the dummy unit) he should be knocked back for a fixed period of time and then not be able to be knocked back again (by the same "ball"). I'm also trying to make it MUI.
I am trying to learn JASS and I've currently created this simple spell (using TT). It's basically just a ball rolling forward. What I want is that if an enemy comes withing the ball (the dummy unit) he should be knocked back for a fixed period of time and then not be able to be knocked back again (by the same "ball"). I'm also trying to make it MUI.
JASS:
scope Ball initializer init
globals
private constant integer ABILITY_ID = 039;A000039;
private constant integer DUMMY_ID = 039;h001039;
endglobals
private struct data
unit cast
unit u
player p
location l
real x
real y
real xl
real yl
real a
real f = 0
endstruct
private function Cond takes nothing returns boolean
return GetSpellAbilityId() == ABILITY_ID
endfunction
private function Movement takes nothing returns boolean
local data d = TT_GetData()
set d.f = d.f + 15
call SetUnitX(d.u,d.x+d.f*Cos(d.a))
call SetUnitY(d.u,d.y+d.f*Sin(d.a))
if GetWidgetLife(d.u)<.405 then
call d.destroy()
return true
endif
return false
endfunction
private function Action takes nothing returns nothing
local data d = data.create()
set d.cast = GetTriggerUnit()
set d.p = GetOwningPlayer(d.cast)
set d.x = GetUnitX(d.cast)
set d.y = GetUnitY(d.cast)
set d.l = GetSpellTargetLoc()
set d.xl = GetLocationX(d.l)
set d.yl = GetLocationY(d.l)
set d.a = Atan2(d.yl-d.y,d.xl-d.x)
set d.u = CreateUnit(d.p,DUMMY_ID,d.x,d.y,d.a*180/3.1415)
call UnitApplyTimedLife(d.u,039;BTLF039;,3.00)
call TT_Start(function Movement,d)
endfunction
private function init takes nothing returns nothing
local trigger t = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(t,EVENT_PLAYER_UNIT_SPELL_EFFECT)
call TriggerAddCondition(t,function Cond)
call TriggerAddAction(t,function Action)
endfunction
endscope