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

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.
 
Level 21
Joined
Mar 29, 2020
Messages
1,237
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:
Level 24
Joined
Jun 26, 2020
Messages
1,850
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?
 
Level 21
Joined
Mar 29, 2020
Messages
1,237
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.
 
Level 24
Joined
Jun 26, 2020
Messages
1,850
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.)
 
Level 3
Joined
Oct 20, 2017
Messages
52
I wanted the event to be activated on a one button option when the player clicks on it.
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,510
@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

  • Resurrect Trees.w3m
    18 KB · Views: 26
Level 3
Joined
Oct 20, 2017
Messages
52
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 --------
 
Level 3
Joined
Oct 20, 2017
Messages
52
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
 
Level 3
Joined
Oct 20, 2017
Messages
52
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?
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,510
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].
 
Level 21
Joined
Mar 29, 2020
Messages
1,237
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.
Top