Amon_PRC8/_module/nss/js_onheartbeat.nss
Jaysyn904 c5cffc37af Initial Commit
Initial Commit [v1.01]
2025-04-03 19:00:46 -04:00

332 lines
13 KiB
Plaintext

//:://////////////////////////////////////////////
//:: Name: OnHeartbeat
//:: FileName: js_onheartbeat
//:://////////////////////////////////////////////
/*
When the Module int is flagged to show that a
PC is dying this scripts check whichPC is
effected causes them to bleed.The PC has a
chance each check to loose 1 point, not loose any
or gain 1 point health.
*/
//:://////////////////////////////////////////////
//:: Created By: SPBTooL
//:: Created By: Jer Wolfe
//:: Modified By:
//:: Created On: Aug 04, 2002
//:://////////////////////////////////////////////
#include "js_include"
void main()
{
object oModule = GetModule();
int bPCAlive = GetLocalInt(oModule, "PCAlive");
//clock force...yuck
int iHour = GetTimeHour ();
int iMinute = GetTimeMinute ();
int iSecond = GetTimeSecond ();
int iMillisecond = GetTimeMillisecond();
SetTime(iHour, iMinute, iSecond, iMillisecond);
// Is somebody dead, disabled, or dying?
if (!bPCAlive)
{ // Get the first PC even if they are not hurt
object oPC = GetFirstPC();
int iPCHealth = PC_HEALTH_ALIVE;
// Assume everybody really is alive
int bPCsAreAlive = TRUE;
// Start checking the PCs with a while valid command untill all PCs have been checked
while (GetIsObjectValid(oPC))
{
iPCHealth = GetLocalInt(oPC, "PCHealth");
if (iPCHealth != PC_HEALTH_ALIVE && iPCHealth != PC_HEALTH_DEAD)
{ // Double check their hit points
if (GetCurrentHitPoints(oPC) <= 0)
{ //Counteracts regeneration items by removing the amount healed
//if a loss of health is what should happen that round.
//regeneration works normaly if the round is counted as
//stable or healed.
int iRegenPen = 0;
int LastHitPoints = GetLocalInt(oPC, "LastHitPoints");
if (GetCurrentHitPoints(oPC) - LastHitPoints == 1)
{
iRegenPen = 1;
}
if (GetCurrentHitPoints(oPC) - LastHitPoints == 2)
{
iRegenPen = 2;
}
if (GetCurrentHitPoints(oPC) - LastHitPoints == 3)
{
iRegenPen = 3;
}
if (GetCurrentHitPoints(oPC) - LastHitPoints == 4)
{
iRegenPen = 4;
}
if (GetCurrentHitPoints(oPC) - LastHitPoints == 5)
{
iRegenPen = 5;
}
if (iPCHealth == PC_HEALTH_DYING)
{//checks to see if you stableize or loose more health.
bPCsAreAlive = FALSE;
//chance to heal 1 point only if at 0 health.
if (d20() + GetFortitudeSavingThrow(oPC) > (iStableCheck + 1 + iRegenPen) && GetCurrentHitPoints(oPC) == 0)
{
effect eDamage = EffectHeal(1);
ApplyEffectToObject(DURATION_TYPE_INSTANT, eDamage, oPC);
SetLocalInt(oPC, "LastHitPoints", GetCurrentHitPoints(oPC));
SetLocalInt(oPC, "PCHealth", PC_HEALTH_ALIVE);
SendMessageToPC(oPC, "You are no longer dying.");
return;
}
if ((d20() + GetFortitudeSavingThrow(oPC)) >= (iStableCheck))
{
SetLocalInt(oPC, "PCHealth", PC_HEALTH_STABLE);
SetLocalInt(oPC, "LastHitPoints", GetCurrentHitPoints(oPC));
SendMessageToPC(oPC, "You have stableized for now.");
return;
}
else
{ // Call out random cries/ groans for help
switch (d6())
{
case 1:
PlayVoiceChat (VOICE_CHAT_PAIN1, oPC);
break;
case 2:
PlayVoiceChat (VOICE_CHAT_PAIN2, oPC);
break;
case 3:
PlayVoiceChat (VOICE_CHAT_PAIN3, oPC);
break;
case 4:
PlayVoiceChat (VOICE_CHAT_HEALME, oPC);
break;
case 5:
PlayVoiceChat (VOICE_CHAT_NEARDEATH, oPC);
break;
case 6:
PlayVoiceChat (VOICE_CHAT_HELP, oPC);
break;
}
// Apply the "bleeding" effect
effect eDamage = EffectDamage((1 + iRegenPen), DAMAGE_TYPE_MAGICAL, DAMAGE_POWER_PLUS_FIVE);
ApplyEffectToObject(DURATION_TYPE_INSTANT, eDamage, oPC);
// Save their hit points in case they disconnect and to check for regeneration.
SetLocalInt(oPC, "LastHitPoints", GetCurrentHitPoints(oPC));
SendMessageToPC(oPC, "You are dying.");
return;
}
}
else if (iPCHealth == PC_HEALTH_STABLE)
{//if stable do you heal or die more with less chance to heal as to dye more.
if ((d20(1) + GetFortitudeSavingThrow(oPC) >= (iStableCheck +1) && GetCurrentHitPoints(oPC) == 0))
{
effect eDamage = EffectHeal(1);
ApplyEffectToObject(DURATION_TYPE_INSTANT, eDamage, oPC);
SetLocalInt(oPC, "LastHitPoints", GetCurrentHitPoints(oPC));
SetLocalInt(oPC, "PCHealth", PC_HEALTH_DYING);
SendMessageToPC(oPC, "You have healed for now.");
return;
}
else if ((d20() + GetFortitudeSavingThrow(oPC) >= iStableCheck) && (GetCurrentHitPoints(oPC) == 0))
{
SetLocalInt(oPC, "PCHealth", PC_HEALTH_STABLE);
SetLocalInt(oPC, "LastHitPoints", GetCurrentHitPoints(oPC));
SendMessageToPC(oPC, "You have stableized for now.");
return;
}
else if ((d20() + GetFortitudeSavingThrow(oPC) >= iStableCheck ) && (GetCurrentHitPoints(oPC) == -1))
{
effect eDamage = EffectHeal(1);
ApplyEffectToObject(DURATION_TYPE_INSTANT, eDamage, oPC);
SetLocalInt(oPC, "LastHitPoints", GetCurrentHitPoints(oPC));
SetLocalInt(oPC, "PCHealth", PC_HEALTH_DYING);
SendMessageToPC(oPC, "You have healed for now.");
return;
}
else if ((d20() + GetFortitudeSavingThrow(oPC) >= (iStableCheck +1)) && (GetCurrentHitPoints(oPC) == -2))
{
effect eDamage = EffectHeal(1);
ApplyEffectToObject(DURATION_TYPE_INSTANT, eDamage, oPC);
SetLocalInt(oPC, "LastHitPoints", GetCurrentHitPoints(oPC));
SetLocalInt(oPC, "PCHealth", PC_HEALTH_DYING);
SendMessageToPC(oPC, "You have healed for now.");
return;
}
else if ((d20() + GetFortitudeSavingThrow(oPC) >= (iStableCheck +1)) && (GetCurrentHitPoints(oPC) == -3))
{
effect eDamage = EffectHeal(1);
ApplyEffectToObject(DURATION_TYPE_INSTANT, eDamage, oPC);
SetLocalInt(oPC, "LastHitPoints", GetCurrentHitPoints(oPC));
SetLocalInt(oPC, "PCHealth", PC_HEALTH_DYING);
SendMessageToPC(oPC, "You have healed for now.");
return;
}
else if ((d20() + GetFortitudeSavingThrow(oPC) >= (iStableCheck +2)) && (GetCurrentHitPoints(oPC) == -4))
{
effect eDamage = EffectHeal(1);
ApplyEffectToObject(DURATION_TYPE_INSTANT, eDamage, oPC);
SetLocalInt(oPC, "LastHitPoints", GetCurrentHitPoints(oPC));
SetLocalInt(oPC, "PCHealth", PC_HEALTH_DYING);
SendMessageToPC(oPC, "You have healed for now.");
return;
}
else
{
effect eDamage = EffectDamage((1 + iRegenPen), DAMAGE_TYPE_MAGICAL, DAMAGE_POWER_PLUS_FIVE);
ApplyEffectToObject(DURATION_TYPE_INSTANT, eDamage, oPC);
SetLocalInt(oPC, "LastHitPoints", GetCurrentHitPoints(oPC));
SetLocalInt(oPC, "PCHealth", PC_HEALTH_DYING);
SendMessageToPC(oPC, "You are dying.");
return;
}
}
}
else
{ // Set int of PC to show status of healed
SetLocalInt(oPC, "PCHealth", PC_HEALTH_ALIVE);
} // Ends the check for - HPs
}//makes sure the PC is marked as dead when -10 or less.
if ((iPCHealth != PC_HEALTH_DEAD) && (GetCurrentHitPoints(oPC) <= -10))
{
SetLocalInt(oPC, "PCHealth", PC_HEALTH_DEAD);
SetLocalInt(oPC, "LastHitPoints", GetCurrentHitPoints(oPC));
}
oPC = GetNextPC();
} // Ends the looking for valid PCs
if (bPCsAreAlive)
{
// No hurt/dying PCs found, set int back to PCAlive
SetLocalInt(oModule, "PCAlive", TRUE);
}
// Ends the !bPCAlive check
}//removes the PC's corpse when it is empty.
//}
object oPC = GetFirstPC();
while (GetIsObjectValid(oPC))
{
if (!GetHasFeat(FEAT_PLAYER_TOOL_01, oPC))
{
object oHide = GetItemInSlot(INVENTORY_SLOT_CARMOUR, oPC);
if (GetIsObjectValid(oHide))
{
FloatingTextStringOnCreature("Player Tool 1 acquired. Use this to direct companions.", oPC, FALSE);
AddItemProperty(DURATION_TYPE_PERMANENT, ItemPropertyBonusFeat(IP_CONST_FEAT_PLAYER_TOOL_01), oHide);
}
}
oPC = GetNextPC();
}
/*/ Lokmar Iskaran's clean-up scripts
//
// This is the MODULE OnHeartbeat script, which makes sure all PC held items have
// reset "Age" tags.
void trashremoval()
{
int modulecounter1 = 0;
modulecounter1 = GetLocalInt(OBJECT_SELF, "modulecounter1");
if (modulecounter1 == 0)
{
SetLocalInt(OBJECT_SELF, "modulecounter1", 2);
// First tick, so first six seconds have already passed, thus we set it to 2
// we're counting from 1 to 11 rather than 0 to 10, because 0 is the result
// returned if the LocalInt does not exist... (as was tested above.)
}
else
{
modulecounter1++;
if (modulecounter1 < 11) // since counter starts at 1, need to go to 11 for 10 rounds
{
SetLocalInt(OBJECT_SELF, "modulecounter1", modulecounter1);
}
else
{
SetLocalInt(OBJECT_SELF, "modulecounter1", 1);
// here we go through player inventory and reset all items' "Age" tag to zero.
// this way, if they pick up items, it resets the age, so they have a correct
// lifespan when dropped again
// this code should go in the world/module heartbeat function
object charObj = OBJECT_INVALID;
object invObj = OBJECT_INVALID;
charObj = GetFirstPC();
while (charObj != OBJECT_INVALID)
{
if (GetArea(charObj) == OBJECT_SELF)
{
invObj = GetFirstItemInInventory(charObj);
while (invObj != OBJECT_INVALID)
{
SetLocalInt(invObj, "Age", 0);
invObj = GetNextItemInInventory(charObj);
}
}
charObj = GetNextPC();
}
}
}
} */
}