Inn Rooms and Keys
Posted: Wed Jul 31, 2013 9:41 am
Is there a copy of the system for handling keys for inn rooms anywhere or could some kind soul package it up for me?
Many thanks,
Teric
Many thanks,
Teric
Faerun Lives
https://www.alandfaraway.info/phpBB3/
https://www.alandfaraway.info/phpBB3/viewtopic.php?f=223&t=49974
I've been looking at the Blade and Stars on BG.Zelknolf wrote:There isn't a singular system; is there a particular inn that you call an ideal/ model that you'd like to emulate?
Code: Select all
void main()
{
object oPC = GetEnteringObject();
if(!GetIsPC(oPC)) return; // we don't want cats opening doors.
object oDoor = GetNearestObject(OBJECT_TYPE_DOOR);
if(GetIsObjectValid(oDoor))
{
vector vPos = GetPosition(oPC);
WriteTimeStampedLogEntry(GetName(oPC) + " has called auto unlock in area " + GetName(GetArea(oPC)) + " at location (" + FloatToInt(vPos.x) + ", " + FloatToInt(vPos.y) + ")");
SetLocked(oDoor, FALSE);
}
}
Code: Select all
string sPrefix = ""; // This should be replaced with the first part of the tags on all of your keys
string sStore = ""; // This should be replaced with the tag of the merchant who sells the keys
object oPC = GetExitingObject(oPC);
object oItem = GetFirstItemInInventory(oPC);
while(GetIsObjectValid(oItem))
{
if(GetBaseItemType(oItem) == BASE_ITEM_KEY)
{
if(GetStringLeft(GetTag(oItem), GetStringLength(sPrefix)) == sPrefix)
{
object oStore = GetObjectByTag(oStore);
if(!GetStoreContainsKey(oStore, oItem))
{
CopyItem(oItem, oStore, TRUE);
}
DestroyObject(oItem);
}
}
oItem = GetNextItemInInventory(oPC);
}
Code: Select all
int GetStoreContainsKey(object oStore, object oItem)
{
object oInv = GetFirstItemInInventory(oStore);
while(GetIsObjectValid(oInv))
{
if(GetTag(oInv) == GetTag(oItem))
return 1;
oInv = GetNextItemInInventory(oStore);
}
return 0;
}