ID:262120
 
mob/Monsters
scorpion
icon = 'Monster.dmi'
icon_state="scorpion"
gold = 20
HP = 15
MHP = 15
player = 0
Str = 2
Expg = 7
level = 3
monster = 1
PK = 1
NPC = 0
New()
. = ..()
spawn()
Wander()
proc/Wander(var/mob/You/P)
while(src)
if(P in oview(5))
step_towards(src,P)
for(P in oview(1))
break
for(P in oview(2))
break
for(P in oview(3))
break
for(P in oview(4))
break
else
step_rand(src)
sleep(5)
for(P in oview(5))
break
sleep(5)
spawn(5)
Wander()
Bump(mob/M)
if(M.player == 1)
Fight(M)
else
return
proc/Fight()
for(var/mob/E in get_step(usr,usr.dir))
var/damage = src.Str
E.HP -= damage
E << "[src] attacks you for [damage] damage!!"
src<<"You attack [E] for [damage] damage!!"
UserDcheck(E)

mob
proc/UserDcheck(mob/M)
if(M.HP<=0)
M<<"<I><small>You died!"
M.HP=M.MHP
M.MP=M.MMP
M.loc=locate(2,2,1)
M.PK=0
return


ok the only problem is that I don't want the wonster running around. I just want them chasing the people when they see them.
Dragon warrior2662 wrote:
                    step_rand(src)



This this part of the Wander() proc? It's telling the monster to run around randomly if it can't find a target. Remove it and it should work as you want it to.
In response to DarkView
it works but now it doesn't chase or respond to attacks.
In response to Dragon warrior2662
Are you sure you only got rid of the line I mentioned (step_rand(src))?
A few problems here:

  • Your Fight() proc has usr in it. Get rid of that. Clearly this should be src, since elsewhere src is the attacker.
  • The death check proc is implemented backwards. The one you should be checking for death is src, and the argument should be the killer. Look at how many times you have M.something in there: That means the thing you're operating on most is M. If you're doing that much to an item, it should be src. The killer is only of minimal importance there, so that's what the argument should be. It'd make infinitely more sense to switch M and src around and call the proc differently.
  • The marching rows of if(P in oview(...)) lines are useless; if a value of P is found in one, it'll still go ahead and search in the others. What you should do instead is create another proc to find the closest player, and use the output from that.
  • You don't need the spawn() Wander() if you're using while(src) in the proc in the first place.

    Lummox JR