Ok. After poking around a lot last night I just made everything worse so I got back to an earlier version of the area and started anew. It seems that the ActionJumpToLocation doesn’t really work in this instance. Now I have a version of the script and the area that works most of the time. I guess I will just have to settle for that. I’m going crazy over this and how buggy and timing sensitive this whole game is. It’s driving me nuts. I found another sitting script among my scripts that I don’t know where it came from. I copied a line from there and that is the best solution yet. As I said, it works most of the time now. This is your somewhat modified script I’m using now (the code as usual looks like crap 'cause I can’t remember what kevL_s told me to do to make it appear so that a normal person can read this code here on the forums, the tabs are just nuts. I tried correcting it in Notepad++ but when it looks fine there and in the toolset it, as usual, looks like crap here):
void ActionPlayCustomAnimation(object oObject, string sAnimationName, int nLooping, float fSpeed = 1.0f)
{
PlayCustomAnimation(oObject, sAnimationName, nLooping, fSpeed);
}
// float GetNormalizedDirection(float fDirection):
// * This script returns a direction normalized to the range 0.0 - 360.0
// * Copyright (c) 2002 Floodgate Entertainment
// * Created By: Naomi Novik
// * Created On: 11/08/2002
float GetNormalizedDirection(float fDirection)
{
float fNewDir = fDirection;
while (fNewDir >= 360.0) {
fNewDir -= 360.0;
}
while (fNewDir <= 0.0) {
fNewDir += 360.0;
}
return fNewDir;
}
void SitDown(object oSitter, object oChair)
{
//AssignCommand(oSitter, SetFacing(GetNormalizedDirection(GetFacing(oChair)+180.00+GetLocalFloat(oChair,"rotate")) ));
AssignCommand(oSitter, ActionPlayCustomAnimation(OBJECT_SELF, "sitidle", 1, 1.0));
// EXTRA CODE THANKS TO SHAUGHN & EGUINTIR
SetOrientOnDialog(oSitter,FALSE);
SetBumpState(oSitter,BUMPSTATE_UNBUMPABLE);
}
void main()
{
object oChair = OBJECT_SELF;
object oSitter = GetLastUsedBy();
object oCheckSitter = GetLocalObject(oChair, "LastSeated");
string sChair = GetTag(oChair);
string sAutofit = GetLocalString(oChair, "autofit");
//SendMessageToAllPCs("Chair used by " + GetName(oSitter));
// RETRIEVE VARS ATTACHED TO CHAIR
int iHeading = GetLocalInt(oChair, "degree");
//string sName = GetFirstName(oChair);
int iPC_size = GetLocalInt(oChair, "size");
//Assign the heading degrees
location lChair_o = GetLocation(oChair);
location lChair = Location(GetArea(oChair), GetPositionFromLocation(lChair_o), GetNormalizedDirection(GetFacingFromLocation(lChair_o) + iHeading));
// CHECK THE SEAT IS FREE
if(GetLocalObject(oChair, "LastSeated") != OBJECT_INVALID && oSitter != oCheckSitter)
{
FloatingTextStringOnCreature("<<< The seat is already being used by somebody. >>>", oSitter, FALSE);
return;
}
// SEAT THE USER & ASSOCIATE SEAT WITH NPC FOR RETURN SEAT
if(oSitter != OBJECT_INVALID)
{
SetLocalObject(oChair, "LastSeated", oSitter);
SetLocalObject(oSitter, "Seated", oChair);
}
// JUST USE THE STANDARD CHAIRS
AssignCommand(oSitter, ActionMoveToLocation(lChair));
DelayCommand(1.5, AssignCommand(oSitter, SetFacing( GetNormalizedDirection(GetFacing(oChair)+180.0+GetLocalFloat(oChair,"pl_rotate")) )));
DelayCommand(0.5, SitDown(oSitter, oChair));
}
EDIT: If forgot to mention that now everyone sits down on their chairs, even if it takes a second or two, which looks kind of lame, but whatever, but when they sit down on one of Patcha’s benches they face in the wrong direction. Therefore did a variation of this script, it’s mostly just exactly like Lance’s original, just without this line:
DelayCommand(1.5, AssignCommand(oSitter, SetFacing( GetNormalizedDirection(GetFacing(oChair)+180.0+GetLocalFloat(oChair,"pl_rotate")) )));
DelayCommand(0.5, SitDown(oSitter, oChair));
}
When doing that the NPCs sitting on the benches face mostly in the right direction. Two of them sit a bit diagonally, if you get what I mean, but I can live with that.
EDIT2: And now another strange bug has appeared. When going out of the inn, if one uses one of the companions to open the door and click on to be teleported, the game hangs/crashes. I mostly just use the PC to do all this stuff but I don’t know why it would behave this way. Maybe it’s because I have a script on the door with some local int checks, so that you can’t leave the inn if you’re in the middle of a quest that needs completion inside…uurrgh, this game gets on my nerves some times.