Recent changes Random page
GAMING
Gaming
 
WoWWiki
Halopedia
FFXIclopedia
Age of Conan
Warhammer Online
Grand Theft Wiki
See more...

D and D rules dying script

From NWNWiki

Jump to: navigation, search

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.

Contents

[edit] The script

You will need two scripts.

[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());
           }
}

[edit] Possible bug

Because 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 the other sits there; when one PC is resolved, the script 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.

Rate this article:
Share this article: