ID:262459
 
Problem description:
Basicly when I press Center(it is set to a macro)
I get this
runtime error: undefined variable /obj/Attack_Spot/var/Guard
verb name: Center (/mob/verb/Center)
source file: Combat.dm,47
usr: Justin (/mob/Player)
src: Justin (/mob/Player)
call stack:
Justin (/mob/Player): Center()
Sniper Joe (/client): Center()

I don't see how the variable is undifiened..I have checked if it is a mob or not! :(
Code:
mob
verb
Center()
set hidden = 1
// var/M as obj|mob
var/obj/Spot = new/obj/Attack_Spot(src.loc)
step(Spot,src.dir)
var/turf/X = Spot.loc
spawn(1)
del(Spot)
var/atom/M
for(M in X)
if(M:React)
src.Getting_Message = 1
M:Interact()
else
if(istype(M,/mob/))
goto COMBAT
COMBAT
for(M in X)
var/mob/P = M
if(istype(M,/mob/NPC/))
return
else
var/Damage = src.Strength+src.Str_Add
var/Block = P.Guard+P.Grd_Add
flick("Punch",src)
if(P.Agility>src.Agility)
var/Rand = rand(1,10)
if(Rand>=6)
P.overlays += new/obj/Miss
return
else
goto HIT
else
goto HIT
HIT
Damage -= Block
if(Damage<=0)
P.overlays += new/obj/Miss
return
else
if(src.Tekken_On)
Damage *= 2
P.Stamina -= Damage

else
P.Stamina -= Damage
P.Death()




You're using goto and : in there, but I'll ignore that.
"runtime error: undefined variable /obj/Attack_Spot/var/Guard
verb name: Center (/mob/verb/Center)
source file: Combat.dm,47
usr: Justin (/mob/Player)
src: Justin (/mob/Player)
call stack:
Justin (/mob/Player): Center()
Sniper Joe (/client): Center()"

You're accessing /obj/Attack_Spot's guard var, which it doesn't have since it's a type path. Make sure it's created.
In response to Ol' Yeller
It should be checking the M as in the mob inside the attack spot...
In response to Sniper Joe
"var/mob/P = M"

M is still a type path, ty:
var/mob/P = new M.type
In response to Ol' Yeller
Ok, I put this in front
            COMBAT
var/mob/P = M// THIS
for(M in X)
if(istype(M,/mob/NPC/))
return
else
var/Damage = src.Strength+src.Str_Add
var/Block = P.Guard+P.Grd_Add

Now I get
runtime error: Cannot read null.Guard
verb name: Center (/mob/verb/Center)
source file: Combat.dm,47
usr: Justin (/mob/Player)
src: Justin (/mob/Player)
call stack:
Justin (/mob/Player): Center()
Sniper Joe (/client): Center()