Files
Anphillia_PRC8/_module/nss/ee_trig_onexit.nss
Jaysyn904 28cdb617b3 Initial commit
Adding all of the current content for Anphillia Unlimited.
2024-01-04 07:49:38 -05:00

57 lines
2.1 KiB
Plaintext

/************************************************************************
* script name : eE_trig_onexit
* created by : eyesolated
* date : 2011/6/1
*
* description : Removes the exiting object (PC) to the Active Players
*
* changes : 2010/6/1 - eyesolated - Initial creation
************************************************************************/
// Includes
#include "eE_inc"
void main()
{
object oTrigger;
object oPC;
if (GetObjectType(OBJECT_SELF) == OBJECT_TYPE_CREATURE) // Creature called this script (PC in OnClientLeave)
{
oTrigger = GetLocalObject(oPC, eE_VAR_PC_CURRENT_TRIGGER);
// if oTrigger is Invalid, we already registered the PCs OnExit and can safely return
if (oTrigger == OBJECT_INVALID)
return;
oPC = OBJECT_SELF;
}
else
{
oTrigger = OBJECT_SELF;
oPC = GetExitingObject();
}
// Delete the Trigger helper var mi
DeleteLocalObject(oPC, eE_VAR_PC_CURRENT_TRIGGER);
// If not a valid PC, exit!
if (!eE_GetIsPC(oPC))
return;
string sTriggerTag = GetTag(oTrigger);
string sEncounterTag = GetStringRight(sTriggerTag, GetStringLength(sTriggerTag) - 3);
object oEncounter = GetNearestObjectByTag(sEncounterTag, oTrigger);
eE_RemovePlayerFromArray(oEncounter, oPC);
//SendMessageToPC(oPC, "You left the area of [" + eE_GetEncounterName(oEncounter) + "]. There are " + IntToString(eE_GetPlayerCountFromArray(oEncounter)) + " active players left.");
// When there are no more players left and the encounter is in progress, this is a wipe
if ((eE_GetPlayerCountFromArray(oEncounter) == 0) && (eE_GetEncounterStatus(oEncounter) == eE_ENCOUNTER_STATUS_INPROGRESS))
{
float fDespawn = GetLocalFloat(oEncounter, eE_VAR_DESPAWNINTERVAL);
SendMessageToPC(oPC, "You are the last player that left the encounter area. 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)));
}
}