#include "inc_mod_constant"
//#include "inc_misc_tools"


void main()
    {
    object oItem = GetItemActivated();
    string sTag = GetTag (oItem);
    object oPC = GetItemActivator();
    object oTarget = GetItemActivatedTarget();
    location lLoc = GetItemActivatedTargetLocation();
    int iAttack,iAC,iAbility,iRace;
    if (sTag == "rodw111")
        {
        SetPlotFlag(oItem,FALSE);
        DestroyObject(oItem);
        }
    else if (sTag == "spear601")
        {
        AssignCommand(oPC,ApplyEffectToObject(DURATION_TYPE_INSTANT,EffectLinkEffects(EffectDamage(GetReflexAdjustedDamage(d6(5),oTarget,14,SAVING_THROW_TYPE_ELECTRICITY,oPC),DAMAGE_TYPE_ELECTRICAL),EffectBeam(VFX_BEAM_LIGHTNING,oPC,BODY_NODE_HAND)),oTarget,3.0));
        DestroyObject(oItem);
        }
    else if (sTag == "dagger602")
        {
        AddItemProperty(DURATION_TYPE_TEMPORARY,ItemPropertyOnHitCastSpell(SPELL_POISON,4),oItem,12.0);
        }
    else if (sTag == "rapier601")
        {
        if (GetRacialType(oTarget) != RACIAL_TYPE_CONSTRUCT
         && GetRacialType(oTarget) != RACIAL_TYPE_ELEMENTAL
         && GetRacialType(oTarget) != RACIAL_TYPE_OOZE
         && GetRacialType(oTarget) != RACIAL_TYPE_UNDEAD)
            AssignCommand(oPC,ApplyEffectToObject(DURATION_TYPE_TEMPORARY,EffectAbilityDecrease(ABILITY_CONSTITUTION,d6()),oTarget,HoursToSeconds(1)));
        }
    else if (sTag == "whammer602")
        {
        iAC = GetAC(oTarget);
        iAbility = GetAbilityModifier(ABILITY_DEXTERITY,oPC);
        iAttack = GetBaseAttackBonus(oPC);
        if (d20() + iAttack + iAbility >= iAC)
            {
            if (GetRacialType(oTarget) == RACIAL_TYPE_GIANT)
                AssignCommand(oPC,ApplyEffectToObject(DURATION_TYPE_INSTANT,EffectDamage(d8(3),DAMAGE_TYPE_BLUDGEONING,DAMAGE_POWER_PLUS_THREE),oTarget));
            else
                AssignCommand(oPC,ApplyEffectToObject(DURATION_TYPE_INSTANT,EffectDamage(d8(2),DAMAGE_TYPE_BLUDGEONING,DAMAGE_POWER_PLUS_THREE),oTarget));
            AssignCommand(oPC,ApplyEffectToObject(DURATION_TYPE_TEMPORARY,EffectVisualEffect(VFX_FNF_PWKILL),oTarget));
            }
        else
            FloatingTextStringOnCreature("Hammer Missed",oPC,FALSE);
        }
    else if (GetLocalInt(oItem,"SpecialAmmo"))
        {
        FloatingTextStringOnCreature("This weapon automatically improves the ammunition fired from it.",oPC,FALSE);
        DelayCommand(1.0,FloatingTextStringOnCreature("Ownership Set and Weapon Stats Stored.",oPC,FALSE));
        StoreCampaignObject(CAMPAIGN,GetName(oPC),oItem,oPC);
        }
    else if (GetWeaponRanged(oItem))
        {
        FloatingTextStringOnCreature("Retrieving stored missile weapon from DB.",oPC,FALSE);
        RetrieveCampaignObject(CAMPAIGN,GetName(oPC),GetLocation(oPC),oPC,oPC);
        DestroyObject(oItem);
        }
    }
