// v2.1.0 - Disabled the Heartbeat and Dialog UDE's since those aren't used now.
// v2.0.0 -
//::////////////////////////////////////////////////////////////////////////////
//:: FileName:  hark_ac9_spawn
//::////////////////////////////////////////////////////////////////////////////
/*
   Determines the course of action to be taken after having just been
  spawned in. Set initial variables, listening patterns, etc...
*/
//::////////////////////////////////////////////////////////////////////////////
#include "hark_i0_henshout"
#include "hark_i0_ac9"
//::////////////////////////////////////////////////////////////////////////////
void main()
{
  if (!preEvent()) { return; }

//::////////////////////////////////////////////////////////////////////////////
// * GENERIC SETTINGS

  // None of these settings need to be modified. All of these are just default
  // spawn settings which can be adjusted through the conversation file.
  SetAssociateListenPatterns();// Listening junk.
  SetListeningPatterns();// More listening junk.
  SetAnimationPatterns();// Sets flags for the animations.
  SetFollowDistance(HS_FOLLOW_CLOSE);// Follow close.
  SetAssociateState(NW_ASC_RETRY_OPEN_LOCKS, TRUE);// Retry locks.
  SetAssociateState(NW_ASC_MODE_DEFEND_MASTER, FALSE);// Do not defend master.
  SetAssociateState(NW_ASC_USE_RANGED_WEAPON, FALSE); // Use melee weapons.
  SetAssociateState(NW_ASC_HEAL_AT_50, TRUE);    // Heal Master at 50% health.
  SetAssociateState(NW_ASC_HEAL_OTH_AT_50, TRUE);// Heal Others at 50% health.
  SetAssociateState(NW_ASC_HEAL_SLF_AT_50, TRUE);// Heal Self at 50% health.
  SetAssociateState(NW_ASC_HEAL_OTH, TRUE); // Attempt to heal Others.
  SetAssociateState(NW_ASC_HEAL_HEN, TRUE); // Attempt to heal Henchmen.
  SetAssociateState(NW_ASC_HEAL_FAM, FALSE);// Do not heal Familiars.
  SetAssociateState(NW_ASC_HEAL_ANI, FALSE);// Do not heal Animal Companions.
  SetLocalInt(OBJECT_SELF, "NoDisarmTraps", TRUE);// Do not auto disarm traps.
  SetIsDestroyable(FALSE);// Make sure the death flag is set right.
  SetAssociateStartLocation();// Initial starting point on mod load.

//::////////////////////////////////////////////////////////////////////////////
// * ANIMATIONS

  // Choose which type of animation to use while the Henchman is not hired.
  // Note: Only uncomment out one of these choices.
  //SetSpawnInCondition(NW_FLAG_ANIMATION_MOBILE);
  SetSpawnInCondition(NW_FLAG_ANIMATION_AMBIENT);

//::////////////////////////////////////////////////////////////////////////////
// * HENCHMAN KCS SETUP

  // Goes through and sets up which keywords the Henchman will listen for.
  object oSelf = OBJECT_SELF;
  string sTag = GetTagNoPrefix(oSelf);
  SetKeyword(sTag+"*w(attack|kill)", "hark_kcs_attackn");
  SetKeyword("(all)*w(attack|kill)", "hark_kcs_attackn");
  SetKeyword(sTag+"*w(equip)",       "hark_kcs_reequip");
  SetKeyword("(all)*w(equip)",       "hark_kcs_reequip");
  SetKeyword(sTag+"*w(heal)",        "hark_kcs_healmas");
  SetKeyword("(all)*w(heal)",        "hark_kcs_healmas");
  SetKeyword(sTag+"*w(follow)",      "hark_kcs_followm");
  SetKeyword("(all)*w(follow)",      "hark_kcs_followm");
  SetKeyword(sTag+"*w(guard)",       "hark_kcs_guardma");
  SetKeyword("(all)*w(guard)",       "hark_kcs_guardma");
  SetKeyword(sTag+"*w(stand|stay)",  "hark_kcs_standgr");
  SetKeyword("(all)*w(stand|stay)",  "hark_kcs_standgr");
  SetKeyword(sTag+"*w(come)",        "hark_kcs_return");
  SetKeyword("(all)*w(come)",        "hark_kcs_return");
  SetKeyword(sTag+"*w(camp)",        "hark_kcs_camp");
  SetKeyword("(all)*w(camp)",        "hark_kcs_camp");

//::////////////////////////////////////////////////////////////////////////////
// * CLASS OPTIONS

  // By default the PC can change/set how a Henchman will level up through the
  // conversation file. If you prefer to disable that you can modify these
  // settings and rename this script for each Henchman to give them a unique
  // mix of classes. Set the primary class in the blueprint for the Henchman
  // and if you wish a second or even third class simply change the class type
  // from INVALID to the CLASS_TYPE_* constant you want them to have. Lastly if
  // you set a second or third class here you must also set the max level for
  // it. If you set it to zero then they will never gain a level. If you just
  // want the Henchman to level evenly without stopping in any one class early,
  // just leave it set to level 20. Note: A Henchman will not gain levels in any
  // class unless they meet the requirements first.
  SetLocalInt(oSelf, HS_LVL_C2_TYPE, CLASS_TYPE_INVALID);// Second class.
  SetLocalInt(oSelf, HS_LVL_C3_TYPE, CLASS_TYPE_INVALID);// Third class.
  SetLocalInt(oSelf, HS_LVL_C1_MAX, 20);// Max level for the first class.
  SetLocalInt(oSelf, HS_LVL_C2_MAX, 20);// Max level for the second class.
  SetLocalInt(oSelf, HS_LVL_C3_MAX, 20);// Max level for the third class.
  SetLocalInt(oSelf, HS_CUR_HENCH_XP, 1);// Current XP the Henchman starts with.

//::////////////////////////////////////////////////////////////////////////////
// * USER DEFINED EVENTS.

  // The following settings will allow the user to fire one of the blank user
  // defined events in the "hark_acd_userdef" script. Like the On Spawn In
  // script this script is meant to be customized by the end user to allow for
  // unique behavior. Change these to TRUE if you wish to use them.
  SetSpawnInCondition(NW_FLAG_EVENT_HEARTBEAT, FALSE);// Fire UDE 1001
  SetSpawnInCondition(NW_FLAG_EVENT_PERCIEVE,  FALSE);// Fire UDE 1002
  SetSpawnInCondition(NW_FLAG_EVENT_COMBAT,    FALSE);// Fire UDE 1003
  SetSpawnInCondition(NW_FLAG_EVENT_DIALOGUE,  FALSE);// Fire UDE 1004
  SetSpawnInCondition(NW_FLAG_EVENT_ATTACK,    FALSE);// Fire UDE 1005
  SetSpawnInCondition(NW_FLAG_EVENT_DAMAGED,   FALSE);// Fire UDE 1006
  SetSpawnInCondition(NW_FLAG_EVENT_DEATH,     FALSE);// Fire UDE 1007
  SetSpawnInCondition(NW_FLAG_EVENT_DISTURBED, FALSE);// Fire UDE 1008
  SetSpawnInCondition(NW_FLAG_EVENT_SPAWN,     FALSE);// Fire UDE 1009
  SetSpawnInCondition(NW_FLAG_EVENT_RESTED,    FALSE);// Fire UDE 1010
  SetSpawnInCondition(NW_FLAG_EVENT_SPELL,     FALSE);// Fire UDE 1011
  SetSpawnInCondition(NW_FLAG_EVENT_BLOCKED,   FALSE);// Fire UDE 1012

//::////////////////////////////////////////////////////////////////////////////
// * PERSISTENT SUPPORT.

  // Restore the Drop Bag.
  if (GetLocalInt(GetObjectByTag(HS_VARS_OBJ), HS_VAR_ADV_PWH) &&
     !GetLocalInt(oSelf, "ENTERED"))
    { RetrieveDropBag(oSelf); }

//::////////////////////////////////////////////////////////////////////////////

  if (GetSpawnInCondition(NW_FLAG_EVENT_SPAWN))
    { SignalEvent(oSelf, EventUserDefined(1009)); }

  postEvent();
}
//::////////////////////////////////////////////////////////////////////////////
