Jaysyn904 04165202c0 Initial upload
Initial upload
2024-11-25 19:36:07 -05:00

62 lines
2.5 KiB
Plaintext

////////////////////////////////////////////////////////////////////////////////
// it_rh_bag - Random House Bag
// By Deva B. Winblood. November 12th, 2008
////////////////////////////////////////////////////////////////////////////////
#include "x3_inc_string"
////////////////////////////////////
// FUNCTIONS
////////////////////////////////////
void fnTransferGoods(object oSource,object oDestination,int bDestroy=FALSE)
{ // PURPOSE: Transfer goods
object oItem;
object oCopy;
oItem=GetFirstItemInInventory(oSource);
while(GetIsObjectValid(oItem))
{ // transfer
oCopy=CopyItem(oItem,oDestination,TRUE);
DelayCommand(0.5,DestroyObject(oItem));
oItem=GetNextItemInInventory(oSource);
} // transfer
if (bDestroy) DelayCommand(1.0,DestroyObject(oSource));
} // fnTransferGoods()
//////////////////////////////////////////////////////////////////////[ MAIN ]//
void main()
{
object oPC=GetItemActivator();
string sName=GetName(oPC);
string sKey=StringReplace(sName," ","_");
string sPlayer=GetPCPlayerName(oPC);
string sTag="RH_"+GetStringLeft(sPlayer,2)+sKey+GetStringRight(sPlayer,2);
object oTemp;
object oWP=GetWaypointByTag("PC_CUSTOMIZATION");
sTag=StringReplace(sTag," ","");
object oStore=GetObjectByTag(sTag);
if (GetLocalInt(oPC,"bBagOpening"))
{ // already opened
SendMessageToPC(oPC,"Already opening that... please wait.");
} // already opened
if (!GetIsObjectValid(oStore))
{ // create
SendMessageToPC(oPC,"Create storage '"+sTag+"'");
oStore=CreateObject(OBJECT_TYPE_PLACEABLE,"rh_pl_bagstore",GetLocation(oWP),FALSE,sTag);
SetLocalObject(oStore,"oOwner",oPC);
if (GetTag(oStore)!=sTag) SendMessageToPC(oPC,"ERROR it_rh_bag: Could not give placeable the tag '"+sTag+"' Strlen:"+IntToString(GetStringLength(sTag))+" Actual Tag '"+GetTag(oStore)+"'");
} // create
oTemp=CreateObject(OBJECT_TYPE_PLACEABLE,"rh_pl_bag",GetLocation(oPC));
SetLocalObject(oTemp,"oOwner",oPC);
SetLocalObject(oTemp,"oStorage",oStore);
fnTransferGoods(oStore,oTemp);
FloatingTextStringOnCreature("** Please wait while opening bag. **",oPC,FALSE);
AssignCommand(oPC,ClearAllActions(TRUE));
//AssignCommand(oPC,ActionOpenDoor(oTemp));
//AssignCommand(oPC,ActionMoveAwayFromObject(oTemp,TRUE,2.0));
AssignCommand(oPC,ActionInteractObject(oTemp));
}
//////////////////////////////////////////////////////////////////////[ MAIN ]//