ID:266450
 
this is my battle thing code

---------------------------------------------

mob
NPC
mosquito
name = "Mosquito"
icon = 'fly.dmi'
HP = 7
MaxHp = 7
Str = 2
Def = 1
Exp = 0
Enterif = 0
var/mob/PC/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(M.key)
Attack(M)
Attack(M)
flick("attack",src)
sleep(5)
var/damage = usr.Str-M:Def
if(damage <= 0)
usr << "You attack [M]!"
usr << "1 damage or none at all!"
M << "[usr] attacks you!"
M << "1 damage or none at all!"
return
else
M.HP-=damage
usr << "You attack [M]!" //send this message to the usr
M << "[usr] attacks you!" //send this message to the mob
M << "[damage] damage!" //tell the damage to the mob
usr << "[damage] damage!" //tell the damage to the usr
M:LevelUp()
M:Die()
-------------------------------------

it gives me this runtime error

runtime error: undefined variable /turf/wall/var/key
proc name: Bump (/mob/NPC/mosquito/Bump)
usr: Mosquito (/mob/NPC/mosquito)
src: Mosquito (/mob/NPC/mosquito)
call stack:
Mosquito (/mob/NPC/mosquito): Bump(the wall (9,32,3) (/turf/wall))
Mosquito (/mob/NPC/mosquito): Move(the wall (9,32,3) (/turf/wall), 1)
Mosquito (/mob/NPC/mosquito): Wander()
Mosquito (/mob/NPC/mosquito): New(the grass (16,34,3) (/turf/grass))
---------------------------------------

how can i fix that?
help me please!
In response to Thief Jack
Always wait AT LEAST two days before "reminding others of your post", otherwise we call it "bumping" which is irritating, and causes people to NOT help you for just that reason.

And it's spelled "Dammit".

On top of that, you might consider reading the error before you go asking for help.
In response to Thief Jack
Thief jack wrote:
help me damnit!

Sorry, but people tend not to help someone who bumps their post after a mere 37 minutes. Wait until tomorrow.

Lummox JR
In response to Thief Jack
Thief jack wrote:
help me damnit!

This is the first time I got to your post, and with an attitude like that, probably the last time I'll bother.

You will get a lot more help if you are polite. Even if you behave well, you will have to wait on the schedule of the person who helps you.
Thief jack wrote:
Bump(mob/M)
if(M.key)
Attack(M)
how can i fix that?

From what the error says, it seems like you bumped a wll, which has no key variable. This is why you got a runtime error. I would change the above to:

Bump(mob/M)
if(ismob(M))
Attack(M)

And please don't bump your posts, most people won't help you when you do...

~X
In response to Xooxer
srry guys but thx