So I've been trying to create a complex Ai procedure, and its coming along pretty nice, but unexpectedly, a problem came up that left me with no choice but to turn to the community. Basically, which of these two methods should I use, and if neither, could you tell me why?
Old proc structure
Code:
proc
SpecialAi(var/mob/m)
/*
block of code
*/
if(test==true)
spawn(m.adelay)
SpecialAi(m)
else
return
New proc structure
Code:
proc
SpecialAi(var/mob/m)
while(test==true)
/*
block of code
*/
sleep(m.adelay)
The old proc structure worked fine, but whilst learning C++ I heard that procs calling themselves was a bad idea in most cases so I opted to change it to a while loop, which on the other hand causes severe lag spikes 20+ minutes into gameplay.