ID:175945
 
When i click my attack verb in the game i get this error:

runtime error: Cannot read null.def
proc name: Attack (/mob/verb/Attack)
source file: Mobs.dm,145
usr: \[Master GM]Wanabe (/mob/Player)
src: \[Master GM]Wanabe (/mob/Player)
call stack:
\[Master GM]Wanabe (/mob/Player): Attack(null)
runtime error: Cannot execute null.DeathCheck().
proc name: Attack (/mob/verb/Attack)
source file: Mobs.dm,152
usr: \[Master GM]Wanabe (/mob/Player)
src: \[Master GM]Wanabe (/mob/Player)
call stack:
\[Master GM]Wanabe (/mob/Player): Attack(null)

I know what it says cannot read null. thingamigig's but i cant stop it, heres the verbs code, any help?..
mob/verb/Attack(mob/m as mob in oview(1))
set category = "Fighting"
var/hitpercent=50+src.dex
var/hitpercent2=hitpercent-m.Agility
if(hitpercent2>100) hitpercent2=100
if(hitpercent2<0) hitpercent=0
var/hitpercent3=rand(1,100)
sleep(2)
src.Attack=1
if(hitpercent3 <= hitpercent2)
if(src.Attack==1)
var/damage = rand (src.str,src.str*2)
damage -= rand(m.def,m.def*2)
m.attacked = 1
if(damage > 0)
m << "[src] attacks you and does [damage] damage"
src << "You attack [m] for [damage] damage"
m.hp-=damage
src.Levelup()
m.DeathCheck()
sleep(5)
src.Attack=1
else
m << "[usr]'s attack bounces off of you!"
src << "Your attack bounces off of [m]!"
src.Levelup()
m.DeathCheck()
sleep(5)
src.Attack=1
else
return
else
src<<"You missed!"
sleep(5)
src.Attack=1

-Thanks
Obviously this is coming up when it's trying to read m.def. Therefore, m is null. That means no mob was found to use with the verb, or the mob was already destroyed by the time the verb "ran".

The first thing to do in your verb is this:
if(!m) return
It'll bail out if m is null.

Lummox JR
In response to Lummox JR (#1)
Thanks that worked perfecto!
Crazy stuff. I had a similar problem earlier today. Your's is a little different though so I don't really know...

-Dagolar