#include "x0_i0_corpses"
#include "inc_misc_tools"

void main()
    {
    object oPC;

    int iAC,iTemp,iTouchAC,iBonus;
    int iUDE = GetUserDefinedEventNumber();
    if (iUDE == 1003)
        {
        SetIsDestroyable(FALSE);
        if (GetLocalInt(OBJECT_SELF,"X2_L_IS_INCORPOREAL"))
            {
            oPC = GetAttemptedAttackTarget();
            if (GetIsObjectValid(oPC))
                {
                iAC = GetAC(oPC);
                iTouchAC = 10 + GetAbilityModifier(ABILITY_DEXTERITY,oPC);
                if (GetHasSpellEffect(SPELL_SHIELD))
                    iTouchAC += 7;
                else if (GetHasSpellEffect(SPELL_MAGE_ARMOR))
                    iTouchAC += 4;
                if (GetHasFeat(FEAT_DODGE))
                    iTouchAC += 1;
                iBonus = iAC - iTouchAC;
                if (iBonus > 0)
                    ApplyEffectToObject(DURATION_TYPE_TEMPORARY,EffectAttackIncrease(iBonus),OBJECT_SELF,7.0);
                }
            }
        }
    }
