2024-06-20 15:47:42 -04:00

84 lines
2.7 KiB
Plaintext

//::///////////////////////////////////////////////
//:: Persistent Container OnOpen Script
//:: Copyright (c) 2001 Bioware Corp.
//:://////////////////////////////////////////////
/*
usage:
attach this script to the OnOpen event of a container
info:
you can customize several parameters:
specify maximum capacity using WillSafe property
choose object TAG for ID generation (ReflexSafe = 0)
!! use this to share inventories
!! use this for moving inventories (like creatures)
choose automatic ID generation for stationary containers (ReflexSafe = 1).
!! probably the best, coz container does not need a specific tag
use player for ID generation (ReflexSafe = 2)
!! use this for player vaults. each player gets his own inventory
!! from the same container
you can easily map those properties to something else, in case you use
this include file for creature/merchant inventory..
*/
//:://////////////////////////////////////////////
//:: Created By: Knat
//:: Created On: 28.4.03
//:://////////////////////////////////////////////
#include "PINV_inc"
void main()
{
object oUser = GetLastOpenedBy();
if(!GetIsPC(oUser)) return;
// one time initialization
if(!GetLocalInt(OBJECT_SELF,"INIT"))
{
// no longer needed thanks to patch 1.30
//PINV_BlockItemByType(BASE_ITEM_MAGICROD);
//PINV_BlockItemByType(BASE_ITEM_MAGICWAND);
//PINV_BlockItemByType(BASE_ITEM_MAGICSTAFF);
// reject items with "NODROP" anywhere in the tag
PINV_BlockItemByFilter("**NODROP**");
SetLocalInt(OBJECT_SELF,"INIT",TRUE);
}
if(!GetLocalInt(OBJECT_SELF,"IMBUSY!"))
{
// lock container
SetLocalInt(OBJECT_SELF,"IMBUSY!",TRUE);
// create inventory from DB
// "Reflex Safe" serves as ID_FLAG
// reflex = 0
// non unique container ID. it will just use the placeable tag as container index
// multiple containers can share the same space this way
// reflex = 1
// unique container ID. area-tag + location used as container index. each container gets
// his own space, tag is irrelevant.
// placeable must be stationary !!!!
// reflex = 2
// ID based on GetPCPlayerName() and GetName()
// container inventory depends on opener
// this is useful for player vaults
int nID = (GetReflexSavingThrow(OBJECT_SELF) == 2) ? PINV_GetID(oUser,2) : PINV_GetID(OBJECT_SELF,GetReflexSavingThrow(OBJECT_SELF));
if( PINV_RetrieveInventory(nID, OBJECT_SELF) == -1 )
SendMessageToPC(oUser, "You can't retrieve items from this container. Your name contains malicious characters...");
}
else
SendMessageToPC(oUser,"Container is busy, try again later...");
}