ID:146926
 
My Death proc is called every time someone attacks, but i found out that was a bad way to call it, because sometimes it is called 3 times, and i get 3 times the XP/Money. What would be a better way to call it, or is there a way to make sure it only works once?
Need to show some code if you want help
In response to Soldierman
mob
proc
Death(mob/M)
if(src.client)
Playerdie()
else
if(src.Hp<=0)
view()<<"<b><font color=White>[src] has been killed by [usr]!"
usr<<"<b><font color=White> You got<i>[src.expgive] Exp and<i>[src.goldgive] Gold!"
GlobalRepopWithDelay()
usr.exp += src.expgive
usr.Gold += src.goldgive
Levelup()
del(src)
Playerdie(mob/M)
if(src.Hp<=0)
world<<"<b><font color=White>[src] has been killed by [usr]!"
usr<<"<b><font color=White> You got<i>[src.expgive] Exp and<i>[src.goldgive] Gold!"
src<<"<b><font color=White> You have been Killed by [usr]"
usr.exp += src.expgive
usr.Gold += src.goldgive
src.loc = locate(50,50,1)
src.Hp = src.Max_Hp
GlobalRepopWithDelay()
In response to Takaru
No put usr in proc. Ungh.

Lummox JR
In response to Takaru
What's the point in having mob/M in the parenthasis if you dont use M at all? In this case M should be "src" and usr should be src?
In response to Dession
Dession wrote:
What's the point in having mob/M in the parenthasis if you dont use M at all?

Indeed.

In this case M should be "src" and usr should be src?

No, and no.

Lummox JR
In response to Lummox JR
I mean the M should be the src..Like instead of src put M..
In response to Dession
Dession wrote:
I mean the M should be the src..Like instead of src put M..

Still no.

Lummox JR
In response to Lummox JR
No I'm not if you do it properly..
In response to Dession
Dession wrote:
No I'm not if you do it properly..

The only proper way to handle a DeathCheck() proc is to make src the victim--as in this code--and pass the killer as an argument. Where this code is failing is in not passing the argument, and then not using it, even though the argument is there.

Changing around Death() so it operates mainly on M is the wrong approach. Death is a function of an individual, and anyone else involved is secondary. The construction of your proc should reflect that.

Lummox JR
In response to Lummox JR
Yeah, ok, i fixed that pretty much, but will that fix the multikilling thingy too?
In response to Lummox JR
Lummox JR wrote:
Dession wrote:
No I'm not if you do it properly..

The only proper way to handle a DeathCheck() proc is to make src the victim--as in this code--and pass the killer as an argument. Where this code is failing is in not passing the argument, and then not using it, even though the argument is there.

Changing around Death() so it operates mainly on M is the wrong approach. Death is a function of an individual, and anyone else involved is secondary. The construction of your proc should reflect that.

Lummox JR


Well, actually, I agree with you; Death is a function of an individual; but "the only proper way"? I'm suprised at you: you even wrote part of the ByondBwicki page.
In response to Wizkidd0123
Wizkidd0123 wrote:
Well, actually, I agree with you; Death is a function of an individual; but "the only proper way"? I'm suprised at you: you even wrote part of the ByondBwicki page.

And yet nothing I said there contradicts what I said here. Just because some things can be done multiple ways doesn't mean all can. And while there are in fact many ways to code a correct DeathCheck() proc, all of them share the basics: src is the victim, and if the killer is at all important it should be passed as an argument. Those elements are inflexible to good (or heck, even mediocre) design.

Lummox JR
In response to Lummox JR
good point.