Trigger doing double?

ZakkWylde-

New Member
Reaction score
14
JASS:
function Trig_RedTerrainKill_Actions takes nothing returns nothing
    local unit u = udg_DemonHunters[1] //Red's DH
    local real x = GetUnitX(u)
    local real y = GetUnitY(u)
    local effect e
    
    if GetTerrainType(x, y) == udg_DeathTerVines and IsTriggerEnabled(gg_trg_RedTerrainKill)==true and GetUnitMoveSpeed(u)==522 then
        call SetUnitMoveSpeed(u, 520)
        call DisableTrigger(gg_trg_RedTerrainKill)
        set e = AddSpecialEffect("Abilities\\Spells\\NightElf\\EntanglingRoots\\EntanglingRootsTarget.mdl", x, y)        

        call TriggerSleepAction(2)
        call SetUnitExploded(u, true)
        call KillUnit(u)

        call SetUnitMoveSpeed(u, 522)
        call DestroyEffect(e)
        set e = null
        call EnableTrigger(gg_trg_RedTerrainKill)
    endif
    
endfunction

//===========================================================================
function InitTrig_RedTerrainKill takes nothing returns nothing
    set gg_trg_RedTerrainKill = CreateTrigger(  )
    call TriggerRegisterTimerEvent(gg_trg_RedTerrainKill, 0.1, true)
    call TriggerAddAction( gg_trg_RedTerrainKill, function Trig_RedTerrainKill_Actions )
endfunction


This seems to run twice...(probably the culprit is TriggerSleepAction(2.0))
After 2 seconds, it kills red's Demon hunter...then once it revives, 2 seconds after it killed red's Demon hunter, it kills it again.

Is there any reason for this and how can I get around it?
 

jwallstone

New Member
Reaction score
33
Actually, I think it's just because you've set the event to be periodic, i.e. after the TriggerSleepAction is done, and you Enable the trigger, it'll run again immediately after 0.1 seconds.

Just change this:
[ljass]call TriggerRegisterTimerEvent(gg_trg_RedTerrainKill, 0.1, true) [/ljass]

to this:
[ljass]call TriggerRegisterTimerEvent(gg_trg_RedTerrainKill, 0.1, false) [/ljass]
 

ZakkWylde-

New Member
Reaction score
14
>I don't think you should be pausing the trigger that is currently being run:nuts:

I disable the trigger so that it doesn't MASS CREATE entangling roots effects every .1 seconds...but the trigger still runs through to the end...

>Actually, I think it's just because you've set the event to be periodic, i.e. after the TriggerSleepAction is done, and you Enable the trigger, it'll run again immediately after 0.1 seconds.

Yeah that makes sense! =D
but I don't want to make that false...because it's terrain kill.
Running it once would be kinda pointless, because after that, the units can run all over that terrain. Heh.

I just turned the old one into this (which works fine as far as I can tell):
JASS:
function RedTerrainKill takes nothing returns nothing
    local unit u = udg_DemonHunters[1]
    local real x = GetUnitX(u)
    local real y = GetUnitY(u)
    local effect e
    
    if GetTerrainType(x, y) == udg_DeathTerVines and IsUnitAliveBJ(u)==true then
        call SetUnitMoveSpeed(u, 520)
        call PauseUnit(u, true)
        call SetUnitFacing(u, GetUnitFacing(u))
        set e = AddSpecialEffect("Abilities\\Spells\\NightElf\\EntanglingRoots\\EntanglingRootsTarget.mdl", x, y)        
        call DisableTrigger(gg_trg_RedTerrainKill)
        call TriggerSleepAction(2)
        call SetUnitExploded(u, true)
        call KillUnit(u)
        call PauseUnit(u, false)
        call SetUnitMoveSpeed(u, 522)
        call DestroyEffect(e)
        set e = null
        call EnableTrigger(gg_trg_RedTerrainKill)
    endif
    
endfunction

//===========================================================================
function InitTrig_RedTerrainKill takes nothing returns nothing
    set gg_trg_RedTerrainKill = CreateTrigger(  )
    call TriggerRegisterTimerEvent(gg_trg_RedTerrainKill, 0.1, true)
    call TriggerAddAction( gg_trg_RedTerrainKill, function RedTerrainKill )
endfunction
 

ZugZugZealot

New Member
Reaction score
33
Try this instead.

JASS:
function LaunchRTK takes nothing returns nothing
    if IsTriggerEnabled( RedTerrainKill ) then
        call TriggerExecute( gg_trg_RedTerrainKill )
    endif
endfunction

function RedTerrainKill takes nothing returns nothing
    local unit u = udg_DemonHunters[1]
    local real x = GetUnitX(u)
    local real y = GetUnitY(u)
    local effect e
    
    if GetTerrainType(x, y) == udg_DeathTerVines and IsUnitAliveBJ(u)==true then
        call SetUnitMoveSpeed(u, 520)
        call PauseUnit(u, true)
        call SetUnitFacing(u, GetUnitFacing(u))
        set e = AddSpecialEffect("Abilities\\Spells\\NightElf\\EntanglingRoots\\EntanglingRootsTarget.mdl", x, y)
        call TriggerSleepAction(2)
        call SetUnitExploded(u, true)
        call KillUnit(u)
        call PauseUnit(u, false)
        call SetUnitMoveSpeed(u, 522)
        call DestroyEffect(e)
        set e = null
    endif
    
    call TimerStart( udg_RTKTimer, 0.10, false, function LaunchRTK )
endfunction

//===========================================================================
function InitTrig_RedTerrainKill takes nothing returns nothing
    set gg_trg_RedTerrainKill = CreateTrigger(  )
    call TriggerAddAction( gg_trg_RedTerrainKill, function RedTerrainKill )
endfunction


You'll need to use [ljass]call TriggerExecute( gg_trg_RedTerrainKill )[/ljass] to enable it; be it at game start or later on.
 

ZakkWylde-

New Member
Reaction score
14
I fail to see how that makes it terrain kill. It seems that you are just running the actions once after timer expires in .1 seconds...:confused: and when wouldn't that trigger be enabled...? Isn't it enabled as soon as the map starts (or even before, I guess)?

JASS:
if IsTriggerEnabled( RedTerrainKill ) then //I presume you meant gg_trg_RedTerrainKill ?
        call TriggerExecute( gg_trg_RedTerrainKill )
    endif


Again, I want this to be terrain kill, and in order for it be so, I need to check periodically (and pretty often)...or am I missing/misunderstanding something here?

Anyways I appreciate the time you take to respond, so please continue to do so until we can get things sorted out =D.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top