int GetNextShieldIndex( object oShield)
{
  int iIndex = GetItemAppearance( oShield, ITEM_APPR_TYPE_SIMPLE_MODEL, 0);
  iIndex--;
  int iItemtype = GetBaseItemType( oShield);

    //shields
  if( iItemtype == BASE_ITEM_SMALLSHIELD)
  {
    if( iIndex == 85)       //CEP2.2
      iIndex = 64;
    else if( iIndex == 60)
      iIndex = 57;
    else if( iIndex == 50)
      iIndex = 49;
    else if( iIndex == 40)
    iIndex = 39;
    else if( iIndex == 30)
    iIndex = 23;
    else if( iIndex == 20)
    iIndex = 13;
    else if( iIndex == 10)
    iIndex = 88;

  }
  else if( iItemtype == BASE_ITEM_LARGESHIELD)
  {
    if( iIndex == 219)   //CEP2.2
      iIndex = 213;
    else if( iIndex == 150)
      iIndex = 149;
    else if( iIndex == 140)
      iIndex = 139;
    else if( iIndex == 130)
    iIndex = 129;
    else if( iIndex == 120)
    iIndex = 119;
    else if( iIndex == 110)
    iIndex = 109;
    else if( iIndex == 99)
    iIndex = 96;
    else if( iIndex == 89)
    iIndex = 88;
    else if( iIndex == 50)
    iIndex = 49;
    else if( iIndex == 40)
    iIndex = 33;
    else if( iIndex == 30)
    iIndex = 23;
    else if( iIndex == 20)
    iIndex = 13;
    else if( iIndex == 11)
    iIndex = 255;

  }
  else if( iItemtype == BASE_ITEM_TOWERSHIELD)
  {
    if( iIndex == 231)   //CEP2.2
      iIndex = 230;
    else if( iIndex == 180)
      iIndex = 153;
    else if( iIndex == 150)
      iIndex = 149;
    else if( iIndex == 140)
    iIndex = 139;
    else if( iIndex == 130)
    iIndex = 129;
    else if( iIndex == 120)
    iIndex = 119;
    else if( iIndex == 50)
    iIndex = 43;
    else if( iIndex == 40)
    iIndex = 33;
    else if( iIndex == 30)
    iIndex = 23;
    else if( iIndex == 20)
    iIndex = 19;
    else if( iIndex == 10)
    iIndex = 237;    //Start Over at Tower Shield 237

  }

  return iIndex;
}

void main()
{
  object oPlayer = GetPCSpeaker();
  object oShield = GetItemInSlot( INVENTORY_SLOT_LEFTHAND, oPlayer);

  int iIndex = GetNextShieldIndex( oShield);

  if( GetIsDM( oPlayer))
    SendMessageToPC( oPlayer, "The index is: " + IntToString( iIndex));

  object oNewShield = CopyItemAndModify(oShield, ITEM_APPR_TYPE_SIMPLE_MODEL, 0, iIndex, TRUE);

  if( GetIsObjectValid( oNewShield))
  {
    AssignCommand( oPlayer, ActionEquipItem( oNewShield, INVENTORY_SLOT_LEFTHAND));
    DestroyObject( oShield);
  }
  else
    DestroyObject( oNewShield);
}