When i use this code...
DeathCheck(mob/M)
if(!src)
oview() << "DFJSD"
return
if(istype(src,/mob/Monster))
NPCDeathCheck(src)
goto END
if(M.HP <= 0)
if(M.Dead)
world << "[src] has killed [M] in battle!"
M << "You have died! You lost half of your gold."
M.icon_state = "Dead"
M.Locked = 1
M.Dead = 1
M.density = 0
sleep(50)
M.loc = locate("[M.LastCity]respawn")
M.Locked = 0
M.density = 1
else
..()
END
It works for the NPC. But when i attack a client it doesn't work, but when i attack an NPC, it works. Any problem with this?
ID:261716
Jan 30 2003, 12:04 pm
|
|
DeathCheck() RaeKwon |
In response to RaeKwon
|
|
RaeKwon wrote:
DeathCheck() Actually that'd be "[M] has killed [src]", except you never specified M:
DeathCheck(mob/M) // M is the killer, src the victim
Lummox JR |
In response to Lummox JR
|
|
Lummox JR wrote:
RaeKwon wrote: DeathCheck() Actually that'd be "[M] has killed [src]", except you never specified M:
DeathCheck(mob/M) // M is the killer, src the victim
Lummox JR Oops, or world<<"[usr] has killed [src] in battle!" usr is the killer, src is the victim. Works great =) RaeKwon |
In response to RaeKwon
|
|
RaeKwon wrote:
Oops, or world<<"[usr] has killed [src] in battle!" usr is the killer, src is the victim. Works great =) Except for the fact that it doesn't, since this is in a proc and usr has no place there. Lummox JR |
In response to Lummox JR
|
|
Lummox JR wrote:
Except for the fact that it doesn't, since this is in a proc and usr has no place there. Yeah, it works, i've used this in Zeta from Day 1. DeathCheck() // There is more but I cut it off. RaeKwon |
In response to RaeKwon
|
|
usr doesn't belong in procs.
|
In response to RaeKwon
|
|
RaeKwon wrote:
Yeah, it works, i've used this in Zeta from Day 1. Who gives a crap if it's worked in the past? Point is, usr is unsafe in procs unless the proc is only ever called by a verb where usr is a known value. For safety's sake, it's better never to put usr in a proc at all. It's safest to restrict usr only to verbs, and have them call procs with additional vars if necessary. It may "work" for you in your particular program, but export that DeathCheck() to any other program and it could introduce a host of difficult-to-trace errors. And the practice of putting usr in procs in general is just boneheaded, and shouldn't be encouraged. In essence right now we're partly paying for your bad programming practices because these idiots asking for help on ripped Zeta code keep re-introducing errors into the community. Granted you never meant that code to get out, but I use this just to illustrate how one mistake can beget hundreds. It's bad enough to program in bad code in the first place, but to tell others to use it when you know better is asinine. To put it bluntly: Don't go telling people to replace a var that should be in their proc with usr, which pretty much shouldn't be in any proc. DUH! Lummox JR |
Yes, lots.
Lummox JR