Disabling (or not enabling) triggers?

ZakkWylde-

New Member
Reaction score
14
JASS:
set udg_is_activ_j[n] = ((GetPlayerController( Player(n) ) == MAP_CONTROL_USER and GetPlayerSlotState( Player(n) ) == PLAYER_SLOT_STATE_PLAYING) or GetPlayerController( Player(n) ) == MAP_CONTROL_COMPUTER)
if udg_is_activ_j[n] then
      set udg_DemonHunters[n] = CreateUnit(Player(n), 'Edem', Xpos, Ypos, 0)
      call SetUnitAnimation(udg_DemonHunters[n], "Spell Alternate")
      call EnableTrigger(udg_check_terrain_j[n]) //each of the terrain kills are set to this global variable upon map initialization
endif


example of one terrain kill initialitzation:
JASS:
function InitTrig_RedTerrainKill takes nothing returns nothing
    set gg_trg_RedTerrainKill = CreateTrigger(  )
    call DisableTrigger(gg_trg_RedTerrainKill)
    call TriggerRegisterTimerEvent(gg_trg_RedTerrainKill, 0.1, true)
    call TriggerAddAction( gg_trg_RedTerrainKill, function RedTerrainKill )
endfunction


So how could I make it so that the terrain kill for each player is run ONLY if he/she is a player in the game?

I could be going about this the completely wrong way...but the way I have it now may not work.
 

ZakkWylde-

New Member
Reaction score
14
Mmk....if you really want...

JASS:
function Trig_GroupDefine_Actions takes nothing returns nothing
    local integer i = 0
    local integer j = 0
    local integer n = 0
    local real Xmax = GetRectMaxX(gg_rct_lvl1)
    local real Xmin = GetRectMinX(gg_rct_lvl1)
    local real Ymax = GetRectMaxY(gg_rct_lvl1)
    local real Ymin = GetRectMinY(gg_rct_lvl1)
    //local real Xdiff = ((Xmax-Xmin)/2)
    //local real Ydiff = Ymax-Ymin
    local real Xpos = Xmax+150
    local real Ypos = Ymin-50
    
    loop
        exitwhen i > 2
        loop
            exitwhen j > 3
            set Ypos = Ypos+50
            set Xpos = Xpos-150
            set udg_is_activ_j[n] = ((GetPlayerController( Player(n) ) == MAP_CONTROL_USER and GetPlayerSlotState( Player(n) ) == PLAYER_SLOT_STATE_PLAYING) or GetPlayerController( Player(n) ) == MAP_CONTROL_COMPUTER)
            if udg_is_activ_j[n] then
                set udg_DemonHunters[n] = CreateUnit(Player(n), 'Edem', Xpos, Ypos, 0)
                call SetUnitAnimation(udg_DemonHunters[n], "Spell Alternate")
                call EnableTrigger(udg_check_terrain_j[n])
            endif
            set n = n + 1
            set j = j + 1
        endloop
        set j = 0
        set i = i + 1
        set Xpos = Xmax+150
    endloop
    
    set i = 0
    
endfunction
// EDIT: I'm proud of my loops...it spawns a pattern going down and to the right, then resets back 
//to left after 4 demon hunters (so 3 rows kinda) =D :ENDEDIT
function Trig_init_slide_triggers_Actions takes nothing returns nothing

    set udg_check_terrain_j[0] = gg_trg_RedTerrainKill
    set udg_check_terrain_j[1] = gg_trg_BlueTerrainKill
    set udg_check_terrain_j[2] = gg_trg_TealTerrainKill
    set udg_check_terrain_j[3] = gg_trg_PurpleTerrainKill
    set udg_check_terrain_j[4] = gg_trg_YellowTerrainKill
    set udg_check_terrain_j[5] = gg_trg_OrangeTerrainKill
    set udg_check_terrain_j[6] = gg_trg_GreenTerrainKill
    set udg_check_terrain_j[7] = gg_trg_PinkTerrainKill
    set udg_check_terrain_j[8] = gg_trg_GrayTerrainKill
    set udg_check_terrain_j[9] = gg_trg_LBTerrainKill
    set udg_check_terrain_j[10] = gg_trg_DGTerrainKill
    set udg_check_terrain_j[11] = gg_trg_BrownTerrainKill
    
    call ExecuteFunc("Trig_GroupDefine_Actions")
endfunction
//===========================================================================
function InitTrig_GroupDefine takes nothing returns nothing
    set gg_trg_GroupDefine = CreateTrigger(  )
    call TriggerAddAction( gg_trg_GroupDefine, function Trig_init_slide_triggers_Actions )
endfunction


Here's one of the terrain kills (FOR LIGHT BLUE!)

JASS:
function LBTerrainKill takes nothing returns nothing
    local unit u = udg_DemonHunters[9]
    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_LBTerrainKill)
        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_LBTerrainKill)
    endif
    
endfunction

//===========================================================================
function InitTrig_LBTerrainKill takes nothing returns nothing
    set gg_trg_LBTerrainKill = CreateTrigger(  )
    call DisableTrigger(gg_trg_LBTerrainKill) //I sense problems with the order of enabling / disabling ... 
    call TriggerRegisterTimerEvent(gg_trg_LBTerrainKill, 0.1, true)
    call TriggerAddAction( gg_trg_LBTerrainKill, function LBTerrainKill )
endfunction
 

cleeezzz

The Undead Ranger.
Reaction score
268


you can get rid of that boolean array.

also, why do you use N and J, when J and N are exactly the same value? since J is used to exit the loop, just replace all your n with j.

now create a global trigger array, for example

JASS:
globals
trigger array TRIGS[12]
endglobals

now before or after you disable each of the player terrain kill triggers, set TRIG[Player number] to the trigger name (within the Initializer and after trigger is created)

for example for LB

JASS:
function InitTrig_LBTerrainKill takes nothing returns nothing
    set gg_trg_LBTerrainKill = CreateTrigger(  )
    set TRIGS[10] = gg_trg_LBTerrainKill //Player 10 is LB right?
    call DisableTrigger(gg_trg_LBTerrainKill) //I sense problems with the order of enabling / disabling ... 
    call TriggerRegisterTimerEvent(gg_trg_LBTerrainKill, 0.1, true)
    call TriggerAddAction( gg_trg_LBTerrainKill, function LBTerrainKill )
endfunction


now in your first trigger, just do
JASS:
call EnableTrigger(TRIGS[j])
 

ZakkWylde-

New Member
Reaction score
14
Why thank you sir. :D

But now, on to my super pro loop.

Obviously it went way over your head :p. n and j are not the same values. j never goes above 3. n goes from 0 to 11. I use it to spawn a pattern. j loops four times per i. i loops three times. i.e. three rows of four units, each slightly displaced compared to the other.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top