Script doubt, custom trap with posioned spikes

Hi all

I’m trying to do a trap with poisoned spikes.
OnTrapTriggered:

#include "x0_i0_spells"
//::////////////////////////////////////////////////////////////////////////////
void main()
{
    object oPC= GetEnteringObject();
    effect ePoison= EffectPoison(POISON_GIANT_WASP_POISON);
    effect eDamage;
    int    nDamage = d6(1);

    if (!MySavingThrow(SAVING_THROW_REFLEX, oPC, 15, SAVING_THROW_TYPE_TRAP))
    {   if (GetHasFeat(FEAT_IMPROVED_EVASION, oPC)) {   nDamage /= 2;    }  }
    else
    {
        if (GetHasFeat(FEAT_IMPROVED_EVASION, oPC)) {   nDamage  = 0;    }
        else                                        {   nDamage /= 2;    }
    }
    if (nDamage)
    {
        eDolor = EffectDamage(nDamage, DAMAGE_TYPE_PIERCING);
        ApplyEffectToObject(DURATION_TYPE_INSTANT, eDamage, oPC);
        if (!MySavingThrow(SAVING_THROW_FORT, oPC, 14, SAVING_THROW_TYPE_POISON))
        {
            VoicePoisoned();
            ApplyEffectToObject(DURATION_TYPE_TEMPORARY, ePoison, oPC);
        }
    }
}

But the problem or unexpected effect is that the player receives immediatly both damages from the poison. Does anyone have any idea about how can I procced?

Thanks in advance

Your braces were all over the place. In places you had too many, in others not enough. I’ve tidied it up the best I can. Is this what you were aiming for?

#include "x0_i0_spells"
//::////////////////////////////////////////////////////////////////////////////
void main()
{
    object oPC= GetEnteringObject();
    effect ePoison= EffectPoison(POISON_GIANT_WASP_POISON);
    effect eDamage;
    int    nDamage = d6(1);

    if(!MySavingThrow(SAVING_THROW_REFLEX, oPC, 15, SAVING_THROW_TYPE_TRAP))
    {   
        if (GetHasFeat(FEAT_IMPROVED_EVASION, oPC))
            nDamage /= 2;
        else
        {
            if (GetHasFeat(FEAT_IMPROVED_EVASION, oPC))
                nDamage  = 0;
            else                                        
                nDamage /= 2;
        }
    }
    if(nDamage)
    {
        eDolor = EffectDamage(nDamage, DAMAGE_TYPE_PIERCING);
        ApplyEffectToObject(DURATION_TYPE_INSTANT, eDamage, oPC);
        
        if (!MySavingThrow(SAVING_THROW_FORT, oPC, 14, SAVING_THROW_TYPE_POISON))
        {
            VoicePoisoned();
            ApplyEffectToObject(DURATION_TYPE_TEMPORARY, ePoison, oPC);
        }
    }
}

Don’t know if it will do what you want though, I haven’t tested it.

TR

No, it does the same thing without unneeded braces.
The problem is that if the player fails all saving throw (reflex and fortitude), he receives in the same moment 1d6 piercing damage (ok), 1d6 dex decrease (ok) and again the second damage of the poison, 1d6 dex decrease (nok).

I’m not sure if I can work with the standard poisons or do manually (scripting) the first poison’s damage and after that the second

Looked at your code and added comments where I noticed some things.

#include "x0_i0_spells"
//::////////////////////////////////////////////////////////////////////////////
void main()
{
    object oPC= GetEnteringObject();
    effect ePoison= EffectPoison(POISON_GIANT_WASP_POISON);
    effect eDamage;
    int    nDamage = d6(1);

    if(!MySavingThrow(SAVING_THROW_REFLEX, oPC, 15, SAVING_THROW_TYPE_TRAP))
    {   
        if (GetHasFeat(FEAT_IMPROVED_EVASION, oPC)) //If they have that feat the else won't be used
            nDamage /= 2;
        else
        {
            if (GetHasFeat(FEAT_IMPROVED_EVASION, oPC)) // so why have got this a second time when the else says they don't have that feat?
                nDamage  = 0;
            else                                        
                nDamage /= 2;
        }
    }
    if(nDamage)
    {
        eDolor = EffectDamage(nDamage, DAMAGE_TYPE_PIERCING); // you should be getting an error here for undeclared variable
        ApplyEffectToObject(DURATION_TYPE_INSTANT, eDamage, oPC);
        
        if (!MySavingThrow(SAVING_THROW_FORT, oPC, 14, SAVING_THROW_TYPE_POISON))
        {
            VoicePoisoned();
            ApplyEffectToObject(DURATION_TYPE_TEMPORARY, ePoison, oPC);
        }
    }
}

TR

I believe the issue is that you’re applying the poison with a temporary duration of 0.0f, and it ticks twice. Try using DURATION_TYPE_PERMANENT. See also here EffectPoison(int) - NWN Lexicon where it advises to never use temporary durations on poisons and diseases.


As for @Tarot_Redhand’s

// so why have got this a second time when the else says they don't have that feat?

it’s because your helpful fix of the braces was incorrect. If you look closer at their original code, this is not the case.

Thank you for your help

ApplyEffectToObject(DURATION_TYPE_PERMANENT, ePoison, oPC, RoundsToSeconds(2));

@Tarot_Redhand , in my opinion (I’m mathematician :slightly_smiling_face:), never is a problem to put more braces than you need. The conditional is:
Saving thrown vs Reflex:

  • If you fail, but you have evasion’s feat, you only receive half damage.
  • If you pass, but you have evasion’s feat, you don’t receive damage, in other case half damage

In any case, again, thank you for your help

1 Like

In my opinion you need to read - TR’s Basics - Mostly Operators, but that is your choice. Too many braces is like having too many full-stops at the end of sentence. It can confuse the hell out of the reader (well it obviously did to me! :confused: :innocent:)..........

TR