54 lines
1.6 KiB
Plaintext
54 lines
1.6 KiB
Plaintext
////////////////////////////////////////////////////////////////////////////////
|
|
// rh_pl_baghb - Bag Heartbeat
|
|
// By Deva B. Winblood. November 12th, 2008
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
////////////////////////////////////
|
|
// 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 oMe=OBJECT_SELF;
|
|
object oOwner=GetLocalObject(oMe,"oOwner");
|
|
object oStorage=GetLocalObject(oMe,"oStorage");
|
|
object oPC=GetLastOpenedBy();
|
|
if (oPC!=oOwner)
|
|
{ // not owner
|
|
int nCount=GetLocalInt(oMe,"nCount");
|
|
nCount++;
|
|
SetLocalInt(oMe,"nCount",nCount);
|
|
if (nCount>1)
|
|
{ // too long - destroy
|
|
DeleteLocalInt(oOwner,"bBagOpening");
|
|
fnTransferGoods(oMe,oStorage,TRUE);
|
|
} // too long - destroy
|
|
} // not owner
|
|
else
|
|
{ // distant
|
|
if (GetDistanceBetween(oMe,oOwner)>5.0||GetArea(oMe)!=GetArea(oOwner))
|
|
{ // destroy
|
|
DeleteLocalInt(oOwner,"bBagOpening");
|
|
fnTransferGoods(oMe,oStorage,TRUE);
|
|
} // destroy
|
|
} // distant
|
|
}
|