ID:1168903
 
Keywords: mitz001, projectile, usr
(See the best response by LordAndrew.)
Code:
obj
Ybeam
icon = 'Yoton Yokai No Jutsu.dmi'
icon_state = "head"
pixel_x = -32
pixel_y = -32
layer = 100
density = 0
Bump(A)
if(istype(A,/turf/))
var/turf/T = A
if(T.density)
del(src)
if(istype(A,/obj/))
New()
del(src)
Move()
for(var/mob/M in src.loc)
var/damage = 100
M.health -= damage
world <<"[M] got hit by [usr]'s Yoton Yokai No Jutsu for [damage] damage!"

var/K = new/obj/Tail1(src.loc)

K:dir = src.dir
..()


Problem description:

The 'text' appears as

The mob got hit by 0's Yoton Yokai No Jutsu for 100 damage!

Instead of

The mob got hit by (Name)'s Yoton Yokai No Jutsu for 100 damage!

How do I fix it :(

Best response
Several things:

For your istype(A,/turf/) and istype(A,/obj/) calls, you can just use the built-in procedures isturf(A) and isobj(A).

Secondly, you should never call New() directly as you're doing in Bump(), though I'm not even sure what you're trying to accomplish in the first place with that.

On the subject of Bump(): It will never be called, because your projectile isn't dense. Bump() is only called if the source object is dense and it runs into another dense object.

usr is not valid in obj.Move(), which is why it is saying "0" instead of a name. If you want to tie an obj to a player, you'll need to create a variable that stores a reference to the person that fired the projectile.

Move is a bit of a weird choice to handle if the projectile has "stepped on" a player, as Crossed() will do the same thing with a bit more finesse.

Finally, you don't need to use the : operator as you're doing there. Simply doing var/obj/Tail1/Tail1 = new(src.loc); Tail1.dir = src.dir would suffice.
In response to LordAndrew
LordAndrew wrote:

usr is not valid in obj.Move(), which is why it is saying "0" instead of a name. If you want to tie an obj to a player, you'll need to create a variable that stores a reference to the person that fired the projectile.

Can you give me an example for this, I'm not very familiar with these codes by far, since I'm still learning how to code properly atm ^^

In response to Mitz001
Something like:
obj
projectile
var/mob/owner

New(mob/m)
owner = m

loc = owner.loc
dir = owner.dir

ybeam
Crossed(mob/m)
// If you cross a non-mob, do nothing.
if(!ismob(m)) return

world << "[owner]'s [src] has struck [m]!"

(Untested, though it should get across the idea.)