Unit trigger problem

Idance

New Member
Reaction score
4
I would like to make a condition like this: Units alive owned by Player11 is equal to 0, can anyone help me? please, thanks :)
 

Never_Quit

New Member
Reaction score
16
That's an integer comparison using a player group that is of all units owned by player 11 equal to 0

Trigger:
  • (Number of units in (Units owned by Player 11 (Dark Green))) Equal to 0
 

Bogrim

y hello thar
Reaction score
154
You should set the unit group with a variable and not in the integer comparison itself, otherwise you leak memory.
 

Never_Quit

New Member
Reaction score
16
Memory leaks are caused from temporary unit groups, points, play groups, basically any variable slot that you reference with computed units rather than an actual variable.

Memory leaks are caused by pieces of data that are not recycled by warcraft automatically. Eventually it can cause lags, and possibly crashes. The primary teller if a map has a lot of memory leaks is that when you exit the map, it takes a significant amount of time to close.

Edit: You recycle your memory by calling a custom script to "destroy" the variable. like this

Trigger:
  • Custom script:call DestroyGroup(udg_TempUnitGroup)
 

Bogrim

y hello thar
Reaction score
154
Memory is the processing power your computer uses to run tasks. The more memory a task takes to run, the slower your system becomes ("lag").

A memory leak is when you waste memory by creating active data that serves no purpose. Specifically, the game automatically generates variables when the trigger doesn't specify a variable and requires a variable. For example, when you check for "all units owned by player" you ask the game to create a unit group with a player comparison condition. However, you don't specify the variable, so the variable is automatically created never to be used again but in effect until the game ends.

This causes your trigger to slow down the game's process every time the trigger runs. With enough memory leaks, your map becomes unplayable. To prevent this, you have to tell the game to destroy the variable when it no longer serves a purpose by destroying it. Read a tutorial here.

Optimization is essential in triggering especially when using a template form of coding, such as the World Editor's Graphic User Interface. You need to understand what the template does in order to create functional triggers.
 

DuelPlayer

Member
Reaction score
21
u forgot something
Remember to set the group
Units owned by darkgreen matching condition unit is alive = true
Or else dead units can also count inside
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top