• Check out the results of the Techtree Contest #19!
  • 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.
  • Create a void inspired texture for Warcraft 3 and enter Hive's 34th Texturing Contest: Void! Click here to enter!
  • The Hive's 22nd Icon Contest: Creep Abilities is now concluded, time to vote for your favourite set of icons! Click here to vote!

Regrow Forests

Level 4
Joined
May 27, 2013
Messages
50
I want to make a trigger that causes all the trees in an area to regrow a short time after the last one is cut down. I tried looking in the event area, but there is no option for starting something when there are zero trees in an area.
 
I had problems in tracking cut trees in my project and I didn’t find any solution like we can do with unit groups.

In my project, the answer was to find key points where the trees could respawn, and order destructibles to revive.

If you have a level design issue, that when trees respawn, can trap units, change the layout and check pathing to prevent this from happening, while using a countdown or similar trigger to respawn trees.

This is my suggestions :)
 
One way would be to use a "Destructible within region dies" and any time it runs pick all destructibles in the area and see if any are alive
  • Events
    • Destructible - A destructible within SomeRegion <gen> dies
The issue with the event is that it reacts only for the first 64 destructibles in a region and besides trees it could include stuff like barrels and crates.

The other option is to enumerate trees in given region during map initialization, store their count in a variable and register them one by one in another trigger with "Destructible dies" event. This will work better as there is no '64 destructibles' limit:
  • Map Ini
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Destructible - Pick every destructible in SomeRegion <gen> and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Or - Any (Conditions) are true
                • Conditions
                  • (Destructible-type of (Picked destructible)) Equal to Summer Tree Wall
                  • (Destructible-type of (Picked destructible)) Equal to Cityscape Fall Tree Wall
            • Then - Actions
              • Set VariableSet AliveTreeCount = (AliveTreeCount + 1)
              • Trigger - Add to Tree Dies <gen> the event (Destructible - (Picked destructible) dies)
            • Else - Actions
  • Tree Dies
    • Events
    • Conditions
    • Actions
      • Set VariableSet AliveTreeCount = (AliveTreeCount - 1)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • AliveTreeCount Equal to 0
        • Then - Actions
          • -------- Wait a bit so that the (Dying destructible) can be resurrected --------
          • Wait 0.10 seconds
          • Destructible - Pick every destructible in SomeRegion <gen> and do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • ((Picked destructible) is dead) Equal to True
                  • Or - Any (Conditions) are true
                    • Conditions
                      • (Destructible-type of (Picked destructible)) Equal to Summer Tree Wall
                      • (Destructible-type of (Picked destructible)) Equal to Cityscape Fall Tree Wall
                • Then - Actions
                  • Set VariableSet AliveTreeCount = (AliveTreeCount + 1)
                  • Destructible - Resurrect (Picked destructible) with (Max life of (Picked destructible)) life and Show birth animation
                • Else - Actions
        • Else - Actions
Notice that the second trigger does not have any events, as those events are added during map initialization via "Trigger - Add to Tree Dies <gen> the event (Destructible - (Picked destructible) dies)"
 
Another approach would be to poll through all destructibles on the map at a rate that every few minutes all will have been checked. You can then register any dead trees to a tree respawn system which can have logic to check if all nearby trees are dead and there are no units directly above the tree before respawning trees.
 
Back
Top