EffectPolymorph(int, int)

From NWN Lexicon
Jump to: navigation, search

Create a Polymorph effect that changes the target into a different type of creature.

effect EffectPolymorph(
    int nPolymorphSelection,
    int nLocked = FALSE


A POLYMORPH_TYPE_* constant matching the form to polymorph into
If TRUE, player can't cancel polymorph (Default: FALSE)


Returns a new effect object that, when applied to a target, will transform them into one of the types defined in the POLYMORPH_TYPE_* constant group, from the "polymorph.2da" file. New forms can be added via a hakpack.

A new polymorph will cancel out an existing one. If nLocked is TRUE, there is no "Cancel Polymorph" in the radial menu, so it cannot be removed manually by a PC; the effect can only be removed when the duration runs out or (if applied via a spell) it is dispelled.

The target this effect is applied to must be a creature for it to work.


There may be polymorph types that can be used but which don't have a constant associated with it. All the different POLYMORPH_TYPE constants are just integers referencing a row number in your polymorph.2da file. Look in this file to see if there are further polymorphs available for you.

Polymorph changes these aspects of a creature:

  • Removes all equipped items temporarily
  • Their appearance (and with it, creature speed, creature size, and associated bonuses/penalties).
  • Their racial type (GetRacialType() return value also changes)
  • Their portrait
  • Their soundset
  • Their equipped primary hand weapon (if valid weapon)
  • Their creature weapons (if valid, else they are considered unarmed)
  • Their hide item (which provides most permanent special bonuses)
  • They may gain additional Natural AC (which should stack with amulets of natural AC)
  • They gain a bonus to their hit points (acts like temporary hit points and cannot be healed.)
  • Their Strength, Dexterity, Constitution (if valid values, else will use the original creatures original statistics. It may even lower statistics if their natural statistic is higher then what the new one is.)
  • They may gain up to 3 spells/natural abilities to cast infinitely (unless restricted in the script that runs)
  • They cannot cast spells or use items apart from potions

All the ones without a comment after should always be present when a polymorph is done. Some are not present (IE: **** in the 2da file) and thus it is just ignored (so no weapon, means no weapon is equipped, and no bonus to dexterity means they use their natural dexterity).

Effect functions are constructors, which are special methods that help construct effect "objects". You can declare and link effects, and apply them using an ApplyEffectToObject() Command. Once applied, each effect can be gotten separately via looping valid effects on the target (GetFirst/NextEffect()). See the Effect Tutorial for more details.




// Sample code for applying a werewolf polymorph to a target
void main()
    // This is the Object to apply the effect to.
    object oTarget = OBJECT_SELF;
    // Create the effect to apply
    effect ePoly = EffectPolymorph(POLYMORPH_TYPE_WEREWOLF);
    // Create the visual portion of the effect. This is instantly
    // applied and not persistent with whether or not we have the
    // above effect.
    effect eVis = EffectVisualEffect(VFX_IMP_POLYMORPH);
    // Apply the visual effect to the target
    ApplyEffectToObject(DURATION_TYPE_INSTANT, eVis, oTarget);
    // Apply the effect to the object
    ApplyEffectToObject(DURATION_TYPE_PERMANENT, ePoly, oTarget);

See Also

functions:  SetCreatureAppearanceType,
constants:  POLYMORPH_TYPE_* Constants

 author: John Shuell, editors: Jasperre, Mistress, additional contributor: Jasperre