82 lines
2.2 KiB
Plaintext
82 lines
2.2 KiB
Plaintext
////////////////////////////////////////////////////////////////////////////////
|
|
//
|
|
// Olander's Pack Animals
|
|
// opa_open_packbox
|
|
// By Don Anderson
|
|
// dandersonru@msn.com
|
|
//
|
|
// Restores Pack Animal Box Inventory
|
|
//
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
#include "opa_inc"
|
|
#include "opw_inc_weapons"
|
|
|
|
void RecursiveChestRestore(object oStore, int iFirst=TRUE)
|
|
{
|
|
object oBox = OBJECT_SELF;
|
|
int nTotal;
|
|
|
|
//Pack Box Maximum Amount
|
|
int nPBMAX = GetLocalInt(oBox,"PBMAX");
|
|
|
|
object oItem = GetFirstItemInInventory(oStore);
|
|
while(oItem!=OBJECT_INVALID)
|
|
{
|
|
if(!iFirst || GetHasInventory(oItem))
|
|
{
|
|
ActionTakeItem(oItem, oStore);
|
|
|
|
//Armor Count 2
|
|
if(GetBaseItemType(oItem) == BASE_ITEM_ARMOR || IsMeleeWeapon(oItem))
|
|
{
|
|
SetLocalInt(oItem,"BOX_REC",1);
|
|
|
|
nTotal = nTotal + 2;
|
|
SetLocalInt(oBox,"OPA_TOTAL",nTotal);
|
|
}
|
|
|
|
//All Else Count 1
|
|
else
|
|
{
|
|
SetLocalInt(oItem,"BOX_REC",1);
|
|
|
|
nTotal = nTotal + 1;
|
|
SetLocalInt(oBox,"OPA_TOTAL",nTotal);
|
|
}
|
|
}
|
|
oItem = GetNextItemInInventory(oStore);
|
|
}
|
|
if(iFirst)
|
|
{
|
|
AssignCommand(oBox, ActionDoCommand(RecursiveChestRestore(oStore, FALSE)));
|
|
return;
|
|
}
|
|
AssignCommand(oBox,ActionDoCommand(DestroyObject(oStore)));
|
|
|
|
//Give Player the Info
|
|
nTotal = GetLocalInt(oBox,"OPA_TOTAL");
|
|
SpeakString("My Inventory Value Is : "+IntToString(nTotal)+" of "+IntToString(nPBMAX)+" Max." );
|
|
}
|
|
|
|
void main()
|
|
{
|
|
object oBox = OBJECT_SELF;
|
|
object oPC = GetLastOpenedBy();
|
|
SendMessageToPC(oPC, "The Pack Box will be locked for 10secs after you close.");
|
|
|
|
string sName = GetName(oPC);
|
|
string sLeft = GetStringLeft(sName,4);
|
|
string sDB = "PACKBOX_" + sLeft;
|
|
|
|
object oStore = RetrieveCampaignObject(sDB, "PackBox", GetLocation(oBox), OBJECT_INVALID, oPC);
|
|
effect eVis = EffectInvisibility(INVISIBILITY_TYPE_IMPROVED);
|
|
effect eImm = EffectCutsceneImmobilize();
|
|
ApplyEffectToObject(DURATION_TYPE_INSTANT,eVis,oStore);
|
|
ApplyEffectToObject(DURATION_TYPE_INSTANT,eImm,oStore);
|
|
|
|
//Override the existing campaign object for this player
|
|
StoreCampaignObject(sDB, "PackBox", OBJECT_INVALID, oPC);
|
|
AssignCommand(oBox, ActionDoCommand(RecursiveChestRestore(oStore)));
|
|
}
|