UW2_PRC8/_module/nss/bleeding.nss
Jaysyn904 f69e979e53 Updated event system
Added caller scripts to the PC events.  Full compile.  Updated release.
2023-11-13 13:16:17 -05:00

113 lines
4.1 KiB
Plaintext

//::///////////////////////////////////////////////
//:: Dying Script
//:: s_dying.NSS
//:://////////////////////////////////////////////
/*
This script handles the default behavior
that occurs when a character is dying. Dying
is when the character is between 0 and -9 hit
points; -10 and below is death. To use, redirect
the OnDying event script of the module to this script.
*/
//:://////////////////////////////////////////////
//:: Author : Scott Thorne
//:: Updated: July 25, 2002
//:://////////////////////////////////////////////
#include "nw_i0_tool"
void bleed(int iBleedAmt)
{
object oPC = GetLastPlayerDying();
if (!GetIsPC(oPC)){
return;
}
string ddVarName = "dd"+GetName(oPC);
object oModule = GetModule();
effect eBleedEff;
/* keep executing recursively until character is dead or at +1 hit points */
if (GetCurrentHitPoints() <= 0) {
/* a positive bleeding amount means damage, otherwise heal the character */
if (iBleedAmt > 0) {
eBleedEff = EffectDamage(iBleedAmt);
} else {
eBleedEff = EffectHeal(-iBleedAmt); /* note the negative sign */
}
ApplyEffectToObject(DURATION_TYPE_INSTANT, eBleedEff, OBJECT_SELF);
/* -10 hit points is the death threshold, at or beyond it the character dies */
if (GetCurrentHitPoints() <= -10) {
SetLocalInt (oModule, ddVarName, 1);
PlayVoiceChat(VOICE_CHAT_DEATH); /* scream one last time */
ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_IMP_DEATH), OBJECT_SELF); /* make death dramatic */
ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectDeath(), OBJECT_SELF); /* now kill them */
return;
}
if (iBleedAmt > 0) { /* only check if character has not stablized */
if (d10(1) == 1) {
/* 10% chance to stablize */
iBleedAmt = -iBleedAmt; /* reverse the bleeding process */
PlayVoiceChat(VOICE_CHAT_LAUGH);
/* laugh at death -- this time */
} else {
switch (d6()) {
case 1: PlayVoiceChat(VOICE_CHAT_PAIN1); break;
case 2: PlayVoiceChat(VOICE_CHAT_PAIN2); break;
case 3: PlayVoiceChat(VOICE_CHAT_PAIN3); break;
case 4: PlayVoiceChat(VOICE_CHAT_HEALME); break;
case 5: PlayVoiceChat(VOICE_CHAT_NEARDEATH); break;
case 6: PlayVoiceChat(VOICE_CHAT_HELP);
}
}
}
DelayCommand(6.0,bleed(iBleedAmt)); /* do this again next round */
}
}
void main()
{
object oDying = GetLastPlayerDying();
object oPlayer = GetLastPlayerDying();
object oPC = GetLastPlayerDying();
string ddVarName = "dd"+GetName(oPC);
object oModule = GetModule();
SetLocalInt (oModule, ddVarName, 1);
object hell = GetArea(oPlayer);
object helltest = GetArea(GetObjectByTag("Satan"));
if (hell == helltest){
DelayCommand(3.0, ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectResurrection(), oPlayer));
return;
}
object oHelm = GetItemInSlot(INVENTORY_SLOT_HEAD, oPlayer);
object oCrown3 = GetObjectByTag("ImmortalCrown2");
if(HasItem(oPlayer, "ImmortalCrown2")){
if ((oCrown3 == oHelm) && (oCrown3 != OBJECT_INVALID) && (oHelm != OBJECT_INVALID))
{
SendMessageToAllDMs("Immortal Crown has been unequipped from player.");
object claw1 = (GetItemPossessedBy(oPlayer, "immortaldagger1")) ;
DestroyObject(claw1);
object claw2 = (GetItemPossessedBy(oPlayer, "immortaldagger2")) ;
DestroyObject(claw2);
object crownskin = ( GetItemPossessedBy(oPlayer, "crownskin") );
DestroyObject(crownskin);
RemoveEffect(oPlayer, EffectRegenerate(150, 3.0f));
RemoveEffect(oPlayer, SupernaturalEffect(EffectConfused()));
AssignCommand(oPlayer, DestroyObject(oHelm));
CreateItemOnObject("immortalcrown2" , oPlayer, 1);
}
}
AssignCommand(oDying, ClearAllActions());
AssignCommand(oDying, bleed(1));
}