Constants

Constants are names that usually represent a numeric value. Constants are used because they act as a single point of entry for a particular value (for example if you need to change the year from 2002 to 2003, rather than updating the number from 2002 to 2003 in a dozen or more places you would just update the constant value YEAR). Constants are also used because they give human readable names to numeric codes (its easier to discern that WHITE means the color white than its integer counterpart, #ffffff). Constants are unlike variables because their values cannot be changed. When compiled, the precompiler will go through the source code and strip out any constant expressions, replacing them with their actual values.


The const keyword is now available for making real constants (rather than declaring variables for a value).

Constant Groups

Constant GroupDescription
ABILITY_*The standard six ability scores.
AC_*Armor class adjustments.
ACTION_*Standard actions.
ACTION_MODE_*Action modes a creature can enter. Used with SetActionMode and GetActionMode.
AI_LEVEL_*Determines the AI (artificial intelligence) level of a creature controlled by the computer. The AI level determines how "smart" the creature is by how much CPU time is given to it.
ALIGNMENT_*Alignment settings (covers both ethos and disposition).
AMBIENT_SOUND_*These constants must match those in the AmbientSound.2da.
ANIMAL_COMPANION_CREATURE_TYPE_*Categories of possible animal companions. Note that animal companions are different from familiars.
ANIMATION_*List of animations.
AOE_MOB_*Area effects with mobile areas. Usually fixed on a mobile creature or target.
AOE_PER_*Area effects centered on a fixed point.
APPEARANCE_TYPE_*Determines the physical appearance of a creature.
AREA_*Constants pertaining to the properties of the area as set in the area's properties, and used with GetIsAreaAboveGround and GetIsAreaNatural.
AREA_TRANSITION_*Defines the various different categories of area transition screens that are displayed when an area is loading.
ASSOCIATE_COMMAND_*Used to define various commands that can be issued to NPC associates.
ASSOCIATE_TYPE_*Various groups of NPC companions available to a play character.
ATTACK_BONUS_*Used to specify which attacks are modified by an EffectAttackIncrease() or EffectAttackDecrease() effect.
ATTITUDE_*Determines attitudes between creatures.
BASE_ITEM_*Base items that other items can be built on top of.
BODY_NODE_*Location on a body; either hand or chest. Used for the EffectBeam effect.
CAMERA_MODE_*Selects one of the three perspective views available in the game.
CAMERA_TRANSITION_TYPE_*Used with SetCameraFacing() to determine how smoothly to transition the camera.
CLASS_TYPE_*Defines the standard class types.
COMBAT_MODE_*Different combat modes.
COLOR_CHANNEL_*UNKNOWN
CREATURE_MODEL_TYPE_*UNKNOWN
CREATURE_PART_*For use with GetCreatureBodyPart() and SetCreatureBodyPart().
CREATURE_SIZE_*The size classes that creatures can belong to. Does not include gargantuan and colossal.
CREATURE_TAIL_TYPE_*For use with GetCreatureTailType() and SetCreatureTailType().
CREATURE_TYPE_*NWN-specific subtype denoting special attributes for a given creature.
CREATURE_WING_TYPE_*For use with GetCreatureWingType() and SetCreatureWingType().
DAMAGE_BONUS_*Determines magical adjustments to damage. Not treated the same as DAMAGE_POWER_*, which determines if an attack can penetrate damage reduction.
DAMAGE_POWER_*Determines the magical strength of a melee or missile attack (for harming creatures with damage reduction). Does not determine actual magical bonus (see DAMAGE_BONUS_*), just determines what damage reductions an attack bypasses.
DAMAGE_TYPE_*The type of damage that can be inflicted.
DC_*Difficulty Class constants used by the AutoDC function. These constants require you to include nw_i0_plot, which is where they are declared. They are in this order, difficulty wise: DC_EASY DC_MEDIUM DC_HARD DC_SUPERIOR DC_MASTER DC_LEGENDARY DC_EPIC
DEFENSIVE_CASTING_MODE_*Determines if a creature is casting a spell defensively so they suffer no attacks of opportunity.
DETECT_MODE_*Determines how a perceptive a creature is being.
DIRECTION_*Used for determining compass direction.
DISEASE_*Different types of Diseases used in creating disease effect objects.
DISTANCE_*Distances used for determining positions.
DOOR_ACTION_*A list of actions that can be done on a door.
DURATION_TYPE_*Duration types for ApplyEffectAtLocation and ApplyEffectToObject functions.
EFFECT_TYPE_*Constants that reflect the different effects that can be applied to creatures.
ENCOUNTER_DIFFICULTY_*The list of encounter difficulties.
EVENT_*User-defined event codes.
FADE_SPEED_*Determines the amount of time a fade screen effect takes.
FAMILIAR_CREATURE_TYPE_*Familiars are creatures specially summoned and bound to a wizard or sorcerer. They help the caster with tasks such as gathering spell components, delivering messages, or even combat, although most of them just perch on the wizards shoulder or pointing hat and grin impishly. When a wizard's or sorcerer's familiar dies, the caster suffers physical shock. Note that familiars are different from animal companions.
FEAT_*Constants that deal with different feats that can be performed.
FOG_COLOR_*The color of the fog, to be specified within SetFogColor(). Remember to check the documentation of SetFogColor() for the ability to get exactly the right color you want.
FOG_TYPE_*For use with SetFogColor(), it is to specify which time of day the color change will affect.
FOOTSTEP_TYPE_*For use with GetFootstepType() and SetFootstepType().
GAME_DIFFICULTY_*Specifies the list of available setting for game difficulty.
GENDER_*List of genders
GlobalsGlobal, non-grouped constant values.
GUI_PANEL_*List of all graphical panels (dialogs in windows programming terminology).
IMMUNITY_TYPE_*Constants to identify different immunities that creatures could possible have.
INVENTORY_DISTURB_TYPE_*The list of possible ways an inventory can be disturbed.
INVENTORY_SLOT_*Constant group for inventory equipment slots. These are the slots where items are placed when that are equiped (in use), and not the slots where items are just stored. Also there exists a constant NUM_INVENTORY_SLOTS which can be used with a for loop as an upper limit (start at 0) to iterate through all inventory slots for equiped items.
INVISIBILITY_TYPE_*Determines how a creature is protected from the sight of other creatures.
IP_CONST_ABILITY_*Itemproperty constants regarding abilities.
IP_CONST_ACMODIFIERTYPE_*Itemproperty constants relating to armor class modifier types.
IP_CONST_ADDITIONAL_*UNKNOWN
IP_CONST_ALIGNMENT_*Itemproperty constants relating to specific alignments, such as AC bonus against an alignment.
IP_CONST_ALIGNMENTGROUP_*Constants used for itemproperties relating to specific alignment groups - for instance AC bonus vs an alignment group.
IP_CONST_AMMOTYPE_*Different types of ranged ammuniations.
IP_CONST_ARCANE_SPELL_FAILURE_*Itemproperty constants relating to arcane spell failure.
IP_CONST_CASTSPELL_*Itemproperty constants for adding "cast spell" to items.
IP_CONST_CASTSPELL_NUMUSES_*Itemproperty constants relating to the number of uses an item has of a specific spell.
IP_CONST_CLASS_*Itemproperty constants relating to classes.
IP_CONST_CONTAINERWEIGHTRED_*Itemproperty constants relating to containers reducing the weight of their contents.
IP_CONST_DAMAGEBONUS_*Itemproperty constants relating to damage bonus.
IP_CONST_DAMAGEIMMUNITY_*Itemproperty constants relating to damage immunity.
IP_CONST_DAMAGEREDUCTION_*Itemproperty constants relating to damage reduction.
IP_CONST_DAMAGERESIST_*Itemproperty constants relating to damage resistance.
IP_CONST_DAMAGESOAK_*Itemproperty constants relating to damage soaking.
IP_CONST_DAMAGETYPE_*Constants relating to itemproperties specific to damagetypes, such as AC bonus against a specific damagetype.
IP_CONST_DAMAGEVULNERABILITY_*Itemproperty constants relating to damage vulnerability.
IP_CONST_FEAT_*Constants for feat related itemproperties. The descriptions here are identical to the ones in the FEAT_* constants section. Far from all the feats can be added to items. Note that even if a description says that a feat requires a prerequisite, this isn't the case when granting that feat through the use of an item.
IP_CONST_IMMUNITYMISC_*Itemproperty constants relating to miscellaneous immunities.
IP_CONST_IMMUNITYSPELL_*Itemproperty constants relating to spell immunities.
IP_CONST_LIGHTBRIGHTNESS_*Itemproperty constants relating to the brightness of light an item emits.
IP_CONST_LIGHTCOLOR_*Itemproperty constants relating to the color of light an item emits.
IP_CONST_MONSTERDAMAGE_*Different damage range (dice) for monsters.
IP_CONST_ONHIT_*Itemproperty constants relating to when a weapons successfully hits something.
IP_CONST_ONHIT_CASTSPELL_*Itemproperty constants relating to OnHit: Cast spell. Please consult the SPELL_* constant section of the Lexicon for further info.
IP_CONST_ONHIT_DURATION_*Itemproperty constants relating to the duration / percentage of effecting the target of certain OnHit properties.
IP_CONST_ONHIT_SAVEDC_*Itemproperty constants relating to the save DC (saving throw difficulty class) against an OnHit property.
IP_CONST_ONMONSTERHIT_*Special abilities a monster can perform when it scores a successful hit.
IP_CONST_POISON_*Itemproperty constants relating to OnHit: poison.
IP_CONST_QUALITY_*UNKNOWN
IP_CONST_RACIALTYPE_*Itemproperty constants relating to racial types - e.g. AC bonus against a certain racial type.
IP_CONST_REDUCEDWEIGHT_*Constants for the reduced weight itemproperty.
IP_CONST_SAVEBASETYPE_*Itemproperty constants relating to saving throw base types.
IP_CONST_SAVEVS_*Itemproperty constants relating to saving throws versus specific effects or damage types.
IP_CONST_SPELLLEVEL_*Denotes different levels of magical spells.
IP_CONST_SPELLRESISTANCEBONUS_*Itemproperty constants relating to spell resistance bonuses.
IP_CONST_SPELLSCHOOL_*Itemproperty constants relating to spell schools.
IP_CONST_TRAPSTRENGTH_*Itemproperty constants relating to traps' strength.
IP_CONST_TRAPTYPE_*Itemproperty constants relating to trap types.
IP_CONST_UNLIMITEDAMMO_*Itemproperty constants relating to unlimited ammunition.
IP_CONST_WEIGHTINCREASE_*Itemproperty constants relating to weight increase of items.
ITEM_APPR_*Various item appearance constants which describe the way certain classes of items can appear.
ITEM_PROPERTY_*Magical or other properties that can be applied to an item.
ITEM_VISUAL_*Visual effects performed by an item.
METAMAGIC_*Metamagic feats applied to a spell.
MISS_CHANCE_TYPE_*Used to specify the miss chance type for EffectMissChance.
NAME_*These constants determine which name table to use when generating random names.
NW_ASC_*Covers miscellaneous skills and settings not categorized into other subgroups. These are not actually constants, and do not exist in nwscript.nss. To use these, you must include nw_i0_generic.
NW_ASC_AGGRESSIVE_*Determines what skills or abilities an NPC associate uses automatically. These are not actually constants, and do not exist in nwscript.nss. To use these, you must include x0_i0_assoc.
NW_ASC_DISTANCE_*Determines the distance, in meters, the NPC associate follows the PC at. These are not actually constants, and do not exist in nwscript.nss. To use these, you must include nw_i0_generic.
NW_ASC_HEAL_AT_*Used to determine at which percentage of the master's hit points an NPC associate should attempt to heal the master. These are not actually constants, and do not exist in nwscript.nss. To use these, you must include nw_i0_generic.
NW_FLAG_*Used to cause events to fire various numeric signals to OnUserDefined and set other attributes of a creature during the OnSpawn script using SetSpawnInCondition. The OnUserDefined event can thus be used to customize the behavior of an object without actually modifying the default behavior.
NW_FLAG_BEHAVIOR_*Determines how an NPC reacts, irregardless of faction.
OBJECT_TYPE_*Used to categorize types of objects.
PACKAGE_*Represent the default packages for classes. Used in conjunction with the LevelUpHenchman command.
PANEL_BUTTON_*Client panel buttons including character sheet, inventory, journal, map, options, player vs player, resting and spellbook.
PERCEPTION_*Determines if a creature perceives another creature using its Spot skill vs. the other creature's Hide skill and its Listen skill vs. the other creature's Move Silently skill.
PERSISTENT_ZONE_*Used with GetFirstInPersistentObject() and GetNextInPersistentObject() functions.
PHENOTYPE_*Phenotype constants (all 3) are meant to be used with the functions GetPhenoType() and SetPhenoType(). They should really only be used by custom content people who aim to take advantage of the new way of altering a Player Characters appearance easily.
PLACEABLE_ACTION_*Actions that can be performed on placeable objects.
PLAYER_CHAR_*Used for testing if a PC is actually controlled by a player.
POISON_*This constant group defines the many in game poisons.
POLYMORPH_TYPE_*These constants define the properties applied to targets when they are polymorphed into different creatures.
PROJECTILE_PATH_TYPE_*Different types of project paths (the path a missile weapon or other projectile follows as it travels).
QUEST_*Various quest statuses for quest functions.
RACIAL_TYPE_*Constants used to identify different races (human, dwarf etc)
RADIUS_SIZE_*Different degrees of radius size used in area-based functions.
REPUTATION_TYPE_*Determines how creatures react to one another.
REST_EVENTTYPE_*Determines the status of the last rest event for the PC.
SAVING_THROW_*Core saving throws.
SAVING_THROW_TYPE_*Describes different saving throw types.
SHAPE_*SHAPE_* constants are used in the GetFirstObjectInShape() and GetNextObjectInShape() functions.
SKILL_*Skills used in NWN. The SKILL_* constants are actually integers, the corresponding values of which can be found in nwscript.nss. Those integers, in turn, are references to row-numbers in the gamefile skills.2da.
SKYBOX_*Skybox constants must match those in the skyboxes.2da file. They are to be used with the SetSkyBox() function.
SPECIAL_ATTACK_*Special attacks that can be performed during combat.
SPELL_*Magical spells cast by classes such as wizards, sorcerers, bards, clerics, and druids. More information about what the spells do can be found in the descriptions in manuals / spell scrolls, and by looking in the "spells.2da" file. Known bug: the spells which summon elements (Summon Creature VII through IX) can successfully summon air, water, and fire elements, but earth elements cannot be summoned.
SPELL_CRAFT_*Unknown.
SPELL_SCHOOL_*Schools of spells.
SPELLABILITY_*Magical spell-like abilities some creatures possess.
STANDARD_FACTION_*The four generic factions used to determine enmity and friendship by NPCs.
STEALTH_MODE_*Determines if stealth mode (moving silently, hiding in shadows) is activated. Characters move slower when stealth mode is activated.
STRING_COLOR_*Used to specify predefined RGB encoded colorization strings used with the StringToRGBString function.

Requires #include x3_inc_string.
SUBSKILL_*Subskills for dealing with traps; additions for Rogues to their standard Search skill.
SUBTYPE_*Effect subtypes.
TALENT_CATEGORY_*Groups the talents into categories.
TALENT_TYPE_*Primary category of talents for use by creatures in game.
TALKVOLUME_*Sets the broadcast range of text displayed using SpeakString() and ActionSpeakString() functions.
TILE_MAIN_LIGHT_COLOR_*List of available colors to be used as the main light source of a tile.
TILE_SOURCE_LIGHT_*Colors for dynamic lighting to shine upon tiles.
TILESET_RESREF_*The following resrefs (string format) must match those in the tileset's set file.
TRACK_*Musical tracks played throughout the game.
TRAP_BASE_TYPE_*Used to catagorize the strength and type of traps.
TREASURE_*Treasure types.
VFX_BEAM_*Beams fire in a straight line towards their targets. These constants are actually integers which can be found in nwscript.nss and refer to row numbers in the file visualeffects.2da - this file also contains visual effects for which there are no constants. If you want to use one of those, just use EffectVisualEffect(XXX) where XXX is the rownumber.
VFX_COM_*Common visual special effects. These constants are actually integers which can be found in nwscript.nss and refer to row numbers in the file visualeffects.2da - this file also contains visual effects for which there are no constants. If you want to use one of those, just use EffectVisualEffect(XXX) where XXX is the rownumber.
VFX_DUR_*Temporary visual effects that last for a specified duration. These constants are actually integers which can be found in nwscript.nss and refer to row numbers in the file visualeffects.2da - this file also contains visual effects for which there are no constants. If you want to use one of those, just use EffectVisualEffect(XXX) where XXX is the rownumber.
VFX_EYES_*Race specific glowing eye effects. These constants are actually integers which can be found in nwscript.nss and refer to row numbers in the file visualeffects.2da - this file also contains visual effects for which there are no constants. If you want to use one of those, just use EffectVisualEffect(XXX) where XXX is the rownumber.
VFX_FNF_*Bigger, flashier visual effects. These constants are actually integers which can be found in nwscript.nss and refer to row numbers in the file visualeffects.2da - this file also contains visual effects for which there are no constants. If you want to use one of those, just use EffectVisualEffect(XXX) where XXX is the rownumber.
VFX_IMP_*Impact visual effects that are generally used for spells when the spell effect hits someone. VFX_IMP_* -type effects can only be applied with DURATION_TYPE_INSTANT These constants are actually integers which can be found in nwscript.nss and refer to row numbers in the file visualeffects.2da - this file also contains visual effects for which there are no constants. If you want to use one of those, just use EffectVisualEffect(XXX) where XXX is the rownumber.
VOICE_CHAT_*List of character voice sayings.
WEATHER_*Different weather types.
X2_IP_ADDPROP_POLICY_*These constants are only available if you include x2_inc_itemprop in your script. They are used in the IPSafeAddItemProperty command in the same include file and determine what should happen when adding a type of itemproperty to an item that already has one of that type.
X2_IP_ARMORTYPE_*Armortype constants for use with various of the x2_inc_itemprop itemproperty functions.
X2_TL_GROUNDTILE_*Tile visual effects for use with the tile magic (tm) system.