• 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.
  • Create a faction for Warcraft 3 and enter Hive's 19th Techtree Contest: Co-Op Commanders! Click here to enter!
  • Get your art tools and paintbrushes ready and enter Hive's 34th Texturing Contest: Void! Click here to enter!

Noob question on trigger efficiency

Status
Not open for further replies.
Level 3
Joined
Dec 2, 2009
Messages
23
Hi guys. I have recently started working with triggers for my map. I am wondering if this is efficient. This is supposed to be a spawn trigger once 2 gates have been destroyed. I wonder if I should separate this into various triggers or maybe if its better to just get em all on one like in the example below which is 1 event, no conditions 2 IF actions

Code:
function Trig_T1_Spawns_Func001C takes nothing returns boolean
    if ( not ( IsUnitAliveBJ(gg_unit_h005_0052) == true ) ) then
        return false
    endif
    if ( not ( IsDestructableAliveBJ(gg_dest_LTe2_0067) == false ) ) then
        return false
    endif
    if ( not ( IsDestructableAliveBJ(gg_dest_B002_0352) == false ) ) then
        return false
    endif
    return true
endfunction

function Trig_T1_Spawns_Func002C takes nothing returns boolean
    if ( not ( IsUnitAliveBJ(gg_unit_h005_0085) == true ) ) then
        return false
    endif
    if ( not ( IsDestructableAliveBJ(gg_dest_B002_0354) == false ) ) then
        return false
    endif
    if ( not ( IsDestructableAliveBJ(gg_dest_LTe4_0006) == false ) ) then
        return false
    endif
    return true
endfunction

function Trig_T1_Spawns_Actions takes nothing returns nothing
    if ( Trig_T1_Spawns_Func001C() ) then
        call CreateNUnitsAtLoc( 2, 'e000', Player(8), GetRectCenter(gg_rct_RightBarracks), 315.00 )
        call CreateNUnitsAtLoc( 4, 'h00J', Player(8), GetRectCenter(gg_rct_RightBarracks), 315.00 )
    else
    endif
    if ( Trig_T1_Spawns_Func002C() ) then
        call CreateNUnitsAtLoc( 4, 'h00J', Player(8), GetRectCenter(gg_rct_LeftBarracks), 225.00 )
        call CreateNUnitsAtLoc( 2, 'e000', Player(8), GetRectCenter(gg_rct_LeftBarracks), 225.00 )
    else
    endif
endfunction

//===========================================================================
function InitTrig_T1_Spawns takes nothing returns nothing
    set gg_trg_T1_Spawns = CreateTrigger(  )
    call TriggerRegisterTimerEventPeriodic( gg_trg_T1_Spawns, 30.00 )
    call TriggerAddAction( gg_trg_T1_Spawns, function Trig_T1_Spawns_Actions )
endfunction
 
Level 3
Joined
Dec 2, 2009
Messages
23
I hope this is better. There are 4 location leaks where units are created right?

Code:
T1 Spawns
    Events
        Time - Every 30.00 seconds of game time
    Conditions
    Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                (Holy Barracks 0052 <gen> is alive) Equal to True
                (Elven Gate (Diagonal 1) 0067 <gen> is alive) Equal to False
                (EGV (Vertical) 0352 <gen> is alive) Equal to False
            Then - Actions
                Unit - Create 2 Angel for Player 9 (Gray) at (Center of RightBarracks <gen>) facing 315.00 degrees
                Unit - Create 4 Warrior Angel for Player 9 (Gray) at (Center of RightBarracks <gen>) facing 315.00 degrees
            Else - Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                (Holy Barracks 0085 <gen> is alive) Equal to True
                (EGV (Vertical) 0354 <gen> is alive) Equal to False
                (Elven Gate (Diagonal 2) 0006 <gen> is alive) Equal to False
            Then - Actions
                Unit - Create 4 Warrior Angel for Player 9 (Gray) at (Center of LeftBarracks <gen>) facing 225.00 degrees
                Unit - Create 2 Angel for Player 9 (Gray) at (Center of LeftBarracks <gen>) facing 225.00 degrees
            Else - Actions
 
Level 37
Joined
Mar 6, 2006
Messages
9,243
Use trigger tags.

  • T1 Spawns
    • Events
      • Time - Every 30.00 seconds of game time
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Holy Barracks 0052 <gen> is alive) Equal to True
          • (Elven Gate (Diagonal 1) 0067 <gen> is alive) Equal to False
          • (EGV (Vertical) 0352 <gen> is alive) Equal to False
        • Then - Actions
          • Unit - Create 2 Angel for Player 9 (Gray) at (Center of RightBarracks <gen>) facing 315.00 degrees
          • Unit - Create 4 Warrior Angel for Player 9 (Gray) at (Center of RightBarracks <gen>) facing 315.00 degrees
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Holy Barracks 0085 <gen> is alive) Equal to True
          • (EGV (Vertical) 0354 <gen> is alive) Equal to False
          • (Elven Gate (Diagonal 2) 0006 <gen> is alive) Equal to False
        • Then - Actions
          • Unit - Create 4 Warrior Angel for Player 9 (Gray) at (Center of LeftBarracks <gen>) facing 225.00 degrees
          • Unit - Create 2 Angel for Player 9 (Gray) at (Center of LeftBarracks <gen>) facing 225.00 degrees
        • Else - Actions
The trigger is OK other than that you leak locations.

This is how to remove leaks:
  • Set Temp_Loc_1 = Center of LeftBarracks <gen>
  • Unit - Create 4 Warrior Angel for Player 9 (Gray) at Temp_Loc_1 facing 225.00 degrees
  • Custom script: call RemoveLocation(udg_Temp_Loc_1)
 
Status
Not open for further replies.
Top