ID:139801
 
Code:
obj/var/tmp
walk = 0
speeding
Move_Delay = 0
Gowner=""
target=""

obj
Ki_Blast
verb
KiBlast()
set category = "Fighting"
set name = "Ki Blast"
if(usr.Doing)
return
if(usr.Firing)
return
if(usr.Frozen)
usr<<"You are frozen."
return
if(usr.Resting)
usr<<"Not while resting."
return
if(usr.Meditating)
usr<<"Not while meditating."
return
if(usr.flying)
usr<<"Not while flying."
return
if(usr.Ki < 10)
usr<<"You need more ki."
return
else
usr.Ki -= 10
usr.Firing = 1
usr.Doing = 1
usr.Frozen = 1
view()<<"<font color = blue>[usr]: Ki Blast!"
var/obj/KiBlast/K = new /obj/KiBlast
K.loc = usr.loc
K.dir = usr.dir
K.Move_Delay=2
K.name="[usr]"
K.Gowner=usr
walk(K,usr.dir)
if (target == null)
del(K)
sleep(5)
usr.Firing = 0
usr.Doing = 0
usr.Frozen = 0
sleep(50)
del(K)

obj
KiBlast
icon = 'Techs.dmi'
icon_state = "Ki Blast"
density = 1
Bump(A)
if(ismob(A))
var/mob/M = A
var/damage = 25
if(damage >= 1)
M.PL -= damage
view(M) << "[M] was hit by [usr.name]'s ki blast for [damage] damage!!"
var/mob/O = src.Gowner
M.DeathCheck(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 get this error...

runtime error: Cannot read 0.name
proc name: Bump (/obj/KiBlast/Bump)
usr: 0
src: Zanshin (/obj/KiBlast)
call stack:
Zanshin (/obj/KiBlast): Bump(Bunny {Weak}(1) (/mob/EnemyNPCs/Animals/Bunny))
Zanshin (/obj/KiBlast): Move(Dragon Ball Aftersight (79,13,2) (/turf/Earth/Grass), 4)

I dont understand.
Diablohunter17 wrote:
Problem description:

I get this error...

runtime error: Cannot read 0.name

The problem is that you are using usr in your Bump() proc. It is unsafe to assume usr to be 'the user' in procs, while in verbs, it's generally set to the mob of the client who used the verb (unless it's called as a proc).

[Edit] I missed a few lines of your code, you're storing the owner so the problem is that you're using 'usr' in your output statement. Changing it to src.Gowner.name should work. However, you should still use the if statement to check if Gowner didn't log out.

You will have to store the owner of your Ki_Blast (ie. the player that fired it) in the actual object to reference it properly, and then validate your data accordingly (like, considering the fact that the user may log out before the blast hits anything)

// When creating the Ki Blast, in the context of your verb, 'usr' is safe to use

// Pass in the owner of the blast, which is the user who fired it (usr in this case) through the second argument for storage
var/obj/blast/B = new /obj/blast (usr.loc, usr)
// ...


obj/blast
var/mob/owner
New(_loc, _owner)
. = ..()
// store the owner of the blast, specified through the second arg in New() which we define above, for later usage
src.owner = _owner

// ...

Bump(A)
// ...
if( ... )
var/mob/M = A
// In this context, we can use src.owner to correctly reference who actually shot the blast
// But we can't guarantee src.owner exists (they may have logged out), so we need another if statement
if(src.owner)
world << "[src.owner] shot a ki blast at [M]"
There are many issues with the programming here. Regardless, it looks like you either have Zero and the letter 'O' confused, or you are trying to access a variable from the source (/obj/Ki_Blast) called Gowner that is nonexistent. May I suggest you start off with these articles?
In response to Unknown Person
The blast itself does shoot, its just when it actually hits the bunny it freezes and them errors pop up like 20 times.
In response to Diablohunter17
I missed the Gowner variable in your code, so I edited my post. The problem is that you're using 'usr.name' in the situation where you can't rely on it.
In response to Unknown Person
Wow I feel so dumb right now but this isnt really making sense...
In response to Diablohunter17
Essentially, looking at this line:

view(M) << "[M] was hit by [usr.name]'s ki blast for [damage] damage!!"


You are using usr.name when you should be using src.Gowner.name. usr is unreliable in the context of a proc, and you already have the owner defined for you to use, so you should be using it.

Another problem is that you're assuming Gowner is a valid mob, when certain things, such as the user logging out, can destroy that assumption. You will want to verify that Gowner exists (a simple if statement) before you do anything.

// Being paranoid, but we can guarantee data validity as well
if(ismob(src.Gowner))
...


You also don't need that if(istype(A, /turf)) line, since Bump() is called when it hits a dense object, and you can be reasonably sure that Bump() won't be called on a non-dense object (unless you do it yourself, which you hopefully probably aren't). You also do not need to check if it's an obj for similar reasons explained above.
In response to Diablohunter17
You need to start off very basic. Even if you don't want to learn in a reading matter, there are shorter documents that you can combine with a methodology of trail and error. Reading something such as Zilal's tutorials can help you start off making something neat, and you can build upon it by looking up items in the reference. I suggest also reading this to learn about boolean operators.