• 🏆 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] Problem with Periodic Trigger/Memory Leaks

Status
Not open for further replies.
Level 2
Joined
Dec 27, 2010
Messages
15
Hey I've got a lil problem here.

I've just started learning about memory leaks and how to fix them, so I'm going through my map ironing them out. I have this trigger here, set to run every 15 seconds:

  • Player Group - Pick every player in tempPlayerGroup and do (Actions)
    • Loop - Actions
      • Unit Group - Pick every unit in (Units owned by (Picked player) of type Slayer) and do (Actions)
        • Loop - Actions
          • Hero - Modify Strength of (Picked unit): Add 4
          • Hero - Modify Agility of (Picked unit): Add 6
          • Hero - Modify Intelligence of (Picked unit): Add 4
(This runs fine apart from leaks)

So I tried to remove the memory leaks on the player group and unit groups. I added the variables tempPlayerGroup and tempGroup, and tried to erase the leaks. Here's what I finished with:

  • Set tempPlayerGroup = WarSlayersGroup
  • Player Group - Pick every player in tempPlayerGroup and do (Actions)
    • Loop - Actions
      • Set tempGroup = (Units owned by (Picked player) of type Slayer)
      • Unit Group - Pick every unit in tempGroup and do (Actions)
        • Loop - Actions
          • Hero - Modify Strength of (Picked unit): Add 4
          • Hero - Modify Agility of (Picked unit): Add 4
          • Hero - Modify Intelligence of (Picked unit): Add 4
  • Custom script: call DestroyForce(udg_tempPlayerGroup)
  • Custom script: call DestroyGroup(udg_tempGroup)
So what happens is it only runs once, then nothing. Something to do with the
  • Player Group - Pick every player in tempPlayerGroup and do (Actions)
    • Loop - Actions
      • Set tempGroup = (Units owned by (Picked player) of type Slayer)
line?

Im stuck, if anyone could help me out that'd be great. :eekani:
 
Well, for this:
  • Set tempPlayerGroup = WarSlayersGroup
What is WarSlayersGroup set to?

Try something like this instead:
  • Player Group - Pick every player in WarSlayersGroup and do (Actions)
    • Loop - Actions
      • Set tempGroup = (Units owned by (Picked player) of type Slayer)
      • Unit Group - Pick every unit in tempGroup and do (Actions)
        • Loop - Actions
          • Hero - Modify Strength of (Picked unit): Add 4
          • Hero - Modify Agility of (Picked unit): Add 4
          • Hero - Modify Intelligence of (Picked unit): Add 4
      • Custom script: call DestroyGroup(udg_tempGroup)
The problem is that you destroy the force in general, not just the reference to it. (tempPlayerGroup) By destroying the tempPlayerGroup, you are also destroying the WarSlayersGroup.

The usage of WarSlayersGroup in the trigger above may or may not count as a leak, it depends. Show us the whole trigger, and we'll see. :)
 
Level 2
Joined
Dec 27, 2010
Messages
15
There's two triggers that make this work. One has the function of adding a player to the WarSlayersGroup when they research a specific technology. The WarSlayersGroup initially has no players in it. Here's the above mentioned trigger:

Unit - A unit Finishes research
Conditions
(Researched tech-type) Equal to Slayer Warfare Training
Actions
Player Group - Add (Owner of (Researching unit)) to WarSlayers
Trigger - Turn on Periodic WarSlayers <gen>

This turns on the trigger and adds the player to the variable WarSlayersGroup so their slayer gets the periodic stat gain effect every 15 seconds.
 
Status
Not open for further replies.
Top