For placeables that need to use delays, you might want to consider pseudo hb's or a global pseudo hb.
Eg:
For a tree grow:
- onHeartbeat for the tree would basically start a global recurring method call on the module.
It would also set an int value on the module to ensure only one copy of itself is running.
void TreeLoop()
{
int i = 1;
object oTree = GetObjectByTag("tree_tag",i);
while(oTree != OBJECT_INVALID)
{
//Do something to tree
//get next tree
oTree= GetObjectByTag("tree_tag",i);
i++;
}
DelayCommand(300.00, TreeLoop());
}
void main()
{
object module = GetModule();
int iDone = GetLocalInt(module,"TREE_LOOP");
if(iDone){ return;}
SetLocalInt(module,"TREE_LOOP",1);
DelayCommand(1.00,TreeLoop());
}
I would actually recommend doing smaller intervals between the loops, for more granularity.
And increment a local variable on the tree to indicate the growth phase.
Eg: When the integer gets to 10, then grow the tree.
When the tree is harvested or cut down, reset it to 0, and let the loop continue to increment it again, until it gets to 10.
This way you avoid long 1 hour delayed commands, and get more accurate command execution.
Depending on how many trees you have, you may want to manage the delayed commands.
Doing 5000 trees in a single method call could end up freezing your module etc
If you however, migrate this to the trees 'actual' hb event, then the server will manage the heartbeats itself, allowing it to lower priority of areas which are empty.
This can however mean that some areas the trees do not grow back as fast.