• 🏆 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 these scripts make memory leaks?

Status
Not open for further replies.

bia

bia

Level 3
Joined
Jun 3, 2007
Messages
39
1.
  • START
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set Spawns = 0
2.
  • Level
    • Events
      • Time - Elapsed game time is 5.00 seconds
    • Conditions
    • Actions
      • Set Spawns = 1
      • Game - Display to (All players) the text: >>> Level 1 <<<
      • Wait 35.00 seconds
      • Set Spawns = 0
      • Wait 5.00 seconds
      • Set Spawns = 2
      • Game - Display to (All players) the text: >>> Level 2 <<<
      • Wait 35.00 seconds
      • Set Spawns = 0
      • Wait 5.00 seconds
      • Set Spawns = 3
      • Game - Display to (All players) the text: >>> Level 3 <<<
      • Wait 35.00 seconds
      • Set Spawns = 0
      • Wait 5.00 seconds
      • Set Spawns = 4
      • Game - Display to (All players) the text: >>> Level 4 <<<
      • Wait 35.00 seconds
      • Set Spawns = 0
      • Wait 5.00 seconds
      • Set Spawns = 5
      • Game - Display to (All players) the text: >>> Level 5 <<<
      • Wait 35.00 seconds
      • Set Spawns = 0
      • Wait 5.00 seconds
      • Set Spawns = 6
      • Game - Display to (All players) the text: >>> Level 6 <<<
      • Wait 35.00 seconds
      • Set Spawns = 0
      • Wait 5.00 seconds
      • Set Spawns = 7
      • Game - Display to (All players) the text: >>> BOSS <<<
      • Wait 500.00 seconds
      • Game - Victory Player 2 (Blue) (Show dialogs, Show scores)
      • Game - Victory Player 3 (Teal) (Show dialogs, Show scores)
      • Game - Victory Player 4 (Purple) (Show dialogs, Show scores)
      • Game - Victory Player 1 (Red) (Show dialogs, Show scores)
3.
  • Zombie
    • Events
      • Time - Every 2.00 seconds of game time
    • Conditions
      • Spawns Equal to 1
    • Actions
      • Unit - Create 4 Zombie for Player 12 (Brown) at (Random point in Zombie Spawns <gen>) facing Default building facing (270.0) degrees
4.
  • Red Grey
    • Events
      • Time - Elapsed game time is 1.00 seconds
    • Conditions
      • (Player 1 (Red) slot status) Equal to Is playing
    • Actions
      • Unit - Create 1 Grey for Player 1 (Red) at (Player 1 (Red) start location) facing Default building facing (270.0) degrees
      • Camera - Pan camera for Player 1 (Red) to (Player 1 (Red) start location) over 2.00 seconds
5.
  • Attack
    • Events
      • Time - Every 12.00 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in (Units owned by Player 12 (Brown)) and do (Actions)
        • Loop - Actions
          • Unit - Order (Picked unit) to Attack-Move To (Position of (Random unit from (Units of type Grey)))
6.
  • Damage
    • Events
      • Unit - A unit Is attacked
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to Zombie
      • (Owner of (Triggering unit)) Equal to Player 12 (Brown)
    • Actions
      • Unit - Order (Triggering unit) to Attack (Attacking unit)
7.
  • Zombie Initalization
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Game - Set the time of day to 9.00
      • Game - Set time of day speed to 0.00% of the default speed
      • Player - Turn Gives bounty On for Player 12 (Brown)
i wonder if any of them memory leak i didnt notice anythink :razz: if they do please explain me how to modify them THX ALOT:thumbs_up:
 

Rui

Rui

Level 41
Joined
Jan 7, 2005
Messages
7,550
  • Unit - Create 4 Zombie for Player 12 (Brown) at (Random point in Zombie Spawns <gen>) facing Default building facing (270.0) degrees
Leaks 1 point;

  • Unit - Create 1 Grey for Player 1 (Red) at (Player 1 (Red) start location) facing Default building facing (270.0) degrees
  • Camera - Pan camera for Player 1 (Red) to (Player 1 (Red) start location) over 2.00 seconds
Leaks 2 points;

  • Unit Group - Pick every unit in (Units owned by Player 12 (Brown)) and do (Actions)
    • Loop - Actions
      • Unit - Order (Picked unit) to Attack-Move To (Position of (Random unit from (Units of type Grey)))
Leaks 1 point and 1 unit group.
If Create Unit leaks as some people recently claimed, then that's 7 leaks in total, if not, you still have 5 point leaks.



How to fix? Easy. Create a point variable and do the following:
  • Set YourPointVariable = (Random point in Zombie Spawns <gen>)
  • Unit - Create 4 Zombie for Player 12 (Brown) at YourPointVariable facing Default building facing (270.0) degrees
  • Custom script: call RemoveLocation(udg_YourPointVariable)
First set the variable to the point you want to refer to,

  • Set YourPointVariable = (Player 1 (Red) start location)
  • Unit - Create 1 Grey for Player 1 (Red) at YourPointVariable facing Default building facing (270.0) degrees
  • Camera - Pan camera for Player 1 (Red) to YourPointVariable over 2.00 seconds
  • Custom script: call RemoveLocation(udg_YourPointVariable)
In this particular example you could use the point variable twice because you use that point twice.

If you ever need help, don't hesitate to post here in the World Editor Help Zone.
 
Last edited:

bia

bia

Level 3
Joined
Jun 3, 2007
Messages
39
thx alot mate rep+ but i still dunno how to fix

  • Unit Group - Pick every unit in (Units owned by Player 12 (Brown)) and do (Actions)
    • Loop - Actions
      • Unit - Order (Picked unit) to Attack-Move To (Position of (Random unit from (Units of type Grey)))
:confused:
 

Rui

Rui

Level 41
Joined
Jan 7, 2005
Messages
7,550
thx alot mate rep+ but i still dunno how to fix

  • Unit Group - Pick every unit in (Units owned by Player 12 (Brown)) and do (Actions)
    • Loop - Actions
      • Unit - Order (Picked unit) to Attack-Move To (Position of (Random unit from (Units of type Grey)))
:confused:
Oh, that one, I forgot to mention it also leaked one (or two?) unit group(s). I don't know what is units of type Grey and I'm not sure if it leaks, if someone knows, please speak.

It's easy to fix. Create a unit group variable for this one too.
  • Set YourUnitGroupVariable = (Units owned by Player 12 (Brown))
  • Set YourPointVariable = (Position of (Random unit from (Units of type Grey)))
  • Unit Group - Pick every unit in YourUnitGroupVariable and do (Actions)
    • Loop - Actions
      • Unit - Order (Picked unit) to Attack-Move To YourPointVariable
  • Custom script: call DestroyGroup(udg_YourUnitGroupVariable)
  • Custom script: call RemoveLocation(udg_YourPointVariable)
Note, though, that using the same variable in every trigger might not function correctly if two triggers run at the same time.
The global variable can only hold a single object/value, as such, as soon as you set the variable to a new thing, the last thing it held is automatically discarded, and you loose reference to it. That's a leak (this is valid for all except if the variable type is Boolean, Real or Integer).

For example, if YourPointVariable is set to Position of Player 1 (Red)'s start location in trigger 1, and trigger 2 is running at the same time, it can set YourPointVariable to (Position of Random unit from (Units of type Grey))) before the custom script of trigger 1 has the chance to delete the Position of Player 1 (Red)'s start location.

GUI, or Triggers, as the majority of the people call it, runs very slowly and although this has a very little chance to happen (or not, depending on the way you're using the triggers), it IS possible.
 

bia

bia

Level 3
Joined
Jun 3, 2007
Messages
39
thx mate my map should be leakless now :grin:

well i have another question how i do i make a icon in builing that combines items [in hero or building inventory] when i click on it, not auto combination nor recepie just like its made in troll tribes ?
 
Status
Not open for further replies.
Top