How to respawn the tree after a trigger action?

Status
Not open for further replies.
Level 3
Joined
Oct 20, 2017
Messages
52
Hello, I'm having difficulties creating a trigger with a certain action to respawn the trees, but I don't want them to grow back after being destroyed, but after a trigger action.
Example: The player took an item and when using it activates a trigger that respawn all the destroyed trees or when the player presses a button and selects such an option and it respawn the destroyed trees.
 
I think this should do it:

  • tree setup
    • Events
      • Map initialization
    • Conditions
    • Actions
      • 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
              • (Destructible-type of (Picked destructible)) Equal to Summer Tree Wall
            • Then - Actions
              • Trigger - Add to tree death <gen> the event (Destructible - (Picked destructible) dies)
            • Else - Actions
  • tree death
    • Events
    • Conditions
    • Actions
      • Set Point = (Position of (Dying destructible))
      • Unit - Create 1 Tree Dummy for Player 1 (Red) at Point facing Default building facing degrees
      • Custom script: call RemoveLocation(udg_Point)
  • tree ability
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Will of the Lorax
    • Actions
      • Custom script: set bj_wantDestroyGroup = true
      • Set UnitGroup = (Units of type Tree Dummy)
      • Unit Group - Pick every unit in UnitGroup and do (Actions)
        • Loop - Actions
          • Set Point = (Position of (Picked unit))
          • Unit - Remove (Picked unit) from the game
          • Destructible - Create a Summer Tree Wall at Point facing (Random angle) with scale 1.00 and variation 0
          • Animation - Play (Last created destructible)'s birth animation
          • Custom script: call RemoveLocation(udg_Point)
In the first trigger make sure you set the right tree type for your map. Make sure that the dummy unit type you use is only used for this purpose (and is invul, locust, invisible etc').

I didn't test it but I think it should work.
 
Last edited:
I think this should do it:

  • tree setup
    • Events
      • Map initialization
    • Conditions
    • Actions
      • 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
              • (Destructible-type of (Picked destructible)) Equal to Summer Tree Wall
            • Then - Actions
              • Trigger - Add to tree death <gen> the event (Destructible - (Picked destructible) dies)
            • Else - Actions
  • tree death
    • Events
    • Conditions
    • Actions
      • Set Point = (Position of (Dying destructible))
      • Unit - Create 1 Tree Dummy for Player 1 (Red) at Point facing Default building facing degrees
      • Custom script: call RemoveLocation(udg_Point)
  • tree ability
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Will of the Lorax
    • Actions
      • Custom script: set bj_wantDestroyGroup = true
      • Set UnitGroup = (Units of type Tree Dummy)
      • Unit Group - Pick every unit in UnitGroup and do (Actions)
        • Loop - Actions
          • Set Point = (Position of (Picked unit))
          • Unit - Remove (Picked unit) from the game
          • Destructible - Create a Summer Tree Wall at Point facing (Random angle) with scale 1.00 and variation 0
          • Animation - Play (Last created destructible)'s birth animation
          • Custom script: call RemoveLocation(udg_Point)
In the first trigger make sure you set the right tree type for your map. Make sure that the dummy unit type you use is only used for this purpose (and is invul, locust, invisible, locust etc').

I didn't test it but I think it should work.


Wouldn't it be better if you just revived the tree showing its animation?, by the way, how do you post like the World Editor GUI?
 
that doesn't answer the question. the action "select every destructible in region" only works for the first 48 (some number stated in the editor) destructibles selected. therefore I am not sure where you want to stick said boolean to make it achieve the desired affect. that is why I used this workaround. If you know a better way to do it please post the entire trigger.
 
I didn't know that there was a destructible selection limit, is that when I made my map I put an action like
  • My Trigger
  • Events
  • Conditions
  • Actions
  • Destructible - Pick every destructible in (Entire Map) do (If ((Destructible-Type) of (Picked destructible) equal to Tree) Resurrect (Picked Destructible))
And it resurrected every destructible in the map (Or is it because there were less than 48 who were dead.)
 
I wanted the event to be activated on a one button option when the player clicks on it.
 
@Ender Wiggins
You can store the Trees in an Array and then loop through them whenever. No need for the Dummy units.
  • Save Trees
    • Events
      • Time - Elapsed game time is 0.00 seconds
    • Conditions
    • Actions
      • 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
              • (Destructible-type of (Picked destructible)) Equal to Summer Tree Wall
            • Then - Actions
              • Set VariableSet Tree_Count = (Tree_Count + 1)
              • Set VariableSet Tree[Tree_Count] = (Picked destructible)
            • Else - Actions
  • Revive Trees
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Resurrect Trees
    • Actions
      • For each (Integer Tree_Loop) from 1 to Tree_Count, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Tree[Tree_Loop] is dead) Equal to True
            • Then - Actions
              • Destructible - Resurrect Tree[Tree_Loop] with 50.00 life and Show birth animation
            • Else - Actions
Tree = Destructible (Array)
Tree_Loop = Integer
Tree_Count = Integer
 

Attachments

It is in this format e.e
  • Dialog
    • Events
      • Dialog - A dialog button is clicked for Dialog
    • Conditions
      • (Clicked dialog button) Equal to Dialog_Button[1]
    • Actions
      • -------- Actions --------
 
I implemented your trigger and tested it on my map, but it didn't work when I activate the Dialog event when I press the button. ;-;
I left it that way, is it wrong?
  • SavesTree
    • Events
      • Time - Elapsed game time is 0.00 seconds
    • Conditions
    • Actions
      • 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
              • (Destructible-type of (Picked destructible)) Equal to Cityscape Summer Tree Wall
            • Then - Actions
            • Else - Actions
              • Set Tree_Count = (Tree_Count + 1)
              • Set Tree[Tree_Count] = (Picked destructible)
---
  • ReviveTrees
    • Events
      • Dialog - A dialog button is clicked for Dialog
    • Conditions
      • (Clicked dialog button) Equal to Dialog_Button[1]
    • Actions
      • For each (Integer Tree_Loop) from 1 to Tree_Count, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Tree[Tree_Loop] is dead) Equal to True
            • Then - Actions
              • Destructible - Resurrect Tree[Tree_Loop] with 50.00 life and Show birth animation
            • Else - Actions
 
Now it worked, but a doubt. Is it necessary to reset the Tree_Counts variable to 0? Because he will be saving the dead trees without returning, can it be a problem?
 
I'm not 100% certain what you're asking but it should work just fine the way it is. You shouldn't have to reset anything.

And if you create any new trees and want to save them as well, simply increase Tree_Count by 1 and set the newly created Tree as Tree[Tree_Count].
 
The desructable limit is for "A destructable dies" event, not for "Pick All Destructables". Also, it's 64.
my bad..

being so, why not just do what @HerlySQR said and do this:

  • Tree trigger
    • Events
      • Dialog - A dialog button is clicked for Dialog
    • Conditions
      • (Clicked dialog button) Equal to Dialog_Button[1]
    • Actions
      • 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
              • (Destructible-type of (Picked destructible)) Equal to Summer Tree Wall
              • ((Picked destructible) is dead) Equal to True
            • Then - Actions
              • Destructible - Resurrect (Picked destructible) with (Max life of (Picked destructible)) life and Show birth animation
            • Else - Actions
what advantage does your more complex solution have, @Uncle ?
 
Status
Not open for further replies.
Back
Top