• 🏆 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 repsawn trees

Status
Not open for further replies.
This library works well:
http://www.thehelper.net/forums/showthread.php?t=104390

Just make sure you have JassNewGenPack. Create a new trigger, Edit -> Convert to Custom Text, and then copy and paste it in. Then change this:
JASS:
private constant real RegrowAfter = 23.0
To this:
JASS:
private constant real RegrowAfter = 10.0

And it should work. :)
 
Level 4
Joined
Aug 19, 2009
Messages
81
Erhmm... aren't you guys complicating things...?
When i tested this it worked perfectly.
[trigger=Tree Respawn]Tree Respawn
Events
Destructible - A destructible within (Entire map) dies
Conditions
(Destructible-type of (Dying destructible)) Equal to Summer Tree Wall
Actions
Wait 10.00 seconds
Destructible - Resurrect (Dying destructible) with (Max life of (Dying destructible)) life and Show birth animation[/trigger]

When i tested this it worked perfectly even though multiple trees died within the 10 sec.
 
Destroy a gate in a map with that trigger and then watch. :p

You can probably do it in GUI too. Idk. But the reason why the JASS is a bit longer is because it checks if the destructible is a tree or not. :D

But it is kind of situational. If you don't really care that other destructibles will respawn, then yeah you can definitely use that trigger. Otherwise, you can compare destructible ID's or just make the naga slave and see if he can harvest it. (like the code I linked does)
 
Level 19
Joined
Feb 4, 2009
Messages
1,313
Erhmm... aren't you guys complicating things...?
When i tested this it worked perfectly.
  • Tree Respawn
    • Events
      • Destructible - A destructible within (Entire map) dies
    • Conditions
      • (Destructible-type of (Dying destructible)) Equal to Summer Tree Wall
    • Actions
      • Wait 10.00 seconds
      • Destructible - Resurrect (Dying destructible) with (Max life of (Dying destructible)) life and Show birth animation
When i tested this it worked perfectly even though multiple trees died within the 10 sec.

"a destructible within entire map dies" only refers to a few destructibles (like 64) but not all
probably blizzard thought it would be bad to create that many single events

you can circumvent that by creating regions with a maxs of 64 trees and so on in it or by something like:
trigger 1:
event - map ini
actions -
- create a peasant or something with harvest ability
- pick all destructibles in playable map area
- - order last created unit to harvest picked destructible//what purge mentioned already
- - if current order of last created unit is equal to harvest
- - - add to trigger 2 the event picked destructible dies
- remove peasant or hide and stop him to use him later or whatever

trigger 2:
events - are added by trigger 1
actions -
- wait some game time
- revive tree
 
^ destructible groups don't leak afaik so no need to use
JASS:
set bj_wantDestroyGroup = true

they don't even use that bj right?

JASS:
function EnumDestructablesInCircleBJ takes real radius, location loc, code actionFunc returns nothing
    local rect r

    if (radius >= 0) then
        set bj_enumDestructableCenter = loc
        set bj_enumDestructableRadius = radius
        set r = GetRectFromCircleBJ(loc, radius)
        call EnumDestructablesInRect(r, filterEnumDestructablesInCircleBJ, actionFunc)
        call RemoveRect(r)
    endif
endfunction
 
Level 6
Joined
May 26, 2010
Messages
212
alright one more thing... i know this is stupid... but how do i make a spell kill the trees it goes through. Like if i make a custom spell of breath of fire or Carrion Swarm how do i make it to where the trees the spells animation passes through die.
 
Level 33
Joined
Mar 27, 2008
Messages
8,035
You're gonna need a formula for that, a cone-shaped formula for that
Say, the Breath of Fire spell, the shape itself is a cone
So, the formula should be Pi * Radius * Side (for Area Formula) (not particularly sure about this formula)
After doing this formula, pick every trees in that particular area, and kills it
 
Level 8
Joined
Oct 31, 2010
Messages
238
You're gonna need a formula for that, a cone-shaped formula for that
Say, the Breath of Fire spell, the shape itself is a cone
So, the formula should be Pi * Radius * Side (for Area Formula) (not particularly sure about this formula)
After doing this formula, pick every trees in that particular area, and kills it

The cone is in a circle where area of circle is pi*r*r

So you will need the angle of cone.. x

x/360 * pi*r*r
 
Level 6
Joined
May 26, 2010
Messages
212
Alright i went to and copied your trigger and edited it to where it should'v worked when the person cast a spell any tips. Heres the trigger i used
  • Mods of Thunder Clap
    • Events
      • Unit - A unit Finishes casting an ability
    • Conditions
      • (Ability being cast) Equal to Dark Nova
      • (Ability being cast) Equal to Ground Spikes
      • (Ability being cast) Equal to Possess Corpse
    • Actions
      • Custom script: set bj_wantDestroyGroup = true
      • Destructible - Pick every destructible within 500.00 of (Position of (Casting unit)) and do (Actions)
        • Loop - Actions
          • Destructible - Kill (Picked destructible)
it didnt work when i used it though
 
It should be this:
  • Mods of Thunder Clap
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • Or - Any (Conditions) are true
        • Conditions
          • (Ability being cast) Equal to Dark Nova
          • (Ability being cast) Equal to Ground Spikes
          • (Ability being cast) Equal to Possess Corpse
    • Actions
      • Set tempPoint = (Position of (Triggering unit))
      • Destructible - Pick every destructible within 500.00 of tempPoint and do (Actions)
        • Loop - Actions
          • Destructible - Kill (Picked destructible)
      • Custom script: call RemoveLocation(udg_tempPoint)
The difference is this:
  • Conditions
    • (Ability being cast) Equal to Dark Nova
    • (Ability being cast) Equal to Ground Spikes
    • (Ability being cast) Equal to Possess Corpse
When you have conditions set up like this above, it will consider it as "and". Basically, ALL conditions must be met for the trigger to run.
  • Conditions
    • Or - Any (Conditions) are true
      • Conditions
        • (Ability being cast) Equal to Dark Nova
        • (Ability being cast) Equal to Ground Spikes
        • (Ability being cast) Equal to Possess Corpse
In this case, it is "or" so any of the conditions will allow the trigger to run. :)

The other parts are just to fix the leak, and the removal of the other custom script you used. Enumeration of destructibles doesn't leak, there is no object that is returned for a destructible group like there is for a unit group.

There is a leak that occurs from a variable not being nulled, but oh well, nothing you can do for that, at least not in GUI. ;P
 
Level 6
Joined
May 26, 2010
Messages
212
Alright i got it but one more thing, I know this is totally off topic for this post but, when i was testing the destroy trees thing (which worked) my guy was killed by npcs and when he died EVERYBODY else on the map died! I'm useing a trigger for npc respawn so anyone think you could help me. Heres the trigger(s)
  • Init Respawn
    • Events
      • Time - Elapsed game time is 0.00 seconds
    • Conditions
    • Actions
      • Hashtable - Create a hashtable
      • Set rhash = (Last created hashtable)
      • Set Rtime = 5.00
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units owned by Neutral Hostile) and do (Actions)
        • Loop - Actions
          • Custom script: call SaveReal( udg_rhash , GetHandleId(GetEnumUnit()) , StringHash("x") , GetUnitX(GetEnumUnit()) )
          • Custom script: call SaveReal( udg_rhash , GetHandleId(GetEnumUnit()) , StringHash("y") , GetUnitY(GetEnumUnit()) )
  • Respawn
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Owner of (Triggering unit)) Equal to Neutral Hostile
    • Actions
      • Wait Rtime seconds
      • Custom script: set udg_r1 = LoadReal( udg_rhash , GetHandleId(GetTriggerUnit()) , StringHash("x") )
      • Custom script: set udg_r2 = LoadReal( udg_rhash , GetHandleId(GetTriggerUnit()) , StringHash("y") )
      • Custom script: set bj_lastCreatedUnit = CreateUnit( GetOwningPlayer(GetTriggerUnit()) , GetUnitTypeId(GetTriggerUnit()) , udg_r1 , udg_r2 , GetRandomReal(0 , 359) )
      • Custom script: call SaveReal( udg_rhash , GetHandleId(bj_lastCreatedUnit) , StringHash("x") , udg_r1 )
      • Custom script: call SaveReal( udg_rhash , GetHandleId(bj_lastCreatedUnit) , StringHash("y") , udg_r2 )
      • Custom script: call FlushChildHashtable( udg_rhash , GetHandleId(GetTriggerUnit()))
      • Unit - Remove (Triggering unit) from the game
:goblin_boom::goblin_boom::goblin_boom::goblin_boom::goblin_boom: :goblin_boom::goblin_boom::goblin_boom::goblin_boom::goblin_boom:
 
Level 6
Joined
May 26, 2010
Messages
212
nvm i found it out but now i have ANOTHER problem D:
im trying to get it to where at a certain time certain units transform into different units.
  • Evo 1
    • Events
      • Time - Elapsed game time is 5.00 seconds
    • Conditions
    • Actions
      • Unit - Create 1 Human Deliverer for Neutral Hostile at (Center of Deliverer Creation <gen>) facing 180.00 degrees
      • Hero - Create War Plans and give it to (Last created unit)
      • Unit - Order (Last created unit) to Patrol To (Center of Deliverer Delivery <gen>)
  • Evo 1 part 2
    • Events
      • Unit - A unit enters Deliverer Delivery <gen>
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to Human Deliverer
    • Actions
      • Unit Group - Pick every unit in (Units owned by Neutral Hostile matching ((Unit-type of (Matching unit)) Equal to Human Soldier)) and do (Unit - Kill (Picked unit))
      • Unit - Remove (Triggering unit) from the game
      • Unit - Create 1 Super Soldier for Neutral Hostile at (Position of (Dying unit)) facing Default building facing degrees
 

Dr Super Good

Spell Reviewer
Level 63
Joined
Jan 18, 2005
Messages
27,178
In worst case senarios, this results in a WC3 fatal error.
No ingame spell will ever be able to fix that...

I do not mean surrounded by trees, I mean impaled by a tree. The WC3 displacement algerthim is not 100% stable (or atleast was not in the past) so I have seen many fatal errors attributed to trees respawning under a unit (impaling the unit with a tree).
 
Status
Not open for further replies.
Top