//:://///////////////////////////////////////////// //:: Morlis (Fear) //:: morlis.nss //:: Copyright (c) 2025 WizardryEE Project //::////////////////////////////////////////////// /* Attempts to frighten and disperse a monster group. Level 4 Mage spell. In Wizardry: Proving Grounds of the Mad Overlord, this is a Level 4 Mage disable spell that targets a monster group. */ //::////////////////////////////////////////////// //:: 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 a monster group // 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 4 if (nCasterLevel < 4) nCasterLevel = 4; // Minimum level 4 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_LOS_NORMAL_20); 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 target location ApplyEffectAtLocation(DURATION_TYPE_INSTANT, eImpact, PRCGetSpellTargetLocation()); // Get first target in the spell area object oTarget = MyFirstObjectInShape(SHAPE_SPHERE, RADIUS_SIZE_LARGE, PRCGetSpellTargetLocation(), TRUE); // 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 if (!PRCMySavingThrow(SAVING_THROW_WILL, oTarget, PRCGetSaveDC(oTarget, oCaster), 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 frightened!", 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 fear!", 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_LARGE, PRCGetSpellTargetLocation(), TRUE); } // Final notification if (nAffected > 0) { FloatingTextStringOnCreature("MORLIS: Frightened " + IntToString(nAffected) + " enemies!", oCaster, TRUE); } else { FloatingTextStringOnCreature("MORLIS: No enemies affected", oCaster, TRUE); } // Clean up spell school variable PRCSetSchool(); }