mob
var
life = 100
strength
defence
proc
DeathCheck()
if (life <= 0)
world << "[src] dies a horrible, bloody death!" //give the death messaging
del src
Problem description:
In testing, people never die, they just move right on to negative health
ID:141348
Apr 4 2009, 10:27 am
|
|
Code:
mob Problem description: In testing, people never die, they just move right on to negative health |
In response to GhostAnime
|
|
mob Just a little test I ran. Works fine for me. |
In response to ArcaneDragonX
|
|
While it works; Don't ever implement it that way. Hell, If you insist on using such a small deathcheck, why not stuff it in a DEFINE; Saves another function call..
I stand by GhostAnime's suggestion on AddHP(value,[CheckDeath?]) functions. |
In response to Xeronage
|
|
Xeronage wrote:
While it works; Don't ever implement it that way. Hell, If you insist on using such a small deathcheck, why not stuff it in a DEFINE; Saves another function call.. I'd advise using #defines for the rather more abstract (like mere calculations) or small-time operations that don't effect much in the world. Something like a DeathCheck() is better done with an object proc to be tidier and take advantage of OOP (not to mention these can easily be more complicated than a single if() statement). Here are some classic examples of utilizing OOP with DeathCheck() (also splitting the proc into an also-recommended Die() proc). mob/person I stand by GhostAnime's suggestion on AddHP(value,[CheckDeath?]) functions. Same here, so consider it Thirded. ;D One proc that sets HP (up/down) and then makes sure it's within bounds (could be optional with an argument) is much more robust and flexible, and is also a useful hook. |
You should modularize your program. Have a procedure like TakeHP(dmg = 0) which calls Deathcheck() after dealing damage.