Lightfoot8 wrote...
Why not just store a LocalLocation and the TagOf the Area.
object oPlayer = OBJECT_SELF;
location lPlayer = GetLocation(oPlayer);
string sAreaTag = GetTag(GetArea(oPlayer));
ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectVisualEffect(925), oPlayer, 0.0);
object oJewel = CreateItemOnObject("starjewel", oPlayer);
SetLocalLocation( oJewel,"JewelLoc",lPlayer);
SetLocalString ( oJewel,"JewelArea",sAreaTag);
SetCutsceneMode(oPlayer, TRUE);
DelayCommand(4.0, SetCutsceneMode(oPlayer, FALSE));
then to rebuild you location to make sure the area is correct would look something like this.
location lLoc = GetLocalLocation( oJewel,"JewelLoc");
string sAreaTag =GetLocalString ( oJewel,"JewelArea");
lLoc = Location(GetObjectByTag(sAreaTag),
GetPositionFromLocation( lLoc),
GetFacingFromLocation( lLoc)
);
I wanted to try out the above method of rebuilding a location to jump to and for the life of me I can not get it to work. I know everything else is working because of the debugging lines that I use to store the information. I even have a separate object OnUsed script which returns the stored tag, position, and facing from the iem, in a message to the player.
Here is the script I have for the player to jump to the location (the rebuilt location is currently commented out but it works the way it is now. It does NOT work with the rebuilt location):
void main()
{
object oPC = GetEnteringObject();
if (!GetIsPC(oPC)) return;
object oDBItem = GetItemPossessedBy(oPC, "Rulebook");
if (GetIsObjectValid(oDBItem))
{
SendMessageToPC(oPC, "DB Item is valid");
location lSavedLoc = GetLocalLocation(oDBItem, "PERSISTENT_LOC");
string sSavedAreaTag = GetLocalString(oDBItem, "PERSISTENT_AREA)");
/*location lLoc = Location(GetObjectByTag(sSavedAreaTag),
GetPositionFromLocation(lSavedLoc),
GetFacingFromLocation(lSavedLoc));*/
AssignCommand(oPC, ClearAllActions(TRUE));
//AssignCommand(oPC, JumpToLocation(lLoc));
AssignCommand(oPC, JumpToLocation(lSavedLoc));
}
SendMessageToPC(oPC, "Trigger or area entered.");
}
This is the section of my OnRest script that pertains to saving the location and tag:
if (GetLocalInt(GetModule(), "SAVE_CHARACTERS") == TRUE)
{
object oDBItem = GetItemPossessedBy(oPC, "Rulebook");
if (GetIsObjectValid(oDBItem))
{
SendMessageToPC(oPC, "DB Item is valid.");
SetLocalLocation(oDBItem, "PERSISTENT_LOC", GetLocation(oPC));
SetLocalString(oDBItem, "PERSISTENT_AREA", GetTag(GetArea(oPC)));
}
DelayCommand(1.0, ExportSingleCharacter(oPC));
SendMessageToPC(oPC, "Your character and location have been saved.");
}
And this is the object OnUsed script that DOES return all the information from the item:
#include "x0_i0_position"
void main()
{
object oPC = GetLastUsedBy();
object oDBItem = GetItemPossessedBy(oPC, "Rulebook");
string sArea = GetLocalString(oDBItem, "PERSISTENT_AREA");
location lLoc = GetLocalLocation(oDBItem, "PERSISTENT_LOC");
float fFace = GetFacingFromLocation(lLoc);
string sVector = VectorToString(GetPositionFromLocation(lLoc));
string sFloat = FloatToString(fFace, 18, 9);
SendMessageToPC(oPC, "The stored area tag: " + sArea + "\\nThe stored
vector: " + sVector + "\\nThe stored facing: " + sFloat);
}
I have been looking over this for a whole day now and am so frustrated with it I need another set of eyes. Am I rebuilding the location incorrectly? Or is there something else about locations that make this not work right?
Any help appreciated.
Modifié par GhostOfGod, 23 juin 2011 - 11:13 .