Disabled defunct module reset. Disabled item destruction on drop. Added PRC'd creature abilities. Fixed invalid hak association. Updated release archive.
904 lines
25 KiB
Plaintext
904 lines
25 KiB
Plaintext
//Script Name: time_keeper
|
||
///////////////////////////////////////////////////////////////
|
||
//Created By: Genisys (Guile)
|
||
//Created On: 8/16/08
|
||
//Revised On: 3/15/09
|
||
///////////////////////////////////////////////////////////////
|
||
//NOTE: This has been THOROUGHLY Playtested
|
||
|
||
//Required Include
|
||
#include "NW_I0_GENERIC"
|
||
///////////////////////////////////////////////////////////////
|
||
/*
|
||
NOTE: By Default the module will only reload (nwnx2 is NOT used)
|
||
|
||
This script is full of options to set what the script does.
|
||
It's designed to keep track of time on a Module, see the
|
||
"time_tutorial" script to learn more about the variables set
|
||
by this script which store actual passing time, which can be
|
||
used in other scripts for to make life easier!
|
||
|
||
This script MUST go on a placeable object's OnHeartbeat Event,
|
||
The Object MUST be tagnamed "timekeeper", it Must be plot, and
|
||
it CANNOT be static, and it MUST be Unique! (no other copies in the module!)
|
||
The original object which is in the erf of this download is
|
||
on the custom palette named "Magical Sundial"
|
||
|
||
The settings for this script tell you more of what the script
|
||
actually can do, though, there is a lot of nice scripting which
|
||
I will not delve into, though a sign is on the palette to help.
|
||
*/
|
||
///////////////////////////////////////////////////////////////
|
||
////////////////// IMPORTANT SETTINGS /////////////////////////
|
||
///////////////////////////////////////////////////////////////
|
||
|
||
////////////////// AUTOMATIC RESET OPTIONS //////////////////
|
||
|
||
//Set this to 1, IF you are using NWNX2 To run your Server
|
||
const int nNWNX2 = 0; //(Default = 0 / You Are NOT using NWNX2 )
|
||
|
||
//Set this to 1 if you wish to Auto Restart The Server
|
||
const int nRestart = 0; //Set this to 0 if you are using Re-Load Module
|
||
|
||
//Set this to 1 if you wish to Auto Re-Load The Module
|
||
const int nReload = 0; //Set this to 0 if you are using Restart Server
|
||
|
||
//Set the name of your module below if you are using Re-Load Module
|
||
const string sModuleName = "Underworld 2";
|
||
|
||
//Set the # below to what Time you want to reset the Module or Server
|
||
//NOTE: The time is in minutes (Multiple Hours X 60)
|
||
const int nMinTillReset = 360; //Default = 360 minutes (6 hours)
|
||
|
||
/////////////// CHARACTER AUTO SAVING OPTIONS /////////////////////
|
||
|
||
//NOTE: This system will not save any character IF they are
|
||
//Polymorphed or Between Areas (To prevent bugs & errors)
|
||
|
||
//Set this to 1 To Activate Auto Character Saving For Server Modules
|
||
//Set this to 2 To Activate Single Player Automatic Quick Save Option
|
||
const int nDoExport = 0; // 0 = Default (OFF - No Saving)
|
||
|
||
//Set the # below to How often (in minutes) you want to
|
||
//export all characters or do a single player quick save..
|
||
const int nTimeTillExport = 5; // 5 = Default (every 5 minutes)
|
||
|
||
///////////////////////////////////////////////////////////////////
|
||
///////////////AUTOMATIC MESSAGING SYSTEM OPTIONS//////////////////
|
||
|
||
//Set this to 1 if you want to send the Current Game Time & Game Date
|
||
//To ALL PCs every 15 minutes.(Original NWN Gaming Calender & Time Used)
|
||
const int nGameTimeMsg = 0; //Default = 0 (No Message)
|
||
|
||
//Set this to 1 if you want to send the Time till server resets to all
|
||
//PCs on the module every 15 mintues..
|
||
const int nServResetTimeMsg = 0;
|
||
|
||
//Set this to 1 to turn on the Server Message System:
|
||
const int nMsgONOFF = 0; //Default = 0 Turned Off
|
||
|
||
//Set # below to the Interval in Minutes you want the Server Message Sent
|
||
const int nMsgTime = 30; //(30 = Default (Send Every 30 Minutes))
|
||
|
||
//Set the # below to the color # you wish to apply to the Message.
|
||
|
||
// 1 = Light Blue / 2 = Red / 3 = Light Green / 4 = Cyan
|
||
// 5 = Light Pink / 6 = Gold / 7 = Light Grey / 8 = Purple
|
||
|
||
const int nColor = 4; //(Default = 0 / No Color);
|
||
|
||
//Place the message you wish to send all of the players every
|
||
//nMsgTime minutes (above) inside of the " " below..
|
||
|
||
const string sMainMessage = " Thanks for playing!";
|
||
|
||
//////////////////////////////////////////////////////////////////////
|
||
|
||
///////////////////////////////////////////////////////////////////////
|
||
/////////##################################################////////////
|
||
////*****# WARNING: DON'T TOUCH ANYTHING BELOW THIS LINE! #******//////
|
||
/////////##################################################////////////
|
||
///////////////////////////////////////////////////////////////////////
|
||
|
||
//PROTOTYPE DECLARED
|
||
void SendMsgToAllPCs(string sMsg);
|
||
void DoExportCharacters();
|
||
void GiveWarnings(string sMC);
|
||
void BootAll();
|
||
void DoResetCheck(string sMC, int nTMin);
|
||
//////////////////////////////////
|
||
|
||
//Main Script
|
||
void main()
|
||
{
|
||
|
||
//The Magical Sundial (The owner of the script)
|
||
object oMe = OBJECT_SELF;
|
||
|
||
/////////////////////PREVENT SCRIPT EXECUTION////////////////////////
|
||
|
||
//This will prevent ANYONE from firing this script EVER!
|
||
//As this script was designed only to be fired by a placeable object.
|
||
//Feel free to copy and paste this into other scriptss
|
||
//you do not want PCs or DMs executing with the console command
|
||
//See the "prevent_cheat" script for another system I use..
|
||
|
||
if(GetIsPC(oMe) || GetIsDM(oMe) || GetIsDMPossessed(oMe))
|
||
{
|
||
if(GetIsPC(oMe))
|
||
{
|
||
string sMsg = "****The Player - " + GetName(oMe) + " / " + GetPCPlayerName(oMe) +
|
||
" / " + GetPCPublicCDKey(oMe) + " Has attempted to Execute a Script!!!****BANN THEM!****";
|
||
|
||
//Busted!
|
||
WriteTimestampedLogEntry(sMsg);
|
||
SendMessageToAllDMs(sMsg);
|
||
}
|
||
|
||
//Stop the script here, we don't want this to happen on a PC or DM EVER!
|
||
return;
|
||
}
|
||
|
||
//////////////////////////////////////////////////////////////////////////
|
||
|
||
//Declare Major Variables
|
||
int nInc1;
|
||
int nInc2;
|
||
|
||
//The # of Heartbeats (1 for Every 6 Seconds)
|
||
int nVar = GetLocalInt(GetModule(), "MODULE_BEAT");
|
||
|
||
//Incement the variable every heartbeat (6 seconds)
|
||
int nInt = nVar+6;
|
||
|
||
//Variables for Time
|
||
int nSec = nInt; //Total Time (In Seconds in 6 Second Increments)
|
||
int nMin = nSec/60; //Total Time (In Minutes)
|
||
//if(nMin>=60)
|
||
int nHr = nMin/60; //Total Hours (Since Start)
|
||
|
||
//Store the Heartbeat Counts on the object.
|
||
SetLocalInt(GetModule(), "MODULE_BEAT", nSec);
|
||
|
||
//These variables will be used to define Real Time
|
||
//Not total minutes but the Hours / Minutes /& Seconds
|
||
string sTime;
|
||
int nMinute;
|
||
int nSecond;
|
||
int nCount;
|
||
int nIncrement;
|
||
|
||
////////////////////////////////////////////////////////////////////////////
|
||
//Define & Store the amount of time that has passed...
|
||
|
||
//If at least 1 Hour has passed..
|
||
if(nHr>=1)
|
||
{
|
||
|
||
//Total Hours converted to minutes (For Calculating)
|
||
nCount = nHr * 60;
|
||
|
||
//Calculate Minutes by subtracting the total hours (in minutes)
|
||
//from total minutes, this gives us the current minutes in 1 hour..
|
||
nMinute = nMin - nCount;
|
||
|
||
//Convert total minutes to seconds.
|
||
//This will give us the current seconds - total minutes PASSED (in seconds)
|
||
nIncrement = nMin * 60;
|
||
|
||
//Calculate Seconds minus the total number of minutes (in seconds)
|
||
//This gives us the current seconds of THIS Heartbeat..
|
||
nSecond = nSec - nIncrement;//this gives us current left over seconds!
|
||
|
||
//Store the Current Hour on the Timekeeper.
|
||
SetLocalInt(GetModule(), "MOD_HOURS", nHr);
|
||
|
||
//Store the Current Minute on the Timekeeper.
|
||
SetLocalInt(GetModule(), "MOD_MINUNTES", nMinute);
|
||
|
||
//Store the Current Second On the Timekeeper
|
||
SetLocalInt(GetModule(), "MOD_SECONDS", nSecond);
|
||
|
||
//Only once/Hour
|
||
if(nMinute == 3 && nSecond == 12)
|
||
{
|
||
WriteTimestampedLogEntry("::::MODULE TIME KEEPER:::: " +IntToString(nHr) + " Hrs" +
|
||
IntToString(nMinute) + " Mins " + IntToString(nSecond) + " Seconds ");
|
||
}
|
||
|
||
}
|
||
|
||
else if(nHr<1 && nMin>=1)
|
||
{
|
||
//Calculate time..
|
||
nMinute = nMin; //Total Minutes
|
||
nCount = nMin * 60; //(Convert Minutes to Seconds)
|
||
nSecond = nSec - nCount; //(Minus Current Minutes)
|
||
|
||
//Store the Current Minute on the Timekeeper
|
||
SetLocalInt(GetModule(), "MOD_MINUTES", nMinute);
|
||
|
||
//Store the Current Second On the Timekeeper
|
||
SetLocalInt(GetModule(), "MOD_SECONDS", nSecond);
|
||
|
||
//Only once/Hour
|
||
if(nMinute == 10 && nSecond == 12)
|
||
{
|
||
WriteTimestampedLogEntry("::::MODULE TIME KEEPER:::: " + "0 Hrs" +
|
||
IntToString(nMinute) + " Mins " + IntToString(nSecond) + " Seconds ");
|
||
}
|
||
}
|
||
|
||
|
||
//Otherwise Just Set the true time..
|
||
else
|
||
{
|
||
|
||
nMinute = nMin;
|
||
|
||
nSecond = nSec;
|
||
|
||
//Store the Current Minute on the Timekeeper
|
||
SetLocalInt(GetModule(), "MOD_MINUTES", nMinute);
|
||
|
||
//Store the Current Second On the Timekeeper
|
||
SetLocalInt(GetModule(), "MOD_SECONDS", nSecond);
|
||
|
||
//WriteTimestampedLogEntry("TIME: " + IntToString(nSecond) + " Seconds ");
|
||
|
||
}
|
||
|
||
///////////////////////////////////////////////////////////////////////////
|
||
//Define Messages & Color
|
||
|
||
string sColor;
|
||
// 1 = Light Blue / 2 = Red / 3 = Light Green / 4 = Cyan (light blue/green)
|
||
// 5 = Pink / 6 = Gold / 7 = Light Grey / 8 = Purple / 0 = NONE
|
||
|
||
//Determine color to be put in messages
|
||
if(nColor==0) //Default
|
||
{ sColor = ""; }
|
||
else if(nColor==1)
|
||
{ sColor = "<c <20><>>"; }
|
||
else if(nColor==2)
|
||
{ sColor = "<c<> >"; }
|
||
else if(nColor==3)
|
||
{ sColor = "<c^<5E> >"; }
|
||
else if(nColor==4)
|
||
{ sColor = "<c <20><>>"; }
|
||
else if(nColor==5)
|
||
{ sColor = "<c<><63><EFBFBD>>"; }
|
||
else if(nColor==6)
|
||
{ sColor = "<c<><63> >"; }
|
||
else if(nColor==7)
|
||
{ sColor = "<c<><63><EFBFBD>>"; }
|
||
else if(nColor==8)
|
||
{ sColor = "<c` <20>>"; }
|
||
else //Default
|
||
{ sColor = ""; }
|
||
|
||
//Store the color on the Magical Sundial (For it's own message)
|
||
SetLocalString(oMe, "MODULECOLOR", sColor);
|
||
|
||
///////////////////////////////////////////////////////////////////////////
|
||
//Game Time Message
|
||
|
||
int nMonth = GetCalendarMonth();
|
||
int nDay = GetCalendarDay();
|
||
int nHour = GetTimeHour();
|
||
int nDHr;
|
||
int nTHr;
|
||
string sSufix;
|
||
string sSufix2;
|
||
string sSufix3;
|
||
|
||
//Hour
|
||
if(nHour>12)
|
||
{ nDHr = nHour - 12; }
|
||
else if(nHour==0)
|
||
{ nDHr = 12; }
|
||
else
|
||
{ nDHr = nHour; }
|
||
|
||
//Hour Suffix
|
||
if(nDHr==3)
|
||
{ sSufix = "rd "; }
|
||
else if(nDHr==2)
|
||
{ sSufix = "nd "; }
|
||
else if(nDHr==1)
|
||
{ sSufix = "rst "; }
|
||
else
|
||
{ sSufix = "th "; }
|
||
|
||
//Day Suffix
|
||
if(nDay==3)
|
||
{ sSufix2 = "rd "; }
|
||
else if(nDay==2)
|
||
{ sSufix2 = "nd "; }
|
||
else if(nDay==1)
|
||
{ sSufix2 = "rst "; }
|
||
else
|
||
{ sSufix2 = "th "; }
|
||
|
||
//Month Suffix
|
||
if(nMonth==3)
|
||
{ sSufix3 = "rd "; }
|
||
else if(nMonth==2)
|
||
{ sSufix3 = "nd "; }
|
||
else if(nMonth==1)
|
||
{ sSufix3 = "rst "; }
|
||
else
|
||
{ sSufix3 = "th "; }
|
||
|
||
string sMsg;
|
||
sMsg = "It's currently the ";
|
||
sMsg += IntToString(nDHr);
|
||
sMsg += sSufix;
|
||
sMsg += " Hour, of the ";
|
||
sMsg += IntToString(nDay);
|
||
sMsg += sSufix2;
|
||
sMsg += " Day, in the ";
|
||
sMsg += IntToString(nMonth);
|
||
sMsg += sSufix3;
|
||
sMsg += " Month, of the Year ";
|
||
sMsg += IntToString(GetCalendarYear());
|
||
|
||
sTime = sMsg;
|
||
|
||
|
||
|
||
/////////////////////////////////////////////////////////////////////////////
|
||
//Server Reset Time Message
|
||
|
||
//Time Till Reset Message... (left over time calcualted & converted)
|
||
int nRCHr = nMinTillReset - 60;
|
||
int nRCheck;
|
||
int nRHr;
|
||
int nRCon;
|
||
int nRTime;
|
||
int nRConTime;
|
||
int nRCTime;
|
||
int nRMin;
|
||
int nTrueHr;
|
||
string sResetTime;
|
||
|
||
nRCheck = nRCHr/60;
|
||
nRHr = nRCheck - nHr; //Hours left over till reset...
|
||
nRCon = nRHr * 60; //Hours left over ~ converted to minutes..
|
||
nRTime = nMinTillReset - nMin; //Total Minutes actually left over..
|
||
//Calcualte minutes left over minus hours passed (in minutes)
|
||
nRConTime = nRTime - nRCon;
|
||
nTrueHr = nRTime/60;
|
||
|
||
if(nMin<=59) //If one hour has not passed yet...
|
||
{
|
||
if(nMinTillReset>=60)
|
||
{
|
||
nRHr = nTrueHr; //Minutes Till Reset converted to hours
|
||
}
|
||
else
|
||
{
|
||
nRHr = 0;
|
||
}
|
||
nRMin = 60 - nMin; //Minutes till reset..(minus 1 hour.)
|
||
}
|
||
else if(nRTime<=59)//If only an hour is left over..
|
||
{
|
||
nRHr = 0;
|
||
nRMin = nRTime;
|
||
}
|
||
else //Otherwise Calculate minutes left over minus hours passed..
|
||
{
|
||
nRHr = nTrueHr;
|
||
//Make sure the time is correct!
|
||
if(nRConTime<=59)
|
||
{
|
||
nRMin = nRConTime;
|
||
}
|
||
//Double Check to make sure time is accurate!
|
||
else if(nRConTime<=120 && nRConTime >=60)
|
||
{
|
||
nRCTime = nRConTime-60;
|
||
nRMin = nRCTime;
|
||
}
|
||
else
|
||
{
|
||
//Print string to log file there is an error in time
|
||
PrintString("ERROR IN SCRIPT (time_keeper), @ lines 337 - 398 PLEASE INVESTIGATE");
|
||
nRMin = 0;
|
||
}
|
||
|
||
|
||
}
|
||
|
||
//Set the restart time on the module...
|
||
SetLocalInt(GetModule(), "HOURS_LEFT", nRHr);
|
||
SetLocalInt(GetModule(), "MINS_LEFT", nRMin);
|
||
|
||
sResetTime = "The Server will restart in: ";
|
||
sResetTime += IntToString(nRHr);
|
||
sResetTime += " Hours & ";
|
||
sResetTime += IntToString(nRMin);
|
||
sResetTime += " Minutes.";
|
||
|
||
|
||
|
||
/////////////////////////////////////////////////////////////////////////
|
||
///////////////////////////MAIN FUNCTIONS////////////////////////////////
|
||
/////////////////////////////////////////////////////////////////////////
|
||
|
||
///////////////////////////////////////////////////////////////
|
||
//Check The Reset System (every heartbeat!)
|
||
|
||
//:: DoResetCheck(sColor, nMinute);
|
||
|
||
/////////////////////////////////////////////////////////////////
|
||
//Let's set some visual effects on the Time Keeper (ONCE!)
|
||
if(GetLocalInt(oMe, "FX_ACTIVE")!=1)
|
||
{
|
||
SetLocalInt(oMe, "FX_ACTIVE", 1);
|
||
ApplyEffectToObject(DURATION_TYPE_PERMANENT, EffectVisualEffect(VFX_DUR_AURA_PULSE_BLUE_YELLOW), oMe);
|
||
ApplyEffectToObject(DURATION_TYPE_PERMANENT, EffectVisualEffect(VFX_DUR_PROTECTION_GOOD_MAJOR), oMe);
|
||
|
||
//Set the module reset time on the module in a variable one time..
|
||
SetLocalInt(GetModule(), "RESET_MIN", nMinTillReset);
|
||
|
||
}
|
||
|
||
////////////////////////////////////////////////////////////////////////
|
||
//Tell the DM's & Players the true time till restart
|
||
|
||
if(nServResetTimeMsg == 1)
|
||
{
|
||
//Send the message 2 X per hour
|
||
if((nMinute == 20 || nMinute == 40) && (nSecond ==6))
|
||
{
|
||
|
||
SendMessageToAllDMs(sResetTime);
|
||
SendMsgToAllPCs(sColor + sResetTime);
|
||
DelayCommand(1.0, SendMsgToAllPCs(sColor + sResetTime));
|
||
|
||
}
|
||
|
||
}
|
||
///////////////// CHARACTER AUTO SAVING SYSTEM //////////////////
|
||
|
||
//Calculate Time for Export & Message Intervals
|
||
|
||
//This Interval Count is Stored to keep track of time
|
||
int nMC1 = GetLocalInt(oMe, "EXPORTCOUNT");
|
||
|
||
int nTimes;
|
||
|
||
if(nMC1==0)//Can't multiply by 0.
|
||
{ nTimes = nTimeTillExport; } //nTimes = The Timed Interval
|
||
else
|
||
{
|
||
//nTimes = (Stored Count * Timed Interval)
|
||
nTimes = nMC1*nTimeTillExport;
|
||
}
|
||
|
||
//If the Total Minutes = (The Interval * The Interval Count)
|
||
if((nTimes==nMin) && (nSecond==6)) //Check only Once / minute!
|
||
{
|
||
//Define the Increment Count
|
||
if(nMC1>0)
|
||
{nInc1 = nMC1 + 1;}
|
||
//NOTE: The first Count MUST be set to 2! (2 x interval = Next Interval)
|
||
else
|
||
{nInc1 = 2;}
|
||
|
||
//Set the current increment
|
||
SetLocalInt(oMe, "EXPORTCOUNT", nInc1);
|
||
|
||
//If we are indeed suppose to export
|
||
|
||
//If it's a server...
|
||
if(nDoExport==1)
|
||
{
|
||
//For debugging..
|
||
PrintString("Auto Quick Saved Fired, SEE SCRIPT: (time_keeper) LINE 488.");
|
||
|
||
//Export all Non-Polymorphed PCs who are NOT between areas..
|
||
// DoExportCharacters(); //:: Not needed w/ NWNEE
|
||
}
|
||
//If it's a Single Player Module..
|
||
else if(nDoExport==2)
|
||
{
|
||
|
||
//Do a quick save...
|
||
DoSinglePlayerAutoSave();
|
||
}
|
||
else //Otherwise Do nothing..
|
||
{}
|
||
}
|
||
|
||
////////////////////////////////////////////////////////////////
|
||
//Global Message System
|
||
//////////////////////////
|
||
|
||
//If Global Messaging is turned on..
|
||
if(nMsgONOFF==1)
|
||
{
|
||
|
||
int nMC2 = GetLocalInt(oMe, "MSGCOUNT");
|
||
int nTimesN;
|
||
|
||
if(nMC2==0)//can't multiply by 0 to get the interval!
|
||
{ nTimesN = nMsgTime; }//The Interval Variable
|
||
|
||
else
|
||
{
|
||
//The # of Counts * The Interval Variable.
|
||
nTimesN = nMC2*nMsgTime;
|
||
}
|
||
|
||
//If the Total # of Minutes = (The Interval * The Interval Count)
|
||
if((nTimesN==nMin) && (nSecond==6)) //Check only Once / minute!
|
||
{
|
||
//Define the Increment Count (to be set.)
|
||
if(nMC2>0)
|
||
{nInc2 = nMC2 + 1;}
|
||
|
||
//NOTE: The first Count MUST be set to 2! (2 x interval = Next Interval)
|
||
else
|
||
{nInc2 = 2;}
|
||
|
||
//Increment the Stored Interval Count
|
||
SetLocalInt(oMe, "MSGCOUNT", nInc2);
|
||
|
||
//Send the message!
|
||
SendMsgToAllPCs(sColor + sMainMessage);
|
||
}
|
||
|
||
//End Global Messaging System..
|
||
}
|
||
|
||
/////////////////////////////////////////
|
||
//Global Game Time & Date Message System
|
||
////////////////////////////////////////
|
||
|
||
//Let's see if we are suppose to send this message..
|
||
if(nGameTimeMsg ==1)
|
||
{
|
||
if(GetLocalInt(oMe, "DIDTHIS")!=1)
|
||
{
|
||
//Send messages to all PCs every 15 minutes!
|
||
if((nMinute==5 || nMinute==20 || nMinute==35 || nMinute==50) && (nSecond==6))
|
||
{
|
||
|
||
//Make the timekeeper do a Timestop Effect Every 30 minutes.
|
||
ApplyEffectAtLocation(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_FNF_TIME_STOP), GetLocation(oMe));
|
||
|
||
//Send the Colorful Game Time Message
|
||
SendMsgToAllPCs(sColor + sTime);
|
||
}
|
||
}
|
||
|
||
//End Global Game Time Message
|
||
}
|
||
|
||
|
||
///////////////////////////////////////////////////////////////
|
||
//Main Script End
|
||
}
|
||
|
||
///////////////////////////////////////////////////////////////
|
||
//////////###### DEFINE PROTOTYPES ######////////////////////
|
||
///////////////////////////////////////////////////////////////
|
||
|
||
////////////////////////////////////////////////////////////////////// `
|
||
//PROTOTYPE DEFINED
|
||
void SendMsgToAllPCs(string sMsg)
|
||
{
|
||
|
||
object oPC = GetFirstPC();
|
||
|
||
//Send Message to All PC's Function
|
||
while(GetIsObjectValid(oPC))
|
||
{
|
||
FloatingTextStringOnCreature(sMsg, oPC, TRUE);
|
||
|
||
//Find the next player if one exist!
|
||
oPC = GetNextPC();
|
||
}
|
||
|
||
//PROTOTYPE END
|
||
}
|
||
|
||
/////////////////////////////////////////////////////////////////////////
|
||
//PROTOTYPE DEFINED
|
||
void DoExportCharacters()
|
||
{
|
||
int nMorph;
|
||
|
||
//We are going to Export All Non-Shifted Player
|
||
//Who are NOT between areas..
|
||
|
||
object oObject = GetFirstPC();
|
||
while(GetIsObjectValid(oObject))
|
||
{
|
||
nMorph = GetHasEffect(EFFECT_TYPE_POLYMORPH, oObject);
|
||
if(GetArea(oObject)!=OBJECT_INVALID)
|
||
{
|
||
if(nMorph == FALSE)
|
||
{
|
||
//Always export before a restart...
|
||
ExportSingleCharacter(oObject);
|
||
SendMessageToPC(oObject, "Character Saved!");
|
||
}
|
||
}
|
||
oObject = GetNextPC();
|
||
}
|
||
|
||
//PROTOTYPE END
|
||
}
|
||
|
||
////////////////////////////////////////////////////////////////////////
|
||
//PROTOTYPE DEFINED
|
||
void GiveWarnings(string sMC)
|
||
{
|
||
object oPC;
|
||
location lVis;
|
||
string sColor = sMC;
|
||
|
||
//Only do this one time!
|
||
if(GetLocalInt(OBJECT_SELF, "SENDVISUALS")!=1)
|
||
{
|
||
|
||
SetLocalInt(OBJECT_SELF, "SENDVISUALS", 1);
|
||
|
||
//Export all characters first...
|
||
DoExportCharacters();
|
||
|
||
//Do the Reset Visuals..
|
||
oPC = GetFirstPC();
|
||
while(GetIsObjectValid(oPC))
|
||
{
|
||
|
||
//Next, after a delay, show everyone the server or module is restarting!
|
||
lVis = GetLocation(oPC);
|
||
ApplyEffectAtLocation(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_FNF_TIME_STOP), lVis, 0.0);
|
||
ApplyEffectAtLocation(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_FNF_SCREEN_SHAKE), lVis, 0.0);
|
||
FloatingTextStringOnCreature(sColor + "THE MODULE IS RESTARTING!", oPC, TRUE);
|
||
ApplyEffectAtLocation(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_FNF_METEOR_SWARM), lVis, 0.0);
|
||
FloatingTextStringOnCreature(sColor + "THE MODULE IS RESTARTING!", oPC, TRUE);
|
||
FloatingTextStringOnCreature(sColor + "THE MODULE IS RESTARTING!", oPC, TRUE);
|
||
FloatingTextStringOnCreature(sColor + "THE MODULE IS RESTARTING!", oPC, TRUE);
|
||
FloatingTextStringOnCreature(sColor + "THE MODULE IS RESTARTING!", oPC, TRUE);
|
||
|
||
oPC = GetNextPC();
|
||
}
|
||
}
|
||
|
||
//PROTOTYPE END
|
||
}
|
||
|
||
/////////////////////////////////////////////////////////////////////
|
||
//PROTOTYPE DEFINED
|
||
|
||
void BootAll()
|
||
{
|
||
//Boot all of the PCs who have remained
|
||
object oObject = GetFirstPC();
|
||
while(GetIsObjectValid(oObject))
|
||
{
|
||
BootPC(oObject);
|
||
|
||
oObject = GetNextPC();
|
||
}
|
||
|
||
//End Prototype
|
||
}
|
||
|
||
/////////////////////////////////////////////////////////////////////////
|
||
//////////PROROTYPE DEFINED
|
||
|
||
//This Prototype is critical to the module, as it determines when to do reset.
|
||
void DoResetCheck(string sMC, int nTMin)
|
||
{
|
||
/* object oMe = OBJECT_SELF;
|
||
string sColor = sMC;
|
||
|
||
//Get the Module HeartBeats to count up total Minutes..
|
||
object oKeeper = GetModule();
|
||
int nBeat = GetLocalInt(oKeeper, "MODULE_BEAT");
|
||
int nSec = GetLocalInt(GetModule(), "MOD_SECONDS");
|
||
|
||
///(Total Time Passed by in seconds converted to minutes)///
|
||
int nTotalMin = nBeat/60;
|
||
|
||
//The int used to determine time till reset...
|
||
int nDelay;
|
||
int nDelayedTime;
|
||
|
||
//Time that delays are allowed to be used...
|
||
int nTime2Delay = nMinTillReset - 33;
|
||
|
||
//The check to see if we have done this before..
|
||
int nDelayCheck = GetLocalInt(GetModule(), "NO_MORE_DELAYS");
|
||
int nStopDelayCheck = GetLocalInt(GetModule(), "STOP_DELAY_CHECK");
|
||
int nStopDelays = GetLocalInt(GetModule(), "STOP_DELAYS");
|
||
|
||
///////////////////////////////////////////////////////////////
|
||
//If it's time to allow delays.. (33 min till restart)
|
||
if((nTotalMin == nTime2Delay) && (nStopDelayCheck !=1))
|
||
{
|
||
|
||
//Only do this one time...
|
||
SetLocalInt(GetModule(), "STOP_DELAY_CHECK", 1);
|
||
|
||
//Set that the PCs can now delay reset...
|
||
SetLocalInt(GetModule(), "DELAY_OK", 0);
|
||
}
|
||
|
||
////////////////////////////////////////////////////////////
|
||
|
||
//Define the delay of Reset...
|
||
if(GetLocalInt(GetModule(), "RESET_DELAY")==3)
|
||
{
|
||
//Note: This is only checked on time...
|
||
if(nStopDelays==0)
|
||
{
|
||
nDelay = nTotalMin - 15; //Delay reset for 15 minutes
|
||
nDelayedTime = nDelay * 60;
|
||
SetLocalInt(GetModule(), "MODULE_BEAT", nDelayedTime);
|
||
SetLocalInt(GetModule(), "STOP_DELAYS", 1);
|
||
WriteTimestampedLogEntry("*******TIME WAS DELAYED 15 MINUTES**********");
|
||
}
|
||
//Otherwise there is no delay...
|
||
else
|
||
{
|
||
nDelay = nTotalMin;
|
||
}
|
||
|
||
//End If Statement
|
||
}
|
||
|
||
else if(GetLocalInt(GetModule(), "RESET_DELAY")==6)
|
||
{
|
||
//Note this is only checked one time!
|
||
if(nStopDelays==1) //Note the 15 min delay MUST occur first..
|
||
{
|
||
nDelay = nTotalMin - 15; //Delay reset for 30 minutes (Was delayed for 15 already!)
|
||
nDelayedTime = nDelay * 60;
|
||
SetLocalInt(GetModule(), "MODULE_BEAT", nDelayedTime);
|
||
SetLocalInt(GetModule(), "STOP_DELAYS", 1); //do this delay 1 time only!
|
||
WriteTimestampedLogEntry("*******TIME WAS DELAYED 30 MINUTES**********");
|
||
//Stop all future Delays!
|
||
SetLocalInt(GetModule(), "DELAY_OK", 1);
|
||
}
|
||
//Otherwise there is no delay...
|
||
else
|
||
{
|
||
nDelay = nTotalMin;
|
||
}
|
||
//End Else If Statement
|
||
}
|
||
|
||
//Otherwise there is no delay...
|
||
else
|
||
{
|
||
nDelay = nTotalMin;
|
||
}
|
||
|
||
///////////////////////////////////////////////////////////
|
||
//Actual Reset Check
|
||
|
||
int nCheck = nDelay + 30; //30 minutes till reset
|
||
int nCheck1 = nDelay + 20; //20 minutes till reset
|
||
int nCheck2 = nDelay + 10; //10 minutes till reset
|
||
int nCheck3 = nDelay + 5; // 5 minutes till reset
|
||
int nCheck4 = nDelay + 1; // 1 minute till reset
|
||
int nCheck5 = nDelay; //Time to restart...
|
||
|
||
//If it's 30 min till restart..(do only one time!)
|
||
if(nCheck == nMinTillReset && nSec==6)
|
||
{
|
||
SendMsgToAllPCs(sColor + "30 Minutes Till Reset!");
|
||
AssignCommand(oMe, ActionSpeakString("30 Minutes Till Reset!", TALKVOLUME_SHOUT));
|
||
|
||
DelayCommand(1.0, SendMsgToAllPCs(sColor + "You can delay Reset 15 minutes by typing (!DelayReset)"));
|
||
DelayCommand(2.0, SendMsgToAllPCs(sColor + "At least 3 Players Must Type (!DelayReset)"));
|
||
|
||
}
|
||
|
||
//If it's 20 minutes till restart...(do only one time!)
|
||
else if(nCheck1 == nMinTillReset && nSec==6)
|
||
{
|
||
|
||
SendMsgToAllPCs(sColor + "20 Minutes Till Reset!");
|
||
AssignCommand(oMe, ActionSpeakString("20 Minutes Till Reset!", TALKVOLUME_SHOUT));
|
||
DelayCommand(1.0, SendMsgToAllPCs(sColor + "You can delay Reset 15 minutes by typing (!DelayReset)"));
|
||
DelayCommand(2.0, SendMsgToAllPCs(sColor + "At least 3 Players Must Type (!DelayReset)"));
|
||
|
||
}
|
||
|
||
//If it's 10 minutes till restart (do only one time!)
|
||
else if(nCheck2 == nMinTillReset && nSec==6)
|
||
{
|
||
SendMsgToAllPCs(sColor + "10 Minutes Till Reset!");
|
||
DelayCommand(1.0, SendMsgToAllPCs(sColor + "10 Minutes Till Reset!"));
|
||
DelayCommand(2.0, SendMsgToAllPCs(sColor + "10 Minutes Till Reset!"));
|
||
AssignCommand(oMe, ActionSpeakString("10 Minutes Till Reset!", TALKVOLUME_SHOUT));
|
||
SetLocalInt(GetModule(), "NO_MORE_DELAYS", 1);
|
||
WriteTimestampedLogEntry("10 Minutes Till Server Restart");
|
||
}
|
||
|
||
//If it's 5 Minutes till restart.. (do only one time!)
|
||
else if(nCheck3 == nMinTillReset && nSec==6)
|
||
{
|
||
SendMsgToAllPCs(sColor + "5 Minutes Till Reset!");
|
||
AssignCommand(oMe, ActionSpeakString("5 Minutes Till Reset!", TALKVOLUME_SHOUT));
|
||
DelayCommand(1.0, SendMsgToAllPCs(sColor + "5 Minutes Till Reset!"));
|
||
DelayCommand(2.0, SendMsgToAllPCs(sColor + "5 Minutes Till Reset!"));
|
||
WriteTimestampedLogEntry("5 Minutes Till Server Restart");
|
||
}
|
||
|
||
//If it's 1 Minute till restart...
|
||
else if(nCheck4 == nMinTillReset && nSec==6)
|
||
{
|
||
SendMsgToAllPCs(sColor + "WARNING: 1 Minute Till Reset!!!");
|
||
AssignCommand(oMe, ActionSpeakString("1 Minutes Till Reset!", TALKVOLUME_SHOUT));
|
||
DelayCommand(1.0, SendMsgToAllPCs(sColor + "WARNING: 1 Minute Till Reset!!!"));
|
||
DelayCommand(2.0, SendMsgToAllPCs(sColor + "WARNING: 1 Minute Till Reset!!!"));
|
||
DelayCommand(3.0, SendMsgToAllPCs(sColor + "WARNING: 1 Minute Till Reset!!!"));
|
||
WriteTimestampedLogEntry("1 Minute Till Server Restart");
|
||
}
|
||
|
||
//If it's time for restart...
|
||
else if(nCheck5 >= nMinTillReset)
|
||
{
|
||
//Delayed after 50 seconds (give the 10 second warning..)
|
||
//Do visual effects too..
|
||
GiveWarnings(sColor);
|
||
|
||
//If we are reloading the module..
|
||
if(nReload == 1)
|
||
{
|
||
|
||
DelayCommand(15.0, WriteTimestampedLogEntry("*****MODULE RELOADING*****"));
|
||
|
||
//Re-Load the current module.. (This is NOT a Server Reset!)
|
||
DelayCommand(17.0, StartNewModule(sModuleName));
|
||
}
|
||
|
||
//If we are restarting the server..
|
||
if(nRestart ==1)
|
||
{
|
||
|
||
DelayCommand(8.0, BootAll());
|
||
|
||
WriteTimestampedLogEntry("*****SERVER RESTART INITIALIZED*****");
|
||
|
||
//If using NWNX2 On the Server do this reset...
|
||
if(nNWNX2 ==1)
|
||
{
|
||
DelayCommand(9.0, SetLocalString(GetModule(), "NWNX!RESETPLUGIN!SHUTDOWN", "1"));
|
||
}
|
||
|
||
//Otherwise use the Standard NWN Reset Option
|
||
else
|
||
{
|
||
WriteTimestampedLogEntry("Attempting To Crash Server");
|
||
DelayCommand(9.0, SetListening(GetModule(), TRUE));
|
||
DelayCommand(9.1, SetListenPattern(GetModule(),"**", 2500));
|
||
}
|
||
|
||
//If Statement End
|
||
}
|
||
|
||
|
||
//else if end
|
||
}
|
||
|
||
|
||
//PROTOTYPE END */
|
||
}
|
||
|
||
//////////////////////////////////////////////////////////////////
|
||
///////////********SCRIPT END*************///////////////////////
|
||
////////////////////////////////////////////////////////////////
|
||
/////Welcome to the 800 Club with your host Genisys(Guile//////
|
||
//////////////////////////////////////////////////////////////
|