I want to create the following spell below:
Gaze Reflection
Caster Level(s): Wiz 1
Innate Level: 1
School: Abjuration
Descriptor(s): None
Component(s): V, S
Range: 0
Area of Effect: Caster
Duration: 2 rounds + 1 round/level
Additional Counter Spells: None
Save: None
Spell Resistance: No
Description:
The spell creates a shimmering, mirror-like effect around the caster, offering protection against gaze attacks. While active, the spell grants immunity to charm effects and petrification. Additionally, any gaze-based attack directed at the caster is reflected back to the attacker, forcing them to save against their own effect. The shimmering barrier moves with the caster and lasts for the duration of the spell.
This is the script so far I have smashed together using ChatGPT that is almost there but it keeps giving errors in compiling. I feel like it is close to what needs to be done.
//::///////////////////////////////////////////////
//:: Gaze Reflection Spell
//:: NWN:EE
//::///////////////////////////////////////////////
//:: File Name: sp_gazereflect.nss
//::///////////////////////////////////////////////
#include "nw_i0_spells"
// Reflect a gaze attack back to the attacker
void ReflectGaze(object oCaster, object oAttacker)
{
// Iterate through effects on the attacker to find gaze-related effects
object oEffect = GetFirstEffect(oAttacker);
// Iterate over all effects on the attacker
while (GetIsEffectValid(oEffect))
{
// Check if the effect is a spell effect (e.g., petrification, charm)
if (GetEffectType(oEffect) == EFFECT_TYPE_SPELL_EFFECT)
{
// Apply the effect back to the attacker (reflect it)
ApplyEffectToObject(DURATION_TYPE_INSTANT, oEffect, oAttacker);
}
// Move to the next effect
oEffect = GetNextEffect(oAttacker);
}
}
// Apply Gaze Reflection effects to the caster
void ApplyGazeReflection(object oCaster, float fDuration)
{
// Apply immunity to charm and petrification effects
object eImmunityCharm = EffectImmunity(IMMUNITY_TYPE_MIND_SPELLS);
object eImmunityPetrify = EffectImmunity(IMMUNITY_TYPE_PARALYSIS);
object eCombined = EffectLinkEffects(eImmunityCharm, eImmunityPetrify);
ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eCombined, oCaster, fDuration);
// Reflective shimmering mirror-like visual effect
ApplyEffectToObject(DURATION_TYPE_TEMPORARY, EffectVisualEffect(VFX_DUR_MIRROR), oCaster, fDuration);
}
void main()
{
object oCaster = OBJECT_SELF;
float fDuration = RoundsToSeconds(2 + GetCasterLevel(oCaster));
// Apply the protective effects to the caster
ApplyGazeReflection(oCaster, fDuration);
// Set up a loop to check for attackers and reflect their gaze attacks
object oAttacker = GetNearestCreature(CREATURE_TYPE_IS_ALIVE, TRUE, oCaster, 1, CREATURE_TYPE_REPUTATION, REPUTATION_TYPE_ENEMY);
while (GetIsObjectValid(oAttacker))
{
ReflectGaze(oCaster, oAttacker);
oAttacker = GetNearestCreature(CREATURE_TYPE_IS_ALIVE, TRUE, oCaster, 1, CREATURE_TYPE_REPUTATION, REPUTATION_TYPE_ENEMY, oAttacker);
}
}