Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Custom script: local timerdialog WINDOW
Custom script: local integer HEROWAIT
Custom script: local timer OURTIMER
Custom script: local unit OURHERO
Custom script: set OURHERO = GetDyingUnit()
Custom script: set HEROWAIT = ( GetHeroLevel(OURHERO) * 5 )
Custom script: set OURTIMER = CreateTimer()
Custom script: call StartTimerBJ( OURTIMER, false, ( I2R(HEROWAIT) ))
Custom script: call CreateTimerDialogBJ( OURTIMER, GetPlayerName(GetOwningPlayer(OURHERO)) )
Custom script: set WINDOW = GetLastCreatedTimerDialogBJ()
Custom script: call TimerDialogDisplayForPlayerBJ( true, WINDOW, GetOwningPlayer(OURHERO) )
Custom script: call PolledWait( HEROWAIT )
Custom script: call ReviveHeroLoc( OURHERO, GetRectCenter(gg_rct_Sentinel_Start), true )
Custom script: call PanCameraToTimedLocForPlayer( GetOwningPlayer(OURHERO), GetUnitLoc(OURHERO), 0.60 )
Custom script: call DestroyTimerDialog(WINDOW)
Test Revive

Events


Unit - A unit Dies

Conditions


And - All (Conditions) are true



Conditions




((Dying unit) is A Hero) Equal to True




Or - Any (Conditions) are true





Conditions






(Owner of (Dying unit)) Equal to Player 1 (Red)






(Owner of (Dying unit)) Equal to Player 2 (Blue)






(Owner of (Dying unit)) Equal to Player 3 (Teal)






(Owner of (Dying unit)) Equal to Player 4 (Purple)

Actions


Set TempUnit = (Dying unit)


Set TempLoc = (Center of Sentinel Start <gen>)


Set TempReal = ((Real((Level of (Dying unit)))) x 5.00)


Set Herowait = (Last started timer)


Set Revive = (Last created timer window)


Countdown Timer - Start Herowait as a One-shot timer that will expire in TempReal seconds


Countdown Timer - Create a timer window for Herowait with title (Name of TempUnit)


Countdown Timer - Show Revive


Wait TempReal seconds


Camera - Pan camera for (Owner of TempUnit) to TempLoc over 0.00 seconds


Hero - Instantly revive TempUnit at TempLoc, Show revival graphics


Custom script: call RemoveLocation(udg_TempLoc)
Trigger

Events


Temps - Every X.XX seconds of game time

Conditions

Actions


Unit Group - Pick every unit in GroupVar and do (Actions)



Loop - Actions



-------- Actions --------
I have a question : How can I store a UnitGroup and keeps it without any changes without leaking.
Because I have a trigger like this :
And so i need to keep all of my units in the Unit Group Variable. But it leaks if i don't modify anything and how can i remove this leak without removing the units from the Unit Group ?
Trigger
Events
Temps - Every X.XX seconds of game time
Conditions
Actions
Unit Group - Pick every unit in GroupVar and do (Actions)
Loop - Actions
-------- Actions --------
But he's still dynamic and the unit group changes (add unit in/remove unit from)
PHP:
This doesn't matter as long as you refer to the variable when you add/remove/pick units
kkots said:You can fully control how units are added or removed, except that when a unit dies and decays for too long, then it is removed automatically and the group doesn't have that unit any more in it.
No, they are not removed of the group automatically, but you can't enum them (short story), we call them ghost units : units removed of the game but not of the group.
In the case you don't remove all units using GroupClear or GroupRemoveUnit, or just a GroupEnum... function, you still can clean the group periodically, like using the function GroupRefresh of the vJass library GroupUtils (just as an example)
Theorically there will be a performance issue with a group full of many ghost units comparing to the same group without ghost units, but i don't think that will be ever noticeable in any real case, especially in GUI.
ManaTideTotem

Events


Time - Every 3.00 seconds of game time

Conditions


(Number of units in (Units of type Tidal Totem)) Equal to 1

Actions


Set HolHin_Mana = (Random real number between 2.00 and 5.00)


Unit Group - Pick every unit in (Units within 1000.00 of (Position of HolHin_Totem)) and do (Actions)



Loop - Actions




If (All Conditions are True) then do (Then Actions) else do (Else Actions)





If - Conditions






(Unit-type of (Picked unit)) Not equal to Lady Seraspia






(Unit-type of (Picked unit)) Not equal to Tidal Totem





Then - Actions






Unit - Set mana of (Picked unit) to ((Mana of (Picked unit)) + HolHin_Mana)






Floating Text - Create floating text that reads ((|c000000ff+ + (String((Integer(HolHin_Mana))))) + mana|r) above (Picked unit) with Z offset 0.00, using font size 8.50, color (100.00%, 100.00%, 100.00%), and 0.00% transparency






Floating Text - Change (Last created floating text): Disable permanence






Floating Text - Change the lifespan of (Last created floating text) to 1.25 seconds






Floating Text - Change the fading age of (Last created floating text) to 1.00 seconds






Floating Text - Set the velocity of (Last created floating text) to 85.00 towards 135.00 degrees





Else - Actions
Yes the conditions leak to. The solution is to use an if/then/else (multiple conditions) and do everything in the actions, so that you can destroy the group.
If there were no "conditions", then everyone would just use the if/then/else (multiple conditions) block. They are not really important.
local rect rect_1 = Rect(x-400.,y-400.,x+400.,y+400.)
local rect rect_2 = RectFromCenterSizeBJ(loc, 400.0, 400.0)
local region region_1 = CreateRegion()
RegionAddRect(region_1 , rect_1)
RegionAddRect(region_1 , rect_2)
//...1
RemoveRect(rect_1)
RemoveRect(rect_2)
//...2
Unit, doodads, destructibles and more don't leak. However, if you move a unit to a point and then do something with the unit, the point will leak.I have a question, if a unit dies will it leak? or do i have to remove the unit when it dies?
I will go kill myself. Gimme gun!Units do leak. There is some internal game bug that removing a unit (any means including natural death) does not removal all memory used by a unit. There is no way to avoid this leak next to unit recycling (re-use existing units instead of making more).

Units do leak. There is some internal game bug that removing a unit (any means including natural death) does not removal all memory used by a unit. There is no way to avoid this leak next to unit recycling (re-use existing units instead of making more).
noob here, someone please help. how do i know references from triggers? i've started making some triggers with clearing mem leaks like location with polar offsets and unit groups. here is my map: https://www.hiveworkshop.com/forums/spells-569/8-way-arrowkeys-223047/You don't allocate or deallocate memory yourself. The game allocates memory for objects you create in triggers. The only thing you need to do is destroy the object, so the allocated memory is freed. However you also need to null any local references to destroyed objects because otherwise that specific handle index can't be recycled.
Hello guys!
Credit to: Wolverabid, PurplePoot, Silvenon, Paskovich
I want to make a list of things that leak and ways to fix them.
Dynamic Unit Groups
This trigger will instantly destroy dynamically generated unit groups.
Another way to avoid a group leak is to store the group into a variable, and then destroy it manually.
Trigger
Events
Event
Conditions
Conditions
Actions
Custom script: set bj_wantDestroyGroup = true
Unit Group - Pick every unit in (Playable Map Area) and do (Unit - Hide (Picked unit))
This is useful if you want to use the group more than once in the trigger.
Set GroupVar = Pick every unit in (Playable Map Area)
Unit Group - Pick every unit in GroupVar and do (Unit - Hide (Picked unit))
Custom script: call DestroyGroup(udg_GroupVar)
Hm, the set bj want destroy group custom script removed the special effect from the group of units.
Indignation Visual

Events


Unit - A unit Starts the effect of an ability

Conditions


(Ability being cast) Equal to Indignation (Neutral Hostile 1)

Actions


Set IndignationGroup = (Units within 375.00 of (Position of (Triggering unit)))


For each (Integer A) from 1 to 5, do (Actions)



Loop - Actions




Custom script: set bj_wantDestroyGroup = true




Unit Group - Pick every unit in (Random 1 units from IndignationGroup) and do (Special Effect - Create a special effect attached to the overhead of (Random unit from IndignationGroup) using Abilities\Spells\Other\Monsoon\MonsoonBoltTarget.mdl)




Special Effect - Destroy (Last created special effect)


Custom script: call DestroyGroup (udg_IndignationGroup)
Indignation Visual

Events


Unit - A unit Starts the effect of an ability

Conditions


(Ability being cast) Equal to Indignation (Neutral Hostile 1)

Actions


Set TempLoc = (Position of (Triggering unit))


Set IndignationGroup = (Units within 375.00 of TempLoc)


For each (Integer A) from 1 to 5, do (Actions)



Loop - Actions




Special Effect - Create a special effect attached to the overhead of (Random unit from IndignationGroup) using Abilities\Spells\Other\Monsoon\MonsoonBoltTarget.mdl)




Special Effect - Destroy (Last created special effect)


Custom script: call DestroyGroup(udg_IndignationGroup)


Custom script: call RemoveLocation(udg_TempLoc)
Indignation Visual

Events


Unit - A unit Starts the effect of an ability

Conditions


(Ability being cast) Equal to Indignation (Neutral Hostile 1)

Actions


Set TempLoc = (Position of (Triggering unit))


Set IndignationGroup = (Units within 375.00 of TempLoc)


For each (Integer A) from 1 to 5, do (Actions)



Loop - Actions




Set TempUnit = (Random unit from IndignationGroup)




Special Effect - Create a special effect attached to the overhead of TempUnit using Abilities\Spells\Other\Monsoon\MonsoonBoltTarget.mdl)




Special Effect - Destroy (Last created special effect)




Unit Group - Remove TempUnit from IndignationGroup


Custom script: call DestroyGroup(udg_IndignationGroup)


Custom script: call RemoveLocation(udg_TempLoc)
