// unit_inv_close #include "unit_inv_h" void main() { object oMe=OBJECT_SELF; object oUnit=GetLocalObject(oMe,"oUnit"); int nParm=GetLocalInt(oMe,"nParm"); object oItem; object oCopy; int nSS; if (nParm==1) { // return belongings ReturnBelongings(oUnit,oMe); AssignCommand(oUnit,ActionEquipMostEffectiveArmor()); if (GetLocalString(oUnit,"sCOMBAT_AI_TYPE")=="ranged") { // equip ranged weapon AssignCommand(oUnit,ActionEquipMostDamagingRanged()); } // equip ranged weapon else if (GetLocalString(oUnit,"sCOMBAT_AI_TYPE")=="melee") { // equip melee AssignCommand(oUnit,ActionEquipMostDamagingMelee()); } // equip melee } // return belongings else if (nParm==2) { // return and equip belongings oItem=GetFirstItemInInventory(oMe); while(oItem!=OBJECT_INVALID) { // transfer and equip nSS=GetItemStackSize(oItem); oCopy=CreateItemOnObject(GetResRef(oItem),oUnit,nSS); DelayCommand(0.5,DestroyObject(oItem)); EquipItem(oUnit,oCopy); oItem=GetNextItemInInventory(oMe); } // transfer and equip AssignCommand(oUnit,ActionEquipMostEffectiveArmor()); if (GetLocalString(oUnit,"sCOMBAT_AI_TYPE")=="ranged") { // equip ranged weapon AssignCommand(oUnit,ActionEquipMostDamagingRanged()); } // equip ranged weapon else if (GetLocalString(oUnit,"sCOMBAT_AI_TYPE")=="melee") { // equip melee AssignCommand(oUnit,ActionEquipMostDamagingMelee()); } // equip melee } // return and equip belongings DelayCommand(2.0,DestroyObject(oMe)); }