ID:142079
 
Code:this is a death()
mob
proc
Death(mob/M)
if(src.health <= 0&&src.NPC==0)
world << "<font color=red>[M] killed [src].</font color>"
src.Deaths += 1
M.kills += 1
M.doing=0
src.loc = locate(1,1,1)
sleep(50)
src<<"You'll be brought back in 5 seconds..."
src.health = src.maxhealth
return


Problem description:when i try to kill someone it works but it announces that NPC has kill NPC! WHY IS IT DOING THAT IF ITS M AND src
I even tried to reinstall byond

Trane5 wrote:
Problem description:when i try to kill someone it works but it announces that NPC has kill NPC! WHY IS IT DOING THAT IF ITS M AND src

No need to shout. >_> M is a variable (proc argument/parameter) that is passed from outside, so you're probably supplying the wrong one; we need to use the code where you're actually calling the Death() proc.
Also, there are little problems in your code. Don't use if(var==1) to check if it's true, if(var) already checks that, the former just runs the == operator then tests if it returned true as normal, but you don't need to check for a specific value, so just use if(Var) to check if Var is true.
Lastly, use the ++ and -- operators to increase or decrease a variable by 1. No major difference here, but they're just a bit faster than using += (and they also have an additional function, though of no use in this particular case).
Oh, and HTML tags are closed by just the base tag with / at the beginning, but with no attributes. What I mean is, no matter how many attributes your <font> tag has (color, face, size...), you close it with no attributes - just </font> only.

I even tried to reinstall byond

Well, that's not going to solve any Code Problems.
In response to Kaioken
Basically

death(var/mob/m)
if(src.health <= 0)
world << "[m] killed [src]"
del(src) //bye bye R.I.P.
else world << "[m] is weak, [src] lived to tell the tale!"


And now for how to call it:

k.death(m)

were "k" is the mob who you check is death (or not) and "m" the person who killed him or atleast took a shot at killing him.

As a result it could be something like this:
mob/verb/hit()
set src in oview(1)
src.health --
src.death(usr)




In response to Fint
I did that but this always comes up

runtime error: undefined variable /obj/fire/FireBall/var/kills
proc name: Death (/mob/proc/Death)
usr: 0
src: NPC (/mob/FireLord)
call stack:
NPC (/mob/FireLord): Death(Trane5 (/obj/fire/FireBall))
Trane5 (/obj/fire/FireBall): Bump(NPC (/mob/FireLord))
In response to Trane5
send a snip and ill fix your code
In response to Trane5
You're trying to say that an object killed it, when only a mob should be able to kill things. You should make sure that M is always a mob with the ismob() proc.
In response to Opop1
<code> obj whip icon = 'Waterwhip.dmi' start icon_state = "start" layer = MOB_LAYER+1 head icon_state = "Tip" density = 1 var/mob/Z New(location, owner) Z = owner ..() Bump(atom/a) if(ismob(a)) var/mob/M = a var/damage = round(Z.bendingpower*1.5) M.health -= damage M.Death(M) sleep(10) del(src) var/turf/last = null New() last = loc Move() last = loc . = ..() if(.) if(x == 1 || x == world.maxx) del src if(y == 1 || y == world.maxy) del src var/obj/t = new/obj/whip/whiptrail(last) t.dir = dir whiptrail icon_state = "Body" New() spawn(2) del src </code>

when i try to chage M.Death(M) to src.Death(usr) it says death undefined proc
In response to Jeff8500
He wasn't typecasting, he needed to have the mob who made the src defined, then put that in with M.
In response to Trane5
The problem on the line I commented is that you passed to the Death proc the same mob calling it. So it's not a surprise why in your output, the one that killed the mob is itself.

        head
icon_state = "Tip"
density = 1
var/mob/Z
New(location, owner)
Z = owner
..()
Bump(atom/a)
if(ismob(a))
var/mob/M = a
var/damage = round(Z.bendingpower*1.5)
M.health -= damage
M.Death(M) // one problem is here
sleep(10)
del(src)


This is just a quick snippet.

obj/whip
var/mob/owner
density = 1

New(mob/M) // override new proc
src.owner = M // assign M as src.owner
spawn(100) del(src) // delete obj after 10 sec
..()

Bump(atom/A)
if(ismob(A)) // if the bumped atom is a mob
var/mob/M = A
var/damage = rand(1,10)
M.health -= damage
M.Death_Check(src.owner) // call the bumped mob's Death_Check proc ...
del(src) // and pass the obj's owner
..()

mob
var
health = 50
verb
Whip()
var/obj/whip/W = new(src) // pass src to the obj's new proc to assign as obj's owner
switch(src.dir)
if(NORTH)
W.loc = locate(src.x,src.y+1,src.z)
if(SOUTH)
W.loc = locate(src.x,src.y-1,src.z)
if(WEST)
W.loc = locate(src.x-1,src.y,src.z)
if(EAST)
W.loc = locate(src.x+1,src.y,src.z)
walk(W,src.dir,2)

proc
Death_Check(var/mob/Attacker) // mob/Attacker is the obj's owner passed in the Death_Check proc
if(src.health <= 0)
world << "[Attacker] killed [src]!"
del(src)
else
world << "[src] was hit by [Attacker]"


Hope this helps ^^