// v2.0.0 -
//::////////////////////////////////////////////////////////////////////////////
//:: FileName:  hark_ac5_attack
//::////////////////////////////////////////////////////////////////////////////
/*
   If already fighting then ignore, else determine combat round.
*/
//::////////////////////////////////////////////////////////////////////////////
#include "hark_i0_hench_ai"
#include "hark_i0_ac5"
//::////////////////////////////////////////////////////////////////////////////
void main()
{
  if (!preEvent()) { return; }

  if (!GetAssociateState(NW_ASC_IS_BUSY) &&
      !GetAssociateState(NW_ASC_MODE_DYING) && !GetIsDead(OBJECT_SELF))
    {
     WrapCommandable(TRUE);

     if (!GetAssociateState(NW_ASC_MODE_STAND_GROUND) && GetCurrentAction() != ACTION_TAUNT)
       {
        if (GetStealthMode(OBJECT_SELF) == STEALTH_MODE_ACTIVATED)
          { ActionUseSkill(SKILL_HIDE, OBJECT_SELF); }

        if (!GetIsObjectValid(GetAttemptedAttackTarget()) &&
            !GetIsObjectValid(GetAttackTarget()) &&
            !GetIsObjectValid(GetAttemptedSpellTarget()))
          {
           if (GetIsObjectValid(GetLastAttacker()))
             {
              if (GetAssociateState(NW_ASC_MODE_DEFEND_MASTER))
                {
                 if (!GetIsObjectValid(GetLastAttacker(GetRealMaster())))
                   { HenchDetermineCombatRound(); }
                }
              else
                { HenchDetermineCombatRound(GetLastAttacker()); }
             }
          }
        if (GetSpawnInCondition(NW_FLAG_EVENT_ATTACK))
          { SignalEvent(OBJECT_SELF, EventUserDefined(1005)); }
       }
    }
  postEvent();
}
//::////////////////////////////////////////////////////////////////////////////
