You are here

Tutorial: What are the module switches and how to configure them.

just for illustration
example module variables with module switches
example how to activate module switch by scripting
Community Patch PC Widget Tool allows to alter several module switches

What are the module switches?

A module switch is basically a toggleable and optional feature/ruleset that applies only to the module you play or build. This allows to alter module rules on the fly as module switches can be activated/deactivated even during play either by script, Dungeon Master or player (in case of single player modules where PC can use console). Technically, the module switch is a module variable and the actual effects are coded elsewhere (spell scripts, crafting scripts, various other scripts) depending on that variable. Most module switches has only two states, actived and deactivated (default state), but some might permit for multiple options based on a value: 1 do this 2 this and 3 that, etc. There are 17 different module switches in standard game patched to 1.69, but new module switches can be obtained by custom content or in unofficial patches (Community Patch). In this case the module switches names and values should be mentioned in the readme included with the custom content.

Note: This system has been introduced in Hordes of Underdark expansion so it might require HotU to work. (But who doesn't have expansions anyway?)

How to configure the module switch?

There are several ways to do this. But by default, only a module builder can do this. Dungeon Master neither player are not able to do this because they cannot "mark" the module object. However Community Patch allows this so I will describe how below.

Note, each module switch has a module switch name and variable name. This is important to distinguish because variable name is what you need to use when setting module switch by variable on module and module switch name is what you need to put into Set/GetModuleSwitchValue function.

1) The most straightforward way to do this is by setting a variable on module in toolset (see the second image). Open the module, go to Edit - Module Properties - Advanced - Variables. Write a variable (not module switch!!) name into first field, and the value (usually 1) to the third field, variable type should be int. Then press Add. Repeat for every module switch you want to add. Then press OK and save module.

2) Another option is to modify the x2_mod_def_load script. You should use (or call with ExecuteScript command) script x2_mod_def_load in your OnModuleLoad event (it's a default script there so if you haven't modified anything its probably there). Alternatively you can have x3_mod_def_load there, that works as well. Now, in this script there are most module switches written but deactivated (commented out). To activate them you need to delete the two "//" in front of the line that starts with "SetModuleSwitch" (see third image). Then save&compile the script and thats it. If for some reason the module switch you want is not written there, you need to use third option.

3) Or you can set module switch by scripting yourself. This doesn't even have to be in OnModuleLoad script, you can set module switch anywhere, for example in a specific area's OnEnter script. To do this you need to include 'x2_inc_switches' library by writing:
#include "x2_inc_switches"
above void main() line. Then you can activate switch with the same code that you can see in the x2_mod_def_load script. Like this:
SetModuleSwitch (MODULE_SWITCH_*, TRUE);
to activate the switch, or
SetModuleSwitch (MODULE_SWITCH_*, FALSE);
to deactiave the switch, which can be usefull if you enabled the switch at start and now you want to perhaps temporarily disable it. Or you can specify also other values such as 2,3 - if the specific switch allows that. Don't forget to compile and save the script.
Note: althought you could actually set module switch also by SetLocalInt(GetModule(),"MODULE_SWITCH_VARIABLE_NAME"); I advise to always use Set/GetModuleSwitchValue function though. It's better to do it this way to enable Community Patch 1.72 module switch improvements which wouldn't be working with SetLocalInt. But otherwise it also a way to do it.

These three methods are the only methods in vanilla NWN and are available only to module builder or module "holder" from toolset. Community Patch 1.70+ allows to modify specific module switches even to Dungeon Master or player in game. To do this.

1) If you are not a player, activate a Debug mode by typing into chat '##DebugMode 1'.
2) move the mouse cursor on ground near character by typing into chat '##dm_spawnitem 70_pcwidget'. An item called PC Widget Tool should appear on the cursor location.
3) pick up the item and activate it, a conversation like the one at fourth image should appear, where you should be able to activate/deactivate most useable switches anytime in game.
Note: the module switches are normally applicable only for given module and so if you are playing campaign where each chapter is different module you will need to set module switches by PC Widget Tool again. This has been resolved in CP 1.72 where module switches are global and apply to all modules you play (more on this in special section below).

 

Vanilla NWN Module Switches:

Module Switch name: MODULE_SWITCH_AOE_HURT_NEUTRAL_NPCS
Variable name: X0_G_ALLOWSPELLSTOHURT
Description: Toggle 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 name: MODULE_SWITCH_DISABLE_AI_DISPEL_AOE
Variable name: X2_L_AI_NO_AOE_DISPEL
Description: If this variable is set, the AI will not use Dispel Magic against harmful AOE spells.

Module Switch name: MODULE_SWITCH_DISABLE_ITEM_CREATION_FEATS
Variable name: X2_SWITCH_DISABLE_ITEMCREATION_FEATS
Description: Toggle on/off the Item Creation Feats. Default = FALSE. Disable the Item Creation Feats that come with Hordes of the Underdark (Scribe Scroll, Brew Potion, Craft Wand) for the module.

Module Switch name: MODULE_SWITCH_DISABLE_SECRET_DOOR_FLASH
Variable name: X2_SWITCH_DISABLE_SECRET_DOOR_FLASH
Description: Setting this switch to TRUE will disable the glow of a newly found secret door used in some locations in XP2.

Module Switch name: MODULE_SWITCH_ENABLE_BEBILITH_RUIN_ARMOR
Variable name: X2_SWITCH_BEBILITH_HARDCORE_RUIN_ARMOR
Description: If 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 name: MODULE_SWITCH_ENABLE_CRAFT_WAND_50_CHARGES
Variable name: X2_SWITCH_ENABLE_50_WAND_CHARGES
Description: For balancing reasons the crafting system won't create 50 charges on a new wand, but instead it will create 10 + casterlevel charges. If you want to be "hard core rules compliant" 50 charges, enable this switch.

Module Switch name: MODULE_SWITCH_ENABLE_CROSSAREA_WALKWAYPOINTS
Variable name: X2_SWITCH_CROSSAREA_WALKWAYPOINTS
Description: Setting this switch to TRUE will enable to 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 name: MODULE_SWITCH_ENABLE_INVISIBLE_GLYPH_OF_WARDING
Variable name: X2_SWITCH_GLYPH_OF_WARDING_INVISIBLE
Description: Setting this switch to TRUE will make the Glyph of Warding symbol disappear after 6 seconds, but the glyph will stay active....

Module Switch name: MODULE_SWITCH_ENABLE_MULTI_HENCH_AOE_DAMAGE
Variable name: X2_SWITCH_MULTI_HENCH_AOE_MADNESS
Description: Multiple 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 name: MODULE_SWITCH_ENABLE_NPC_AOE_HURT_ALLIES
Variable name: X2_SWITCH_ENABLE_NPC_AOE_HURT_ALLIES
Description: Spell 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 name: MODULE_SWITCH_ENABLE_TAGBASED_SCRIPTS
Variable name: X2_SWITCH_ENABLE_TAGBASED_SCRIPTS
Description: Setting 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_*).
Note: This switch is activated by default int x2_mod_def_load or x3_mod_def_load scripts.

Module Switch name: MODULE_SWITCH_ENABLE_UMD_SCROLLS
Variable name: X2_SWITCH_ENABLE_UMD_SCROLLS
Description: Force 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.
Note: This switch is activated by default in x2_mod_def_load or x3_mod_def_load scripts if the game is started on Harcore/Very High difficulty, but its not automatically deactivated with lowering the difficulty later!

Module Switch name: MODULE_SWITCH_EPIC_SPELLS_HURT_CASTER
Variable name: X2_SWITCH_EPIC_SPELLS_HURT_CASTER
Description: Some 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 name: MODULE_SWITCH_NO_RANDOM_MONSTER_LOOT
Variable name: X2_L_NOTREASURE
Description: Setting this variable to TRUE on the module will disable the call to the random loot generation in most creatures' OnSpawn script.

Module Switch name: MODULE_SWITCH_RESTRICT_USE_POISON_TO_FEAT
Variable name: X2_SWITCH_RESTRICT_USE_POISON_FEAT
Description: By 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 name: MODULE_SWITCH_SPELL_CORERULES_DMASTERTOUCH
Variable name: X2_SWITCH_SPELL_CORERULE_DMTOUCH
Description: Deathless 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 name: MODULE_SWITCH_USE_XP2_RESTSYSTEM
Variable name: X2_SWITCH_ENABLE_XP2_RESTSYSTEM
Description: Setting 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).       

 

Community Patch Module Switches:

The variable name prefix implies which version was the specific module switch added. Thus if you aren't using 1.72, the 72_ module switches aren't applicable for you.

Module Switch name: MODULE_SWITCH_DEVASTATING_CRITICAL_ONCE_PER_TARGET
Variable name: 72_DEVAST_ONCE_PER_TARGET
Description: This switch will enforce a one roll only rule for devastating critical ability. This is a very efficient method of making this feat more balanced yet still allow to slain a monster with single blow as this was designed.

Module Switch name: MODULE_SWITCH_POLYMORPH_MERGE_EVERYTHING
Variable name: 72_POLYMORPH_MERGE_EVERYTHING
Description: This switch will allow to merge every items the character wears into every polymorph shape in game even Tenser's transformation. This automatically enable the "merge arms" switch.
Note: for unarmed shapes only defensive properties from weapon will merge.

Module Switch name: MODULE_SWITCH_SOU_EMPOWER_SPELL_BEHAVIOR
Variable name: 71_SOU_EMPOWER_SPELL_BEHAVIOR
Description: This switch will change the behavior of the Empower Spell feat to what it was introduced in the Shadows of the Undertide expansion. This behavior empowers only the result of the dice values and any bonus is just added to the result.

Module Switch name: MODULE_SWITCH_UNLIMITED_SUMMONING
Variable name: 71_UNLIMITED_SUMMONING
Description: This switch will allow to summon and keep multiple creatures at the same time. Value of 1 means unlimited summoning, while higher values holds a max limit of the number of summoned creatures at the same time.

Module Switch name: MODULE_SWITCH_POLYMORPH_STACK_MERGED_BONUSES
Variable name: 71_POLYMORPH_STACK_ABILITY_BONUSES
Description: This switch will enable stacking some of the item properties merged on skin when polymorhing. By default only highest bonus applies. With this switch active, all ability bonuses, ability penalties, stacks together.
Note: 1.72 enables stacking of skill bonuses, skill penalties, saving throw bonuses and saving throw penalties along with abilities.

Module Switch name: MODULE_SWITCH_POLYMORPH_MERGE_ARMS
Variable name: 71_POLYMORPH_MERGE_ARMS
Description: This switch will merge bracers or gloves in the "items" category.

Module Switch name: MODULE_SWITCH_PALEMASTER_ADDS_CASTER_LEVEL
Variable name: 71_PALEMASTER_ADDS_CASTER_LEVEL
Description: This switch will apply Pale Master levels into the caster level calculation. This works only for arcane spells cast normally, this won't work for arcane spells cast from item, as special ability or from feat. This feature is taking into consideration the 2da settings in classes.2da if the builder changes the ArcSpellLvlMod for PM the formula will respect this.

Module Switch name: MODULE_SWITCH_RESTRICT_MUSICAL_INSTRUMENTS
Variable name: 71_RESTRICT_MUSICAL_INSTRUMENTS
Description: This switch will restrict usage of musical instruments by a two choices:
With value 1, instruments will be restricted to the Perform skill, DC for success is then same as for UMD, 7+(3*SpellLevel)
With value 2, instruments will be restricted to the bard song feat, just the way the Lich lyric are, each casting will decrement one use of the bard song feat
Note: 1.72 adds a value of 3 to combine both restrictions. Also this switch can be set to specific item and will override module-wide settings (so its possible to make an item without restriction when restrictions are enabled or unique item with both restrictions while not imposing any restriction on other musical instruments)

Module Switch name: MODULE_SWITCH_SHORTENED_DURATION_OF_DISABLE_EFFECTS
Variable name: 71_SHORTENED_DURATION_OF_DISABLE_EFFECTS
Description: This switch will change the behavior of GetScaledDuration function and allow to shorten duration of disable effects from spells to 3 rounds considering who is target and who is caster. By default duration is scaled only for "disable" effects like fear or paralysis. Note: this affects all spells and special abilities that apply stunning, confusion, paralysis, fear, charm, dominate and entangle/immobility effects, but it affects only spells/abilities with 1round/x levels calculation, not those with drect duration such as 1d6rounds.
Values:
1: apply only when caster isn't PC and target is PC or his associate
2: apply regardless of who is caster but only when target is PC or his associate
3: apply regardless of who is caster and who target

Module Switch name: MODULE_SWITCH_ALLOW_POISON_STACKING
Variable name: 71_ALLOW_POISON_STACKING
Description: Set to TRUE if you want to allow stack poisons. By default, character cannot be poisoned anymore if he is poisoned already. With this switch, the poison effect itself is removed from character with also the green HP bar indicating that player is poisoned but the poison is still running in background, unless cured. Standard methods for removing poison except healer's kit will still work.
Warning: This can inbalance your modules if you have many monsters with poisonous claws etc. In such environment, it is recommend to balance and lower the ability damages of the all poisons in poison.2da. Otherwise it might be very harsh.

Module Switch name: MODULE_SWITCH_ALLOW_BOOST_GLOVES
Variable name: 71_ALLOW_BOOST_GLOVES
Description: By setting this to TRUE, weapon-boost spells like flame weapon will be able to target and boost gloves just like any other weapon. Does affects only gloves (offensive), not bracers (defensive), keep that in mind.

Module Switch name: MODULE_SWITCH_AOE_HEARTBEAT_WORKAROUND
Variable name: 70_AOE_HEARTBEAT_WORKAROUND
Description: Set to TRUE if you have issues with AOE spells not working properly - not running their heartbeat. Then spellscripts will use special workaround that fixes it. In addition to this it is recommend to remove references to all hearbeats scripts in vfx_persistent.2da

Module Switch name: MODULE_SWITCH_SPELL_MANTLE_169_BEHAVIOR
Variable name: 70_RESISTSPELL_SPELLMANTLE_GOES_FIRST
Description: Set to TRUE if you don't want the new ResistSpell behavior where spell immunity is checked before spell mantle from community patch.

Module Switch name: MODULE_SWITCH_OVERFILLED_STORES_ISSUE_FIX
Variable name: 70_OVERFILLED_STORES_ISSUE_FIX
Description: Set this switch if you have issues with stores overfilled with sold items causing huge lags when opened. This switch in fact controls how many items sold by players can be in single store in one time. Older items will disappear when this cap is reached. Recommend value is 100.


Community Patch 1.72 Module Switches Improvement info

1.72 made module switches globalized. This was only logical because players playing single player modules wanted to apply their ruleset choices to every module as previously all module switches had to be reactivated in every module again from scratch.

Note this whole section applies only for Single Player modules. Player cannot interfere with module switches on a PW or LAN game where he is not host. So if you are PW admin you don't have to read nor worry any further.

This introduced a new behavior and new options for module builders. Since technically the player activated module switches are stored in database there exists two places where switch can be set - database and module. If a module switch is activated in module, it has a priority over player's decision. However, the problem is that most module switches are explicitely beneficial and module builder might not want to allow player to have unlimited summons etc.. To do this, module builder needs to set the module switch variable manually (method 1) but as a string type instead with value 0. This is the only way how to prioritize specific module switch to be deactivated in your module.

Note however, that player will be able to overwrite module switches in your module with PC Widget Tool anyway. To disallow this, you need to open the 70_pcwidget conversation in conversation editor, delete all nodes and save. This will make sure the player won't be able to interfere with ruleset in your module (unless the player open the module in toolset and modify it of course).

 

First Release: 
  • up
    100%
  • down
    0%