EffectPolymorph(int, int)

From NWN Lexicon
Revision as of 23:50, 8 March 2021 by Jasperre (talk | contribs) (Effect Breakdown)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
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
);

Parameters

nPolymorphSelection
A POLYMORPH_TYPE_* constant matching the form to polymorph into (line from polymorph.2da)
nLocked
If TRUE, player can't cancel polymorph (Default: FALSE)

Description

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.

Remarks

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, PC's can be affected by things like Turn Undead if they're undead)
  • Their portrait
  • Their soundset
  • Their equipped primary hand weapon (if valid weapon) (note that they don't need proficiency feats for this, it just magically appears in their hands).
  • Their creature weapons (if valid, else they are considered unarmed) (they also get the feat FEAT_CREATURE_WEAPON_PROFICIENCY to use creature weapons properly).
  • Their hide item (which provides most permanent special bonuses)
  • They may gain Dodge AC - yes, the column in polymorph.2da is wrong.
  • 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.

Effect Breakdown

The actual functionality of polymorph is completely crazy in a mad scentist kind of way. You do literally have most of your base statistics replaced. See polymorph.2da for some more information on what is setup in the 2da file.

Some specific details (compared to the general list above) and caveats of the effect are:

  • You have any existing EFFECT_POLYMORPH effects removed at the time of application
  • Internal effects applied:
    • EffectTemporaryHitpoints("HPBONUS") effect, for the temporary hit points but done internally. This is removed when the polymorph is cancelled, but it running out doesn't cancel it. This is hidden from GetFirst/NextEffect. An effect icon does appear for this.
    • EffectACIncrease("NATURALACBONUS", AC_DODGE_BONUS) is applied. Yes it's dodge. This is presumably so it can go higher than usual limitations. No effect icon appears for this.
  • When the game is saved or characters are exported, the effect is temporarily removed. When effects are tied to it, such as with EffectLinkEffects, these get removed (example: Tensers Transformation has this issue).
    • This also removes any shifter-based "merged item bonuses" to creature items
    • You can test this very simply by using the Export Character function in the main menu in singleplayer. The VFX for removing polymorph also occurs.
    • This is all to fix the even worse bug of "character saved to file is now the polymorph creature" which breaks ELC and other things.

The character sheet of the PC is updated with most of the new statistics, but not all of them in case you wondered why some don't appear. Creature weapons appear oddly - it shows all 3 options of attacks, even though of course only one will be randomly chosen.

There are obvious issues in some areas when polymorphing to a large or giant creature - but a PC can just usually unpolymorph to get around this.

nIndex Parameter Value Description and Notes
GetEffectInteger
0 nPolymorphSelection Can be 0 which is a valid polymorph.2da line
1 Not sure Something internal it looks like. Set to FALSE in intial effect creation.
2 nLocked

Known Bugs

There are some strange issues around Polymorph still, some up until recently causing crashes even in NWN:EE. One known bug that is unlikely to be fixed is that bonus spells from higher ability scores, since bonus ability scores from items are lost during polymorph, may be lost from your spellbook. To solve this a very short EffectAbilityIncrease to the relevant statistics can help reach a point where such ability score bonuses are added to the creatures hide to tide people over. This does have some effect on those abilities skill checks, ability checks and saves however.


Version

1.62

Example

// 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