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

Things That Leak

Level 6
Joined
Jun 14, 2008
Messages
176
I have a question, if I use(for example), "Remove Last Created Unit" action, will the "Last Created Unit" only refer to the last created unit in that specific trigger only or does it mean Last Created Unit in any trigger throughout the entire map?
 
Level 6
Joined
Jun 14, 2008
Messages
176
I see thanks.

I was wondering because I have something like this:
  • A unit is attacked:
  • Create a Unit for owner of attacking unit
  • Play last created unit's "spin" animation
  • Wait 0.25
  • Remove Last Created Unit

Now the thing I was concerned about was if "Remove Last Created Unit" would instead remove another unit created in another trigger.

Now for some reason, the last time I did a trigger with:
  • Add an expiration timer to last created, expiring in <x seconds>
If I made the duration shorter than 1 second or something, it would glitch for some reason and cause problems(I forgot what they were though). Not sure if it'll happen again which is why I avoided using an expiration timer in this case.

So I assume the way around this problem would be to set the "Last Created Unit" to a "local unit variable", then wait 0.25 seconds, then removed the unit referring to the local unit variable I made?
 
Level 13
Joined
May 11, 2008
Messages
1,198
I see thanks.

I was wondering because I have something like this:
  • A unit is attacked:
  • Create a Unit for owner of attacking unit
  • Play last created unit's "spin" animation
  • Wait 0.25
  • Remove Last Created Unit

Now the thing I was concerned about was if "Remove Last Created Unit" would instead remove another unit created in another trigger.

Now for some reason, the last time I did a trigger with:
  • Add an expiration timer to last created, expiring in <x seconds>
If I made the duration shorter than 1 second or something, it would glitch for some reason and cause problems(I forgot what they were though). Not sure if it'll happen again which is why I avoided using an expiration timer in this case.

So I assume the way around this problem would be to set the "Last Created Unit" to a "local unit variable", then wait 0.25 seconds, then removed the unit referring to the local unit variable I made?

yeah that could work out ok. just make sure to null the variable afterwards so it doesn't leak.
after you remove it, you would do set variablename = null
 
Level 4
Joined
May 3, 2009
Messages
69
Can't delete arrays. You can only delete specific indices on an array. E.g.
call DestroyGroup(udg_GroupVar[0])
call DestroyGroup(udg_GroupVar[1])

bj_forLoopAIndex = "Integer A"
bj_forLoopBIndex = "Integer B"

So I need 12 triggers???

or use loop integer? but I don't know how to use them.

  • Set AllUnitsGroup[(Player number of (Owner of (Casting unit)))] = (Units in (Playable map area) matching ((((Triggering unit) is A Hero) Equal to False) and ((Owner of (Matching unit)) Equal to (Owner of (Casting unit)))))
  • Custom script: call DestroyGro...
 
Level 4
Joined
May 3, 2009
Messages
69
You can always use variables in scripts...

  • Set GroupIndex = Player number of (owner of (casting unit))
  • Set AllUnitsGroup[GroupIndex] = ...
  • Custom script: call DestroyGroup(udg_AllUnitsGroup[udg_GroupIndex])

Pretty smart...
Thanks for the advice Eleandor. +rep given.
I think this should be added at the first page of the tutorial.
 
Level 1
Joined
Aug 23, 2009
Messages
2
Leak?

Hello I could use some help. Does this leak?

  • Judgement
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Judgement
    • Actions
      • Set Judgement_Target = (Target unit of ability being cast)
      • Set Judgement_Caster = (Triggering unit)
      • Set Judgement_Ally = (Owner of Judgement_Caster)
      • Set Judgement_Duration_Base = 3.00
      • Set Judgement_Level = (Level of (Ability being cast) for Judgement_Caster)
      • Set Judgement_Modifier = (6.00 + ((Real(Judgement_Level)) x 2.00))
      • Set Judgement_Duration = (Judgement_Duration_Base x (Real(Judgement_Level)))
      • Set Judgement_Caster_Inteligence = (Intelligence of Judgement_Caster (Include bonuses))
      • Set Judgement_Heal = ((Real(Judgement_Caster_Inteligence)) x Judgement_Modifier)
      • Set Judgement_Damage = (Judgement_Heal / 2.00)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Judgement_Target belongs to an ally of Judgement_Ally) Equal to True
        • Then - Actions
          • Unit - Set life of Judgement_Target to ((Life of Judgement_Target) + Judgement_Heal)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Judgement_Level Equal to 1
            • Then - Actions
              • Unit - Add Item Armor Bonus (+2) to Judgement_Target
              • Wait Judgement_Duration seconds
              • Unit - Remove Item Armor Bonus (+2) from Judgement_Target
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Judgement_Level Equal to 2
                • Then - Actions
                  • Unit - Add Item Armor Bonus (+4) to Judgement_Target
                  • Wait Judgement_Duration seconds
                  • Unit - Add Item Armor Bonus (+4) to Judgement_Target
                • Else - Actions
                  • Unit - Add Item Armor Bonus (+6) to Judgement_Target
                  • Wait Judgement_Duration seconds
                  • Unit - Remove Item Armor Bonus (+6) from Judgement_Target
        • Else - Actions
          • Unit - Cause Judgement_Caster to damage Judgement_Target, dealing Judgement_Damage damage of attack type Spells and damage type Normal
          • Unit - Set mana of Judgement_Target to ((Mana of Judgement_Target) - (Judgement_Damage / 2.00))
      • Set Judgement_Target = No unit
      • Set Judgement_Caster = No unit
 
Level 1
Joined
Aug 23, 2009
Messages
2
Thanks Element of Water. It's weird this spell is the only custom spell I have with trigger in a game but it crashes every time, only when there are more than 2 players though.
 
Level 2
Joined
Sep 3, 2009
Messages
15
I have a question about leaks.
If you set a variable for something like

Set Group = (Units within 500 of (Position Of Picked Unit))

The (Position Of Picked Unit) will leak, but will it leak if i store it within a variable, and then destroy it? I was wondering because the variable is set as a GROUP, not a POINT.

Do i have to set (Position Of Picked Unit) into another variable and then do something like this?

Set Group = (Unit within 500 of (Point))
 
Level 9
Joined
May 30, 2008
Messages
430
I have a question about leaks.
If you set a variable for something like

Set Group = (Units within 500 of (Position Of Picked Unit))

The (Position Of Picked Unit) will leak, but will it leak if i store it within a variable, and then destroy it? I was wondering because the variable is set as a GROUP, not a POINT.

Do i have to set (Position Of Picked Unit) into another variable and then do something like this?

Set Group = (Unit within 500 of (Point))

It should be somthing like
Set TempPoint = position of picked unit
Set TempGroup = (Units within 500 of (TempPoint))

and then just destroy them to clear the leaks
 
Level 5
Joined
Sep 29, 2008
Messages
171
I know that triggering an ability to use a lightning effect can cause a leak if you fail like I did and leave a timer so it looks like a really powerful shock /facepalm

If someone casts chain lightning right as my single target lightning bolt stun thing goes off, the trigger may remove the chain lightning over the one triggered by the spell. Any suggestions?
 
Level 5
Joined
Jun 13, 2008
Messages
102
Object Creation Leak

At the beginning of the thread paskovich said:
Creating any object will of course leak, but it is not that common for example a dummy unit is not killed/removed.
I have a map where I'm creating a lot of units by triggers, will this leak? And if so how can I fix it? (Sorry if someones already answered this, theres too much thread to read). Thanks for any help.
 
Level 9
Joined
Nov 28, 2008
Messages
704
At the beginning of the thread paskovich said:
I have a map where I'm creating a lot of units by triggers, will this leak? And if so how can I fix it? (Sorry if someones already answered this, theres too much thread to read). Thanks for any help.

When a unit dies, it stops (edit) using memory (unless it has special effects attached via trigger). You probably shouldn't worry, unless you use custom spells a lot and use dummy units to cast things and dont remove those dummy units.
 
Level 6
Joined
Jul 13, 2006
Messages
140
Uh, hello I am kinda confused about the set bj_wantDestroyGroup = true thing.

Here I have an example:

  • Actions
    • Player - Add 10 to Player 9 (Gray) Current gold
    • Unit Group - Pick every unit in (Units owned by Player 9 (Gray) of type Builder) and do (Actions)
      • Loop - Actions
  • Unit Group - Pick every unit in (Units owned by Player 9 (Gray)) and do (Actions)
    • Loop - Actions
      • Unit - Order (Picked unit) to Attack-Move To (Random point in (Playable map area))
    • Unit Group - Pick every unit in (Units owned by Player 9 (Gray) of type Workshop) and do (Actions)
      • Loop - Actions
    • Unit Group - Pick every unit in (Units owned by Player 9 (Gray) of type Keep) and do (Actions)
      • Loop - Actions
    • Unit Group - Pick every unit in (Units owned by Player 9 (Gray) of type Shipyard) and do (Actions)
      • Loop - Actions
    • Unit Group - Pick every unit in (Units owned by Player 9 (Gray) of type Barracks) and do (Actions)
      • Loop - Actions
    • Unit Group - Pick every unit in (Units owned by Player 9 (Gray) of type Town Hall) and do (Actions)
      • Loop - Actions
    • Unit Group - Pick every unit in (Units owned by Player 9 (Gray) of type Arcane Sanctum) and do (Actions)
      • Loop - Actions
    • Unit Group - Pick every unit in (Units owned by Player 9 (Gray) of type Castle) and do (Actions)
      • Loop - Actions
    • Unit Group - Pick every unit in (Units owned by Player 9 (Gray) of type Scout Tower) and do (Actions)
      • Loop - Actions
The main thing is, Where should bj_wantDestroyGroup = true be located?
Yes, I know that the location leaks but that is irrelevant in this example.

Since the problem is, what happens if I have multiple pick unit actions and want to use the wantDestroyGroup thing, where should I place it in the trigger?
 
  • Group Loop
    • Events
    • Conditions
    • Actions
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units in (Playable map area) owned by Player 1 (Red)) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Or - Any (Conditions) are true
                • Conditions
                  • (Unit-type of (Picked unit)) Equal to Town Hall
                  • (Unit-type of (Picked unit)) Equal to Keep
                  • (Unit-type of (Picked unit)) Equal to Castle
                  • (Unit-type of (Picked unit)) Equal to Barracks
            • Then - Actions
              • -------- stuff --------
            • Else - Actions
      • -------- ---------------------------------------------------------- --------
      • -------- ---------------------------OR---------------------------- --------
      • -------- ---------------------------------------------------------- --------
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units owned by Player 1 (Red) matching (((Unit-type of (Picked unit)) Equal to Town Hall) or (((Unit-type of (Picked unit)) Equal to Keep) or (((Unit-type of (Picked unit)) Equal to Castle) or ((Unit-type of (Picked unit)) Equal to Barracks))))) and do (Actions)
        • Loop - Actions
          • -------- stuff --------
God, that took my ages to make... now I remember why I wanted to learn Jass in the first place...

By the way, the second one is more efficient.
 
Level 6
Joined
Jul 13, 2006
Messages
140
Oh, like that, well the only real problem is that they should all spawn a different unit but that is easily fixed.
And the second one is IMO not as efficient because it is simply a pain.
But the only problem is, it'll just be a loop trigger and won't that mean that the whole row is executed for one structure? Instead of the example I had where it just picks the relevant structures and executes them?

And yeah, I guess JASS would be more efficient except for the one fact that has prevented me from learning it, how can you remember all actions and all that without any sort of list?

Anyways, thanks for the help.
 
There's a great list in TESH (no idea what that stands for... something-Syntax Highlighter?), which comes with JNGP (Jass NewGen Pack - I'm sure you've heard of it). It has a search function too.
 

Attachments

  • yeah....PNG
    yeah....PNG
    73.1 KB · Views: 89
Level 37
Joined
Mar 6, 2006
Messages
9,240
  • Custom script: set bj_wantDestroyGroup = true
  • Unit Group - Pick every unit in (Units owned by Player 1 (Red) matching (((Unit-type of (Picked unit)) Equal to Town Hall) or (((Unit-type of (Picked unit)) Equal to Keep) or (((Unit-type of (Picked unit)) Equal to Castle) or ((Unit-type of (Picked unit)) Equal to Barracks))))) and do (Actions)
    • Loop - Actions
      • -------- stuff --------

All those picked units should be matching units ;) Just saying, incase someone tries it and wonders why it doesn't work.
 
Level 17
Joined
Apr 24, 2005
Messages
762
Okay i have a question. I set the locations to variables in a trigger, which then turns on a couple more triggers that run every x seconds, creating and sending units to those locations and i use call RemoveLocation(udg_Loc) for every location every time the units get sent there. Does this work or do i have to set the locations to variables again each time the periodic trigger runs?
 
Level 17
Joined
Apr 24, 2005
Messages
762
  • Unit Spawn Init
    • Events
      • Destructible - Gate (Diagonal 1) 3003 <gen> dies
    • Conditions
    • Actions
      • Set Loc[1] = (Center of RunLoc <gen>)
      • Set Loc[2] = (Center of Spawn 1 <gen>)
      • Set Loc[3] = (Center of Spawn 2 <gen>)
      • Set Loc[4] = (Center of Spawn 3 <gen>)
      • Trigger - Turn on Unit1 Spawn <gen>
      • Trigger - Turn on Unit2 Spawn <gen>
  • Unit1 Spawn
    • Events
      • Time - Every 18.00 seconds of game time
    • Conditions
    • Actions
      • Unit - Create 1 Unit1 for Player 12 (Brown) at Loc[2] facing (Position of Gate (Diagonal 1) 3003 <gen>)
      • Custom script: call RemoveLocation(udg_Loc[2])
      • Unit - Order (Last created unit) to Attack-Move To (Center of RunLoc <gen>)
      • Unit - Create 1 Unit1 for Player 12 (Brown) at Loc[3] facing (Position of Gate (Diagonal 1) 3003 <gen>)
      • Custom script: call RemoveLocation(udg_Loc[3])
      • Unit - Order (Last created unit) to Attack-Move To (Center of RunLoc <gen>)
      • Unit - Create 1 Unit1 for Player 12 (Brown) at Loc[4] facing (Position of Gate (Diagonal 1) 3003 <gen>)
      • Custom script: call RemoveLocation(udg_Loc[4])
      • Unit - Order (Last created unit) to Attack-Move To (Center of RunLoc <gen>)
So my question is, do i have to set Loc[2], Loc[3] etc again every time Unit1 Spawn runs?
 
Top