Author Sticky: Post Working Scripts Here
jamos Posted: Tuesday, 25 June 11:19PM
1: Final Version of Bleeding to Death 3rd edition script

look previous post above for description on how to code this script. it now accounts for all pcs in game by using a while loop to check nextpc. dont forget to set the idying local varible to 0 at end of dying script.

NWScript:
// custom function that is called by main if pc is valid and not dying

void pcdying (object oPC)

{

// set name to PC's name

string sName = GetName (oPC);

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

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

  {

  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

 SendMessageToPC ( oPC, " Stabilize Roll: " + sDieroll);

 if ( 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 Self 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 Self 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) ;

 }

 }

 }

void main()

{

// enumerate all PCs, check to make sure they are dying before executing functions

object oPC = GetFirstPC ();

while ( GetIsObjectValid (oPC))

{

// only call user defined function if pc is dying then enumerate

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

{

pcdying (oPC);

}

oPC = GetNextPC ();

}

}
Author Sticky: Post Working Scripts Here
jamos Posted: Wednesday, 26 June 01:37PM
1: Second part for Bleeding Script omitted from before:

sorry you need to use this script in your module on dying event to get the on bleeding script to work properly:

NWScript:
void main()

{

object oDying = GetLastPlayerDying() ;

SetLocalInt(oDying, "iDying", 1) ;

}
Author Sticky: Post Working Scripts Here
jamos Posted: Wednesday, 26 June 02:48PM
1:Ok third part to the bleeding script above.
you need to add this to the onrespawn event..put it right after the last else statement in the default script. if you dont you'll automatically respawn after the first time you respawn. you can also put this anywhere after the oRepawner is set.

NWScript:
SetLocalInt(oRespawner, "iCurrhp", GetCurrentHitPoints(oRespawner));