Fun Cantrips script (RESOLVED)

As some of you know I did a “Puke Cantrip” on here a while back where some of you helped me. I am working on releasing some cantrips and orisons (cleric cantrips) to the vault. I have been working on some funny/fun cantrips. All apprentices loved playing pranks on each other :wink:

I have the Puke cantrip done

Others I plan to do are:

Fart (one here below)

I used the Puke cantrip for my fart cantrip as a a base script. I thought if I changed a few variables and constants and vfx effects and sounds I could do this…apparently not so…lol

I got the following error and honestly I do not know how to fix it. I even looked at the NWN wiki

Here is the full script:

 //Fart Cantrip

#include "x0_i0_spells"
#include "x2_inc_spellhook"

void main()
      Spellcast Hook Code
      Added 2003-06-20 by Georg
      If you want to make changes to all spells,
      check x2_inc_spellhook.nss to find out more
    if (!X2PreSpellCastCode())
    // End of Spell Cast Hook
    //Setup for Spell
    object    oTarget      = GetSpellTargetObject();
    location  lLocal       = GetSpellTargetLocation();
    int       nCasterLevel = GetCasterLevel(OBJECT_SELF);
    float fDelay = IntToFloat(nCasterLevel)*5;
    AssignCommand (oTarget, PlaySound("Tb1a1__1"));
    effect eFart = EffectVisualEffect(VFX_FNF_SMOKE_PUFF);
    string sFartTalk = "FART!!";
    string sFartApology = "Ugh, I think farted my brains out!";


       string szLaughMale = "as_pl_ailingm5";
            string szLaughFemale = "as_pl_ailingf3";

            if (GetGender(oTarget) == GENDER_FEMALE)

        //Fire cast spell at event for the specified target
        SignalEvent(oTarget, EventSpellCastAt(OBJECT_SELF, 416));

        //Make SR Check
        if ((!MyResistSpell(OBJECT_SELF, oTarget)) &&  (MySavingThrow(SAVING_THROW_FORT, oTarget, GetSpellSaveDC()) == FALSE) )

            int nIntelligence = GetAbilityScore(oTarget,ABILITY_INTELLIGENCE);

            effect eIntelligence = EffectAbilityDecrease(ABILITY_INTELLIGENCE, nIntelligence -1);

            int nDiceRoll = d4();

            if(nDiceRoll== 1)
                ApplyEffectToObject(DURATION_TYPE_TEMPORARY, nIntelligence, oTarget, 6.0f);
            else if(nDiceRoll==2)
                ApplyEffectToObject(DURATION_TYPE_TEMPORARY, nIntelligence, oTarget, 12.0f);
            else if(nDiceRoll==3)
                ApplyEffectToObject(DURATION_TYPE_TEMPORARY, nIntelligence, oTarget, 18.0f);
            else if(nDiceRoll==4)
                ApplyEffectToObject(DURATION_TYPE_TEMPORARY, nIntelligence, oTarget, 24.0f);

            AssignCommand(oTarget, ActionPlayAnimation(ANIMATION_LOOPING_MEDITATE));
            AssignCommand(oTarget, ActionSpeakString(sFartTalk));
            DelayCommand(2.0,ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eFart, oTarget, 1.0));
            DelayCommand(5.0, AssignCommand(oTarget, ActionSpeakString(sFartApology)));

Now on the Puke cantrip I used Constitution so I thought if I just switch it to intelligence “I think I farted my brains out”…it would work…now why doesn’t it? Should be as easy as just changing the variable right? If you look I did…why is it not working?

Also, why can’t I use a vfx persistent effect? I know i can use EffectVisualEffect(VFX_FNF_SMOKE_PUFF);

But what is the name of the persistent constant? I could not find one? I like one on the persistent 2da I found I want to use for the fart effect.

If you look at the description of the function ApplyEffectToObject (taken from NWN Lexicon):

void ApplyEffectToObject(int nDurationType, effect eEffect,object oTarget,float fDuration = 0.0f);


    The type of duration to apply; a DURATION_TYPE_* constant.
    The effect to apply.
    The target of the effect.
    The duration of temporary effects. (Default: 0.0f)

Then compare it to what you wrote in the script…As you can (probably) (hopefully) see you need to change nIntelligence to eIntelligence like this:

 ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eIntelligence, oTarget, 6.0f);

In the description you see that the second parameter needs to be an effect while you wrote an integer instead. That’s why it wouldn’t compile.

Again, check the lexicon. It says this:

nMissEffect if this is TRUE, a random vector near or past the target will be generated, on which to play the effect (use only for DURATION_TYPE_INSTANT vfx, see remarks) (Default: FALSE)

Gee andgalf,

How did I miss that?..ugh…thanks …AGAIN…it compiles now.

Now I need to figure out how to put a persistent vfx instead of a visual vfx

I read this the other night…did not see how (the nMissEffect) would effect the target (creature). I need the target creature the spell is cast on to have the persistent effect take place…not an object or place near the target/creature.

Why does the effect need to be persistent? From my understanding reading the Lexicon it needs to be instant. Why not go with DURATION_TYPE_INSTANT? That doesn’t work you mean?

Like this perhaps?

DelayCommand(2.0,ApplyEffectToObject(DURATION_TYPE_INSTANT, eFart, oTarget, 1.0));

Because the visual effect has to be drawn from the persistent 2da (where the effect vfx is I like) not drawn from the Visual effect 2da (which is what the EffectVisualEffect is drawn from for most effects)

DelayCommand(2.0,ApplyEffectToObject(DURATION_TYPE_INSTANT, eFart, oTarget, 1.0));

Where in this bit of code do I put the line number or name of the vfx effect drawn from the persistent vfx 2da?

I have no idea unfortunately.

EDIT: I mean, I don’t think you do it there. I think you du that under eFart for example.

Sigh…no problem I understand…you work in the NWN2 community.

You have helped me a lot though and for that I am greatful :slight_smile:

What exactly is the effect called you are after?

Not sure what you mean? Can you give me the line code with where I would do that

I mean, I think you need to declare the effect beforehand, just like you did with this.

It comes from the persistent vfx 2da called: VFX_PER_FOGGHOUL

I’m searching the lexicon for this but nothing shows up… The spelling is right and all that?

Yes…but it is an effect I picked up from the vfx_persistent.2da see screen shot

I’m trying my best to search for this but it is quite hard. Is it a visual effect? In that case maybe you could use the function EffectVisualEffect? I don’t know…

Just need to know how to call an effect from there

It is a different 2da…that function calls from the visualeffects.2da

Do you see VFX_PER_FOGGHOUL somewhere among the constants (In the NWN2 toolset it’s called Globals).

I get that it’s a different 2da and all that but I don’t think that has anything to do with it, to be honest.

EDIT: If it’s not among the constants then I have a hard time seeing as how you would be able to call it in a script, but I don’t know. This is beyond my knowledge.