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

Dynamic trees with lifestages

Status
Not open for further replies.
Level 5
Joined
May 21, 2006
Messages
22
Hey
I have had an idea for making a fully dynamic map, with eco-systems and such at some point. So recently I have been messing around with making trees age, die and respawn. I have made a proto-type for it, but I would love to get some feedback, because I am not sure I have done it the best way
I hope you have time to check it out

  • Tree replacer Copy
    • Events
      • Time - Every 2.00 seconds of game time
    • Conditions
    • Actions
      • Set WaterCheck = ((Position of (Random destructible in (Playable map area) matching ((Destructible-type of (Matching destructible)) Equal to Summer Tree Wall))) offset by ((Random real number between -500.00 and 500.00), (Random real number between -500.00 and 500.00)))
      • Set DyingTree = 1
      • Destructible - Kill (Random destructible in (Playable map area) matching ((Destructible-type of (Matching destructible)) Equal to Summer Tree Wall (Dead)))
      • Wait 5.00 seconds
      • Destructible - Pick every destructible in (Playable map area) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • And - All (Conditions) are true
                • Conditions
                  • (Destructible-type of (Picked destructible)) Equal to Summer Tree Wall (sprout)
                  • (Current life of (Picked destructible)) Equal to 0.00
            • Then - Actions
              • Destructible - Remove (Picked destructible)
              • For each (Integer DyingTree) from 0 to DyingTree, do (Actions)
                • Loop - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • And - All (Conditions) are true
                        • Conditions
                          • (Terrain pathing at WaterCheck of type Walkability is off) Equal to False
                          • (Terrain pathing at WaterCheck of type Buildability is off) Equal to False
                    • Then - Actions
                      • Destructible - Create a Summer Tree Wall (sprout) at WaterCheck facing (Random angle) with scale (Random real number between 0.10 and 0.50) and variation (Random integer number between 0 and 9)
                      • Animation - Play (Last created destructible)'s birth animation
                      • Animation - Change (Last created destructible)'s animation speed to 100.00% of its original speed
                      • Set WaterCheck = ((Position of (Random destructible in (Playable map area) matching ((Destructible-type of (Matching destructible)) Equal to Summer Tree Wall))) offset by ((Random real number between -500.00 and 500.00), (Random real number between -500.00 and 500.00)))
                      • Game - Display to (All players) the text: Spawn
                      • Skip remaining actions
                    • Else - Actions
                      • Set WaterCheck = ((Position of (Random destructible in (Playable map area) matching ((Destructible-type of (Matching destructible)) Equal to Summer Tree Wall))) offset by ((Random real number between -500.00 and 500.00), (Random real number between -500.00 and 500.00)))
                      • Set DyingTree = (DyingTree + 1)
                      • Game - Display to (All players) the text: Spawn
            • Else - Actions
              • Do nothing
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • And - All (Conditions) are true
                • Conditions
                  • (Destructible-type of (Picked destructible)) Equal to Summer Tree Wall
                  • (Current life of (Picked destructible)) Equal to 0.00
            • Then - Actions
              • Destructible - Remove (Picked destructible)
              • For each (Integer DyingTree) from 0 to DyingTree, do (Actions)
                • Loop - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • And - All (Conditions) are true
                        • Conditions
                          • (Terrain pathing at WaterCheck of type Walkability is off) Equal to False
                          • (Terrain pathing at WaterCheck of type Buildability is off) Equal to False
                    • Then - Actions
                      • Set TreeSpawnPoint = (Random destructible in (Playable map area) matching ((Destructible-type of (Matching destructible)) Equal to Summer Tree Wall (sprout)))
                      • Set TreeSpawnPoint_Copy = (Position of TreeSpawnPoint)
                      • Destructible - Remove TreeSpawnPoint
                      • Destructible - Create a Summer Tree Wall at TreeSpawnPoint_Copy facing (Random angle) with scale (Random real number between 0.80 and 1.20) and variation (Random integer number between 0 and 9)
                      • Destructible - Create a Summer Tree Wall (sprout) at WaterCheck facing (Random angle) with scale (Random real number between 0.10 and 0.50) and variation (Random integer number between 0 and 9)
                      • Animation - Play (Last created destructible)'s birth animation
                      • Animation - Change (Last created destructible)'s animation speed to 100.00% of its original speed
                      • Set WaterCheck = ((Position of (Random destructible in (Playable map area) matching ((Destructible-type of (Matching destructible)) Equal to Summer Tree Wall))) offset by ((Random real number between -500.00 and 500.00), (Random real number between -500.00 and 500.00)))
                      • Game - Display to (All players) the text: Spawn
                      • Skip remaining actions
                    • Else - Actions
                      • Set WaterCheck = ((Position of (Random destructible in (Playable map area) matching ((Destructible-type of (Matching destructible)) Equal to Summer Tree Wall))) offset by ((Random real number between -500.00 and 500.00), (Random real number between -500.00 and 500.00)))
                      • Set DyingTree = (DyingTree + 1)
                      • Game - Display to (All players) the text: Spawn
            • Else - Actions
              • Do nothing
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • And - All (Conditions) are true
                • Conditions
                  • (Destructible-type of (Picked destructible)) Equal to Summer Tree Wall (Old)
                  • (Current life of (Picked destructible)) Equal to 0.00
            • Then - Actions
              • Destructible - Remove (Picked destructible)
              • For each (Integer DyingTree) from 0 to DyingTree, do (Actions)
                • Loop - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • And - All (Conditions) are true
                        • Conditions
                          • (Terrain pathing at WaterCheck of type Walkability is off) Equal to False
                          • (Terrain pathing at WaterCheck of type Buildability is off) Equal to False
                    • Then - Actions
                      • Set TreeSpawnPoint = (Random destructible in (Playable map area) matching ((Destructible-type of (Matching destructible)) Equal to Summer Tree Wall))
                      • Set TreeSpawnPoint_Copy = (Position of TreeSpawnPoint)
                      • Destructible - Remove TreeSpawnPoint
                      • Destructible - Create a Summer Tree Wall (Old) at TreeSpawnPoint_Copy facing (Random angle) with scale (Random real number between 1.40 and 1.60) and variation (Random integer number between 0 and 9)
                      • Set TreeSpawnPoint = (Random destructible in (Playable map area) matching ((Destructible-type of (Matching destructible)) Equal to Summer Tree Wall (sprout)))
                      • Set TreeSpawnPoint_Copy = (Position of TreeSpawnPoint)
                      • Destructible - Remove TreeSpawnPoint
                      • Destructible - Create a Summer Tree Wall at TreeSpawnPoint_Copy facing (Random angle) with scale (Random real number between 0.80 and 1.20) and variation (Random integer number between 0 and 9)
                      • Destructible - Create a Summer Tree Wall (sprout) at WaterCheck facing (Random angle) with scale (Random real number between 0.10 and 0.50) and variation (Random integer number between 0 and 9)
                      • Animation - Play (Last created destructible)'s birth animation
                      • Animation - Change (Last created destructible)'s animation speed to 100.00% of its original speed
                      • Set WaterCheck = ((Position of (Random destructible in (Playable map area) matching ((Destructible-type of (Matching destructible)) Equal to Summer Tree Wall))) offset by ((Random real number between -500.00 and 500.00), (Random real number between -500.00 and 500.00)))
                      • Game - Display to (All players) the text: Spawn
                      • Skip remaining actions
                    • Else - Actions
                      • Set WaterCheck = ((Position of (Random destructible in (Playable map area) matching ((Destructible-type of (Matching destructible)) Equal to Summer Tree Wall))) offset by ((Random real number between -500.00 and 500.00), (Random real number between -500.00 and 500.00)))
                      • Set DyingTree = (DyingTree + 1)
                      • Game - Display to (All players) the text: Spawn
            • Else - Actions
              • Do nothing
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • And - All (Conditions) are true
                • Conditions
                  • (Destructible-type of (Picked destructible)) Equal to Summer Tree Wall (Ancient)
                  • (Current life of (Picked destructible)) Equal to 0.00
            • Then - Actions
              • Destructible - Remove (Picked destructible)
              • For each (Integer DyingTree) from 0 to DyingTree, do (Actions)
                • Loop - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • And - All (Conditions) are true
                        • Conditions
                          • (Terrain pathing at WaterCheck of type Walkability is off) Equal to False
                          • (Terrain pathing at WaterCheck of type Buildability is off) Equal to False
                    • Then - Actions
                      • Set TreeSpawnPoint = (Random destructible in (Playable map area) matching ((Destructible-type of (Matching destructible)) Equal to Summer Tree Wall (Old)))
                      • Set TreeSpawnPoint_Copy = (Position of TreeSpawnPoint)
                      • Destructible - Remove TreeSpawnPoint
                      • Destructible - Create a Summer Tree Wall (Ancient) at TreeSpawnPoint_Copy facing (Random angle) with scale (Random real number between 1.80 and 2.20) and variation (Random integer number between 0 and 9)
                      • Set TreeSpawnPoint = (Random destructible in (Playable map area) matching ((Destructible-type of (Matching destructible)) Equal to Summer Tree Wall))
                      • Set TreeSpawnPoint_Copy = (Position of TreeSpawnPoint)
                      • Destructible - Remove TreeSpawnPoint
                      • Destructible - Create a Summer Tree Wall (Old) at TreeSpawnPoint_Copy facing (Random angle) with scale (Random real number between 1.40 and 1.60) and variation (Random integer number between 0 and 9)
                      • Set TreeSpawnPoint = (Random destructible in (Playable map area) matching ((Destructible-type of (Matching destructible)) Equal to Summer Tree Wall (sprout)))
                      • Set TreeSpawnPoint_Copy = (Position of TreeSpawnPoint)
                      • Destructible - Remove TreeSpawnPoint
                      • Destructible - Create a Summer Tree Wall at TreeSpawnPoint_Copy facing (Random angle) with scale (Random real number between 0.80 and 1.20) and variation (Random integer number between 0 and 9)
                      • Destructible - Create a Summer Tree Wall (sprout) at WaterCheck facing (Random angle) with scale (Random real number between 0.10 and 0.50) and variation (Random integer number between 0 and 9)
                      • Animation - Play (Last created destructible)'s birth animation
                      • Animation - Change (Last created destructible)'s animation speed to 100.00% of its original speed
                      • Set WaterCheck = ((Position of (Random destructible in (Playable map area) matching ((Destructible-type of (Matching destructible)) Equal to Summer Tree Wall))) offset by ((Random real number between -500.00 and 500.00), (Random real number between -500.00 and 500.00)))
                      • Game - Display to (All players) the text: Spawn
                      • Skip remaining actions
                    • Else - Actions
                      • Set WaterCheck = ((Position of (Random destructible in (Playable map area) matching ((Destructible-type of (Matching destructible)) Equal to Summer Tree Wall))) offset by ((Random real number between -500.00 and 500.00), (Random real number between -500.00 and 500.00)))
                      • Set DyingTree = (DyingTree + 1)
                      • Game - Display to (All players) the text: Spawn
            • Else - Actions
              • Do nothing
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • And - All (Conditions) are true
                • Conditions
                  • (Destructible-type of (Picked destructible)) Equal to Summer Tree Wall (Dead)
                  • (Current life of (Picked destructible)) Equal to 0.00
            • Then - Actions
              • Destructible - Remove (Picked destructible)
              • For each (Integer DyingTree) from 0 to DyingTree, do (Actions)
                • Loop - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • And - All (Conditions) are true
                        • Conditions
                          • (Terrain pathing at WaterCheck of type Walkability is off) Equal to False
                          • (Terrain pathing at WaterCheck of type Buildability is off) Equal to False
                    • Then - Actions
                      • Set TreeSpawnPoint = (Random destructible in (Playable map area) matching ((Destructible-type of (Matching destructible)) Equal to Summer Tree Wall (Ancient)))
                      • Set TreeSpawnPoint_Copy = (Position of TreeSpawnPoint)
                      • Destructible - Remove TreeSpawnPoint
                      • Destructible - Create a Summer Tree Wall (Dead) at TreeSpawnPoint_Copy facing (Random angle) with scale (Random real number between 1.80 and 2.20) and variation (Random integer number between 0 and 9)
                      • Set TreeSpawnPoint = (Random destructible in (Playable map area) matching ((Destructible-type of (Matching destructible)) Equal to Summer Tree Wall (Old)))
                      • Set TreeSpawnPoint_Copy = (Position of TreeSpawnPoint)
                      • Destructible - Remove TreeSpawnPoint
                      • Destructible - Create a Summer Tree Wall (Ancient) at TreeSpawnPoint_Copy facing (Random angle) with scale (Random real number between 1.80 and 2.20) and variation (Random integer number between 0 and 9)
                      • Set TreeSpawnPoint = (Random destructible in (Playable map area) matching ((Destructible-type of (Matching destructible)) Equal to Summer Tree Wall))
                      • Set TreeSpawnPoint_Copy = (Position of TreeSpawnPoint)
                      • Destructible - Remove TreeSpawnPoint
                      • Destructible - Create a Summer Tree Wall (Old) at TreeSpawnPoint_Copy facing (Random angle) with scale (Random real number between 1.40 and 1.60) and variation (Random integer number between 0 and 9)
                      • Set TreeSpawnPoint = (Random destructible in (Playable map area) matching ((Destructible-type of (Matching destructible)) Equal to Summer Tree Wall (sprout)))
                      • Set TreeSpawnPoint_Copy = (Position of TreeSpawnPoint)
                      • Destructible - Remove TreeSpawnPoint
                      • Destructible - Create a Summer Tree Wall at TreeSpawnPoint_Copy facing (Random angle) with scale (Random real number between 0.80 and 1.20) and variation (Random integer number between 0 and 9)
                      • Destructible - Create a Summer Tree Wall (sprout) at WaterCheck facing (Random angle) with scale (Random real number between 0.10 and 0.50) and variation (Random integer number between 0 and 9)
                      • Animation - Play (Last created destructible)'s birth animation
                      • Animation - Change (Last created destructible)'s animation speed to 100.00% of its original speed
                      • Set WaterCheck = ((Position of (Random destructible in (Playable map area) matching ((Destructible-type of (Matching destructible)) Equal to Summer Tree Wall))) offset by ((Random real number between -500.00 and 500.00), (Random real number between -500.00 and 500.00)))
                      • Game - Display to (All players) the text: Spawn
                      • Skip remaining actions
                    • Else - Actions
                      • Set WaterCheck = ((Position of (Random destructible in (Playable map area) matching ((Destructible-type of (Matching destructible)) Equal to Summer Tree Wall))) offset by ((Random real number between -500.00 and 500.00), (Random real number between -500.00 and 500.00)))
                      • Set DyingTree = (DyingTree + 1)
                      • Game - Display to (All players) the text: Spawn
            • Else - Actions
              • Do nothing
BTW. I wasnt sure if this belonged to ideas or editor help, so I am sorry if I posted it the wrong place
 

Attachments

  • DynamicTrees.w3x
    47.1 KB · Views: 42
Last edited:
Level 6
Joined
Aug 28, 2015
Messages
213
Cool idea was tinkering with things like this myself at some time...
Could you also post the triggers here that would be great dor everyone who is not able to run the editor(suprisingly lot of Hive members)
Ps: for my animal spawning system I used dummy units for each type and used their health as spawn amount I think that was pretty neat system maybe you like to adopt it.
 
Level 20
Joined
Feb 23, 2014
Messages
1,264
It's a cool idea, but...

1) It might just be me, but seeing a tree randomly die only to later have another one "rise" in its place seems kinda weird.

2) Besides, that's not really what real life trees do. I mean, yes, eventually trees die, but it takes a lot of time and the new trees don't really start growing when the old one falls - they start growing long before that, though sometimes their growth is inhibited by the old tree obstructing light/space.

3) I think this could work as a fun experiment, but as a gameplay system - not really. Like... how will you handle building space? I mean, what if someone was clearing out a chunk of land to build somewhere there and then suddenly gets a bunch of trees respawned in the middle of the cleared area? What if respawning trees trap units behind them? Sure, that's not game breaking in any way and probably could be accounted for by clever triggering, at least to some extent, but still there's a fair amount of space for frustration here.

If I were to suggest something - I think a better system would work by not killing trees at all, but SLOWLY respawning trees that were cut provided that there is another tree nearby (to "provide the sapling"). That way, if you left the forest alone for a bit, it would slowly regrow, creeping layer by layer to where it once was, but without feeling so random and with possibly lower risk of causing frustration.
 
Level 5
Joined
May 21, 2006
Messages
22
It's a cool idea, but...

1) It might just be me, but seeing a tree randomly die only to later have another one "rise" in its place seems kinda weird.

2) Besides, that's not really what real life trees do. I mean, yes, eventually trees die, but it takes a lot of time and the new trees don't really start growing when the old one falls - they start growing long before that, though sometimes their growth is inhibited by the old tree obstructing light/space.

3) I think this could work as a fun experiment, but as a gameplay system - not really. Like... how will you handle building space? I mean, what if someone was clearing out a chunk of land to build somewhere there and then suddenly gets a bunch of trees respawned in the middle of the cleared area? What if respawning trees trap units behind them? Sure, that's not game breaking in any way and probably could be accounted for by clever triggering, at least to some extent, but still there's a fair amount of space for frustration here.

If I were to suggest something - I think a better system would work by not killing trees at all, but SLOWLY respawning trees that were cut provided that there is another tree nearby (to "provide the sapling"). That way, if you left the forest alone for a bit, it would slowly regrow, creeping layer by layer to where it once was, but without feeling so random and with possibly lower risk of causing frustration.

1) The way it works right now, is that it removes a tree and replaces it with a bigger/"older" one. I think the reason it might look wierd is because I have it play the birth animation. I kinda wont to figure out a way to start the animation at the middle so it actually looks like the tree is growing larger, but i am not sure how to do that. Maybe I can make it grow in scale before being removed?

2) yeah, right now it depends on a periodic timer that triggers every 2 second, this can be adjusted to whatever one likes, except at the moment I find that there is more lag if there are more dead trees to be replaced, which is kinda unfortunate

3) I am planning on making a quite large map (Something about the dawn of civilization starting in the stonage.. I think), so hopefully it wont be too much of an issue in that case. I see what you mean though

I really like the idea of spawning them close to other grown trees, that is definetly something I will experiment more with, so that certain areas will naturally grow into large forests. That could be really cool
 
Level 5
Joined
May 21, 2006
Messages
22
Cool idea was tinkering with things like this myself at some time...
Could you also post the triggers here that would be great dor everyone who is not able to run the editor(suprisingly lot of Hive members)
Ps: for my animal spawning system I used dummy units for each type and used their health as spawn amount I think that was pretty neat system maybe you like to adopt it.

Sure I just need to figure out how to post the triggers, I havnt used these forums all that much :p
 
Level 6
Joined
Aug 28, 2015
Messages
213
That looks not bad I see there are few things i would take on a bit differently.
First of, as much as I know the pick every destructible in... function stops after a 'short' amount and will most likely not pick every destructible on the map.
Thats why I would make a region and move the region over the map picking every tree inside on each iteration qnd save it to an array(I personally like to work with arrays but you could also use hashtabelles)
Then you can easily loop over the array once and don't have to bother to compare to your different tree types each loop because you did it at start already and all new spawned trees can be easily added at the spawn.
Next do nothing does exactly what it says except it runs a function call just get rid of it.
Your variable naming is a bit off your TreeSpawnPoint is a destructable, TreeSpawnPoint_copy is actually the point but why copy?, And WaterCheck sounds for me more like a function name.
The rest is most likely just something from inexperience that you have a lot of code copied and pasted but this will be already fixed if you go with the array or hashtabelle, thats how I started and I am pretty sure many others aswell nothing wrong with it but you make it easier for everyone handeling with your code to try to avoid CnP because most likely its you who has to handle with it^^.
And then we get beside the code, more to the system itself.
atm. I see a overly complicated tree respawn system but you mentioned something different in your post so what do you want to do?
What should be the system you want to do?
Edit:
This is a long post sorry
 
Status
Not open for further replies.
Top