ID:139976
 
Code:
Projectile()//a long range attack, which will follow hit your target only.
if(!usr.targeting)
usr<<"Target someone you'd like to throw projectile at."
return
else
var/mob/j = usr.Tgt
if(j in oview(usr,usr.client.view))//This checks if your target is in your view, so that it might not follow your target from map to map
var/obj/Energyball/K = new /obj/Energyball
K.owner = usr
K.loc = usr.loc
K.power = usr.power
K.elvl = usr.elvl
K.money =usr.money
K.kills = usr.kills
K.name = "[usr]"
K.owner = usr
walk_towards(K,j.loc)
sleep(15)
del(K)
obj
Energyball
icon = 'Attacks.dmi'
icon_state = "energy ball"
density = 1
Bump(A)
if(ismob(A))
var/mob/M = A
var/damage = round(src.power*src.elvl)
if(damage >= 1)
M.hp -= damage
view(M) << "[M] was hit by Energyball for [damage] damage!!"
M.deathcheck()
del(src)
if(istype(A,/turf/))
var/turf/T = A
if(T.density)
del(src)
if(istype(A,/obj/))
del(src)

else
M << "You killed [src.name]."
M.money+=src.money
M.exp+=src.exp
M.kills++
oview(M) << "<font color=red><b>[M.name] killed [src.name]."
sleep(5)
del(src)


Problem description: The first part of the the code, is the verb, second part, the obj, third part, the deatcheck.

When I use the melee attack, same enemy, it works just fine, but when the projectile is used, it doesn't due to the code not being able to process any of the killer's variables such as money, kills or exp. I've tried to combat that by giving the obj those varaibles but still not working. This also works on a targeting system that works fine and if you take out all lines from deathcheck besides del(src) it works just fine. Please help.

You are not passing an argument to deathcheck(). It should be M.deathcheck(src.owner).
Also, for less CPU usage, you should make the projectile's location null instead of deleting it.
In response to Darkjohn66
That makes no sense what-so-ever, John. Deleting it frees up memory, while changing its loc to null would just keep it in memory.
In response to Warlord Fred
The garbage collector will take care of it (hint: look it up in the DM reference).
In response to Warlord Fred
Lummox JR explained more on this just recently.
In response to Garthor
Thank you Garthor. I wasn't passing an argument like you said and I was naming the deatcheck proc wrong.

M.deathcheck(src.owner)

deathcheck(mob/M)

was the solution. I feel retarded now...