• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

A leaking condition?

Status
Not open for further replies.
Level 7
Joined
Feb 7, 2009
Messages
93
well i have in my currently spawn typed map encountered an annoying problem.
it works pretty much as its supposed to untill the game ends since when that
happens a huge lag starts, and most players have to either close warcraft3
or their computer to make it end, i have been told that its the conditions that leak.

so i need some help with my spawn trigger :) im sure that there is some realy simple sollution
that i just fail to notice. And if someone can tell me how it should be then
best would be if the ansver was in gui cause i cant do jass yet.

  • redvillagespawn
    • Events
      • Time - Spawntimer expires
    • Conditions
      • (Number of units in (Units owned by Player 1 (Red))) Less than 160
      • (Inn 0696 <gen> is alive) Equal to True
      • (Number of units in (Units owned by Player 1 (Red) of type Fort)) Less than or equal to 1
      • (Player 1 (Red) controller) Equal to User
    • Actions
      • Set quickusepoint = (Center of Red village <gen>)
      • Unit - Create 1 Militia for Player 1 (Red) at quickusepoint facing 0.00 degrees
      • Custom script: call RemoveLocation( udg_quickusepoint )

JASS:
function Trig_redvillagespawn_Conditions takes nothing returns boolean
    if ( not ( CountUnitsInGroup(GetUnitsOfPlayerAll(Player(0))) < 160 ) ) then
        return false
    endif
    if ( not ( IsUnitAliveBJ(gg_unit_n01X_0696) == true ) ) then
        return false
    endif
    if ( not ( CountUnitsInGroup(GetUnitsOfPlayerAndTypeId(Player(0), 'n01R')) <= 1 ) ) then
        return false
    endif
    if ( not ( GetPlayerController(Player(0)) == MAP_CONTROL_USER ) ) then
        return false
    endif
    return true
endfunction

function Trig_redvillagespawn_Actions takes nothing returns nothing
    set udg_quickusepoint = GetRectCenter(gg_rct_Red_village)
    call CreateNUnitsAtLoc( 1, 'h003', Player(0), udg_quickusepoint, 0.00 )
    call RemoveLocation( udg_quickusepoint )
endfunction

//===========================================================================
function InitTrig_redvillagespawn takes nothing returns nothing
    set gg_trg_redvillagespawn = CreateTrigger(  )
    call TriggerRegisterTimerExpireEventBJ( gg_trg_redvillagespawn, udg_Spawntimer )
    call TriggerAddCondition( gg_trg_redvillagespawn, Condition( function Trig_redvillagespawn_Conditions ) )
    call TriggerAddAction( gg_trg_redvillagespawn, function Trig_redvillagespawn_Actions )
endfunction
i hope i posted right and stuff :D
 
Level 13
Joined
Nov 22, 2006
Messages
1,260
  • Conditions
    • (Number of units in (Units owned by Player 1 (Red))) Less than 160
    • (Number of units in (Units owned by Player 1 (Red) of type Fort)) Less than or equal to 1
Those are the conditions that leak. You should put those "Units owned by Player 1 (Red)" and "Units owned by Player 1 (Red) of type Fort" in a group variable and destroy them.

The minor problem here is that you can't put those checks under "Conditions", but you can simply make an if then else (multiple actions). So something like this:

  • redvillagespawn
    • Events
      • Time - Spawntimer expires
    • Conditions
      • (Inn 0696 <gen> is alive) Equal to True
      • (Player 1 (Red) controller) Equal to User
    • Actions
      • Set Group1 = (Units owned by Player 1 (Red))
      • Set Group2 = (Units owned by Player 1 (Red) of type Fort)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of units in Group1) Less than 160
          • (Number of units in Group2) Less than or equal to 1
        • Then - Actions
          • Set quickusepoint = (Center of Red village <gen>)
          • Unit - Create 1 Militia for Player 1 (Red) at quickusepoint facing 0.00 degrees
          • Custom script: call RemoveLocation( udg_quickusepoint )
        • Else - Actions
      • Custom script: call DestroyGroup( udg_Group1 )
      • Custom script: call DestroyGroup( udg_Group2 )
So those two remaining conditions can stay where they are.
 
Level 7
Joined
Feb 7, 2009
Messages
93
  • Conditions
    • (Number of units in (Units owned by Player 1 (Red))) Less than 160
    • (Number of units in (Units owned by Player 1 (Red) of type Fort)) Less than or equal to 1
Those are the conditions that leak. You should put those "Units owned by Player 1 (Red)" and "Units owned by Player 1 (Red) of type Fort" in a group variable and destroy them.

The minor problem here is that you can't put those checks under "Conditions", but you can simply make an if then else (multiple actions). So something like this:

  • redvillagespawn
    • Events
      • Time - Spawntimer expires
    • Conditions
      • (Inn 0696 <gen> is alive) Equal to True
      • (Player 1 (Red) controller) Equal to User
    • Actions
      • Set Group1 = (Units owned by Player 1 (Red))
      • Set Group2 = (Units owned by Player 1 (Red) of type Fort)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of units in Group1) Less than 160
          • (Number of units in Group2) Less than or equal to 1
        • Then - Actions
          • Set quickusepoint = (Center of Red village <gen>)
          • Unit - Create 1 Militia for Player 1 (Red) at quickusepoint facing 0.00 degrees
          • Custom script: call RemoveLocation( udg_quickusepoint )
        • Else - Actions
      • Custom script: call DestroyGroup( udg_Group1 )
      • Custom script: call DestroyGroup( udg_Group2 )
So those two remaining conditions can stay where they are.

uhh can i do it like this instead?
  • redvillagespawn
    • Events
      • Time - spawntimer expires
    • Conditions
      • (Inn 0696 <gen> is alive) Equal to True
      • (Player 1 (Red) controller) Equal to User
    • Actions
      • Set unitpicker = (Units owned by Player 1 (Red))
      • If ((Number of units in unitpicker) Greater than or equal to 160) then do (Skip remaining actions) else do (Do nothing)
      • Custom script: call DestroyGroup( udg_unitpicker )
      • Set unitpicker = (Units owned by Player 1 (Red) of type Fort)
      • If ((Number of units in unitpicker) Greater than 1) then do (Skip remaining actions) else do (Do nothing)
      • Custom script: call DestroyGroup( udg_unitpicker )
      • Set quickusepoint = (Center of Red village <gen>)
      • Unit - Create 1 Militia for Player 1 (Red) at quickusepoint facing 0.00 degrees
      • Custom script: call RemoveLocation( udg_quickusepoint )
 
Level 13
Joined
Nov 22, 2006
Messages
1,260
Well, you can but it will leak your way. You can do this:

  • redvillagespawn
    • Events
      • Time - spawntimer expires
    • Conditions
      • (Inn 0696 <gen> is alive) Equal to True
      • (Player 1 (Red) controller) Equal to User
    • Actions
      • Set unitpicker = (Units owned by Player 1 (Red))
      • Set unitpickerCount = (Number of units in unitpicker)
      • Custom script: call DestroyGroup( udg_unitpicker )
      • If (unitpickerCount Greater than or equal to 160) then do (Skip remaining actions) else do (Do nothing)
      • Set unitpicker = (Units owned by Player 1 (Red) of type Fort)
      • Set unitpickerCount = (Number of units in unitpicker)
      • Custom script: call DestroyGroup( udg_unitpicker )
      • If (unitpickerCount Greater than 1) then do (Skip remaining actions) else do (Do nothing)
      • Set quickusepoint = (Center of Red village <gen>)
      • Unit - Create 1 Militia for Player 1 (Red) at quickusepoint facing 0.00 degrees
      • Custom script: call RemoveLocation( udg_quickusepoint )
This way it won't leak.

Btw, unitpickerCount is an integer variable.
 
Level 10
Joined
Feb 20, 2008
Messages
448
Level 7
Joined
Feb 7, 2009
Messages
93
You realize that if it's greater than or equal to 160, it will never get to the "Call destroygroup" part and thus leak?

now im confused, did the trigger that the other guy said, leak or not?
this is how my trigger looks now


  • redvillagespawn
    • Events
      • Time - spawntimer expires
    • Conditions
      • (Inn 0696 <gen> is alive) Equal to True
      • (Player 1 (Red) controller) Equal to User
    • Actions
      • Set unitpicker = (Units owned by Player 1 (Red))
      • Set unitpickercounter = (Number of units in unitpicker)
      • Custom script: call DestroyGroup( udg_unitpicker )
      • If (unitpickercounter Greater than or equal to 160) then do (Skip remaining actions) else do (Do nothing)
      • Set unitpicker = (Units owned by Player 1 (Red) of type Fort)
      • Set unitpickercounter = (Number of units in unitpicker)
      • Custom script: call DestroyGroup( udg_unitpicker )
      • If (unitpickercounter Greater than 1) then do (Skip remaining actions) else do (Do nothing)
      • Set quickusepoint = (Center of Red village <gen>)
      • Unit - Create 1 Militia for Player 1 (Red) at quickusepoint facing 0.00 degrees
      • Custom script: call RemoveLocation( udg_quickusepoint )
 
Status
Not open for further replies.
Top