I’m back with my noobish questions.
I’m trying to add some exceptions in a few of my scripts. Let’s take Wail of the banshee spell as an example. It has EffectDeath()
as the only effect (besides visuals) when oTarget fails the fort save.
What I’m trying to do is to add an exception that will apply damage to the target on successful save throw and when he’s immune to death.
That first part is easy to achieve, but I’m having issues with catching that death immunity.
What I’ve tried so far:
- function
GetIsImmune
with IMMUNITY_TYPE_DEATH
- switch with
MySavingThrow
(it should return 2 if target is immune to death)
Both of those failed and it doesn’t work as intended. It doesn’t catch creatures’ death immunity (e.g. undead) nor death immunity from item.
Here’s a code sample:
//Make a fortitude save to avoid death
switch (MySavingThrow(spell.SavingThrow, oTarget, spell.DC, SAVING_THROW_TYPE_DEATH, spell.Caster, fDelay))
{
//Failed save
case 0:
//Apply the death effect
DelayCommand(fDelay, ApplyEffectToObject(DURATION_TYPE_INSTANT, eDeath, oTarget));
break;
//Succeeded save
case 1:
//Immune to death
case 2:
//Roll damage
nDamage = MaximizeOrEmpower(6, spell.DamageCap, spell.Meta, spell.Level);
//Set damage effect
eDam = EffectDamage(nDamage, spell.DamageType);
//Apply damage effect
DelayCommand(fDelay, ApplyEffectToObject(DURATION_TYPE_INSTANT, eDam, oTarget));
break;
}
What am I doing wrong?
I think you do nothing wrong. The problem must be elsewhere.
MySavingThrow should return 2 under community patch, but in vanilla it returns 0
Therefore it could mean that in your module there is vanilla nw_i0_spells so you are using vanilla MySavingThrow.
If that is not the case, maybe this could be a bug in nwn©x_patch plugin, do you use nwnx? If so, try without. If it works without it is bug in my plugin and I will investigate.
Otherwise I don’t know but I would try debug it.
Make it print a debug message under case 0: case 1: and case 2:
also make the spell print debug message with result of GetIsImmune(oTarget,IMMUNITY_TYPE_DEATH). This could give a clue…
If you don’t solve this let me know what were result of those debug messages.
EDIT: one more idea, is the spell.SavingThrow defined at the top of the spellscript? there should be spell.SavingThrow = SAVING_THROW_FORT; , also try debug spell.SavingThrow before the roll, it might be possible you overriden that value in spellhook and therefore the MySavingThrow function makes no roll and returns 0. Though if it didn’t make a roll then you would probably know it…
1 Like
You could just do the damage not matter what and then use the effect death if the save is failed. Those not who fail the save and are immune to death will just get the damage and those who are not will not notice the damage since they will be dead…
2 Likes
@Shadooow You were right about that vanilla nw_i0_spells.nss. I’ve updated it to 1.72 CPP and added debug messages in each case. Now it returns correct values and my script works like a charm. Thank you.