ID:174558
 
well i was messing around and decided to make up a monster code thing, where it wanders and then follows you when you're close but for some reason it only wanders and doesnt follow. also i made a bump proc thing but that doesnt work either.


New()

Wander()

proc/Wander()
var/mob/Enemy/M
if(M in viewers(5)) // Run through all the monsters within 5 squares that can see you
walk_to(M,src,0,10)
else
walk_rand(src,20)

Bump(mob/M)
if(istype(M.client))
var/rando = rand(1,3)
switch(rando)
if(1)
mattack(src)
Cloudiroth wrote:
well i was messing around and decided to make up a monster code thing, where it wanders and then follows you when you're close but for some reason it only wanders and doesnt follow. also i made a bump proc thing but that doesnt work either.


New()

Wander()

proc/Wander()
var/mob/Enemy/M
if(M in viewers(5)) // Run through all the monsters within 5 squares that can see you
walk_to(M,src,0,10)
else
walk_rand(src,20)

Bump(mob/M)
if(istype(M.client))
var/rando = rand(1,3)
switch(rando)
if(1)
mattack(src)

Probleme is the monster only checks as soon as he is created and never does it again, add
spawn(10) Wander()
at the end of the wander procedure so every 1 second it does it again
In response to FranquiBoy
Ahh crap, I can't believe i over looked that! thanks. EEEEEEEEEEEEERRRRRRRRRRRRRRRRRR! Oh well time to try more.
Cloudiroth wrote:
well i was messing around and decided to make up a monster code thing, where it wanders and then follows you when you're close but for some reason it only wanders and doesnt follow. also i made a bump proc thing but that doesnt work either.

Various problems here:

New()
Wander()

That should be spawn() Wander() to be safe.

proc/Wander()
var/mob/Enemy/M
if(M in viewers(5)) // Run through all the monsters within 5 squares that can see you
walk_to(M,src,0,10)
else
walk_rand(src,20)

M has no value to start out; you never gave it one. if(M in viewers(5)) is the same as if(null in viewers(5)).

viewers(5) should be viewers(5,src), since this is a proc and usr can't be trusted here.

walk_to() has been reversed, so that if the if() did anything, the enemies would walk toward src instead of src to them. Since src should be the enemy, I think what you really want to do is loop through players who can be seen by src.

Bump(mob/M)
if(istype(M.client))
var/rando = rand(1,3)
switch(rando)
if(1)
mattack(src)

I think you meant that to be attack(M).

If you're using one attack proc for monsters and one for players, don't; that's the wrong way to go. They should use the same basic attack proc, but each type should override it to do specific things.
mob
proc/attack(mob/other)
// do nothing

player/attack(mob/other)
// attack something

Enemy/attack(mob/other)
// attack something

Lummox JR