Persistent Location Script not working in NWN:EE
birdman076
Member Posts: 29
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();
}
}
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();
}
}
0
Comments
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..
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()
This was always an issue even in 1.69.