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

[Trigger] Coul this triggers couse any lags,bugs or leaks?

Status
Not open for further replies.
Level 13
Joined
Mar 4, 2009
Messages
1,156
This triggers will be played many times (every time you build a building) and i was wondering would it be to much or something...
  • Untitled Trigger 007 006 005
    • Events
      • Unit - A unit enters Region 007 <gen>
      • Unit - A unit enters Region 006 <gen>
      • Unit - A unit enters Region 005 <gen>
    • Conditions
      • ((Entering unit) is A structure) Equal to True
    • Actions
      • Set EU = (Position of (Entering unit))
      • Unit - Create 1 BASE PROTECTOR for (Owner of (Random unit from (Units in Region 007 <gen> matching ((Mana of (Matching unit)) Equal to 100000.00)))) at EU facing Default building facing degrees
      • Unit - Create 1 BASE PROTECTOR for (Owner of (Random unit from (Units in Region 006 <gen> matching ((Mana of (Matching unit)) Equal to 100000.00)))) at EU facing Default building facing degrees
      • Unit - Create 1 BASE PROTECTOR for (Owner of (Random unit from (Units in Region 005 <gen> matching ((Mana of (Matching unit)) Equal to 100000.00)))) at EU facing Default building facing degrees
      • Custom script: call RemoveLocation(udg_EU)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Unit-type of (Entering unit)) Equal to Human Flag(Base Owner)
        • Then - Actions
          • Unit - Add Spell Immunity. (Item) to (Entering unit)
        • Else - Actions
  • Untitled Trigger 07
    • Events
      • Unit - A unit enters (Playable map area)
    • Conditions
      • (Unit-type of (Entering unit)) Equal to BASE PROTECTOR
    • Actions
      • Unit - Kill (Entering unit)
      • Wait 0.01 seconds
      • Unit - Remove (Entering unit) from the game
 
Level 25
Joined
May 11, 2007
Messages
4,651
Runned it in leakcheck that can be downloaded from this site:

(Line: 10) (Word: 12) Unit Group Leak
Unit - Create 1 BASE PROTECTOR for (Owner of (Random unit from (Units in Region 007 <gen> matching ((Mana of (Matching unit)) Equal to 100000.00)))) at EU facing Default building facing degrees
Unit - Create 1 BASE PROTECTOR for (Owner of (Random unit from ^Leak
(Suggested Fix) Set MyUnitGroup = (Units in Region 007 <gen> matching ((Mana of (Matching unit)) Equal to 100000.00)))) at EU facing Default building facing degrees
(Suggested Fix) Unit - Create 1 BASE PROTECTOR for (Owner (Random unit from MyUnitGroup degrees
(Suggested Fix) Custom script: call DestroyGroup(udg_MyUnitGroup)

(Line: 11) (Word: 12) Unit Group Leak
Unit - Create 1 BASE PROTECTOR for (Owner of (Random unit from (Units in Region 006 <gen> matching ((Mana of (Matching unit)) Equal to 100000.00)))) at EU facing Default building facing degrees
Unit - Create 1 BASE PROTECTOR for (Owner of (Random unit from ^Leak
(Suggested Fix) Set MyUnitGroup = (Units in Region 006 <gen> matching ((Mana of (Matching unit)) Equal to 100000.00)))) at EU facing Default building facing degrees
(Suggested Fix) Unit - Create 1 BASE PROTECTOR for (Owner (Random unit from MyUnitGroup degrees
(Suggested Fix) Custom script: call DestroyGroup(udg_MyUnitGroup)

(Line: 12) (Word: 12) Unit Group Leak
Unit - Create 1 BASE PROTECTOR for (Owner of (Random unit from (Units in Region 005 <gen> matching ((Mana of (Matching unit)) Equal to 100000.00)))) at EU facing Default building facing degrees
Unit - Create 1 BASE PROTECTOR for (Owner of (Random unit from ^Leak
(Suggested Fix) Set MyUnitGroup = (Units in Region 005 <gen> matching ((Mana of (Matching unit)) Equal to 100000.00)))) at EU facing Default building facing degrees
(Suggested Fix) Unit - Create 1 BASE PROTECTOR for (Owner (Random unit from MyUnitGroup degrees
(Suggested Fix) Custom script: call DestroyGroup(udg_MyUnitGroup)

Short advice: Store regions as a variable and clear that variable using customscript:
call RemoveLocation( udg_variablename )
 
Level 13
Joined
Mar 4, 2009
Messages
1,156
Leak free, but I dont get why you want to remove base protectors

So there is no leaks?:grin:
I need to kill "BASE PROTECTOR" becouse it has ability that actives on his death.(It stops other players to build in your own base)

Runned it in leakcheck that can be downloaded from this site:

Short advice: Store regions as a variable and clear that variable using customscript:
call RemoveLocation( udg_variablename )

From what site can i download your leakchecker?

Is it good like this?
  • Untitled Trigger 007 006 005 Copy
    • Events
      • Unit - A unit enters Region 007 <gen>
      • Unit - A unit enters Region 006 <gen>
      • Unit - A unit enters Region 005 <gen>
    • Conditions
      • ((Entering unit) is A structure) Equal to True
    • Actions
      • Set EU = (Position of (Entering unit))
      • Set UNITGROUP = (Units in Region 007 <gen> matching ((Mana of (Matching unit)) Equal to 100000.00))
      • Unit - Create 1 BASE PROTECTOR for (Owner of (Random unit from UNITGROUP)) at EU facing Default building facing degrees
      • Set UNITGROUP = (Units in Region 006 <gen> matching ((Mana of (Matching unit)) Equal to 100000.00))
      • Unit - Create 1 BASE PROTECTOR for (Owner of (Random unit from UNITGROUP)) at EU facing Default building facing degrees
      • Set UNITGROUP = (Units in Region 005 <gen> matching ((Mana of (Matching unit)) Equal to 100000.00))
      • Unit - Create 1 BASE PROTECTOR for (Owner of (Random unit from UNITGROUP)) at EU facing Default building facing degrees
      • Custom script: call DestroyGroup(udg_UNITGROUP)
      • Custom script: call RemoveLocation(udg_EU)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Unit-type of (Entering unit)) Equal to Human Flag(Base Owner)
        • Then - Actions
          • Unit - Add You can build in this base. (Item) to (Entering unit)
        • Else - Actions
 
Last edited by a moderator:
Level 13
Joined
Mar 4, 2009
Messages
1,156
You need to destroy the current group before you set it to a new group
ok so i should do it like this?
  • Untitled Trigger 007 006 005 Copy
    • Events
      • Unit - A unit enters Region 007 <gen>
      • Unit - A unit enters Region 006 <gen>
      • Unit - A unit enters Region 005 <gen>
    • Conditions
      • ((Entering unit) is A structure) Equal to True
    • Actions
      • Set FIXLAGS = (Position of (Entering unit))
      • Set UNITGROUP = (Units in Region 007 <gen> matching ((Mana of (Matching unit)) Equal to 100000.00))
      • Unit - Create 1 BASE PROTECTOR for (Owner of (Random unit from UNITGROUP)) at FIXLAGS facing Default building facing degrees
      • Custom script: call DestroyGroup(udg_UNITGROUP)
      • Set UNITGROUP = (Units in Region 006 <gen> matching ((Mana of (Matching unit)) Equal to 100000.00))
      • Unit - Create 1 BASE PROTECTOR for (Owner of (Random unit from UNITGROUP)) at FIXLAGS facing Default building facing degrees
      • Custom script: call DestroyGroup(udg_UNITGROUP)
      • Set UNITGROUP = (Units in Region 005 <gen> matching ((Mana of (Matching unit)) Equal to 100000.00))
      • Unit - Create 1 BASE PROTECTOR for (Owner of (Random unit from UNITGROUP)) at FIXLAGS facing Default building facing degrees
      • Custom script: call DestroyGroup(udg_UNITGROUP)
      • Custom script: call RemoveLocation(udg_FIXLAGS)
And i don't know why the variable "FIXLAGS" don't work if set on map initialization.
 
Level 6
Joined
Mar 20, 2008
Messages
208
At map initilazation it might be set to null, or not pointing at anything.
And yes, that looks like it won't leak.

Previously, you were only destroying one group at the end and had some groups floating around in memory with no pointers to them.
 
Level 13
Joined
Mar 4, 2009
Messages
1,156
At map initilazation it might be set to null, or not pointing at anything.
And yes, that looks like it won't leak.

Previously, you were only destroying one group at the end and had some groups floating around in memory with no pointers to them.

thx...is it needed to set location if you destroy the whole group?

I was wondering is it possible for conditions to make leaks and can the conditions like this make leaks?
  • ((Random unit from (Units owned by Player 11 (Dark Green) matching (((Matching unit) is A Hero) Equal to True))) is alive) Not equal to True
 
Level 6
Joined
Mar 20, 2008
Messages
208
Yes conditions will leak, they are not special. They work just like regular functions except they return a value

I don't believe the regions will leak as they have a direct reference. Not 100% sure though.
 
Level 25
Joined
May 11, 2007
Messages
4,651
Regions leak. Make a variable called temppoint1 (point)
then when you want a region use :
set temppoint1 = center of region X
then after used that temppoint, use
Custom script: call RemoveLocation(udg_temppoint1)
 
Level 40
Joined
Dec 14, 2005
Messages
10,532
Regions leak. Make a variable called temppoint1 (point)
then when you want a region use :
set temppoint1 = center of region X
then after used that temppoint, use
Custom script: call RemoveLocation(udg_temppoint1)
Those are globals, so no, they don't.

How can i make my condition not to leak?:confused:
(random unit owned by player 1 of type Human is alive......)
Your condition is fine.
 
Level 6
Joined
Mar 20, 2008
Messages
208
Those are globals, so no, they don't.

Your condition is fine.

JASS:
function GetUnitsOfPlayerMatching takes player whichPlayer, boolexpr filter returns group
    local group g = CreateGroup()
    call GroupEnumUnitsOfPlayer(g, whichPlayer, filter)
    call DestroyBoolExpr(filter)
    return g
endfunction

Thats essentially the random unit from unit group with units owned by a player. It leaks unless he turns on the bj_wantdestroygroup thing.

Thats 2 strikes poot :razz:
 
Level 13
Joined
Mar 4, 2009
Messages
1,156
JASS:
function GetUnitsOfPlayerMatching takes player whichPlayer, boolexpr filter returns group
    local group g = CreateGroup()
    call GroupEnumUnitsOfPlayer(g, whichPlayer, filter)
    call DestroyBoolExpr(filter)
    return g
endfunction

Thats essentially the random unit from unit group with units owned by a player. It leaks unless he turns on the bj_wantdestroygroup thing.

Thats 2 strikes poot :razz:
How do you make conditions not to leak?
 
Level 6
Joined
Mar 20, 2008
Messages
208
set bj_wantDestroyGroup = true in custom code prior to running that group code

That should tell it to destroy the group when its done.
 
Level 11
Joined
Jul 28, 2007
Messages
920
** OMG Rui every time i see you avatar i have to watch it few seconds to see how she dances. -.-' Can't help myself :D.
Corpse counts as a unit in map right ? so 300 corpses could cause lagg i think.
Sometimes is good to remove after death unused corpses. BTW, what's about map you are working there ? Some kind of TD or ?
 

Dr Super Good

Spell Reviewer
Level 63
Joined
Jan 18, 2005
Messages
27,180
Computers are capable of millions of calculations per second, a couple of 100 units will not lag unless you do it more than a few times a second or for each unit do something demanding.

Globals do leak if you do not null them and never overwrite their value. However you can null them at any time and generally for systems that are constantly in use, there is no need to null them as they will be overwritten soon enough.
 
Level 13
Joined
Mar 4, 2009
Messages
1,156
** OMG Rui every time i see you avatar i have to watch it few seconds to see how she dances. -.-' Can't help myself :D.
Corpse counts as a unit in map right ? so 300 corpses could cause lagg i think.
Sometimes is good to remove after death unused corpses. BTW, what's about map you are working there ? Some kind of TD or ?

Yes.. its something like TD (Vampirism Fire) i needed this to stop other players to build in your own base if you dont allow it...
and yes i it is good to remove dying after about 7 seconds.
 
Level 6
Joined
Mar 20, 2008
Messages
208
thx...is it needed to set location if you destroy the whole group?

I was wondering is it possible for conditions to make leaks and can the conditions like this make leaks?
  • ((Random unit from (Units owned by Player 11 (Dark Green) matching (((Matching unit) is A Hero) Equal to True))) is alive) Not equal to True
  • /
  • /
  • /

How can i make my condition not to leak?:confused:
(random unit owned by player 1 of type Human is alive......)

What? That is not his condition, and it has nothing to do with using rect globals.

Both quoted above are what he was referring to. The second one if what you quoted.

It leaks as it creates a group, and doesn't destroy it.

JASS:
GroupPickRandomUnit(GetUnitsOfPlayerAndTypeId(Player(0), 'hfoo'))

function GroupPickRandomUnit takes group whichGroup returns unit
    // If the user wants the group destroyed, remember that fact and clear
    // the flag, in case it is used again in the callback.
    local boolean wantDestroy = bj_wantDestroyGroup
    set bj_wantDestroyGroup = false

    set bj_groupRandomConsidered = 0
    set bj_groupRandomCurrentPick = null
    call ForGroup(whichGroup, function GroupPickRandomUnitEnum)

    // If the user wants the group destroyed, do so now.
    if (wantDestroy) then
        call DestroyGroup(whichGroup)
    endif
    return bj_groupRandomCurrentPick
endfunction

function GetUnitsOfPlayerAndTypeId takes player whichPlayer, integer unitid returns group
    local group g = CreateGroup()
    set bj_groupEnumTypeId = unitid
    call GroupEnumUnitsOfPlayer(g, whichPlayer, filterGetUnitsOfPlayerAndTypeId)
    return g
endfunction

The first line is what the WE uses, the rest is the code behind those functions.
It will leak if he doesn't tell it to destroy the group.
 
Last edited:
Level 6
Joined
Mar 20, 2008
Messages
208
I have a feeling someone is missing what a condition is...

He listed something to do with random units underneath the question about his condition, but seeing as his condition clearly lacks such a line... meh, whatever.

"can the conditions like this make leaks" and then showing a condition, even with the question mark icon, one would infer it was what he was referring to, as in the WHOLE thing not just "of Type human"

If he is referring to the whole line, it leaks a group.
If he is referring to just "of Type human" I would still consider it a leak because its a part of the code tha leaks a group.

Whatever way you want to spin it, it still leaks unless you are telling it you want the group destroyed.
 
Level 11
Joined
Dec 31, 2007
Messages
780
unless you :

  • event
    • Unit dies
  • conditions
    • region with size 1200 1200 from position of X unit contains triggering unit == to true
  • actions
there you would be leaking a region and a location... am i correct?

EDIT: nvm i was not logged in and i didnt see the 2nd page :p
 
Level 13
Joined
Mar 4, 2009
Messages
1,156
"can the conditions like this make leaks" and then showing a condition, even with the question mark icon, one would infer it was what he was referring to, as in the WHOLE thing not just "of Type human"

If he is referring to the whole line, it leaks a group.
If he is referring to just "of Type human" I would still consider it a leak because its a part of the code tha leaks a group.

Whatever way you want to spin it, it still leaks unless you are telling it you want the group destroyed.

But how can you destroy the group if it is condition???

random unit (some unit) is alive not equal to true
 
Status
Not open for further replies.
Top