111 lines
3.6 KiB
Plaintext
111 lines
3.6 KiB
Plaintext
//------------------------------------------------------------------------------
|
|
// File Name : uth__inc_resting
|
|
// Created: March 18th, 2005
|
|
// Creator: Uthoroc
|
|
// Function: Creates functions to handle additional resting options (wandering
|
|
// monsters, etc.)
|
|
//------------------------------------------------------------------------------
|
|
|
|
#include "uth__inc_time"
|
|
|
|
// INTERFACE
|
|
//------------------------------------------------------------------------------
|
|
// Constants
|
|
|
|
// Sets the time period in hours, after which number of rests is reset
|
|
const int THAIN_REST_PERIOD = 8;
|
|
// Default number of rests a char may do
|
|
const int THAIN_RESTS_PER_PERIOD = 4;
|
|
const string LOC_STRING_RESTS_LEFT = "nRestsLeft";
|
|
const string LOC_STRING_START_PERIOD = "nStartOfRestPeriod";
|
|
|
|
// Functions
|
|
|
|
// Remove All Item Buffs from a Resting Player regardless who cast the spells
|
|
void RemoveItemBuffs(object oPC);
|
|
// Sets the current time as start of the rest period (in game minutes)
|
|
void SetStartOfRestPeriod(object oPC);
|
|
// Gets the start time of the current rest period (in game minutes)
|
|
int GetStartOfRestPeriod(object oPC);
|
|
// Sets how many times PC can still rest in the current rest period
|
|
void SetNumberOfRestsLeft(object oPC, int nNumberOfRests);
|
|
// Checks how many times PC can still rest in the current rest period
|
|
int GetNumberOfRestsLeft(object oPC);
|
|
|
|
//------------------------------------------------------------------------------
|
|
// IMPLEMENTATION
|
|
//------------------------------------------------------------------------------
|
|
|
|
void RemoveItemBuffs(object oPC)
|
|
{
|
|
object oItem;
|
|
effect eEffect;
|
|
int iSlotCounter;
|
|
int bEffectRemoved;
|
|
|
|
// cycle through all Equipment Slots
|
|
for(iSlotCounter = 0; iSlotCounter <= NUM_INVENTORY_SLOTS; iSlotCounter ++)
|
|
{
|
|
oItem = GetItemInSlot(iSlotCounter, oPC);
|
|
// check through all effects on the item
|
|
eEffect = GetFirstEffect(oItem);
|
|
while (GetIsEffectValid(eEffect))
|
|
{
|
|
// if it is a temporary effect, remove it
|
|
if(GetEffectDurationType(eEffect) == DURATION_TYPE_TEMPORARY)
|
|
{
|
|
RemoveEffect(oItem, eEffect);
|
|
bEffectRemoved = 1;
|
|
}
|
|
eEffect = GetNextEffect(oItem);
|
|
}
|
|
}
|
|
|
|
// Notify the player if any effect was removed
|
|
if(bEffectRemoved != 0)
|
|
SendMessageToPC(oPC, "As you rest the magic cast upon your equipment fades.");
|
|
}
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
void SetStartOfRestPeriod(object oPC)
|
|
{
|
|
SetLocalInt(oPC, LOC_STRING_START_PERIOD, GetTimeInMinutes());
|
|
}
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
int GetStartOfRestPeriod(object oPC)
|
|
{
|
|
return GetLocalInt(oPC, LOC_STRING_START_PERIOD);
|
|
}
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
void SetNumberOfRestsLeft(object oPC, int nNumberOfRests)
|
|
{
|
|
SetLocalInt(oPC, LOC_STRING_RESTS_LEFT, nNumberOfRests);
|
|
}
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
int GetNumberOfRestsLeft(object oPC)
|
|
{
|
|
int nFirstRestTime = GetStartOfRestPeriod(oPC);
|
|
int nCurrentTime = GetTimeInMinutes();
|
|
|
|
// Has time period passed after first rest of PC ?
|
|
if((nCurrentTime - nFirstRestTime) > (THAIN_REST_PERIOD * THAIN_MINUTES_PER_HOUR))
|
|
// then reset number fo rests to base
|
|
SetNumberOfRestsLeft(oPC, THAIN_RESTS_PER_PERIOD);
|
|
|
|
return GetLocalInt(oPC, LOC_STRING_RESTS_LEFT);
|
|
}
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|