Author Sticky: Post Working Scripts Here
jamos Posted: Tuesday, 25 June 03:28PM
Bleeding to death 3rd Edition Rules Script:

ok it works good if you have more than one person bleeding to death there may be a skip in who loses hitpoints first in the next round..not sure how it will work with more than one person dying..probably going to modify it using get first get next pc functions in the future so i handle all pcs in the same round.

put this in your heartbeat event for your module...
NWScript:
void main()

{

// set object to dying pc

object oPC = GetLastPlayerDying ();

// set name to PC's name

string sName = GetName (oPC);

// check to see if pc is dying

if ( GetIsObjectValid (oPC) == TRUE)

{

// check current hitpoints..if the pc has been healed then stop bleeding

  if ((GetCurrentHitPoints (oPC) > GetLocalInt ( oPC, "iCurrhp"))

  && (GetLocalInt (oPC, "iDying") == 1))

  {

  SetLocalInt( oPC, "iDying", 0)  ;

  // display text string to all players in faction.

  string sCurrhp = IntToString ( GetCurrentHitPoints(oPC));

  FloatingTextStringOnCreature( sName + " Has Stabilized By Healing at " + sCurrhp + " HPs", oPC, TRUE) ;

  if  (( GetCurrentHitPoints( oPC) <= 0) &&   ( GetLocalInt (oPC, "iDying") == 0 ))

  {

   // Popup gui panel that lets a stabilized pc respawn or wait (note: no way of getting panel back if you hit wait)

   DelayCommand(2.5, PopUpDeathGUIPanel( oPC, TRUE, TRUE, 0, "You Stabilized By Healing, If You Respawn You Will Lose Some Experience!"));

  }

  }

  // if pc is still bleeding he has a 10% chance to stabilize

 if ( GetLocalInt( oPC, "iDying") == 1)

 {

 int oDieroll = d100 (1) ;

 string sDieroll = IntToString ( oDieroll);

 // show stabilize roll results for each round

 FloatingTextStringOnCreature( sName + " Stabilize Roll: " + sDieroll, oPC, TRUE) ;

 if (oDieroll > 1 && oDieroll <=10 &&  GetLocalInt(oPC, "iDying") == 1 )

 {

  SetLocalInt(oPC, "iDying", 0)  ;

  // display text string to all players in faction.

  string sCurrhp = IntToString( GetCurrentHitPoints( oPC));

  FloatingTextStringOnCreature(sName + " Has Stabilized at " + sCurrhp + " HPs", oPC, TRUE) ;

  // Popup gui panel that lets a stabilized pc respawn or wait (note: no way of getting panel back if you hit wait)

  DelayCommand(2.5, PopUpDeathGUIPanel(oPC, TRUE, TRUE, 0, "You Stabilized, If You Respawn You Will Lose Some Experience!"));

 }

 }

 if (GetLocalInt(oPC, "iDying") == 1)

 {

 // pc is still bleeding add one point of damage

 effect eDamage = EffectDamage( 1, DAMAGE_TYPE_MAGICAL, DAMAGE_POWER_PLUS_FIVE);

 ApplyEffectToObject ( DURATION_TYPE_INSTANT, eDamage,  oPC);

 SetLocalInt( oPC, "iCurrhp", GetCurrentHitPoints( oPC));

 string sCurrhp = IntToString( GetCurrentHitPoints( oPC));

 // display text string to all players in faction until pc is dead.

 if ( GetCurrentHitPoints( oPC) > -10)

 {

 FloatingTextStringOnCreature( sName + "  is Bleeding! Hitpoints currently at " + sCurrhp, oPC, TRUE) ;

 }

 }

 }

}



the popup death panel appears when you stabilize (if anyone could kindly make a pop up gui panel that doesnt say your dead on it i would appreciate it). if you choose wait for help when your stabilized you will not be able to respawn later because the panel goes away!!! if anyone can tell me how to map a hotkey to a user defined event i could fix that problem.
as in d&d rules ive given you a 10% chance of stabilizing on your own each round. also if someone heals you but you still dont get up(ie 0 to -9 hitpoints) you stabilize also.

Important: make sure to add

NWScript:
SetLocalInt( oPC, "iDying", 0)  ;


to end of on death script to clear out the iDying flag or you will continue to lose hit points after you respawn..hehee