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

grow tree

Status
Not open for further replies.
uhm... i wanna all trees u harvested regrow (i dotn like depleting resourses)
  • Regrow Trees
    • Events
      • Destructible - A destructible within (Playable map area) dies
    • Conditions
    • Actions
      • Wait (Random real number between 8.00 and 40.00) seconds
      • Destructible - Resurrect (Dying destructible) with (Max life of (Dying destructible)) life and Show birth animation
this is the trigger i made... but nothing happens o_O
PS: since my map only got trees as destructible, i assume this trigger only targets my ... trees XD
 
Level 6
Joined
Jun 14, 2008
Messages
176
If you don't want trees to ever die, just go to "destructables/doodads"(I forgot where trees were, edit the hitpoints of the tree you want to not die to 9999999 health.

Of course, that means trees won't ever go down unless something with high damage attacks it but if you want infinite resources, you can do that.
 
Level 13
Joined
Nov 4, 2006
Messages
1,239
if you want something less complicated, this should work too. (i'm not sure if it also only works for the first 64 trees but i don't think so)

  • Events
    • Destructible - a destructible dies
  • Conditions
  • Actions
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • 'IF'-Conditions
        • Or - Any (Conditions) are true
          • Conditions
            • (dying destructable) destrutible- type equal to lordearon summer tree
              • (add all of your treetypes here)
      • 'THEN'-Actions
        • wait (random number between 8 and 40) sec
        • Revive dying destructable with max life showing birth animation
      • 'ELSE'-Actions
 
Level 9
Joined
Jan 23, 2008
Messages
384
  • Regrow Trees
    • Events
      • Destructible - a destructible dies
    • Conditions
      • (dying destructible) type equal to lordaeron summer tree
    • Actions
      • Set Dying point = (location of dying unit)
      • Wait 10 seconds
      • Destructible - create 1 lordaeron summer tree at position of Dying point
I am pretty sure i have over 100000000 mistakes but this is the idea of how you should do it ...

Or the simplest way to do it is to go in the Object editor and make a dummy revive spell with cooldown 0 seconds,add it to the summer tree and whenever a tree dyes it will revive within few seconds
 
Level 5
Joined
Nov 14, 2007
Messages
161
  • Regrow Trees
    • Events
      • Destructible - a destructible dies
    • Conditions
      • (dying destructible) type equal to lordaeron summer tree
    • Actions
      • Set Dying point = (location of dying unit)
      • Wait 10 seconds
      • Destructible - create 1 lordaeron summer tree at position of Dying point
I am pretty sure i have over 100000000 mistakes but this is the idea of how you should do it ...
...

with that method, if 2 trees die within 10 seconds, the first will never grow back. JASS would fix that with locals.





honestly though i dont see what's harder than to copy/paste a beautiful code into the "custom script" section at the top of the triggers. (when u open triggers, click on the map name 1 time and it's the lower box)

JASS:
constant function TreeRegrowTime takes nothing returns real
    return 10.00 //the amount of time you want before the tree respawns
endfunction

//To add more trees press CTRl+D while looking at the Object Editor
//then follow the same format and add your tree's RAWCODE inside single quotes (Example ' ' )

function IsDesTree takes destructable a returns boolean
    local integer d=GetDestructableTypeId(a)
    if d =='ATtr' then
      return true
    elseif d=='BTtw' then
      return true
    elseif d=='KTtw' then
      return true
    elseif d=='YTft' then
      return true
    elseif d=='JTct' then
      return true
    elseif d=='YTst' then
      return true
    elseif d=='YTct' then
      return true
    elseif d=='YTwt' then
      return true
    elseif d=='JTwt' then
      return true
    elseif d=='DTsh' then
      return true
    elseif d=='FTtw' then
      return true
    elseif d=='CTtr' then
      return true
    elseif d=='ITtw' then
      return true
    elseif d=='NTtw' then
      return true
    elseif d=='OTtw' then
      return true
    elseif d=='ZTtw' then
      return true
    elseif d=='WTst' then
      return true
    elseif d=='LTlt' then
      return true
    elseif d=='GTsh' then
      return true
    elseif d=='Xtlt' then
      return true
    elseif d=='WTtw' then
      return true
    elseif d=='Attc' then
      return true
    elseif d=='BTtc' then
      return true
    elseif d=='CTtc' then
      return true
    elseif d=='ITtc' then
      return true
    elseif d=='NTtc' then
      return true
    elseif d=='ZTtc' then
      return true
    else 
    return false
endif
endfunction

function RegrowTrees takes nothing returns nothing
    local destructable tree=GetDyingDestructable()
    call TriggerSleepAction(TreeRegrowTime())
    call DestructableRestoreLife( tree, GetDestructableMaxLife(tree), true )
    set tree=null
endfunction

function Trig_Int_Tree_Revival takes nothing returns nothing
    local trigger t
    if IsDesTree(GetEnumDestructable())==true then
    set t=CreateTrigger()
    call TriggerRegisterDeathEvent( t, GetEnumDestructable() )
    call TriggerAddAction(t,function RegrowTrees)
endif
endfunction

function Int_Tree_Revive takes nothing returns nothing
    call EnumDestructablesInRectAll( GetPlayableMapRect(), function Trig_Int_Tree_Revival )
endfunction

attachment.php

and dont forget to add the function call:
attachment.php



the only thing u really can/need to change is the delay which is at the first line and is commented on where and what it does.
 

Attachments

  • pic.jpg
    pic.jpg
    236.9 KB · Views: 338
  • pic2.jpg
    pic2.jpg
    105 KB · Views: 289
Level 8
Joined
Feb 20, 2007
Messages
338
To do it without Jass, you need two triggers.

One Is the set up of the other:

  • Tree Regrowth
    • Events
    • Conditions
    • Actions
      • Wait 65.00 seconds
      • Destructible - Resurrect (Dying destructible) with (Max life of (Picked destructible)) life and Show birth animation
Note there is no condition nor event for this trigger. This trigger is called upon in the next trigger:

  • Tree Picker
    • Events
      • Time - Elapsed game time is (0.01 + 1.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 Ashenvale Tree Wall
            • Then - Actions
              • Custom script: set bj_wantDestroyGroup = true
              • Trigger - Add to Tree Regrowth <gen> the event (Destructible - (Picked destructible) dies)
            • Else - Actions
              • Do nothing
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Destructible-type of (Picked destructible)) Equal to Ashenvale Canopy Tree
            • Then - Actions
              • Custom script: set bj_wantDestroyGroup = true
              • Trigger - Add to Tree Regrowth <gen> the event (Destructible - (Picked destructible) dies)
            • Else - Actions
              • Do nothing
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Destructible-type of (Picked destructible)) Equal to Dark Forest Giant Tree wall
            • Then - Actions
              • Custom script: set bj_wantDestroyGroup = true
              • Trigger - Add to Tree Regrowth <gen> the event (Destructible - (Picked destructible) dies)
            • Else - Actions
              • Do nothing
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Destructible-type of (Picked destructible)) Equal to Dark Forest Giant Tree
            • Then - Actions
              • Custom script: set bj_wantDestroyGroup = true
              • Trigger - Add to Tree Regrowth <gen> the event (Destructible - (Picked destructible) dies)
            • Else - Actions
              • Do nothing
The initial event is lapsed time - it needs to be elapsed time, it will not work on Map initialization - sorry I don't know why.

When destructible dies is an added event, added to the first trigger. thus when a tree dies of specific type (yes you have to make this for each type you use, this prevents the regrowth of other destructible like crates, barrels, gates) it 'regrows'.

Custom script is used to remove leak points. In the CD version of WE there are no trigger functions that remove points. I think that WE ultimate does but few people actually use them.
 
Level 5
Joined
Nov 14, 2007
Messages
161
what happens when you kill more than 1 tree with that GUI method?

the answer is only the last tree in the 65 seconds will grow back. kill a tree and it's saved as the "dying destructable" and the trigger starts, if you kill another tree, it re-executes that trigger and the first tree will never grow back because there it's a different "dying destructable". You can change that by creating locals (basically makes each dying tree into it's own instance) in the first trigger.


sorry dont have WE handy but should be something like:
  • Actions
  • Custom script: local destructable tree=GetDyingDestructable()
  • Wait 65.00 seconds
  • Destructible - Resurrect (tree) with (Max life of (tree)) life and Show birth animation
in order to get "tree" in there, make the global variable "tree" like you would. JASS takes locals before globals so it will work.


notice some similaritys from Hero's code?
JASS:
function RegrowTrees takes nothing returns nothing
    local destructable tree=GetDyingDestructable()
    call TriggerSleepAction(TreeRegrowTime())
    call DestructableRestoreLife( tree, GetDestructableMaxLife(tree), true )
    set tree=null
endfunction
 
Status
Not open for further replies.
Top