ID:170141
 
Heres a bit of coding from my game. Its the monster movement coding.
mob/var/kill = list("")
mob/proc/move()
var/mob/M
while(src)
if(M in oview(5))
if(M.name in src.kill)
walk_to(src,M,1,4)
if(M in oview(4))
step_towards(src,M)
else
sleep(15)
step_rand(src)
break
else
for(M in view(src))
break
sleep(5)
spawn(2)
src.move()

Now heres my death verb that Im using in my game:
mob/proc/Death()
if(usr.hp <= 0)
if(!src.client)
view() << "\blue [src] was slain by [usr]"
usr.exp += src.exp
usr.gold += src.gold
usr.Level()
del(src)
else
view() << "\red [usr] was slain by [src]"
usr.loc = locate(/area/start)
usr.hp = usr.mhp
usr.mp = usr.mmp

Now finally hers a simple monster code i put in:
mob/spider
icon = 'monsters.dmi'
icon_state = "spider"
hp = 6
mhp = 6
mindam = 1
maxdam = 2
str = 1
def = 1
exp = 6
New()
.=..()
spawn(1)
move()
Bump(mob/M)
if(M.client)
monattack(M)

Now heres the question:
The move code i coded is suppposed to make mobs move around, and if attacked or if they spot someone who attacked them, they attack. However they dont. They just stand there. They dont die, either. And, yes, incase your wondering, i DID make it so that when a mob attacks the monster, they are added to its enemies list. SOmeone please tell me how to fix this. Thanks in advance(again)
-----Rein-----
No put usr in proc. Ungh.

Lummox JR
In response to Lummox JR
Lummox JR wrote:
No put usr in proc. Ungh.

To elaborate on that, if you don't understand why you shouldn't be putting usr in proc, then please read the usr lecture.
In response to Lummox JR
Theres still the slight problem that the monsters won't move when u attack em'. I still need help wit dat.
In response to Wizkidd0123
I hate to make myself look stupid by saying this(even though i AM stupid-__-), but I understand what he means by not putting usr in proc. I mean where int he coding did I PUT usr in a proc? Sorry if this seems like a stupid question, but im an idiot.
In response to Reinhartstar
That problem is caused by using usr in move() (a proc). While you're not directly using it, the view() and oview() procs' center argument defaults to usr. Since you called this from New(), usr should be null, and that makes oview(usr) completely empty.

Also, why are you using walk_to() and step_towards()? For a loop that iterates this quickly, I'd use a step proc and get rid of that second check in oview().

*Edit
M is null as well, you can use locate() to grab a mob.
In response to Reinhartstar
Reinhartstar wrote:
I mean where int he coding did I PUT usr in a proc?

You put it in your mob/Death() proc.

Instead of usr there, pass the killer mob through the proc as an argument.