ID:143425
 
Code:
Bump(atom/M)
var/damage = rand((owner:power/2.5)-(M:defense+M:speed))/10
if(isturf(M))
owner.firing = 0
owner.freeze = 0
for(var/obj/O in src.ki_beam)
del(O)
del(src)
else if(ismob(M))
owner.firing=0
owner.freeze=0
if(damage<=0)
M<<"[owner] missed!"
owner<<"You missed!"
for(var/obj/O in src.ki_beam)
del(O)
del(src)
return
owner<<"You hit [M] with [src] for [damage]!"
M<<"[owner] hit you with [src] for [damage]!"
M:health-=damage
M:health_check()
if(M:health<=0)
owner<<"You killed [M]"
M:death_check()
for(var/obj/O in src.ki_beam)
del(O)
del(src)
else
if(!ismob(M) && !isturf(M) && !isobj(M) && !isarea(M))
owner.firing = 0
owner.freeze = 0
for(var/obj/O in src.ki_beam)
del(O)
del(src)


Problem description:
The problem is that when beam which is an obj bumps another obj such as a wall or door it sends errors to me talking about how much it hated what I just did.

This is the problem I had when I shot the beam toward my training bag

runtime error: undefined variable /obj/training_objs/bag_2/var/defense
proc name: Bump (/obj/beams/ki_beam/Bump)
source file: Beam System.dm,27
usr: 0
src: the ki beam (/obj/beams/ki_beam)
call stack:
the ki beam (/obj/beams/ki_beam): Bump(Training bag level 2 (/obj/training_objs/bag_2))
the ki beam (/obj/beams/ki_beam): Move(the floor1 (10,18,1) (/turf/house_icons/floor1), 4)
runtime error: undefined variable /obj/training_objs/bag_2/var/defense
proc name: Bump (/obj/beams/ki_beam/Bump)
source file: Beam System.dm,27
usr: 0
src: the ki beam (/obj/beams/ki_beam)
call stack:
the ki beam (/obj/beams/ki_beam): Bump(Training bag level 2 (/obj/training_objs/bag_2))
the ki beam (/obj/beams/ki_beam): Move(the floor1 (10,18,1) (/turf/house_icons/floor1), 4)
runtime error: undefined variable /obj/training_objs/bag_2/var/defense
proc name: Bump (/obj/beams/ki_beam/Bump)
source file: Beam System.dm,27
usr: 0
src: the ki beam (/obj/beams/ki_beam)
call stack:
the ki beam (/obj/beams/ki_beam): Bump(Training bag level 2 (/obj/training_objs/bag_2))
the ki beam (/obj/beams/ki_beam): Move(the floor1 (10,18,1) (/turf/house_icons/floor1), 4)

Yes I am aware this is for a DBZ style game but its totally original and I can prove it.

add
if(ismob(M))
on the first line its trying to use defense no matter what type it bumps into

or just move that line down to the mob section <.<
In response to Falacy
Okay so I move if(ismob(M)) to the first line but i still wanna have it do something when it hits objs. Hmmm...what if I just moved the var down to below the call?? Thanks I needed another set of eyes.
In response to Smokymcpot
dont move if ismob
either make a 2nd one up at the top
or move the variable to the one below
In response to Falacy
though if you make a 2nd one up top youll have to define that variable outside it!
so id say just move the var down
In response to Falacy
Thats what i said move the var/damage down
In response to Falacy
Actually by moving the var down right under if(ismob(M)) and testing this is worked without error and thank I would have never thought that it would call the var first but now it makes since.