Ancordia_PRC8/_module/nss/pseudo_qonexit.nss
Jaysyn904 102ba7dab6 Initial Commit
Initial Commit
2023-09-21 19:51:32 -04:00

80 lines
3.1 KiB
Plaintext

#include "_sh_inc_list"
#include "69_hench_lib"
void Body()
{
//A workaround to prevent the OnEnter event body from firing after loading a saved game
if (GetLocalInt(GetModule(), "LoadCooldown") == TRUE) return;
string sAreaString = GetLocalString(OBJECT_SELF, "AreaString");
int nPopulated = FALSE;
object oObject;
if (GetLocalInt(OBJECT_SELF, "Players") > 0) nPopulated = TRUE;
if (nPopulated == FALSE)
{
DeleteLocalInt(OBJECT_SELF, "IsPopulated");
DeleteLocalInt(OBJECT_SELF, "NO_ESCAPE");
DeleteLocalInt(OBJECT_SELF, "ThugNoticed");
DeleteLocalInt(OBJECT_SELF, "TributePaid");
DeleteLocalInt(OBJECT_SELF, "Level");
DeleteLocalInt(OBJECT_SELF, "AmbushPrepared");
DeleteLocalInt(OBJECT_SELF, "Duel");
DeleteLocalInt(OBJECT_SELF, "MerchantTrouble");
DeleteLocalInt(OBJECT_SELF, "DiscoveredVillage");
DeleteLocalInt(OBJECT_SELF, "DiscoveredDungeon");
DeleteLocalObject(OBJECT_SELF, "PartyLeader");
if (GetLocalInt(OBJECT_SELF, "Battle") != 0) MusicBattleChange(OBJECT_SELF, GetLocalInt(OBJECT_SELF, "Battle"));
//Delete all chests, items, demon portals and creatures in the area
oObject = GetFirstObjectInArea(OBJECT_SELF);
while (GetIsObjectValid(oObject))
{
if (GetTag(oObject) == "anc_tchest" || GetTag(oObject) == "anc_demongate" || GetObjectType(oObject) == OBJECT_TYPE_CREATURE || GetObjectType(oObject) == OBJECT_TYPE_ITEM)
{
if ( !GetIsPC(oObject) && !GetIsPC(GetMaster(oObject)) && !GetIsPC(GetMaster(GetMaster(oObject))) && !GetIsPC(GetLastMaster(oObject)) ) //do NOT delete PCs and their associates
DestroyObject(oObject);
if ( !GetIsPC(oObject) && GetIsDead(oObject) && GetLocalInt(oObject, "Escorted") == TRUE) //...unless they are a dead escorted NPC
DestroyObject(oObject);
}
/*if (GetObjectType(oObject) == OBJECT_TYPE_TRIGGER)
{
DestroyObject(oObject);
}*/
if (GetTag(oObject) == "anc_pcloot")
{
object oItem = GetFirstItemInInventory(oObject);
while (GetIsObjectValid(oItem))
{
DestroyObject(oItem);
oItem = GetNextItemInInventory(oObject);
}
DestroyObject(oObject);
}
oObject = GetNextObjectInArea(OBJECT_SELF);
}
//Add this area to the list of free areas (1.06)
string sRegionString = GetStringLeft(sAreaString, 1);
string sList = "sList"+sRegionString+"q";
object oList = GetLocalObject(GetModule(), sList);
int i;
string sListString = ListGetString(oList, i);
for (i = 1; i <= ListGetElementCount(oList); i++)
{
if (ListGetString(oList, i) == sAreaString)
{
i = -1;
break;
}
}
if (i != -1) ListAddString(oList, sAreaString);
}
}
void main()
{
DelayCommand(1.0, Body());
}