ID:1646764
 
I've been thinking around the ways of having on-going auto-update (if that makes sense) of stats and /or anything else related to the players.

But how do i go about doing this in a efficient way?

I originally started with something along the lines of this:

mob
New()
.=..() // is this correct?
spawn(0) Live()

Proc/Live()
while(src)
// Do checks on whatever
update_stat() //updates stat proc
Health() //checks and updates health?
// ++ more procs


Now this is just a quick mockup of what the code could look like. The problem i have with this, is that i feel that having an endless (more or less) loop that continiusly calls upon procs like update_stats and Health to be bad? or am i wrong?

I would rather that it was only called upon if changes were made or if there were changes to be made, if you catch my drift.

Then i thought, what if i pull all those other procs in that one live proc, but that would then be a rather large proc. (but i'd not have X number of procs being called all the time and running) . Anyways.. not sure if what I'm asking is clear or if I'm even making sense..

How would the more experienced of you go about doing something like this?
A more efficient way is to update the stats when changes occur. For example:
mob/verb/Attack()
X.TakeDmg(100, st)


mob/proc/TakeDmg(Dmg, Attacker)
src.hp = max(0, min(src.MaxHP, src.hp - Dmg)) // Damage is capped between 0 - MaxHP
src.UpdateStat()


If you are using stat panels, there's simply one less headache but it is less efficient then outputting to a grid when needed.
aaah yes.. that's actually not bad at all. that way im not constantly checking to see if changes have been made, but rather letting the action activate the check. So if there's no action, there's nothing to check! .. makes sense.