////////::////////////////////////////////////////////////////////////// //:: Name mod_heartbeat //:: mod_heartbeat //:: Copyright (c) 2001 Bioware Corp. //::////////////////////////////////////////////// /* This script goes in OnHeartBeat in the Module Properties Events It checks players to see if their PlayerState is other than Alive and takes steps as noted below to affect them. */ //::////////////////////////////////////////////// //:: Created By: Pad O'Lion (inspired by Archaegeo) //:: Created On: 06/29/2002 //:://////////////////////////////////////////////// //#include "array_api" #include "rpo_inc" #include "jw_wolf_script" void main() { if(BLEEDSYSTEM) { object oModule = GetModule(); int nHour=GetTimeHour(); if (GetLocalInt(OBJECT_SELF,"nHour")!=nHour) { ExportAllCharacters(); SetLocalInt(OBJECT_SELF,"nHour",nHour); } int nDay=GetCalendarDay(); int iEverybodyAlive = GetLocalInt(oModule, "PWS_EverybodyAlive"); /// Only bother looping through players if there are disabled, dying, stable or dead players if (1) { object oPlayer = GetFirstPC(); object oDeathAmulet; // Assume everyone is alive till tracking finds otherwise int iEverybodyReallyAlive = TRUE; while (GetIsObjectValid(oPlayer)) { int iPlayerState = GetLocalInt(oPlayer, "PlayerState"); // Remove death amulet if player got healed and/or reset state to alive. if( (iPlayerState==PWS_PLAYER_STATE_STABLE || iPlayerState==PWS_PLAYER_STATE_DYING || iPlayerState==PWS_PLAYER_STATE_DEAD) && GetCurrentHitPoints(oPlayer) > 0) { SetLocalInt(oPlayer, "PlayerState", PWS_PLAYER_STATE_ALIVE); RemoveDeathAmulet(oPlayer); } // Whoops, we found a dead one. if (iPlayerState==PWS_PLAYER_STATE_DEAD) //&& GetLocalInt(oPlayer, "RPO_Reputation") != RPO_PLAYER_REPUTATION_CRIMINAL) { iEverybodyReallyAlive = FALSE; } else if (iPlayerState==PWS_PLAYER_STATE_RESCUED) { iEverybodyReallyAlive = FALSE; } else if (iPlayerState==PWS_PLAYER_STATE_DYING) { // We found someone dying iEverybodyReallyAlive = FALSE; // They bleed! effect eDamage = EffectDamage(1, DAMAGE_TYPE_MAGICAL, DAMAGE_POWER_PLUS_FIVE); if (GetCurrentHitPoints(oPlayer)<1) { ApplyEffectToObject( DURATION_TYPE_INSTANT, eDamage, oPlayer); } int which = d6(); switch (which) { case 1: PlayVoiceChat (VOICE_CHAT_PAIN1, oPlayer); break; case 2: PlayVoiceChat (VOICE_CHAT_PAIN2, oPlayer); break; case 3: PlayVoiceChat (VOICE_CHAT_PAIN3, oPlayer); break; case 4: PlayVoiceChat (VOICE_CHAT_HEALME, oPlayer); break; case 5: PlayVoiceChat (VOICE_CHAT_NEARDEATH, oPlayer); break; case 6: PlayVoiceChat (VOICE_CHAT_HELP, oPlayer); break; } if (GetCurrentHitPoints(oPlayer) <= -9) { PlayVoiceChat (VOICE_CHAT_DEATH, oPlayer); } } // If they are stable or disabled, let them pray to their god or wait for /// help as applicable. (Stable means between 0 and -9 and not bleeding) else if (iPlayerState == PWS_PLAYER_STATE_DISABLED || iPlayerState == PWS_PLAYER_STATE_STABLE) { // We found someone Disabled or Stable iEverybodyReallyAlive = FALSE; // Check for spontaneous healing if( (iPlayerState == PWS_PLAYER_STATE_STABLE && GetLocalInt(oPlayer,"LastRecCheckHour") < nHour) || (iPlayerState == PWS_PLAYER_STATE_DISABLED && GetLocalInt(oPlayer,"LastRecCheckDay") < nDay) ) { if(d100() <= 10) { SendMessageToPC(oPlayer,"You recover a little."); effect eHeal = EffectHeal(1); ApplyEffectToObject(DURATION_TYPE_INSTANT, eHeal, oPlayer); if(GetCurrentHitPoints(oPlayer)==0) { SetLocalInt(oPlayer, "PlayerState", PWS_PLAYER_STATE_DISABLED); SendMessageToPC(oPlayer, "You are now Disabled."); } else if(GetCurrentHitPoints(oPlayer)>0) SetLocalInt(oPlayer,"PlayerState",PWS_PLAYER_STATE_ALIVE); } else { effect eDamage = EffectDamage(1, DAMAGE_TYPE_MAGICAL, DAMAGE_POWER_PLUS_FIVE); ApplyEffectToObject( DURATION_TYPE_INSTANT, eDamage, oPlayer); SendMessageToPC(oPlayer,"You slip closer to death."); } SetLocalInt(oPlayer, "LastRecCheckHour", nHour); SetLocalInt(oPlayer, "LastRecCheckDay", nDay); } } oPlayer = GetNextPC(); } if (iEverybodyReallyAlive) // We didn't find any dead players, so assume everybody is alive SetLocalInt(oModule, "PWS_EverybodyAlive", TRUE); } } else if(DEATHSYSTEM) { // Check for Death Amulets on folks who are alive again. object oPlayer = GetFirstPC(); RemoveDeathAmulet(oPlayer); } }