Fireball Spell - changes

Hi everyone,

I have combined two scripts together to try to get a really cool Fireball effect on detonation. I recommend this Fireball spell I found here on the vault:

https://neverwintervault.org/project/nwnee/script/enhanced-fireball-effects

Now, I also took the Catapult script and mixed a couple of lines in. I want the knockdown and daze effect to work in the above improved spell. So far no luck. Here is the modified spell below:

//::///////////////////////////////////////////////
//:: Fireball
//:: NW_S0_Fireball
//:: Copyright (c) 2001 Bioware Corp.
//:://////////////////////////////////////////////
/*
// A fireball is a burst of flame that detonates with
// a low roar and inflicts 1d6 points of damage per
// caster level (maximum of 10d6) to all creatures
// within the area. Unattended objects also take
// damage. The explosion creates almost no pressure.
*/
//:://////////////////////////////////////////////
//:: Created By: Noel Borstad
//:: Created On: Oct 18 , 2000
//:://////////////////////////////////////////////
//:: Last Updated By: Preston Watamaniuk, On: April 6, 2001
//:: Last Updated By: AidanScanlan, On: April 11, 2001
//:: Last Updated By: Preston Watamaniuk, On: May 25, 2001

//:: Modified By Jonathan Cwiok on 7/14/2019

#include “X0_I0_SPELLS”
#include “x2_inc_spellhook”
#include “_incl_rndloc”
#include “inc_spprojectile”

//Constants used to make modifying fireball visual parameters easier.
const float SCORCH_LIFESPAN = 600.0;
const float SMOKE_LIFESPAN = 30.0;
const float FIRE_LIFESPAN = 120.0;
const int FIRE_CHANCE = 50;
const int FIRE_MAX = 3;
const float HEIGHT_MAX = 2.0;
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())
{
// If code within the PreSpellCastHook (i.e. UMD) reports FALSE, do not run this spell
    return;
}

// End of Spell Cast Hook

//Declare major variable.

object oCaster = OBJECT_SELF;
int nCasterLvl = GetCasterLevel(oCaster);
int nMetaMagic = GetMetaMagicFeat();
int nDamage;
float fDelay;
effect eExplode = EffectVisualEffect(VFX_FNF_FIREBALL);
effect eVis = EffectVisualEffect(VFX_IMP_FLAME_M);
effect eDam;

//Get the spell target location as opposed to the spell target.
location lTarget = GetSpellTargetLocation();
object oMark;
object oFire;
object oSmoke;
int nFire = 0;
vector oPos = GetPositionFromLocation(lTarget);
float fHeight;
//Limit Caster level for the purposes of damage
if (nCasterLvl > 10)
{
    nCasterLvl = 10;
}
//Apply the fireball explosion at the location captured above.
ApplyEffectAtLocation(DURATION_TYPE_INSTANT, eExplode, lTarget);
 effect knockdown = EffectKnockdown();
 effect dazed = EffectDazed();
//------------ENHANCED FIREBALL ADDITIONS----------------
//The following segment creates scorch marks and small fire effects.
//Get the difference in height from target to ground.
fHeight = oPos.z - GetGroundHeight(lTarget);
//Only do the following if target is not too high above ground.
if (fHeight < HEIGHT_MAX){
    //Create dynamic scorch mark
    oMark = CreateObject(OBJECT_TYPE_PLACEABLE, "plc_weathmark", lTarget);
    //Make sure it doesn't get destroyed by making it Plot.
    SetPlotFlag(oMark, TRUE);
    //Randomize its size.
    SetObjectVisualTransform(oMark, OBJECT_VISUAL_TRANSFORM_SCALE, RndFloat(2) + 0.5);
    //Make sure it's drawn at current ground height.
    SetObjectVisualTransform(oMark, OBJECT_VISUAL_TRANSFORM_TRANSLATE_Z, -(fHeight)+0.01);
    //Destroy after SCORCH_LIFESPAN
    DestroyObject(oMark, SCORCH_LIFESPAN);

    //Create dynamic smoke.
    oSmoke = CreateObject(OBJECT_TYPE_PLACEABLE, "plc_dustplume", lTarget);
    SetPlotFlag(oSmoke, TRUE);
    SetObjectVisualTransform(oSmoke, OBJECT_VISUAL_TRANSFORM_TRANSLATE_Z, -(fHeight)+0.01);
    DestroyObject(oSmoke, SMOKE_LIFESPAN);

    //Chance to create up to FIRE_MAX fire objects at a random location near lTarget.
    while (Random(100) < FIRE_CHANCE && nFire < FIRE_MAX){
        oFire = CreateObject(OBJECT_TYPE_PLACEABLE, "plc_flamesmall", GetRandomLocation(GetArea(oCaster), oMark, RndFloat(3)));
        SetPlotFlag(oFire, TRUE);
        SetObjectVisualTransform(oFire, OBJECT_VISUAL_TRANSFORM_SCALE, RndFloat(2) + 0.2);
        SetObjectVisualTransform(oFire, OBJECT_VISUAL_TRANSFORM_TRANSLATE_Z, -(fHeight));
        DestroyObject(oFire, FIRE_LIFESPAN);
        nFire++;
        }
}
//------------END ADDITIONS----------------

//Declare the spell shape, size and the location.  Capture the first target object in the shape.
object oTarget = GetFirstObjectInShape(SHAPE_SPHERE, RADIUS_SIZE_HUGE, lTarget, TRUE, OBJECT_TYPE_CREATURE | OBJECT_TYPE_DOOR | OBJECT_TYPE_PLACEABLE);
//Cycle through the targets within the spell shape until an invalid object is captured.
while (GetIsObjectValid(oTarget))
{
    if (spellsIsTarget(oTarget, SPELL_TARGET_STANDARDHOSTILE, OBJECT_SELF))
    {
        if((GetSpellId() == 341) || GetSpellId() == 58)
        {
            //Fire cast spell at event for the specified target
            SignalEvent(oTarget, EventSpellCastAt(OBJECT_SELF, SPELL_FIREBALL));
            //Get the distance between the explosion and the target to calculate delay
            fDelay = GetDistanceBetweenLocations(lTarget, GetLocation(oTarget))/20;
            if (!MyResistSpell(OBJECT_SELF, oTarget, fDelay))
            {
                //Roll damage for each target
                nDamage = d6(nCasterLvl);
                //Resolve metamagic
                if (nMetaMagic == METAMAGIC_MAXIMIZE)
                {
                    nDamage = 6 * nCasterLvl;
                }
                else if (nMetaMagic == METAMAGIC_EMPOWER)
                {
                   nDamage = nDamage + nDamage / 2;
                }
                //Adjust the damage based on the Reflex Save, Evasion and Improved Evasion.
                nDamage = GetReflexAdjustedDamage(nDamage, oTarget, GetSpellSaveDC(), SAVING_THROW_TYPE_FIRE);
                //Set the damage effect
                eDam = EffectDamage(nDamage, DAMAGE_TYPE_FIRE);
                if(nDamage > 0)
                {
                    // Apply effects to the currently selected target.
                    DelayCommand(fDelay, ApplyEffectToObject(DURATION_TYPE_INSTANT, eDam, oTarget));
                    //This visual effect is applied to the target object not the location as above.  This visual effect
                    //represents the flame that erupts on the target not on the ground.
                    DelayCommand(fDelay, ApplyEffectToObject(DURATION_TYPE_INSTANT, eVis, oTarget));
                }
             }
         }
    }
   //Select the next target within the spell shape.
   oTarget = GetNextObjectInShape(SHAPE_SPHERE, RADIUS_SIZE_HUGE, lTarget, TRUE, OBJECT_TYPE_CREATURE | OBJECT_TYPE_DOOR | OBJECT_TYPE_PLACEABLE);
}

}

And the other catapult script :

//::///////////////////////////////////////////////
//:: Name Things that go boom
//:: FileName xs_catapult_use
//:: Copyright (c) 2003 NWNZone.com
//:://////////////////////////////////////////////
/*
This is the on use event for the catapults
[Version .5a]
*/
//:://////////////////////////////////////////////
//:: Created By: Xeno
//:: Created On: 11 Aug 2003
//:://////////////////////////////////////////////
#include “NW_I0_SPELLS”

effect eShake = EffectVisualEffect(VFX_FNF_SCREEN_BUMP);
effect eDark = EffectVisualEffect(VFX_DUR_DARKNESS);
effect eBoom = EffectVisualEffect(VFX_FNF_FIREBALL,FALSE);
effect eVis = EffectVisualEffect(VFX_IMP_FLAME_M);
effect eFire = EffectVisualEffect(VFX_IMP_PULSE_FIRE);
effect knockdown = EffectKnockdown();
effect dazed = EffectDazed();
effect eSmoke = EffectVisualEffect(320);
effect eDebris = EffectVisualEffect(354);
effect eDam;
float fDelay;
int nDamage;
effect eDest = EffectDeath();
object oDetinator = GetLocalObject(OBJECT_SELF, “GZ_OBJECT_ACTIVATOR”);
int iRoll6 = d10(3)-7;//Very Far away. Avg b4 Reflex Save: 15-7
int iRoll5 = d10(6)-15;//Near enough. Avg b4 Reflex Save: 30-15
int iRoll4 = d10(9)-23;//Kinda close arn’t ya? Avg b4 Reflex Save: 45-23
int iRoll3 = d10(12)-30;//Still gona get hurt! Avg b4 Reflex Save: 60-30
int iRoll2 = d10(15);//Too close. Avg b4 Reflex Save: 75
int iRoll1 = d6(18);//Standing Right next to it! Avg b4 Reflex Save: 90

//Produce a radius intensity damage at lLoc
//The closer you are to the lLoc, the more damage you take!
void BlastArea(location lLoc);

void Knock_Down(location lLoc)
{
object oPC = GetFirstObjectInShape(SHAPE_SPHERE, RADIUS_SIZE_COLOSSAL, lLoc, TRUE, OBJECT_TYPE_CREATURE);
while (GetIsObjectValid(oPC))
{
int iKnock = d10();
//int iDazed = d10()+iKnock;
float fKnock = IntToFloat(iKnock);
//float fDazed = IntToFloat(iDazed);
ApplyEffectToObject(DURATION_TYPE_TEMPORARY, knockdown, oPC, fKnock);
//ApplyEffectToObject(DURATION_TYPE_TEMPORARY, dazed, oPC, fDazed);
SetLocalInt(oPC, “Blast_Radius”,6);
SetIsTemporaryEnemy(oDetinator, oPC, FALSE);
oPC = GetNextObjectInShape(SHAPE_SPHERE, RADIUS_SIZE_COLOSSAL, lLoc, TRUE, OBJECT_TYPE_CREATURE);
}
}

void Assign_Damage(location lLoc, float fRadius, int iBlastEffect)
{
object oTarget = GetFirstObjectInShape(SHAPE_SPHERE, fRadius, lLoc, TRUE, OBJECT_TYPE_CREATURE);
while (GetIsObjectValid(oTarget))
{
if (!GetPlotFlag(oTarget))
SetLocalInt(oTarget, “Blast_Radius”, iBlastEffect);
oTarget = GetNextObjectInShape(SHAPE_SPHERE, fRadius, lLoc, TRUE, OBJECT_TYPE_CREATURE);
}
}

void Do_Damage(location lLoc)
{
object oTarget = GetFirstObjectInShape(SHAPE_SPHERE, RADIUS_SIZE_COLOSSAL, lLoc, TRUE, OBJECT_TYPE_CREATURE | OBJECT_TYPE_DOOR | OBJECT_TYPE_PLACEABLE);
while (GetIsObjectValid(oTarget))
{
if (!GetPlotFlag(oTarget))
{
int iDamageApply = GetLocalInt(oTarget, “Blast_Radius”);
fDelay = GetDistanceBetweenLocations(lLoc, GetLocation(oTarget))/20;
if (GetObjectType(oTarget) == OBJECT_TYPE_DOOR)
nDamage = GetCurrentHitPoints(oTarget)+1;
if (GetTag(oTarget) == “XS_BOULDER”)
nDamage = GetCurrentHitPoints(oTarget)+1;
else if (GetTag(oTarget) ==“gz_obj_pkeg”)
nDamage = d6(2); // lower chance to destroy other powerderkeg
else if (iDamageApply==6)
nDamage = iRoll6;
else if (iDamageApply==5)
nDamage = iRoll5;
else if (iDamageApply==4)
nDamage = iRoll4;
else if (iDamageApply==3)
nDamage = iRoll3;
else if (iDamageApply==2)
nDamage = iRoll2;
else if (iDamageApply==1)
nDamage = iRoll1;
else nDamage = 0;

            nDamage = GetReflexAdjustedDamage(nDamage, oTarget, GetSpellSaveDC(), SAVING_THROW_TYPE_FIRE);
            eDam = EffectDamage(nDamage, DAMAGE_TYPE_FIRE);
            if(nDamage > 0 )//& GetObjectSeen(oTarget_r6, OBJECT_SELF))
              {
               DelayCommand(fDelay, ApplyEffectToObject(DURATION_TYPE_INSTANT, eDam, oTarget));
               DelayCommand(fDelay, ApplyEffectToObject(DURATION_TYPE_INSTANT, eVis, oTarget));
              }
        DeleteLocalInt(oTarget, "Blast_Radius");
       }
 oTarget = GetNextObjectInShape(SHAPE_SPHERE, RADIUS_SIZE_COLOSSAL, lLoc, TRUE, OBJECT_TYPE_CREATURE | OBJECT_TYPE_DOOR | OBJECT_TYPE_PLACEABLE);
}

}

void BlastArea(location lLoc)
{
//location lLoc = GetLocation(OBJECT_SELF);
ApplyEffectAtLocation(DURATION_TYPE_INSTANT,eBoom, lLoc);

DelayCommand(0.3f,ApplyEffectAtLocation(DURATION_TYPE_INSTANT,eDest,lLoc));
ApplyEffectAtLocation(DURATION_TYPE_TEMPORARY,eDark,lLoc,0.5);

//Has problems//ApplyEffectAtLocation(DURATION_TYPE_TEMPORARY,eSmoke,lLoc,20.0);
ApplyEffectAtLocation(DURATION_TYPE_INSTANT, eFire, lLoc);
ApplyEffectAtLocation(DURATION_TYPE_INSTANT, eDebris, lLoc);
ApplyEffectAtLocation(DURATION_TYPE_INSTANT, eDebris, lLoc);
ApplyEffectAtLocation(DURATION_TYPE_INSTANT, eDebris, lLoc);
ApplyEffectAtLocation(DURATION_TYPE_INSTANT, eDebris, lLoc);
PlaySound(“sim_explsun”);
ApplyEffectAtLocation(DURATION_TYPE_INSTANT,eShake, lLoc);
//Xeno’s radius intensity damage (Please give credit if you use this in other scripts.)
//The closer you are to the source, the more damage you take!
Knock_Down(lLoc);//Knock down everyone in area and assign max radius damage!
Assign_Damage(lLoc, RADIUS_SIZE_GARGANTUAN, 5);//Assign damage per radius.
Assign_Damage(lLoc, RADIUS_SIZE_HUGE, 4);//Assign damage per radius.
Assign_Damage(lLoc, RADIUS_SIZE_LARGE, 3);//Assign damage per radius.
Assign_Damage(lLoc, RADIUS_SIZE_MEDIUM, 2);//Assign damage per radius.
Assign_Damage(lLoc, RADIUS_SIZE_SMALL, 1);//Assign damage per radius.
Do_Damage(lLoc);//Now that everyones radius is assigned, do the damage that was assigned.
}

Can anyone tell me why the knockdown and daze not work currently in the first spell above?

The script compiled but those two effects do not work