// Resting Script by Fractal // FileName frc_rest /* This script goes to OnPlayerRest in the Module's Properties Made for THAIN module, on April 20th, 2003 */ #include "uth__inc_resting" void main() { object oPC = GetLastPCRested(); int nRestType = GetLastRestEventType(); int nRestsLeft, iNextRest = 0; //Only do extended resting funstions for PCs if (!GetIsPC(oPC)) return; // Define Sleep effects effect eSleepy = EffectLinkEffects(EffectBlindness(), EffectDeaf()); eSleepy = SupernaturalEffect(eSleepy); effect eGroggy = EffectSlow(); eGroggy = SupernaturalEffect(eGroggy); // Calculate wake up period for char float fWakeUpTime = 30.00 - IntToFloat(3* GetAbilityModifier(ABILITY_CONSTITUTION, oPC)); if(fWakeUpTime <= 20.00) fWakeUpTime = 20.00; switch (nRestType) { // Starting to Rest case REST_EVENTTYPE_REST_STARTED: // Remove Spells on Items RemoveItemBuffs(oPC); //Apply Sleep Effects ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eSleepy, oPC, fWakeUpTime); ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eGroggy, oPC, fWakeUpTime + 5.00); nRestsLeft = GetNumberOfRestsLeft(oPC); // we have rests left in our rest period if (nRestsLeft > 0) { //If this is the first rest, reset the time period if (nRestsLeft == 4) SetStartOfRestPeriod(oPC); // Deduct this rest from the number of rests left SetNumberOfRestsLeft(oPC, nRestsLeft - 1); // and let the PC know SendMessageToPC(oPC, "You have " + IntToString(nRestsLeft - 1) + " rests left."); } else { // calculate hours until next possible rest iNextRest = 9 - ((GetTimeInMinutes() - GetStartOfRestPeriod(oPC)) / THAIN_MINUTES_PER_HOUR); // make PC collapse from exhaustion AssignCommand(oPC, ClearAllActions()); effect eCollapse = EffectKnockdown(); ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eCollapse, oPC, fWakeUpTime -10); // Notify PC of rest restrictions SendMessageToPC(oPC, "You cannot rest yet."); SendMessageToPC(oPC, "You must wait " + IntToString(iNextRest) + " hour(s) before you can rest again."); // Remove Sleep Effects prematurely DelayCommand(5.00, RemoveEffect(oPC, eSleepy)); DelayCommand(5.00, RemoveEffect(oPC, eGroggy)); } break; // Rest completed case REST_EVENTTYPE_REST_FINISHED: // Remove Sleep effect RemoveEffect(oPC, eSleepy); break; // Rest interrupted case REST_EVENTTYPE_REST_CANCELLED: break; } }