//:: Script Name: everpcunequip
//::///////////////////////////////////////////////
//:: Example XP2 OnItemEquipped
//:: x2_mod_def_unequ
//:: (c) 2003 Bioware Corp.
//:://////////////////////////////////////////////
//   Put into the: OnUnEquip Module Event
//:://////////////////////////////////////////////
//:: Created By: Georg Zoeller
//:: Created On: 2003-07-16
//:://////////////////////////////////////////////
//Modified By Guile 3/24/08 (Updated 8/10/08)
//This modifcation stops a weapon switching exploit
//Which gives the makes the PC never miss!!!
///////////////////////////////////////////////////

//Required Includes
#include "x2_inc_switches"
#include "x2_inc_intweapon"

//Main Script
void main()
{

     object oItem = GetPCItemLastUnequipped();
     object oPC   = GetPCItemLastUnequippedBy();

     if (!GetIsPC(oPC)) return;


//This is my weapon swap pvp exploit fix
//Lets make sure they are actually fighting someone
if(GetIsInCombat(oPC))
{
//Lets make sure it's a weapon or shield they are unequipping
if(GetBaseItemType(oItem) != BASE_ITEM_AMULET)
{if(GetBaseItemType(oItem) != BASE_ITEM_ARROW)
{if(GetBaseItemType(oItem) != BASE_ITEM_BELT)
{if(GetBaseItemType(oItem) != BASE_ITEM_BOLT)
{if(GetBaseItemType(oItem) != BASE_ITEM_BOOTS)
{if(GetBaseItemType(oItem) != BASE_ITEM_BRACER)
{if(GetBaseItemType(oItem) != BASE_ITEM_CLOAK)
{if(GetBaseItemType(oItem) != BASE_ITEM_HELMET)
{if(GetBaseItemType(oItem) != BASE_ITEM_BULLET)
{if(GetBaseItemType(oItem) != BASE_ITEM_RING)
{
DelayCommand(0.5, AssignCommand(oPC, ClearAllActions()));
}}}}}}}}}}
//Exploit Fix END
}

///////////////////////////////////////////////////////////////////////////


//Your Code Goes here..


///////////////////////////////////////////////////////////////////////////

///////////////////BIOWARE XP2 FUNCTIONS///////////////////////////////////
    //Commented out because I am not using it...
    /* Delete this line to activate
    // -------------------------------------------------------------------------
    //  Intelligent Weapon System
    // -------------------------------------------------------------------------
    if (IPGetIsIntelligentWeapon(oItem))
    {
            IWSetIntelligentWeaponEquipped(oPC,OBJECT_INVALID);
            IWPlayRandomUnequipComment(oPC,oItem);
    }

    // DO NOT TOUCH THIS LINE! */


///////////////////////XP2 TAGBASED SCRIPTING CODE///////////////////////////

     // -------------------------------------------------------------------------
     // Generic Item Script Execution Code
     // If MODULE_SWITCH_EXECUTE_TAGBASED_SCRIPTS is set to TRUE on the module,
     // it will execute a script that has the same name as the item's tag
     // inside this script you can manage scripts for all events by checking against
     // GetUserDefinedItemEventNumber(). See x2_it_example.nss
     // -------------------------------------------------------------------------
     if (GetModuleSwitchValue(MODULE_SWITCH_ENABLE_TAGBASED_SCRIPTS) == TRUE)
     {
        SetUserDefinedItemEventNumber(X2_ITEM_EVENT_UNEQUIP);
        int nRet =   ExecuteScriptAndReturnInt(GetUserDefinedItemEventScriptName(oItem),OBJECT_SELF);
        if (nRet == X2_EXECUTE_SCRIPT_END)
        {
           return;
        }

     }

//Main Script End
}