Protection from Alignment
|Spell level :||Innate level: 1, Cleric: 1, Paladin: 1, Sorcerer/Wizard: 1|
|Components :||Verbal and Somatic|
|Duration :||1 Hour * cLevel|
20 Rounds (cLevel)
|Spell resistance :||No|
Protection from Alignment allows the caster to choose either protection from evil or protection from good and give the target a +2 deflection bonus to armor class, a +2 bonus to saving throws and immunity to mind-affecting spells and spell-like effects used by a creature of the chosen type.
- The saving throw increase against selected alignment stacks with the saving throw bonus granted by the Magic Circle Against Alignment, provided both this spell and the Magic Circle protect from the same alignment. Deflection bonus does not stack due to the way AC bonuses are applied in NWN2 and protection against mind-affecting spells obviously doesn't stack either, only the saving throw bonus.
In order to fix this bug, the scripts need to check whether the target is already protected by the respective other spell AND whether the target is protected by their own Magic Circle or by somebody else (if protected by own circle or Protection of Alignment - do nothing, because already protected, if protected by somebody else, remove the Magic Circle effects before applying Protection from Alignment, this is needed in case the target exits the Magic Circle AoE, losing AoE protection).
In order to check for own circle, check all current effects on potential target against GetEffectSpellId (check for SPELL_MAGIC_CIRCLE_AGAINST_GOOD / SPELL_MAGIC_CIRCLE_AGAINST_EVIL) AND GetEffectType (will return 20=EFFECT_TYPE_AREA_OF_EFFECT).
In order to check for Protection from Alignment, simply check against GetHasSpellEffect (SPELL_PROTECTION_FROM_EVIL/SPELL_PROTECTION_FROM_GOOD).
The checks are required when the spells are cast and every time a target enters the Magic Circle zone.