/************************************************************************ * script name : eE_OnAreaExit * created by : eyesolated * date : 2011/6/1 * * description : eE's OnAreaExit Script keeps track of current players * in the Area and resets encounters as necessary when no more * players are in the Area * * changes : 2010/6/1 - eyesolated - Initial creation ************************************************************************/ #include "ee_inc" void main() { object oArea; object oPC; if (GetObjectType(OBJECT_SELF) == OBJECT_TYPE_CREATURE) // Creature called this script (PC in OnClientLeave) { oArea = GetLocalObject(oPC, eE_VAR_PC_CURRENT_AREA); // if oArea is Invalid, we already registered the PCs OnExit and can safely return if (oArea == OBJECT_INVALID) return; oPC = OBJECT_SELF; } else { oArea = OBJECT_SELF; oPC = GetExitingObject(); } // Delete the Area helper var DeleteLocalObject(oPC, eE_VAR_PC_CURRENT_AREA); // If not a valid PC, exit! if (!eE_GetIsPC(oPC)) return; // Retrieve and recude area's playercount int nPlayerCount = GetLocalInt(oArea, eE_VAR_AREA_PLAYERCOUNT); nPlayerCount--; SetLocalInt(oArea, eE_VAR_AREA_PLAYERCOUNT, nPlayerCount); //SendMessageToPC(oPC, "Exiting Area... there are now " + IntToString(nPlayerCount) + " players left."); // If the player count reached 0, reset all initialized encounters if (nPlayerCount == 0) { // We need to get all Encounters in the Area Encounter Array and reset those object oEncounter; while (eas_Array_GetSize(oArea, eE_VAR_AREA_ENCOUNTERARRAY_INI) > 0) { eE_DebugMSG(oEncounter, "no more players in Area, resetting encounter"); oEncounter = eas_OArray_Entry_Get(oArea, eE_VAR_AREA_ENCOUNTERARRAY_INI, 0); ExecuteScript(eE_SCRIPT_ENCOUNTER_RESET, oEncounter); } // Then, we need to do silent wipe checks for all encounters that are in Progress int nEncountersInProgress = eas_Array_GetSize(oArea, eE_VAR_AREA_ENCOUNTERARRAY_PROG); int n; for (n = 0; n < nEncountersInProgress; n++) { eE_DebugMSG(oEncounter, "no more players in Area, initiating wipe check"); oEncounter = eas_OArray_Entry_Get(oArea, eE_VAR_AREA_ENCOUNTERARRAY_PROG, n); float fDespawn = GetLocalFloat(oEncounter, eE_VAR_DESPAWNINTERVAL); /* Area sized encounters don't give a wipe warning SendMessageToPC(oPC, "You have " + FloatToString(fDespawn, 0, 2) + " seconds to return to the encounter area and prevent a wipe."); */ AssignCommand(GetModule(), DelayCommand(fDespawn, ExecuteScript(eE_SCRIPT_ENCOUNTER_WIPE, oEncounter))); } } }