I modified the grease spell so that if it is cast on an object that is on fire, there is a small fiery explosion that does some fire damage to enemies in the area. Everything works fine except that I can't get targets in the area of the spell to make a reflex saving throw. In the spell code I used the line:
nDamage = GetReflexAdjustedDamage(nDamage, oTarget, GetSpellSaveDC(), SAVING_THROW_TYPE_FIRE);
Is there anything else that must be done to cause a creature to make a saving throw?
Thanks.
incorporating reflex saves into a spell script
Débuté par
M. Rieder
, déc. 29 2010 04:50
#1
Posté 29 décembre 2010 - 04:50
#2
Guest_Chaos Wielder_*
Posté 30 décembre 2010 - 05:58
Guest_Chaos Wielder_*
You need the #include "nw_i0_spells" and then use the function MySavingThrow. It returns 0, FALSE, if the player fails their save.
#3
Posté 30 décembre 2010 - 08:27
For reflex-reduced damage, the function you already mentioned should handle everything; what you have to watch out for is things like Evasion, which I believe it takes into account for you. If in doubt, look at a similar spell's script and copy the appropriate bits.
#4
Posté 30 décembre 2010 - 09:28
That's the confusing part. I copied the line from the fireball spell. You know what? I copied the line from the fireball spell and put it into the grease spell. I used the function GetSpellDC(). I wonder if it isn't working because I am checking for a fire saving throw in the grease spell script. I'll check it out.
Thanks for the response.
Thanks for the response.
#5
Posté 30 décembre 2010 - 10:02
Grease doesn't do damage, though, does it? Unless you're modifying it to do so. So, you would use the function Chaos Wielder suggested rather than the damage adjustment one. However, I thought Grease already had a reflex saving throw, doesn't it?
#6
Posté 30 décembre 2010 - 11:45
I added code and now the grease spell will check the object it is cast on for a local int called "on_fire". If the local int == 1, then a conditional is triggered which does some fire damage based on the caster's level.
So maybe there is a conflict with having 2 saving throws in the same script. maybe I need to put and if else conditional to sort out the saving throws. Could that be the problem?
So maybe there is a conflict with having 2 saving throws in the same script. maybe I need to put and if else conditional to sort out the saving throws. Could that be the problem?
#7
Guest_Chaos Wielder_*
Posté 30 décembre 2010 - 11:52
Guest_Chaos Wielder_*
I don't think there's a problem with two separate saves in a given spell(take phantasmal killer for instance). Could you post the code?
#8
Posté 31 décembre 2010 - 03:07
//MODIFIED TO ALLOW THE GREASE SPELL TO FIRE THE ONSPELLCASTAT EVENT OF TARGETED PLACEABLE
//MODIFIED TO CREATE A 1d6/2 caster level MINI-FIREBALL EFFECT WITH DAMAGE WHEN CAST ON A FLAMING OBJECT
//A FLAMING OBJECT IS DENOTED BY HAVING THE INTEGER VARIABLE "on_fire" set to 1.
//::///////////////////////////////////////////////
//:: Grease
//:: NW_S0_Grease.nss
//:: Copyright © 2001 Bioware Corp.
//:://////////////////////////////////////////////
/*
Creatures entering the zone of grease must make
a reflex save or fall down. Those that make
their save have their movement reduced by 1/2.
*/
#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
*/
//ADDITION TO ALLOW TARGETED PLACEABLE'S ONSPELLCASTAT EVENT TO FIRE
object oTarget = GetSpellTargetObject();
SignalEvent(oTarget, EventSpellCastAt(GetLastSpellCaster(), SPELL_GREASE, TRUE) );
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 including Area of Effect Object
effect eAOE = EffectAreaOfEffect(AOE_PER_GREASE);
location lTarget = GetSpellTargetLocation();
//int nDuration = 2 + GetCasterLevel(OBJECT_SELF) / 3;
int nDuration = GetCasterLevel(OBJECT_SELF); // AFW-OEI 04/16/2007: Change duration to 1 round/level.
int nMetaMagic = GetMetaMagicFeat();
//Check Extend metamagic feat.
if (nMetaMagic == METAMAGIC_EXTEND)
{
nDuration = nDuration *2; //Duration is +100%
}
//*****************************************************************************
//******************************************************************************
//MODIFIED CODE - ADDS SMALL 1d6/2casterlevels FIREBALL EFFECT IF GREASE IS CAST ON A FLAMING PLACEABLE
int nIsOnFire=GetLocalInt(oTarget,"on_fire");
effect eFireburst = EffectVisualEffect(VFX_FNF_FIREBALL);//EffectNWN2SpecialEffectFile("sp_fire_aoe",oTarget);
effect eFirehit = EffectVisualEffect(VFX_IMP_FLAME_M);
//location lTarget = GetLocation(oTarget);
object oDamaged = GetFirstObjectInShape(SHAPE_SPHERE,RADIUS_SIZE_LARGE,lTarget);
//fDelay is used to make sure the effects hit the target at the right time to
//coincide with the VFX.
float fDelay = GetDistanceBetweenLocations(lTarget, GetLocation(oDamaged))/20;
object oCaster = OBJECT_SELF;
int nDamageUnadjusted;
int nDamage;
int nCasterLevel;
//debug
// FloatingTextStringOnCreature(IntToString(nIsOnFire),oCaster);
//check to see if oTarget is an object that is on fire.
//apply fireburst visual effect to oTarget
ApplyEffectToObject(DURATION_TYPE_INSTANT,eFireburst,oTarget);
if (nIsOnFire == 1)
{
//start loop to get objects in circle area
while (GetIsObjectValid(oDamaged))
{
//CALCULATE DAMAGE FOR EACH TARGET INDIVIDUALLY
nCasterLevel=GetCasterLevel(oCaster);
//set caster level to top out at 6th level
if (nCasterLevel > 6){nCasterLevel = 6;}
nDamageUnadjusted = d6(nCasterLevel/2);
nDamage = GetReflexAdjustedDamage(nDamageUnadjusted, oTarget, GetSpellSaveDC(), SAVING_THROW_TYPE_FIRE);
effect eDamage = EffectDamage(nDamage,DAMAGE_TYPE_FIRE);
//Check to see if oDamaged is hostile
if (spellsIsTarget(oDamaged, SPELL_TARGET_STANDARDHOSTILE, oCaster))
{
// Apply damage effect to oDamaged
DelayCommand(fDelay, ApplyEffectToObject(DURATION_TYPE_INSTANT, eDamage, oDamaged));
//apply visual effects to oDamaged
DelayCommand(fDelay, ApplyEffectToObject(DURATION_TYPE_INSTANT, eFirehit, oDamaged));
//DEBUG AssignCommand(oDamaged,SpeakString("ouch"));
}
oDamaged = GetNextObjectInShape(SHAPE_SPHERE,RADIUS_SIZE_LARGE,lTarget);
}
//return to keep grease effect from being applied.
return;
}
//ENDMODIFIEDCODE********************************************
//******************************************************************************
//Create an instance of the AOE Object using the Apply Effect function
ApplyEffectAtLocation(DURATION_TYPE_TEMPORARY, eAOE, lTarget, RoundsToSeconds(nDuration));
}
//MODIFIED TO CREATE A 1d6/2 caster level MINI-FIREBALL EFFECT WITH DAMAGE WHEN CAST ON A FLAMING OBJECT
//A FLAMING OBJECT IS DENOTED BY HAVING THE INTEGER VARIABLE "on_fire" set to 1.
//::///////////////////////////////////////////////
//:: Grease
//:: NW_S0_Grease.nss
//:: Copyright © 2001 Bioware Corp.
//:://////////////////////////////////////////////
/*
Creatures entering the zone of grease must make
a reflex save or fall down. Those that make
their save have their movement reduced by 1/2.
*/
#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
*/
//ADDITION TO ALLOW TARGETED PLACEABLE'S ONSPELLCASTAT EVENT TO FIRE
object oTarget = GetSpellTargetObject();
SignalEvent(oTarget, EventSpellCastAt(GetLastSpellCaster(), SPELL_GREASE, TRUE) );
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 including Area of Effect Object
effect eAOE = EffectAreaOfEffect(AOE_PER_GREASE);
location lTarget = GetSpellTargetLocation();
//int nDuration = 2 + GetCasterLevel(OBJECT_SELF) / 3;
int nDuration = GetCasterLevel(OBJECT_SELF); // AFW-OEI 04/16/2007: Change duration to 1 round/level.
int nMetaMagic = GetMetaMagicFeat();
//Check Extend metamagic feat.
if (nMetaMagic == METAMAGIC_EXTEND)
{
nDuration = nDuration *2; //Duration is +100%
}
//*****************************************************************************
//******************************************************************************
//MODIFIED CODE - ADDS SMALL 1d6/2casterlevels FIREBALL EFFECT IF GREASE IS CAST ON A FLAMING PLACEABLE
int nIsOnFire=GetLocalInt(oTarget,"on_fire");
effect eFireburst = EffectVisualEffect(VFX_FNF_FIREBALL);//EffectNWN2SpecialEffectFile("sp_fire_aoe",oTarget);
effect eFirehit = EffectVisualEffect(VFX_IMP_FLAME_M);
//location lTarget = GetLocation(oTarget);
object oDamaged = GetFirstObjectInShape(SHAPE_SPHERE,RADIUS_SIZE_LARGE,lTarget);
//fDelay is used to make sure the effects hit the target at the right time to
//coincide with the VFX.
float fDelay = GetDistanceBetweenLocations(lTarget, GetLocation(oDamaged))/20;
object oCaster = OBJECT_SELF;
int nDamageUnadjusted;
int nDamage;
int nCasterLevel;
//debug
// FloatingTextStringOnCreature(IntToString(nIsOnFire),oCaster);
//check to see if oTarget is an object that is on fire.
//apply fireburst visual effect to oTarget
ApplyEffectToObject(DURATION_TYPE_INSTANT,eFireburst,oTarget);
if (nIsOnFire == 1)
{
//start loop to get objects in circle area
while (GetIsObjectValid(oDamaged))
{
//CALCULATE DAMAGE FOR EACH TARGET INDIVIDUALLY
nCasterLevel=GetCasterLevel(oCaster);
//set caster level to top out at 6th level
if (nCasterLevel > 6){nCasterLevel = 6;}
nDamageUnadjusted = d6(nCasterLevel/2);
nDamage = GetReflexAdjustedDamage(nDamageUnadjusted, oTarget, GetSpellSaveDC(), SAVING_THROW_TYPE_FIRE);
effect eDamage = EffectDamage(nDamage,DAMAGE_TYPE_FIRE);
//Check to see if oDamaged is hostile
if (spellsIsTarget(oDamaged, SPELL_TARGET_STANDARDHOSTILE, oCaster))
{
// Apply damage effect to oDamaged
DelayCommand(fDelay, ApplyEffectToObject(DURATION_TYPE_INSTANT, eDamage, oDamaged));
//apply visual effects to oDamaged
DelayCommand(fDelay, ApplyEffectToObject(DURATION_TYPE_INSTANT, eFirehit, oDamaged));
//DEBUG AssignCommand(oDamaged,SpeakString("ouch"));
}
oDamaged = GetNextObjectInShape(SHAPE_SPHERE,RADIUS_SIZE_LARGE,lTarget);
}
//return to keep grease effect from being applied.
return;
}
//ENDMODIFIEDCODE********************************************
//******************************************************************************
//Create an instance of the AOE Object using the Apply Effect function
ApplyEffectAtLocation(DURATION_TYPE_TEMPORARY, eAOE, lTarget, RoundsToSeconds(nDuration));
}
#9
Guest_Chaos Wielder_*
Posté 31 décembre 2010 - 03:54
Guest_Chaos Wielder_*
So, everything is working except the saving throw? Looking at it, I don't see a problem. I'll try playing around with it but it really looks like it should be working. Are you absolutely sure creatures are getting no save?
#10
Posté 03 janvier 2011 - 11:36
Hi,
Just a quick look. ... Be sure that nDamageUnadjusted does not come back zero for a low level caster. Ensure a minimum of 1 is returned.
Lance.
Just a quick look. ... Be sure that nDamageUnadjusted does not come back zero for a low level caster. Ensure a minimum of 1 is returned.
Lance.
#11
Posté 04 janvier 2011 - 01:23
I'll check that, thanks Lance.
#12
Posté 04 janvier 2011 - 01:24
Chaos Wielder wrote...
So, everything is working except the saving throw? Looking at it, I don't see a problem. I'll try playing around with it but it really looks like it should be working. Are you absolutely sure creatures are getting no save?
There is no message about the saving throw popping up and the damage numbers all seem to be at 2D6, I don't see any 1D6-ish numbers.





Retour en haut






