ID:142314
 
Code:
short and sweet deathcheck
mob
proc
deathcheck(mob/M)
if(hp<=0)//If the health is less than 0.
world<<"[M] has died at the hands of [src] "
M.loc = locate(50,50,1)
M.hp = M.mhp
else

piece of attack proc
                        src<<"You shot [M]!" //
M.hp -= rand(12,17)
src.deathcheck(M)

Problem description:.
well.... when attacking, the mob doesnt die. i have NO idea why. this DC works for other things. jst not this ;/
Your problem is that In the deathcheck(), your if() statement should be
if(M.hp<=0)

otherwise it'll check to see if the src is dead.
You have your deathcheck proc back to front. An important concept in object orientated programming is that an object's procedures apply and relate directly to itself (and for that matter, its verbs, variables etc.).

If I were to have a swim procedure, it would concern the act of me swimming. If I had an attack procedure, it would concern the act of me attacking someone else.
If I had a dying procedure, it would concern the act of me dying (presumably at the hands of someone else, assuming it wasn't a natural death).

If you look at your deathcheck, you'll see you've got it reversed. The deathcheck belongs to src, but the person who is actually dying is M, the would-be murderer!

You're going to have to redesign it so it kills off src, not M (you've actually already got that half way done: the if statement checking the hp is below (or equal) to 0 defaults to src.hp, so that line is fine. It's the rest you have to look at).

Once you've fixed your deathcheck, go back to your attack proc and sort that out too. If your deathcheck procedure is in working order, you'll see where you've gone wrong when invoking src.deathcheck(M).
In response to Giantpandaman
Sorry, that's not quite correct. Though it would "fix" the code, it'd simply be reinforcing a bad design choice, thus making the entire game worse off.
From then on he'd have to program his game around the idea that someone's deathcheck kills off other people (which makes no sense. Why would "my" deathcheck kill *you*? My deathcheck should apply to me and me alone), which'll just cause headaches and all sorts of other horrid things.

Remember: just because it just seems to work doesn't mean it actually does! :)
In response to Giantpandaman
buahhahaha roflol i overseen that one lmfao. thx for noticing this for me. ;) rep++
In response to Elation
elation youre a sicko 0.o


dude rly.



and im a sicko too. got to cut up on that booze a bit -.-