Skip to content

Persistent Location Script not working in NWN:EE

Hello,

The persistent location script I have been using for years no longer functions in NWN:EE I was wondering if someone might have some insight?

void LodPlayer(object oPC)
{


string playnam = GetPCPlayerName(oPC);
location playloc = GetLocation(oPC);

if(GetLocalInt(oPC, "load") <= 3){
DelayCommand(3.0, AssignCommand(oPC, JumpToLocation(GetCampaignLocation("trimmelonLocations", playnam, oPC))));
SetLocalInt(oPC, "load", 5);
}
}



void SavPlayer(object oPC) {


string playnam = GetPCPlayerName(oPC);
location playloc = GetLocation(oPC);

SetCampaignLocation("trimmelonLocations", playnam, playloc, oPC);



}



void SavAllPlayers() {

object oPC = OBJECT_INVALID;


oPC = GetFirstPC();

while (oPC != OBJECT_INVALID) {
PrintString("Saving all players: Found valid player");

if (GetIsObjectValid(GetArea(oPC)) == TRUE) {

SavPlayer(oPC);
}

oPC = GetNextPC();
}
}

Comments

  • NeverwinterWightsNeverwinterWights Member Posts: 339
    edited July 2018
    That all compiles just fine.

    These would just be functions that would be in their own # include script or added to other scripts that call each of these functions when needed. So for example in your OnPlayerRest script you might have the line:

    SavePlayer(oPC);

    which would work so long as you add a line at the top of the script:

    # include "whatever_includescript_these_functions_are_in"

    It looks like there is more to these functions though. In the first function "LodPlayer" there is a local int "load" being checked and set. 3 or less then do stuff and then set it to 5. So somewhere else this is likely being changed for whatever reasons. Why is it 3 or less? Why then set to 5? Etc..
  • ShadooowShadooow Member Posts: 402
    I already answered this on vault forums where he reposted it.

    In short - storing persistent locations as location doesn't work properly because the location contains area ID in it and area ID will change whenever you add or remove new area in module (which then leads either into invalid location thus the script will break and won't teleport player anywhere or teleporting player to different area).

    To workaround this, you need to store location by parts - store area tag, store area position vector, store area facing angle separately, then retrieve these informations and assemble area from them using ffunction Location()
  • NeverwinterWightsNeverwinterWights Member Posts: 339
    Shadooow said:

    I already answered this on vault forums where he reposted it.

    In short - storing persistent locations as location doesn't work properly because the location contains area ID in it and area ID will change whenever you add or remove new area in module (which then leads either into invalid location thus the script will break and won't teleport player anywhere or teleporting player to different area).

    To workaround this, you need to store location by parts - store area tag, store area position vector, store area facing angle separately, then retrieve these informations and assemble area from them using ffunction Location()

    I understand all that but that solution also pertains to pre EE versions. He did say it was "working" for years before EE meaning he probably hadn't changed any areas. Was it due to adding the areas to a new EE module? Does that change most of the IDs?
  • ShadooowShadooow Member Posts: 402

    I understand all that but that solution also pertains to pre EE versions. He did say it was "working" for years before EE meaning he probably hadn't changed any areas. Was it due to adding the areas to a new EE module? Does that change most of the IDs?

    Either saving module or just moving onto NWN:EE changed area IDs. Or he did made new area (or remove one) after he moved onto NWN:EE.

    This was always an issue even in 1.69.
  • birdman076birdman076 Member Posts: 29
    I did a lot of area additions during 1.69 and it always worked without fail, maybe i just got lucky.
Sign In or Register to comment.