I've fixed this before with someone else giving me a hand, but unfortunately I lost the bloody code change @_@
Here is the code.
#include "ipi_constants"
#include "ipi_defaults"
#include "ipi_datemath_inc"
#include "pf_facade"
void ActionAutoCloseAndLock(object theObject)
{
if (GetIsOpen(OBJECT_SELF))
{ ActionCloseDoor(OBJECT_SELF); }
ActionDoCommand (SetLocked (OBJECT_SELF, TRUE));
}
void main()
{
string sInnTag = GetStringLeft(GetTag(OBJECT_SELF),
GetStringLength(sPREFIX) + 2);
object myInn = GetObjectByTag(sInnTag);
// Complain if we can't find our inn object
if (myInn == OBJECT_INVALID)
{
string msg = "ERROR: Door with tag "+ GetTag(OBJECT_SELF) +
" can't find inn placeable with tag "+ sInnTag;
SpeakString(msg);
WriteTimestampedLogEntry(msg);
return;
}
object thisPC = GetClickingObject();
string thisPCKey = GetName(thisPC) + GetPCPlayerName(thisPC);
string sRoomNumber = GetStringRight(GetTag(OBJECT_SELF),3);
string sTenantVar = "Rm" + sRoomNumber + "Tenant";
string ownerKey = GetPFCampaignString(sCampaignName, sTenantVar, myInn);
// DEBUG
//SpeakString("Your Key = "+ thisPCKey +", OwnerKey = "+ownerKey);
// Expire this agreement if necessary
string sExpireVar = "Rm" + sRoomNumber + "Expire";
string expireDateStr = GetPFCampaignString(sCampaignName, sExpireVar, myInn);
int daysLeft = 0;
if (expireDateStr != "")
daysLeft = DateStrCmp(NewDateString(), expireDateStr);
if (daysLeft < 0)
{
string msg = "Expiring contract for "+ GetName(thisPC) +
" on room "+ sRoomNumber;
WriteTimestampedLogEntry(msg);
DeletePFCampaignVariable(sCampaignName, sTenantVar, myInn);
DeletePFCampaignVariable(sCampaignName, sExpireVar, myInn);
}
else if (thisPCKey == ownerKey)
{
int roomNum = StringToInt(sRoomNumber);
string myName = "Room "+ IntToString(roomNum);
if (GetWillSavingThrow(OBJECT_SELF) == USE_ROOM_NAME)
myName = GetName(OBJECT_SELF);
string msg = "*" + myName +" opens for "+ GetName(thisPC) +"*";
ActionOpenDoor(OBJECT_SELF);
FloatingTextStringOnCreature(msg, thisPC);
DelayCommand(DOOR_DELAY, ActionAutoCloseAndLock(OBJECT_SELF));
}
}
Here is the problem: These doors lock for anyone except the person who is assigned to the inn room door. They use it and it pops right open for them. I use persistent location for players. Sometimes players will do something silly and nonsensical like logging out in their inn room. Madness, right? Well if they have their contract expire while they are offline and log back in... they're stuck behind the door and I have to port them out.
I'd hate to have to put a placeable 'escape' lever in each room. That's just immersion breaking as can be. I know it can be done because I've had the fix given to me before. I believe it had something to do with collecting the angles behind the door (from like 91 - 269 I think) and checking to see if the player is in that angle and then opening the door. Much as I've messed with it to try and figure it out myself all I've managed to do is mess it up more. The innkeepers are really mad at me for making all the inns free across the city. They've threatened to sue.
Anyone come across the same, or at least could help me figure out how to do this?