//:://///////////////////////////////////////////// //:: 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 //::////////////////////////////////////////////// void main() { // Spell implementation for WizardryEE // Core functionality: Frighten and disperse a monster group // 1. Get caster information object oCaster = OBJECT_SELF; // 2. Get the target monster group object oTarget = GetSpellTargetObject(); if (!GetIsObjectValid(oTarget)) { // If no specific target, get the nearest enemy oTarget = GetNearestCreature(CREATURE_TYPE_IS_ALIVE, TRUE, oCaster, 1, CREATURE_TYPE_PERCEPTION, PERCEPTION_SEEN, CREATURE_TYPE_REPUTATION, REPUTATION_TYPE_ENEMY); } // 3. Check if target is valid and is an enemy if (GetIsObjectValid(oTarget) && GetIsEnemy(oTarget, oCaster)) { // 4. Calculate save DC based on caster level int nCasterLevel = GetLevelByClass(CLASS_TYPE_WIZARD, oCaster); if (nCasterLevel < 1) nCasterLevel = 4; // Minimum level 4 for this spell int nDC = 10 + nCasterLevel; float fDuration = RoundsToSeconds(nCasterLevel); // Get the faction/group of the target object oFaction = GetFactionLeader(oTarget); // Create fear visual effect at the target location location lTarget = GetLocation(oTarget); effect eFearVis = EffectVisualEffect(48); // Fear visual effect ApplyEffectAtLocation(DURATION_TYPE_INSTANT, eFearVis, lTarget); // Apply to all members of the faction/group object oMember = GetFirstFactionMember(oFaction); int nAffected = 0; while (GetIsObjectValid(oMember)) { // Only affect enemies if (GetIsEnemy(oMember, oCaster)) { // Signal spell cast at event SignalEvent(oMember, EventSpellCastAt(oCaster, 28)); // Fear spell ID // Allow saving throw to resist if (!WillSave(oMember, nDC, 2)) // 2 = Fear saving throw type { // Create the fear effects effect eFear = EffectFrightened(); effect eVis = EffectVisualEffect(48); // Fear visual effect effect eDur = EffectVisualEffect(15); // Negative duration visual effect effect eLink = EffectLinkEffects(eFear, eDur); // Apply the fear effect ApplyEffectToObject(DURATION_TYPE_INSTANT, eVis, oMember); ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eLink, oMember, fDuration); // Set fear condition flag SetLocalInt(oMember, "CONDITION_FEARED", 1); // Notify success FloatingTextStringOnCreature(GetName(oMember) + " is frightened!", oCaster, TRUE); nAffected++; } else { // Notify resistance FloatingTextStringOnCreature(GetName(oMember) + " resisted fear!", oCaster, TRUE); } } // Get next faction member oMember = GetNextFactionMember(oFaction); } // Final notification if (nAffected > 0) { FloatingTextStringOnCreature("MORLIS: Frightened " + IntToString(nAffected) + " enemies!", oCaster, TRUE); } else { FloatingTextStringOnCreature("MORLIS: No enemies affected", oCaster, TRUE); } } else { // Notify if no valid target FloatingTextStringOnCreature("MORLIS: No valid target found", oCaster, TRUE); } }