Hey all, first time poster here. I've done a lot of playing around on the SC and WC3 editors for years, just never really got around to doing a whole map. Anyways, doing an ORPG right now, and just learned about the cause of memory leaks. I'll post all 3 triggers involved in the creep respawn, could you please check to see if I removed all memory leaks?
Creep Respawn Initialization (For all creeps initially on the map)
Events
Map initialization
Conditions
Actions
Unit Group - Pick every unit in (Units in (Playable map area) owned by Neutral Hostile) and do (Actions)
Loop - Actions
Set creepCount = (creepCount + 1)
Unit - Set the custom value of (Picked unit) to creepCount
Set creepLocation[(Custom value of (Picked unit))] = (Position of (Picked unit))
New Creep Enters Game Respawn (for all creeps that enter the game beyond initialization)
Events
Unit - A unit enters (Playable map area)
Conditions
(Owner of (Triggering unit)) Equal to Neutral Hostile
Actions
Set creepCount = (creepCount + 1)
Unit - Set the custom value of (Triggering unit) to creepCount
Set creepLocation[creepCount] = (Position of (Triggering unit))
Creep Respawn Function (actual respawn trigger)
Events
Unit - A unit owned by Neutral Hostile Dies
Conditions
(Triggering unit) Not equal to (Summoned unit)
Actions
Wait 30.00 seconds
Unit - Create 1 (Unit-type of (Triggering unit)) for Neutral Hostile at creepLocation[(Custom value of (Triggering unit))] facing Default building facing degrees
Custom script: call RemoveLocation (udg_creepLocation[GetUnitUserData(GetTriggerUnit())])
I tested this with a few random creeps, works fine, just couldn't tell if there was a memory leak yet. What I'm mainly asking for is if the syntax of my custom script in the third trigger is proper for removing the initial location of the creep that died. Also do custom values leak? Should those be removed as well when creep die? Thanks in advance!
Creep Respawn Initialization (For all creeps initially on the map)
Events
Map initialization
Conditions
Actions
Unit Group - Pick every unit in (Units in (Playable map area) owned by Neutral Hostile) and do (Actions)
Loop - Actions
Set creepCount = (creepCount + 1)
Unit - Set the custom value of (Picked unit) to creepCount
Set creepLocation[(Custom value of (Picked unit))] = (Position of (Picked unit))
New Creep Enters Game Respawn (for all creeps that enter the game beyond initialization)
Events
Unit - A unit enters (Playable map area)
Conditions
(Owner of (Triggering unit)) Equal to Neutral Hostile
Actions
Set creepCount = (creepCount + 1)
Unit - Set the custom value of (Triggering unit) to creepCount
Set creepLocation[creepCount] = (Position of (Triggering unit))
Creep Respawn Function (actual respawn trigger)
Events
Unit - A unit owned by Neutral Hostile Dies
Conditions
(Triggering unit) Not equal to (Summoned unit)
Actions
Wait 30.00 seconds
Unit - Create 1 (Unit-type of (Triggering unit)) for Neutral Hostile at creepLocation[(Custom value of (Triggering unit))] facing Default building facing degrees
Custom script: call RemoveLocation (udg_creepLocation[GetUnitUserData(GetTriggerUnit())])
I tested this with a few random creeps, works fine, just couldn't tell if there was a memory leak yet. What I'm mainly asking for is if the syntax of my custom script in the third trigger is proper for removing the initial location of the creep that died. Also do custom values leak? Should those be removed as well when creep die? Thanks in advance!