122 lines
5.0 KiB
Plaintext
122 lines
5.0 KiB
Plaintext
|
/* Filename: s_pc_death
|
||
|
// This file is responsible for the execution of automatic time delay respawn on the PC
|
||
|
|
||
|
|
||
|
Written by Shayan on 18/01/2004
|
||
|
|
||
|
*/
|
||
|
#include "dem_color_text"
|
||
|
|
||
|
|
||
|
//MAKE SURE MINIMUM TIME < MAXIMUM TIME by atleast .1
|
||
|
const float MINIMUM_DEAD_TIME_ALLOWED = 120.0;
|
||
|
const float MAXIMUM_DEAD_TIME_ALLOWED = 240.0;
|
||
|
|
||
|
string MODULE_DEATH_SCRIPT = "rhun_onpc_respwn";
|
||
|
|
||
|
//it is the maximum level the PC can gain on the server
|
||
|
const float MAX_PC_LEVEL = 40.0;
|
||
|
|
||
|
|
||
|
//returns the time the PC can stay dead in seconds.
|
||
|
float CalculateDeathTime(object oPC)
|
||
|
{
|
||
|
float PCLevel = IntToFloat(GetHitDice(oPC));
|
||
|
float TimeRange = MAXIMUM_DEAD_TIME_ALLOWED - MINIMUM_DEAD_TIME_ALLOWED;
|
||
|
float TimeGapPerLevel = 0.0;
|
||
|
TimeGapPerLevel = TimeRange/MAX_PC_LEVEL;
|
||
|
return MINIMUM_DEAD_TIME_ALLOWED + TimeGapPerLevel*PCLevel;
|
||
|
}
|
||
|
|
||
|
string SaySomethingStupid()
|
||
|
{
|
||
|
string stupid;
|
||
|
|
||
|
switch(d10())
|
||
|
{
|
||
|
case 1: stupid = "Grand ma..? Is that you?"; break;
|
||
|
case 2: stupid = "I knew this would happen!"; break;
|
||
|
case 3: stupid = "So this is what it feels like..."; break;
|
||
|
case 4: stupid = "I knew I should have bought heal potions!"; break;
|
||
|
case 5: stupid = "Tell mother that I..."; break;
|
||
|
case 6: stupid = "Hey why are you just standing there?! I'm dying here!"; break;
|
||
|
case 7: stupid = "Mystra, Helm, Cyric, Selune, Shar, Sune, Lolth, Ao, I believe in you all! Save me!"; break;
|
||
|
case 8: stupid = "Maybe dying won't be so bad..."; break;
|
||
|
case 9: stupid = "Is this all there is?"; break;
|
||
|
case 10: stupid = "I repent all my sins! Save me!"; break;
|
||
|
default: stupid = "Death cannot stop me! I will return!"; break;
|
||
|
}
|
||
|
return stupid;
|
||
|
}
|
||
|
|
||
|
void ShowTimeRemaining(int TimeRemaining)
|
||
|
{
|
||
|
if(GetIsDead(OBJECT_SELF))
|
||
|
{
|
||
|
if(TimeRemaining > 0)
|
||
|
{
|
||
|
//Sound off warnings
|
||
|
if(TimeRemaining <= 10 || TimeRemaining == 20 || TimeRemaining == 30 || TimeRemaining == 60 || TimeRemaining == 120)
|
||
|
{
|
||
|
if(TimeRemaining <=10)
|
||
|
{
|
||
|
FloatingTextStringOnCreature(ColorText(IntToString(TimeRemaining), "red"), OBJECT_SELF, TRUE);
|
||
|
}
|
||
|
if(TimeRemaining == 20 || TimeRemaining == 30)
|
||
|
{
|
||
|
SendMessageToPC(OBJECT_SELF, ColorText("Death has come closer. You have " + IntToString(TimeRemaining) + " seconds remaining.", "red"));
|
||
|
}
|
||
|
if(TimeRemaining == 120 || TimeRemaining == 60)
|
||
|
{
|
||
|
SendMessageToPC(OBJECT_SELF, ColorText("You feel that your body cannot sustain your spirit for too much longer. You have " + IntToString(TimeRemaining) + " seconds before your soul leaves it's mortal coil.", "green"));
|
||
|
if(TimeRemaining == 60)
|
||
|
{
|
||
|
if(d10() == 1)
|
||
|
{
|
||
|
SpeakString(SaySomethingStupid());
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
effect DeathEffect = EffectVisualEffect(VFX_IMP_RAISE_DEAD);
|
||
|
effect DeathEffect2 = EffectVisualEffect(VFX_IMP_MAGBLUE);
|
||
|
ApplyEffectToObject(DURATION_TYPE_TEMPORARY, DeathEffect, OBJECT_SELF);
|
||
|
ApplyEffectToObject(DURATION_TYPE_TEMPORARY, DeathEffect2, OBJECT_SELF);
|
||
|
//to get rid of the Death GUI
|
||
|
TimeRemaining = 0;
|
||
|
SetLocalInt(OBJECT_SELF, "DEAD_TIME_REMAINING", TimeRemaining);
|
||
|
//to get rid of the Death GUI fake a resurrection.
|
||
|
SignalEvent(OBJECT_SELF, EventSpellCastAt(GetModule(), SPELL_RESURRECTION, FALSE));
|
||
|
ExecuteScript(MODULE_DEATH_SCRIPT, OBJECT_SELF);
|
||
|
return;
|
||
|
}
|
||
|
TimeRemaining = TimeRemaining - 1;
|
||
|
SetLocalInt(OBJECT_SELF, "DEAD_TIME_REMAINING", TimeRemaining);
|
||
|
DelayCommand(1.0, ShowTimeRemaining(TimeRemaining));
|
||
|
}
|
||
|
else
|
||
|
{return;}
|
||
|
}
|
||
|
|
||
|
void main()
|
||
|
{
|
||
|
//Check whether the PC had died and left the module while the timer was ticking.
|
||
|
int TimeRemaining = 0;
|
||
|
if(GetLocalInt(OBJECT_SELF, "DEAD_TIME_REMAINING") == 0)
|
||
|
{
|
||
|
TimeRemaining = FloatToInt(CalculateDeathTime(OBJECT_SELF));
|
||
|
SetLocalInt(OBJECT_SELF, "DEAD_TIME_REMAINING", TimeRemaining);
|
||
|
string DeathLine = "You are dead. Your body can only sustain your spirit for another " + IntToString(TimeRemaining) + " seconds.";
|
||
|
SendMessageToPC(OBJECT_SELF, DeathLine);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
TimeRemaining = GetLocalInt(OBJECT_SELF, "DEAD_TIME_REMAINING");
|
||
|
}
|
||
|
DelayCommand(1.0, PopUpDeathGUIPanel(OBJECT_SELF, TRUE, TRUE, 0, "You are dead. You can either wait for another player to ressurect you, or you can choose respawn. If you choose the respawn option, and you are above level 5, you will lose 75 XP per level, and 10% of your total gold pieces."));
|
||
|
ShowTimeRemaining(TimeRemaining);
|
||
|
}
|