R = return
Sp() = spawn
I used the #define for those 2
mob/proc/PreyAI()
if(!canattack)
if(prey.len)
for(var/mob/M in prey)
if(!M) R
else prey -= M
else R
else if(canattack)
if(length(prey))
for(var/mob/M in prey)
if(!M) R
else
if(!M in oview(vision)) prey -= M
else if(!M.infight) M.suffix = ""
for(var/mob/M in oview(vision))
if(!M) R
if(istype(src,/mob/NPC) && istype(M,/mob/NPC)) R //An NPC can't attack another NPC
if(M in prey) R // ERROR IS HERE
else src.prey += M
if(M.infight) M.suffix = "Fighting"
Sp() PreyAI()
mob/NPC/proc/AttkAI()
if(ischasing) R
if(length(prey)) R
else for(var/mob/M in prey)
if(M.infight) R
var/emotion = personality + mood
var/attkchance = prob(round(emotion))
if(attkchance)
ischasing = M
while(M in prey)
step_towards(src,M)
sleep(src.walkdelay)
It adds the mob that it finds into prey which is displayed on the Statpanel, but it still gives Type Mismatch and it also isn't calling AttkAI().
Note that I put AttkAI() in because I suspect that there will be something wrong with it when the other proc is fixed, and was hoping someone may save me the trouble of finding it myself, lol.
Resonating Light
One thing I can tell you: Using return in those loops is a bad idea; you should use continue instead, which will skip to the next thing in the loop. Whenever you use return or continue (or break) at the end of an if() block, too, you won't need the else statement because it's implied.
Besides that, I'm a little curious why you've set up #define statements for return and spawn; unless you're writing a game for the next 4K challenge, they're just going to clutter your code and cause confusion.
Lummox JR