ID:149364
 
For some reason whenever there is a monster created on the map it lags so much untill it takes 5 seconds just to move. I think it has something to do with my monsters move code

mob/monster1
icon = 'npcs.dmi'
icon_state = "horse"
health = 50
mindamage = 2
maxdamage = 10
lvl = 1
isnpc = 1
Att = 60
DEF = 3
DEX = 20
AGI = 12
gold = 35
EXPgive = 25
action_speed = 20
New()
// Start my action cycle at a random point, to keep cycles spread out.
spawn(1) Walk()//calls walk proc spawn to prevent crashing
return ..()

proc/Walk()
for(var/mob/M as mob in oview())//for mobs in oview
if(M.client)//if its a player
walk_to(src,M,0,10)///walks to the mob
if(get_dist(src,M)<=1)//if distance between the monster and mob is 1 or less than 1
src.attacking(M)// monster attacks
else
walk_rand(src, 5)//walks randomly
spawn() Walk()//loops proc
Mrhat99au wrote:
spawn() Walk()//loops proc

The format for spawn() changed slightly a few versions ago. Change that line to:
spawn(1) Walk()//loops proc
In response to Shadowdarke
Yeah i changed that but it still lags up my game. Whenever i go into battle or it dies it stops lagging. I dont know why though. And the monster still moves too.
In response to Mrhat99au
Anyone? Its been a day. Just brining me post back to the top. k.