Adding destructibles to a group

TDN

New Member
Reaction score
3
I have a map that spawns trees randomly when a condition is met. Later on I want the trees to be removed when the condition is met again, but I don't want any preset trees to be removed.

Is it possible to add destructibles to a group as they are created, so that I can later delete all destructibles within that group?
 

Necrach

You can change this now in User CP.
Reaction score
62
I do not have the editor to answer your question, but you could create a dummy unit by the position of each spawned tree, and then destroy all destructibles within 0.1 range of any such dummy
 

Accname

2D-Graphics enthusiast
Reaction score
1,462
you can make an index system to save the trees inside an array. like, each time you create a tree you increase an integer variable and save the unit as Trees[Integer] = (LastCreatedDestructible) and if you want to remove them all go with an forLoopIntegerA iteration.
 

TDN

New Member
Reaction score
3
Sounds like it should work, but I've hit a bit of a snag - trees aren't being placed at all. Here's the trigger:

Trigger:
  • Tree spawns
    • Events
      • Time - Every 60.00 seconds of game time
    • Conditions
    • Actions
      • Set Tree_Increments = 1
      • For each (Integer A) from 1 to 200, do (Actions)
        • Loop - Actions
          • Destructible - Remove Tree_Count[(Integer A)]
      • For each (Integer A) from 1 to 50, do (Actions)
        • Loop - Actions
          • Set Location = (Random point in (Playable map area))
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • And - All (Conditions) are true
                • Conditions
                  • (Terrain cliff level at Location) Greater than 1
                  • (Town <gen> contains Location) Equal to False
            • Then - Actions
              • Set TreeScale = (Random real number between 0.85 and 1.10)
              • Set TreeVariation = (Random integer number between 1 and 3)
              • Set SpawnSize = (Random integer number between 1 and 5)
              • For each (Integer A) from 1 to SpawnSize, do (Actions)
                • Loop - Actions
                  • Destructible - Create a Summer Tree Wall at (Location offset by 35.00 towards (Random angle) degrees) facing (Random angle) with scale TreeScale and variation TreeVariation
                  • Set Tree_Count[Tree_Increments] = (Last created destructible)
                  • Set Tree_Increments = (Tree_Increments + 1)
            • Else - Actions
 

Accname

2D-Graphics enthusiast
Reaction score
1,462
first of all, why do you run this iteration from 1 to 200? you create about 50 - 250 trees, that means either you run it too often or not often enough.
Trigger:
  • For each (Integer A) from 1 to 200, do (Actions)
    • Loop - Actions
      • Destructible - Remove Tree_Count[(Integer A)]


this conditions might not be met:
Trigger:
  • If - Conditions
    • And - All (Conditions) are true
      • Conditions
        • <b>(Terrain cliff level at Location) Greater than 1</b>
        • (Town &lt;gen&gt; contains Location) Equal to False

are you sure the cliff level is greater then 1?

and finally this action is leaking a point variable:
Trigger:
  • Destructible - Create a Summer Tree Wall at <b>(Location offset by 35.00 towards (Random angle) degrees)</b> facing (Random angle) with scale TreeScale and variation TreeVariation

with that offset function you are creating another point variable which is leaking.
 

TDN

New Member
Reaction score
3
I'm randomizing the SpawnSize variable between 1 and 5, so that's potentially 50 x 5 trees - I should actually be running 250 removal iterations in the beginning instead of 200.

I disabled both conditions, still no luck. Yes the cliff level is greater than one, since other triggers running that check work fine.

I need the offset, otherwise when I create groups of 2 - 5 trees they'll end up right on top of each other, surely? Anyhow I'm not sure how to fix that leak.
 

Accname

2D-Graphics enthusiast
Reaction score
1,462
Trigger:
  • Tree spawns
    • Events
      • Time - Every 60.00 seconds of game time
    • Conditions
    • Actions
      • Set Tree_Increments = 1
      • For each (Integer A) from 1 to 250, do (Actions)
        • Loop - Actions
          • Destructible - Remove Tree_Count[(Integer A)]
      • For each (Integer A) from 1 to 50, do (Actions)
        • Loop - Actions
          • Set Location = (Random point in (Playable map area))
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • And - All (Conditions) are true
                • Conditions
                  • (Terrain cliff level at Location) Greater than 1
                  • (Town &lt;gen&gt; contains Location) Equal to False
            • Then - Actions
              • Set TreeScale = (Random real number between 0.85 and 1.10)
              • Set TreeVariation = (Random integer number between 1 and 3)
              • Set SpawnSize = (Random integer number between 1 and 5)
              • For each (Integer B) from 1 to SpawnSize, do (Actions)
                • Loop - Actions
                  • set TempPoint = (Location offset by 35.00 towards (Random angle) degrees)
                  • Destructible - Create a Summer Tree Wall at TempPoint facing (Random angle) with scale TreeScale and variation TreeVariation
                  • Set Tree_Count[Tree_Increments] = (Last created destructible)
                  • Set Tree_Increments = (Tree_Increments + 1)
                  • custom script: call RemoveLocation (udg_TempPoint)
            • Else - Actions
          • custom script: call RemoveLocation (udg_Location)

this is how it should look like to avoid memory leaks.
I also noticed you used an integer A iteration inside an integer A iteration, thats not good, i changed the second one to integer B.

to fix your problem you should try adding some debug messages and test where the problem might be.
good luck.
 

TDN

New Member
Reaction score
3
Thanks, it seems to work perfectly, the error was surely the use of an Integer A loop inside another Int. A loop. I can't believe I didn't see that before, I was so busy going through other checks that I missed it ><

I'm curious as to why you destroy both variables TempPoint and Location at the end. I know they leak, but I'll be re-using them constantly throughout the game, and each time they are used they over-write the leak. I would understand if it's a size 1000 array that you are destroying, but a single variable leak that is constantly re-used?
 

Azylaminaz

Vox Populi
Reaction score
91
It isn't cleaned when it is reused, it's just defined in another location and the reference to the first is lost.

Only non-primitive types do this, such as units, locations, groups, forces, special effects.... etc. Primitives do redefine in the same space (reals, integers, etc).
 

Accname

2D-Graphics enthusiast
Reaction score
1,462
[...]
I know they leak, but I'll be re-using them constantly throughout the game, and each time they are used they over-write the leak. I would understand if it's a size 1000 array that you are destroying, but a single variable leak that is constantly re-used?

i think you didnt understand how leaks work.
if you set a variable the stuff saved inside the variable takes up some memory.
if you clear the variable (like with removelocation, destroyGroup, whatsoever) you free the memory.
but if you set the variable, without removing the first saved object, to something else again you still have both objects saved, both objects take some of your memory but the first one cannot be removed again because you lost the reference with saving something else in the variable.
thats a memory leak.
that means, whenever you re-set a point/unitgroup/force/rect/etc variable without removing its reference before you leak memory.
 

TDN

New Member
Reaction score
3
Wow that's completely retarded lol. You'd wonder why the devs at Blizzard didn't have some or most leaks automatically removed. They did such a sloppy job with the GUI editor as well, so much so that there's even a topic floating around allowing the creation of new GUI commands.

Too bad there isn't a better editor in existence; I may try Starcraft 2 but I haven't much hope for it having anything other than a post-modern 'look'.

Yeah I'll definitely be including destroying the variables if they chain-leak like that. :thup:
 

Accname

2D-Graphics enthusiast
Reaction score
1,462
actually i believe the wc3 world editor aint bad at all, just imagine how much you can do with it. i remember the map editor of, lets say command and conquer red alert, compared to the world editor of wc3 that was peanuts.

i think the problem lies within blizzard's lazyness, or maybe they just didnt thought the world editor would become this famous and favoured. Maybe they thought it wouldnt be used that much and didnt introduced that much "in-depth" functions.

however i heard the galaxy editor (of starcraft 2) is alot better then the world editor, with many many new features which where missing in the world editor, like a generic "unit takes damage" event.
i heard it though, might be wrong.
 
General chit-chat
Help Users
  • The Helper The Helper:
    The bots will show up as users online in the forum software but they do not show up in my stats tracking. I am sure there are bots in the stats but the way alot of the bots treat the site do not show up on the stats
  • Varine Varine:
    I want to build a filtration system for my 3d printer, and that shit is so much more complicated than I thought it would be
  • Varine Varine:
    Apparently ABS emits styrene particulates which can be like .2 micrometers, which idk if the VOC detectors I have can even catch that
  • Varine Varine:
    Anyway I need to get some of those sensors and two air pressure sensors installed before an after the filters, which I need to figure out how to calculate the necessary pressure for and I have yet to find anything that tells me how to actually do that, just the cfm ratings
  • Varine Varine:
    And then I have to set up an arduino board to read those sensors, which I also don't know very much about but I have a whole bunch of crash course things for that
  • Varine Varine:
    These sensors are also a lot more than I thought they would be. Like 5 to 10 each, idk why but I assumed they would be like 2 dollars
  • Varine Varine:
    Another issue I'm learning is that a lot of the air quality sensors don't work at very high ambient temperatures. I'm planning on heating this enclosure to like 60C or so, and that's the upper limit of their functionality
  • Varine Varine:
    Although I don't know if I need to actually actively heat it or just let the plate and hotend bring the ambient temp to whatever it will, but even then I need to figure out an exfiltration for hot air. I think I kind of know what to do but it's still fucking confusing
  • The Helper The Helper:
    Maybe you could find some of that information from AC tech - like how they detect freon and such
  • Varine Varine:
    That's mostly what I've been looking at
  • Varine Varine:
    I don't think I'm dealing with quite the same pressures though, at the very least its a significantly smaller system. For the time being I'm just going to put together a quick scrubby box though and hope it works good enough to not make my house toxic
  • Varine Varine:
    I mean I don't use this enough to pose any significant danger I don't think, but I would still rather not be throwing styrene all over the air
  • The Helper The Helper:
    New dessert added to recipes Southern Pecan Praline Cake https://www.thehelper.net/threads/recipe-southern-pecan-praline-cake.193555/
  • The Helper The Helper:
    Another bot invasion 493 members online most of them bots that do not show up on stats
  • Varine Varine:
    I'm looking at a solid 378 guests, but 3 members. Of which two are me and VSNES. The third is unlisted, which makes me think its a ghost.
    +1
  • The Helper The Helper:
    Some members choose invisibility mode
    +1
  • The Helper The Helper:
    I bitch about Xenforo sometimes but it really is full featured you just have to really know what you are doing to get the most out of it.
  • The Helper The Helper:
    It is just not easy to fix styles and customize but it definitely can be done
  • The Helper The Helper:
    I do know this - xenforo dropped the ball by not keeping the vbulletin reputation comments as a feature. The loss of the Reputation comments data when we switched to Xenforo really was the death knell for the site when it came to all the users that left. I know I missed it so much and I got way less interested in the site when that feature was gone and I run the site.
  • Blackveiled Blackveiled:
    People love rep, lol
    +1
  • The Helper The Helper:
    The recipe today is Sloppy Joe Casserole - one of my faves LOL https://www.thehelper.net/threads/sloppy-joe-casserole-with-manwich.193585/
  • The Helper The Helper:
    Decided to put up a healthier type recipe to mix it up - Honey Garlic Shrimp Stir-Fry https://www.thehelper.net/threads/recipe-honey-garlic-shrimp-stir-fry.193595/
  • The Helper The Helper:
    Here is another comfort food favorite - Million Dollar Casserole - https://www.thehelper.net/threads/recipe-million-dollar-casserole.193614/

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top