//////////////////////////////////////////////////////////////////////////////// // // Olander's Pack Animals // opa_dist_packbox // By Don Anderson // dandersonru@msn.com // // place this in the OnDisturbed Event of the Pack Box // //////////////////////////////////////////////////////////////////////////////// #include "opw_inc_weapons" void main() { object oPC = GetLastOpenedBy(); object oBox = OBJECT_SELF; object oItem = GetInventoryDisturbItem(); int nType = GetBaseItemType(oItem); //Pack Box Maximum Amount int nPBMAX = GetLocalInt(oBox,"PBMAX"); //Current Total of Items int nTotal = GetLocalInt(oBox,"OPA_TOTAL"); int nDType = GetInventoryDisturbType(); //Added an Item if(nDType == INVENTORY_DISTURB_TYPE_ADDED) { if(nTotal > nPBMAX) { DestroyObject(oItem); //Clear the Player Actions AssignCommand(oPC,ClearAllActions()); AssignCommand(oPC,ActionMoveAwayFromObject(oBox,TRUE,3.0)); SpeakString("I AM FULL!!"); return; } if(nTotal >= (nPBMAX - 2)) { //Clear the Player Actions AssignCommand(oPC,ClearAllActions()); AssignCommand(oPC,ActionMoveAwayFromObject(oBox,TRUE,3.0)); SpeakString("I AM FULL!!"); return; } //Reset Item int nBoxRec = GetLocalInt(oItem,"BOX_REC"); if(nBoxRec == 1) { DeleteLocalInt(oItem,"BOX_REC"); return; } //Armor Count 2 if(nType == BASE_ITEM_ARMOR || IsMeleeWeapon(oItem)) { SetLocalInt(oItem,"BOX_REC",1); nTotal = nTotal + 2; SetLocalInt(OBJECT_SELF,"OPA_TOTAL",nTotal); } //All Else Count 1 else { SetLocalInt(oItem,"BOX_REC",1); nTotal = nTotal + 1; SetLocalInt(OBJECT_SELF,"OPA_TOTAL",nTotal); } //Give Player the Info nTotal = GetLocalInt(oBox,"OPA_TOTAL"); SpeakString("My Inventory Value Is : "+IntToString(nTotal)+" of "+IntToString(nPBMAX)+" Max." ); } //Removed an Item if(nDType == INVENTORY_DISTURB_TYPE_REMOVED) { //Armor Count 2 if(nType == BASE_ITEM_ARMOR || IsMeleeWeapon(oItem)) { SetLocalInt(oItem,"BOX_REC",1); nTotal = nTotal - 2; SetLocalInt(OBJECT_SELF,"OPA_TOTAL",nTotal); } //All Else Count 2 else { SetLocalInt(oItem,"BOX_REC",1); nTotal = nTotal - 1; SetLocalInt(OBJECT_SELF,"OPA_TOTAL",nTotal); } object oPC = GetLastDisturbed(); if(GetIsPC(oPC)) { //Give Player the Info nTotal = GetLocalInt(oBox,"OPA_TOTAL"); SpeakString("My Inventory Value Is : "+IntToString(nTotal)+" of "+IntToString(nPBMAX)+" Max." ); } } }