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

Please check my respawn trigger!

Status
Not open for further replies.
Level 1
Joined
Oct 12, 2009
Messages
1
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!
 
Level 14
Joined
Apr 20, 2009
Messages
1,543
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!

as far as I know this is leakless... and no custom values do not leak, but I'm not sure about the GetUnitUserData... I honestly don't know if that is the correct syntax ;) If your not getting any errors I guess it should work fine ;)

EDIT: ow and next time please use the
  • tags when you paste your trigger from the world editor, thats way easyer to overlook...
 
Level 6
Joined
Mar 22, 2009
Messages
276
fixed with trigger quote:
  • 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())])
next time use the [/trigger] quotes.
 
Level 6
Joined
May 13, 2009
Messages
260
Leak fix
  • Creep Respawn Initialization (For all creeps initially on the map)
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set aleak_group = (Units in(Playable map area) owned by Neutral Hostile)
      • Unit Group - Pick every unit in aleak_group 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))
      • call DestroyGroup( udg_aleak_group )
 
Status
Not open for further replies.
Top