• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.
  • The Hive's 22nd Icon Contest: Creep Abilities is now concluded, time to vote for your favourite set of icons! Click here to vote!
  • ✅ The POLL for Hive's Texturing Contest #34 is OPEN! Vote for the TOP 3 SKINS! 🔗Click here to cast your vote!
  • ✅ The POLL for Hive's Techtree Contest #20 is OPEN! Vote for the TOP 3 FACTIONS! 🔗Click here to cast your vote!

passing local variable in JASS? Channeled effects with JASS?

Status
Not open for further replies.
Level 2
Joined
Jan 30, 2006
Messages
12
I'm looking to make timed effects for channeled spells in JASS. Namely, a channeled dummy spell is activated or being channeled, which will fulfill a condition. The condition, when true, will cause something to happen every x seconds, until the spell is no longer being channelled, at which point the condition is false. I could do this with three regular triggers, but that would require a global variable.

So, how could this be done? And can local variable be passed from function to function in JASS?
 
That's pretty simple...

The first thing is to use a local trigger that takes place when the caster stops casting any spell (which will obviously be our channeling spell).

local trigger t = CreateTrigger()
call TriggerRegisterUnitEvent(t, GetTriggerUnit(), EVENT_UNIT_SPELL_ENDCAST)

And now, you keep the trigger going until the unit stops casting the spell, like this:

loop
exitwhen GetTriggerEvalCount(t)>0
call TriggerSleepAction(0.10)
endloop

GetTriggerEvalCount(t) counts how many times was trigger t fired. This function ignores the fact that the conditions of the trigger are fulfilled or not, when the event takes place. But that's not a problem in this case.

As for the effect, I would do it inside the loop above (if condition is true, make the dummy do something).

~Daelin
 
Status
Not open for further replies.
Back
Top