mob/monster
var/mob/player/P
New()
.=..()
spawn(1)
Wander()
proc/Wander()
while(src)
if (P in oview(5))
step_towards(src,P)
else
step_rand(src)
for(P in view(src))
break
sleep(5)
spawn(40)
Wander()
Bump(mob/M)
if (istype(M,/mob/player))
Attack(M)
M.powerlevelRefresh()
proc/Attack(mob/M)
if(istype(M,/mob/player))
M.powerlevel -= usr.powerlevel * 1
view() << "<font color = red>[src]<font color = aqua> Attacks <font color = red>[M]"
M.DeathCheck()
How ever,when the player floats above the ground as in flying w/ magic the monster does not attack them and the player can attack the monster but that monster does not attack them unless they land could anyone please help me ?thanks
Your Wander() proc needs a few other improvements as well; it uses usr (as it's a default argument to view() and oview()), and the method it uses for finding players is suspect. I'd do it like this:
<code>proc/Wander() while(src) var/mob/player/P=locate() in oview(5,src) if (P in oview(1,src)) Attack(M) else if (P) step_to(src,P) else step_rand(src) sleep(5)</code>
You need to make one change to your existing code to use this. Read the code I posted through, work out what you need to change, and do it; you'll learn faster than if I just continually hand you code on a silver platter.
This method has a few advantages over the one you're using. It uses a local variable, instead of a /mob/monster variable; it doesn't rely on that variable's value staying the same between loops; it doesn't have that redundant spawn(40) code (what's the point of that? The while() loop accomplishes everything you need anyway); it uses Attack() directly instead of relying on bumping; and because it doesn't rely on bumping, we can use step_to instead of step_towards, which makes the monsters smarter in terms of finding their way around obstacles.
You won't be able to copy and paste the code I posted. Study it and adapt your existing code first.