140 lines
5.0 KiB
Plaintext
140 lines
5.0 KiB
Plaintext
//::///////////////////////////////////////////////
|
|
//:: Mamorlis (Terror)
|
|
//:: mamorlis.nss
|
|
//:: Copyright (c) 2025 WizardryEE Project
|
|
//:://////////////////////////////////////////////
|
|
/*
|
|
Attempts to frighten and disperse all monsters.
|
|
Level 5 Mage spell.
|
|
|
|
In Wizardry: Proving Grounds of the Mad Overlord,
|
|
this is a Level 5 Mage disable spell that targets
|
|
all monsters.
|
|
*/
|
|
//:://////////////////////////////////////////////
|
|
//:: Created By: WizardryEE Project
|
|
//:: Created On: April 26, 2025
|
|
//:://////////////////////////////////////////////
|
|
|
|
#include "prc_inc_spells"
|
|
#include "prc_add_spell_dc"
|
|
|
|
void main()
|
|
{
|
|
// Spell implementation for WizardryEE
|
|
// Core functionality: Frighten and disperse all monsters
|
|
|
|
// Spellcast Hook Code
|
|
if (!X2PreSpellCastCode()) return;
|
|
|
|
// Set spell school for proper record keeping
|
|
PRCSetSchool(SPELL_SCHOOL_NECROMANCY);
|
|
|
|
// Declare major variables
|
|
object oCaster = OBJECT_SELF;
|
|
int nCasterLevel = PRCGetCasterLevel(oCaster);
|
|
int nMetaMagic = PRCGetMetaMagicFeat();
|
|
int nPenetr = nCasterLevel + SPGetPenetr();
|
|
float fDuration = RoundsToSeconds(nCasterLevel);
|
|
float fDelay;
|
|
|
|
// Make sure caster level is at least 5
|
|
if (nCasterLevel < 5)
|
|
nCasterLevel = 5; // Minimum level 5 for this spell
|
|
|
|
// Check for metamagic extend
|
|
if (CheckMetaMagic(nMetaMagic, METAMAGIC_EXTEND))
|
|
{
|
|
fDuration *= 2; // Duration is +100%
|
|
}
|
|
|
|
// Create the fear effects
|
|
effect eVis = EffectVisualEffect(VFX_IMP_FEAR_S);
|
|
effect eFear = EffectFrightened();
|
|
effect eMind = EffectVisualEffect(VFX_DUR_MIND_AFFECTING_FEAR);
|
|
effect eImpact = EffectVisualEffect(VFX_FNF_HOWL_MIND);
|
|
effect eDur = EffectVisualEffect(VFX_DUR_CESSATE_NEGATIVE);
|
|
|
|
// Link the fear and mind effects
|
|
effect eLink = EffectLinkEffects(eFear, eMind);
|
|
eLink = EffectLinkEffects(eLink, eDur);
|
|
|
|
// Apply Impact at the caster location
|
|
ApplyEffectAtLocation(DURATION_TYPE_INSTANT, eImpact, GetLocation(oCaster));
|
|
|
|
// Get first object in the spell area (colossal radius - entire area)
|
|
object oTarget = MyFirstObjectInShape(SHAPE_SPHERE, RADIUS_SIZE_COLOSSAL, GetLocation(oCaster));
|
|
|
|
// Track affected targets
|
|
int nAffected = 0;
|
|
|
|
// Cycle through the targets within the spell shape
|
|
while (GetIsObjectValid(oTarget))
|
|
{
|
|
// Check if target is valid (hostile)
|
|
if (spellsIsTarget(oTarget, SPELL_TARGET_STANDARDHOSTILE, oCaster))
|
|
{
|
|
// Random delay for visual effect
|
|
fDelay = PRCGetRandomDelay();
|
|
|
|
// Fire cast spell at event for the specified target
|
|
SignalEvent(oTarget, EventSpellCastAt(oCaster, GetSpellId()));
|
|
|
|
// Make SR check
|
|
if (!PRCDoResistSpell(oCaster, oTarget, nPenetr, fDelay))
|
|
{
|
|
// Make Will save with a -2 penalty (more powerful than regular fear)
|
|
if (!PRCMySavingThrow(SAVING_THROW_WILL, oTarget, PRCGetSaveDC(oTarget, oCaster) + 2, SAVING_THROW_TYPE_FEAR, oCaster, fDelay))
|
|
{
|
|
// Check for immunity to fear
|
|
if (!GetIsImmune(oTarget, IMMUNITY_TYPE_FEAR))
|
|
{
|
|
// Apply the fear effect
|
|
SPApplyEffectToObject(DURATION_TYPE_TEMPORARY, eLink, oTarget, fDuration, TRUE, -1, nCasterLevel);
|
|
SPApplyEffectToObject(DURATION_TYPE_INSTANT, eVis, oTarget);
|
|
|
|
// Set fear condition flag
|
|
SetLocalInt(oTarget, "CONDITION_FEARED", 1);
|
|
|
|
// Notify success
|
|
DelayCommand(fDelay, FloatingTextStringOnCreature(GetName(oTarget) + " is terrified!", oCaster, TRUE));
|
|
|
|
// Increment affected count
|
|
nAffected++;
|
|
}
|
|
else
|
|
{
|
|
// Notify immunity
|
|
DelayCommand(fDelay, FloatingTextStringOnCreature(GetName(oTarget) + " is immune to fear!", oCaster, TRUE));
|
|
}
|
|
}
|
|
else
|
|
{
|
|
// Notify save
|
|
DelayCommand(fDelay, FloatingTextStringOnCreature(GetName(oTarget) + " resisted terror!", oCaster, TRUE));
|
|
}
|
|
}
|
|
else
|
|
{
|
|
// Notify SR
|
|
DelayCommand(fDelay, FloatingTextStringOnCreature(GetName(oTarget) + " has spell resistance!", oCaster, TRUE));
|
|
}
|
|
}
|
|
|
|
// Get next target in the shape
|
|
oTarget = MyNextObjectInShape(SHAPE_SPHERE, RADIUS_SIZE_COLOSSAL, GetLocation(oCaster));
|
|
}
|
|
|
|
// Final notification
|
|
if (nAffected > 0)
|
|
{
|
|
FloatingTextStringOnCreature("MAMORLIS: Terrified " + IntToString(nAffected) + " enemies!", oCaster, TRUE);
|
|
}
|
|
else
|
|
{
|
|
FloatingTextStringOnCreature("MAMORLIS: No enemies affected", oCaster, TRUE);
|
|
}
|
|
|
|
// Clean up spell school variable
|
|
PRCSetSchool();
|
|
} |