ID:180742
 
I got some procs that I want to always run in my game such as a healing proc that basically adds hit points then sleeps for a certain amount of time and loops again.
Should I just run the proc after a character is created and after characters are loaded, or is there a better way to do it?
On 2/28/01 2:06 pm Karver wrote:
I got some procs that I want to always run in my game such as a healing proc that basically adds hit points then sleeps for a certain amount of time and loops again.
Should I just run the proc after a character is created and after characters are loaded, or is there a better way to do it?

Your way would work fine: just kick off the proc for each new mob that's created. One alternative would be to maintain a list of mobs that can heal, and cycle through it every so often, instead of handling it separately for each individual mob. That might offer some minor advantage in CPU usage, but probably not enough to make any kind of difference. Your idea sounds good.
In response to Guy T. (#1)
On 2/28/01 2:19 pm Guy T. wrote:
On 2/28/01 2:06 pm Karver wrote:
I got some procs that I want to always run in my game such as a healing proc that basically adds hit points then sleeps for a certain amount of time and loops again.
Should I just run the proc after a character is created and after characters are loaded, or is there a better way to do it?

Your way would work fine: just kick off the proc for each new mob that's created. One alternative would be to maintain a list of mobs that can heal, and cycle through it every so often, instead of handling it separately for each individual mob. That might offer some minor advantage in CPU usage, but probably not enough to make any kind of difference. Your idea sounds good.

This is basically how I do it. I maintain a global list of mobs which need to be checked and I have a loop which cycles through the list at a set rate.

This basically means that, if a mob is damaged, then that mob is added to the global list. When the mob is completly healed, it's removed from the global list.

[EDIT]
In addition, I put checks throughout the code so if a mob is damaged and for some reason not in the list and getting checked, when the mob does something that triggers a check the mob will then be added. This is more a saftey feature than anything else, but I've found that checks of this sort are quite handy - especially if there is a crash and something escapes the reboot.