mob
proc
NPCAI() //name of proc
var/mob/player/M //variable M has to be mob/usr
while(src) //while src is stil kickin
if(M in oview(5)) //if M is in oview(5)
if(M.name in src.killlist) //now if M.name is in src.killlist, this has it only attack if attacked!
walk_to(src,M,1,4) //src walks to M until 1 block away, moving 4/10ths of a second
if(M in oview(1)) //if M is in oview(1)
step_towards(src,M) //src steps toward M
else //if usr.name isnt in src.killlist
sleep(15)//pauses for 1 and 1/2 seconds
step_rand(src) //step randomly on the field
break //breaks out of the while loop
else //if M isnt in oview(5)
for(M in view(src)) //for all Ms in view(src)
break //breaks out of the while loop
sleep(5) //pauses 1/2 second before redoing loop
spawn(2) // pauses 2/10 of second before redoing proc
NPCAI()
Problem description:
I'm trying to make the npcs/AI's cause less lag to my game. It's making the game go to like..extremely low server efficiency rates. I tried testing game w/o npcs and it was 100%,however,with npcs it was way higher. I deleted a bunch of them and it went higher, but I can't really afford to delete any more..it'd just be awkward.
Any1 know how to optimize the NPCs/AIs to cause less lag
1. AIFindTarget()
2. AIMove2Target()
3. AIAttackTarget()
4. AISleep() <-- This one makes the AI go inactive as it ends.