Hi there, I'm currently learning vJass and was trying to code a simple dash spell. What the spell does is obvious: when cast, the casting unit dashes [int] units forward. This is the current code:
Please explain it in simple english because I'm really bad at english. Thanks for helping.
JASS:
scope Dash initializer Init
private function Move takes nothing returns nothing
//*This part is to move the unit forward every 0.03 seconds.
//*I couldn't figure out how to retrieve the CastingUnit from
//the private function 'Actions' and how can I stop the timer
//when the unit reached its maximum range.
//*I thought of declaring globals and use them but if I do so,
//does that mean this spell is not MUI? Does this also mean that
//if I use global variables, in order to make this spell MUI, I
//would have to make an indexing system like in GUI?
//*I also thought of using structs but I don't really understand
//the concept of structs. If structs are much more easier, please
//show me how to use them.
endfunction
private function Conditions takes nothing returns boolean
return GetSpellAbilityId() == 'A000'
endfunction
private function Actions takes nothing returns nothing
local unit a = GetSpellAbilityUnit()
local timer b = CreateTimer()
call TimerStart(b, 0.03, true, function Move)
set a = null
endfunction
private function Init takes nothing returns nothing
local trigger a = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(a, EVENT_PLAYER_UNIT_SPELL_EFFECT)
call TriggerAddCondition(a, Condition(function Conditions))
call TriggerAddAction(a, function Actions)
endfunction
endscope
Please explain it in simple english because I'm really bad at english. Thanks for helping.