Multi Fireball spell not working (RESOLVED)

Hi again…can anyone tell me why this spell doesn’t work as it should? I cast it and it shoots a fireball in one direction then the wizard does an about face (180 degrees) and fires off in succession other fireballs in a straight line. Is it possible to make it fire ALL the fireballs at the target chosen?

//::///////////////////////////////////////////////
//:: Multi Fireball
//:: kl_sp_multiball
//:: 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: junhunglau
//:: Created On: Dec 25, 2006
//:://////////////////////////////////////////////
// Modified 04082007 by junhunglau - Multiball now targets random locations near to original

#include "kl_inc_spells"
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 variables
    object oCaster = OBJECT_SELF;
    int nCasterLvl = GetCasterLevel(oCaster),
        nCasterLvl2= GetCasterLevel(oCaster); //Declare for later use casting multiball
    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();
    //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);
    //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))
        {
            //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);
    }

// Cast Multiple Fireballs at random locations, based on level
object oEnemy;
location lTarget2;
int nCount = 0;
int nNumFBalls = nCasterLvl2/5;
for (nNumFBalls; nNumFBalls > 0; nNumFBalls --)
    {
    /*
    nCount ++;
    oEnemy = GetNearestPerceivedEnemy(oCaster, nCount, CREATURE_TYPE_IS_ALIVE, TRUE);
    lTarget = GetLocation(oEnemy);
    */
    lTarget2 = klGetRandomLocationToLocation(lTarget, FeetToMeters(10.0));
    ActionCastSpellAtLocation(SPELL_FIREBALL, lTarget2, nMetaMagic, TRUE, PROJECTILE_PATH_TYPE_HOMING, TRUE);
    ActionWait(1.0);
    }
}

Here is the “kl_inc_spells” it is referencing

It is too long to paste here. See attached

kl_inc_spells.zip (7.4 KB)

This thing actually works:

// Multi Fireball
// overwriting nw_s0_fireball

#include "x2_inc_spellhook"

void main()
{
  if (!X2PreSpellCastCode()) return;

  SendMessageToPC (GetFirstPC(), "Fired by: "+GetName (OBJECT_SELF));

  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;

  location lTarget = GetSpellTargetLocation();
  if (nCasterLvl > 10) nCasterLvl = 10;

  int n, nNumFBalls = 3;  //nNumFBalls = nCasterLvl/5;
  for (n = 0; n < nNumFBalls; n++)
    {
      SendMessageToPC (GetFirstPC(), "Round: "+ IntToString (n));

      DelayCommand (n * 2.0, ApplyEffectAtLocation(DURATION_TYPE_INSTANT, eExplode, lTarget));

      object oTarget = GetFirstObjectInShape(SHAPE_SPHERE, RADIUS_SIZE_HUGE, lTarget, TRUE, OBJECT_TYPE_CREATURE | OBJECT_TYPE_DOOR | OBJECT_TYPE_PLACEABLE);
      while (GetIsObjectValid(oTarget))
        {
          SignalEvent(oTarget, EventSpellCastAt(OBJECT_SELF, SPELL_FIREBALL));
          fDelay = GetDistanceBetweenLocations(lTarget, GetLocation(oTarget))/20;
          if (!MyResistSpell(OBJECT_SELF, oTarget, fDelay))
            {
              nDamage = d6(nCasterLvl);
              if (nMetaMagic == METAMAGIC_MAXIMIZE) nDamage = 6 * nCasterLvl;
              else if (nMetaMagic == METAMAGIC_EMPOWER) nDamage = nDamage + nDamage/2;

              nDamage = GetReflexAdjustedDamage(nDamage, oTarget, GetSpellSaveDC(), SAVING_THROW_TYPE_FIRE);
              eDam = EffectDamage(nDamage, DAMAGE_TYPE_FIRE);
              if (nDamage > 0)
                {
                  DelayCommand(fDelay+2.0*n, ApplyEffectToObject(DURATION_TYPE_INSTANT, eDam, oTarget));
                  DelayCommand(fDelay+2.0*n, ApplyEffectToObject(DURATION_TYPE_INSTANT, eVis, oTarget));
                }
            }
          oTarget = GetNextObjectInShape(SHAPE_SPHERE, RADIUS_SIZE_HUGE, lTarget, TRUE, OBJECT_TYPE_CREATURE | OBJECT_TYPE_DOOR | OBJECT_TYPE_PLACEABLE);
        }
    }
}

The only little thing is, that the casting animation and the projectile path are shown only once.

So is that a new script or is it the same one? Because the original never worked for me…it would cast a single fireball at the target then do a 180 and cast several in the opposite direction which was useless.

So is that a new script or is it the same one?

What do you think? It’s a most sophisticated script coded by me!

Cool…thanks bud :slight_smile:

I demand only 5 gold pieces for it.

LOL…ok…here is your 5 G.P…lol

Ah,I see this message below and you are right…I only see one fireball…is there no way to delay casting of each fireball so we can see the all animations (fireballs).

Hi Mmat,

I thought I would add extra effects like in my fireball to make the explosion more spectacular but I got an error.

This is what i added:

effect eShake = EffectVisualEffect(VFX_FNF_SCREEN_BUMP);
    effect eExplode = EffectVisualEffect(VFX_FNF_FIREBALL);
    effect eVis = EffectVisualEffect(VFX_IMP_FLAME_M);
    effect knockdown = EffectKnockdown();
    effect dazed = EffectDazed();
    effect eDam;
    int iKnock = d10();
    //int iDazed = d10()+iKnock;
    float fKnock = IntToFloat(iKnock);
    //float fDazed = IntToFloat(iDazed);

So the script looks like below…

//::///////////////////////////////////////////////
//:: Multi Fireball
//:: kl_sp_multiball
//:: 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: junhunglau
//:: Created On: Dec 25, 2006
//:://////////////////////////////////////////////
// Modified 04082007 by junhunglau - Multiball now targets random locations near to original

#include "kl_inc_spells"
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 variables
    object oCaster = OBJECT_SELF;
    int nCasterLvl = GetCasterLevel(oCaster),
        nCasterLvl2= GetCasterLevel(oCaster); //Declare for later use casting multiball
    int nMetaMagic = GetMetaMagicFeat();
    int nDamage;
    effect eShake = EffectVisualEffect(VFX_FNF_SCREEN_BUMP);
    effect eExplode = EffectVisualEffect(VFX_FNF_FIREBALL);
    effect eVis = EffectVisualEffect(VFX_IMP_FLAME_M);
    effect knockdown = EffectKnockdown();
    effect dazed = EffectDazed();
    effect eDam;
    int iKnock = d10();
    //int iDazed = d10()+iKnock;
    float fKnock = IntToFloat(iKnock);
    //float fDazed = IntToFloat(iDazed);

    //Get the spell target location as opposed to the spell target.
    location lTarget = GetSpellTargetLocation();
    //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);
    //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))
        {
            //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);
    }

// Cast Multiple Fireballs at random locations, based on level
object oEnemy;
location lTarget2;
int nCount = 0;
int nNumFBalls = nCasterLvl2/5;
for (nNumFBalls; nNumFBalls > 0; nNumFBalls --)
    {
    /*
    nCount ++;
    oEnemy = GetNearestPerceivedEnemy(oCaster, nCount, CREATURE_TYPE_IS_ALIVE, TRUE);
    lTarget = GetLocation(oEnemy);
    */
    lTarget2 = klGetRandomLocationToLocation(lTarget, FeetToMeters(10.0));
    ActionCastSpellAtLocation(SPELL_FIREBALL, lTarget2, nMetaMagic, TRUE, PROJECTILE_PATH_TYPE_HOMING, TRUE);
    ActionWait(1.0);
    }
}

But i got this error? Why?

fDelay is not defined in your script. Compare with Mmat’s script and you’ll see it…hopefully.
You need to let the game know what you want fDelay to be. Is it an integer, a float, an object etc.

But it compiled before I added the extra effects…I just added more effects…wonder why that would effect the script?

Your script looks quite different from Mmat’s as far as I can see. I don’t think you just added stuff.

Hmm, it seems you added stuff to your own script, the one in your first post, and not Mmat’s script.

This is missing in your current script.

And I see you actually have that in your first script in this thread.

1 Like

where does that go?

Just check your own script in your first post. There you will see where it should go. I mean it’s there.

1 Like

Here is a part of your script in your first post. Do you see the float fDelay; there?

yuppers…it compiled :slight_smile:

Thanks…must have accidentally overwrote it in adding the extra effects

See you are helpful :slight_smile: