mob/proc/Hunt()
var/mob/PC/P
while(src)
if(P in oview(10))
walk_to(src,P,1,4)
if(P in oview(1))
step_towards(src,P)
else
step_rand(src)
break
else
for(P in view(src))
break
sleep(5)
spawn(2)
Hunt()
mob/proc/Wander()
var/mob/PC/P
while(src)
if(P in oview(10))
if(P.name in src.killlist)
walk_to(src,P,1,4)
if(P in oview(1))
step_towards(src,P)
else
sleep(15)
step_rand(src)
break
else
for(P in view(src))
break
sleep(5)
spawn(2)
Wander()
Problem description:
I am currently working on the (basic) monster AI for my game. It works as intended, I am here hoping maybe someone could take a look and tell me if there's a better way to do this?
The idea is I set the aggression of the monster at New(), Wander has them just wander around (until attacked) and Hunt has them go directly to a player if they are within the proper view.
You can actually leverage the bounds variable and the Cross/Crossed() procs to activate NPCs.
As for wandering part, you'd probably want something that determines what region NPCs belong to, then start their wandering around when a player enters that region, and cease it when there are no players left in the region.
This way you don't have a bunch of NPCs eating up CPU cycles unless there's something nearby to appreciate it.