Why timer not stopped?

~GaLs~

† Ғσſ ŧħə ѕαĸε Φƒ ~Ğ䣚~ †
Reaction score
180
Why No damage is dealt to target

JASS:
scope Aim

constant function RawC takes nothing returns integer
    return 'A006' // the raw code if Aim
endfunction

private function ChannelingCond takes nothing returns boolean
    return GetSpellAbilityId() == RawC()
endfunction

private function AimCountAct takes nothing returns nothing
local effect array laser
local timer t = GetExpiredTimer()
local real Time = GetHandleReal(t,"time")
local integer dmg = GetHandleInt(t,"dmg")
local unit caster = GetHandleUnit(t,"caster")
local unit target = GetHandleUnit(t,"target")
        if (OrderId2StringBJ(GetUnitCurrentOrder(caster)) == "channel") then
            if Time >= .5 then
                call SetHandleInt(t,"dmg",dmg+GetRandomInt(1,100))
                call SetHandleReal(t,"time",Time-.5)
            else
                call PauseTimer(GetExpiredTimer())
                set laser[1] = AddSpecialEffectTarget("LasercannonfinalRED.mdx", target, "origin")
                set laser[2] = AddSpecialEffectTarget("Abilities\\Spells\\Human\\Flare\\FlareCaster.mdl",caster,"origin")
                call TriggerSleepAction(1.20)
                call BJDebugMsg(I2S(dmg)) //testing
                call UnitDamageTarget(caster, target, I2R(dmg), true, false, ATTACK_TYPE_MAGIC, DAMAGE_TYPE_NORMAL, WEAPON_TYPE_WHOKNOWS)
                call FlushHandleLocals(t)            
                call DestroyTimer(GetExpiredTimer())
                call DestroyEffect(laser[1])
                call DestroyEffect(laser[2])
                set laser[1] = null
                set laser[2] = null
            endif
        else
            call PauseTimer(GetExpiredTimer())
            set laser[1] = AddSpecialEffectTarget("LasercannonfinalRED.mdx", target, "origin")
            set laser[2] = AddSpecialEffectTarget("Abilities\\Spells\\Human\\Flare\\FlareCaster.mdl",caster,"origin")
            call BJDebugMsg(I2S(dmg)) //testing
            call TriggerSleepAction(1.20)
            call UnitDamageTarget(caster, target, I2R(dmg), true, false, ATTACK_TYPE_MAGIC, DAMAGE_TYPE_NORMAL, WEAPON_TYPE_WHOKNOWS)
            call FlushHandleLocals(t)
            call DestroyTimer(GetExpiredTimer())
            call DestroyEffect(laser[1])
            call DestroyEffect(laser[2])
            set laser[1] = null
            set laser[2] = null
        endif
    set t = null
    set caster = null
    set target = null
endfunction

private function AimSetCond takes nothing returns boolean
    return GetSpellAbilityId() == RawC()
endfunction

private function AimSetAct takes nothing returns nothing
local integer dmg = 0
local unit caster = GetSpellAbilityUnit()
local unit target = GetSpellTargetUnit()
local timer t = CreateTimer()
local integer LvlOfSpell = GetUnitAbilityLevel(caster,RawC())
local real Time = I2R(LvlOfSpell)+4
    call SetHandleReal(t,"time",Time)
    call SetHandleInt(t,"dmg",dmg)
    call SetHandleHandle(t,"caster",caster)
    call SetHandleHandle(t,"target",target)
    call TimerStart(t,0.5,true,function AimCountAct)
set caster = null
set target = null
set t = null
endfunction

//===========================================================================
function InitTrig_FullAimSetTryHandleVars takes nothing returns nothing
    set gg_trg_FullAimSetTryHandleVars = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ(gg_trg_FullAimSetTryHandleVars, EVENT_PLAYER_UNIT_SPELL_EFFECT)
	call TriggerAddCondition(gg_trg_FullAimSetTryHandleVars, Condition(function AimSetCond))
    call TriggerAddAction( gg_trg_FullAimSetTryHandleVars, function AimSetAct )
endfunction

endscope


View attachment 11198
 
waits in timer callbacks end the thread, I thin, or atleast bug it

btw

(OrderId2StringBJ(GetUnitCurrentOrder(caster)) == "channel") == false

is the same as

OrderId2String(GetUnitCurrentOrder(caster))!="channel"

and

no need to
set caster = null
set target = null
set t = null
in every if statement, just do it at the end, since it is always needed

also, if Time >= .5, it assumes that if it isnt, its under, no need to check again, as with your checking if the current order is and isn't "channel"

a few other things, for instance, you can do

call SetHandleReal(t,"time",Time - .5)
as opposed to doing it then storing it

you can also destroy and create effects in one line

maybe more minor things, but I am done for now
 
>>waits in timer callbacks end the thread, I thin, or atleast bug it

Cant really understand this line..

>>
(OrderId2StringBJ(GetUnitCurrentOrder(caster)) == "channel") == false

is the same as

OrderId2String(GetUnitCurrentOrder(caster))!="channel"

I see...

>>you can also destroy and create effects in one line
No, that special effect require 1 sec to play it's "stand" animation...
 
>>Do not use "wait"s in functions that are called because of a timer.
If then...what should i do...make another timer and use handlers in it again?

Edit:
I renewed the code...now the problem is..
Why no damage is dealt to target but the dmg integer is being added
 
is that function running?
 
Yes it does, and i did a test..
Refer back to first post...

It shows the number of dmg in 2 position but it didn't deal damage in I2R function...
 
is the unitdamagetarget function running?
 
>>is the unitdamagetarget function running?
I dont think so...the target is not being damaged
 
well...check it out and see, if its running, its the functions fault(or something in it)
 
>>well...check it out and see, if its running, its the functions fault(or something in it)
how to check it out ?? O.O
 
add a debug the line before and the line after it

and if both display, the function is running

if its running, and no damage is being done

then something IN the function is farked
 
>>add a debug the line before and the line after it

and if both display, the function is running

Don't really understand what do you mean by that...

But i had tried
JASS:
call UnitDamageTarget(caster, target, I2R(dmg), true, false, ATTACK_TYPE_MAGIC, DAMAGE_TYPE_NORMAL, WEAPON_TYPE_WHOKNOWS)
call BJDebugMsg(I2S(dmg)) //testing

And it still shows Number and this proved that the code is still running after the UnitDamageTarget function.
 
Do you even have target ? Can target be damaged even ? Is there caster ? It looks fine, at least I can' t spot any mistake what could cause problems.
To check does both local variables point to units add these lines:
JASS:
if (caster != null) then
     call BJDebugMsg("Caster points to unit.")
else
     call BJDebugMsg("Caster dosn' t point to unit.")
endif
 
like I said, teh function is running, your damage is where you want

make sure all other inputs in teh damage function are exactly what they should be
 
>>Do you even have target ? Can target be damaged even ? Is there caster ?
I do checked that...there is a caster and a target..

>>make sure all other inputs in teh damage function are exactly what they should be
Dont understand.
But maybe you are pointing on what sooda said...

I did a test and there is a value in caster, target, dmg
 
Ok, i found out the source of problem, but no way to fix it.

This code works:
JASS:
scope Aim

constant function RawC takes nothing returns integer
    return 'A006' // the raw code if Aim
endfunction

private function ChannelingCond takes nothing returns boolean
    return GetSpellAbilityId() == RawC()
endfunction

private function AimCountAct takes nothing returns nothing
local effect array laser
local timer t = GetExpiredTimer()
local real Time = GetHandleReal(t,"time")
local real dmg = I2R(GetHandleInt(t,"dmg"))
local unit caster = GetHandleUnit(t,"caster")
local unit target = GetHandleUnit(t,"target")
        if (OrderId2StringBJ(GetUnitCurrentOrder(caster)) == "channel") then
            if Time >= .5 then
                call SetHandleInt(t,"dmg",R2I(dmg)+GetRandomInt(1,100))
                call SetHandleReal(t,"time",Time-.5)
            elseif Time<= .5 then
                call PauseTimer(GetExpiredTimer())
                set laser[1] = AddSpecialEffectTarget("LasercannonfinalRED.mdx", target, "origin")
                set laser[2] = AddSpecialEffectTarget("Abilities\\Spells\\Human\\Flare\\FlareCaster.mdl",caster,"origin")
                call UnitDamageTarget(caster, target, dmg, true, false, ATTACK_TYPE_MAGIC, DAMAGE_TYPE_NORMAL, WEAPON_TYPE_WHOKNOWS)
                call BJDebugMsg(R2S(dmg)) //testing
                call BJDebugMsg(GetUnitName(caster)) //testing
                call BJDebugMsg(GetUnitName(target)) //testing
                call FlushHandleLocals(t)            
                call DestroyTimer(GetExpiredTimer())
                call DestroyEffect(laser[1])
                call DestroyEffect(laser[2])
                set laser[1] = null
                set laser[2] = null
            endif
        elseif (OrderId2StringBJ(GetUnitCurrentOrder(caster)) != "channel") then
            call PauseTimer(GetExpiredTimer())
            set laser[1] = AddSpecialEffectTarget("LasercannonfinalRED.mdx", target, "origin")
            set laser[2] = AddSpecialEffectTarget("Abilities\\Spells\\Human\\Flare\\FlareCaster.mdl",caster,"origin") 
            call UnitDamageTarget(caster, target, dmg, true, false, ATTACK_TYPE_MAGIC, DAMAGE_TYPE_NORMAL, WEAPON_TYPE_WHOKNOWS)
            call BJDebugMsg(R2S(dmg)) //testing
            call BJDebugMsg(GetUnitName(caster)) //testing
            call BJDebugMsg(GetUnitName(target)) //testing            
            call FlushHandleLocals(t)
            call DestroyTimer(GetExpiredTimer())
            call DestroyEffect(laser[1])
            call DestroyEffect(laser[2])
            set laser[1] = null
            set laser[2] = null
        endif
    set t = null
    set caster = null
    set target = null
endfunction

private function AimSetCond takes nothing returns boolean
    return GetSpellAbilityId() == RawC()
endfunction

private function AimSetAct takes nothing returns nothing
local integer dmg = 0
local unit caster = GetSpellAbilityUnit()
local unit target = GetSpellTargetUnit()
local timer t = CreateTimer()
local integer LvlOfSpell = GetUnitAbilityLevel(caster,RawC())
local real Time = I2R(LvlOfSpell)+4
    call SetHandleReal(t,"time",Time)
    call SetHandleInt(t,"dmg",dmg)
    call SetHandleHandle(t,"caster",caster)
    call SetHandleHandle(t,"target",target)
    call TimerStart(t,0.5,true,function AimCountAct)
set caster = null
set target = null
set t = null
endfunction

//===========================================================================
function InitTrig_FullAimSetTryHandleVars takes nothing returns nothing
    set gg_trg_FullAimSetTryHandleVars = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ(gg_trg_FullAimSetTryHandleVars, EVENT_PLAYER_UNIT_SPELL_EFFECT)
	call TriggerAddCondition(gg_trg_FullAimSetTryHandleVars, Condition(function AimSetCond))
    call TriggerAddAction( gg_trg_FullAimSetTryHandleVars, function AimSetAct )
endfunction

endscope

This code doesn't contain TriggerSleepAction, it do dealt damage and shows the value of caster, target, and dmg.

But once i added TriggerSleepAction with 1.2 second, the entire decoding fail.
No damage dealt, no words are shown.

If i dont add in the TriggerSleepAction, the spell would look wierd which the damage is dealt before the missle came down...

HELP !!~~
 
You have to check your conditions before starting timer. Problem still was that you used TriggerSleepAction(X) in timer callback function what you can' t do.
You could solve kinda problem by creating two timers - one for special effects and another for doing damage and checking does caster is channeling still.
Special effect timer would be periodic timer what would run after 1.2 seconds and would destroy effects (If any created) and creates new laser effects.
Second timer would run each .5 seconds and would check is there still time to run ability and is caster channeling ability. If not it would pause first timer and will destroy all effects. Pauses both timers and ends ability.
If you are already using global variables for passing effects why are you still using handle system to pass other handles ? You could use for all things global variables.
Unit variables dosn' t need to be nulled.
 
>>used TriggerSleepAction(X) in timer callback function what you can' t do.
Reply With Quote

I..can't?
 
executefunc native and some globals to pass your arguments? with a short wait in it
 
General chit-chat
Help Users

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top