ID:138964
 
Ok, so I was working on my new side scroller game, and I compiled with the following code:
obj
shuriken
icon = 'shuriken.dmi'
density = 1
Bump(A)
if(istype(A,/turf/))
var/turf/T = A
if(T.density)
del(src)
var/mob/M = A
M.HP -= 10
if(M.naruto == 1)
view(M) << sound('Naruto Damage.wav')
if(M.deidara == 1)
view(M) << sound('Damage.wav')
if(usr.dir == EAST)
M.dir = WEST
if(usr.dir == WEST)
M.dir = EAST
flick("damage",M)
view(M) << sound('shurikenhit.wav')
M.frozen = 1
spawn(4)
M.frozen = 0
M.DeathCheck()
del(src)

All vars are defined, as well as procs too. I get no errors, however, when it comes to runtime, when I execute the verb to throw the shuriken, when it collides (or Bumps) with the mob, it will take off HP from the mob, and even have the damage sound play, yet the flick() doesn't work, it doesn't change their dir, doesn't play the shurikenhit.wav to view(M), nor does it even do a DeathCheck().

Also, the big part to this is that it doesn't del() the obj as defined there.

So basically, my issue is, the proc is stopping at the damage sound for the character (usr << sound('Damage.wav')) however I haven't specified in the code for return.

Edit: I just added an output and found runtime errors:

Narutorox123456 (/obj/projectile/shuriken): Bump(NarutoNPC (/mob/NarutoNPC))
Narutorox123456 (/obj/projectile/shuriken): Move(the sky (50,40,1) (/turf/sky), 4)
runtime error: Cannot read 0.dir
proc name: Bump (/obj/projectile/shuriken/Bump)
usr: 0
src: Narutorox123456 (/obj/projectile/shuriken)
call stack:
Narutorox123456 (/obj/projectile/shuriken): Bump(NarutoNPC (/mob/NarutoNPC))
Narutorox123456 (/obj/projectile/shuriken): Move(the sky (50,40,1) (/turf/sky), 4)
runtime error: Cannot read 0.dir
proc name: Bump (/obj/projectile/shuriken/Bump)
runtime error: bad client
proc name: DeathCheck (/mob/proc/DeathCheck)
runtime error: Cannot read 0.dir


Just for clarification, this means that the shuriken or NarutoNPC (the mob being hit) has an invalid dir?

Edit2: I added a dir to NarutoNPC by putting:
New()
dir=EAST

Still no solution to it that way, and I even tried moving left right etc to change my dir and still no progress.</<>
You did not check if A was a /mob before defining M (this can lead to runtime errors if, for example, it hits in to an /obj)

And you cannot use usr here because it will not be defined (hence the 0). usr is defined as the /mob which ultimately called the verb/procedure and ... as you can see, there isn't one that directly called it.

Have a variable defined on the object which refers to the person that spawned it (ex: var/mob/owner and define the owner via New() or after creating the object)
In response to GhostAnime
GhostAnime wrote:
You did not check if A was a /mob before defining M (this can lead to runtime errors if, for example, it hits in to an /obj)

And you cannot use usr here because it will not be defined (hence the 0). usr is defined as the /mob which ultimately called the verb/procedure and ... as you can see, there isn't one that directly called it.

Have a variable defined on the object which refers to the person that spawned it (ex: var/mob/owner and define the owner via New() or after creating the object)

Ok, I'll try that right now.

Edit: Where did I use usr?

Edit2: I found it, now testing again.
In response to GhostAnime
GhostAnime wrote:
You did not check if A was a /mob before defining M (this can lead to runtime errors if, for example, it hits in to an /obj)

And you cannot use usr here because it will not be defined (hence the 0). usr is defined as the /mob which ultimately called the verb/procedure and ... as you can see, there isn't one that directly called it.

Have a variable defined on the object which refers to the person that spawned it (ex: var/mob/owner and define the owner via New() or after creating the object)

Thanks so much! You really helped me out a lot here!