• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[JASS] Tree regrowth

Status
Not open for further replies.
Level 2
Joined
Nov 19, 2006
Messages
11
Yeah, I dont know how to JASS and I already tried this in GUI so can anyone help me out here? I just want the playable map area to regrow its trees upon x seconds after death :\
 
Level 5
Joined
May 22, 2006
Messages
150
Ah, no. The GUI-function stopps on 64 destructibles...
A map may have around 4000 trees. ^^

Okay, try this:

- create a new trigger and name it "Baeume"
- convert the raw trigger into custom text
- delete everything inside the text window
- copy this into it:

JASS:
function Trig_Baeume_Baumfilter takes nothing returns boolean
  return GetDestructableTypeId(GetFilterDestructable()) == 'LTlt' or GetDestructableTypeId(GetFilterDestructable()) == 'VTlt'
endfunction

function Trig_Baeume_Subactions takes nothing returns nothing
  call TriggerRegisterDeathEvent(gg_trg_Baeume,GetEnumDestructable())
endfunction

function Trig_Baeume_Actions takes nothing returns nothing
  local destructable tempDestructable = GetDyingDestructable()
  call TriggerSleepAction(GetRandomReal(60,300))
  call DestructableRestoreLife(tempDestructable,100,true)
  set tempDestructable = null
endfunction

function InitTrig_Baeume takes nothing returns nothing
  set gg_trg_Baeume = CreateTrigger()
  call EnumDestructablesInRect(bj_mapInitialPlayableArea,Filter(function Trig_Baeume_Baumfilter),function Trig_Baeume_Subactions)
  call TriggerAddAction(gg_trg_Baeume,function Trig_Baeume_Actions)
endfunction
- look out via object manager, which kind of trees are placed in the map
- get the type id of these trees by seeking them in the object editor and pressing 'Strg' + 'D'
- edit this line:
JASS:
return GetDestructableTypeId(GetFilterDestructable()) == 'LTlt' or GetDestructableTypeId(GetFilterDestructable()) == 'VTlt'
There, remove the ids, which you do not need and add these you do. If there are more than two ones, simply copy this part and add it at the lines end with an "or" before:
JASS:
GetFilterDestructable()) == 'LTlt'

If you are interested in understanding, how it works, do not hesitate to ask me to replace the german names with english (or french) ones.

Ah, and if the trees respawn too fastly/too slowly, change the numbers in this line:
JASS:
call TriggerSleepAction(GetRandomReal(60,300))
The first number is the lower end of the random value, the second one is the upper one.
Here, a number will be returned, which is bigger or equal 60 and smaller then 300.
It is the time to wait after a tree's death until it will be revived in seconds.
 
Status
Not open for further replies.
Top