//::///////////////////////////////////////////////
//:: Name x2_def_attacked
//:: Copyright (c) 2001 Bioware Corp.
//:://////////////////////////////////////////////
/*
    Default On Physically attacked script
*/
//:://////////////////////////////////////////////
//:: Created By: Keith Warner
//:: Created On: June 11/03
//:://////////////////////////////////////////////

void main()
{
    object oMod = GetModule();
    object oPC = GetLastAttacker();
    string oAtt;
    object oDest;
    int oHit;
    int oPCdam;
    int oDam = GetTotalDamageDealt();
    if (GetIsPC(oPC))
       {
        oHit = GetLocalInt(oPC, "pc_hit");
        oPCdam= GetLocalInt(oPC, "player_dd");
        ++oHit;
        oPCdam+=oDam;
        SetLocalInt(oPC, "pc_hit", oHit);
        SetLocalInt(oPC, "player_dd", oPCdam);

       }
    else
       {
       oAtt = GetResRef(GetLastAttacker());
       string oSelf = GetResRef(OBJECT_SELF);
       oAtt+="_dd";
       oSelf+="_dt";
       int oSDTaken = GetLocalInt(oMod, oSelf);
       int oUDTaken = oSDTaken+oDam;
       int oSDDealt = GetLocalInt(oMod, oAtt);
       int oUDDealt = oSDDealt+oDam;
       SetLocalInt(oMod, oSelf, oUDTaken);
       SetLocalInt(oMod, oAtt, oUDDealt);
      }



    //--------------------------------------------------------------------------
    // GZ: 2003-10-16
    // Make Plot Creatures Ignore Attacks
    //--------------------------------------------------------------------------
    if (GetPlotFlag(OBJECT_SELF))
    {
        return;
    }

    //--------------------------------------------------------------------------
    // Execute old NWN default AI code
    //--------------------------------------------------------------------------

    ExecuteScript("nw_c2_default5", OBJECT_SELF);
}