- Joined
- May 4, 2007
- Messages
- 2,260
After many suggestions of those who know something about JASS, i decided to leave the evil SleepWaits(although some times they are really cool and I use them) and started learning timers.
My friend Blue_jeans made some codes and i studied them in order to accomplish a classic spell called Apocalypse - which makes meteors fall from the sky every X seconds.
To make this spell i read a tutorial that my idol (Daelin) made.
The spell was in GUI, was not MUI and had a few leaks, but it is was still a very cool spell.
So I decided to apply my vJASS to it and to make it JESP, MUI and leak free.
I must confess I am impressed with what i accomplished so far. But it is still not enough for what i want to do.
So, I present you my problem:
- When cast the spell starts a timer that will expire in "5 * GetUnitAbilityLevel(data.caster, 'A000') + 10" seconds.
- Every "3 / GetUnitAbilityLevel(data.caster, 'A000')" seconds a meteor will fall from the sky damaging enemy units.
-PROBLEM: the spell is meant to end when the timer expires or the hero dies.
But although the function is fired, the spell never stops, and meteors keep falling even after the heroe's death.
That is why i need your help guys, help me learning how to use timers, for THW sake ! =P
This spell uses vJASS and ABC timing system, suggested by my friend Blue_Jeans.
I just wanna know how to fix it, that's all.
Btw, don't get scared, the logic of the spell is actually pretty simple to understand - that is mainly why i created this spell, after all, i am just a beginner to the timing world =P.
My friend Blue_jeans made some codes and i studied them in order to accomplish a classic spell called Apocalypse - which makes meteors fall from the sky every X seconds.
To make this spell i read a tutorial that my idol (Daelin) made.
The spell was in GUI, was not MUI and had a few leaks, but it is was still a very cool spell.
So I decided to apply my vJASS to it and to make it JESP, MUI and leak free.
I must confess I am impressed with what i accomplished so far. But it is still not enough for what i want to do.
So, I present you my problem:
- When cast the spell starts a timer that will expire in "5 * GetUnitAbilityLevel(data.caster, 'A000') + 10" seconds.
- Every "3 / GetUnitAbilityLevel(data.caster, 'A000')" seconds a meteor will fall from the sky damaging enemy units.
-PROBLEM: the spell is meant to end when the timer expires or the hero dies.
But although the function is fired, the spell never stops, and meteors keep falling even after the heroe's death.
That is why i need your help guys, help me learning how to use timers, for THW sake ! =P
This spell uses vJASS and ABC timing system, suggested by my friend Blue_Jeans.
I just wanna know how to fix it, that's all.
Btw, don't get scared, the logic of the spell is actually pretty simple to understand - that is mainly why i created this spell, after all, i am just a beginner to the timing world =P.
JASS:
struct Mystruct
unit caster = GetTriggerUnit()
timer repeator = CreateTimer()
timer expirer = CreateTimer()
trigger end = CreateTrigger()
triggeraction endAction
triggercondition endCondition
endstruct
//==========================================================================
function endConds takes nothing returns boolean
local Mystruct data = GetTriggerStructB(GetTriggeringTrigger())
return GetTriggerUnit() == data.caster
endfunction
//==========================================================================
function endActs takes nothing returns nothing
//catches the expired timer and runs this function
local Mystruct data = GetTimerStructB(GetExpiredTimer())
//a test message
call DisplayTextToPlayer(GetLocalPlayer(),0,0, "Ending Spell ??")
//removes the created trigger in the Code_acts function
call TriggerRemoveCondition(data.end,data.endCondition)
call TriggerRemoveAction(data.end,data.endAction)
call DestroyTrigger(data.end)
call ClearTriggerStructB(data.end)
//IT SHOULD stop the timer repeator, and cease the spell, but nothing happens. Help !
call PauseTimer(data.repeator)
call DestroyTimer(data.repeator)
call ClearTimerStructA(data.repeator)
endfunction
//==========================================================================
function Apoca takes nothing returns nothing
//catches the expired timer and runs this function
local Mystruct data = GetTimerStructA(GetExpiredTimer())
//creates a dummy that makes the meteor fall
local unit dummy = CreateUnit(GetOwningPlayer(data.caster), 'h000', GetUnitX(data.caster), GetUnitY(data.caster), 0)
call UnitAddAbility(dummy, 'A001')
call IssuePointOrderLocBJ( dummy, "flamestrike", PolarProjectionBJ(GetUnitLoc(data.caster), GetRandomReal(300.00, 600.00), GetRandomReal(0.00, 360.00)) )
call UnitApplyTimedLife(dummy, 'BTLF', 3)
set dummy = null
endfunction
//==========================================================================
function Code_conds takes nothing returns boolean
return GetSpellAbilityId() == 'A000'
endfunction
//==========================================================================
function Code_acts takes nothing returns nothing
local Mystruct data = Mystruct.create()
//starts the effect of the spell, meteors start falling from sky
call SetTimerStructA(data.repeator, data)
call TimerStart(data.repeator, 3 / GetUnitAbilityLevel(data.caster, 'A000'), true, function Apoca)
//creates the timer that ends the spell when expired
call SetTimerStructB(data.expirer, data)
call TimerStart(data.expirer, 5 * GetUnitAbilityLevel(data.caster, 'A000') + 10, false, null)
//creates the trigger that will end the spell when the timer expires or the hero dies
call SetTriggerStructB(data.end, data)
call TriggerRegisterTimerExpireEvent( data.end, data.expirer )
call TriggerRegisterAnyUnitEventBJ(data.end, EVENT_PLAYER_UNIT_DEATH )
set data.endCondition = TriggerAddCondition( data.end, Condition( function endConds ) )
set data.endAction = TriggerAddAction( data.end, function endActs )
endfunction
//===========================================================================
function InitTrig_Code takes nothing returns nothing
set gg_trg_Code = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Code, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( gg_trg_Code, Condition( function Code_conds ) )
call TriggerAddAction( gg_trg_Code, function Code_acts )
endfunction