- Joined
- Mar 24, 2008
- Messages
- 184
so, i wanted to try and make a spell in vJASS after reading some tutorials (i wanted to do that like 2-3 months ago but only now i have time since i'm done with uni exams) but i'm having some problems with timers
The spell works this way, there's a unit that creates 4 clones and they all attack moving around the target, this is the part that's supposed to control each clone (the main spell puts the created unit and the target unit in the struct in the variables owner and target, and attaches it to the unit, then when it's needed, orders the units to use the ability to activate this trigger)
Actually i do know what the problem is, the GetTriggerUnit of the function slicedice doesn't get anything. i've tried passing the unit with a global variable and it worked, but i'm pretty sure there's a better way to do this, i just can't think anything to make it work (why oh why i can't use variables with arguments on timers code? there are some silly limits in the WE imho)
JASS:
library Shadowloop
public function slicedice takes nothing returns nothing
local loopthingie stru=GetUnitUserData(GetTriggerUnit())
local unit SliceAndDiceCaster=stru.owner
local unit SliceAndDiceTarget=stru.target
//stuff
endfunction
struct loopthingie
public boolean attack=true
public unit owner
public unit target
public timer loopy = CreateTimer()
public integer in = 0
public real angle1
public real angle2
method onDestroy takes nothing returns nothing
call PauseTimer(this.loopy)
call DestroyTimer(this.loopy)
endmethod
endstruct
private function Conditions takes nothing returns boolean
return (GetSpellAbilityId() == 'A02O')== true
endfunction
private function Actions takes nothing returns nothing
local loopthingie stru = GetUnitUserData(GetTriggerUnit())
call TimerStart(stru.loopy, GetRandomReal(0.10, 0.27), true, function slicedice)
endfunction
//===========================================================================
public function InitTrig takes nothing returns nothing
local trigger Shadowloop = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(Shadowloop, EVENT_PLAYER_UNIT_SPELL_CAST)
call TriggerAddCondition(Shadowloop, Condition( function Conditions))
call TriggerAddAction(Shadowloop, function Actions)
endfunction
endlibrary
The spell works this way, there's a unit that creates 4 clones and they all attack moving around the target, this is the part that's supposed to control each clone (the main spell puts the created unit and the target unit in the struct in the variables owner and target, and attaches it to the unit, then when it's needed, orders the units to use the ability to activate this trigger)
Actually i do know what the problem is, the GetTriggerUnit of the function slicedice doesn't get anything. i've tried passing the unit with a global variable and it worked, but i'm pretty sure there's a better way to do this, i just can't think anything to make it work (why oh why i can't use variables with arguments on timers code? there are some silly limits in the WE imho)
Last edited: