ID:272685
 
I wasn't sure if this would go somewhere else, so I picked the one I thought it would mostly go under. My question is pretty much said in the Topic name.

obj/Weaponry
density = 1
layer = MOB_LAYER
Kunai
name = "Kunai"
icon = 'Kunai.dmi'
Bump(A)
var/mob/O = src.Owner
if(istype(A,/mob/))
var/mob/M = A
var/dmg = round(O.KunaiSkill + O.Taijutsu)
M.Health -= dmg
view(M)<<"[M] was hit by a [src] for [dmg]"
M.Death(O)
if(istype(A,/obj/))
var/obj/X = A
if(X.density)
del(src)
if(istype(A,/turf/))
var/turf/T = A
if(T.density)
del(src)
verb
Drop()
for(var/obj/Weaponry/Kunai/K in usr.contents)
if(K.Amount < 1)
del(src)
else
var/drop = input("How many do you want to drop?\nYou have [src.Amount] [src]","Drop") as num|null
if(drop < 1 || drop > src.Amount) return
src.Amount -= drop
var/obj/Weaponry/Kunai/D = new/obj/Weaponry/Kunai
D.loc = locate(usr.x,usr.y,usr.z)
D.Amount = drop
if(src.Amount == 0)
del(src)
usr.AutoSave()
Get()
set src in oview(1)
for(var/obj/Weaponry/Kunai/K in usr.contents)
Amount += 1
if(Amount < 1)
Move(usr)
else
for(var/obj/Weaponry/Kunai/X in usr.contents)
X.Amount = src.Amount
X.name = "[src] ([X.Amount])"
del(src)
usr.AutoSave()
Code what, exactly ?

I noticed a few things just by skimming through it.

                        var/obj/Weaponry/Kunai/D = new/obj/Weaponry/Kunai
D.loc = locate(usr.x,usr.y,usr.z)

// should be

var/obj/Weaponry/Kunai/D = new(usr.loc)


Lack of boolean variables.(DROP() verb)
In response to Andre-g1 (#1)
Is that the only improvement I could make to this snippet?
In response to Mizukouken Ketsu (#2)
You can also avoid all of the typecasting(except the mob one) by making the Bump() argument, atom/A.
In response to Andre-g1 (#3)
Like that?
       Bump(atom/A)
var/mob/O = src.Owner
if(istype(A,/mob/))
var/dmg = round(O.KunaiSkill + O.Taijutsu)
A.Health -= dmg
view(A)<<"[A] was hit by a [src] for [dmg]"
A.Death(O)
if(istype(A,/obj/))
if(A.density)
del(src)
if(istype(A,/turf/))
if(A.density)
del(src)
In response to Mizukouken Ketsu (#4)
It should error you on the mob if I'm not mistaken.
In response to Andre-g1 (#5)
Oh okay I reread your previeous post and I got it. Thanks.
([link])
Ended up with 2 topics with the same code, eh. >,>
In response to Kaioken (#7)
Ha. Yeah, I guess. Only the other one is the one where I had a coding problem. The one on here is for "improvements" xD. Looks like you did both in one post and just posted in the thread you happened to be in ;p