Transitions and Area Cleanup
vonstorm
Member Posts: 66
Having a heck of a time with this for some reason, cant seem to find a common cause.
When PCs transition sometimes they lose henchmen, familiars, companions etc. Also enemies flood through the transition when running away killing them before the area load screen is finished (and sometimes they dont).
I think its an on exit, area cleanup issue. Any insights?
When PCs transition sometimes they lose henchmen, familiars, companions etc. Also enemies flood through the transition when running away killing them before the area load screen is finished (and sometimes they dont).
I think its an on exit, area cleanup issue. Any insights?
// ffbj_area_clean
// created by: ffbj Administrative Team & Moderator of The Builder's Project
// put in onarea exit ffbj
void TrashObject(object oObject)
{
if (GetObjectType(oObject) == OBJECT_TYPE_DOOR)
ActionCloseDoor(oObject);
if (GetObjectType(oObject) == OBJECT_TYPE_PLACEABLE) {
if (GetTag(oObject)!= "PlayerCorpse") {
object oItem = GetFirstItemInInventory(oObject);
while (GetIsObjectValid(oItem))
{
TrashObject(oItem);
oItem = GetNextItemInInventory(oObject);
}
}
}
if (GetTag(oObject)!= "PlayerCorpse")
DestroyObject(oObject);
}
void main()
{
if(!GetIsPC(GetExitingObject()) ) {
return; }
object oPC = GetExitingObject();
if (!GetIsPC(oPC))
return;
oPC = GetFirstPC();
while (oPC != OBJECT_INVALID)
{
if (OBJECT_SELF == GetArea(oPC))
return;
else oPC = GetNextPC();
}
object oObject = GetFirstObjectInArea(OBJECT_SELF);
while (oObject != OBJECT_INVALID)
{
if (GetIsEncounterCreature(oObject))
if (GetPlotFlag(oObject) == FALSE)
DestroyObject(oObject);
if (GetObjectType(oObject)== OBJECT_TYPE_CREATURE)
if (GetPlotFlag(oObject) == FALSE)
DestroyObject(oObject);
if (GetObjectType(oObject) == OBJECT_TYPE_DOOR)
ActionCloseDoor(oObject);
oObject = GetNextObjectInArea(OBJECT_SELF);
}
object oItem = GetFirstObjectInArea();
while (GetIsObjectValid(oItem))
{
int iObjectType = GetObjectType(oItem);
switch (iObjectType) {
case OBJECT_TYPE_PLACEABLE:
if (GetTag(oItem) != "BodyBag") {
break; }
case OBJECT_TYPE_ITEM:
TrashObject(oItem); }
oItem = GetNextObjectInArea();
}
}
0
Comments
There seems to be an implicit assumption that associates have already moved to the new area when OnExit fires. If that's not working, use GetMaster iteratively to exclude associates from deletion. You'll nned to store the PC who is leaving - at present, the code uses oPC both for the exiting PC and for a loop to check that no other PCs remain.
However, it might simply be that the party has been overwhelmed by monsters before they can leave and/or following pursuit.
You can block pursuit in nw_g0_transition by returning if the creature is not a PC... but perhaps the mob is just too overwhelming and needs to be scaled back?
Probably lots of other issues - the first statement of the main section is redundant, for example.
Still a lot to learn about how NWN handles stuff.
Appreciate all the insights.