ID:1663962
Aug 22 2014, 3:07 pm
|
|
Health regen is triggered every time the player gets damaged or logs in. I made the regen tick every 5 seconds but it feels sluggish. I did this because I thought it would put less stress on the server than having it tick every second. Would it really matter?
|
Aug 22 2014, 3:23 pm
|
|
A simple incremental for just players really wouldn't be much to handle. When you've got more things going on is when you'll want to conceder increasing the delay on what you can. (Say creating a couple of hundred objects while trying to keep the game playable - and things like that).
|
SMR(mob/M) Thats for stam regen. There are also two other stats that can regen - HP and MP. They're similar to stamina regen just with different variables. If there were 50 players and all three procs were running per player (so 150 procs in all running concurrently) would there be any noticeable lag? |
I rewrote your code because I was bored and I saw a couple small things that urked me slightly.
mob To answer your question, you shouldn't be so concerned with lag on a simple loop like this. You should definitely be able to shorten your sleep to to at least world.tick_lag*2 (tick_lag pending, ofc.) |
Further cleanup. Slightly more efficient, slightly cleaner:
Notably, I removed the unnecessary spawn(), which makes this function impossible to profile accurately. Instead, I replaced it with setting waitfor to 0, which effectively does the same thing as a spawn, but without the added consequence of the code not showing up properly in the profiler. mob/proc There's no real reason to worry about something this simple, though. You can have this happen thousands upon thousands of times per second with no real impact. |