How to make a creature incorporeal through scripting?

As the title say, some spells haves this:

if(!GetCreatureFlag(oTarget, CREATURE_VAR_IS_INCORPOREAL))

I tried the following and it didn’t work(i don’t know if that’s how it is used): SetCreatureFlag(OBJECT_SELF,CREATURE_VAR_IS_INCORPOREAL,TRUE);

I noticed that incorporeal creatures have this variable X2_L_IS_INCORPOREAL in the toolset set to 1. Is that a local var or is something different?

In short, I’m trying to make the caster incorporeal and flag it as incorporeal.

“X2_L_IS_INCORPOREAL” simply flags this code to run in the default OnSpawn script ‘nw_c2_default 9’

    if (GetCreatureFlag(oSelf, CREATURE_VAR_IS_INCORPOREAL))
        effect eGhost   = EffectCutsceneGhost();
        effect eConceal = EffectConcealment(50, MISS_CHANCE_TYPE_NORMAL);
        effect eReduct  = EffectDamageReduction(9999, DAMAGE_POWER_PLUS_ONE, 0, DR_TYPE_MAGICBONUS); // immune to non-magical weapons

        eGhost = EffectLinkEffects(eGhost, eConceal);
        eGhost = EffectLinkEffects(eGhost, eReduct);
        eGhost = SupernaturalEffect(eGhost);

        ApplyEffectToObject(DURATION_TYPE_PERMANENT, eGhost, oSelf);

so if you want to make an already-spawned creature incorporeal, construct and apply the same or similar effect, on the fly.


What i need to do is to flag the creature as incorporeal through scripting so the
“GetCreatureFlag(oSelf, CREATURE_VAR_IS_INCORPOREAL)” can detect it.

I don’t know how to do it since i don’t know if X2_L_IS_INCORPOREAL is a local var or something else.

You are on the right track: X2_L_IS_INCORPOREAL is a creature switch.

So you can put it on the creature itself as a variable, “1” in this case means “True.”
Type: Integer
Value: 1

You could also set this creature switch on an on spawn but I like to just put it on the creature variables. My wraith or other incorporeal creatures always has this trait. I hope this helps

EDIT: I wrote this for NWN1, funny how similar the two are. I have no idea if it works for NWN2, sorry!

1 Like
#include "x2_inc_switches"

void main()

    // this is the stock incorporeal code ->
    effect eConceal = EffectConcealment(50, MISS_CHANCE_TYPE_NORMAL);
    eConceal = ExtraordinaryEffect(eConceal);
    effect eGhost = EffectCutsceneGhost();
    eGhost = ExtraordinaryEffect(eGhost);
    effect eImmuneToNonMagicWeapons = EffectDamageReduction(1000, DAMAGE_POWER_PLUS_ONE, 0, DR_TYPE_MAGICBONUS);
    eImmuneToNonMagicWeapons = ExtraordinaryEffect(eImmuneToNonMagicWeapons);

    ApplyEffectToObject(DURATION_TYPE_PERMANENT, eConceal, OBJECT_SELF);
    ApplyEffectToObject(DURATION_TYPE_PERMANENT, eImmuneToNonMagicWeapons, OBJECT_SELF);

CREATURE_VAR_IS_INCORPOREAL is the constant for the string-literal “X2_L_IS_INCORPOREAL” ( ‘x2_inc_switches’ ) – they’re the same thing.


Thanks, that it’s working perfectly.

1 Like