Back

### On Spawn Explanation

This is always fired when a creature is created - even in pause mode. It can initiate behaviours, set spawn options, and do many special things. My version has a LOT of options compared to the Bioware AI, and therefore here it documents what the different options do in a LOT of detail.

The list below are options in a brief order of IMPORTANT, TARGETING, COMBAT, OTHER COMBAT (healing, fleeing), OTHER, SHOUTS + USER-DEFINED and finally DEFAULT BIOWARE. There are no arguments for this file. The default spawn file contains very briefed notes compared to this document. The list is set with the default values for it (IE what setting is stored under, or the default value it uses).

Important spawn options that should always be set
SetAIInteger(AI_INTELLIGENCE, 10); - 1-10, creatures intelligence.
SetAIInteger(AI_MORALE, 10); - A creatures morale value
SetAIInteger(SetCustomAIFileName("CUSTOM_AI_FILE"); - A custom AI file (Uncommented)
Targeting (what we attack) - All SetSpawnInCondition settings are under AI_TARGETING_FLEE_MASTER
SetSpawnInCondition(AI_FLAG_TARGETING_LIKE_LOWER_XXX, AI_TARGETING_FLEE_MASTER); - All override "likes"
SetAIConstant(AI_FAVOURED_ENEMY_XXX); - A favoured constant to attack.
Target Changing Explaintion - Explanation of when/why we change targets.
SetAIInteger(AI_MAX_TURNS_TO_ATTACK_ONE_TARGET, 6); - Max turns to attack one target.
SetAIInteger(AI_MELEE_LAST_TO_NEW_TARGET_CHANCE, 20); - Chance to re-check melee target each round.
SetAIInteger(AI_RANGED_LAST_TO_NEW_TARGET_CHANCE, 20); - " " Ranged target.
SetAIInteger(AI_SPELL_LAST_TO_NEW_TARGET_CHANCE, 20); - " " Spell target.
Targeting Values Explaintion - Explanation of the main points of the targeting values that can be set (EG: The maximum/minimum targets based on AC)
AI_SetAITargetingValues(TARGETING_MANTALS, TARGET_LOWER, i1, i12); - Mantal Targeting.
AI_SetAITargetingValues(TARGETING_RANGE, TARGET_HIGHER, i2, i9); - Range Targeting.
AI_SetAITargetingValues(TARGETING_AC, TARGET_LOWER, i1, i12); - AC Targeting.
AI_SetAITargetingValues(TARGETING_SAVES, TARGET_LOWER, i2, i4); - Mantal Targeting.
AI_SetAITargetingValues(TARGETING_PHISICALS, TARGET_LOWER, i2, i6); - Phisical Protections Targeting.
AI_SetAITargetingValues(TARGETING_BAB, TARGET_LOWER, i1, i4); - BAB Targeting.
AI_SetAITargetingValues(TARGETING_HITDICE, TARGET_LOWER, i1, i3); - HD Targeting.
AI_SetAITargetingValues(TARGETING_HP_PERCENT, TARGET_LOWER, i1, i3); - HP Percent Targeting.
AI_SetAITargetingValues(TARGETING_HP_CURRENT, TARGET_LOWER, i1, i3); - HP Current Targeting.
AI_SetAITargetingValues(TARGETING_HP_MAXIMUM, TARGET_LOWER, i1, i3); - HP Maximum Targeting.
Fleeing (How/why we run from combat) - All SetSpawnInCondition settings are under AI_TARGETING_FLEE_MASTER
SetSpawnInCondition(AI_FLAG_FLEEING_FEARLESS, AI_TARGETING_FLEE_MASTER); - Basically turns off morale checks if set.
SetSpawnInCondition(AI_FLAG_FLEEING_NEVER_FIGHT_IMPOSSIBLE_ODDS, AI_TARGETING_FLEE_MASTER); - Never any immpossible battles.
SetSpawnInCondition(AI_FLAG_FLEEING_TURN_OFF_GROUP_MORALE, AI_TARGETING_FLEE_MASTER); - Turns off group morale.
SetAIInteger(AMOUNT_OF_HD_DIFFERENCE_TO_CHECK, -2); - If enemy within this, we do not check morale.
SetAIInteger(BASE_MORALE_SAVE, 20); - The base DC for morale check saves (Default: 20 + HD difference - Morale vaule).
SetAIInteger(HP_PERCENT_TO_CHECK_AT, 20); - % Of HP needed to be at to run.
SetSpawnInCondition(AI_FLAG_FLEEING_NO_OVERRIDING_HP_AMOUNT, AI_TARGETING_FLEE_MASTER); - If set, turns off "Intelligent" disregard for current HP.
SetAIInteger(AI_DAMAGE_AT_ONCE_FOR_MORALE_PENALTY, GetMaxHitPoints()/6); - Damage needed to be done to get a massive morale penalty (Below)
SetAIInteger(AI_DAMAGE_AT_ONCE_PENALTY, 6); - Penalty for the above.
SetSpawnInCondition(AI_FLAG_FLEEING_FLEE_TO_NEAREST_NONE_SEEN, AI_TARGETING_FLEE_MASTER); - If set, just runs to nearest non-seen ally.
SetSpawnInCondition(AI_FLAG_FLEEING_FLEE_TO_OBJECT, AI_TARGETING_FLEE_MASTER); - Turns on "Flee to specific set object".
SetLocalString(OBJECT_SELF, AI_FLEE_OBJECT, "BOSS_TAG_OR_WHATEVER"); - What flee object to use (for above setting)
Combat (Spells, melee) - All SetSpawnInCondition settings are under AI_COMBAT_MASTER
Fighters - Explanation of Melee/Archery settings.
SetSpawnInCondition(AI_FLAG_COMBAT_PICK_UP_DISARMED_WEAPONS, AI_COMBAT_MASTER); - AI attempts to pick up any weapons disarmed from them.
SetAIInteger(AI_RANGED_WEAPON_RANGE, 3); - Range at which to switch to melee combat.
SetSpawnInCondition(AI_FLAG_COMBAT_BETTER_AT_HAND_TO_HAND, AI_COMBAT_MASTER); - This creature likes HTH more then range (EG: Giants)
SetSpawnInCondition(AI_FLAG_COMBAT_ARCHER_ATTACKING, AI_COMBAT_MASTER); - Makes the creature rather move back & shoot then go into melee.
SetSpawnInCondition(AI_FLAG_COMBAT_ARCHER_ALWAYS_MOVE_BACK, AI_COMBAT_MASTER); - Forces the creature to always run back with thier bow from melee attackers.
SetSpawnInCondition(AI_FLAG_COMBAT_ARCHER_ALWAYS_USE_BOW, AI_COMBAT_MASTER); - Forces the creature to always use thier bow.
SetSpawnInCondition(AI_FLAG_COMBAT_NO_GO_FOR_THE_KILL, AI_COMBAT_MASTER); - Turns off all attempts to kill dying things.
Spellcasters - Explanation of Spellcasters settings.
SetSpawnInCondition(AI_FLAG_COMBAT_LONGER_RANGED_SPELLS_FIRST, AI_COMBAT_MASTER); - Makes the caster only cast spells in range of the enemy, long to shorter ranges.
SetSpawnInCondition(AI_FLAG_COMBAT_FLAG_FAST_BUFF_ENEMY, AI_COMBAT_MASTER); - The caster will use buffs fast-cast if the enemy comes in 40M
SetSpawnInCondition(AI_FLAG_COMBAT_SUMMON_FAMILIAR, AI_COMBAT_MASTER); - Creature summons thier familiar/animal companion. Either a nameless bat or badger.
SetSpawnInCondition(AI_FLAG_COMBAT_COUNTER_SPELL_ARCANE, AI_COMBAT_MASTER); - If got dispels, counterspell arcane spellcasters.
SetSpawnInCondition(AI_FLAG_COMBAT_COUNTER_SPELL_DIVINE, AI_COMBAT_MASTER); - If got dispels, counterspell divine spellcasters.
SetSpawnInCondition(AI_FLAG_COMBAT_COUNTER_SPELL_ONLY_IN_GROUP, AI_COMBAT_MASTER); - Only counterspells above if got 5+ (Including us) allies.
SetSpawnInCondition(AI_FLAG_COMBAT_DISPEL_MAGES_MORE, AI_COMBAT_MASTER); - Targets seen mages to dispel, else uses normal spell target.
SetSpawnInCondition(AI_FLAG_COMBAT_DISPEL_IN_ORDER, AI_COMBAT_MASTER); - This will make the mage not dispel just anything all the time, but important things first, others later.
SetSpawnInCondition(AI_FLAG_COMBAT_NEVER_HIT_ALLIES, AI_COMBAT_MASTER); - OVerride. Forces never to cast AOE's if it will hit any allies.
SetSpawnInCondition(AI_FLAG_COMBAT_AOE_DONT_MIND_IF_THEY_SURVIVE, AI_COMBAT_MASTER); - If the ally will survive the blast, they are ignored from best AOE calculations.
SetAIInteger(AI_AOE_ALLIES_LOWEST_IN_AOE, 3); - Defualt: 3. If amount of allies in blast radius are equal or more then this, then that location is ignored.
SetAIInteger(AI_AOE_HD_DIFFERENCE, -8); - Ignores allies who are very, very weak compared to us (cannon fodder). -30 minimum, -1 maximum.
SetSpawnInCondition(AI_FLAG_COMBAT_SINGLE_TARGETING, AI_COMBAT_MASTER); - For Same-level spells, single target spells are used first.
SetSpawnInCondition(AI_FLAG_COMBAT_MANY_TARGETING, AI_COMBAT_MASTER); - For Same-level spells, AOE spells are used first.
SetSpawnInCondition(AI_FLAG_COMBAT_IMPROVED_INSTANT_DEATH_SPELLS, AI_COMBAT_MASTER); - A few Death spells may be cast top-prioritory if the enemy will always fail saves.
SetSpawnInCondition(AI_FLAG_COMBAT_IMPROVED_SUMMON_TARGETING, AI_COMBAT_MASTER); - Will use a better target to summon a creature at (EG: Ranged attacker)
SetSpawnInCondition(AI_FLAG_COMBAT_IMPROVED_IMMUNITY_CHECKING, AI_COMBAT_MASTER); - Turns On "GetIsImmune" checks. Auto on for 7+ Intel.
SetSpawnInCondition(AI_FLAG_COMBAT_IMPROVED_SPECIFIC_SPELL_IMMUNITY, AI_COMBAT_MASTER); - Turns On checks for Globes & levels of spells. Auto on for 9+ Intel.
SetSpawnInCondition(AI_FLAG_COMBAT_MORE_ALLY_BUFFING_SPELLS, AI_COMBAT_MASTER); - This will make the caster buff more allies.
SetSpawnInCondition(AI_FLAG_COMBAT_USE_ALL_POTIONS, AI_COMBAT_MASTER); - Uses all buffing potions before melee.
SetAICheatCastSpells(); - Special: Mages cast for ever with this set.
SetSpellTrigger(); - Special: Spell trigger. Automatic spells to help casters.
Dragons - Explanation of Dragon settings.
SetSpawnInCondition(AI_FLAG_COMBAT_NO_WING_BUFFET, AI_COMBAT_MASTER); - Turns of Dragon-only wing buffet.
SetAIInteger(AI_DRAGON_FREQUENCY_OF_BUFFET, 3); - Defualt: 3. Min rounds between each Dragon Wing buffet.
SetAIInteger(AI_DRAGON_FREQUENCY_OF_BREATH, 3); - Defualt: 3. Min rounds between each Breath use.
SetSpawnInCondition(AI_FLAG_COMBAT_FLYING, AI_COMBAT_MASTER); - Turns on Flying attacks, for any creature.
Other Combat (Healing, Skills) - All SetSpawnInCondition settings are under AI_OTHER_COMBAT_MASTER
Healers - Explanation of Healers settings.
SetSpawnInCondition(AI_FLAG_OTHER_COMBAT_HEAL_AT_PERCENT_NOT_AMOUNT, AI_OTHER_COMBAT_MASTER); - Forces healing as long as under %.
SetAIInteger(AI_HEALING_US_PERCENT, 50); - % of HP we need to be at until we heal us at all. Default: 50
SetAIInteger(AI_HEALING_ALLIES_PERCENT, 60); - % of HP allies would need to be at to heal them Readme = info. Default: 60
SetSpawnInCondition(AI_FLAG_OTHER_COMBAT_WILL_RAISE_ALLIES_IN_BATTLE, AI_COMBAT_MASTER); - Turns on rasing dead with Resurrection/Raise dead.
SetSpawnInCondition(AI_FLAG_OTHER_COMBAT_NO_CURING, AI_OTHER_COMBAT_MASTER); - This turns off all healing.
SetSpawnInCondition(AI_FLAG_OTHER_COMBAT_ONLY_CURE_SELF, AI_OTHER_COMBAT_MASTER); - This turns off ally healing.
SetSpawnInCondition(AI_FLAG_OTHER_COMBAT_ONLY_RESTORE_SELF, AI_OTHER_COMBAT_MASTER); - This turns off ally restoring (Remove/Restoration).
SetSpawnInCondition(AI_FLAG_OTHER_COMBAT_USE_BAD_HEALING_SPELLS, AI_OTHER_COMBAT_MASTER); - This forces all cure spells to be used, check readme.
SetAIInteger(SECONDS_BETWEEN_STATUS_CHECKS, 30); - Seconds between we loop everyone for bad effects like Fear/stun ETC. If not set, done each round.
SetSpawnInCondition(AI_FLAG_OTHER_COMBAT_GIVE_POTIONS_TO_HELP, AI_OTHER_COMBAT_MASTER); - ActionGiveItem standard healing potion's to allies who need them, if they possess them.
Skills - Explanation of Skills' settings.
SetSpawnInCondition(AI_FLAG_OTHER_COMBAT_NO or FORCE XXX, AI_OTHER_COMBAT_MASTER); - List of skill toggles.
Concentration - Extra concentration check explaining.
Leaders - Explanation of Leaders' settings.
SetSpawnInCondition(AI_FLAG_OTHER_COMBAT_GROUP_LEADER, AI_OTHER_COMBAT_MASTER); - Special leader. Can issuse some orders.
SetSpawnInCondition(AI_FLAG_OTHER_COMBAT_BOSS_MONSTER_SHOUT, AI_OTHER_COMBAT_MASTER); - Boss shout. 1 time use - calls all creatures in X meters (below) for battle!
SetAIInteger(AI_BOSS_MONSTER_SHOUT_RANGE, 60); - Meters for monsters to come when a boss shouts (with above setting).
Other (Other) - All SetSpawnInCondition settings are under AI_OTHER_MASTER
SetSpawnInCondition(AI_FLAG_OTHER_NO_CLEAR_ACTIONS_BEFORE_CONVERSATION, AI_OTHER_MASTER); - No ClearAllActions() before BeginConversation. May keep a creature sitting.
SetSpawnInCondition(AI_FLAG_OTHER_NO_POLYMORPHING, AI_OTHER_MASTER); - This will stop all polymorphing.
SetSpawnInCondition(AI_FLAG_OTHER_CHEAT_MORE_POTIONS, AI_OTHER_MASTER); - If at low HP, and no potion, create one.
SetAIConstant(AI_POLYMORPH_INTO, POLYMORPH_TYPE_WEREWOLF); - Polymorph to this type, when damaged (Once). Natural were creature.
AI_CreateRandomStats(-3, 3, 6); - Create (Effect-applied) random statistics.
-2, 2, -2, 2, -2, 2, -2, 2); - Create (Effect-applied) random HP, saves, AC.
SetSpawnInCondition(AI_FLAG_OTHER_RETURN_TO_SPAWN_LOCATION, AI_OTHER_MASTER); - This will store our spawn location, and then move back there after combat.
SetSpawnInCondition(AI_FLAG_OTHER_DONT_RESPOND_TO_EMOTES, AI_OTHER_MASTER); - This will ignore ALL chat by PC's (Enemies) who speak actions in Stars - *Bow*
SetSpawnInCondition(AI_FLAG_OTHER_DONT_SHOUT, AI_OTHER_MASTER); - Turns off all silent talking NPC's do to other NPC's.
SetSpawnInCondition(AI_FLAG_OTHER_SEARCH_IF_ENEMIES_NEAR, AI_OTHER_MASTER); - Move randomly closer to enemies in range set below.
SetAIInteger(AI_SEARCH_IF_ENEMIES_NEAR_RANGE, 25); - Range limit for "Search if enemies near".
SetSpawnInCondition(AI_FLAG_OTHER_ONLY_ATTACK_IF_ATTACKED, AI_OTHER_MASTER); - One shot. We won't instantly attack a creature we see.
SetAIInteger(AI_DOOR_INTELLIGENCE, 1); - 3 Special "What to do with Doors" settings. See readme.
SetSpawnInCondition(AI_FLAG_OTHER_REST_AFTER_COMBAT, AI_OTHER_MASTER); - When combat is over, creature rests.
SetSpawnInCondition(AI_FLAG_OTHER_REST_AFTER_COMBAT, AI_OTHER_MASTER); - Stops any use of "PlayVoiceChat". Use with Custom speakstrings.
Death settings
AI_SetDeathResRef("Resref Here"); - Creates a creature from the string set. Instantly destroys this creatures body on death.
SetAIConstant(AI_DEATH_VISUAL_EFFECT, VFX_FNF_IMPLOSION); - Fires this visual effect number instantly on death.
SetAIInteger(AI_CORPSE_DESTROY_TIME, 30); - Seconds before body gets finally destroyed.
SetSpawnInCondition(AI_FLAG_OTHER_USE_BIOWARE_LOOTING, AI_OTHER_MASTER); - Makes the death file use Bioware's cool SetLootable() instead of destroying the creature.
Lag and performance settings
SetSpawnInCondition(AI_FLAG_OTHER_LAG_NO_SPELLS, AI_OTHER_MASTER); - The creature doesn't ever cast spells (and never checks them)
SetSpawnInCondition(AI_FLAG_OTHER_LAG_EQUIP_MOST_DAMAGING, AI_OTHER_MASTER); - Uses EquipMostDamaging(), like Bioware code. No shield/second weapon equipped.
SetSpawnInCondition(AI_FLAG_OTHER_LAG_IGNORE_HEARTBEAT, AI_OTHER_MASTER); - Stops the heartbeat running (Except Pre-event).
SetSpawnInCondition(LAG_AI_LEVEL_NO_PC_OR_ENEMY_50M, AI_LEVEL_VERY_LOW); - Changes to this AI setting if there is no enemy or PC in 50M.
SetAIConstant(LAG_AI_LEVEL_YES_PC_OR_ENEMY_50M, AI_LEVEL_LOW); - Changes to this AI setting if there IS an enemy or PC in 50M.
SetAIConstant(LAG_AI_LEVEL_COMBAT, AI_LEVEL_NORMAL); - This OVERRIDES others. Only used when a creature is put into combat.
Shouts & User Defined Events - All SetSpawnInCondition settings (only UDE's have them) are under AI_UDE_MASTER
SetSpawnInCondition(AI_FLAG_UDE_XXX, AI_UDE_MASTER); - All user defined events are like this. Click to check specific names and special ones.
Shouts
AI_SetSpawnInSpeakArray(); - Check here for all AI_SetSpawnInSpeakValue()'s and AI_SetSpawnInSpeakArray()'s, and descriptions.
Bioware Default - All SetSpawnInCondition settings are under NW_GENERIC_MASTER
Waypoints - The flags that affect walking waypoints.
NwN Animations - The flags that affect any version of NwN animations.
SoU/Hordes Animations - The flags that affect only SoU/Hordes animations.
Treasure Generation - Bioware's treasure generation you can add.

Start of documentation

Back to Top
Required spawn options that should always be set

These are important settings, which if nothing else, should probably be included. The custom AI file also is an important setting, and should be put to use.

Back to Top
SetAIInteger(AI_INTELLIGENCE, 10);

This is the intelligence of the creature 1-10. Default to 10 if this is never set. Read the file in "Explainations" about this intelligence for more info.

Back to Top
SetAIInteger(AI_MORALE, 10);

This is a value, which is added to the morale check. Morale checks are at HD difference, + 20. (10 bonus averages this out to HD+10). They never flee at similar levels. It is a will save. Note: You can change the DC base of 20 to anything using the spawn value

SETTING THIS TO A MINUS VALUE MAKES THEM ALWAYS FLEE! :-o
Note 2: Commoners who have less then 10 levels, are set to -1 (IE always flee) during SetUpEndOfSpawn();

Back to Top
SetCustomAIFileName("CUSTOM_AI_FILE");

You can set a custom AI file to run instead of the normal AI file. This is pretty simple! You can easily use your own, and benifit from less calls of things you may not need. It can run scripts, for example, that use specific spells or abilities (EG: A goblin who only uses a sword, can just attack with a small script!). Please note: Almost all of the other spawn options, of course, never apply to the new AI file.

You can now override the default call, which will run the script "J_AI_DeterCombat", and will run a combat action.

If you SetCustomAIFileName, then this will be run IN ITS PLACE, therefore will make the AI run FASTER, depending on how big that file is, of course :-)

The AI scripts will run as normal otherwise. You can determine what target (If any!) was imputted, (EG: You have a hostile spell cast against you - it'd be the spellcaster) by using:

GetLocalObject(OBJECT_SELF, AI_TEMP_SET_TARGET);

To get the temp target - it is a good idea to delete it after you get it.

This is most useful to cause special boss combat, or make boring monsters with no abilities do things like "Attack nearest enemy". 1.3 should include some of these in its zip file.

Back to Top
Targeting - All SetSpawnInCondition settings are under AI_TARGETING_FLEE_MASTER

Starting note: The target is not changed if we have not attacked it for X amount of rounds, unless they are dead, or we can't see/hear them as appropriate

Melee

Must be within touch range, OR be nearby if we have tumble or spring attack. We bascially have a "Reach" that is used.

Any overriding settings, such as "only attack mages" only works if there is a mage in our reach. This stops them trying to get somewhere they are blocked from (oops!) or too many Attacks-of-oppotunity no creature would go through.

Ranged

It always uses range - by default, the futhest targets to the nearest ones. We only bother to set a ranged target if we have a bow, if we are not in HTH (and don't want to run) and so on.

You can set special cases for attacking a class type (EG: Spellcaster) over range checks, as always.

Spells

Range is one of the most important aspects. Range is used if nothing else is set. There are some, or a lot, that take thier values from the phisical attacking side, but some special ones, such as Mantals Present, and Save Totals (Total of Will, Fortitude and Reflex).

In the end, it basically narrows down what we should attack. So it might start off with 5 targets in our melee range, but we only want to attack 3 of them based on AC (Maybe the others have too high AC). So, at the end, a dice is rolled and we choose 1, 2 or 3 or attack :-)

Intellgence and Targeting:
- Intelligences of 3 or under will attempt to move out of melee and run to futher attackers.
- Intellgiences of 8+ who are attacking someone with many attackers already and can break off (are not being attacked) especially with tumble or spring attack, will try and attack other enemies.
- Intellgiences of 7+ will get thier own dispel target, rather then using the same one as the spell target. This means they might dispel a powerful mage, but still attack a better spell target
- Intelligence DOES NOT OVERRIDE THE TARGETING SETTINGS HERE APART FROM ABOVE! This might mean goblins attack the same as lich's! So use sperate spawn files, or use GetAbilityScore and set things with that.

Back to Top
AI_FLAG_TARGETING_LIKE_LOWER_XXX
OVERRIDE SETTINGS
These OVERRIDE the others.
NOTE : It will STILL use range for melee attacking, so it won't try and go 40 meters just to get to the lowest AC.
NOTE 2: These are not very good if you want the AI to not target the same creature all the time.
NOTE 3: An idea could be to set these randomly on a creature if you want such behaviour.
NOTE 4: If it doesn't give us something to attack (EG no mages) we attack normal set targets.
Note 5: It will only use SEEN enemies for this, else defaults to normal targeting settings.

AI_FLAG_TARGETING_LIKE_LOWER_HP - We only attack the lowest (seen) current HP.

AI_FLAG_TARGETING_LIKE_LOWER_AC - We only attack the lowest (seen) AC (as in 1.2).

AI_FLAG_TARGETING_LIKE_LOWER_HD - Target the lowest (seen) hit dice

AI_FLAG_TARGETING_LIKE_MAGE_CLASSES - We go straight for the nearest (seen) mage/sorceror.

AI_FLAG_TARGETING_LIKE_ARCHERS - We go for the nearest (seen) enemy with a ranged weapon equipped.

AI_FLAG_TARGETING_LIKE_PCS - We go for the nearest (seen) enemy PC.

Back to Top
AI_FAVOURED_ENEMY_XXX
Also override, these you should use constants under the "constants" tab on the right hand side.

AI_FAVOURED_ENEMY_RACE - The AI attacks the nearest enemy, seen, of this race. Use the RACIAL_* constants.

AI_FAVOURED_ENEMY_CLASS - The AI attacks the nearest enemy, seen, of this class. Use the CLASS_* constants.

Back to Top
Target Changing Explaintion
Target changing - this is imporant.

Bascially, we will get better targets (depending on the targeting amounts below this) if we re-target more often. But, it will obviously take up more CPU time to retarget every round. Therefore, you can set a random chance to retarget (it may still target the same person!) for cirtain types, and a general integer for the amount of rounds we had target X stored to attack (Even if we don't attack it, EG a ranged target, but we are in melee)

Back to Top
SetAIInteger(AI_MELEE_LAST_TO_NEW_TARGET_CHANCE, 20);

This is the % chance to reset our current melee target. It will Automatically check for new targets if the current enemy is dead, not seen, or we have sneak attack (Special case: always get new target).

Back to Top
SetAIInteger(AI_RANGED_LAST_TO_NEW_TARGET_CHANCE, 20);

This is the % chance to reset our current ranged target. It will Automatically check for new targets if the current enemy is dead, not seen, or we've got a nearby enemy attacking us in HTH (So we might not even set a ranged target!)

Back to Top
SetAIInteger(AI_SPELL_LAST_TO_NEW_TARGET_CHANCE, 20);

Bascially, this is a % chance that the spellcaster will choose a new target, if they have already got a good one (someone seen). This is ignored if we use "LONGER_RANGED_SPELLS_FIRST". Default is 20% and is checked each round.

Back to Top
Targeting Values Explaintion
Target changing - this is imporant.

We use the same values for ranged and melee things. This means, of course, space saved. It would mostly be the same for melee + ranged combat choosing for players/monster anyway. IE In this we use the same AC values (EG: max of 5, min of 2) for ranged and melee targeting.

If nothing is set below, it automatically uses range for melee (anything it can hit in its range) and uses range for spells (the closest targets) and ranged targets use range too (the nearest targets). In each case, it takes a minimum of 3 and a maximum of 6 to randomly choose between.

Note: The default On spawn which comes when installed sets up most of them to a degree of intelligence (misses out HP ones). It is a good idea to change values, however (even using d4, d6, d2 and so on for random amounts)

List (In order of how it is checked!):
- Has Spell Mantals - Used only for spell attacks (TARGETING_MANTALS)
- Range - Used only for ranged phisical attacks and spell attacks (TARGETING_RANGE) (Melee - Range is used to see what it can reach, and the MAX and MIN are taken to account)
- AC - Used only for phisical attacks (TARGETING_AC)
- Saving Throws - Used only for spell attacks (TARGETING_SAVES)
- Phisical Protections - Used for both spells and phisical attacks (TARGETING_PHISICALS)
- Base Attack Bonus - Used for both spells and phisical attacks (TARGETING_BAB)
- Hit Dice - Used for both spells and phisical attacks (TARGETING_HITDICE)
- HP Percent - Used for both spells and phisical attacks (TARGETING_HP_PERCENT)
- HP Current - Used for both spells and phisical attacks (TARGETING_HP_CURRENT)
- HP Maximum - Used for both spells and phisical attacks (TARGETING_HP_MAXIMUM)

Special: Filter for PC's filters for PC's :-)

Note 2: By default, it attacks things it sees with GetObjectSeen. Remember, that the creatures perception range alters this! :-D

Back to Top
AI_SetAITargetingValues(TARGETING_MANTALS, TARGET_LOWER, i1, i12);

Spell mantals are checked only for the spell target. Basically, it can either choose if they have any or have none. Uses GetHasSpellEffect.

- TARGET_HIGHER is that they DO have spell mantals
- TARGET_LOWER is the absense of spell mantals

  NOTE: If we have less then iMinimum, we do not add more from those who have mantals, unless we have 0 targets without mantals. (then we just ignore this, and fall through to anyone we can spell attack)

  Back to Top
  AI_SetAITargetingValues(TARGETING_RANGE, TARGET_HIGHER, i2, i9);

  Range is VERY important, and works well for an AI. It can target futher (TARGET_HIGHER) ranged targets, or nearer (TARGET_LOWER) All it does is work from the furthest, or nearests, and until it gets up to iMaximum.

  iMinimum does do something. If we get to iMinimum, we then make sure that all targets we add up to iMaximum are either under half or over half the range the closest/futhest target (respectivly) is. Melee uses only iMaximum, iMinimum. It ignores TARGET_HIGHER and TARGET_LOWER

  EG:

  4 targets, A(7M), B(12M), C(15M), D(20M) away. If we have minimum of 2, and target futher targets, then after D, then C targets, we make sure B, and A are over 50% of the distance to D, so over 10 meters. Therefore, we would ignore A if iMaximum was, for example, 6.

  Back to Top
  AI_SetAITargetingValues(TARGETING_AC, TARGET_LOWER, i2, i6);

  AC is for phiscial attacks - an important one for melee. We'd like to hit more often!

- It uses GetAC and checks targets.
- Basically, gets as many as possible to iMimaximum.
- It will (like range) use iMinimum to stop if we seem to get one target with much higher (or lower!) AC then another.

Back to Top
AI_SetAITargetingValues(TARGETING_SAVES, TARGET_LOWER, i2, i6);

Saves is almost the equivilant of the AC for phisical attacks. It is only used for spells, and totals GetWillSavingThrow, GetReflexSavingThrow and GetFortitudeSavingThrow.

Back to Top
AI_SetAITargetingValues(TARGETING_PHISICALS, TARGET_LOWER, i2, i6);

Phisical protections. This is checked using a loop of the targets effects, so it is recommended to have AC, mantals or range targeting ON to use.

- We target the lowest (or absense of!) Damage Reduction if TARGET_LOWER
- We target the ones with the highest damage reduction if TARGET_HIGHER

With iMinimum, we (like previous examples) do not target a really high phisical protection target, if we reach iMinimum, if it comapares to the others. (EG: Got 5, 5, 10 DR, iMin = 3, and a 30 pops up, ignore the 30) NOTE: Used for mages too (IE: Phisical targets are hard to kill with melee attacks!)

Back to Top
AI_SetAITargetingValues(TARGETING_BAB, TARGET_LOWER, i1, i4);

Base attack bonus. Used for spells and phisical attacks.

- Checks BAB with GetBaseAttackBonus.
- HIGHER/LOWER are the respective obvious Higher BAB and lower BAB.

This is useful, because fighters have the higher BAB, and mages the lower. It is also simple :-D And is obviously those who will hit us more, or less. NOTE: Doesn't take into account ability modifiers

Back to Top
AI_SetAITargetingValues(TARGETING_HITDICE, TARGET_LOWER, i1, i3);

Hit dice - how powerful in levels the enemy is. This is a good way to target the most powerful, or least powerful, people in an enemy group. Used for spells and phisical attacks.

Back to Top
AI_SetAITargetingValues(TARGETING_HP_PERCENT, TARGET_LOWER, i1, i3);
AI_SetAITargetingValues(TARGETING_HP_CURRENT, TARGET_LOWER, i1, i3);
AI_SetAITargetingValues(TARGETING_HP_MAXIMUM, TARGET_LOWER, i1, i3);

The HP's are the last thing to choose a target. They are generally good for specific targeting of lower, lower % or lower maximum HP's. Oh, of course you can be evil and target the higher current/percents so harm does more damage, or target the lowest current for the Power Word series or worse - the current HP's so they concentrate on those closest to dying! NOTE: Default installation doesn't use these.

Back to Top
Fleeing - All SetSpawnInCondition settings are under AI_TARGETING_FLEE_MASTER

These give greater control over fleeing.

On Default, If break (WILL, DC EnemyHD + 20 and take MoraleBonus above), we will either run to valid allies, stay and fight (already at allies, or none) OR if low intelligence, randomly run (until we are away).

The default that the AI checks a will save is when our HD is lower than thier HD - 2. You can set this as well.

Leaders inspire morale bonuses equal to an extra 2x the persons default morale value!

The monsters also gain group morale bonuses - extra for a mass of creatures. It is up to a maximum of half our hit dice, or 6, whichever is higher. The value is 1 per ally creature we know of. It can be totally turned off below.

NOTE: All monsters will flee. For animals and things, it is best to set FEARLESS. This is because some animals may flee, and it is up to you (Mr module builder) to set which ones.

Intellgence and Generic:
- If we have 3 or under intellgience, and we ever fail a morale check, we will run away from our attackee's - even if we don't have any allies to run to

Back to Top
SetSpawnInCondition(AI_FLAG_FLEEING_FEARLESS, AI_TARGETING_FLEE_MASTER);

This will make the creature never flee at all. This ONLY AFFECTS MORALE! Here, uncommented by default. :-) Note: This is set if we are Immune by item/feat/fearless race, at the end of spawn.

Back to Top
SetSpawnInCondition(AI_FLAG_FLEEING_NEVER_FIGHT_IMPOSSIBLE_ODDS, AI_TARGETING_FLEE_MASTER);

This will make the creature never fight against impossible odds. A massive (8) difference in HD/CR will make them run off, if there are valid near allies.

Back to Top
SetSpawnInCondition(AI_FLAG_FLEEING_TURN_OFF_GROUP_MORALE, AI_TARGETING_FLEE_MASTER);

This turns OFF any sort of group morale bonuses. Morale bonuses VIA. Groups are 1 per ally seen (to a maximum of 6). This is useful OFF for people who think thier allies are untrustworthy and may run in a group, and ON for all other circumstances - especially for low Hit Dice/will save creatures such as Goblins.

Back to Top
SetAIInteger(AMOUNT_OF_HD_DIFFERENCE_TO_CHECK, -2);

This is the amount of HD difference we will check our morale. This means, when the enemy HD take that value is over our HD, we check morale (our = 10, thier = 13, means check, if it is set to -2.) Default is -2. Useful to stop some creatures from running away from similar-toughness enemies.

Back to Top
SetAIInteger(BASE_MORALE_SAVE, 20);

The base DC of the will save is This (20) + HD difference between us and our melee target - Morale (set above) - Group Morale Modification. Setting this lower, means an easier save. I would personally make this based on thier will save, if you wanted figters (low will) to be comparable to clerics (very high will), Using GetWillSavingThrow.

Back to Top
SetAIInteger(HP_PERCENT_TO_CHECK_AT, 80);

This is the the percent that the creature will check the morale status It will default to 80, if under 1 or over 100. For very low hit point creatures, or ones you want to check fleeing whatever precentage, this should be set to 100. As there are delays between checks of more then 6 seconds (and a lot can happen in 6 seconds) improved fleeing may happen if it is set to 100. This doens't affect "Never fight impossible odds" however, and there are some circumstances it wil be ignored unless the setting below is set to TRUE. (See below for what the settings are)

Back to Top
SetSpawnInCondition(AI_FLAG_FLEEING_NO_OVERRIDING_HP_AMOUNT, AI_TARGETING_FLEE_MASTER);

Morale may make them run off even if they are not at X% HP, as above.

- If the enemy is very strong, we do a will save (8 HD over us)
- If we have a morerate morale penalty (Set by massive damage/many deaths around us)
- We are alone

  This setting, however, will turn these checks OFF.

  Back to Top
  SetAIInteger(AI_DAMAGE_AT_ONCE_FOR_MORALE_PENALTY, GetMaxHitPoints()/6);

  When damaged, if the amount we are damaged is over this amount (default to Max Hit Points / 6) then we apply the penalty below to our morale.

  Back to Top
  SetAIInteger(AI_DAMAGE_AT_ONCE_PENALTY, 6);

  Penalty for the above, set for some time to negativly affect morale. This is set for a total of 600 seconds, or basically a long time, and can only be set once. It can be used to adversly affect the creature being damaged by a huge amount of damage at once (and fleeing on the basis of having massive damage done to them).

  Back to Top
  SetSpawnInCondition(AI_FLAG_FLEEING_FLEE_TO_NEAREST_NONE_SEEN, AI_TARGETING_FLEE_MASTER);

  This is a simple thing, and will, instead of moving to the best group of allies, will just move to the nearest non-seen and non-heard ally. This may help resources...(but is pretty dumb behaviour), if fleeing is activated.

  Back to Top
  SetSpawnInCondition(AI_FLAG_FLEEING_FLEE_TO_OBJECT, AI_TARGETING_FLEE_MASTER);

  This will flee to an object, with the correct tag. ONLY if they are not there already, of course. Gets nearest (but if not valid, any one). This will get any object - placeables, monsters, well - anything! Also, waypoints, so this is easily useful. Can be dynamic: Instead of a single tag (EG: "MY_BOSS") it could be GetTag(OBJECT_SELF) + "_FLEE" or something. This is set using the object below.

  Ideas: Fleeing to thier leader, fleeing to a cage or a door (can be another area).

  Back to Top
  SetLocalString(OBJECT_SELF, AI_FLEE_OBJECT, "BOSS_TAG_OR_WHATEVER");

  This is the object's tag to flee to, for the above setting. A good use is a boss monster, or a location such as "Barracks". If this is not valid, they will not flee.

  Back to Top
  Combat (Fighters) - All SetSpawnInCondition settings are under AI_COMBAT_MASTER

  Some fighter behaviour can be used to set how fighters basically fight. This means melee and ranged combat. A good idea, to get variations in style, is to have random settings for some of these (Especially better at hand to hand, archer attacking, and range weapon range).

  There are very useful settings here, especially the "No go for the kill" which will stop them knocking out dying PC's, and stop them from attempting to finnish off very low current hit point enemies (only on with higher intelligence anyway).

  Back to Top
  SetSpawnInCondition(AI_FLAG_COMBAT_PICK_UP_DISARMED_WEAPONS, AI_COMBAT_MASTER);

  This will make the creature pick up any disarmed weapons on the ground, when he has become disarmed. Turn off for slightly better performance (in the fact they won't move to the disarmed weapons and pick them up). This is never automatic. Note also that if they are set to "Diarmable" and thier weapon is not "Droppable", then any disarmed weapons are lost.

  Back to Top
  SetAIInteger(AI_RANGED_WEAPON_RANGE, 3);

  This is the range at which they put away thier ranged weapon, and go HTH. It is normally intelligence based, 5 for under 5 INT, 3 for 5+ INT. It is in meters. 1 tile = 10x10M. If set, this overrides what the AI thinks it should be. Normally the lower (to about 3) is better for the AI, because of the problems with too many people running into melee and not being able to reach. Also note, that the AI takes into account creature size and reach automatically (adding as appropriate), because distances between creatures are taken from thier centres.

  Back to Top
  SetSpawnInCondition(AI_FLAG_COMBAT_BETTER_AT_HAND_TO_HAND, AI_COMBAT_MASTER);

  IE TANK! Well, if we do have ranged weapons (EG giants with slings for "rocks"), but are bloody tougher in HTH. It guesses if it is better to run forwards. Always will move to HTH if the chosen enemy has a ranged weapon armed, or is a mage, else % based on range.

  Back to Top
  SetSpawnInCondition(AI_FLAG_COMBAT_ARCHER_ATTACKING, AI_COMBAT_MASTER);

  This is quite specifically for archers - ones good at using bows. They will, quite often (with support from others) retreat to use bows much better (IE no AOO). they perfere ranged combat, and only draw HTH weapons (If they have any, else they use thier bow) in the end. Note: Below, you can set it to ALWAYs move back, if an archer.

  Back to Top
  SetSpawnInCondition(AI_FLAG_COMBAT_ARCHER_ALWAYS_MOVE_BACK, AI_COMBAT_MASTER);

  This is not quite the above, it sets so that the creature, if it has a ranged weapon, will move away from attackers and shoot, ALWAYS, regardless of allies. IF caught in a cornor, it may equip HTH weapons but it is a slight chance (so it may get chopped to pieces in a cornor until the roll is sucessful to attack in HTH).

  Back to Top
  SetSpawnInCondition(AI_FLAG_COMBAT_ARCHER_ALWAYS_USE_BOW, AI_COMBAT_MASTER);

  This forces the creature to always use thier bow, in hand-to-hand, or whereever. Careful when using this - point blank shot, or one of the above behaviours, is recommended.

  Back to Top
  SetSpawnInCondition(AI_FLAG_COMBAT_NO_GO_FOR_THE_KILL, AI_COMBAT_MASTER);

  This will turn off, even if they wouldn't or would do (intelligence dependant) an attempt to kill of a dying PC OR someone with really low HP or sleep. This is useful if ON because of the dying factor - IE PC's dying. - Need 9+ Intelligence to do this anyway.

  Back to Top
  Combat (Spellcasters) - All SetSpawnInCondition settings are under AI_COMBAT_MASTER

  Spellcaster AI has been improved significantly. As well as adding all new spells, now spellcasters more randomly choose spells from the same level (EG: they may choose not to cast magic missile, and cast negative energy ray instead).

  There are also options here for counterspelling, fast buffing, Cheat cast spells, spell triggers dispelling, long ranged spells first, immunity toggles, and AOE settings.

  Note: You cannot use any of the spell triggers unless you have inported the spell trigger creature, under Special -> 5 of the custom creature pallet.

  Back to Top
  SetSpawnInCondition(AI_FLAG_COMBAT_LONGER_RANGED_SPELLS_FIRST, AI_COMBAT_MASTER);

  Hey - this is good, but can be widly ineffective sometimes. We look to attack with spells in order, against people in the spells' ranges' Spells are ranged from: 40, then 20, 8, and then 2.5. It is most ineffective when a creature has "Harm" or similar powerful short ranged spells, but perferes to stay back and use "searing light" or similar. Make sure they have the best spells for this behaviour.

  This is cirtainly best used in circumstances when you have problems with mages running forwards to cast "Vampiric touch" (touch, 2.25M range) when "Magic Missile" (long, 40M range) is a better idea. Also, any circumstance when there are many creatures, or a boss creature who wants to stay behind his goons, it is a good idea to have this on (or randomly on).

  Back to Top
  SetSpawnInCondition(AI_FLAG_COMBAT_FLAG_FAST_BUFF_ENEMY, AI_COMBAT_MASTER);

  When an enemy comes in 40M, they will use some of thier spells to buff before combat (Or react and cast at least), as if prepared. This uses spells memorised.

  Back to Top
  SetSpawnInCondition(AI_FLAG_COMBAT_SUMMON_FAMILIAR, AI_COMBAT_MASTER);

  This will make the creature summon thier respective familiars/animal companions. It will be a nameless bat for the familiar, and badger for the druid, and without a hakpack, this cannot be changed.

  Back to Top
  SetSpawnInCondition(AI_FLAG_COMBAT_COUNTER_SPELL_ARCANE, AI_COMBAT_MASTER);

  This will make the creature counterspell mages specifically. It, as its top prioritory (if it has dispell spells) ActionCounterspell the nearest mage, if they have spells (dispells) (can be sorceror as well, it targets). Below is a clerical one...

  Back to Top
  SetSpawnInCondition(AI_FLAG_COMBAT_COUNTER_SPELL_DIVINE, AI_COMBAT_MASTER);

  This will make the creature counterspell clerics specifically. It, as its nearly top prioritory (after mages, if set) (if it has dispell spells) ActionCounterspell the nearest cleric, if they have spells (can be druid as well, it targets). Above is the mage one.

  Back to Top
  SetSpawnInCondition(AI_FLAG_COMBAT_COUNTER_SPELL_ONLY_IN_GROUP, AI_COMBAT_MASTER);

  This will make the creature only counterspell if it has a group to help it - as the PC's are usually buffed, of course, and the mage could just shoot or attack normally (especially if multiclassed). I recommmend this, otherwise a single mage may just stand there, doing nothing, if an enemy caster (if valid) doesn't cast anything! It makes the caster require 5 or more allies (including self).

  Back to Top
  SetSpawnInCondition(AI_FLAG_COMBAT_DISPEL_MAGES_MORE, AI_COMBAT_MASTER);

  Checks for mages seen, and perferes to remove thier protections. Note: If this is not set, we dispel our spell target according to the things in the targeting section.

  Back to Top
  SetSpawnInCondition(AI_FLAG_COMBAT_DISPEL_IN_ORDER, AI_COMBAT_MASTER);

  Basically, this will cast dispells at a target, only to remove specific ones. It instead of normally dispelling anything (any good spell basically) it will dispell spell shields, globes, which will inhibit pure spellcasters, but not bother about stoneskins, protection froms, and others till lower down the list (of spells we check). for example, we WILL cast greater dispelling if they have a mantal, but NOT if they have premonition, until later on, perhaps AFTER wail of the banshee and high-level-spells.

  Back to Top
  SetSpawnInCondition(AI_FLAG_COMBAT_NEVER_HIT_ALLIES, AI_COMBAT_MASTER);

  This will make AOE spells never target anywhere if an ally would get hit Makes sure that AOE spells (and hopefully persistant ones like wall of fire) don't harm allies. Good if you know it is a problem! There are some specific AOE spell things to set below. This overrides them.

  Back to Top
  SetSpawnInCondition(AI_FLAG_COMBAT_AOE_DONT_MIND_IF_THEY_SURVIVE, AI_COMBAT_MASTER);

  This will, check the HP of the target. If they fail thier save, and still survive the blast, then they will be ignored in finding the best target. If is is a status AOE, it is still affected (as they will probably die sooner if it is caster).

  Back to Top
  SetAIInteger(AI_AOE_ALLIES_LOWEST_IN_AOE, 3);

  If not set, it is always 3. It will target AOE spells at the biggest group of enemies, always looking for the lowest ally in the blast as well (as long as this blast contains the most enemies). If, at any time, a target has X (default 3) or more allies in the blast, that target is ignored. This lessness major ally hurting.

  Note: Neutrals are ignored in such procedings (as they ain't friends!). Remember: Allies who are immune, or always save (depends on spell) are not counted anyway.

  Back to Top
  SetAIInteger(AI_AOE_HD_DIFFERENCE, -8);

  Is not used if not set (IE cannot use 0 for this), it is -8. If it is set (eg, to -8) it will ignore all allies that are that many HD difference. It is so that scum much lower then us are ignored (IE cannon fodder) and are too weak compared to us, so can be sacrificed.

  Default: -8 off our HD. Used in conjunction with the things above. Note: Cannot be 0 or above, and cannot be below -30.

  Back to Top
  SetSpawnInCondition(AI_FLAG_COMBAT_SINGLE_TARGETING, AI_COMBAT_MASTER);

  This will use single target spells over all AOE target spells, at similar levels. It will force it to use Magic Missile over Bruning Hands for instance, but Web will be used over magic missile (level 2 vs. level 1).

  If neither this nor the MANY version is set, the AI will use more single spells with lower amounts of enemies, and more AOE spells with greater amounts of enemies. It only slightly differs behaviour normally.

  Back to Top
  SetSpawnInCondition(AI_FLAG_COMBAT_MANY_TARGETING, AI_COMBAT_MASTER);

  This will force the caster to use, or try and use, AOE spells over all single spells. If this is on, we always try and fire an AOE spell over a single spell - at the same level. For example, fireball over Flame Arrow.

  If neither this nor the SINGLE version is set, the AI will use more single spells with lower amounts of enemies, and more AOE spells with greater amounts of enemies. It only slightly differs behaviour normally.

  Back to Top
  SetSpawnInCondition(AI_FLAG_COMBAT_IMPROVED_INSTANT_DEATH_SPELLS, AI_COMBAT_MASTER);

  This will make the creature cheat by using some instant death spells on low save enemies Its not that powerful at all, really, but might as well be toggelable. Example: Casting finger of Death at someone who can never save against it.

  Back to Top
  SetSpawnInCondition(AI_FLAG_COMBAT_IMPROVED_SUMMON_TARGETING, AI_COMBAT_MASTER);

  This will make the mage search out a decent target to summon a creature at. It should be thier ranged target, spell target or last hostile actor if they are within 20M, and then casts it at a location between the caster and the enemy. If this is off, it saves a very little bit of CPU use and also can't summon across gaps/fences etc.

  Back to Top
  SetSpawnInCondition(AI_FLAG_COMBAT_IMPROVED_IMMUNITY_CHECKING, AI_COMBAT_MASTER);

  There are checks for immunities (death, fear ETC). Take out if you don't want them to happen (but they will cast Power Word Stun against those immune to it, or try and slow those who cannot be and so forth.). This is actually quite a lot of cheating, in ONE way, but, as PC's do easily check "Description" screens for this information, and also know what spells have been cast (EG: Death Ward) then, basically, NPC's are also doing this.

- This is automatically on for intelligence 7+

Back to Top
SetSpawnInCondition(AI_FLAG_COMBAT_IMPROVED_SPECIFIC_SPELL_IMMUNITY, AI_COMBAT_MASTER);

This checks, for most spells, if they have cirtain spells (IE Globes) that stop cirtain levels of spells. It also checks immunty by level for NPC's which use my AI (It is set On Spawn, via. checking the hides). This is not very comprehensive, but if off, will mean they cast fireball against those with Major Globes on, and so forth.

- This is automatically on for intelligence 9+

Back to Top
SetSpawnInCondition(AI_FLAG_COMBAT_MORE_ALLY_BUFFING_SPELLS, AI_COMBAT_MASTER);

This will make the caster buff more allies - or, in fact, use spells to buff allies which they might have not used before.

- Normally, when invsibible, they cast buffs until they drop :-D
- Without this, some buffs are cast at close allies still.
- With this on, buffs are cast against allies and ourself high in the casting list.
- We move to longer ranged allies (we run around to targets more) if this is set.

Back to Top
SetSpawnInCondition(AI_FLAG_COMBAT_USE_ALL_POTIONS, AI_COMBAT_MASTER);

When set, this will use all potions (not healing ones!) that the creature does not have the effects if already. This can be used as a backup, incase you experience problems with normal item useage.

Back to Top
SetAICheatCastSpells();

If this is set, then we cast a spell from 6 set random one, using a d6, at the end of all other spells. Only recommended for non-dragons, and mages (Sorcerors or Wizards) who will get down to level 1 spells on thier BAB checks.

- You cans set the same spell to more then one slot,
- No immunities are checked - NOT even !GetHasSpellEffect.
- Hostile spells only. Not recommended to add AOE spells in.
- Good for bosses who seem to run out of spells to quickly.

Back to Top
SetSpellTrigger();

When this is set, correctly, it will relase spells under cirtain circumstances, defensive only, against the caster. This is vrey cool for high level casters. It is not perfect (as the checks run each heartbeat, 6 seconds, therefore may not fire exactly as wanted).

The explaination (when double clicked on it) explains most of it:

This will set a spell trigger up. Under cirtain conditions, spells are released and cast on the caster.
Once fired, a spell trigger is only reset by resting. Only 1 of each max is fired at once!
- sType - is specifically:
  SPELLTRIGGER_DAMAGED_AT_PERCENT - When damaged, the trigger fires. Use iValue for the %. One at a time is fired.
  SPELLTRIGGER_IMMOBILE - Fired when held/paralyzed/sleeping ETC. One at a time is fired.
  SPELLTRIGGER_NOT_GOT_FIRST_SPELL - Makes sure !GetHasSpellEffect(iSpell1) already, then fires. Checks all in this category each round (first one fires!)
  SPELLTRIGGER_START_OF_COMBAT - Triggered always, at the start of DetermineCombatRound.
- iNumber - can be 1-9, in sequential order of when you want them to fire.
- iValue - is only required with DAMAGED_AT_PERCENT.
- iSpellX - Cannot be 0. It should only really be defensive spells.
void SetSpellTrigger(string sType, int iValue, int iNumber, int iSpell1, int iSpell2 = 0, int iSpell3 = 0, int iSpell4 = 0, int iSpell5 = 0, int iSpell6 = 0, int iSpell7 = 0, int iSpell8 = 0, int iSpell9 = 0)

Back to Top
Combat (Dragons) - All SetSpawnInCondition settings are under AI_COMBAT_MASTER

I have a fondness for dragons - in NWN they are deprived of many abilities. Here I have added a few that help them become more terrifying! Rooooarrrr!

I've improved thier attack and combat AI (taking into account of size for knockdown does a LOT!). Spells are better used, to a degree, taking into account they are heavily built for hand to hand combat.

Please, oh please, check out the flying too. This is, to a degree, one of thier best abilities, jumping over people they don't like, and buffeting things at the location they fly from and the location they fly too.

None of these abilties (Flying, Wing Buffet) are overpowered, especially compared to thier Dragon's Breath. Simply put, they are good additions. The flying is also very much for any creature with wings - they looks good, I assure you. Try it out!

Back to Top
SetSpawnInCondition(AI_FLAG_COMBAT_NO_WING_BUFFET, AI_COMBAT_MASTER);

This turns all wing buffet uses off. Wing buffet is a special Dragon-only ability (must be of huge size too) and will knock down all large-or-smaller creatures around them, as they flap thier wings:

The dragon will launch into the air, knockdown all opponents who fail a Reflex Save and then land on one of those opponents doing damage up to a maximum of the Dragons HD + 10.

The ability is used randomly between this and its Dragons Breath. Not totally random, but it does use a counter (Below)

Back to Top
SetAIInteger(AI_DRAGON_FREQUENCY_OF_BUFFET, 3);

This is the amount of rounds (defualt of 3, must be over 0, not over 10) in between each wing buffet attack, or the minimum rounds between each one at least (taking into account we have a counter for breath). Note: Dragons Breath is a similar used skill, and has a seperate counter, this is used AFTER any counted breaths, and only if the dragon can wing buffet in the first place!

Back to Top
SetAIInteger(AI_DRAGON_FREQUENCY_OF_BREATH, 3);

This is the amount of rounds (defualt of 3, must be over 0, not over 10) in between each Breath Weapon attack. This is used by dragons, and is any breath weapon they possess. Basically, it alternates between buffets (if on) and breath weapon uses. Note: If counter for these are both at the amount required, breaths are used first.

Note this! From the 3E rules: "Using a breath weapon is a standard action. Once a dragon breathes, it can’t breathe again until 1d4 rounds later." So choose the amount carefully.

Back to Top
SetSpawnInCondition(AI_FLAG_COMBAT_FLYING, AI_COMBAT_MASTER);

This turns on Flying. This is not strickly for dragons, but anything with wings! It looks alright for all winged creatures, they disappear up and reappear next to a target they want to attack, with a few visuals. Huge creatures push off and come down with so much force, that they do damage and knockdown like Wing Buffet.

- This applies similar visual effects to Wing Buffet, but will move between 2 places, with a flying delay. This is done if they are 8M or more away from thier melee target.
- Only huge creatures have knockdown and damage effects
- Can be turned on for any dragon/flying creature/winged creature.
- It will STOP the use of missile weapons as they fly into melee range all the time!!!

Back to Top
Combat Other (Healers) - All SetSpawnInCondition settings are under AI_OTHER_COMBAT_MASTER

Clerical AI is changed from 1.0/1/2. Not exactly anything too complicated - however, Undead healing has been added, as well as many variables to determine what exactly they should do - as in %'s needed to heal others, and so forth.

You can set up some more clerical behaviours, when to heal ourselfs and so on, here. Also, usfully, the cooldown times for status effect healing and things like that.

There are some parts for non-clerics/druids as well. Things like "potion passing" can sometimes tip the battle by passing some potions around the battlefield.

Back to Top
SetSpawnInCondition(AI_FLAG_OTHER_COMBAT_HEAL_AT_PERCENT_NOT_AMOUNT, AI_OTHER_COMBAT_MASTER);

This actually does not as much as you may thing. Healing, when used, will check how much a healing spell heals. For example, say we had cure ciriticals, but not 35HP damage yet, but say, 50% damage, we would not use it. This setting turns off this check, and basically uses it anyway. There is a cutoff point of 30% anyway, but use this if you have problems with the AI an healing. :-)

Back to Top
SetAIInteger(AI_HEALING_US_PERCENT, 50);

This is used to check what amount we have to be damaged to consider healing. Should be 20+, and under 90 or so. Heal and Mass heal will be only cast at lower HP anyway, but still must be damaged by this % to trigger it.

Back to Top
SetAIInteger(AI_HEALING_ALLIES_PERCENT, 60);

It will not heal allies until they are at this % or lower HP. We always heal ourselves before any allies, and choose the closest ally with this amount of HP % damage - but, if it finds someone VERY damaged, it will choose them over a closer ally who is damaged. Leaders are healed first, if they are under this % HP. It should be greater then our own healing value if we want to heal allies, and lower if we want to leave it later to heal allies.

Back to Top
SetSpawnInCondition(AI_FLAG_OTHER_COMBAT_WILL_RAISE_ALLIES_IN_BATTLE, AI_OTHER_COMBAT_MASTER);

This will let the creature use the raising spells (Resurrection, Raise Dead) in battle. They check for dead friends, and cast the spells on them. This is why there is a normal 30 second time out for corpses. Leaders are always checked first, so bosses will be raised before other allies. Turning this off (by not having it On Spawn) is recommended for any sort of custom corpse system.

Back to Top
SetSpawnInCondition(AI_FLAG_OTHER_COMBAT_NO_CURING, AI_OTHER_COMBAT_MASTER);

This turns off all healing. No healing spells (Cure Wounds) will be cast at all.

Back to Top
SetSpawnInCondition(AI_FLAG_OTHER_COMBAT_ONLY_CURE_SELF, AI_OTHER_COMBAT_MASTER);

This turns off ally healing. No healing spells (Cure Wounds) will be cast at allies, or leaders. Basically, we will only check ourselves for damage.

Back to Top
SetSpawnInCondition(AI_FLAG_OTHER_COMBAT_ONLY_RESTORE_SELF, AI_OTHER_COMBAT_MASTER);

This turns off ally restoring (Remove/Restoration). Really, it removes ALL status checks, as only ability damage and so forth would be healed by us, as when stunned, we can't cast spells to remove our own stun! (And so forth).

Back to Top
SetSpawnInCondition(AI_FLAG_OTHER_COMBAT_USE_BAD_HEALING_SPELLS, AI_OTHER_COMBAT_MASTER);

When a cleric casts healing spells, usually AOO, disruption and oppotunity costs (instead of doing something else) makes some rubbish healing spells worthless in battle. Put this on to make them use them but don't expect amazing results. Basically, Cure Critical Wounds will ALWAYS be cast (at whatever level and HP amount) but lower ones will always have a check - so Cure Minor Wounds will have almost no chance of being cast by a level 20 cleric, except when the enemies are not around, say, at the end of combat.

Back to Top
SetAIInteger(SECONDS_BETWEEN_STATUS_CHECKS, 30);

Seconds between we loop everyone for bad effects like Fear/stun ETC. If not set, done each round. This can be turned on for lag reducing, or AI-worsening effect. The looping is not bad, especially not as bad as Bioware's.

Back to Top
SetSpawnInCondition(AI_FLAG_OTHER_COMBAT_GIVE_POTIONS_TO_HELP, AI_OTHER_COMBAT_MASTER);

his will, if they have any (Standard healing potions! unless you add them into the actual AI file (search for "NW_IT_MPOTION001" for the correct part) and then they'd work) healing potions, they will, if close, pass them to people who need them. It uses ActionGiveItem so may move to target. There are extra speakstrings for these events. It also never passes to those who do not/cannot use potions.

Back to Top
Combat Other (Skills) - All SetSpawnInCondition settings are under AI_OTHER_COMBAT_MASTER

Skills are a part of fighting - EG Taunt. These are mainly on/off switches. A creature will *may* use it if they are not set to "NO_" for the skill.

The skills are always set to NO_ if they do not possess the skill, under SetUpEndOfSpawn. Also NOTE: Hide and Stealth are NOT used in waypoint walking (basically, there is a reason! really!).

Hide is force used/not used with shadowdancer classes, and at the very start of combat if a rogue percieves a creature (and so is not officially in "combat", so they vanish). The ON switch also means it is never turned off when searching around at the end of combat (but rather turned on ready for battle)

Search is used when searching at the end of battle, and if there are hidden things around. It is usually off in combat - for the fact creatures need to run around! This has no effect on weather they search when walking thier waypoints, and also, elves with Keen Sight obviously don't need to have this set (and are always searching!).

Concentration checks are probably the most important here. Mainly, leaving these alone will not hamper the AI much, but turning them off may be to an advantage (EG: If you see them using it too much and it not working, remember to tell me as well) or disadvantage/worse AI (EG: Using taunt in HTH to lower AC, turning it off stops it being used at all)

Back to Top
SetSpawnInCondition(AI_FLAG_OTHER_COMBAT_NO or FORCE XXX, AI_OTHER_COMBAT_MASTER);

List of NO (Off) and FORCE (Always on) skill toggles. Remember, if not NO, then it MAY turn it on automatically. Note that this in no way interferes with hiding or non-combat routines.

- AI_FLAG_OTHER_COMBAT_NO_PICKPOCKETING
- AI_FLAG_OTHER_COMBAT_FORCE_PICKPOCKETING
- AI_FLAG_OTHER_COMBAT_NO_TAUNTING
- AI_FLAG_OTHER_COMBAT_FORCE_TAUNTING
- AI_FLAG_OTHER_COMBAT_NO_EMPATHY
- AI_FLAG_OTHER_COMBAT_FORCE_EMPATHY
- AI_FLAG_OTHER_COMBAT_NO_HIDING
- AI_FLAG_OTHER_COMBAT_FORCE_HIDING
- AI_FLAG_OTHER_COMBAT_NO_OPENING_LOCKED_DOORS
- AI_FLAG_OTHER_COMBAT_FORCE_OPENING_LOCKED_DOORS
- AI_FLAG_OTHER_COMBAT_NO_USING_HEALING_KITS
- AI_FLAG_OTHER_COMBAT_NO_PARRYING
- AI_FLAG_OTHER_COMBAT_FORCE_PARRYING
- AI_FLAG_OTHER_COMBAT_NO_SEARCH
- AI_FLAG_OTHER_COMBAT_FORCE_SEARCH
- AI_FLAG_OTHER_COMBAT_NO_CONCENTRATION
- AI_FLAG_OTHER_COMBAT_FORCE_CONCENTRATION

Back to Top
Concentration Checks

Concentration checks.

- These are done by spellcasters to move back if there is an ally nearby, and they think they will benifit (there are melee attackers)
- They don't if not at 3+ Intelligence, or not a mage, so below can override this.
- More chance with tumble or spring attack to move back.
- This will not be done with Ranged Spells on, as they may have wanted to move closer.
- It is checked if they will cast a spell.

Back to Top
Combat Other (Leaders) - All SetSpawnInCondition settings are under AI_OTHER_COMBAT_MASTER

Leaders and/or bosses are an integral part of the D&D world. Normally, in NwN you fight them (sadly!) so I've made some things to make them more respectable (AI wise). I would create a differnt OnSpawn file for all your bosses (or one, and select things using tags, if you can script it).

NOTE: Leader behaviours, I expect, don't work too well if there are more than a few giving orders, as they try and give out same orders again and again. It is scripted to not give same orders (or react to them again) in short timespans, but not large ones. One leader per group is more then enough.

Also, using the other behaviours can make them use thier abilities and things a bit better - I always put my lich's to use long range spells first, because otherwise they'll get into HTH with casting "Wail of the banshee" for example. See below for what leader status does to a creature.

Back to Top
SetSpawnInCondition(AI_FLAG_OTHER_COMBAT_GROUP_LEADER, AI_OTHER_COMBAT_MASTER);

Leaders are special NPC's, or not, but they are more "intelligent" as a rule - they issue some commands (detailed below) and also inspire morale in those who see them. It is best they is never more then 1 in a group or dungeon, but there of course can be.

Information about what exactly the group leader flag does:

- Adds morale - thier HD's worth, onto allies who can see them.
- If they think it is wise, against great odds, they will make all thier command flee at once (a mass retreat)
- They will call many creatures into combat with thier Boss shout - if set - be it alarms being raised, a message spell from a caster, or generally shouting and ordering! It is only done once (for performance issuses mainly)
- A leader may choose to make allies target "Creature X". This means, especially in lower intelligence beings, that they try and kill one target who is dangerous, or just a pest. Doesn't bring perfect results, but who knows?
- A leader may force an ally to run for help - IE be sent as a runner. This runner specailly shouts to allies to come and help the battle - or any remains of it, and will run off to groups of allies trying to bring (prepared) help.
- Leaders are always raised first if a high-level cleric knows they are dead
- Leaders are always healed first, dispite range or near-death status, as long as they are under the % each cleric needs to heal allies.

Back to Top
SetSpawnInCondition(AI_FLAG_OTHER_COMBAT_BOSS_MONSTER_SHOUT, AI_OTHER_COMBAT_MASTER);

Boss shout. 1 time use - and only used if they are a "group leader", which calls all creatures in X meters (below) for battle! It is a sure-fire way to make sure, in a large dungeon, PC's take more care then to rush a boss creature. In some situations it doesn't work to well, be sure to test.

Back to Top
SetAIInteger(AI_BOSS_MONSTER_SHOUT_RANGE, 60);

Limit, in Meters, that the range of a boss shout is. It brings any non-fighting creatures to the "Leader" when he sees an enemy, and therefore will do combat. Basically, 10M = 1 NwN tile, so, putting to about 180 will get all monsters in any sized area, but will cause a lot of lag. 60 is still quite enough, although less means less creatures will come (obviously). Creatures must be spawned for this to work, of course.

Back to Top
Other - All SetSpawnInCondition settings are under AI_OTHER_MASTER

Generally, anything else the AI doesn't categorise specifically as combat-orientated! Death, Cheat-potions and polymorph all have mentions. Generally, these are least-used, but control useful toggles.

Back to Top
SetSpawnInCondition(AI_FLAG_OTHER_NO_CLEAR_ACTIONS_BEFORE_CONVERSATION, AI_OTHER_MASTER);

Basically, this will not clear all actions before a conversation. It *should* keep the person sitting down, but needs proper testing. Also, if moving they may still be moving (which may cancel the conversation) so be careful.

Back to Top
SetSpawnInCondition(AI_FLAG_OTHER_NO_POLYMORPHING, AI_OTHER_MASTER);

This makes it so NPC's will never ever use thier polymorph feats, spells and abilities. Obviously, removing them is better! but this is the easy option to make no NPC with spells like Polymorph or feats like Wildshape use them instead of attacking normally. Usually, polymorphing is only done once all spells are used. For a shifter, make sure they have limited spells so they polymorph into thier good shapes early.

Back to Top
SetSpawnInCondition(AI_FLAG_OTHER_CHEAT_MORE_POTIONS, AI_OTHER_MASTER);

Once the NPC thinks it needs healing, and it fails to heal itself using any spells or exsisting potions, then it will create a cure critical wounds potion and should use it straight away. It only has a 25% chance of working each round, so isn't "Always create, always drink" but a good thing to make some creatures a little harder without much effort.

Back to Top
SetAIConstant(AI_POLYMORPH_INTO, POLYMORPH_TYPE_WEREWOLF);

When a creature is damaged, then this polymorph (if set at all) will be applied to them. Use POLYMORPH_TYPE_* constants, or look at "Polymorph.2da" file in the source NwN directory. This is a very similar thing to the Wererats on the pallet, and useful for natural were-creature's. The effect cannot be dispelled, and only is fired once, so they instantly become, basically, melee-only creatures.

Back to Top
AI_CreateRandomStats(-3, 3, 6);

This will affect 3 (by default random stats. They will rise or go down by the amount, randomly You can make the numbers anything. The first is the LOWEST and the second the HIGHEST. WARNING: They are supernatural effects. Force resting by a DM removes them, as does Dying and Death. Dispelling should not affect them, although Restoration will (unless edited).

Back to Top
AI_CreateRandomOther(-2, 2, -2, 2, -2, 2, -2, 2);

As above function, but used for HP, Saves and AC, in that order (see exact specifications for function when double-clicked on, in help box). These are also Effect-applied, and so are removed on death, and when rested.

Back to Top
SetSpawnInCondition(AI_FLAG_OTHER_RETURN_TO_SPAWN_LOCATION, AI_OTHER_MASTER);

This will store our spawn location, and then move back there after combat. Will turn off if there are waypoints, but should not be used with waypoints anyway!...no need. It is set in SetUpEndOfSpawn. This is basically a good way to get creatures to "re-group" especially when using Animations (with which, this work best). Also, this saves on a ton of waypoints, or objects, or whatever!

Back to Top
SetSpawnInCondition(AI_FLAG_OTHER_DONT_RESPOND_TO_EMOTES, AI_OTHER_MASTER);

This will ignore ALL chat by PC's (Enemies) who speak actions in Stars - a PC saying, without quotes, "*Bows*", will be ignored, while "Lets attack them" will be picked up, and likely the NPC will come around and try and find them. Of course, stars are not everyones way of showing actions, but is the one I (and others I know) use, and should be recommended as it covers both sides. If abused, don't have this on (as abusion of the AI not hearing you speaking and not knowing your there is a bit wrong!)

Back to Top
SetSpawnInCondition(AI_FLAG_OTHER_DONT_SHOUT, AI_OTHER_MASTER);

This turns off all silent talking (which you may see if logged in as an admin/start a server in the DM client, and turn on DebugMode) which the NPC's use to talk and warn each other of aspects of the game, mainly "Come help me, I've been attacked!!!!!!" (thats 6 exclamation marks!, this is important, and really shouldn't be turned off). This can be turned off if you want to lower lag, and test it and like it (I don't recommend it).

Back to Top
SetSpawnInCondition(AI_FLAG_OTHER_SEARCH_IF_ENEMIES_NEAR, AI_OTHER_MASTER);

On heartbeat, similar to the Henchmen AI (Which, mind you, we all steal off each other... :-) - Just take a peek at Bioware's AI) will move randomly closer to any enemy PC's in a range set below (default of 25M). It is random, and makes them a little harder to surprise - and this is easier to set then any sort of patrols (although systematic patrols are better for getting PC's surprised!).

Back to Top
SetAIInteger(AI_SEARCH_IF_ENEMIES_NEAR_RANGE, 25);

Range limit for "Search if enemies near". If set to a large amount, they will start searching from futher away (gradually, randomly, getting nearer and nearer the nearest enemy PC location). Shorter is good if you want them to wander around cornors once the PC's are very near.

Back to Top
SetSpawnInCondition(AI_FLAG_OTHER_ONLY_ATTACK_IF_ATTACKED, AI_OTHER_MASTER);

This makes the OnPerception not attack enemies the creature see's, until they are attacked (or, of course, get a normal AOO), via. spells, if hostile, phisical or otherwise will react to all hostiles. BUT we won't automatically get them when we see them...

Back to Top
SetAIInteger(AI_DOOR_INTELLIGENCE, 1);

This will determine what to do with blocking doors. Default is 0 or not set, which means intelligence will take the key, and they may unlock, untrap, knock or bash it.

- 1 = Always bashes the door (does not check for plot flag, or if it can be opened). Very suitable for low intelligence Animals.
- 2 = Never open any doors (none! Just stops there) Very suitable for animals who wouldn't/couldn't bash stuff (as they have no hands)
- 3 = Never attempts to open (bash or anything) plot doors. Stops plot-related doors being attacked, which is pointless.

Back to Top
SetSpawnInCondition(AI_FLAG_OTHER_REST_AFTER_COMBAT, AI_OTHER_MASTER);

This is a VERY useful tool. When combat is over (when there are no more things to attack, we can see or hear) we will rest after searching for enemies, and so replenish health, spells and so on (as long as an enemy hasn't just hidden themselves). It doesn't reset any settings like "Boss shout" (which is one shot) but resting does replenish spell triggers.

Back to Top
SetSpawnInCondition(AI_FLAG_OTHER_NO_PLAYING_VOICE_CHAT, AI_OTHER_MASTER);

This stops all uses of the function "PlayVoiceChat" for combat taunting. It is a good idea to turn this on if you have any custom speakstrings for battle set below, if it is off, then it may be that both will happen at once - IE, one that fires "Howaboutye!!" and one that is their normal voice, "Attack them!".

Back to Top
AI_SetDeathResRef("Resref Here");

Add in a resref, and OnDeath, when they are dealt a final blow, will create creatre X from the resref. Resrefs only, else badgers will be popping up! Idea: Use the spawn in setting AI_DEATH_VISUAL_EFFECT, to make it fancy. This is mearly used to save editing an important file, and will destroy the body instantly if this is set.

Back to Top
SetAIConstant(AI_DEATH_VISUAL_EFFECT, VFX_FNF_IMPLOSION);

This will set the visual effect, X, to be used instantly (so only Fire and Forget ones or instant ones should be used). It is fired ONCE every time the death script is fired. Only constants with FNF and IMP should be used - and FNF ones usually work 100% of the time. Remember to test. A useful use would be a chunky VFX, like blood splattering around when they are finally killed, or some gate effect for planar creatures who teleport back to their home plane.

Back to Top
SetAIInteger(AI_CORPSE_DESTROY_TIME, 30);

This is the amount of time, in seconds, that it will take for a corpse to dissapear. High means a cleric may raise it in time, lower for faster loot. Default = 30. This number is not used if the standard corpse system isn't on - IE, the setting below is set. If it is higher and Bioware Looting is on, this is the delay from which it becomes un-lootable, to becoming lootable (the corpse always stays there until Bioware's corpse stuff destroys it).

Back to Top
SetSpawnInCondition(AI_FLAG_OTHER_TURN_OFF_CORPSES, AI_OTHER_MASTER);

This turns off the corpses, IE, the ones that usually stay at death via. my use of SetDestroyable - but it means that there is no raising possible, and it don't look as nice. This should be used if you have any custom corpse settings, or don't want the bodies to linger at all when they die. Bioware looting toggle below cannot be used if this is on.

Custom Corpses and Experience has an actual place in the death file "NW_C2_DEFAULT7", and so do not just place it anywhere if you want the normal corpse destroy stuff to work. The section in the death file also will only fire once per creature, so no multiple awards. A system for non-repeating XP messages is also included.

Back to Top
SetSpawnInCondition(AI_FLAG_OTHER_USE_BIOWARE_LOOTING, AI_OTHER_MASTER);

When set, Bioware's SetLootable will be used, with the correct SetDestroyable, but only when it is going to fade away after the determined time above. If corpses are turned off from the above setting, then it cannot be used. The SetLootable is set during the end of the spawn section, and "J_AI_DestroySelf" handles the final SetDestroyable.

Back to Top
SetSpawnInCondition(AI_FLAG_OTHER_LAG_NO_ITEMS, AI_OTHER_MASTER);

The creature doesn't check for, or use any items that cast spells. It won't do much if they don't have potions of stoneskin, or wands of magic missile, but can help in cases (it removes the checks for validness entirely) - and is especially useful if you want the items not to be used, but to drop as loot.

Back to Top
SetSpawnInCondition(AI_FLAG_OTHER_LAG_NO_SPELLS, AI_OTHER_MASTER);

This will miss out the ENTIRE section of spells, which will (in the worse case) perform 300~ GetHasSpell checks. NO spells are ever cast. Note: No spells will be checked for if, OnSpawn, it has none in the talent categories :-)

Note: It basically only makes the heal, and ranged/melee fight.

Back to Top
SetSpawnInCondition(AI_FLAG_OTHER_LAG_NO_LISTENING, AI_OTHER_MASTER);

The creature doesn't have SetListening() set. Turns of the basic listening for shouts. The creature will NEVER hear ANYTHING said, and the conversation script will never fire, except if a PC wants to talk to the monster. It will help lag, as many shouts are portayed through battle, making the script fire often. However! It will remove a LOT of the workings, and is to be used at your own risk - it will basically make them deaf and not respond to allies being attacked or leaders.

Back to Top
SetSpawnInCondition(AI_FLAG_OTHER_LAG_EQUIP_MOST_DAMAGING, AI_OTHER_MASTER);

This will make the creature use the default rules for equipping weapons. Expect 2 handed weapons, no deul wielding, and no shields with this. This should help lag, but not much as EquipMostDamaging is called each round. Using with only 1 weapon (and no shield/second weapon) is fine, of course.

Back to Top
SetSpawnInCondition(AI_FLAG_OTHER_LAG_NO_CURING_ALLIES, AI_OTHER_MASTER);

This will stop checks for allies ailments. It may reduce lag as each person with any ailment curing spells checks all allies nearby for effects. This is good to turn on if they don't have the spells anyway (Such as Freedom, etc).

Back to Top
SetSpawnInCondition(AI_FLAG_OTHER_LAG_IGNORE_HEARTBEAT, AI_OTHER_MASTER);

This will turn off the heartbeat prematurely. It won't do much except stop a few more checks for animations and so forth. The AI things the AI needs on heartbeat (EG: Fleeing) are still catered for, and the Pre-heartbeat event will fire, but that is it. Most useful if no animations, no anything special is being used (no fast buffing and so on, see NW_C2_Default1).

Back to Top
SetSpawnInCondition(AI_FLAG_OTHER_LAG_TARGET_NEAREST_ENEMY, AI_OTHER_MASTER);

This will force the AI to target the nearest seen enemy, and so limits the loops done in the AI, IE ignoring the now-normal targeting system. If no nearest seen is found, it will still do its normal loops, and find something to attack in its LOS or move somewhere. Expect the AI to cirtainly react worse to people, but it will work good for Goblins/Animals and other low intelligence people, as well as saving several object loops for all enemies to see which to attack. Use carefully, like I said!

Back to Top
SetAIConstant(LAG_AI_LEVEL_NO_PC_OR_ENEMY_50M, AI_LEVEL_VERY_LOW);

Uses AI_LEVEL_* constants - Changes to this AI setting if there is no enemy or PC in 50M, and so should possibly be the lowest (the one suggested) and should really not be used without setting the other 2, or at least 1, unless they never fight, cannot fight, or always run. Can even be used to set to NORMAL level to walk waypoints when a PC is not in the area.

Back to Top
SetAIConstant(LAG_AI_LEVEL_YES_PC_OR_ENEMY_50M, AI_LEVEL_LOW);

Uses AI_LEVEL_* constants - Changes to this AI setting if there IS an enemy or PC in 50M. This should be likely LOW (as stated by Bioware) or even keeping to VERY_LOW, as they are not in combat (although this might affect animations). Cirtainly be careful when using these.

Back to Top
SetAIConstant(LAG_AI_LEVEL_COMBAT, AI_LEVEL_LOW);

Uses AI_LEVEL_* constants - This OVERRIDES others. Only used when a creature is put into combat, and so the other 2 are ignored. Obviously, to change it back to anything but this setting, the other 2 must be used! It never resets to default at the end of combat, although that can be added via. user defined events or additional heartbeat editing.

Shouts & User Defined Events - All SetSpawnInCondition settings (only UDE's have them) are under AI_UDE_MASTER

The user defined events, set up to fire here, with new "Start combat attack" and "End Combat Attack" events. New "Pre" events. Use these to optionally stop a script from firing under cirtain circumstances as well! (Read nw_c2_defaultd or j_ai_onuserdef) (User Defined Event = UDE)

Back to Top
SetSpawnInCondition(AI_FLAG_UDE_XXX, AI_UDE_MASTER);

All these Spawn Conditions fire the specific event, which you can look at innw_c2_defaultd or j_ai_onuserdef. Pre-events are new, and fire before the rest of the script (unless the AI is off!) and can even stop the rest of the script and the AI firing. The events are all in the spawn file, and the constants list, prefixed with AI_FLAG_UDE_

- AI_FLAG_UDE_HEARTBEAT_EVENT - 1001
- AI_FLAG_UDE_HEARTBEAT_PRE_EVENT - 1021
- AI_FLAG_UDE_PERCIEVE_EVENT - 1002
- AI_FLAG_UDE_PERCIEVE_PRE_EVENT - 1022
- AI_FLAG_UDE_END_COMBAT_ROUND_EVENT - 1003
- AI_FLAG_UDE_END_COMBAT_ROUND_PRE_EVENT - 1023
- AI_FLAG_UDE_ON_DIALOGUE_EVENT - 1004
- AI_FLAG_UDE_ON_DIALOGUE_PRE_EVENT - 1024
- AI_FLAG_UDE_ATTACK_EVENT - 1005
- AI_FLAG_UDE_ATTACK_PRE_EVENT - 1025
- AI_FLAG_UDE_DAMAGED_EVENT - 1006
- AI_FLAG_UDE_DAMAGED_PRE_EVENT - 1026
- AI_FLAG_UDE_DEATH_EVENT - 1007
- AI_FLAG_UDE_DEATH_PRE_EVENT - 1027
- AI_FLAG_UDE_DISTURBED_EVENT - 1008
- AI_FLAG_UDE_DISTURBED_PRE_EVENT - 1028
- AI_FLAG_UDE_RESTED_EVENT - 1009
- AI_FLAG_UDE_RESTED_PRE_EVENT - 1029
- AI_FLAG_UDE_SPELL_CAST_AT_EVENT - 1011
- AI_FLAG_UDE_SPELL_CAST_AT_PRE_EVENT - 1031
- AI_FLAG_UDE_ON_BLOCKED_EVENT - 1015
- AI_FLAG_UDE_ON_BLOCKED_PRE_EVENT - 1035
- AI_FLAG_UDE_COMBAT_ACTION_EVENT - 1012 - New: Fires when we have finnished all combat actions. It does fire wether we do an action or not - IE after we have done a combat round. More consistant then the End Combat Round event.
- AI_FLAG_UDE_COMBAT_ACTION_PRE_EVENT - 1032 - This fires at the start of DetermineCombatRound() *IF they can do an action*. Can be easily used to override a combat action they might normally take to do a special action, like, cast a cheat-spell (say, stoneskin)
- AI_FLAG_UDE_DAMAGED_AT_1_HP - 1014 - Fires when we are damaged, and are at 1 HP. This should be used for immortal creatures to turn off immortaility or perhaps start a conversation. It should fire more then once, because it just stops the NPC going below 1HP, not not taking damage. Fires at the end (just before the actual end-damaged event) of the file.

Shouts

If you wish, there are strings that can be said on cirtain events. There is the ability to use a conversation item (special combat conversation, at the top) but these may allow randomness, and ones for more special events. The combat ones (TALK_ON_COMBAT_ROUND_XXX) actually delays the shout by a random amount - they won't all be spoken at once, while the event-driven ones are.

This is good for making creatures of different types speak things they would say like a goblin saying "Groala!" instead of "Attack!". Setting up random ones for the PC's

Replace SetSpawnInSpeakValue with SetSpawnInStringRandomValue for randomness, which is always a good idea and is mainly what is below.

Back to Top
AI_SetSpawnInSpeakArray();

The different spawn in arrays - speakstring, done by a simple SetLocalString and said by SpeakString. These are excelent for adding more life to battles, as orcs scream in orcish (for all them language people out there) or just good common, like "RAAWAWWWRRRHHHHGGGG!!!". There are quite a few, detailed below, with what they do. All can be set with AI_SetSpawnInSpeakArray() and AI_SetSpawnInSpeakValue().

AI_TALK_ON_CONVERSATION. This should be set to 100% chance of being said. It is spoken On Conversation, Replacing BeginConversation(). This is used to REPLACE the BeginConversation line when a PC or DM talks to an NPC. they will face them, and say this line. Note: Also, it plays the talking animation, and 3 seconds later, starts wandering again.

AI_TALK_ON_MORALE_BREAK. This will be spoken when the creatures morale breaks and they move to another group of allies. Set to 100% to alway say. Normally, shouts like "No more!", "I'm outta here!" and "Catch me if you can!" might be appropriate. They are essentially retreating, not fleeing as in panic - so organised creatures might sound a retreat (Leaders can force all NPC's to flee who hear them) or at least not sound as pathetic as my ideas.

AI_TALK_ON_CANNOT_RUN. This will be spoken when the creatures morale breaks, but they cannot find someone to run to (may be alone, or no allies far enough away) AND that they have 4 or more intelligence. At 3 or less, they panic and run away - using the below shout. Panicing is obviously not as organised, wise or intelligent, and is one way Intelligence determines what to do. Suitable shouts could be "Never give up! Never surrender!", "I've no where to run, so make my day!" and "RRRAAAAA!!!" - that is, they know they want to run, but are cornored/against a bigger enemy.

AI_TALK_ON_STUPID_RUN. This will be spoken when the creatures morale breaks, but they cannot find someone to run to (may be alone, or no allies far enough away) AND that they have 3 or less intelligence. This is panic - they just run away from the enemy as fast as possible. Things like "Ahhhhgggg! NO MORE! Run!!" and "Help! No more!" could be suitable - they will then panic for the rest of the battle. Note: This is also used when a creature's morale is 0 or less, like herbivour animals or commoners.

AI_TALK_ON_COMBAT_ROUND_EQUAL, AI_TALK_ON_COMBAT_ROUND_THEM_OVER_US, AI_TALK_ON_COMBAT_ROUND_US_OVER_THEM. These are basically the combat taunts. Very simple and effective at changing due to circumstances - which is why there are 3 sets. All must be set to have them work correctly (even if they are the same, only copied). It is a small %, and a d1000 is rolled for it, so using a value 100 will mean they fire a taunt/speakstring 10% of the time, each combat round. Also note that this has a small delay of up to 1.5 seconds from choosing one to be said - this means a mass of these are never said exactly at the same time. Using the nearest enemy, we determine what state they are compared to us:

- EQUAL - Thier HD is within 4HD of us (EG: Us 10HD, them 10HD, or perhaps us 12HD, them 9HD)
- THEM_OVER_US - They have 5+ levels over us. (EG: Us 10HD, them 15HD or more)
- US_OVER_THEM - We have 5+ levels over them. (EG: Us 10HD, them 5HD or less)

AI_TALK_ON_TAUNT. This is said when the creature uses the taunt skill. By default, nothing is said (for some reason) when the skill is used, or if it is, then overriding it with this isn't hard. Anyway, a decent taunt is always a good idea, especially when they have the skill! Taunts like "You're going down!", "No need to think, let my blade do it for you!" and "Time to meet your death!" might be appropriate. The % should really be 100 to have it said each time they use their skill.

AI_TALK_ON_PERCIEVE_ENEMY. This is said when they percieve an enemy, and go into combat with them. If we just see a new one, while in combat, nothing happens. This is useful for the initial taunt, or whatever. Suitable ones might be "Stand and fight, lawbreaker!", "Don't run from the law!", "I have my orders!", "I am ready for violence!", "CHARGE!" and "Time you died!" (some, obviously, are for lawmen, others for anyone).

AI_TALK_ON_DAMAGED. When we are damaged by an enemy , this is said - damage event obviously happens more frequently then most other events, because damage kills a creature! Remember this, and set the % low. Also note that this can overlap with PHISICALLY_ATTACKED and HOSTILE_SPELL taunts, as both of them could damage the target at the same time. I'd either set the % lower for one or the other, or only use one or the other (IE: Only use this ON_DAMAGED, or only use the other 2).

AI_TALK_ON_PHISICALLY_ATTACKED. When an enemy attacker attacks the creature with a melee or ranged weapon, this fires. Of course, at higher levels, this can be 2-4 attacks each round, so a lower % could mean it is said just as much as a higher % at lower levels. Taunts like "Hah! Mear weapons won't defeat me!", "Pah! You cannot defeat me with such rubbish!" and "Come on! Hit me harder!" or just "That was meant to hurt??!" for the idiot NPC's.

AI_TALK_ON_HOSTILE_SPELL_CAST_AT. When an enemy attacker attacks the creature with a hostile spell, of any sort, this will fire up. Unlike the Phisically Attacked talk, normally no more then 2 spells can be cast by any one mage - on the other hand, higher levels have more area-of-effect spells, and so Area-of-effect's will cause this to be set of at a phonominal rate. Such taunts like "No one spell will stop me!", "Is that all you have!?!" and "Urg...spell no gud!" might be appropriate. You must script anything more specific then "hostile spell hit us", as this doesn't check immunity, if we saved (which is impossible to check) or what type of spell it is (damaging etc) or even if it was a monster ability.

AI_TALK_ON_DEATH. This should really be set to a 100% chance, and is also always said whenever a creature dies - so doesn't care who killed them! Random ones can be set (the default spawn is 1 value), and some ideas could be: "Agggggg!", "Its only a flesh wound!" and "*and there was much rejoicing*" (sorry, I like that film...)

AI_TALK_WE_PASS_POTION. This is a special one, This will be spoken when the creature passes a potion to an ally, and fires each time. Also note that if they can't use potions, none are thrown. Oh, and it only uses 1 value, to save randomly picking one, so only use AI_SetSpawnInSpeakValue(). AssignCommand is used to make the catcher of the potion say the string below. "Here! Catch!" is one of the better things to use.

AI_TALK_WE_GOT_POTION. This will be spoken when the creature gets passed a potion. Note: it will be AssignCommand and using THIS creatures array. It will always be said. It only uses 1 value, so use AI_SetSpawnInSpeakValue(). This value should only be used if you can be sure it will look fine - IE: Not having a human pass an orc a potion, and the orc then saying "Thanks, mate!" back! "Got it!" is another good one to put.

AI_TALK_ON_LEADER_SEND_RUNNER. When a leader sends someone to go get help, this is said, and may overlap with any other speakstrings that round, however, that is normally not a problem. Use this to see the leader issue the order correctly, because otherwise it is silent and things just happen behind the scene. "Quickly! We need help!" is a good one to use.

AI_TALK_ON_LEADER_ATTACK_TARGET. When the leader thinks target X should be attacked, it will say this. "Help attack this target!" is a good one to use, and this might be said more then once per battle. Orders might be a good one to use, or a roar or something (most of my made up ones are for humanoid creatures).

Back to Top
Waypoint's

Bioware's waypoint system is automatic, to a degree, and working using the heartbeat event (or just On Spawn in some cases). Either way, some standard settings apply to all versions of NwN, and here is some information about them:

- NW_FLAG_STEALTH - If the NPC has the Hide skill they will go into stealth mode while doing WalkWayPoints().
- NW_FLAG_SEARCH - If the NPC has the Search skill they will go into search mode while doing WalkWayPoints().
- NW_FLAG_DAY_NIGHT_POSTING - Separate the NPC's waypoints into day & night. See "nw_i0_generic" or "x0_i0_walkway" as appropriate.

Back to Top
NwN Animations

The Animation system has 2 flags that can be set for any version of NwN to turn on animations. These are them 2, basically, a "Immobile" set of animations and a "Mobile" one. The extra options offered in SoU + Hordes are below and expand what these do, however, one of these must be one for any animations to work, of course.

- NW_FLAG_IMMOBILE_AMBIENT_ANIMATIONS - This will cause an NPC to use common animations it possesses. Basically, it won't use ActionRandomWalk, and just talk to nearby creatures and move about a little (with SoU/Hordes)
- NW_FLAG_AMBIENT_ANIMATIONS - Same as above, except NPC will wander randomly around the area. This makes them spread out and do stuff. Uses ActionRandomWalk a lot more, and does do most of the animations that would happen above (EG: Talking)

Back to Top
SoU/Hordes Animations

These are optional ones, and might only be in SoU and Hordes expansion packs. They add optional components to the above behaviours, although they do nothing by themselves (IE: A setting above must be uncommented for these to actually work). You must use SetAnimationCondition() for these.

- NW_ANIM_FLAG_IS_CIVILIZED - Civilized creatures interact with placeables in their area that have the tag "NW_INTERACTIVE" and "talk" to each other. Humanoid races are civilized by default, so only set this flag for monster races that you want to behave the same way.
- NW_ANIM_FLAG_CHATTER - Civilized creatures with this flag set will randomly use a few voicechats. It's a good idea to avoid putting this on multiple creatures using the same voiceset.
- NW_ANIM_FLAG_IS_MOBILE_CLOSE_RANGE - Creatures with _immobile_ ambient animations can have this flag set to make them mobile in a close range. They will never leave their immediate area, but will move around in it, frequently returning to their starting point. Note that creatures spawned inside interior areas that contain a waypoint with one of the tags "NW_HOME", "NW_TAVERN", "NW_SHOP" will automatically have this condition set.

Back to Top
Treasure Generation

By default, the NwN treasure system is OFF for any version of my AI. You must uncomment the appropriate include file and line to make it work.

- CTG_GenerateNPCTreasure() - To use the SoU treasure generating facility, uncomment this and the "x0_i0_treasure" line at the top. See the file "x0_i0_treasure" for info.
- GenerateNPCTreasure() - Use this to create a small amount of treasure on the creature from the NwN (orignal) treasure scripts. You need the line with "nw_o2_coninclude" uncommented to use this.

Script:

    /************************ [On Spawn] *******************************************
        Filename: j_ai_onspawn or nw_c2_default9
    ************************* [On Spawn] *******************************************
        This file contains options that will determine some AI behaviour, and a lot
        of toggles for turning things on/off. A big read, but might be worthwhile.

        The documentation is actually fully in the readme files, under the name
        "On Spawn.html", under "AI File Explanations".

        The order of the options:

        - Important Spawn Settings                   N/A
        - Targeting & Fleeing                       (AI_TARGETING_FLEE_MASTER)
        - Fighting & Spells                         (AI_COMBAT_MASTER)
        - Other Combat - Healing, Skills & Bosses   (AI_OTHER_COMBAT_MASTER)
        - Other - Death corpses, minor things       (AI_OTHER_MASTER)
        - User Defined                              (AI_UDE_MASTER)
        - Shouts                                     N/A
        - Default Bioware settings (WP's, Anims)    (NW_GENERIC_MASTER)

        The OnSpawn file is a settings file. These things are set onto a creature, to
        define cirtain actions. If more than one creature has this script, they all
        use the settings, unless If/Else statements are used somehow. There is also
        the process of setting any spells/feats availible, and hiding and walk waypoints
        are started.

        Other stuff:
        - Targeting is imporant :-D
        - If you delete this script, there is a template for the On Spawn file
          in the zip it came in, for use in the "scripttemplate" directory.
    ************************* [History] ********************************************
        Note: I have removed:
        - Default "Teleporting" and exit/return (this seemed bugged anyway, or useless)
        - Spawn in animation. This can be, of course, re-added.
        - Day/night posting. This is uneeded, with a changed walk waypoints that does it automatically.

        Changes from 1.0-1.2:
        - All constants names are changed, I am afraid.
        - Added Set/Delete/GetAIInteger/Constant/Object. This makes sure that the AI
          doesn't ever interfere with other things - it pre-fixes all stored things
          with AI_INTEGER_ (and so on)
    ************************* [Workings] *******************************************
        Note: You can do without all the comments (it may be that you don't want
        the extra KB it adds or something, although it does not at all slow down a module)
        so as long as you have these at the end:

        AI_SetUpEndOfSpawn();
        DelayCommand(2.0, SpawnWalkWayPoints());

        Oh, and the include file (Below, "j_inc_spawnin") must be at the top like
        here. Also recommended is the AI_INTELLIGENCE and AI_MORALE being set (if
        not using custom AI).
    ************************* [Arguments] ******************************************
        Arguments: GetIsEncounterCreature
    ************************* [On Spawn] ******************************************/

    // Treasure Includes - See end of spawn for uncomment options.

    //#include "nw_o2_coninclude"
    // Uncomment this if you want default NwN Treasure - Uses line "GenerateNPCTreasure()" at the end of spawn.
    // - This generates random things from the default pallet based on the creatures level + race

    //#include "x0_i0_treasure"
    // Uncomment this if you want the SoU Treasure - Uses line "CTG_GenerateNPCTreasure()" at the end of spawn.
    // - This will spawn treasure based on chests placed in the module. See "x0_i0_treasure" for more information.

    // This is required for all spawn in options!
    #include "j_inc_spawnin"

    void main()
    {
    /************************ [Important Spawn Settings] **************************/
        SetAIInteger(AI_INTELLIGENCE, 10);
            // Intelligence value of the creauture. Can be 1-10, read readme's for help.
        SetAIInteger(AI_MORALE, 10);
            // Will save (See readme). Remember: -1 or below means they always flee.
        //SetCustomAIFileName("CUSTOM_AI_FILE");
            // Sets our custom AI file. Really, only animation settings will apply when this is set.
            // - Can sort actions against a imputted target (EG: On Percieved enemy) by
            //   "GetLocalObject(OBJECT_SELF, "AI_TEMP_SET_TARGET");"
    /************************ [Important Spawn Settings] **************************/

    /************************ [Targeting] ******************************************
        All targeting settings.
    ************************* [Targeting] *****************************************/
        //SetSpawnInCondition(AI_FLAG_TARGETING_LIKE_LOWER_HP, AI_TARGETING_FLEE_MASTER);
            // We only attack the lowest current HP.
        //SetSpawnInCondition(AI_FLAG_TARGETING_LIKE_LOWER_AC, AI_TARGETING_FLEE_MASTER);
            // We only attack the lowest AC (as in 1.2).
        //SetSpawnInCondition(AI_FLAG_TARGETING_LIKE_LOWER_HD, AI_TARGETING_FLEE_MASTER);
            // Target the lowest hit dice
        //SetSpawnInCondition(AI_FLAG_TARGETING_LIKE_MAGE_CLASSES, AI_TARGETING_FLEE_MASTER);
            // We go straight for mages/sorcerors. Nearest one.
        //SetSpawnInCondition(AI_FLAG_TARGETING_LIKE_ARCHERS, AI_TARGETING_FLEE_MASTER);
            // We go for the nearest enemy with a ranged weapon equipped.
        //SetSpawnInCondition(AI_FLAG_TARGETING_LIKE_PCS, AI_TARGETING_FLEE_MASTER);
            // We go for the nearest seen PC enemy.

        //SetAIConstant(AI_FAVOURED_ENEMY_RACE, RACIAL_TYPE_HUMAN);
            // The AI attacks the nearest enemy, seen, of this race. Use the RACIAL_* constants.
        //SetAIConstant(AI_FAVOURED_ENEMY_CLASS, CLASS_TYPE_BARD);
            // The AI attacks the nearest enemy, seen, of this class. Use the CLASS_* constants.

        // Target changing - see readme for info.
        //SetAIInteger(AI_MAX_TURNS_TO_ATTACK_ONE_TARGET, 6);
            // Maximum rounds to attack the current target, before re-checking.
        // % Chance to re-set each target type each round (Could result in current target still)
        //SetAIInteger(AI_MELEE_LAST_TO_NEW_TARGET_CHANCE, 20);
        //SetAIInteger(AI_RANGED_LAST_TO_NEW_TARGET_CHANCE, 20);
        //SetAIInteger(AI_SPELL_LAST_TO_NEW_TARGET_CHANCE, 20);

        // We only target PC's if there are any in range if this is set
        //SetSpawnInCondition(AI_FLAG_TARGETING_FILTER_FOR_PC_TARGETS, AI_TARGETING_FLEE_MASTER);

        // Main explanation of AI_SetAITargetingValues, see the AI readme (spawn file)
        // - Remember, uncommenting one will just ignore it (so will never check target's
        //   AC without TARGETING_AC on)

        AI_SetAITargetingValues(TARGETING_MANTALS, TARGET_LOWER, i1, i12);
            // Spell mantals are checked only for the spell target. Either Absense of or got any.
        AI_SetAITargetingValues(TARGETING_RANGE, TARGET_HIGHER, i2, i9);
            // Range - very imporant! Basis for all ranged/spell attacks.
        AI_SetAITargetingValues(TARGETING_AC, TARGET_LOWER, i2, i6);
            // AC is used for all phisical attacks. Lower targets lower (By default).
        AI_SetAITargetingValues(TARGETING_SAVES, TARGET_LOWER, i2, i4);
            // Used for spell attacks. Saves are sorta a AC versus spells.

        // Phisical protections. Used by spells, ranged and melee.
        // Jasperre - simple check if we are a fighter (hit lower phisicals) or a
        //            mage (attack higher!)
        if(GetBaseAttackBonus(OBJECT_SELF) > ((GetHitDice(OBJECT_SELF)/2) + 1))
        {
            // Fighter/Clerics (It is over a mages BAB + 1 (IE 0.5 BAB/Level) target lower
            AI_SetAITargetingValues(TARGETING_PHISICALS, TARGET_LOWER, i2, i6);
        }
        else
        {
            // Mages target higher (so dispel/elemental attack those who fighters
            // cannot hit as much). (the lowest BAB, under half our hit dice in BAB)
            AI_SetAITargetingValues(TARGETING_PHISICALS, TARGET_HIGHER, i1, i5);
        }
        // Base attack bonus. Used for spells and phisical attacks. Checked with GetBaseAttackBonus.
        AI_SetAITargetingValues(TARGETING_BAB, TARGET_LOWER, i1, i4);
        // Hit dice - how powerful in levels the enemy is. Used for all checks.
        AI_SetAITargetingValues(TARGETING_HITDICE, TARGET_LOWER, i1, i3);

        //AI_SetAITargetingValues(TARGETING_HP_PERCENT, TARGET_LOWER, i1, i3);
        //AI_SetAITargetingValues(TARGETING_HP_CURRENT, TARGET_LOWER, i1, i3);
        //AI_SetAITargetingValues(TARGETING_HP_MAXIMUM, TARGET_LOWER, i1, i3);
            // The HP's are the last thing to choose a target with.
    /************************ [Targeting] *****************************************/

    /************************ [Fleeing] ********************************************
        Fleeing - these are toggled on/off by FEARLESS flag.

        3 or under intelligence will just run away. 4 or more will know where allies
        are, and if there are none, will not run.
    ************************* [Fleeing] *******************************************/
        SetSpawnInCondition(AI_FLAG_FLEEING_FEARLESS, AI_TARGETING_FLEE_MASTER);
            // Forces them to not flee. This may be set with AI_SetMaybeFearless at the end.
        //SetSpawnInCondition(AI_FLAG_FLEEING_NEVER_FIGHT_IMPOSSIBLE_ODDS, AI_TARGETING_FLEE_MASTER);
            // This will make the creature never fight against impossible odds (8HD+ different)
        //SetSpawnInCondition(AI_FLAG_FLEEING_TURN_OFF_GROUP_MORALE, AI_TARGETING_FLEE_MASTER);
            // This turns OFF any sort of group morale bonuses.

        //SetAIInteger(AMOUNT_OF_HD_DIFFERENCE_TO_CHECK, -2);
            // If enemy is within this amount of HD, we do not check morale.
        //SetAIInteger(BASE_MORALE_SAVE, 20);
            // Base DC of the will save. It is set to 20 + HD difference - Morale - Group morale mod.
        //SetAIInteger(HP_PERCENT_TO_CHECK_AT, 80);
            // %HP needed to be at to check morale. This doesn't affect "Never fight impossible odds"
        //SetSpawnInCondition(AI_FLAG_FLEEING_NO_OVERRIDING_HP_AMOUNT, AI_TARGETING_FLEE_MASTER);
            // This will turn off overriding HP checks. AI may decide to run even
            // not at the %HP above, this turns the checks off.

        //SetAIInteger(AI_DAMAGE_AT_ONCE_FOR_MORALE_PENALTY, GetMaxHitPoints()/6);
            // Damage needed to be done at once to get a massive morale penalty (Below)
        //SetAIInteger(AI_DAMAGE_AT_ONCE_PENALTY, 6);
            // Penalty for the above, set for some time to negativly affect morale. Added to save DC for fleeing.

        //SetSpawnInCondition(AI_FLAG_FLEEING_FLEE_TO_NEAREST_NONE_SEEN, AI_TARGETING_FLEE_MASTER);
            // If set, just runs to nearest non-seen ally, and removes the loop for a good group of allies to run to.

        //SetSpawnInCondition(AI_FLAG_FLEEING_FLEE_TO_OBJECT, AI_TARGETING_FLEE_MASTER);
            // They will flee to the nearest object of the tag below, if set.
        //SetLocalString(OBJECT_SELF, AI_FLEE_OBJECT, "BOSS_TAG_OR_WHATEVER");
            // This needs setting if the above is to work.
    /************************ [Fleeing] *******************************************/

    /************************ [Combat - Fighters] **********************************
        Fighter (Phiscal attacks, really) specific stuff - disarmed weapons, better
        at hand to hand, and archer behaviour.
    ************************* [Combat - Fighters] *********************************/
        SetSpawnInCondition(AI_FLAG_COMBAT_PICK_UP_DISARMED_WEAPONS, AI_COMBAT_MASTER);
            // This sets to pick up weapons which are disarmed.

        //SetAIInteger(AI_RANGED_WEAPON_RANGE, 3);
            // This is the range at which they go into melee (from using a ranged weapon). Default is 3 or 5.

        //SetSpawnInCondition(AI_FLAG_COMBAT_BETTER_AT_HAND_TO_HAND, AI_COMBAT_MASTER);
            // Set if you want them to move forwards into HTH sooner. Will always
            // if the enemy is a mage/archer, else % based on range.

        //SetSpawnInCondition(AI_FLAG_COMBAT_ARCHER_ATTACKING, AI_COMBAT_MASTER);
            // For archers. If they have ally support, they'd rather move back & shoot then go into HTH.
        //SetSpawnInCondition(AI_FLAG_COMBAT_ARCHER_ALWAYS_MOVE_BACK, AI_COMBAT_MASTER);
            // This forces the move back from attackers, and shoot bows. Very small chance to go melee.
        //SetSpawnInCondition(AI_FLAG_COMBAT_ARCHER_ALWAYS_USE_BOW, AI_COMBAT_MASTER);
            // This will make the creature ALWAYs use any bows it has. ALWAYS.

        //SetSpawnInCondition(AI_FLAG_COMBAT_NO_GO_FOR_THE_KILL, AI_COMBAT_MASTER);
            // Turns off any attempts to kill dying PCs, or attack low hit point people.
            // This is only ever attempted at 9 or 10 intelligence anyway.
    /************************ [Combat - Fighters] *********************************/

    /************************ [Combat - Spell Casters] *****************************
        Spellcaster AI has been improved significantly. As well as adding all new spells,
        now spellcasters more randomly choose spells from the same level (EG: they
        may choose not to cast magic missile, and cast negative energy ray instead).

        There are also options here for counterspelling, fast buffing, Cheat cast spells,
        dispelling, spell triggers, long ranged spells first, immunity toggles, and AOE settings.
    ************************* [Combat - Spell Casters] ****************************/

        //SetSpawnInCondition(AI_FLAG_COMBAT_LONGER_RANGED_SPELLS_FIRST, AI_COMBAT_MASTER);
            // Casts spells only if the caster would not move into range to cast them.
            // IE long range spells, then medium, then short (unless the enemy comes to us!)
        //SetSpawnInCondition(AI_FLAG_COMBAT_FLAG_FAST_BUFF_ENEMY, AI_COMBAT_MASTER);
            // When an enemy comes in 40M, we fast-cast many defensive spells, as if prepared.
        //SetSpawnInCondition(AI_FLAG_COMBAT_SUMMON_FAMILIAR, AI_COMBAT_MASTER);
            // The caster summons thier familiar/animal companion. Either a nameless Bat or Badger respectivly.

        // Counterspelling/Dispelling...
        // It checks for these classes within the 20M counterspell range.
        //SetSpawnInCondition(AI_FLAG_COMBAT_COUNTER_SPELL_ARCANE, AI_COMBAT_MASTER);
            // If got dispels, it counterspells Arcane (Mage/Sorceror) spellcasters.
        //SetSpawnInCondition(AI_FLAG_COMBAT_COUNTER_SPELL_DIVINE, AI_COMBAT_MASTER);
            // If got dispels, it counterspells Divine (Cleric/Druid) spellcasters.
        //SetSpawnInCondition(AI_FLAG_COMBAT_COUNTER_SPELL_ONLY_IN_GROUP, AI_COMBAT_MASTER);
            // Recommended. Only counterspells with 5+ allies in group.

        //SetSpawnInCondition(AI_FLAG_COMBAT_DISPEL_MAGES_MORE, AI_COMBAT_MASTER);
            // Targets seen mages to dispel, else uses normal spell target.
        SetSpawnInCondition(AI_FLAG_COMBAT_DISPEL_IN_ORDER, AI_COMBAT_MASTER);
            // This will make the mage not dispel just anything all the time, but important (spell-stopping)
            // things first, others later, after some spells. If off, anything is dispelled.

        // AOE's
        //SetSpawnInCondition(AI_FLAG_COMBAT_NEVER_HIT_ALLIES, AI_COMBAT_MASTER);
            // Override toggle. Forces to never cast AOE's if it will hit an ally + harm them.
        //SetSpawnInCondition(AI_FLAG_COMBAT_AOE_DONT_MIND_IF_THEY_SURVIVE, AI_COMBAT_MASTER);
            // Allies who will survive the blast are ignored for calculating best target.
        //SetAIInteger(AI_AOE_ALLIES_LOWEST_IN_AOE, 3);
            // Defualt: 3. If amount of allies in blast radius are equal or more then
            // this, then that location is ignored.
        //SetAIInteger(AI_AOE_HD_DIFFERENCE, -8);
            // Very weak allies (who are not comparable to us) are ignored if we would hit them.

        // For these 2, if neither are set, the AI will choose AOE more if there are
        // lots of enemies, or singles if there are not many.
        //SetSpawnInCondition(AI_FLAG_COMBAT_SINGLE_TARGETING, AI_COMBAT_MASTER);
            // For Same-level spells, single target spells are used first.
        //SetSpawnInCondition(AI_FLAG_COMBAT_MANY_TARGETING, AI_COMBAT_MASTER);
            // For Same-level spells, AOE spells are used first.

        SetSpawnInCondition(AI_FLAG_COMBAT_IMPROVED_INSTANT_DEATH_SPELLS, AI_COMBAT_MASTER);
            // A few Death spells may be cast top-prioritory if the enemy will always fail saves.
        SetSpawnInCondition(AI_FLAG_COMBAT_IMPROVED_SUMMON_TARGETING, AI_COMBAT_MASTER);
            // Will use a better target to summon a creature at (EG: Ranged attacker)
        SetSpawnInCondition(AI_FLAG_COMBAT_IMPROVED_IMMUNITY_CHECKING, AI_COMBAT_MASTER);
            // Turns On "GetIsImmune" checks. Auto on for 7+ Intel.
        SetSpawnInCondition(AI_FLAG_COMBAT_IMPROVED_SPECIFIC_SPELL_IMMUNITY, AI_COMBAT_MASTER);
            // Turns On checks for Globes & levels of spells. Auto on for 9+ Intel.

        //SetSpawnInCondition(AI_FLAG_COMBAT_MORE_ALLY_BUFFING_SPELLS, AI_COMBAT_MASTER);
            // This will make the caster buff more allies - or, in fact, use spells
            // to buff allies which they might have not used before.

        //SetSpawnInCondition(AI_FLAG_COMBAT_USE_ALL_POTIONS, AI_COMBAT_MASTER);
            // Uses all buffing spells before melee.

        //SetAICheatCastSpells(SPELL_MAGIC_MISSILE, SPELL_ICE_DAGGER, SPELL_HORIZIKAULS_BOOM, SPELL_MELFS_ACID_ARROW, SPELL_NEGATIVE_ENERGY_RAY, SPELL_FLAME_ARROW);
            // Special: Mages cast for ever with this set.

        // Spell triggers
        //SetSpellTrigger(SPELLTRIGGER_NOT_GOT_FIRST_SPELL, FALSE, 1, SPELL_PREMONITION);
            // This is just an example. See readme for more info.

    /************************ [Combat - Spell Casters] ****************************/

    /************************ [Combat - Dragons] ***********************************
        I have a fondness for dragons - in NWN they are deprived of many abilities. Here
        are some new ones for your enjoyment! Switches and flying for ANYTHING! :-)
    ************************* [Combat - Dragons] **********************************/

        //SetSpawnInCondition(AI_FLAG_COMBAT_NO_WING_BUFFET, AI_COMBAT_MASTER);
            //This sets so there is no Dragon wing buffet. Readme has details of it.
        //SetAIInteger(AI_DRAGON_FREQUENCY_OF_BUFFET, 3);
            // Min. Amount of Rounds between each buffet. See readme for counter defaults. Def: 3
        //SetAIInteger(AI_DRAGON_FREQUENCY_OF_BREATH, 3);
            // Min. Amount of Rounds between each breath use. See readme for counter defaults. Def: 3

        // Default checks for dragon flying automatic turning on of flying.
        if(GetLevelByClass(CLASS_TYPE_DRAGON) || GetRacialType(OBJECT_SELF) == RACIAL_TYPE_DRAGON)
        {
            SetSpawnInCondition(AI_FLAG_COMBAT_FLYING, AI_COMBAT_MASTER);
            // This turns ON combat flying. I think anything winged looks A-OK. See readme for info.
        }
    /************************ [Combat - Dragons] **********************************/

    /************************ [Combat Other - Healers/Healing] *********************
        Healing behaviour - not specifically clerics. See readme.
    ************************* [Combat Other - Healers/Healing] ********************/
        //SetSpawnInCondition(AI_FLAG_OTHER_COMBAT_HEAL_AT_PERCENT_NOT_AMOUNT, AI_OTHER_COMBAT_MASTER);
            // if this is set, we ignore the amount we need to be damaged, as long
            // as we are under AI_HEALING_US_PERCENT.
        //SetAIInteger(AI_HEALING_US_PERCENT, 50);
            // % of HP we need to be at until we heal us at all. Default: 50
        //SetAIInteger(AI_HEALING_ALLIES_PERCENT, 60);
            // % of HP allies would need to be at to heal them Readme = info. Default: 60
        SetSpawnInCondition(AI_FLAG_OTHER_COMBAT_WILL_RAISE_ALLIES_IN_BATTLE, AI_OTHER_COMBAT_MASTER);
            // Turns on rasing dead with Resurrection/Raise dead.
        //SetSpawnInCondition(AI_FLAG_OTHER_COMBAT_NO_CURING, AI_OTHER_COMBAT_MASTER);
            // This turns off all healing.
        //SetSpawnInCondition(AI_FLAG_OTHER_COMBAT_ONLY_CURE_SELF, AI_OTHER_COMBAT_MASTER);
            // This turns off ally healing.
        //SetSpawnInCondition(AI_FLAG_OTHER_COMBAT_ONLY_RESTORE_SELF, AI_OTHER_COMBAT_MASTER);
            // This turns off ally restoring (Remove/Restoration).
        //SetSpawnInCondition(AI_FLAG_OTHER_COMBAT_USE_BAD_HEALING_SPELLS, AI_OTHER_COMBAT_MASTER);
            // This forces all cure spells to be used, check readme.
        //SetAIInteger(SECONDS_BETWEEN_STATUS_CHECKS, 30);
            // Seconds between when we loop everyone for bad effects like Fear/stun ETC. If not set, done each round.
        //SetSpawnInCondition(AI_FLAG_OTHER_COMBAT_GIVE_POTIONS_TO_HELP, AI_OTHER_COMBAT_MASTER);
            // ActionGiveItem standard healing potion's to allies who need them, if they possess them.

    /************************ [Combat Other - Healers/Healing] ********************/

    /************************ [Combat Other - Skills] ******************************
        Skills are a part of fighting - EG Taunt. These are mainly on/off switches.
        A creature will *may* use it if they are not set to "NO_" for the skill.
    ************************* [Combat Other - Skills] *****************************/

        // "NO" - This is for forcing the skill NEVER to be used by the combat AI.
        // "FORCE" - This forces it on (and to be used), except if they have no got the skill.

        //SetSpawnInCondition(AI_FLAG_OTHER_COMBAT_NO_PICKPOCKETING, AI_OTHER_COMBAT_MASTER);
        //SetSpawnInCondition(AI_FLAG_OTHER_COMBAT_FORCE_PICKPOCKETING, AI_OTHER_COMBAT_MASTER);
        //SetSpawnInCondition(AI_FLAG_OTHER_COMBAT_NO_TAUNTING, AI_OTHER_COMBAT_MASTER);
        //SetSpawnInCondition(AI_FLAG_OTHER_COMBAT_FORCE_TAUNTING, AI_OTHER_COMBAT_MASTER);
        //SetSpawnInCondition(AI_FLAG_OTHER_COMBAT_NO_EMPATHY, AI_OTHER_COMBAT_MASTER);
        //SetSpawnInCondition(AI_FLAG_OTHER_COMBAT_FORCE_EMPATHY, AI_OTHER_COMBAT_MASTER);
        //SetSpawnInCondition(AI_FLAG_OTHER_COMBAT_NO_HIDING, AI_OTHER_COMBAT_MASTER);
        //SetSpawnInCondition(AI_FLAG_OTHER_COMBAT_FORCE_HIDING, AI_OTHER_COMBAT_MASTER);
        //SetSpawnInCondition(AI_FLAG_OTHER_COMBAT_NO_OPENING_LOCKED_DOORS, AI_OTHER_COMBAT_MASTER);
        //SetSpawnInCondition(AI_FLAG_OTHER_COMBAT_FORCE_OPENING_LOCKED_DOORS, AI_OTHER_COMBAT_MASTER);
        //SetSpawnInCondition(AI_FLAG_OTHER_COMBAT_NO_USING_HEALING_KITS, AI_OTHER_COMBAT_MASTER);
        //SetSpawnInCondition(AI_FLAG_OTHER_COMBAT_NO_PARRYING, AI_OTHER_COMBAT_MASTER);
        //SetSpawnInCondition(AI_FLAG_OTHER_COMBAT_FORCE_PARRYING, AI_OTHER_COMBAT_MASTER);
        //SetSpawnInCondition(AI_FLAG_OTHER_COMBAT_NO_SEARCH, AI_OTHER_COMBAT_MASTER);
        //SetSpawnInCondition(AI_FLAG_OTHER_COMBAT_FORCE_SEARCH, AI_OTHER_COMBAT_MASTER);
        // - Concentration - special notes in the readme
        //SetSpawnInCondition(AI_FLAG_OTHER_COMBAT_NO_CONCENTRATION, AI_OTHER_COMBAT_MASTER);
        //SetSpawnInCondition(AI_FLAG_OTHER_COMBAT_FORCE_CONCENTRATION, AI_OTHER_COMBAT_MASTER);

    /************************ [Combat Other - Skills] *****************************/

    /************************ [Combat Other - Leaders] *****************************
        Leaders/Bosses can be set to issue some orders and inspire more morale - and bring
        a lot of allies to a battle at once!
    ************************* [Combat Other - Leaders] ****************************/
        //SetSpawnInCondition(AI_FLAG_OTHER_COMBAT_GROUP_LEADER, AI_OTHER_COMBAT_MASTER);
            // Special leader. Can issuse some orders. See readme for details.

        //SetSpawnInCondition(AI_FLAG_OTHER_COMBAT_BOSS_MONSTER_SHOUT, AI_OTHER_COMBAT_MASTER);
            // Boss shout. 1 time use - calls all creatures in X meters (below) for battle!
        //SetAIInteger(AI_BOSS_MONSTER_SHOUT_RANGE, 60);
            // Defaults to a 60 M range. This can change it. Note: 1 toolset square = 10M.

    /************************ [Combat Other - Leaders] ****************************/

    /************************ [Other - Behaviour/Generic] **************************
        This is generic behaviours - alright, really it is all things that cannot
        really be categorised.
    ************************* [Other - Behaviour/Generic] *************************/

        //SetSpawnInCondition(AI_FLAG_OTHER_NO_CLEAR_ACTIONS_BEFORE_CONVERSATION, AI_OTHER_MASTER);
            // No ClearAllActions() before BeginConversation. May keep a creature sitting.
        //SetSpawnInCondition(AI_FLAG_OTHER_NO_POLYMORPHING, AI_OTHER_MASTER);
            // This will stop all polymorphing spells feats from being used.
        //SetSpawnInCondition(AI_FLAG_OTHER_CHEAT_MORE_POTIONS, AI_OTHER_MASTER);
            // If at low HP, and no potion, create one and use it.
        //SetAIConstant(AI_POLYMORPH_INTO, POLYMORPH_TYPE_WEREWOLF);
            // Polymorph to this creature when damaged (once, natural effect).

        //AI_CreateRandomStats(-3, 3, 6);
            // Create (Effect-applied) random statistics.
        //AI_CreateRandomOther(-2, 2, -2, 2, -2, 2, -2, 2);
            // Create (Effect-applied) random HP, saves, AC.

        //SetSpawnInCondition(AI_FLAG_OTHER_RETURN_TO_SPAWN_LOCATION, AI_OTHER_MASTER);
            // This will store our spawn location, and then move back there after combat.
        SetSpawnInCondition(AI_FLAG_OTHER_DONT_RESPOND_TO_EMOTES, AI_OTHER_MASTER);
            // This will ignore ALL chat by PC's (Enemies) who speak actions in Stars - *Bow*

        //SetSpawnInCondition(AI_FLAG_OTHER_DONT_SHOUT, AI_OTHER_MASTER);
            // Turns off all silent talking NPC's do to other NPC's.

        //SetSpawnInCondition(AI_FLAG_OTHER_SEARCH_IF_ENEMIES_NEAR, AI_OTHER_MASTER);
            // Move randomly closer to enemies in range set below.
        //SetAIInteger(AI_SEARCH_IF_ENEMIES_NEAR_RANGE, 25);
            // This is the range creatures use, in metres.

        //SetSpawnInCondition(AI_FLAG_OTHER_ONLY_ATTACK_IF_ATTACKED, AI_OTHER_MASTER);
            // One shot. We won't instantly attack a creature we see. See readme.

        //SetAIInteger(AI_DOOR_INTELLIGENCE, 1);
            // 3 Special "What to do with Doors" settings. See readme. Good for animals.

        //SetSpawnInCondition(AI_FLAG_OTHER_REST_AFTER_COMBAT, AI_OTHER_MASTER);
            // When combat is over, creature rests. Useful for replenising health.

        //SetSpawnInCondition(AI_FLAG_OTHER_NO_PLAYING_VOICE_CHAT, AI_OTHER_MASTER);
            // Stops any use of "PlayVoiceChat". Use with Custom speakstrings.

              /*** Death settings - still under AI_OTHER_MASTER ***/

        //AI_SetDeathResRef("Resref Here");
            // Creates a creature from the string set. Instantly destroys this creatures body on death.

        //SetAIConstant(AI_DEATH_VISUAL_EFFECT, VFX_FNF_IMPLOSION);
            // Fires this visual effect number instantly on death. Use FNF and IMP ones.

        //SetAIInteger(AI_CORPSE_DESTROY_TIME, 30);
            // Seconds before body finally gets destroyed. Used for Clerical Raise Dead on NPC's.

        //SetSpawnInCondition(AI_FLAG_OTHER_TURN_OFF_CORPSES, AI_OTHER_MASTER);
            // This turns off the SetDestroyable() usually performed, and the above timer.

        //SetSpawnInCondition(AI_FLAG_OTHER_USE_BIOWARE_LOOTING, AI_OTHER_MASTER);
            // Makes the death file use Bioware's cool SetLootable() feature when corpses would disappear.

          /*** Lag and a few performance settings - still under AI_OTHER_MASTER ***/

        //SetSpawnInCondition(AI_FLAG_OTHER_LAG_NO_ITEMS, AI_OTHER_MASTER);
            // The creature doesn't check for, or use any items that cast spells.
        //SetSpawnInCondition(AI_FLAG_OTHER_LAG_NO_SPELLS, AI_OTHER_MASTER);
            //The creature doesn't ever cast spells (and never checks them)
        //SetSpawnInCondition(AI_FLAG_OTHER_LAG_NO_LISTENING, AI_OTHER_MASTER);
            // The creature doesn't  have SetListening() set. Turns of the basic listening for shouts.
        //SetSpawnInCondition(AI_FLAG_OTHER_LAG_EQUIP_MOST_DAMAGING, AI_OTHER_MASTER);
            // Uses EquipMostDamaging(), like Bioware code. No shield/second weapon equipped.
        //SetSpawnInCondition(AI_FLAG_OTHER_LAG_NO_CURING_ALLIES, AI_OTHER_MASTER);
            // This will stop checks for and curing of allies ailments.
        //SetSpawnInCondition(AI_FLAG_OTHER_LAG_IGNORE_HEARTBEAT, AI_OTHER_MASTER);
            // Stops the heartbeat running (Except Pre-Heartbeat-event).
        //SetSpawnInCondition(AI_FLAG_OTHER_LAG_TARGET_NEAREST_ENEMY, AI_OTHER_MASTER);
            // Ignores targeting settings. VERY good for lag/bad AI. Attacks nearest seen enemy.

          /*** AI Level setting - Do not use AI_LEVEL_DEFAULT at all. ***/

        //SetAIConstant(LAG_AI_LEVEL_NO_PC_OR_ENEMY_50M, AI_LEVEL_VERY_LOW);
            // Changes to this AI setting if there is no enemy or PC in 50M.
        //SetAIConstant(LAG_AI_LEVEL_YES_PC_OR_ENEMY_50M, AI_LEVEL_LOW);
            // Changes to this AI setting if there IS an enemy or PC in 50M.
        //SetAIConstant(LAG_AI_LEVEL_COMBAT, AI_LEVEL_NORMAL);
            // This OVERRIDES others. Only used when a creature is put into combat.

    /************************ [Other - Behaviour/Generic] *************************/

    /************************ [User Defined and Shouts] ****************************
        The user defined events, set up to fire here.
        - New "Start combat attack" and "End Combat Attack" events
        - New "Pre" events. Use these to optionally stop a script from firing
          under cirtain circumstances as well! (Read nw_c2_defaultd or j_ai_onuserdef)
        (User Defined Event = UDE)
    ************************* [User Defined and Shouts] ***************************/

        //SetSpawnInCondition(AI_FLAG_UDE_HEARTBEAT_EVENT, AI_UDE_MASTER);             // UDE 1001
        //SetSpawnInCondition(AI_FLAG_UDE_HEARTBEAT_PRE_EVENT, AI_UDE_MASTER);         // UDE 1021
        //SetSpawnInCondition(AI_FLAG_UDE_PERCIEVE_EVENT, AI_UDE_MASTER);              // UDE 1002
        //SetSpawnInCondition(AI_FLAG_UDE_PERCIEVE_PRE_EVENT, AI_UDE_MASTER);          // UDE 1022
        //SetSpawnInCondition(AI_FLAG_UDE_END_COMBAT_ROUND_EVENT, AI_UDE_MASTER);      // UDE 1003
        //SetSpawnInCondition(AI_FLAG_UDE_END_COMBAT_ROUND_PRE_EVENT, AI_UDE_MASTER);  // UDE 1023
        //SetSpawnInCondition(AI_FLAG_UDE_ON_DIALOGUE_EVENT, AI_UDE_MASTER);           // UDE 1004
        //SetSpawnInCondition(AI_FLAG_UDE_ON_DIALOGUE_PRE_EVENT, AI_UDE_MASTER);       // UDE 1024
        //SetSpawnInCondition(AI_FLAG_UDE_ATTACK_EVENT, AI_UDE_MASTER);                // UDE 1005
        //SetSpawnInCondition(AI_FLAG_UDE_ATTACK_PRE_EVENT, AI_UDE_MASTER);            // UDE 1025
        //SetSpawnInCondition(AI_FLAG_UDE_DAMAGED_EVENT, AI_UDE_MASTER);               // UDE 1006
        //SetSpawnInCondition(AI_FLAG_UDE_DAMAGED_PRE_EVENT, AI_UDE_MASTER);           // UDE 1026
        //SetSpawnInCondition(AI_FLAG_UDE_DEATH_EVENT, AI_UDE_MASTER);                 // UDE 1007
        //SetSpawnInCondition(AI_FLAG_UDE_DEATH_PRE_EVENT, AI_UDE_MASTER);             // UDE 1027
        //SetSpawnInCondition(AI_FLAG_UDE_DISTURBED_EVENT, AI_UDE_MASTER);             // UDE 1008
        //SetSpawnInCondition(AI_FLAG_UDE_DISTURBED_PRE_EVENT, AI_UDE_MASTER);         // UDE 1028
        //SetSpawnInCondition(AI_FLAG_UDE_RESTED_EVENT, AI_UDE_MASTER);                // UDE 1009
        //SetSpawnInCondition(AI_FLAG_UDE_RESTED_PRE_EVENT, AI_UDE_MASTER);            // UDE 1029
        //SetSpawnInCondition(AI_FLAG_UDE_SPELL_CAST_AT_EVENT, AI_UDE_MASTER);         // UDE 1011
        //SetSpawnInCondition(AI_FLAG_UDE_SPELL_CAST_AT_PRE_EVENT, AI_UDE_MASTER);     // UDE 1031
        //SetSpawnInCondition(AI_FLAG_UDE_ON_BLOCKED_EVENT, AI_UDE_MASTER);            // UDE 1015
        //SetSpawnInCondition(AI_FLAG_UDE_ON_BLOCKED_PRE_EVENT, AI_UDE_MASTER);        // UDE 1035

        //SetSpawnInCondition(AI_FLAG_UDE_COMBAT_ACTION_EVENT, AI_UDE_MASTER);         // UDE 1012
            // Fires when we have finnished all combat actions.
        //SetSpawnInCondition(AI_FLAG_UDE_COMBAT_ACTION_PRE_EVENT, AI_UDE_MASTER);     // UDE 1032
            // This fires at the start of DetermineCombatRound() *IF they can do an action*.
        //SetSpawnInCondition(AI_FLAG_UDE_DAMAGED_AT_1_HP, AI_UDE_MASTER);             // UDE 1014
            // Fires when we are damaged, and are at 1 HP. Use for immortal-flagged creatures.

     /*** Speakstrings - as it were, said under cirtain conditions % chance each time ***/

        //AI_SetSpawnInSpeakArray(AI_TALK_ON_CONVERSATION, 100, 4, "Hello there", "I hope you enjoy your stay", "Do you work here too?", "*Hic*");
            // On Conversation - see readme. Replaces BeginConversation().

        // Morale
        //AI_SetSpawnInSpeakArray(AI_TALK_ON_MORALE_BREAK, 100, 3, "No more!", "I'm outta here!", "Catch me if you can!");
            // Spoken at running point, if they run to a group of allies.
        //AI_SetSpawnInSpeakArray(AI_TALK_ON_CANNOT_RUN, 100, 3, "Never give up! Never surrender!", "I've no where to run, so make my day!", "RRRAAAAA!!!");
            // Spoken at running point, if they can find no ally to run to, and 4+ Intelligence. See readme
        //AI_SetSpawnInSpeakValue(AI_TALK_ON_STUPID_RUN, "Ahhhhgggg! NO MORE! Run!!");
            // As above, when morale breaks + no ally, but they panic and run from enemy at 3 or less intelligence.

        // Combat
        //AI_SetSpawnInSpeakArray(AI_TALK_ON_COMBAT_ROUND_EQUAL, 5, 4, "Come on!", "You won't win!", "We are not equals! I am better!", "Nothing will stop me!");
        //AI_SetSpawnInSpeakArray(AI_TALK_ON_COMBAT_ROUND_THEM_OVER_US, 5, 4, "I'll try! try! and try again!", "Tough man, are we?", "Trying out your 'skills'? Pathetic excuse!", "Nothing good will come from killing me!");
        //AI_SetSpawnInSpeakArray(AI_TALK_ON_COMBAT_ROUND_US_OVER_THEM, 5, 4, "My strength is mighty then yours!", "You will definatly die!", "NO chance for you!", "No mercy! Not for YOU!");
            // Spoken each DetermineCombatRound. % is /1000. See readme for Equal/Over/Under values.
        //AI_SetSpawnInSpeakArray(AI_TALK_ON_TAUNT, 100, 3, "You're going down!", "No need to think, let my blade do it for you!", "Time to meet your death!");
            // If the creature uses thier skill, taunt, on an enemy this will be said.

        // Event-driven.
        //AI_SetSpawnInSpeakArray(AI_TALK_ON_PERCIEVE_ENEMY, 70, 6, "Stand and fight, lawbreaker!", "Don't run from the law!", "I have my orders!", "I am ready for violence!", "CHARGE!", "Time you died!");
            // This is said when they see/hear a new enemy, and start attacking them.
        //AI_SetSpawnInSpeakArray(AI_TALK_ON_DAMAGED, 20, 2, "Ouch, damn you!", "Haha! Nothing will stop me!");
            // A random value is set to speak when damaged, and may fire same time as below ones.
        //AI_SetSpawnInSpeakArray(AI_TALK_ON_PHISICALLY_ATTACKED, 20, 2, "Hah! Mear weapons won't defeat me!", "Pah! You cannot defeat me with such rubbish!");
            // This is said when an enemy attacks the creature with a melee/ranged weapon.
        //AI_SetSpawnInSpeakArray(AI_TALK_ON_HOSTILE_SPELL_CAST_AT, 20, 2, "No one spell will stop me!", "Is that all you have!?!");
            // This is said when an enemy attacks the creature with a hostile spell.
        //AI_SetSpawnInSpeakValue(AI_TALK_ON_DEATH, "Agggggg!");
            // This will ALWAYS be said, whenever the creature dies.

        // Specific potion ones.
        //AI_SetSpawnInSpeakValue(AI_TALK_WE_PASS_POTION, "Here! Catch!");
            // This will be spoken when the creature passes a potion to an ally. See readme.
        //AI_SetSpawnInSpeakValue(AI_TALK_WE_GOT_POTION, "Got it!");
            // This will be spoken by the creature we pass the potion too, using AssignCommand().

        // Leader ones
        //AI_SetSpawnInSpeakValue(AI_TALK_ON_LEADER_SEND_RUNNER, "Quickly! We need help!");
            // This will be said when the leader, if this creature, sends a runner.
        //AI_SetSpawnInSpeakValue(AI_TALK_ON_LEADER_ATTACK_TARGET, "Help attack this target!");
            // When the leader thinks target X should be attacked, it will say this.

    /************************ [User Defined and Shouts] ***************************/

    /************************ [Bioware: Animations/Waypoints/Treasure] *************
        All Bioware Stuff. I'd check out "x0_c2_spwn_def" for the SoU/Hordes revisions.
    ************************* [Bioware: Animations/Waypoints/Treasure] ************/

        // SetSpawnInCondition(NW_FLAG_STEALTH, NW_GENERIC_MASTER);
        // SetSpawnInCondition(NW_FLAG_SEARCH, NW_GENERIC_MASTER);
            // Uses said skill while WalkWaypoints()

        // SetSpawnInCondition(NW_FLAG_DAY_NIGHT_POSTING, NW_GENERIC_MASTER);
            // Separate the NPC's waypoints into day & night. See comment in "nw_i0_generic" for use.

        // SetSpawnInCondition(NW_FLAG_IMMOBILE_AMBIENT_ANIMATIONS, NW_GENERIC_MASTER);
            // This will cause an NPC to use common animations it possesses,
            // and use social ones to any other nearby friendly NPCs.
        // SetSpawnInCondition(NW_FLAG_AMBIENT_ANIMATIONS, NW_GENERIC_MASTER);
            // Same as above, except NPC will wander randomly around the area.

        // SetAnimationCondition(NW_ANIM_FLAG_IS_CIVILIZED);
            // Interacts with placeables + More civilized actions. See Readme.
        // SetAnimationCondition(NW_ANIM_FLAG_CHATTER);
            // Will use random voicechats during animations, if Civilized
        // SetAnimationCondition(NW_ANIM_FLAG_IS_MOBILE_CLOSE_RANGE);
            // Will move around the area a bit more, if using Immobile Animations. See readme.

        // Treasure generating.
        //CTG_GenerateNPCTreasure();
            // SoU. Requires "x0_i0_treasure" to be uncommented. See readme.
        //GenerateNPCTreasure();
            // Default NwN. Requires "nw_o2_coninclude" to be uncommented. See readme.

    /************************ [Bioware: Animations/Waypoints/Treasure] ************/

        // AI Behaviour. DO NOT CHANGE! DO NOT CHANGE!!!
        AI_SetUpEndOfSpawn();
            // This MUST be called. It fires these events:
            // SetUpSpells, SetUpSkillToUse, SetListeningPatterns, SetWeapons, AdvancedAuras.
            // These MUST be called! the AI might fail to work correctly if they don't fire!

    /************************ [User] ***********************************************
        This is the ONLY place you should add user things, on spawn, such as
        visual effects or anything, as it is after SetUpEndOfSpawn. By default, this
        does have encounter animations on. This is here, so is easily changed :-D

        Be careful otherwise.

        Notes:
        - SetListening is already set to TRUE, unless AI_FLAG_OTHER_LAG_NO_LISTENING is on.
        - SetListenPattern's are set from 0 to 7.
        - You can use the wrappers AI_SpawnInInstantVisual and AI_SpawnInPermamentVisual
          for visual effects (Instant/Permament as appropriate).
    ************************* [User] **********************************************/
        // Example (and default) of user addition:
        // - If we are from an encounter, set mobile (move around) animations.
        if(GetIsEncounterCreature())
        {
            SetSpawnInCondition(NW_FLAG_AMBIENT_ANIMATIONS, NW_GENERIC_MASTER);
        }
        // Leave this in if you use the variable for creature attacks, as for golems. Bioware's code.
        int nNumber = GetLocalInt(OBJECT_SELF, "CREATURE_VAR_NUMBER_OF_ATTACKS");
        if(nNumber > 0)
        {
            SetBaseAttackBonus(nNumber);
        }

    /************************ [User] **********************************************/

        // Note: You shouldn't really remove this, even if they have no waypoints.
        DelayCommand(f2, SpawnWalkWayPoints());
            // Delayed walk waypoints, as to not upset instant combat spawning.
            // This will also check if to change to day/night posts during the walking, no heartbeats.
    }