D and D rules dying script

What it does
This little script I made mimics the way that dying is explained in the D&D Player's Handbook. It states that between -1 and -9, you are dying. Every round you have a 10% chance of stabilizing. At -10, your dead. In this script, after you stabilize you also will have a 33% chance of continuing to heal 1 point, up to 1 hit point. At that point you recover and of course can act normally. This script will also work when the player is at exactly 0 HP. I did this so a player won't have to sit there watching his unconcious body until his friends come and find him. This way you either slowly bleed to death, or you will recover within about 5 minutes or less. If you want to make recovery faster or slower, feel free to change the numbers around to suit your needs. If you need a major change to this script let me know and I will see what I can do.

Note
You will need two scripts. The first one goes into the module's OnEnter event. The second goes into the module's OnHeartbeat event. Also remember to blank out the default OnDying script event (VERY IMPORTANT).

== The Script

onEnter
void main { object oPC = GetEnteringObject; SetLocalString(oPC, "sBleeding", "True"); }

Onheartbeat
/*Created by Fadedshadow 8/28/02. Feel free to modify,pirate,or whatever to suit your needs. */ void main {   object oPC = GetLastPlayerDying; int nHitPoints = GetCurrentHitPoints(oPC); effect eHeal = EffectHeal(1); effect eDamage = EffectDamage(1,DAMAGE_TYPE_MAGICAL,DAMAGE_POWER_PLUS_FIVE); string sDying = "Help ! I'm dying !"; string sStable = "I've stablized."; string sRecover = "I have recovered."; /* You can make this 0 so the pc will stay unconcious until healed by someone else. */   if (nHitPoints < 1) {       if (nHitPoints > -10) {           int nRoll = (Random(100)); if (GetLocalString(oPC,"sBleeding") == "True" && nRoll <=10) {               ApplyEffectToObject(DURATION_TYPE_INSTANT, eHeal, oPC); AssignCommand(oPC,SpeakString(sStable)); SetLocalString(oPC, "sBleeding","False"); if (GetCurrentHitPoints(oPC) >= 1) {                       SetLocalString(oPC, "sBleeding","True"); }               }             if (GetLocalString(oPC,"sBleeding") == "True" && nRoll > 10) {               ApplyEffectToObject(DURATION_TYPE_INSTANT, eDamage, oPC); AssignCommand(oPC,SpeakString(sDying)); }            if (nRoll <=33 && GetLocalString(oPC,"sBleeding") =="False") {               ApplyEffectToObject(DURATION_TYPE_INSTANT, eHeal, oPC); }            if (GetCurrentHitPoints(oPC) >= 1) {               SetLocalString(oPC, "sBleeding","True"); AssignCommand(oPC,SpeakString(sRecover)); }           }        }

if(GetCurrentHitPoints(oPC) <= -10) {          effect eDeath = EffectDeath(FALSE, FALSE); ApplyEffectToObject(DURATION_TYPE_INSTANT, eDeath, GetLastPlayerDying); } }

Possible bug
Since this script uses the GetLastPlayerDying function, I do not know what will happen if two or more PCs are dying at the same time. It appears to me that it will handle one PC while that other sits there, and then when one PC is resolved, it will move on to the next PC. Not a super problem since hopefully you won't have mobs of PCs dying, but you may want to know of this if you decide to use it.