/**********************************
ItemLossUponDeath()
By: Panduh
Date: 6/29/2002
**********************************/
void ItemLossUponDeath(object oPlayer)
{
    // Find PC's current location
    location loc_Current    = GetLocation(oPlayer);
    // Create a loot bag to hold PC's stuff.
    object oBagLoot = CreateObject(OBJECT_TYPE_PLACEABLE, "pclootbag", loc_Current);
    //Pick off the equipped items(I would love a stack/array to work with)
    object oChest       = GetItemInSlot( INVENTORY_SLOT_CHEST, oPlayer);
    object oBelt        = GetItemInSlot( INVENTORY_SLOT_BELT, oPlayer);
    object oCloak       = GetItemInSlot( INVENTORY_SLOT_CLOAK, oPlayer);
    object oHead        = GetItemInSlot( INVENTORY_SLOT_HEAD, oPlayer);
    object oLeftRing    = GetItemInSlot( INVENTORY_SLOT_LEFTRING, oPlayer);
    object oRightRing   = GetItemInSlot( INVENTORY_SLOT_RIGHTRING, oPlayer);
    object oAmulet      = GetItemInSlot( INVENTORY_SLOT_NECK, oPlayer);
    object oBoots       = GetItemInSlot( INVENTORY_SLOT_BOOTS, oPlayer);
    object oGloves      = GetItemInSlot( INVENTORY_SLOT_ARMS, oPlayer);
    object oWeapon      = GetItemInSlot( INVENTORY_SLOT_RIGHTHAND, oPlayer);
    object oOffhand     = GetItemInSlot( INVENTORY_SLOT_LEFTHAND, oPlayer);
    // Pop all the valid equipment into the loot bag
    if (GetIsObjectValid(oChest))
    {
        AssignCommand(oBagLoot, ActionTakeItem(oChest, oPlayer));
    }
    if (GetIsObjectValid(oBelt))
    {
        AssignCommand(oBagLoot, ActionTakeItem(oBelt, oPlayer));
    }
    if (GetIsObjectValid(oCloak))
    {
        AssignCommand(oBagLoot, ActionTakeItem(oCloak, oPlayer));
    }
    if (GetIsObjectValid(oHead))
    {
        AssignCommand(oBagLoot, ActionTakeItem(oHead, oPlayer));
    }
    if (GetIsObjectValid(oLeftRing))
    {
        AssignCommand(oBagLoot, ActionTakeItem(oLeftRing, oPlayer));
    }
    if (GetIsObjectValid(oRightRing))
    {
        AssignCommand(oBagLoot, ActionTakeItem(oRightRing, oPlayer));
    }
    if (GetIsObjectValid(oAmulet))
    {
        AssignCommand(oBagLoot, ActionTakeItem(oAmulet, oPlayer));
    }
    if (GetIsObjectValid(oBoots))
    {
        AssignCommand(oBagLoot, ActionTakeItem(oBoots, oPlayer));
    }
    if (GetIsObjectValid(oGloves))
    {
        AssignCommand(oBagLoot, ActionTakeItem(oGloves, oPlayer));
    }
    if (GetIsObjectValid(oWeapon))
    {
        AssignCommand(oBagLoot, ActionTakeItem(oWeapon, oPlayer));
    }
    if (GetIsObjectValid(oOffhand))
    {
        AssignCommand(oBagLoot, ActionTakeItem(oOffhand, oPlayer));
    }
    // Loop thru the backpack and have loot bag "take" all the items
    object oItem = GetFirstItemInInventory(oPlayer);
    while ( GetIsObjectValid(oItem) == TRUE )
    {
        AssignCommand(oBagLoot, ActionTakeItem(oItem, oPlayer));
        oItem = GetNextItemInInventory(oPlayer);
    }
}
