ID:264492
 
Code:
mob
verb
Spirit_Gun() // Verb used for firing the beam
set category = "Techniques"
set name = "Spirit Gun"
if(usr.strength <= 5)
usr<<"You dont have enough power!"
return
else // If the firing var isn't 1...
if(usr.strength >= 6)
usr.strength -= 1
usr.hp -= 2
if(usr.hp<=0)
usr.death_check(usr)
if(usr.strength<=0)
usr.strength = 0
usr.firing = 1
usr.icon_state="spiritgun"
sleep(10)
usr.icon_state=""
var/obj/spiritgun/K = new /obj/spiritgun
K.loc = usr.loc
K.dir = usr.dir
usr.level_up()
K.name="[usr]"
walk(K,usr.dir)
sleep(600)
usr.firing = 0
del(K)
if (target == null)
del(K)
usr.random = rand(1,6)
if(random == 5||random==1)
usr.exp += rand(1,10)
usr.level_up()
else
return
else
usr.random = rand (1,4)
if(usr.random == 1||usr.random == 4)
usr.strength -= 1
usr.hp -= 2
if(usr.hp<=0)
usr.death_check(usr)
if(usr.strength<=0)
usr.strength=0
usr.firing = 1
usr.icon_state="spiritgun"
sleep(10)
usr.icon_state=""// Sets the firing var to 1, so he cant fire another beam // Disables the mob's movement
var/obj/spiritgun/K = new /obj/spiritgun
K.loc = usr.loc
usr.level_up()
K.dir = usr.dir
src.name="[usr]"
src.Gowner=usr
walk(K,usr.dir)
sleep(600)
usr.firing = 0
del(K)
if (target == null)
del(K)
usr.random = rand(1,6)
if(random == 5||random==1)
usr.exp += rand(1,10)
usr.level_up()
else
return
else
usr<<"You failed to use Spirit Gun."



obj
spiritgun
icon = 'spirit gun.dmi'
icon_state = ""
density = 1
Bump(A)
if(ismob(A))
var/mob/M = A
if(M.Kaiten||M.sphere)
return
var/damage = round(usr.strength*2)
if(damage >= 1)
M.hp -= damage
var/mob/O= usr.Gowner
view(M) << "[M] was hit by Spirit Gun for [damage] damage!!"
Blood(M.x,M.y,M.z)
M.death_check(O)
del(src)
if(istype(A,/turf/))
var/turf/T = A
if(T.density)
del(src)
if(istype(A,/obj/))
del(src)


Problem description:

i keep getting this problem no matter wut i do to fix it.
the porblem is:

The gfhxfghgfh (/obj/spiritgun): Bump(the gfhxfghgfh (/mob/charactermenu))
runtime error: Cannot read 0.strength
proc name: Bump (/obj/spiritgun/Bump)
usr: 0
src: The gfhxfghgfh (/obj/spiritgun)
call stack:
.............................................................



its suppose to shoot out the spirit gun. it works fine until the bump and then i get the runtime error. can someone plz help me.
Sorry, but we do not know which line you refer to. However, I would like to point out that you are using rand() in a terrible way there (before anyone comes onto me about "prob() and rand() being a choice of the user", I'm refering to the fact of using a compile-created var instead of a runtime-created var).
In response to Demon_F0rce
so wut should i do? and its the bump i guess i dont quite under stand the error
In response to Cnsdddarrius
Cnsdddarrius wrote:
so wut should i do? and its the bump i guess i dont quite under stand the error


btw i am young_D_Rell to.
In response to Cnsdddarrius
In the code file, go to:

Build (the tab up the top) > Preferences for [environment name] > and tick the box titled "Generate Debugging Information".

Now, cause the runtime error to happen again. The runtime error will list a code file and line. Go into the code file and push ctrl+g and type in the error line. Now give me said line. Also, could you pleash show me your deathcheck proc, as I think that's gonna be what's causing you some trouble.
In response to Demon_F0rce
its this

var/damage = round(usr.strength*2)
In response to Cnsdddarrius
Well does usr.strength exist? What is usr? I've saved you the trouble and did some testing of my own:


usr is 0. src is Demon_F0rce

usr is false. So no, usr.strength does not exist. You might want to try using src. Also, a tip: NEVER use usr in procs. It's not what you think it is. For more information, http://www.byond.com/members/ DreamMakers?command=view_post&post=35932
In response to Demon_F0rce
but i tried src i keep getting an error saying
src.strength:undefined var
In response to Cnsdddarrius
That's because I got mixed up with your damn names, since you've set up the projectiles name to be equal to it's shooter. Anyway, I notice you've got a var title Gowner which is set to the usr. If you move the part where you define Gowner as a mob up to the top of Bump(), you can use O.strength instead of usr.strength and it will work fine.
In response to Demon_F0rce
umm now i have another error.
src.Gowner:undefined var
In response to Cnsdddarrius
Did you read the error? An undefined var is a var that isn't defined - it doesn't exist.
In response to Demon_F0rce
but i have Gowner in my vars
In response to Cnsdddarrius
But is it a var that src can access? Is it defined as obj's var, a mob's var, a turf's var, an area's var, or an atom's var?
In response to Demon_F0rce
mob var
In response to Cnsdddarrius
Well what use is it there, when you're trying to use it as an obj var?
In response to Demon_F0rce
aw kool its fixed thanxs