Author Topic: I can not change a spell.  (Read 440 times)

Legacy_Cursed Eclipse

  • Full Member
  • ***
  • Posts: 132
  • Karma: +0/-0
I can not change a spell.
« on: December 28, 2011, 11:04:41 am »


               Hello.
I would like to ensure that the darts launched with IGMs are equal to the modifier of the caster.


here's what I changed


int MyResistSpell(object oCaster, object oTarget, float fDelay = 0.0);
int spellsIsTarget(object oTarget, int nTargetType, object oSource);

void DoMissileStorm(int nD6Dice, int nCap, int nSpell, int nMIRV = VFX_IMP_MIRV, int nVIS = VFX_IMP_MAGBLUE, int nDAMAGETYPE = DAMAGE_TYPE_MAGICAL, int nONEHIT = FALSE, int nReflexSave = FALSE)
{
    object oTarget = OBJECT_INVALID;
////////////////////////////////////////////////////////////////////////////////////
//I changed only this part of code.
/////////////////////////////////////////////////////////////////////////////////////  
int nclass = GetLastSpellCastclass();

    //int nCasterLvl = GetLevelByclass(OBJECT_SELF); <- before was on CasterLvl
   
int nMissiles;

    switch (nclass)
    {
    case class_TYPE_WIZARD: nMissiles = GetAbilityScore(OBJECT_SELF, ABILITY_INTELLIGENCE, FALSE);
    break;
    case class_TYPE_SORCERER: nMissiles = GetAbilityScore(OBJECT_SELF, ABILITY_CHARISMA, FALSE);
    break;
    default:  nMissiles = 1;
    break;
    }
/////////////////////////gives a bonus if you have these talents.////////////////////////////////////////////////////////////////////
    if(GetHasFeat(FEAT_SPELL_FOCUS_EVOCATION, OBJECT_SELF)) nMissiles += 2;
    if(GetHasFeat(FEAT_GREATER_SPELL_FOCUS_EVOCATION, OBJECT_SELF)) nMissiles += 4;
    if(GetHasFeat(FEAT_EPIC_SPELL_FOCUS_EVOCATION, OBJECT_SELF)) nMissiles += 6
;
/*------------------------------------------------------------------------------------------------------------------------------*/
//////////////END OF CHANGES////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    int nMetaMagic = GetMetaMagicFeat();
    int nCnt = 1;
    effect eMissile = EffectVisualEffect(nMIRV);
    effect eVis = EffectVisualEffect(nVIS);
    float fDist = 0.0;
    float fDelay = 0.0;
    float fDelay2, fTime;
    location lTarget = GetSpellTargetLocation(); // missile spread centered around caster
    //int nMissiles = nCasterLvl;//

    if (nMissiles > nCap)
    {
        nMissiles = nCap;
    }

        /* New Algorithm
            1. Count # of targets
            2. Determine number of missiles
            3. First target gets a missile and all Excess missiles
            4. Rest of targets (max nMissiles) get one missile
       */
    int nEnemies = 0;

    oTarget = GetFirstObjectInShape(SHAPE_SPHERE, RADIUS_SIZE_GARGANTUAN, lTarget, TRUE, OBJECT_TYPE_CREATURE);
    //Cycle through the targets within the spell shape until an invalid object is captured.
    while (GetIsObjectValid(oTarget) )
    {
        // * caster cannot be harmed by this spell
        if (spellsIsTarget(oTarget, SPELL_TARGET_STANDARDHOSTILE, OBJECT_SELF) && (oTarget != OBJECT_SELF))
        {
            // GZ: You can only fire missiles on visible targets
            // If the firing object is a placeable (such as a projectile trap),
            // we skip the line of sight check as placeables can't "see" things.
            if ( ( GetObjectType(OBJECT_SELF) == OBJECT_TYPE_PLACEABLE ) ||
                   GetObjectSeen(oTarget,OBJECT_SELF))
            {
                nEnemies++;
            }
        }
        oTarget = GetNextObjectInShape(SHAPE_SPHERE, RADIUS_SIZE_GARGANTUAN, lTarget, TRUE, OBJECT_TYPE_CREATURE);
     }

     if (nEnemies == 0) return; // * Exit if no enemies to hit
     int nExtraMissiles = nMissiles / nEnemies;

     // April 2003
     // * if more enemies than missiles, need to make sure that at least
     // * one missile will hit each of the enemies
     if (nExtraMissiles <= 0)
     {
        nExtraMissiles = 1;
     }

     // by default the Remainder will be 0 (if more than enough enemies for all the missiles)
     int nRemainder = 0;

     if (nExtraMissiles >0)
        nRemainder = nMissiles % nEnemies;

     if (nEnemies > nMissiles)
        nEnemies = nMissiles;

    oTarget = GetFirstObjectInShape(SHAPE_SPHERE, RADIUS_SIZE_GARGANTUAN, lTarget, TRUE, OBJECT_TYPE_CREATURE);
    //Cycle through the targets within the spell shape until an invalid object is captured.
    while (GetIsObjectValid(oTarget) && nCnt <= nEnemies)
    {
        // * caster cannot be harmed by this spell
        if (spellsIsTarget(oTarget, SPELL_TARGET_SELECTIVEHOSTILE, OBJECT_SELF) &&
           (oTarget != OBJECT_SELF) &&
           (( GetObjectType(OBJECT_SELF) == OBJECT_TYPE_PLACEABLE ) ||
           (GetObjectSeen(oTarget,OBJECT_SELF))))
            {
                //Fire cast spell at event for the specified target
                SignalEvent(oTarget, EventSpellCastAt(OBJECT_SELF, nSpell));

                // * recalculate appropriate distances
                fDist = GetDistanceBetween(OBJECT_SELF, oTarget);
                fDelay = fDist/(3.0 * log(fDist) + 2.0);

                // Firebrand.
                // It means that once the target has taken damage this round from the
                // spell it won't take subsequent damage
                if (nONEHIT == TRUE)
                {
                    nExtraMissiles = 1;
                    nRemainder = 0;
                }

                int i = 0;
                //--------------------------------------------------------------
                // GZ: Moved SR check out of loop to have 1 check per target
                //     not one check per missile, which would rip spell mantels
                //     apart
                //--------------------------------------------------------------
                if (!MyResistSpell(OBJECT_SELF, oTarget, fDelay))
                {
                    for (i=1; i <= nExtraMissiles + nRemainder; i++)
                    {
                        //Roll damage
                        int nDam = d6(nD6Dice);
                        //Enter Metamagic conditions
                        if (nMetaMagic == METAMAGIC_MAXIMIZE)
                        {
                             nDam = nD6Dice*6;//Damage is at max
                        }
                        if (nMetaMagic == METAMAGIC_EMPOWER)
                        {
                              nDam = nDam + nDam/2; //Damage/Healing is +50%
                        }
                        // Jan. 29, 2004 - Jonathan Epp
                        // Reflex save was not being calculated for Firebrand
                        if(nReflexSave)
                        {
                            if ( nDAMAGETYPE == DAMAGE_TYPE_ELECTRICAL )
                            {
                                nDam = GetReflexAdjustedDamage(nDam, oTarget, GetSpellSaveDC(), SAVING_THROW_TYPE_ELECTRICITY);
                            }
                            else if ( nDAMAGETYPE == DAMAGE_TYPE_FIRE )
                            {
                                nDam = GetReflexAdjustedDamage(nDam, oTarget, GetSpellSaveDC(), SAVING_THROW_TYPE_FIRE);
                            }
                        }

                        fTime = fDelay;
                        fDelay2 += 0.1;
                        fTime += fDelay2;

                        //Set damage effect
                        effect eDam = EffectDamage(nDam, nDAMAGETYPE);
                        //Apply the MIRV and damage effect
                        DelayCommand(fTime, ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eVis, oTarget));
                        DelayCommand(fDelay2, ApplyEffectToObject(DURATION_TYPE_INSTANT, eMissile, oTarget));
                        DelayCommand(fTime, ApplyEffectToObject(DURATION_TYPE_INSTANT, eDam, oTarget));
                    }
                } // for
                else
                {  // * apply a dummy visual effect
                 ApplyEffectToObject(DURATION_TYPE_INSTANT, eMissile, oTarget);
                }
                nCnt++;// * increment count of missiles fired
                nRemainder = 0;
        }
        oTarget = GetNextObjectInShape(SHAPE_SPHERE, RADIUS_SIZE_GARGANTUAN, lTarget, TRUE, OBJECT_TYPE_CREATURE);
    }

}
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;
    }

   DoMissileStorm(2, 20, SPELL_ISAACS_GREATER_MISSILE_STORM);

}


I'm not sure this is the way to change it, also when I try to compile the script there is an error to the line

if (spellsIsTarget(oTarget, SPELL_TARGET_STANDARDHOSTILE, OBJECT_SELF) && (oTarget !=OBJECT_SELF))

ERROR: VARIABLE DEFINED WITHOUT TYPE  ?? ':?'








EDIT
another solution could be

int nclass = GetLastSpellCastclass();
int nLevel = GetLevelByclass(nclass);

int nMissiles;

int nCha =  GetAbilityModifier(ABILITY_CHARISMA,OBJECT_SELF);
int nInt =  GetAbilityModifier(ABILITY_INTELLIGENCE,OBJECT_SELF);


if (nclass == class_TYPE_WIZARD)
      {
          nMissiles = nInt;
       }
       else
       {
           nMissiles = nCha;
        }


if(nMissiles < 0)
{
nMissiles =  1
}


but I do not know what is the best between the two I posted.
               
               

               


                     Modifié par Cursed Eclipse, 28 décembre 2011 - 11:29 .
                     
                  


            

Legacy_Stammer

  • Newbie
  • *
  • Posts: 6
  • Karma: +0/-0
I can not change a spell.
« Reply #1 on: December 28, 2011, 12:04:48 pm »


               
Quote
Cursed Eclipse wrote...

Hello.
I would like to ensure that the darts launched with IGMs are equal to the modifier of the caster.


here's what I changed


Quote


int MyResistSpell(object oCaster, object oTarget, float fDelay = 0.0);
int spellsIsTarget(object oTarget, int nTargetType, object oSource);

void DoMissileStorm(int nD6Dice, int nCap, int nSpell, int nMIRV = VFX_IMP_MIRV, int nVIS = VFX_IMP_MAGBLUE, int nDAMAGETYPE = DAMAGE_TYPE_MAGICAL, int nONEHIT = FALSE, int nReflexSave = FALSE)
{
    object oTarget = OBJECT_INVALID;
////////////////////////////////////////////////////////////////////////////////////
//I changed only this part of code.
/////////////////////////////////////////////////////////////////////////////////////  
int nclass = GetLastSpellCastclass();

    //int nCasterLvl = GetLevelByclass(OBJECT_SELF); <- before was on CasterLvl
   
int nMissiles;

    switch (nclass)
    {
    case class_TYPE_WIZARD: nMissiles = GetAbilityScore(OBJECT_SELF, ABILITY_INTELLIGENCE, FALSE);
    break;
    case class_TYPE_SORCERER: nMissiles = GetAbilityScore(OBJECT_SELF, ABILITY_CHARISMA, FALSE);
    break;
    default:  nMissiles = 1;
    break;
    }
/////////////////////////gives a bonus if you have these talents.////////////////////////////////////////////////////////////////////
    if(GetHasFeat(FEAT_SPELL_FOCUS_EVOCATION, OBJECT_SELF)) nMissiles += 2;
    if(GetHasFeat(FEAT_GREATER_SPELL_FOCUS_EVOCATION, OBJECT_SELF)) nMissiles += 4;
    if(GetHasFeat(FEAT_EPIC_SPELL_FOCUS_EVOCATION, OBJECT_SELF)) nMissiles += 6
;
/*------------------------------------------------------------------------------------------------------------------------------*/
//////////////END OF CHANGES////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    int nMetaMagic = GetMetaMagicFeat();
    int nCnt = 1;
    effect eMissile = EffectVisualEffect(nMIRV);
    effect eVis = EffectVisualEffect(nVIS);
    float fDist = 0.0;
    float fDelay = 0.0;
    float fDelay2, fTime;
    location lTarget = GetSpellTargetLocation(); // missile spread centered around caster
    //int nMissiles = nCasterLvl;//

    if (nMissiles > nCap)
    {
        nMissiles = nCap;
    }

        /* New Algorithm
            1. Count # of targets
            2. Determine number of missiles
            3. First target gets a missile and all Excess missiles
            4. Rest of targets (max nMissiles) get one missile
       */
.......


There might be a problem with the nCap part of the original script....
               
               

               
            

Legacy_Cursed Eclipse

  • Full Member
  • ***
  • Posts: 132
  • Karma: +0/-0
I can not change a spell.
« Reply #2 on: December 28, 2011, 02:23:46 pm »


               what kind of problem?
               
               

               
            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
I can not change a spell.
« Reply #3 on: December 29, 2011, 03:17:41 am »


               IGMS in 1.70

#include "70_inc_spells"
#include "x0_i0_spells"
#include "70_inc_spellfunc"
#include "x2_inc_spellhook"

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

    struct spell spell = spellsDeclareMajorVariables();
    int nMod = GetCasterAbilityModifier(spell.Caster);
    DoMissileStormSpell(2, nMod, spell);
}

in 1.69

#include "X0_I0_SPELLS"
#include "x2_inc_spellhook"

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

    int nMod = GetCasterAbilityModifier(OBJECT_SELF);

    DoMissileStorm(2, nMod, SPELL_ISAACS_GREATER_MISSILE_STORM);
}


edit OK, i see you want bonus for focuses, then it should be like this:
1.70
int nMod = spell.DC-16;
1.69
int nMod = GetSpellSaveDC()-16;

the -16 is for IGMS, as DC is calculated as 10+spell lvl (6for igms 4 for ilms) + caster modifier + spell focus feats
               
               

               


                     Modifié par ShaDoOoW, 29 décembre 2011 - 06:41 .
                     
                  


            

Legacy_Cursed Eclipse

  • Full Member
  • ***
  • Posts: 132
  • Karma: +0/-0
I can not change a spell.
« Reply #4 on: December 29, 2011, 01:47:11 pm »


               thx for reply ShadoOow ,I had already installed the 1.70 (2 days after the launch),but I haven't merged all the scripts,because I had already changed all spells and did not want to redo all the work again.

anyway there is an error when i try to compile -missstorm2-

#include "X0_I0_SPELLS"
#include "x2_inc_spellhook"

void main()
{
   if (!X2PreSpellCastCode())
   {
   // If code within the PreSpellCastHook (i.e. UMD) reports FALSE, do not run this spell
       return;
   }

  int nMod = GetCasterAbilityModifier(OBJECT_SELF);
  int nMod = spell.DC-16; // HERE< - varible defined whitout type.
   DoMissileStorm(2, nMod, SPELL_ISAACS_GREATER_MISSILE_STORM);



What should I change now?
               
               

               
            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
I can not change a spell.
« Reply #5 on: December 29, 2011, 02:40:53 pm »


               if you are running 1.70 you can put this into your spellscript and it should compile:

#include "70_inc_spells"
#include "x0_i0_spells"
#include "70_inc_spellfunc"
#include "x2_inc_spellhook"

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

   struct spell spell = spellsDeclareMajorVariables();
   int nMod = spell.DC-16;
   DoMissileStormSpell(2, nMod, spell);
}

reason why it doesnt compile is that you are missing the initial struct spell spell = spellsDeclareMajorVariables(); line that is a basic line for all 1.70 spellscripts.