ID:268062
 
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
The monster can't bump the player when the player is flying, because the player's density is 0. The solution to this is to give monsters a better method of attacking; instead of relying on Bump(), make their Wander() proc call Attack() directly when the monster is adjacent to the player.

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.
Find a new AI system to use. That one is terribly broken.
As I've said many times, and as Garthor has here reiterated, that Wander() proc is no good. Throw it away, or look up one of the many forum posts I've made with possible fixes (read: complete overhauls).

Lummox JR
In response to Lummox JR
I just noticed that the tutorial has been updated and fixed.
In response to Crispy
couldnt i just set it up some how that if they have no density they attack and if they have density? just an idea.