• 🏆 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!

Does this tigger leak? if yes then how do i fix

Status
Not open for further replies.
Level 11
Joined
Jul 17, 2013
Messages
544
  • nienazwany chuj
    • Events
      • Time - Every 0.99 seconds of game time
    • Conditions
    • Actions
      • Set TempUnitGroup = (Units of type TradePort)
      • Unit Group - Pick every unit in TempUnitGroup and do (Actions)
        • Loop - Actions
          • Set Picked_Copy = (Picked unit)
          • Unit Group - Pick every unit in (Units within 360.00 of (Position of (Picked unit))) and do (Actions)
            • Loop - Actions
              • Set Picked = (Picked unit)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Owner of (Picked unit)) Not equal to (Owner of Picked_Copy)
                  • ((Owner of (Picked unit)) is an ally of (Owner of Picked_Copy)) Equal to True
                  • (Unit-type of (Picked unit)) Equal to MerchantShip
                • Then - Actions
                  • Player - Add 600 to (Owner of Picked_Copy) Current gold
                  • Unit - Remove (Picked unit) from the game
                • Else - Actions
      • Custom script: call DestroyGroup(udg_TempUnitGroup)
 
Level 11
Joined
Nov 23, 2013
Messages
665
I think you should create a unit group variable and store Units within 360.00 of (Position of (Picked unit)) in it before your second loop. Then after that loop, use DestroyGroup again to destroy that group.
 
Level 11
Joined
Jul 17, 2013
Messages
544
I think you should create a unit group variable and store Units within 360.00 of (Position of (Picked unit)) in it before your second loop. Then after that loop, use DestroyGroup again to destroy that group.
are you able to post me that tigger at map :(? triggers are dark magic for me rly xd pls post at map if u can or send here how it shoul dlook like
 
Level 6
Joined
Jun 4, 2017
Messages
172
  • nienazwany chuj
    • Events
      • Time - Every 0.99 seconds of game time
    • Conditions
    • Actions
      • Set TempUnitGroup = (Units of type TradePort)
      • Unit Group - Pick every unit in TempUnitGroup and do (Actions)
        • Loop - Actions
          • Set Picked_Copy = (Picked unit)
          • Unit Group - Pick every unit in (Units within 360.00 of (Position of (Picked unit))) and do (Actions)
            • Loop - Actions
              • Set Picked = (Picked unit)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Owner of (Picked unit)) Not equal to (Owner of Picked_Copy)
                  • ((Owner of (Picked unit)) is an ally of (Owner of Picked_Copy)) Equal to True
                  • (Unit-type of (Picked unit)) Equal to MerchantShip
                • Then - Actions
                  • Player - Add 600 to (Owner of Picked_Copy) Current gold
                  • Unit - Remove (Picked unit) from the game
                • Else - Actions
      • Custom script: call DestroyGroup(udg_TempUnitGroup)
I think there are 4 leaks: Picked Unit_Copy variable isn't removed, Picked Unit variable isn't removed, Position of (Picked unit) leaks a point for every execution, Units within 360.00 of (Position of (Picked unit)) isn't stored in a variable and I think it will create a leak for every execution too.
However I'm not 100% sure
 
Level 7
Joined
Mar 10, 2013
Messages
366
I think there are 4 leaks: Picked Unit_Copy variable isn't removed, Picked Unit variable isn't removed, Position of (Picked unit) leaks a point for every execution, Units within 360.00 of (Position of (Picked unit)) isn't stored in a variable and I think it will create a leak for every execution too.
However I'm not 100% sure
I only spot the Unit Group and the Point leaks.

Since picked unit and picked unit copy are both globals (one local for his map and one bj, used in the loop).

  • nienazwany chuj
    • Events
      • Time - Every 0.99 seconds of game time
    • Conditions
    • Actions
      • Set TempUnitGroup = (Units of type TradePort)
      • Unit Group - Pick every unit in TempUnitGroup and do (Actions)
        • Loop - Actions
          • Set Picked_Copy = (Picked unit)
          • Set TempPoint = (Position of (Picked unit))
          • Set TempUnitGroup2 = ((Units within 360.00 of TempPoint))
          • Custom script: call RemoveLocation(udg_TempPoint)
          • Unit Group - Pick every unit in TempUnitGroup2 and do (Actions)
            • Loop - Actions
              • Set Picked = (Picked unit)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Owner of (Picked unit)) Not equal to (Owner of Picked_Copy)
                  • ((Owner of (Picked unit)) is an ally of (Owner of Picked_Copy)) Equal to True
                  • (Unit-type of (Picked unit)) Equal to MerchantShip
                • Then - Actions
                  • Player - Add 600 to (Owner of Picked_Copy) Current gold
                  • Unit - Remove (Picked unit) from the game
                • Else - Actions
          • Custom script: call DestroyGroup(udg_TempUnitGroup2)
      • Custom script: call DestroyGroup(udg_TempUnitGroup)
This should fix your leaks.
Also, yes, this may very well leak so much to make the game unpleayable, since it leaks the amount TempUnitGroup times groups and the amount TempUnitGroup times regions summed. Since we don't know how much units TempUnitGroup does have I can't say for certain, but if every second if have 10+ units, it would leak 10 groups and 10 points for every second of game.
 
Last edited:
Level 6
Joined
Jun 4, 2017
Messages
172
is this tigger able to crash game after 20 min of palying?
I'm not sure, if your triggers has only these 4 leaks, and it is the only trigger that leak so maybe more than 20 minutes, but in a long time it will probably crash, however I'm not sure, I think it probably depends on the RAM of your PC probably.
i can also post other tiggers i think they might have leaks too :(
Why not? :)
 
Level 13
Joined
Mar 24, 2013
Messages
1,105
The Units of Type function leaks so we cannot use it.

You need to create the group/identify the units yourself. -- See below how below.

Then once you've identified the units you're looking for, you get their location and create another group around their position and then search for the ships, if we find any we remove each one and add gold to the player who owned them.


  • SomeTrig
    • Events
    • Every .99 sec.
    • Conditions
    • Actions
      • Set TempGroup = (Units in (Playable map area))
      • Unit Group - Pick every unit in TempGroup and do (Actions)
        • Loop - Actions
          • Set TempUnit = (Picked unit)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Unit-type of TempUnit) Equal to TradePort
            • Then - Actions
              • Set TempPoint = (Position of TempUnit)
              • Set TempGroup2 = (Units within 360.00 of TempPoint)
              • Unit Group - Pick every unit in TempGroup2 and do (Actions)
                • Loop - Actions
                  • Set TempUnit2 = (Picked unit)
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Owner of TempUnit) Not equal to (Owner of TempUnit2)
                      • (TempUnit belongs to an ally of (Owner of TempUnit2)) Equal to True
                      • (Unit-type of TempUnit2) Equal to MerchantShip
                    • Then - Actions
                      • Player - Add 600 to (Owner of TempUnit) Current gold
                      • Unit - Remove TempUnit from the game
                    • Else - Actions
              • Custom script: call RemoveLocation(udg_TempPoint)
              • Custom script: call DestroyGroup(udg_TempGroup2)
            • Else - Actions
      • Custom script: call DestroyGroup(udg_TempGroup)
 
Level 7
Joined
Mar 10, 2013
Messages
366
The Units of Type function leaks so we cannot use it.

You need to create the group/identify the units yourself. -- See below how below.

Then once you've identified the units you're looking for, you get their location and create another group around their position and then search for the ships, if we find any we remove each one and add gold to the player who owned them.


  • SomeTrig
    • Events
    • Every .99 sec.
    • Conditions
    • Actions
      • Set TempGroup = (Units in (Playable map area))
      • Unit Group - Pick every unit in TempGroup and do (Actions)
        • Loop - Actions
          • Set TempUnit = (Picked unit)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Unit-type of TempUnit) Equal to TradePort
            • Then - Actions
              • Set TempPoint = (Position of TempUnit)
              • Set TempGroup2 = (Units within 360.00 of TempPoint)
              • Unit Group - Pick every unit in TempGroup2 and do (Actions)
                • Loop - Actions
                  • Set TempUnit2 = (Picked unit)
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Owner of TempUnit) Not equal to (Owner of TempUnit2)
                      • (TempUnit belongs to an ally of (Owner of TempUnit2)) Equal to True
                      • (Unit-type of TempUnit2) Equal to MerchantShip
                    • Then - Actions
                      • Player - Add 600 to (Owner of TempUnit) Current gold
                      • Unit - Remove TempUnit from the game
                    • Else - Actions
              • Custom script: call RemoveLocation(udg_TempPoint)
              • Custom script: call DestroyGroup(udg_TempGroup2)
            • Else - Actions
      • Custom script: call DestroyGroup(udg_TempGroup)


Are you sure the Units of Type implementation leaks?
 
Level 6
Joined
Jun 4, 2017
Messages
172
Level 13
Joined
Mar 24, 2013
Messages
1,105
@emil23

This trigger even in it's first form would not be enough to cause a crash outright. The leaks would eventually stack up and result in fps dropping/lag and eventually when wc3 runs out of memory it would crash but it would be a rather long while before this trigger would have that kind of impact.

You can post other triggers that you think could be problematic, but a crash usually results in doing something like an infinite loop, moving destroyed lightning etc. Check out [Crash] - List of WarCraft III Crashes and see if you are doing any of these things.
 
Level 7
Joined
Dec 19, 2014
Messages
300
You could also activate and deactivate the trigger only if it's needed. When a unit enters the area around these TradePorts the trigger is activated and when a unit leaves or dies in the area and no units are in the area left the trigger is deactivated. I also created visibility triggers in my map this way.
 
Level 11
Joined
Jul 17, 2013
Messages
544
The Units of Type function leaks so we cannot use it.

You need to create the group/identify the units yourself. -- See below how below.

Then once you've identified the units you're looking for, you get their location and create another group around their position and then search for the ships, if we find any we remove each one and add gold to the player who owned them.


  • SomeTrig
    • Events
    • Every .99 sec.
    • Conditions
    • Actions
      • Set TempGroup = (Units in (Playable map area))
      • Unit Group - Pick every unit in TempGroup and do (Actions)
        • Loop - Actions
          • Set TempUnit = (Picked unit)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Unit-type of TempUnit) Equal to TradePort
            • Then - Actions
              • Set TempPoint = (Position of TempUnit)
              • Set TempGroup2 = (Units within 360.00 of TempPoint)
              • Unit Group - Pick every unit in TempGroup2 and do (Actions)
                • Loop - Actions
                  • Set TempUnit2 = (Picked unit)
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Owner of TempUnit) Not equal to (Owner of TempUnit2)
                      • (TempUnit belongs to an ally of (Owner of TempUnit2)) Equal to True
                      • (Unit-type of TempUnit2) Equal to MerchantShip
                    • Then - Actions
                      • Player - Add 600 to (Owner of TempUnit) Current gold
                      • Unit - Remove TempUnit from the game
                    • Else - Actions
              • Custom script: call RemoveLocation(udg_TempPoint)
              • Custom script: call DestroyGroup(udg_TempGroup2)
            • Else - Actions
      • Custom script: call DestroyGroup(udg_TempGroup)
well i got 3 answers here how to fix which fix should i use??????????? also i got there similar tigger to this



how should i do it???????? should there be group nameds another than in my frist tigger or it can be named same?????? and the only one difference will be kind of units. if its not problem can u post triggers in empty map?



  • nienazwany chuj Copy
    • Events
      • Time - Every 0.95 seconds of game time
    • Conditions
    • Actions
      • Set TempUnitGroup = (Units of type TradeCenter)
      • Unit Group - Pick every unit in TempUnitGroup and do (Actions)
        • Loop - Actions
          • Set TradeCenter = (Picked unit)
          • Unit Group - Pick every unit in (Units within 360.00 of (Position of (Picked unit))) and do (Actions)
            • Loop - Actions
              • Set Convoye = (Picked unit)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Owner of Convoye) Not equal to (Owner of TradeCenter)
                  • ((Owner of TradeCenter) is an ally of (Owner of Convoye)) Equal to True
                  • (Unit-type of Convoye) Equal to Convoy with money
                • Then - Actions
                  • Player - Add 500 to (Owner of TradeCenter) Current gold
                  • Unit - Remove Convoye from the game
                • Else - Actions
      • Custom script: call DestroyGroup(udg_TempUnitGroup)
 
Status
Not open for further replies.
Top