x2_inc_switches

This file provides a basic interface for switching different Hordes of the Underdark subsystems on/off and allows centralized access to certain "expert" functionality like overriding AI or Spellscripts.

Changing any of these switches from their default position is considered unsupported and done at your own risk.

Constants

NameValueBrief Description
CREATURE_AI_MODIFIED_COMPASSION_RATEX2_L_BEH_COMPASSIONThe higher value of this variable, the higher the chance that the creature will aid friendly creatures in combat.

Not that helping usually degrades the overall difficulty of an encounter, but makes it more interesting.
CREATURE_AI_MODIFIED_MAGIC_RATEX2_L_BEH_MAGICThe value of this variable (int) is added to the chance that a creature will use magic in combat.

Set to 100 for always, 0 for never.
CREATURE_AI_MODIFIED_OFFENSE_RATEX2_L_BEH_OFFENSEThe higher value of this variable, the higher the chance that the creature will use offensive abilities in combat. Set to 0 to make them flee.
CREATURE_VAR_CUSTOM_AISCRIPTX2_SPECIAL_COMBAT_AI_SCRIPTSee x2_ai_demo for details.
CREATURE_VAR_IMMUNE_TO_DISPELX1_L_IMMUNE_TO_DISPELSet to TRUE to make the creature immune to dispel magic (used for statues).
CREATURE_VAR_IS_INCORPOREALX2_L_IS_INCORPOREALSet this variable to TRUE on a creature to make it walk through other creatures.
CREATURE_VAR_NUMBER_OF_ATTACKSX2_L_NUMBER_OF_ATTACKSSet this variable to 1 - 6 to override the number of attacks a creature has based on its BAB.
CREATURE_VAR_PALE_MASTER_SPECIAL_ITEMX2_S_PM_SPECIAL_ITEMThis allows you to script items that enhance a Palemaster's summoned creatures.

You need to put the name of a script into this variable that will be run on any creature called by the Palemaster's summon undead ability.

You can use this script to add effects to the creature.

You can use the OnEquip/OnUnEquip event hooks set this variable.
CREATURE_VAR_RANDOMIZE_NAMEX2_NAME_RANDOMSetting this variable on a creature will make its use a random name.

See nw_c2_default9 for details.
CREATURE_VAR_RANDOMIZE_SPELLUSEX2_SPELL_RANDOMSetting this variable on a spellcaster creature will make its spell use a bit more random, but their spell selection may not always be appropriate to the situation anymore.
CREATURE_VAR_USE_SPAWN_AMBIENTX2_L_SPAWN_USE_AMBIENTSet to TRUE to make the creature play mobile ambient animations after spawn.
CREATURE_VAR_USE_SPAWN_AMBIENT_IMMOBILEX2_L_SPAWN_USE_AMBIENT_IMMOBILESet to TRUE to make the creature play immobile ambient animations after spawn.
CREATURE_VAR_USE_SPAWN_SEARCHX2_L_SPAWN_USE_SEARCHSet to TRUE to make the creature activate detectmode after spawn.
CREATURE_VAR_USE_SPAWN_STEALTHX2_L_SPAWN_USE_STEALTHSet to TRUE to make the creature activate stealth mode after spawn.
DOOR_FLAG_RESIST_KNOCKX2_FLAG_DOOR_RESIST_KNOCKDoors.
ITEM_FLAG_NO_CRAFT_MODIFICATIONX2_FLAG_ITEM_CRAFT_DO_NOT_MODIFYNOTE: THIS NO LONGER WORKS. TO PREVENT MODIFICATION USE THE PLOT FLAG.
MODULE_SWITCH_AOE_HURT_NEUTRAL_NPCSX0_G_ALLOWSPELLSTOHURTToggle Area of Effect Spell behavior.

If set to TRUE, AOE Spells will hurt NPCS that are neutral to the caster if they are caught in the effect.
MODULE_SWITCH_DISABLE_AI_DISPEL_AOEX2_L_AI_NO_AOE_DISPELIf this variable is set, the AI will not use Dispel Magic against harmful AOE spells.
MODULE_SWITCH_DISABLE_ITEM_CREATION_FEATSX2_SWITCH_DISABLE_ITEMCREATION_FEATSToggle on/off the Item Creation Feats.

Default = FALSE.

Disable the Item Creation Feats that come with Hordes of the Underdark for the module.
MODULE_SWITCH_DISABLE_SECRET_DOOR_FLASHX2_SWITCH_DISABLE_SECRET_DOOR_FLASHSetting this switch to TRUE will disable the glow of a newly found secret door used in some locations in XP2.
MODULE_SWITCH_ENABLE_BEBILITH_RUIN_ARMORX2_SWITCH_BEBILITH_HARDCORE_RUIN_ARMORIf set to TRUE, the Bebilith Ruin Armor ability is going to actually destroy the armor it hits.

Would be very annoying for players...
MODULE_SWITCH_ENABLE_CRAFT_WAND_50_CHARGESX2_SWITCH_ENABLE_50_WAND_CHARGESFor balancing reasons the crafting system will create 50 charges on a new wand instead it will create 10 + casterlevel charges.

If you want to be "hard core rules compliant" 50 charges, enable this switch.
MODULE_SWITCH_ENABLE_CROSSAREA_WALKWAYPOINTSX2_SWITCH_CROSSAREA_WALKWAYPOINTSSetting this switch to TRUE will enable the allow NPCs running between waypoints using the WalkWaypoints function to cross areas, like they did in the original NWN.

This was changed in 1.30 to use only waypoints in one area.
MODULE_SWITCH_ENABLE_INVISIBLE_GLYPH_OF_WARDINGX2_SWITCH_GLYPH_OF_WARDING_INVISIBLESetting this switch to TRUE will make the Glyph of Warding symbol disappear after 6 seconds, but the glyph will stay active....
MODULE_SWITCH_ENABLE_MULTI_HENCH_AOE_DAMAGEX2_SWITCH_MULTI_HENCH_AOE_MADNESSMultiple Henchmen: By default, henchmen will never damage each other with AoE spells.

By activating this switch, henchmen will be able to damage each other with AoE spells and potentially go on each other's throats.

Warning: Activating this switch has the potential of introducing game breaking bugs. Do not use on the official SoU campaign. Use at your own risk. Really, its dangerous!
MODULE_SWITCH_ENABLE_NPC_AOE_HURT_ALLIESX2_SWITCH_ENABLE_NPC_AOE_HURT_ALLIESSpell Targeting: Pre Hordes of the Underdark, in hardcore mode, creatures would not hurt each other with their AOE spells if they were no PCs.

Setting this switch to true, will activate the correct behavior.

Activating this on older modules can break things, unless you know what you are doing!
MODULE_SWITCH_ENABLE_TAGBASED_SCRIPTSX2_SWITCH_ENABLE_TAGBASED_SCRIPTSSetting this switch to TRUE will disable execution of tag based scripts that are enabled by default when using the standard module events (x2_mod_def_*).
MODULE_SWITCH_ENABLE_UMD_SCROLLSX2_SWITCH_ENABLE_UMD_SCROLLSForce Use Magic Device Skillchecks.

Default = FALSE except for GAME_DIFFICULTY_CORE_RULES. If switched to TRUE, a rogue has to succeed in a UMD check against DC 25 + SpellLevel in order to use a scroll.

See x2_pc_umdcheck.nss for details.
MODULE_SWITCH_EPIC_SPELLS_HURT_CASTERX2_SWITCH_EPIC_SPELLS_HURT_CASTERSome epic spells, namely Hellball, do damage to the caster. We found this too confusing in testing, so it was disabled.

You can reactivate using this flag.
MODULE_SWITCH_NO_RANDOM_MONSTER_LOOTX2_L_NOTREASURESetting this variable to TRUE on the module will disable the call to the random loot generation in most creatures' OnSpawn script.
MODULE_SWITCH_RESTRICT_USE_POISON_TO_FEATX2_SWITCH_RESTRICT_USE_POISON_FEATBy default, all characters can use the various poisons that can be found to poison their weapons if they win a dexterity check.

Activating this flag will restrict the use of poison to chars with the UsePoison feat only.
MODULE_SWITCH_SPELL_CORERULES_DMASTERTOUCHX2_SWITCH_SPELL_CORERULE_DMTOUCHDeathless master touch is not supposed to affect creatures of size > large but we do not check this condition by default to balance the fact that the slain creature is not raised under the command of the Palemaster.

By setting this switch to TRUE, the ability will no longer effect creatures of huge+ size.
MODULE_SWITCH_USE_XP2_RESTSYSTEMX2_SWITCH_ENABLE_XP2_RESTSYSTEMSetting this switch to TRUE will enable the XP2 Wandering Monster System for this module (if you are using the default rest script and you have set up the correct variables for each area).
MODULE_VAR_AI_NO_DISPEL_AOE_CHANCEX2_L_AI_AOE_DISPEL_CHANCEThis variable allows specifying a % for NOT using dispel magic against AOEs instead fleeing.
MODULE_VAR_AI_STOP_EXPERTISE_ABUSEX2_L_STOP_EXPERTISE_ABUSESetting this variable to TRUE will cause the Expertise/Improved Expertise modes to be disabled whenever a player is casting a spell.
MODULE_VAR_OVERRIDE_SPELLSCRIPTX2_S_UD_SPELLSCRIPT
MODULE_VAR_TAGBASED_SCRIPT_PREFIXX2_S_UD_SPELLSCRIPT
MODULE_VAR_WANDERING_MONSTER_2DAX2_WM_2DA_NAMEVariable that holds the wandering monster 2da filename.
WAYPOINT_VAR_FORCE_SETFACINGX2_L_WAYPOINT_SETFACINGBy setting this variable to TRUE on a waypoint, a creature using this waypoint as part of its WalkWaypoints routine will assume the facing of the waypoint upon reaching it.
X2_EXECUTE_SCRIPT_CONTINUE0
X2_EXECUTE_SCRIPT_END1
X2_ITEM_EVENT_ACQUIRE4Defines item messages that are routed to script files with the item tag's through the default XP2 module scripts.
X2_ITEM_EVENT_ACTIVATE0Defines item messages that are routed to script files with the item tag's through the default XP2 module scripts.
X2_ITEM_EVENT_EQUIP1Defines item messages that are routed to script files with the item tag's through the default XP2 module scripts.
X2_ITEM_EVENT_ONHITCAST3Defines item messages that are routed to script files with the item tag's through the default XP2 module scripts.
X2_ITEM_EVENT_SPELLCAST_AT6Defines item messages that are routed to script files with the item tag's through the default XP2 module scripts.
X2_ITEM_EVENT_UNACQUIRE5Defines item messages that are routed to script files with the item tag's through the default XP2 module scripts.
X2_ITEM_EVENT_UNEQUIP2Defines item messages that are routed to script files with the item tag's through the default XP2 module scripts.

Functions

NameBrief Description
ClearCreatureOverrideAIScriptTargetDeletes the flag X2_NW_I0_GENERIC_INTRUDER from a specific target.
ExecuteScriptAndReturnIntExecute sScript on oTarget returning an integer.

Do not nest this function.
GetCreatureFlagReturns a flag set on a specific object.
GetCreatureOverrideAIScriptTargetReturns the value of X2_NW_I0_GENERIC_INTRUDER.
GetDoorFlagUsed to toggle custom flags on a door.
GetItemFlagReturns a flag set on an item.
GetModuleOverrideSpellScriptFinishedInternal function. Returns and deletes a saved flag.
GetModuleSwitchValueReturns the value of a module switch.
GetUserDefinedItemEventNumberGet the active User Defined Item Event.
- X2_ITEM_EVENT_ACTIVATE
- X2_ITEM_EVENT_EQUIP
- X2_ITEM_EVENT_UNEQUIP
- X2_ITEM_EVENT_ONHITCAST
- X2_ITEM_EVENT_ACQUIRE
- X2_ITEM_EVENT_UNACQUIRE
- X2_ITEM_EVENT_SPELLCAST_AT
GetUserDefinedItemEventScriptNameInternal function. Returns the name for the User Defined Item Event script for oItem, including possible prefixes configured by SetUserDefinedItemEventPrefix.
SetCreatureFlagSets a flag on a specific object.
SetCreatureOverrideAIScriptDefine a replacement script for DetermineCombatRound.

See x2_ai_demo for details.
SetCreatureOverrideAIScriptFinishedCall this at end of your custom override AI script set via CREATURE_VAR_CUSTOM_AISCRIPT.

See x2_ai_demo for details.
SetDoorFlagUsed to toggle custom flags on a door.

X2_FLAG_DOOR_RESIST_KNOCK:
-Set to 1 to prevent knock from working with feedback.
-Set to 2 to prevent knock from working without feedback.
SetExecutedScriptReturnValueSets the return value for scripts called via ExecuteScriptAndReturnInt.

Valid values are:
- X2_EXECUTE_SCRIPT_CONTINUE - continue calling script after executed script is done.
- X2_EXECUTE_SCRIPT_END - end calling script after executed script is done.
SetItemFlagToggles a flag's setting on an item.
SetModuleOverrideSpellscriptAllows the module creator to specify a script that will be run before any spell script is run.

You can call SetModuleOverrideSpellscript() at the end of the script specified by sScriptName.

If you call this function this will prevent the original spell script (and all craft item code) from being executed.

If you do not add this line, the original spell script and/or crafting code will run in addition to your script.
SetModuleOverrideSpellScriptFinishedInternal function. You can call this in the overridden spell script. If you call this, it will prevent the original spell script (and all craft item code) from being executed. If you do not add this line, the original spell script and/or crafting code will run in addition to your script.
SetModuleSwitchUsed to switch between different rule implementations or to subsystems for the game.

See constants list above for more detailed information on these switches.
SetUserDefinedItemEventNumberSet the active User Defined Item Event.
- X2_ITEM_EVENT_ACTIVATE
- X2_ITEM_EVENT_EQUIP
- X2_ITEM_EVENT_UNEQUIP
- X2_ITEM_EVENT_ONHITCAST
- X2_ITEM_EVENT_ACQUIRE
- X2_ITEM_EVENT_UNACQUIRE
- X2_ITEM_EVENT_SPELLCAST_AT
SetUserDefinedItemEventPrefixThis is a security feature.

If you are running a *local vault* server and you have tag based script execution enabled, people could bring items into your game that execute existing scripts.

You can set a script prefix here to prevent that.

Note that you have to add this prefix to your item scripts in the module to make them work.
SetWanderingMonster2DAFileDefine the name of the 2da file which is used for the wandering monster system.

See Also

categories:  Module Functions

  author: Mistress, contributor: Graewerld