• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[Trigger] Leak in Custom Resource Harvesting System

Status
Not open for further replies.
Level 12
Joined
May 20, 2009
Messages
822
Need help with this custom Harvest system

Having some huge leaks in here and I can't quite find them.

  • Ordered To Mine
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Unit-type of (Triggering unit)) Equal to Peasant
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Ability being cast) Equal to Harvest
            • Then - Actions
              • Unit - Add Peasant Morph to (Triggering unit)
              • Selection - Remove (Triggering unit) from selection for (Owner of (Triggering unit))
              • Animation - Play Gold Mine 0013 <gen>'s work animation
              • Set __GS_GoldHarvestMaxIndex = (__GS_GoldHarvestMaxIndex + 1)
              • Set __GS_GoldHarvestingUpdate[__GS_GoldHarvestMaxIndex] = 1
              • Set __GS_TargetMine[__GS_GoldHarvestMaxIndex] = (Target unit of ability being cast)
              • Set __GS_GoldHarvestTimer[__GS_GoldHarvestMaxIndex] = 0
              • Set __GS_GoldHarvestUnit[__GS_GoldHarvestMaxIndex] = (Triggering unit)
              • Set __GS_GoldHarvestUnitPoint[__GS_GoldHarvestMaxIndex] = (Position of __GS_GoldHarvestUnit[__GS_GoldHarvestMaxIndex])
            • Else - Actions
        • Else - Actions
  • Timer Order Return
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • For each (Integer __GS_GoldHarvestMaxIndex) from 1 to __GS_GoldHarvestInit, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • __GS_GoldHarvestingUpdate[__GS_GoldHarvestInit] Equal to 1
              • __GS_GoldHarvestTimer[__GS_GoldHarvestInit] Less than 67
            • Then - Actions
              • Set __GS_GoldHarvestTimer[__GS_GoldHarvestInit] = (__GS_GoldHarvestTimer[__GS_GoldHarvestInit] + 1)
              • Selection - Remove __GS_GoldHarvestUnit[__GS_GoldHarvestInit] from selection
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • __GS_GoldHarvestingUpdate[__GS_GoldHarvestInit] Equal to 1
              • __GS_GoldHarvestTimer[__GS_GoldHarvestInit] Equal to 66
            • Then - Actions
              • Unit - Remove Peasant Morph from __GS_GoldHarvestUnit[__GS_GoldHarvestInit]
              • Unit - Add Peasant Remorph to __GS_GoldHarvestUnit[__GS_GoldHarvestInit]
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • __GS_GoldHarvestingUpdate[__GS_GoldHarvestInit] Equal to 1
              • __GS_GoldHarvestTimer[__GS_GoldHarvestInit] Equal to 67
            • Then - Actions
              • Set __GS_GoldHarvestingUpdate[__GS_GoldHarvestInit] = 0
              • Animation - Add the gold animation tag to __GS_GoldHarvestUnit[__GS_GoldHarvestInit]
              • Animation - Play Gold Mine 0013 <gen>'s stand animation
              • Neutral Building - Add -100 gold to Gold Mine 0013 <gen>
              • Unit - Remove Peasant Remorph from __GS_GoldHarvestUnit[__GS_GoldHarvestInit]
              • Unit - Add Return Resources to __GS_GoldHarvestUnit[__GS_GoldHarvestInit]
              • Unit - Remove Harvest from __GS_GoldHarvestUnit[__GS_GoldHarvestInit]
              • Custom script: set bj_wantDestroyGroup = true
              • Unit Group - Pick every unit in (Units within 8192.00 of __GS_GoldHarvestUnitPoint[__GS_GoldHarvestInit]) 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)) Equal to __GS_ReturnSource[__GS_GoldHarvestInit]
                    • Then - Actions
                      • Unit - Order GoldReturningUnit to Neutral Alchemist - Transmute (Picked unit)
                      • Custom script: call RemoveLocation(udg___GS_GoldHarvestUnitPoint[udg___GS_GoldHarvestInit])
                    • Else - Actions
              • Set __GS_GoldHarvestUnit[__GS_GoldHarvestInit] = No unit
            • Else - Actions
  • HarvesterDontIdle
    • Events
      • Time - Every 0.00 seconds of game time
    • Conditions
    • Actions
      • For each (Integer __GS_GoldHarvestInit) from 1 to __GS_GoldHarvestMaxIndex, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • __GS_GoldHarvestingUpdate[__GS_GoldHarvestInit] Equal to 1
              • __GS_GoldHarvestTimer[__GS_GoldHarvestInit] Less than 67
            • Then - Actions
              • Unit - Order __GS_GoldHarvestUnit[__GS_GoldHarvestInit] to Undead Crypt Fiend - Web __GS_TargetMine[__GS_GoldHarvestInit]
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • GoldReturningUpdate Equal to 1
              • GoldReturnedTimer Less than 67
            • Then - Actions
              • Custom script: set bj_wantDestroyGroup = true
              • Unit Group - Pick every unit in (Units within 8192.00 of __GS_GoldHarvestUnitPoint[__GS_GoldHarvestInit]) 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)) Equal to __GS_ReturnSource[__GS_GoldHarvestInit]
                    • Then - Actions
                      • Unit - Order GoldReturningUnit to Neutral Alchemist - Transmute (Picked unit)
                      • Custom script: call RemoveLocation(udg___GS_GoldHarvestUnitPoint[udg___GS_GoldHarvestInit])
                    • Else - Actions
            • Else - Actions
This isn't the entire system, as it's not finished yet, but this causes a leak.

EDIT: It may be the last trigger, but stay tuned as there's bound to be A LOT more, not to mention it's nice to see if there's anything else I need to fix. (Especially since I'm highly considering submitting this)

EDIT2: Okay so now I can't get the second ITE to function. . .The conditions are not the issue, as I put some text to display there and it displays.
 
Last edited:
Level 15
Joined
Aug 7, 2013
Messages
1,338
How do you know there are leaks? Did WC3's memory usage increase over time without bound?

I believe you may be leaking a group here in this line:

Unit Group - Pick every unit in (Units within 8192.00 of __GS_GoldHarvestUnitPoint[__GS_GoldHarvestInit]) and do (Actions)

Cache the group created by Units within 8192.00 of __GS_GoldHarvestUnitPoint[__GS_GoldHarvestInit] into a group object. Then remove it after you finish looping over every unit.

I believe the same problem also holds in other cases where you do Unit Group - Pick every unit in(...).

But I could be wrong since I'm not familiar with GUI.
 
Level 12
Joined
May 20, 2009
Messages
822
Yeah, I think you're right. But Unit Group leaks don't cause a huge problem unless they're very large groups. In this case, it often won't be. So that I'll fix later. And actually, doing "set bj_wantDestroyGroup" removes a lot of the leaks in it.

Right now, I'm having one particular problem.

Also, my first issue was visible slowing and very quickly freezing the game. The problem in it was the last trigger having a periodic timer of 0.00. Changing it to 0.10 completely fixed the lag issue.


  • Ordered To Mine
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Unit-type of (Triggering unit)) Equal to Peasant
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Ability being cast) Equal to Harvest
            • Then - Actions
              • Unit - Add Peasant Morph to (Triggering unit)
              • Selection - Remove (Triggering unit) from selection for (Owner of (Triggering unit))
              • Animation - Play Gold Mine 0013 <gen>'s work animation
              • Set __GS_GoldHarvestMaxIndex = (__GS_GoldHarvestMaxIndex + 1)
              • Set __GS_GoldHarvestingUpdate[__GS_GoldHarvestMaxIndex] = 1
              • Set __GS_TargetMine[__GS_GoldHarvestMaxIndex] = (Target unit of ability being cast)
              • Set __GS_GoldHarvestTimer[__GS_GoldHarvestMaxIndex] = 0
              • Set __GS_GoldHarvestUnit[__GS_GoldHarvestMaxIndex] = (Triggering unit)
              • Set __GS_GoldHarvestUnitPoint[__GS_GoldHarvestMaxIndex] = (Position of __GS_GoldHarvestUnit[__GS_GoldHarvestMaxIndex])
            • Else - Actions
        • Else - Actions
  • Timer Order Return
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • For each (Integer __GS_GoldHarvestInit) from 1 to __GS_GoldHarvestMaxIndex, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • __GS_GoldHarvestingUpdate[__GS_GoldHarvestInit] Equal to 1
              • __GS_GoldHarvestTimer[__GS_GoldHarvestInit] Less than 67
            • Then - Actions
              • Set __GS_GoldHarvestTimer[__GS_GoldHarvestInit] = (__GS_GoldHarvestTimer[__GS_GoldHarvestInit] + 1)
              • Selection - Remove __GS_GoldHarvestUnit[__GS_GoldHarvestInit] from selection
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • __GS_GoldHarvestingUpdate[__GS_GoldHarvestInit] Equal to 1
              • __GS_GoldHarvestTimer[__GS_GoldHarvestInit] Equal to 66
            • Then - Actions
              • Game - Display to (All players) the text: FIRED!
              • Unit - Remove Peasant Morph from __GS_GoldHarvestUnit[__GS_GoldHarvestInit]
              • Unit - Add Peasant Remorph to __GS_GoldHarvestUnit[__GS_GoldHarvestInit]
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • __GS_GoldHarvestingUpdate[__GS_GoldHarvestInit] Equal to 1
              • __GS_GoldHarvestTimer[__GS_GoldHarvestInit] Equal to 67
            • Then - Actions
              • Set __GS_GoldHarvestingUpdate[__GS_GoldHarvestInit] = 0
              • Animation - Add the gold animation tag to __GS_GoldHarvestUnit[__GS_GoldHarvestInit]
              • Animation - Play Gold Mine 0013 <gen>'s stand animation
              • Neutral Building - Add -100 gold to Gold Mine 0013 <gen>
              • Unit - Remove Peasant Remorph from __GS_GoldHarvestUnit[__GS_GoldHarvestInit]
              • Unit - Add Return Resources to __GS_GoldHarvestUnit[__GS_GoldHarvestInit]
              • Unit - Remove Harvest from __GS_GoldHarvestUnit[__GS_GoldHarvestInit]
              • Custom script: set bj_wantDestroyGroup = true
              • Unit Group - Pick every unit in (Units within 8192.00 of __GS_GoldHarvestUnitPoint[__GS_GoldHarvestInit]) 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)) Equal to __GS_ReturnSource[__GS_GoldHarvestInit]
                    • Then - Actions
                      • Unit - Order __GS_GoldHarvestUnit[__GS_GoldHarvestInit] to Human Blood Mage - Banish (Picked unit)
                      • Custom script: call RemoveLocation(udg___GS_GoldHarvestUnitPoint[udg___GS_GoldHarvestInit])
                    • Else - Actions
            • Else - Actions


I think the problem is somewhere in these:

  • Ordered to Return
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Unit-type of (Triggering unit)) Equal to Peasant
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Ability being cast) Equal to Return Resources
            • Then - Actions
              • Set __GS_HarvestReturnMaxIndex = (__GS_HarvestReturnMaxIndex + 1)
              • Set __GS_GoldReturnedTimer[__GS_HarvestReturnMaxIndex] = 0
              • Set __GS_GoldReturningUnit[__GS_HarvestReturnMaxIndex] = (Triggering unit)
              • Set GoldReturningUpdate = 1
              • Unit - Add Peasant Morph to (Triggering unit)
              • Selection - Remove (Triggering unit) from selection
            • Else - Actions
        • Else - Actions
  • Timer Order Harvest
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • For each (Integer __GS_GoldHarvestInit) from 1 to __GS_HarvestReturnMaxIndex, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • GoldReturningUpdate Equal to 1
              • __GS_GoldReturnedTimer[__GS_GoldHarvestInit] Less than 67
            • Then - Actions
              • Set __GS_GoldReturnedTimer[__GS_GoldHarvestInit] = (__GS_GoldReturnedTimer[__GS_GoldHarvestInit] + 1)
              • Selection - Remove __GS_GoldReturningUnit[__GS_GoldHarvestInit] from selection
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • GoldReturningUpdate Equal to 1
              • __GS_GoldReturnedTimer[__GS_GoldHarvestInit] Equal to 66
            • Then - Actions
              • Unit - Remove Peasant Morph from __GS_GoldReturningUnit[__GS_GoldHarvestInit]
              • Unit - Add Peasant Remorph to __GS_GoldReturningUnit[__GS_GoldHarvestInit]
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • GoldReturningUpdate Equal to 1
              • __GS_GoldReturnedTimer[__GS_GoldHarvestInit] Equal to 67
            • Then - Actions
              • Set GoldReturningUpdate = 0
              • Unit - Remove Peasant Remorph from __GS_GoldReturningUnit[__GS_GoldHarvestInit]
              • Unit - Add Harvest to __GS_GoldReturningUnit[__GS_GoldHarvestInit]
              • Unit - Remove Return Resources from __GS_GoldReturningUnit[__GS_GoldHarvestInit]
              • Animation - Remove the gold animation tag to __GS_GoldReturningUnit[__GS_GoldHarvestInit]
              • Set GoldReturnedFinished = 1
              • Set PlayerGold[1] = (PlayerGold[1] + 100)
              • Multiboard - Set the text for PlayerResources item in column 1, row 1 to (|c00BBAA00Gold:|r + (String(PlayerGold[1])))
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • __GS_GoldPointOrder[__GS_GoldHarvestInit] Equal to False
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • __GS_GoldMineInRange[__GS_GoldHarvestInit] Equal to True
                • Then - Actions
                  • Unit - Order __GS_GoldReturningUnit[__GS_GoldHarvestInit] to Night Elf Warden - Shadow Strike __GS_TargetMine[__GS_GoldHarvestInit]
                  • Set __GS_GoldMineInRange[__GS_GoldHarvestInit] = False
                • Else - Actions
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • __GS_GoldMineInRange[__GS_GoldHarvestInit] Equal to False
              • __GS_GoldPointOrder[__GS_GoldHarvestInit] Equal to False
              • GoldReturnedFinished Equal to 1
            • Then - Actions
              • Unit - Remove Harvest from __GS_GoldReturningUnit[__GS_GoldHarvestInit]
              • Unit - Add Harvest (Point Order) to __GS_GoldReturningUnit[__GS_GoldHarvestInit]
              • Set __GS_TargetMinePoint[__GS_GoldHarvestInit] = (Position of __GS_TargetMine[__GS_GoldHarvestInit])
              • Unit - Order __GS_GoldReturningUnit[__GS_GoldHarvestInit] to Orc Far Seer - Earthquake __GS_TargetMinePoint[__GS_GoldHarvestInit]
              • Set __GS_GoldPointOrder[__GS_GoldHarvestInit] = True
              • Set GoldReturnedFinished = 0
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • __GS_GoldPointOrder[__GS_GoldHarvestInit] Equal to True
              • __GS_GoldMineInRange[__GS_GoldHarvestInit] Equal to False
            • Then - Actions
              • Game - Display to (All players) the text: FIRED!
              • Set __GS_GoldReturningUnitPoint[__GS_GoldHarvestInit] = (Position of __GS_GoldReturningUnit[__GS_GoldHarvestInit])
              • Custom script: set bj_wantDestroyGroup = true
              • Unit Group - Pick every unit in (Units within 100.00 of __GS_GoldReturningUnitPoint[__GS_GoldHarvestInit]) and do (Actions) //It's somewhere in here, I think.
                • Loop - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Picked unit) Equal to __GS_TargetMine[__GS_GoldHarvestInit]
                    • Then - Actions
                      • Set __GS_GoldMineInRange[__GS_GoldHarvestInit] = True
                      • Set __GS_GoldPointOrder[__GS_GoldHarvestInit] = False
                      • Unit - Remove Harvest (Point Order) from __GS_GoldReturningUnit[__GS_GoldHarvestInit]
                      • Unit - Add Harvest to __GS_GoldReturningUnit[__GS_GoldHarvestInit]
                      • Custom script: call RemoveLocation(udg___GS_GoldReturningUnitPoint[udg___GS_GoldHarvestInit])
                    • Else - Actions
            • Else - Actions
Basically, in the very last ITE, in the Unit Group, it's suppose to remove the Point Order ability and add the normal Harvest ability at that point. But I can't quite figure out why it's not doing that.

I can provide a test map if it's necessary.

EDIT: I think I'm done with it for the night. But please do give me as much info as you can now so I can check back in the morning and make suggested changes. =)
EDIT2: Do still need help with this, or at least until I figure it out. If I figure it out, I'll edit this post again, but I might not figure it out any time soon.
 
Last edited:
Level 12
Joined
May 20, 2009
Messages
822
Bumping with a test map.

I'm having quite a lot of trouble figuring out what the problem is. It's also very messy.

The reason why I want this though is because this allows me to do a few things -

1. I can catch when Gold is harvested or returned via an "A unit starts the effect of an Ability" event.
2. I have some pretty extreme control over how every bit functions.
3. I plan on making this work for a virtually limitless amount of different resources. One can have Stone, Iron, Gold, Oil, etc.

There's one downside and that is I'll have to do something completely different for lumber harvesting, using the same abilities somehow, especially since I want virtually the same as the three things I listed above.
 

Attachments

  • CustomHarvestSystem.w3x
    28.8 KB · Views: 32
Level 12
Joined
May 20, 2009
Messages
822
I've done a lot of looking at it, and our systems are a bit too different to learn anything off of it. I think, anyway.

What I've done works, I'm just having trouble converting it over to MUI.

Once it's converted over to MUI, I can very easily do everything else I plan on doing.

Basically, your system works good but I need a lot more control and flexibility in it. So that's why I decided to make my own.

I'm at my wits end of trying to figure out what's wrong with it, that's why I'm asking for help.
 
Status
Not open for further replies.
Top