#include "inc_levelset"

void main()
{
    object oTarget = GetPCSpeaker();
    int iFoundItemFlag = 0;
    int i = 0;
    //for testing
    //AssignCommand(oTarget, SpeakString("stripInventory fired"));

    //valid only for creatures
    //if ( GetObjectType(oTarget) != OBJECT_TYPE_CREATURE) return;

    // set the variables
    object oItem = GetFirstItemInInventory(oTarget);

    // unflag unequipped items in inventory
    while ( GetIsObjectValid(oItem) )
        {
        //SendMessageToPC(oTarget, "Evaluating " + GetName(oItem));

        if (GetPlotFlag(oItem) == TRUE)
            {
            SetPlotFlag(oItem, FALSE);
            SendMessageToPC(oTarget, "Plot flag removed from " + GetName(oItem));
            iFoundItemFlag = 1;
            }

        if (GetStolenFlag(oItem) == TRUE)
            {
            SetStolenFlag(oItem, FALSE);
            SendMessageToPC(oTarget, "Stolen flag removed from " + GetName(oItem));
            iFoundItemFlag = 1;
            }
            //else SendMessageToPC(oTarget, GetName(oItem) + " was not changed.");

        oItem = GetNextItemInInventory(oTarget);
        }

    //unflag equipped items in slots
        for ( i = 0; i < NUM_INVENTORY_SLOTS; i++ )
        {
        oItem = GetItemInSlot(i, oTarget);
        if (GetPlotFlag(oItem) == TRUE)
            {
            SetPlotFlag(oItem, FALSE);
            SendMessageToPC(oTarget, "Plot flag removed from " + GetName(oItem));
            iFoundItemFlag = 1;
            }

        if (GetStolenFlag(oItem) == TRUE)
            {
            SetStolenFlag(oItem, FALSE);
            SendMessageToPC(oTarget, "Stolen flag removed from " + GetName(oItem));
            iFoundItemFlag = 1;
            }
        }

    if (iFoundItemFlag == 0) SendMessageToPC(oTarget, "No Plot or Stolen items found.");
}
