Constants

定数とは数値を表す名称です。

定数は特定の値を表す記述として一ヶ所で定義しておけば、ソースコード上のその定数は全て同じ数値として振る舞います。

例えば年数を表す数値をソースコード上で扱います。その値を2002から2003に変更しようとします。

ソースコード上のあちこちにある2002という記述を2003に変更するよりも、定数"YEAR"をソースコード上に用いておけば、あとから"YEAR"の定義を2002から2003に変更するだけで済むのです。


また、定数は一意の名前を付けることにより、人間が解釈しやすいようにするといった用途でも用いられます。

例えば、白を表す数値(0xFFFFFF)の代わりにWHITEと書いた方が解釈しやすいでしょう。

定数は変数と異なり一定の値をとり、その値を動的に変えることはできません。

コンパイル時にプリコンパイラーがソースコード上の定数を意味するコードを探し出して実際の数値に置き換えます。

Constant Groups

Constant GroupDescription
ABILITY_*キャラクターの基本的な6つの能力値
AC_*アーマークラス修正
ACTION_*標準のアクション
AI_LEVEL_*クリーチャーを動かしているAI(人工知能)のレベルを定めます。
AIのレベルが”高度”ということはCPU時間がより多いということです。
ALIGNMENT_*属性の設定。気質(善と悪)と、道徳的規範(秩序と混沌)を含んでいます。
ANIMAL_COMPANION_CREATURE_TYPE_*動物の相棒に出来るカテゴリー。動物の相棒と使い魔が異なることに注意してください。
ANIMATION_*アニメーションのリスト
AOE_MOB_*範囲エフェクトです。通常は移動するクリーチャーに設定されます。
AOE_PER_*ある一点を中央とした範囲エフェクトです。位置のデータタイプは不明。
APPEARANCE_TYPE_*プレイヤーキャラクターが仲間に出来るNPCの種類。
AREA_TRANSITION_*エリアをロード中に表示される画面の種類。
ASSOCIATE_COMMAND_*仲間のNPCに対する命令
ASSOCIATE_TYPE_*プレイヤーキャラクターが仲間に出来るNPCの種類。
ATTACK_BONUS_*EffectAttackIncrease()とEffectAttackDecrease()によって修正される種類
ATTITUDE_*クリーチャー間の態度
BASE_ITEM_*Base items that other items can be built on top of.
BODY_NODE_*体の位置;手と胸。
EffectBeamエフェクトで使用されます。
CAMERA_MODE_*カメラ視点
CAMERA_TRANSITION_TYPE_*SetCameraFacing() でどの程度スムーズにカメラを移動させるかの設定
CLASS_TYPE_*クラス
COMBAT_MODE_*Different combat modes.
CREATURE_SIZE_*The size classes that creatures can belong to. Does not include gargantuan and colossal.
CREATURE_TYPE_*NWN-specific subtype denoting special attributes for a given creature.
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.
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_*コンパスの方角
DISEASE_*Different types of Diseases used in creating disease effect objects.
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_*使い魔とはウィザードやソーサラーに特別に召喚され、仕えるクリーチャーです。

彼らは術者の仕事を手伝います。例えば呪文のスクロールを集めたり、メッセージを届けたり、戦闘さえも参加します。

しかしたいていは術者の肩や帽子の先に停まり、腕白な笑みをもらしています。

ウィザードやソーサラーの使い魔が死ぬと術者は肉体的なショックを受けます。(1d6ダメージ)

使い魔と動物の相棒は異なることに注意してください。

FEAT_*Constants that deal with different feats that can be performed.
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.
ITEM_PROPERTY_*Magical or other properties that can be applied to an item.
METAMAGIC_*Metamagic feats applied to a spell.
MISS_CHANCE_TYPE_*Used to specify the miss chance type for EffectMissChance.
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_AGRESSIVE_*Determines what skills or abilities an NPC associate uses automatically. These are not actually constants, and do not exist in nwscript.nss. Not sure if these even exist anymore unlike the other NW_ASC constants (well, variables), they are not defined in nw_i0_generic. If you know where these constants / variables are defined, please contact the Lexicon makers.
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. These are not actually constants, and do not exist in nwscript.nss. To use these, you must include nw_i0_generic.
NW_FLAG_BEHAVIOR_*Determines how an NPC reacts, irregardless of faction. "NW_I0_GENERIC" must be included to use these constants (include "NW_I0_GENERIC using the #include compiler directive).
OBJECT_TYPE_*Used to categorize types of objects.
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.
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).
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.
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.
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.
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.
TRAP_BASE_TYPE_*Used to catagorize the strength and type of traps.
TREASURE_*Treasure types. These constants are defined in "nw_o2_coninclude"; in order to use the constant values the file "nw_o2_coninclude" must be included (using the "#include" compiler directive).
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_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.


Send comments on this topic.