//::///////////////////////////////////////////////
//:: Custom User Defined Event
//:: FileName
//:: Copyright (c) 2001 Bioware Corp.
//:://////////////////////////////////////////////
/*

*/
//:://////////////////////////////////////////////
//:: Created By:
//:: Created On:
//:://////////////////////////////////////////////

void main()
{
	ExecuteScript("prc_npc_userdef", OBJECT_SELF);
	

object oObject;
string sString;
object oCreate;
object oLoot;
int nCounter;
int nGold;
object oBlood;
object oShouter;
object oSeen;
int nRandom;

    int nUser = GetUserDefinedEventNumber();

    if(nUser == 1001) //HEARTBEAT
    {


    }
    else if(nUser == 1002) // PERCEIVE
    {
     oSeen=GetLastPerceived();



     ClearPersonalReputation(oSeen,OBJECT_SELF);

    if (GetReputation (OBJECT_SELF,oSeen)<50)
     {
      AdjustReputation(oSeen,OBJECT_SELF,20);
     }


      if (GetLastPerceptionSeen())
       {

           if (GetIsPlayableRacialType(oSeen))
         {
            int iDC = 21;
            int iBonus = GetSkillRank(SKILL_ANIMAL_EMPATHY, oSeen);
            if ((d20() + iBonus) >= iDC)
           {
            ClearAllActions();
            SetFacingPoint(GetPosition(oSeen));
            ActionPlayAnimation(ANIMATION_FIREFORGET_BOW);
            PlaySound("as_an_dogbark1");
           }
           else
           {
            ClearAllActions();
            ActionMoveAwayFromObject(oSeen,TRUE,40.0);
            SpeakString("JW_RUN_AWAY",TALKVOLUME_SILENT_TALK);
            PlaySound("as_an_dogbark2");
           }
         }

       }
    }


    else if(nUser == 1003) // END OF COMBAT
    {

    }
    else if(nUser == 1004) // ON DIALOGUE
    {
if (GetListenPatternNumber()==30)
      {
        ClearAllActions();
        oShouter=GetLastSpeaker();
        ActionMoveAwayFromObject(oShouter,TRUE,40.0);
        }
    }
    else if(nUser == 1005) // ATTACKED
    {
     ClearAllActions();
     SpeakString("JW_RUN_AWAY",TALKVOLUME_SILENT_TALK);
      PlaySound("as_an_dogbark6");
     ActionMoveAwayFromObject(GetLastAttacker(),TRUE,40.0);
    }
    else if(nUser == 1006) // DAMAGED
    {

    }
    else if(nUser == 1007) // DEATH
    {

    }


    else if(nUser == 1008) // DISTURBED
    {

    }

else if(nUser == 50) // Destory self
    {



    }
}