I want to know why my code snippet causes my game to crash. Is there a better way to accomplish what I am trying to do?
Guard_Behavior()
while(src)
var/mob/Life_Form/L = locate()
if(L) world<<"Hi"
spawn(1) Guard_Behavior()
In response to Nadrew
|
|
I wasn't even aware of set wait for. Thanks for the help, I am now able to make the code run properly now.
|
However, you seem to have this proc defined for all mobs, you definitely do not want a loop running all the time on every mob of that type in the game. You'd run out of resources pretty rapidly as you added more. You'd likely want to have a single global loop running that runs over a list of guard NPCs and calls a behavior proc (that's not a loop).
Or you can simply trigger the NPCs as a player comes into view by keeping track of them in a list and going over said list when a player enters an area.