D and D rules dying script
From NWNWiki
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, the character is dying. Every round, the PC has a 10% chance of stabilizing. At -10, your charater is dead.
In this script, after you stabilize you also will have a 33% chance of continuing to heal 1 point, up to a total of 1 hit point. When that occurs, the character recovers and can act normally.
This script will also work when the player is at exactly 0 HP. I did this so that a player need not wait and watch the character's unconcious body until friends find the character. This way the PC either slowly bleeds to death, or recovers 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.
[edit] The script
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 OnPlayerDying event script. (This is very important.)
[edit] OnEnter
void main()
{
object oPC = GetEnteringObject();
SetLocalString(oPC, "sBleeding", "True");
}
[edit] 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());
}
}
