Fix for Weird, Wail, Phantasmal Killer Ignoring Imm and Will

Forum for scripters of NWN material and third party applications.
Post Reply
Arkonswrath
Ambassador: Hala
Posts: 447
Joined: Wed May 26, 2004 3:57 am

Fix for Weird, Wail, Phantasmal Killer Ignoring Imm and Will

Post by Arkonswrath »

The following code updates were put in and tested on Hala and proven to be working.

This is the code for Wail that makes it respect Death Immunity

Code: Select all

case SPELL_WAIL_OF_THE_BANSHEE:
        //::///////////////////////////////////////////////
        //:: Wail of the Banshee
        //:: NW_S0_WailBansh
        //:: Copyright (c) 2001 Bioware Corp.
        //:://////////////////////////////////////////////
        //
        // * You emit a terrible scream that kills enemy creatures who hear it
        // * The spell affects up to one creature per caster level. Creatures
        // * closest to the point of origin are affected first.
        //
        //:://////////////////////////////////////////////
        //:: Last Updated By: Aloro
        //::                    Added creation of death variable.  Removed visual effects.
        //::                  Doug Noel - July 28, 2004
        //::                    Added to Avlis spellhook script.
        //:://////////////////////////////////////////////
        {
        //Declare major variables
        effect eVis = EffectVisualEffect(VFX_IMP_DEATH);
        effect eLink = EffectVisualEffect(VFX_FNF_WAIL_O_BANSHEES);
        location lCenter = lTarget;
        int iCount = 1;
        float fDelay, fTargetDistance;

        //Apply the FNF VFX impact
        ApplyEffectAtLocation(DURATION_TYPE_INSTANT, eLink, GetSpellTargetLocation());
        //Get the closet target from the spell target location

        if (!GetIsObjectValid(oTarget))
          oTarget = GetNearestObjectToLocation(OBJECT_TYPE_CREATURE, GetSpellTargetLocation(), iCount);
        while (iCount < iLevel)
        {
            lTarget = GetLocation(oTarget);
            //Get the distance of the target from the center of the effect
            fDelay = GetRandomDelay(3.0, 4.0);//
            fTargetDistance = GetDistanceBetweenLocations(lCenter, lTarget);
            //Check that the current target is valid and closer than 10.0m
            if(GetIsObjectValid(oTarget) && fTargetDistance <= 10.0)
            {
                if(!GetIsFriend(oTarget) && !GetIsReactionTypeFriendly(oTarget))
                {
                    //Fire cast spell at event for the specified target
                    SignalEvent(oTarget, EventSpellCastAt(OBJECT_SELF, SPELL_WAIL_OF_THE_BANSHEE));
                    //Make SR check
                    //Don't do anything if the target has death immunity
                    if(GetIsImmune(oTarget, IMMUNITY_TYPE_DEATH) == TRUE)
                    {
                    }
                    if(GetIsImmune(oTarget, IMMUNITY_TYPE_DEATH) == FALSE)
                    {
                    if(!MyResistSpell(OBJECT_SELF, oTarget)) //, 0.1))
                    {
                        //Make a fortitude save to avoid death
                        if(!MySavingThrow(SAVING_THROW_FORT, oTarget, iSpellDC, SAVING_THROW_TYPE_DEATH)) //, OBJECT_SELF, 3.0))
                        {
                            //Apply the delay VFX impact and death effect
                            SetLocalInt(oTarget, "InDying", TRUE);
                            DelayCommand(fDelay, ApplyEffectToObject(DURATION_TYPE_INSTANT, eVis, oTarget));
                            DelayCommand(fDelay, ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectDeath(), oTarget)); // no delay
                        }
                    }
                    }
                }
            }
            else
            {
                //Kick out of the loop
                iCount = iLevel;
            }
            //Increment the count of creatures targeted
            iCount++;
            //Get the next closest target in the spell target location.
            oTarget = GetNearestObjectToLocation(OBJECT_TYPE_CREATURE, lCenter, iCount);
        }

        SetModuleOverrideSpellScriptFinished();
        break;
        }


Here is the code for Phantasmal Killer to make it respect Imm Mind/Fear and accept the Will save as it should.

Code: Select all

        case SPELL_PHANTASMAL_KILLER:

        //::///////////////////////////////////////////////
        //:: Phantasmal Killer
        //:: NW_S0_PhantKill
        //:://////////////////////////////////////////////
        //
        // * Target of the spell must make 2 saves or die.
        //
        //:://////////////////////////////////////////////
        //:: Last Updated By: Aloro
        //:: - Added variable for death quests and to prevent server-hopping
        //::   when dead.  Removed visual effects.
        //:: Doug Noel - July 27, 2004
        //:: - Added to Avlis spellhook script.
        //:: Doug Noel - February 26, 2005 (v 1.5.1)
        //:: - Changed to only work on creatures.  Will no longer work on any
        //::   object that can be targeted.
        //:://////////////////////////////////////////////
        {
        //Declare major variables
        int iDamage = d6(3);
        effect eVis = EffectVisualEffect(VFX_IMP_SONIC);
        if(!GetIsReactionTypeFriendly(oTarget) && GetObjectType(oTarget) == OBJECT_TYPE_CREATURE) //Creatures Only - DN 2/26/05
        {
            //Fire cast spell at event for the specified target
            SignalEvent(oTarget, EventSpellCastAt(OBJECT_SELF, SPELL_PHANTASMAL_KILLER));
            //Make an SR check
            if(!MyResistSpell(OBJECT_SELF, oTarget))
             {
             if ( !GetIsImmune(oTarget, IMMUNITY_TYPE_MIND_SPELLS) &&
                  !GetIsImmune(oTarget, IMMUNITY_TYPE_FEAR))
               {
                //Make a Will save
                if (!MySavingThrow(SAVING_THROW_WILL,  oTarget, iSpellDC, SAVING_THROW_TYPE_MIND_SPELLS))
                {
                    //Make a Fort save
                    if (MySavingThrow(SAVING_THROW_FORT, oTarget, iSpellDC,SAVING_THROW_TYPE_DEATH))
                    {
                         //Check for metamagic
                         if (GetWasMetamagicFeatUsed(iMeta, METAMAGIC_MAXIMIZE))
                            iDamage = 18;
                         if (GetWasMetamagicFeatUsed(iMeta, METAMAGIC_EMPOWER))
                            iDamage = FloatToInt( IntToFloat(iDamage) * 1.5 );
                         //Set the damage property
                         effect eLink = EffectDamage(iDamage, DAMAGE_TYPE_MAGICAL);
                         //Apply the damage effect and VFX impact
                         ApplyEffectToObject(DURATION_TYPE_INSTANT, eLink, oTarget);
                         ApplyEffectToObject(DURATION_TYPE_INSTANT, eVis, oTarget);
                    }
                    else
                    {
                     // * I failed BOTH saving throws. Now I die.
                     if(GetIsImmune(oTarget, IMMUNITY_TYPE_FEAR) == TRUE){}
                     if(GetIsImmune(oTarget, IMMUNITY_TYPE_FEAR) == FALSE)
                       {
                         if(GetIsImmune(oTarget, IMMUNITY_TYPE_MIND_SPELLS) == FALSE)
                         //Apply the death effect and VFX impact
                         SetLocalInt(oTarget, "InDying", TRUE);
                         ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectDeath(), oTarget);
                       }
                    }
                  }
               }
            }
        }

        SetModuleOverrideSpellScriptFinished();
        break;
        }
And last but not least, Here is the code to make Weird respect Imm Mind/Fear and respect the Will save.

Code: Select all

        case SPELL_WEIRD:
        //::///////////////////////////////////////////////
        //:: Weird
        //:: NW_S0_Weird
        //:: Copyright (c) 2001 Bioware Corp.
        //:://////////////////////////////////////////////
        //
        // * All enemies in LOS of the spell must make 2 saves or die.
        //
        //:://////////////////////////////////////////////
        //:: Last Updated By: Aloro
        //::                    Added creation of death variable.  Removed visual effects.
        //::                  Doug Noel - July 28, 2004
        //::                    Added to Avlis spellhook script.
        //:://////////////////////////////////////////////
        {
        //Declare major variables
        effect eVis = EffectVisualEffect(VFX_IMP_SONIC);
        effect eLink = EffectVisualEffect(VFX_FNF_WEIRD);
        float fDelay;
        int iDamage;

        //Apply the FNF VFX impact
        ApplyEffectAtLocation(DURATION_TYPE_INSTANT, eLink, GetSpellTargetLocation());
        //Get the first target in the spell area
        oTarget = GetFirstObjectInShape(SHAPE_SPHERE, RADIUS_SIZE_COLOSSAL, GetSpellTargetLocation(), TRUE);
        while (GetIsObjectValid(oTarget))
        {
            //Make a faction check
            if(!GetIsFriend(oTarget))
            {
                   fDelay = GetRandomDelay(3.0, 4.0);
                   //Fire cast spell at event for the specified target
                   SignalEvent(oTarget, EventSpellCastAt(OBJECT_SELF, SPELL_WEIRD));
                   //Make an SR Check
                   if(!MyResistSpell(OBJECT_SELF, oTarget, fDelay))
                   {
                     if ( !GetIsImmune(oTarget, IMMUNITY_TYPE_MIND_SPELLS) &&
                          !GetIsImmune(oTarget, IMMUNITY_TYPE_FEAR))
                      {
                        if(GetHitDice(oTarget) >= 4)
                        {
                            //Make a Will save against mind-affecting
                            if(!MySavingThrow(SAVING_THROW_WILL, oTarget, iSpellDC, SAVING_THROW_TYPE_MIND_SPELLS, OBJECT_SELF, fDelay))
                            {
                                //Make a fortitude save against death
                                if(MySavingThrow(SAVING_THROW_FORT, oTarget, iSpellDC, SAVING_THROW_TYPE_DEATH, OBJECT_SELF, fDelay))
                                {
                                    //Roll damage
                                    iDamage = d6(3);
                                    //Make metamagic check
                                    if (GetWasMetamagicFeatUsed(iMeta, METAMAGIC_MAXIMIZE))
                                        iDamage = 18;
                                    if (GetWasMetamagicFeatUsed(iMeta, METAMAGIC_EMPOWER))
                                        iDamage = FloatToInt( IntToFloat(iDamage) * 1.5 );
                                    //Set damage effect
                                    eLink = EffectDamage(iDamage, DAMAGE_TYPE_MAGICAL);
                                    //Apply VFX Impact and damage effect
                                    DelayCommand(fDelay, ApplyEffectToObject(DURATION_TYPE_INSTANT, eVis, oTarget));
                                    DelayCommand(fDelay, ApplyEffectToObject(DURATION_TYPE_INSTANT, eLink, oTarget));
                                }
                                else
                                {
                                    //Apply VFX impact and death effect
                                    //DelayCommand(fDelay, ApplyEffectToObject(DURATION_TYPE_INSTANT, eVis2, oTarget));
                                    SetLocalInt(oTarget, "InDying", TRUE);
                                    DelayCommand(fDelay, ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectDeath(), oTarget));
                                }
                            }
                        }
                        else
                        {
                         // * I failed BOTH saving throws. Now I die.
                         if(GetIsImmune(oTarget, IMMUNITY_TYPE_FEAR) == TRUE){}
                         if(GetIsImmune(oTarget, IMMUNITY_TYPE_FEAR) == FALSE)
                          {
                            if(GetIsImmune(oTarget, IMMUNITY_TYPE_MIND_SPELLS) == FALSE)
                           {
                            //Apply VFX impact and death effect
                            eVis = EffectVisualEffect(VFX_IMP_DEATH);
                            DelayCommand(fDelay, ApplyEffectToObject(DURATION_TYPE_INSTANT, eVis, oTarget));
                            SetLocalInt(oTarget, "InDying", TRUE);
                            DelayCommand(fDelay, ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectDeath(), oTarget));
                            }
                          }
                        }
                   }
                }
            }
            //Get next target in spell area
            oTarget = GetNextObjectInShape(SHAPE_SPHERE, RADIUS_SIZE_COLOSSAL, GetSpellTargetLocation(), TRUE);
        }

        SetModuleOverrideSpellScriptFinished();
        break;
        }
Post Reply