insights on reducing total cpu usage/realtime? in Developer Help
|
|
Profile:
Profile results (total time) Proc Name Self CPU Total CPU Real Time Calls -------------------------------------------- --------- --------- --------- --------- /mob/mobs/start 2836.503 2896.235 582370.563 21578 /mob/proc/mobcheck 33.849 2830.942 565216.563 532645 /client/proc/savegame 145.881 496.566 48782.426 15704 /mob/Write 333.418 333.436 333.473 15703 /mob/Stat 7.362 134.555 521407.375 249926 /obj/projectile/Fire 78.327 121.768 72620.891 31897 /mob/proc/updatestats 1.779 103.227 103.305 229675 /client/Move 22.159 101.889 102.175 650676 /mob/proc/bullycheck 0.078 98.561 17088.494 9797 /mob/proc/updatecompletestats 89.838 90.216 90.319 186142 /mob/Move 73.695 85.811 86.211 873278
|
Problem description: The server uses too much CPU. I don't know any other means of reducing it, I have tried random fixes.
/mob/mobs/start: starts the AI /mob/proc/mobcheck: checks surrounding mobs around you that aren't 'active' /mob/proc/bullycheck: checks for a certain mob and starts it
|
Saving:
client/proc savegame() set background = 1 var/savefile/f = new("players/[ckey].sav") if(mob) f["playername"] << mob.name f["mob"] << mob
|
AI:
mob/proc bullycheck(var/mob/m) set background = 1 if(istype(m, /mob/mobs/Bully) && !m.active) spawn() m.start()
mobcheck() set background = 1
for(var/mob/mobs/m in viewers(7, src)) if(!m || m.active && m.target != null || !see_invisible && m.invisibility || istype(m, /mob/mobs/Bully)) continue
m.target = src spawn() m.start()
mob start() set background = 1
if(active || !target) return
active = 1
while(active && target != null && get_dist(src, target) <= 7) if(stamina >= maxstamina * 0.20)
if(get_dist(src, target) == 1 && punchdelay <= world.time) attack(target) if(get_dist(src, target) >= 2) step_to(src, target)
else
step_away(src, target)
sleep(4)
|
|