ID:262931
 
Code:
mob/proc/Attack(mob/player/M)
if(get_dist(src, M) < 2)
if(M != /mob/player)
return
else
M << "[src] attacked you!"
var/D = src.Attack - M.Defense
if(D <= 0)
D = 0
M.HP -= D
M.DeathCheck()


It's being called here.
Ice_Dragon_Weakling
icon_state = "Ice Dragon Weakling"
maxHP = 100
HP = 100
Attack = 15
Defense = 5
EXPGive = 65
GoldGive = 25
New()
walk_rand(src,30)
src.Attack()
proc/ItemGive()
if(prob(5))
ItemGive = pick(FDWIG)


Problem description:
Not attacking.
if(!istype(M,/mob/player))
1 - You're calling attack() without arguments. That means m will be null.

2 - null != /mob/player, so the function returns. Of course it isn't attacking!

3 - I think you mean if(!istype(m,/mob/player)), anyway.
In response to Jp
1 - You're calling attack() without arguments. That means m will be null.

I had a feeling it was something like that. This is my first time calling an attack proc with monsters instead of players, so I knew something was missing somewhere. What is needed there?
In response to Pyro_dragons
The monster needs to know what it's attacking.

Something like this:

var/const/AIDELAY=5

mob/monster
var/mob/target
New()
..()
spawn(1) Ai()
proc/Ai()
while(src)
if(!target)
for(var/mob/m in view(src))
target=m
break
step_rand(src)
else
if(target in range(src,1))
Attack(target)
return
else
step_to(src,target)
sleep(AIDELAY)


should work.