Skip to content

Acidfog rewrite [SOLVED]

arvutarvut Member Posts: 13
edited December 2025 in Builders - Scripting
So, I've rewritten a lot of spells (almost all) for the server I devel for, damage calculations based on feats. However the spells for certain AoE cloud effects (acid fog, cloudkill etcetera) won't use the calculated damage dices. The feats acidfog and cloudkill tests for are of course Spellfocus/Greater Spellfocus/Epic Spellfocus Conjuration, the 166, 394 and 611 feat constants.

Here's the nw_s0_acidfoga.nss script for the enter conditions on the spell.
#include "X0_I0_SPELLS"

void main()
{

    //Declare major variables
    int nMetaMagic = GetMetaMagicFeat();
    int nDamage, nRoll, nDice;
    string sMessage;
    object oCaster = OBJECT_SELF;
    int nMax;
    int nCasterLevel = GetCasterLevel(OBJECT_SELF);
    effect eDam;
    effect eVis = EffectVisualEffect(VFX_IMP_ACID_S);
    effect eSlow = EffectMovementSpeedDecrease(50);
    object oTarget = GetEnteringObject();
    float fDelay = GetRandomDelay(1.0, 2.2);
    if (spellsIsTarget(oTarget, SPELL_TARGET_SELECTIVEHOSTILE, GetAreaOfEffectCreator()))
    {
        //Fire cast spell at event for the target
        SignalEvent(oTarget, EventSpellCastAt(GetAreaOfEffectCreator(), SPELL_ACID_FOG));
        //Spell resistance check
        if(!MyResistSpell(GetAreaOfEffectCreator(), oTarget, fDelay))
        {
            //Roll Damage
            //Enter Metamagic and Spellfocus conditions
             if (GetHasFeat(611,oCaster))
             {
                nRoll = d20(6);
                nMax = 120;
             }
             else if (GetHasFeat(394,oCaster))
             {
                nRoll = d12(5);
                nMax = 60;
             }
             else if (GetHasFeat(166,oCaster))
             {
                nRoll = d8(4);
                nMax = 32;
             }
             else if (!GetHasFeat(166,oCaster))
             {
                nRoll = d6(4);
                nMax = 24;
             }
    //             sMessage = "Your spell does: " + IntToString(nDice) + "d" + IntToString(nRoll) + " damage to: " + GetName(oTarget);
             nDamage = nRoll;
            if (nMetaMagic == METAMAGIC_MAXIMIZE)
            {
                nDamage = nMax;//Damage is at max
            }
            else if (nMetaMagic == METAMAGIC_EMPOWER)
            {
                nDamage = nDamage + (nDamage/2); //Damage/Healing is +50%
            }
            //Make a Fortitude Save to avoid the effects of the movement hit.
            if(!MySavingThrow(SAVING_THROW_FORT, oTarget, GetSpellSaveDC(), SAVING_THROW_TYPE_ACID, GetAreaOfEffectCreator(), fDelay))
            {
                //slowing effect
                ApplyEffectToObject(DURATION_TYPE_PERMANENT, eSlow, oTarget);
                // * BK: Removed this because it reduced damage, didn't make sense nDamage = d6();
            }

            //Set Damage Effect with the modified damage
            eDam = EffectDamage(nDamage, DAMAGE_TYPE_ACID);
            //Apply damage and visuals
            DelayCommand(fDelay, ApplyEffectToObject(DURATION_TYPE_INSTANT, eVis, oTarget));
            DelayCommand(fDelay, ApplyEffectToObject(DURATION_TYPE_INSTANT, eDam, oTarget));
      //      SendMessageToPC(oCaster,sMessage);
        }
    }
}

I'm beginning to suspect these damage dices are set in either 2da files or hardcoded in the engine? Any suggestions on how to get this to work is welcome!
Post edited by arvut on

Comments

  • ForSeriousForSerious Member Posts: 532
    edited December 2025
    Open the floodgates: add a send message in more of the if cases. In that example message you have nDice that is not defined. Change it print out something more like nRoll is X, nMax is X, and then right before "eDam = EffectDamage(nDamage, DAMAGE_TYPE_ACID);" print out what nDamage is.
    I don't see anything wrong with it, but in general, I've stopped using 'else if' statements because they tend to not do what I expect. Using standalone 'if statements' tends to be better for how my mind likes to order instructions.
  • ForSeriousForSerious Member Posts: 532
    Also, nCasterLevel is not used at all.
  • ForSeriousForSerious Member Posts: 532
    edited December 2025
    I tried it out with a scroll and a bard I have handy. oCaster is not the player object that casts the spell, somehow. I tried GetLastSpellCaster() too, but it didn't fix it. Maybe it's because I did it with a scroll?

    I made a proper wizard and tried it out. Same issue. OBJECT_SELF is not the caster somehow… even though it is with all the other spells I checked.
    Post edited by ForSerious on
  • ForSeriousForSerious Member Posts: 532
    edited December 2025
    I figured it out. It uses a proxy object or something to make the area effect. You need to use the value from nMetaMagic = GetMetaMagicFeat() to get what metamagic feat was used. Change your 'if (GetHasFeat(###,OBJECT_SELF))' blocks to check against the nMetaMagic value/ For example: 'if(nMetaMagic == METAMAGIC_EMPOWER)
    This will work better than checking if they have the feat because players can slot spells to use specific metamagic feats, and this will reflect what metamagic feat was used to cast the spell.
  • arvutarvut Member Posts: 13
    edited December 2025
    Changing
    object oCaster = OBJECT_SELF;
    
    to
    object oCaster = GetAreaOfEffectCreator();
    
    did the trick, thx for finding this!
Sign In or Register to comment.