- Joined
- Oct 5, 2012
- Messages
- 86
So... I made an aos map, and thought it would be kinda funny if the trees would regrow at a random time spawn each (for example 1 to 8 seconds). Is this possible?
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Time - Every (Random real number between 1.00 and 8.00) seconds of game time
// In case you have JNGP uncomment this:
// globals
// hashtable udg_hashrev = InitHashtable()
// endglobals
function trigger2 takes nothing returns nothing
local timer t = GetExpiredTimer()
local destructable dest = LoadDestructableHandle(udg_hashrev, GetHandleId(t), 0)
call DestructableRestoreLife(dest, 9999, true)
set dest = null
call DestroyTimer(t)
set t = null
endfunction
function trigger1 takes nothing returns boolean
local timer t = CreateTimer()
call SaveDestructableHandle(udg_hashrev, GetHandleId(t), 0, GetTriggerDestructable())
call TimerStart(t, GetRandomReal(4., 8.), false, function trigger2)
set t = null
return false
endfunction
//===========================================================================
function InitTrig_randomdest takes nothing returns nothing
local trigger t = CreateTrigger( )
call TriggerRegisterDestDeathInRegionEvent(t, GetWorldBounds() )
call TriggerAddCondition( t, Condition(function trigger1))
endfunction
randomdest

Events


Destructible - A destructible within (Entire map) dies

Conditions

Actions


Custom script: local destructable dest = GetTriggerDestructable()


Wait (Random real number between 1.00 and 8.00) seconds


Custom script: call DestructableRestoreLife(dest, 9999, true)


-------- the first argument is the destructable, because I use local destructable Im also calling --------


-------- the GUI function Revive/Restore Destructable as custom script --------


-------- the second argument is with how much health should it revive --------


-------- the third argument is if we want a birth animation to show or not --------


Custom script: set dest = null
(Destructible-type of (Dying destructible)) Equal to Summer Tree Wall
TreeRevival Init

Events


Map initialization

Conditions

Actions


Set TempPoint = (Center of (Playable map area))


Unit - Create 1 Peasant for Neutral Passive at TempPoint facing Default building facing degrees


Set TreeDetector = (Last created unit)


Unit - Hide TreeDetector


Custom script: call RemoveLocation(udg_TempPoint)
TreeDeath

Events


Destructible - A destructible within (Playable map area) dies

Conditions

Actions


Set TempTree = (Dying destructible)


Unit - Order TreeDetector to Harvest TempTree


If (All Conditions are True) then do (Then Actions) else do (Else Actions)



If - Conditions




(Current order of TreeDetector) Equal to (Order(harvest))



Then - Actions




Unit - Order TreeDetector to Stop




Set TreeMaxIndex = (TreeMaxIndex + 1)




Set DeadTree[TreeMaxIndex] = TempTree




Set TreeTimer[TreeMaxIndex] = (Random real number between 1.00 and 8.00)




If (All Conditions are True) then do (Then Actions) else do (Else Actions)





If - Conditions






TreeMaxIndex Equal to 1





Then - Actions






Trigger - Turn on TreeLoop <gen>





Else - Actions



Else - Actions


Destructible - Kill TempTree
TreeLoop

Events


Time - Every 0.03 seconds of game time

Conditions

Actions


For each (Integer TreeCurrentIndex) from 1 to TreeMaxIndex, do (Actions)



Loop - Actions




Set TreeTimer[TreeCurrentIndex] = (TreeTimer[TreeCurrentIndex] - 0.03)




If (All Conditions are True) then do (Then Actions) else do (Else Actions)





If - Conditions






TreeTimer[TreeCurrentIndex] Less than or equal to 0.00





Then - Actions






Destructible - Resurrect DeadTree[TreeCurrentIndex] with (Max life of (Last created destructible)) life and Show birth animation






Set TreeTimer[TreeCurrentIndex] = TreeTimer[TreeMaxIndex]






Set DeadTree[TreeCurrentIndex] = DeadTree[TreeMaxIndex]






Set TreeMaxIndex = (TreeMaxIndex - 1)






Set TreeCurrentIndex = (TreeCurrentIndex - 1)






If (All Conditions are True) then do (Then Actions) else do (Else Actions)







If - Conditions








TreeMaxIndex Equal to 0







Then - Actions








Trigger - Turn off (This trigger)







Else - Actions





Else - Actions
