HoS_PRC8/_mod/_module/nss/unit_inv.nss
Jaysyn904 04165202c0 Initial upload
Initial upload
2024-11-25 19:36:07 -05:00

137 lines
5.3 KiB
Plaintext

//unit_inv - Manage Unit inventory
// 1 = non-equipped, 2 = equipped
void main()
{
object oPC=GetPCSpeaker();
object oUnit=OBJECT_SELF;
object oChest=CreateObject(OBJECT_TYPE_PLACEABLE,"unit_inv",GetLocation(oUnit));
int nParm=GetLocalInt(oPC,"nParm");
object oItem;
object oCopy;
int nSS;
SetLocalObject(oChest,"oPC",oPC);
SetLocalObject(oChest,"oUnit",oUnit);
SetLocalInt(oChest,"nParm",nParm);
if (nParm==1)
{ // non-equipped
oItem=GetFirstItemInInventory(oUnit);
while(oItem!=OBJECT_INVALID)
{ // traverse inventory
nSS=GetItemStackSize(oItem);
CreateItemOnObject(GetResRef(oItem),oChest,nSS);
DelayCommand(0.5,DestroyObject(oItem));
oItem=GetNextItemInInventory(oUnit);
} // traverse inventory
} // non-equipped
else
{ // equipped
oItem=GetItemInSlot(INVENTORY_SLOT_ARROWS,oUnit);
if (oItem!=OBJECT_INVALID)
{ // slot has item
nSS=GetItemStackSize(oItem);
oCopy=CreateItemOnObject(GetResRef(oItem),oChest,nSS);
SetLocalInt(oCopy,"nSlot",INVENTORY_SLOT_ARROWS);
DelayCommand(0.1,DestroyObject(oItem));
} // slot has item
oItem=GetItemInSlot(INVENTORY_SLOT_BELT,oUnit);
if (oItem!=OBJECT_INVALID)
{ // slot has item
nSS=GetItemStackSize(oItem);
oCopy=CreateItemOnObject(GetResRef(oItem),oChest,nSS);
SetLocalInt(oCopy,"nSlot",INVENTORY_SLOT_BELT);
DelayCommand(0.1,DestroyObject(oItem));
} // slot has item
oItem=GetItemInSlot(INVENTORY_SLOT_BOLTS,oUnit);
if (oItem!=OBJECT_INVALID)
{ // slot has item
nSS=GetItemStackSize(oItem);
oCopy=CreateItemOnObject(GetResRef(oItem),oChest,nSS);
SetLocalInt(oCopy,"nSlot",INVENTORY_SLOT_BOLTS);
DelayCommand(0.1,DestroyObject(oItem));
} // slot has item
oItem=GetItemInSlot(INVENTORY_SLOT_BOOTS,oUnit);
if (oItem!=OBJECT_INVALID)
{ // slot has item
nSS=GetItemStackSize(oItem);
oCopy=CreateItemOnObject(GetResRef(oItem),oChest,nSS);
SetLocalInt(oCopy,"nSlot",INVENTORY_SLOT_BOOTS);
DelayCommand(0.1,DestroyObject(oItem));
} // slot has item
oItem=GetItemInSlot(INVENTORY_SLOT_BULLETS,oUnit);
if (oItem!=OBJECT_INVALID)
{ // slot has item
nSS=GetItemStackSize(oItem);
oCopy=CreateItemOnObject(GetResRef(oItem),oChest,nSS);
SetLocalInt(oCopy,"nSlot",INVENTORY_SLOT_BULLETS);
DelayCommand(0.1,DestroyObject(oItem));
} // slot has item
oItem=GetItemInSlot(INVENTORY_SLOT_CHEST,oUnit);
if (oItem!=OBJECT_INVALID)
{ // slot has item
nSS=GetItemStackSize(oItem);
oCopy=CreateItemOnObject(GetResRef(oItem),oChest,nSS);
SetLocalInt(oCopy,"nSlot",INVENTORY_SLOT_CHEST);
DelayCommand(0.1,DestroyObject(oItem));
} // slot has item
oItem=GetItemInSlot(INVENTORY_SLOT_CLOAK,oUnit);
if (oItem!=OBJECT_INVALID)
{ // slot has item
nSS=GetItemStackSize(oItem);
oCopy=CreateItemOnObject(GetResRef(oItem),oChest,nSS);
SetLocalInt(oCopy,"nSlot",INVENTORY_SLOT_CLOAK);
DelayCommand(0.1,DestroyObject(oItem));
} // slot has item
oItem=GetItemInSlot(INVENTORY_SLOT_HEAD,oUnit);
if (oItem!=OBJECT_INVALID)
{ // slot has item
nSS=GetItemStackSize(oItem);
oCopy=CreateItemOnObject(GetResRef(oItem),oChest,nSS);
SetLocalInt(oCopy,"nSlot",INVENTORY_SLOT_HEAD);
DelayCommand(0.1,DestroyObject(oItem));
} // slot has item
oItem=GetItemInSlot(INVENTORY_SLOT_LEFTHAND,oUnit);
if (oItem!=OBJECT_INVALID)
{ // slot has item
nSS=GetItemStackSize(oItem);
oCopy=CreateItemOnObject(GetResRef(oItem),oChest,nSS);
SetLocalInt(oCopy,"nSlot",INVENTORY_SLOT_LEFTHAND);
DelayCommand(0.1,DestroyObject(oItem));
} // slot has item
oItem=GetItemInSlot(INVENTORY_SLOT_LEFTRING,oUnit);
if (oItem!=OBJECT_INVALID)
{ // slot has item
nSS=GetItemStackSize(oItem);
oCopy=CreateItemOnObject(GetResRef(oItem),oChest,nSS);
SetLocalInt(oCopy,"nSlot",INVENTORY_SLOT_LEFTRING);
DelayCommand(0.1,DestroyObject(oItem));
} // slot has item
oItem=GetItemInSlot(INVENTORY_SLOT_NECK,oUnit);
if (oItem!=OBJECT_INVALID)
{ // slot has item
nSS=GetItemStackSize(oItem);
oCopy=CreateItemOnObject(GetResRef(oItem),oChest,nSS);
SetLocalInt(oCopy,"nSlot",INVENTORY_SLOT_NECK);
DelayCommand(0.1,DestroyObject(oItem));
} // slot has item
oItem=GetItemInSlot(INVENTORY_SLOT_RIGHTHAND,oUnit);
if (oItem!=OBJECT_INVALID)
{ // slot has item
nSS=GetItemStackSize(oItem);
oCopy=CreateItemOnObject(GetResRef(oItem),oChest,nSS);
SetLocalInt(oCopy,"nSlot",INVENTORY_SLOT_RIGHTHAND);
DelayCommand(0.1,DestroyObject(oItem));
} // slot has item
oItem=GetItemInSlot(INVENTORY_SLOT_RIGHTRING,oUnit);
if (oItem!=OBJECT_INVALID)
{ // slot has item
nSS=GetItemStackSize(oItem);
oCopy=CreateItemOnObject(GetResRef(oItem),oChest,nSS);
SetLocalInt(oCopy,"nSlot",INVENTORY_SLOT_RIGHTRING);
DelayCommand(0.1,DestroyObject(oItem));
} // slot has item
} // equipped
AssignCommand(oPC,ClearAllActions(TRUE));
AssignCommand(oPC,ActionInteractObject(oChest));
}