//::///////////////////////////////////////////////
//:: Associate: On Percieve
//:: 69_hen_perceived
//:: Copyright (c) 2001 Bioware Corp.
//:://////////////////////////////////////////////
//:://////////////////////////////////////////////
//:: Created By: Preston Watamaniuk
//:: Created On: Nov 19, 2001
//:://////////////////////////////////////////////

#include "69_inc_henai"

void main()
{
    //This is the equivalent of a force conversation bubble, should only be used if you want an NPC
    //to say something while he is already engaged in combat.
    if(GetSpawnInCondition(NW_FLAG_SPECIAL_COMBAT_CONVERSATION))
    {
        ActionStartConversation(OBJECT_SELF);
    }
    if(!GetAssociateState(NW_ASC_MODE_STAND_GROUND))
    {
        //Do not bother checking the last target seen if already fighting
            // PAUS: No, actually please do check
        if(!GetIsObjectValid(GetAttemptedAttackTarget()) &&
           !GetIsObjectValid(GetAttackTarget()) &&
           !GetIsObjectValid(GetAttemptedSpellTarget()))
        {
            //Check if the last percieved creature was actually seen
            if(GetLastPerceptionSeen())
            {
                //69MEH69 Fixed so that the henchman does not shout at dead bodies
                if(GetIsEnemy(GetLastPerceived()) && !GetIsDead(GetLastPerceived()))
                {
                    if(GetDetectMode(OBJECT_SELF) == 1)
                    {
                     SetAssociateState(NW_ASC_AGGRESSIVE_STEALTH, FALSE);
                     ActionUseSkill(SKILL_SEARCH, OBJECT_SELF);
                    }
                    //SetFacingPoint(GetPosition(GetLastPerceived()));
                    BattleCry();
                    HenchmenCombatRound(GetLastPerceived());
                }
                //Linked up to the special conversation check to initiate a special one-off conversation
                //to get the PCs attention
                else if(GetSpawnInCondition(NW_FLAG_SPECIAL_CONVERSATION) && GetIsPC(GetLastPerceived()))
                {
                    ActionStartConversation(OBJECT_SELF);
                }
            }
        }
    }
    if(GetSpawnInCondition(NW_FLAG_PERCIEVE_EVENT))
    {
        SignalEvent(OBJECT_SELF, EventUserDefined(1002));
    }
}

/*
#include "NW_I0_GENERIC"

void main()
{
    // * If have no master then run default scripts
    if (GetIsObjectValid(GetMaster()) == FALSE)
    {
        ExecuteScript("nw_c2_default2",OBJECT_SELF);
    }
    else
    {
        object oNoticed = GetLastPerceived();
        object oTarget = GetAttackTarget();
        if(GetIsObjectValid(oNoticed) && !GetIsObjectValid(GetAttemptedAttackTarget()))
        {
            if (GetLastPerceptionSeen() && GetIsEnemy(oNoticed))
            {
                DetermineCombatRound();
            }
            else if(GetLastPerceptionVanished() && oTarget == oNoticed)
            {
                 ClearAllActions();
            }
        }
    }
}
//Could just use the same one as the generic
*/

