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

Tree regrowth...but with a twist!

Status
Not open for further replies.
Level 1
Joined
Dec 15, 2013
Messages
4
Apologies in advance for covering yet another topic that's probably been beaten to death, but after two days of searching, I still seem to be coming up blank, so if if this has been covered previously then apologies in advance.

In terms of expected outcome for the trigger or script, what I'm looking for is a very slow and gradual tree regrowth script over time for an altered melee-style map. Rather then using scripts that revive fallen trees after a set period, I want the script to check for dead trees in the region and revive them randomly every x amount of seconds. For that purpose I've cobbled together a really rudimentary script for now that needs some serious polishing.

  • Events
  • -Time - Every 30.00 seconds of game time
  • Actions
  • -Destructible - Resurrect (Random destructible in (Entire map) Matching (((Destructible-type of (Matching Destructible)) Equal to (==) Summer Tree Wall) and ((Current life of (Matching Destructible)) Less than or equal to (<= 0.00) with 120.00 life and Show birth animation
As you can see, the trigger is...really long for what I would think is a fairly straightforward trigger and is probable a lot more complicated then it needs to be, so I'd like some help in streamlining it. A few extra considerations - the map is huge, and has an absolute ton of tree in the landscape, so I'd like to avoid anything that relies on logging the number of killed destructibles or anything that could potentially cause memory problems if the number of values stored increases memory usage. If a single global region is too much then smaller regions with staggered trigger times (ie all regions fire every 30 seconds, but region 2's trigger fires 5 seconds after region 1 and so forth) is a possible workaround to reduce trigger-related shudders in-game. I'm very open to suggestions.

Another factor I'd like to look into concerns blighted trees. If at all possible, I'd like to add in some sort of mechanic whereupon a blighted tree does not revive under this global trigger. I can live without this extra function, but I figured I would ask.

I'm open to using JASS, as I can read it, but I'm not all that adept at writing it, and in all honesty this is the first time I've cracked open the World Editor in a few years, so I've probably forgotten most of what I used to know.

Anyway, thanks for hearing me out, and a BIG thanks in advance to anyone who can help me out with this script!
 
Last edited:
Level 1
Joined
Dec 15, 2013
Messages
4
Yeah, I figured the blight thing would be fairly easy theoretically, but at the same time I'm not sure if it's worth the hassle or how taxing it'll be on memory, so those are important factors.

Also, I forgot to mention this above, but the map I'm making uses more then one tree type, so the trigger I wrote above only fires per tree type, which feels a bit clunky. I figure there's a variable array that'd solve that particular issue, but I've never delved into variables myself, so that seems like an alien concept to me.

Not that I'm asking for help on that particular issue, because there's likely a million and one tutorials on that. I just thought it'd be worth clarifying.
 
Level 15
Joined
Oct 18, 2008
Messages
1,588
Well whatever you do this one will never become too... effective :D The thing is (as far as I know) if you use regions, the game iterates through all the trees on the map to find the ones in your region (unless the trees area already placed into quadtrees by the engine, not sure about that), so you can't avoid including all the trees in your calculations this way.

So I think it's easier to write a trigger that catches dying trees and adds them to an array. Using an array should be faster than iterating through all the trees on the map to find the dead ones, especially since what you create there (or at least it should work like that) are just pointers to existing objects, not much excess memory is used.

But in the end it really depends on how the engine handles destructibles and pointers, which I'm not entirely sure about.
 
Level 1
Joined
Dec 15, 2013
Messages
4
I was thinking that too - regarding 'there's no nice, clean way of getting that effect' because ultimately the effect is still dependant on going through the region and picking out dead trees and reviving them at random, which involves a LOT of a checks as my map is quite tree heavy.

A thought did occur to me though - what if I had a trigger where, upon the tree dying, the destructible is removed and replaced with a 'dummy stump destructible' instead? Then I'd make the tree revival trigger pick from the stumps at random, remove the picked stump and create a new tree at the same location as the that dummy stump? I mean, late game it'd still create a heavier load, because the trigger isn't designed to keep up with the rate at which trees are cut down, it'd still probably be less laggy then checking every tree and stump.
 
Level 15
Joined
Oct 18, 2008
Messages
1,588
I was thinking that too - regarding 'there's no nice, clean way of getting that effect' because ultimately the effect is still dependant on going through the region and picking out dead trees and reviving them at random, which involves a LOT of a checks as my map is quite tree heavy.

A thought did occur to me though - what if I had a trigger where, upon the tree dying, the destructible is removed and replaced with a 'dummy stump destructible' instead? Then I'd make the tree revival trigger pick from the stumps at random, remove the picked stump and create a new tree at the same location as the that dummy stump? I mean, late game it'd still create a heavier load, because the trigger isn't designed to keep up with the rate at which trees are cut down, it'd still probably be less laggy then checking every tree and stump.

Having an array of trees with only the dead ones in it is practically the same thing as having a stump destructible, memory-wise. But this one does not include the removal of a tree and the creation of a new destructible, but rather just creating a pointer to a dead tree.

So essentially if you replace things you end up using too much resources, better just add the destroyed ones to an array and select a random one from that array to revive.
 
Level 1
Joined
Dec 15, 2013
Messages
4
I actually completely misread your first post - remind me not to talk triggers before having my morning coffee, haha. That makes more sense!
 
Status
Not open for further replies.
Top