Respawn after awhile, ideally, or perhaps after a certain event so I can proc it with a skill or something. I like it when maps have a bunch of trees in them, and it bothers me quite a bit when they're all gone towards the end. Usually I'd fix it by just giving them a lot of health, but you can't do that with the Keeper of the Grove, so.What exactly are you trying to do? Do you want trees to respawn automatically after a while? Or do you want them to respawn after a specific event?
function ModifyGateBJ takes integer gateOperation,destructable d returns nothing
if (gateOperation == bj_GATEOPERATION_CLOSE) then
if (GetDestructableLife(d) <= 0) then
call DestructableRestoreLife(d, GetDestructableMaxLife(d), true)
endif
call SetDestructableAnimation(d, "stand")
elseif (gateOperation == bj_GATEOPERATION_OPEN) then
if (GetDestructableLife(d) > 0) then
call KillDestructable(d)
endif
call SetDestructableAnimation(d, "death alternate")
elseif (gateOperation == bj_GATEOPERATION_DESTROY) then
if (GetDestructableLife(d) > 0) then
call KillDestructable(d)
endif
call SetDestructableAnimation(d, "death")
else
endif
endfunction
I've made trees respawn before in my mapI've tried various things from various forums but I can't find anything that helps me specifically. It's either a single selected tree, or none at all.
Does the map not crash if it respawns on top of a unit? There is a reason people avoid tree respawn systems...done your trees now repawn ^-^
function IsUnitAlive takes unit u returns boolean
return not (GetUnitTypeId(u) == 0 or IsUnitType(u, UNIT_TYPE_DEAD))
endfunction
function TreeRespawn_AreUnitsAround takes real x, real y returns boolean
local unit u=null
call GroupEnumUnitsInRange(udg_ug, x, y, 400.00, null)
loop
set u = FirstOfGroup(udg_ug)
exitwhen u == null
if IsUnitAlive(u) then
set u=null
return true
endif
call GroupRemoveUnit(udg_ug, u)
endloop
return false
endfunction
function Trig_TreeRespawn_Actions takes nothing returns nothing
local destructable tree=GetDyingDestructable()
call TriggerSleepAction(10.00)
loop
exitwhen not TreeRespawn_AreUnitsAround(GetDestructableX(tree), GetDestructableY(tree))
call TriggerSleepAction(2.00)
endloop
call DestructableRestoreLife(tree, GetDestructableMaxLife(tree), true )//ressurect tree
set tree=null
endfunction
//===========================================================================
function InitTrig_TreeRespawn takes nothing returns nothing
set gg_trg_TreeRespawn = CreateTrigger( )
call TriggerAddAction( gg_trg_TreeRespawn, function Trig_TreeRespawn_Actions )
endfunction
you can play my map... it doesn't crashDoes the map not crash if it respawns on top of a unit? There is a reason people avoid tree respawn systems...
So?Waits aside, would that not give a single trigger hundreds of events?
How so?Sounds like a good cause of lag.
So you admit it leaks destructables?the only bother is the fact that you can see the tree stump of the previous tree
No as the event can still fire again if the destructable is revived.ell I imagine it would result in empty pointers when a destructible die?
In such a case one can reconstruct the trigger which will purge all events.or if it is removed from the game.
trees can die
Events
Destructible - A destructible within Region 043 <gen> dies
Destructible - A destructible within Region 044 <gen> dies
Destructible - A destructible within Region 034 <gen> dies
Conditions
Actions
Destructible - Resurrect (Dying destructible) with (Max life of (Dying destructible)) life and Show birth animation
But with this trigger, the reviving is instant, and I think the OP wants the trees to resurrect after a while. And if you use waits, you'll have trouble to resurrect the right tree at the right moment.Here is the solution, and look how lovely and short it is
Code:trees can die Events Destructible - A destructible within Region 043 <gen> dies Destructible - A destructible within Region 044 <gen> dies Destructible - A destructible within Region 034 <gen> dies Conditions Actions Destructible - Resurrect (Dying destructible) with (Max life of (Dying destructible)) life and Show birth animation
Ok let me see.....There are a number of problemsBut with this trigger, the reviving is instant, and I think the OP wants the trees to resurrect after a while. And if you use waits, you'll have trouble to resurrect the right tree at the right moment.
Secondly, the event Destructible - A destructible within Region takes only 64 destructibles into account, therefore you won't be able to resurrect the other ones.
Here is what I tried:
One trigger to add the event:
The action may be run at map initilization or whenever you want it to fire
Initialisation
Events
Map initialization
Conditions
Actions
Destructible - Pick every destructible in (Playable map area) and do (Actions)
Loop - Actions
Trigger - Add to RespawnTrees the event (Destructible - (Picked destructible) dies)
Variable Tree is a destructible array, TreeIndex01 and TreeIndex02 are integers.
RespawnTrees
Events
Conditions
(Destructible-type of (Dying destructible)) Equals Some Tree <Select here which type of tree your map contains>
Actions
Set TreeIndex01 = (TreeIndex01 + 1)
Set Tree[TreeIndex01] = (Dying destructible)
Wait 10.00 seconds
Set TreeIndex02 = (TreeIndex02 + 1)
Destructible - Resurrect Tree[TreeIndex02] with (Max life of (Last created destructible)) life and Show birth animation
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
TreeIndex02 Equals TreeIndex01
Then - Actions
Set TreeIndex01 = 0
Set TreeIndex02 = 0
Else - Actions
If you want to add new trees in the game for some reason, run again the first trigger so the new trees can be taken into account for the respawning stuff.
If your map contains more than one type of tree, just use a OR condition in the second trigger:
Thanks to Magtheridon96, who helped me understand the basics of MUI with his tutorial
RespawnTrees
Events
Conditions
Or - Any (Conditions) are true
Conditions
(Destructible-type of (Dying destructible)) Equals Tree X
(Destructible-type of (Dying destructible)) Equals Tree Y
(Destructible-type of (Dying destructible)) Equals Tree Z
It seems to work just fine. There is no issue when there is a unit standing at the position of a reviving tree.
Any suggestion about this? Does it leak or anything?
Yes, I know waits can be problematic, but I'm not very experienced in advanced triggeringfirst off using wait can cause problems in lan games, you have to remember that wait is determined by the computer not the game. Luckily there is a simple fix for this one, which is , "wait in game" which is a wait option
Well spotted, I totally missed that one.the second thing is that in your event RespawnTrees you use the command of ,'Destructible - Resurrect Tree[TreeIndex02] with (Max life of (Last created destructible)) life and Show birth animation'
Last created destructible will mean that any destructible created in the last few seconds before this event, will represent the live points of this try. What you should do is set that value to max life of TreeIndex02