Battledale_PRC8/_module/nss/inc_tavern.nss
Jaysyn904 7b9e44ebbb Initial upload
Initial upload.  PRC8 has been added.  Module compiles, PRC's default AI & treasure scripts have been integrated.  Started work on top hak for SLA / Ability / Scripting modifications.
2024-03-11 23:44:08 -04:00

67 lines
2.0 KiB
Plaintext

//::///////////////////////////////////////////////
//:: inc_tavern
//:: Copyright (c) 2001 Bioware Corp.
//:://////////////////////////////////////////////
/*
*/
//:://////////////////////////////////////////////
//:: Created By: Lysandius
//:: Created On: 12-07-2002
//:://////////////////////////////////////////////
int INT_STOCKLIMIT_LOW = 5;
object OBJ_KEG_ALE = GetNearestObjectByTag("item_keg_ale");
object OBJ_CRATE_WINE = GetNearestObjectByTag("item_crate_wine");
object OBJ_CRATE_SPIRITS = GetNearestObjectByTag("item_crate_spirits");
object OBJ_CRATE_STORAGE = GetNearestObjectByTag("item_crate_storage");
object OBJ_WAYPOINT_BAR = GetNearestObjectByTag("waypoint_bar");
object OBJ_WAYPOINT_STORAGE = GetNearestObjectByTag("waypoint_storage");
object OBJ_WAYPOINT_STAIRS = GetNearestObjectByTag("waypoint_stairs");
int TransferItem(object oObjectTo, object oObjectFrom, string sItemTag, int nAmount);
void ActionCreateItemOnObject(string sItemTemplate, object oTarget);
// Transfer nAmount items from oObjectFrom to oObjectTo.
// Returns the amount of items that could NOT be transferred.
int TransferItem(object oObjectTo, object oObjectFrom, string sItemTag, int nAmount)
{
int nCount;
object oItem = GetFirstItemInInventory(oObjectFrom);
while (GetIsObjectValid(oItem))
{
string sTag = GetTag(oItem);
if (sTag == sItemTag)
{
nCount += GetNumStackedItems(oItem);
DestroyObject(oItem);
}
oItem = GetNextItemInInventory(oObjectFrom);
}
int nNeeded;
while (nCount > 0 && nAmount > nNeeded)
{
nNeeded++;
nCount--;
}
while (nNeeded > 0)
{
CreateItemOnObject(sItemTag, oObjectTo);
nNeeded--;
nAmount--;
}
while (nCount > 0)
{
DelayCommand(0.1, ActionCreateItemOnObject(sItemTag, oObjectFrom));
nCount--;
}
return nAmount;
}
void ActionCreateItemOnObject(string sItemTemplate, object oTarget)
{
CreateItemOnObject(sItemTemplate, oTarget);
}