/*
          HCR Henchman System - Designed to be used with HCR.

    NOTE: Designed and tested with SOU v1.32 and HCR v3.1.0!

  This system was originally based on the Cohort system (v1.0.8). Though it has
 undergone quite a few changes since I first started. See below for a current
 list of features that can be found within this system.

  To get the most recent version of HCR and any add on's for it go to:
  - http://www.rpging.net/nwn/

  Do not download anything from the main HCR site located at:
  - http://nwn.darkemud.com/~darke/HC/

  Everything there is very out of date and the site is not controlled by the
 current developers of HCR. However you can use the forums there for help.

  Built upon and expanded from the great works of others:

  Pausanias---- For the Henchman AI.
  Jugulator---- For the Spellcaster AI.
  Tony K------- For his work on the Henchman and Spellcaster AI.
  69MEH69------ For multi-hench code and idea's.
  Krebb-------- For his keyword conversation system.
  CWard-------- For Henchman XP Level Up code.
  0100010------ For the Cohort System and tons of ideas and feedback.
  Yibble------- For the extra work done to the Cohort system.
  Celowin------ For awesome tutorials and initial work on creating Henchmen.
  Jamos-------- For keeping HCR going, bug fixes, ideas, being a code guru, etc. :)
  Ragnar------- For his support of HCR and his knowledge of it's operation.
  The Lexicon - For being one of the most useful tools I have run across.
  And to any other people and/or work I may have forgot to mention.

   The ERF contains all of the scripts required to run this system, five custom
  placeables and one custom item. The Henchman Home object should be placed
  where the home town of the Henchman is. (And near a NPC cleric of atleast
  level 9 if the Rez system is on.) Each Henchman will require their own home
  object. Just place as many as you need then edit each of them adding the
  Henchman's TAG to the end of the objects TAG. The Corpse Location object
  should already be placed in the Henchmen Fugue Plane. If you are upgrading
  from a previous version of this system you MUST delete the old one from HCR's
  Fugue Plane. The Henchman System Sign can be placed anywhere. Many of the
  system variables and some persistent variables will be set on this sign. The
  Henchman Track DC object is optional. If you want Henchmen Rangers to be able
  to "track" creatures it should be placed in each area that tracking is
  permitted. The Henchman Drop Bag and the Henchman Corpse Token does not need
  to be placed. They will be created whenever a Henchman dies IF you use the
  death system. One custom file is also included in the download. The
  CRR_HS_EVENT_SCRIPTS.ini file should be placed in the scripttemplates folder
  in the NeverwinterNights directory. This file makes it faster and safer to
  place the event scripts where they belong in the Henchman blueprints.

  A couple of system flags in HCR can affect this system:
  - MATERCOMP: Henchmen will use spell comps and let you know when they need
   one to cast a spell. The spell comp must be in the Henchman's inventory NOT
   yours. Sometimes you may notice, a cleric for example, equip his Holy Symbol
   (dagger) and try to fight with it. Though irritating it is not a big deal,
   just have them re-equip weapons and armor. By default though I recommend you
   only give them the necklace type Holy Symbols and the misc. type Thief Tools
   to avoid equip issues. Note: The variable name for the master has changed
   from the previous version. This change will require you to search for the
   string "REAL_MASTER" in the "hc_inc_component" script and change it to
   "HS_REAL_MASTER". This will ensure the PC master of the Henchman gets
   recognized properly.
  - RESTSYSTEM: Henchmen will rest the same way PC's do. Snoring, etc.
  - LIMITEDRESTHEAL: Henchmen only recover their hit die in hit points when they
   rest instead of going to full health. This requires the RESTSYSTEM to be on.

  Creating the Henchman Blueprint:

  - Step 1: Initial Blueprint
   The easiest way is to open the Creature Wizard. Using this tool will ensure
  the initial feats and skills are valid for the class that is chosen. The
  number one thing to remember is to give the Henchman one class and start them
  at level one. It is also vital that the Henchman starts in one of the standard
  classes. If you want them to have multi-classes that will come later. Now that
  you have this initial blueprint we will customize it so that it works for us.
  Note: This initial blueprint will be deleted later. It is just used to verify
  feat selection for the package. If you are experienced with 2DA's and know
  how the packages work you can skip this and just create a valid blueprint.

  - Step 2: Basic Tab
   Now that we have the initial blueprint created right-click it and choose
  "Edit Copy". Starting with the Basic Tab set the following:
  -- First Name: I recommend something kinda short but still unique.
  -- Last Name: I strongly suggest you give them a last name. Long and unique.
  -- TAG: Set this to HS_ plus the first name in all caps. (ex. HS_HARKINIAN)
  -- Description: Make use of this. Give hints to personality or class.
  -- Portrait: Give a unique portrait to each Henchman. This reduces confusion.
  -- Conversation: Set either the "hark_hench_dlg" one or a custom one you made.

  - Step 3: Statistics Tab
   This Tab holds all of the attributes for the Henchman. You can twink these as
  needed but I suggest you dont stray too far from the defaults. Remember this
  is a Henchman NOT a PC. They should not be very extraordinary. Most Henchmen
  are normal folk that got tired of the "normal" life. The single exception to
  this should be only for story reasons. Whatever you set here verify that the
  points spent are legal and are high enough to support the primary class.

  - Step 4: Appearance Tab
   Again make sure no two Henchmen look the same. If a PC can identify a
  Henchman by sight it greatly reduces confusion during battle.

  - Step 5: Classes Tab
   Note: Only choose a single class here and make sure the Henchman is level 1.
  -- Alignment: Choose an alignment appropriate to the class and personality.
  -- Class: Place the class in the TOP MOST slot and set it to level 1.
  -- Package: Pick a package to set the feats that will be aquired on level-up.

  - Step 6: Skills Tab
   You can adjust these if desired but the package chosen will determine where
  the points go on level-up. The classes a Henchman has also influence this.
  Leaving these at default is generally a safe way to go. Finally verify all
  points spent here are legal.

  - Step 7: Scripts Tab
   Click the Load Script Set button and choose the CRR_HS_EVENT_SCRIPTS.ini
  file. This file is included in the download and contains all of the event
  scripts. Using the ini file will place them where they belong for you. Once
  you have done this they should appear as shown below:
  -- OnBlocked: ----------- hark_ace_blocked
  -- OnCombatRoundEnd: ---- hark_ac3_combat
  -- OnConversation: ------ hark_ac4_dialog
  -- OnDamaged: ----------- hark_ac6_damaged
  -- OnDeath: ------------- hark_ac7_death
  -- OnDisturbed: --------- hark_ac8_disturb
  -- OnHeartbeat: --------- hark_ac1_heartbt
  -- OnPerception: -------- hark_ac2_perciev
  -- OnPhysicalAttacked: -- hark_ac5_attack
  -- OnRested: ------------ hark_aca_rest
  -- OnSpawn: ------------- hark_ac9_spawn
  -- OnSpellCastAt: ------- hark_acb_spell
  -- OnUserDefined: ------- hark_acd_userdef

  - Step 8: Advanced Tab
  -- ResRef: Should be identical to the TAG but in lower case. (ex. hs_harkinian)
  -- Faction: Create a new faction. Set it to Friendly to PC's and Hostile
     towards the Hostile faction. It should be Neutral to everyone else.
  -- No Permanent Death: Make sure this check box has been checked.
  -- Diety: Type in a Diety name that is appropriate to Class and Alignment.
  -- Sound Set: I prefer using the PC sets since they are complete but you can
     set anything that sounds right for this Henchman.
  -- Perception Range: Verify that this is set to Default.

  - Step 9: Feats Tab
   If you have modified the 2DA's then you know what to set here otherwise I
  strongly suggest leaving them at default. If you choose a feat that is not
  valid for this class it WILL break the level up code! Remember the Creature
  Wizard will choose default feats appropriate for the class you chose.

  - Step 10: Spells Tab
   If this Henchman has any spell ability at level one then you can choose what
  those spells are here. If the Henchman will aquire spells later then they will
  choose their own spells when they level-up based upon the package chosen.
  Verify the number of spells taken is legal.

  - Step 11: Special Abilities Tab
   Do not set anything here. This should be used for monsters only.

  - Step 12: Comments Tab
   Place anything you wish here. For building purposes you may find it useful to
  place the TAG of the Henchman, the primary class and alignment. This makes it
  a little easier to examine all of the Henchmen blueprints to see what classes
  and alignments you have chosen so far.

  - Step 13: Inventory
   Now that all of the Tabs have been set up click on the inventory button below
  the 3D figure of the Henchman. You may want to take a quick glance at the Feat
  Tab to verify what type of armor and Weapon should be given. The Henchman
  should be given a Melee weapon, Ranged Weapon, Armor and a Shield if they have
  the feats. Give them some Ammo for the Ranged weapon and maybe a Cure Light
  Wounds potion or two. I suggest you dont give them anything magical to start
  with. I also suggest you dont give them the very best armor they can wear.
  Starting them too decked out makes it tempting for some players to rob them
  blind and sell their gear for cash. Note: If you give the Henchman a custom
  item, make sure the identified box has been checked. A Henchman can no longer
  equip an item that has not been identified first!

  - Step 14: Verify the Name, TAG and ResRef
  -- FirstName: Harkinian    (Can be any. I suggest short and unique.)
  -- LastName : Anything     (Whatever you want. I suggest long and unique.)
  -- Tag      : HS_HARKINIAN (HS_ prefix plus the FirstName in all caps.)
  -- Blueprint: hs_harkinian (Same as TAG but in lower case.)

  - Step 15: Cleaning Up
   Your Henchman is finished. Click OK to close the blueprint editor. You should
  now see the blueprint you was working on highlighted. Right-Click the one you
  created using the Creature Wizard and delete it. Repeat these steps for each
  Henchman you will place in your module. If this is a large world it is wise to
  create a large variety of Henchmen with varying Alignment's. It is also wise
  to have more than one of each Class so no PC is restricted from hiring a
  Henchman they could use because of Alignment or availability. One final point,
  never ever start a Henchman with a prestige class, multi-classed or higher
  than level one.

  - Henchman Conversation:
   I assume everyone knows how to create dialog for their Henchman. I have
  included a dialog file which contains all the possible options for your
  Henchman, use this as a reference dialog. Simply copy and paste from this
  dialog tree into a new conversation or do a "SaveAs" with a new name and
  remove or add what you need for this Henchman. Or if you wish you can just
  give all of your Henchmen the same dialog file. If you choose the latter
  method then I suggest you actually DM the module or else the Henchmen will be
  a bit on the boring side. Note: If you are adding custom plot nodes that have
  a specific condition, place them at the top of the root file.

  - Henchmen of level 2+ and Multi-Class:
   Never ever start a Henchman higher than level one. It will break the level-up
  code. By default the PC's can choose what classes the Henchman will take and
  how many levels they can take in each class. If you choose to turn off this
  option, you can choose default settings in the OnSpawnIn script. You will need
  to rename it and create a copy for each Henchman however. In the Class Options
  section of that script you can choose what classes will be taken and what the
  max level for that class will be. The Henchman will only gain a level in a
  specific class if they are eligible to do so. So if you choose a prestige
  class it will NOT gain levels until the requirements for that class are met.
  Once a Henchman has a second or even a third class they will try to level-up
  evenly until a class hits it's max level. I generally suggest you leave the
  leveling up to the PC's or to force Henchmen to remain as single classed.

  - Place The Henchman System Sign Placeable:
   The Henchman System Sign you can place anywhere. It contains info which is
  useful for players so the start area of your mod is a good choice. If you have
  custom keywords or have changed the options from the default settings this is
  a good place to let players know how Henchmen will react. Note: You can change
  the sign to something else if you wish but retain the same TAG and keep it
  marked as Plot or placed in a safe place. If this object should be destroyed
  or removed from the game it will utterly break this system. Failing to add
  this placeable will also have the same effect so dont forget to add it!

  - Place The Henchman Corpse Location Placeable:
   You will need to place this invisible object in an area that is inaccessible
  to players, such as the blocked off portion of the fugue plane in HCR. You
  will have to make such an area if one does not exist. This is where the
  corpses of Henchmen go when they are picked up. Note: If the DEATHSYSTEM is
  off they will respawn at their home location instead.

  - Place The Henchman Home Location Placeable:
   This must be added and by default it's TAG should be: "HS_HOME_LOC" plus the
  TAG of the Henchman. So my home would be "HS_HOME_LOCHS_HARKINIAN". You will
  need to create a home object for each Henchman in the module. If the Hench Rez
  option is on and the Henchman cannot resurrect their master, they will pickup
  the PCT and make their way to this object. Once there they will seek help from
  a PC or NPC cleric to try and get their master rez'd. Note: PW Henchman can
  have a new home location saved via dialog. If the Go Home when Fired/Quit
  option is on then this is where they will go.

  - Place The Henchman Track DC Placeable:
   This object is optional but if you place it then Ranger's can make use of the
  tracking skill. Place this in all area's the Henchman is allowed to track
  creature's in and adjust the Will save of each object. The Will save is the
  base DC of the tracking check. Things like Weather and Natural settings will
  apply a bonus or penalty as appropriate. The roll is calculated with a d20
  plus the level in the Ranger Class. The DC is the Will save plus/minus 2 for
  Weather and plus/minus 2 for a Natural setting. If the roll is higher the
  tracking attempt succeeds. Note: Distance to the target creature will also
  affect the final DC. The closer the creature the more recent the tracks.

  - Add The On Module Load Script:
   This script will initialize all the variables you set in the "hark_i0_vars"
  script. See the "hark_onmod_load" script for instructions on how to add this
  to your module.

  - Add The On Player Aquire Item Script:
   This script will remove the corpse of a Henchman when you pick up the corpse
  token. See the "hark_onply_acq" script for instructions on how to add this
  to your module.

  - Add The On Player Death Script:
   This script will set a variable on your Henchman when you die which allows
  them to rejoin you when you get rez'd. See the "hark_onply_death" script for
  instructions on how to add this to your module.

  - Add The On Player Enter Script:
   This script will remove any Henchman Corpse Tokens the PC may have in their
  inventory. See the "hark_onply_enter" script for instructions on how to add
  this to your module.

  - Add The On Player Exit Script:
   This will force the PC to drop any Henchman Corpse Tokens they may have in
  their inventory. See the "hark_onply_exit" script for instructions on how to
  add this to your module.

  - Add The On Player Level Up Script:
   This script will cause the Henchman to level when you do IF they can. If you
  choose to not use this that isn't a problem, you can still tell them to level
  up via the conversation. Note: If you charge your PC's to level your Henchmen
  they will automatically take the required amount. If the PC does not have the
  gold then the Henchman will not level up. See the "hark_onply_lvlup" script
  for instructions on how to add this to your module.

  - Add The On Player Rest Script:
   This script will make the Henchman snore and if used, limit the hitpoints
  healed from resting. See the "hark_onply_rest" script for instructions on how
  to add this to your module.

  - Add The On Player Transition Script: (OPTIONAL)
   Not an actual module event script but intended to be placed on doors or
  trigger transitions that move the PC from one place to another within the SAME
  area. This will cause all associates to "follow" the PC instead of getting
  stuck or standing around looking stupid. See the "hark_onply_trans" script.

  - Add The On Player UnAquire Item Script:
   This script will recreate the Henchman Drop Bag or move it, if it still
  exists. See the "hark_onply_unacq" script for instructions on how to add this
  to your module.

  - Modified Bioware Scripts:
   If you use the "nw_d1_templeheal" script a modified one has been included
  that will properly heal you and all associates. Either use this script in
  its place or rename and overwrite the existing one. Modified versions of the
  "nw_s0_raisdead" and "nw_s0_resserec" is also included. You MUST overwrite
  these scripts on import for these spells to work on Henchmen corpses. The Rod
  of Resurrection will also work on corpses with these scripts. If you use HCR
  this will also fix a bug where these spells would fail to raise NPC's.

  - Documentation and Control File:
  -- hark_hs_file_log:
   Details changes that have been made since I have started working on this
   system and contains a current list of files used.
  -- hark_hs_read_dm:
   Describes what options a DM can change and what effects they have if the DM
   helper system is turned on.
  -- hark_hs_read_me:
   Describes setting this system up and lists the features.
  -- hark_hs_read_pw:
   Describes how persistent Henchmen work.
  -- hark_i0_vars:
   Contains all of the switches you can modify to fit your personal taste. Each
   switch is commented to explain what it does.

   It would be wise to read through all of these scripts even if you have used
  the Cohort system or this system before, just to make sure you know what all
  has changed and what is currently available.

   If you are reading this then my thanks to you for actually taking the time
  to get this far. If you have questions/comments/suggestions send them to:
  - Harkinian00@YAHOO.com

  Features:

  - Paus'/Tony K's Henchman AI v0.98: This is the "brains" of the Henchmen. I
    modified it slightly to be friendly for multiple Henchmen but for the most
    part the AI was left unmodified.

  - Kurt Jaegers (Krebbs) Keyword Conversation System v1.2: Most of this system
    has been removed since it was not being used. I retained only what was
    required to evoke a script based on the typed keyword from the PC that hired
    the Henchman. By typing the Henchman's first name or "all" plus a given
    keyword will execute the relating script and desired effect. To change the
    keywords or add your own see the "hark_ac9_spawn" script. Note: the "HS_"
    prefix is dropped so all you need to type is the actual first name.
    Example:
     - "Harkinian attack" OR "Harkinian kill", Calls Attack Nearest command.
     - "Harkinian equip", Tells the Henchman to equip Weapon's and Armor.
     - "Harkinian follow", Calls Follow Me command.
     - "Harkinian guard", Calls Guard Me command.
     - "Harkinian heal", Calls Heal Me command.
     - "Harkinian stand" OR "Harkinian stay", Calls Stand Ground command.
     - "Harkinian come", Tell's the Henchman to immediately run to your side.
     - "Harkinian camp", Tell's the Henchman to join you by the campfire.

  - Henchmen can use about any Bioware item and can also use the HCR versions of
   the Thief Tool, Heal Kit and Potions. If you use the "dagger" version of the
   Thief Tool or Holy Symbol they may try to wield it so I strongly recommend
   against using those. If you insist then just have them re-equip themselves to
   get them to switch to best weapon. The misc. type of Cure potions (non stack)
   are supported and you can use those on them to bring them out of dying.

  - Hook scripts (preEvent & postEvent) are in place and named "hark_i0_ac#" for
   the event script's. Use these hook scripts to add your own custom code. It is
   wise to use these since I will NEVER change these scripts. So when you
   upgrade you dont have to overwrite these files. Leaving your code intact and
   in place. To make use of them: the preEvent hook can be used to occur before
   my code or to replace it entirely. To bypass my code change the return value
   to zero. The postEvent hook will occur after my code has run.

  - Restrictions on hiring a Henchman:
  -- Cant hire if you have the maximum number of Henchmen allowed per PC.
  -- Cant hire if the Henchman is too high of a level for you.
  -- Cant hire if your alignment will not permit it.
  -- Cant hire if your current Henchman's alignment won't permit it.
  -- Cant hire if the Henchman is already working for someone.
  -- Cant hire the Henchman if you cant afford it.
  -- Cant hire the Henchman if you previously killed the Henchman.

  Conversation Options:

  - DM Helper Node: A conversation node which permits DM's to change system
    options or even reset the Henchman being spoken to. This requires the option
    to be turned on under the advanced section of the "hark_i0_vars" script.
    Read the "hark_hs_read_dm" script for full details of this option.

  - Henchmen have limited feelings. Attacking them or leaving them to bleed to
    death can have them refuse to ever work for you again! It should be easy for
    mod makers to expand this for Plot/Quest related stuff. I plan to expand on
    this further after getting some initial feedback.

  - It costs Gold to hire and or level up your Henchman. The exact cost is set
    in the "hark_i0_vars" script. To disable this set the cost to zero.

  - Options: This has 7 sub options which breaks up all the choices into related
    categories. Descriptions of the sub-categories follow:
    - Auto: These are things the Henchman will do automatically. Once activated
      when the option chosen is encountered the Henchman will try to deal with
      it. Note: The option will only appear if the Henchman has the required
      skills to carry it out.
    - Healing: With these you can choose Who, What and When a Henchman will try
      to heal a given target. For some you can even tell the Henchman to never
      heal them. Familiars for example. If certain conditions are met the
      Henchman will try to heal dying or dead targets as well. Note: Anything
      in the same party as the Henchman is a valid heal target!
    - Level Up: If PC's are permitted to set the class options of Henchmen, this
      is where it will be done at. Classes that are valid to take will appear
      here and the PC can also set what the max level of each class will be.
    - Misc: These are miscellaneous options that dont quite fit anywhere else.
    - Persistent: If persistent Henchmen is used the PC can do 3 things here.
      The first is to save the current state. This includes any equipment
      carried! Mod makers should be careful of this. If a Henchman is given a
      Plot related item this could be abused to no end! The second option is to
      set a new home waypoint. The last only appears if the Henchman has a
      previously stored state. It will restore that state and remove the "old"
      Henchman as well as delete the saved state from the database.
    - Spell: If the Henchman has any spell ability you can set what they will do
      with it here. Including to not cast at all!
    - Weapon: This handles what weapon a Henchman will use. The PC can also have
      the Henchman unequip weapons for roleplaying purposes. Melee or Ranged
      weapons can be chosen or even how to dual wield Melee weapons.

  - Inventory: If PC's are permitted to open the Henchman's inventory they can
    do so through dialog or the radial command. At present I do not suggest you
    disable this option. I have removed all of the "old" level up functions so
    Henchmen would be stuck with their starting equipment. I do plan to re-add
    support for that so you can choose specific gear that your PC's cant access.

  - Identify: This node will appear only if the Henchman has more ranks in Lore
    than the PC does AND the PC actually has something to ID.

  - Use Skill/Spell: Here you can tell your Henchman to use the given skill or
    spell. Only the skills or spells the Henchman actually has will appear here.
    If you choose a spell you must also choose who the target will be. This can
    be the PC, the Henchman or a nearby enemy. If you choose the track and
    follow, the Henchman will actually follow the tracks to the creature.

  - Rez Nearby Corpse: If a corpse is nearby and the Henchman has the means to
    raise it, this node will appear.

  - Scout: The Henchman will move in the general direction of the nearest enemy
    and engage if any are present.

  - Level Up: This will cause the Henchman to level up. You can choose to have
    them only gain a single level or level as far as they can per the default
    settings. You may be required to pay before any levels are gained.

  - Leave: This fires the Henchman. Removing him from the PC's employ. If the
    Go Home option is on the Henchman will return to their home location,
    otherwise they will remain where they are.

*/
void main(){}
