//:://///////////////////////////////////////////// //:: Katino (Bad Air) //:: katino.nss //:: Copyright (c) 2025 WizardryEE Project //::////////////////////////////////////////////// /* Attempts to put to sleep a monster group. Level 1 Mage spell. In Wizardry: Proving Grounds of the Mad Overlord, this is a Level 1 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: Put monster group to sleep // 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 = 1; int nDC = 10 + nCasterLevel; // Get the faction/group of the target object oFaction = GetFactionLeader(oTarget); // Create sleep visual effect at the target location location lTarget = GetLocation(oTarget); effect eSleepVis = EffectVisualEffect(39); // Sleep cloud visual effect ApplyEffectAtLocation(DURATION_TYPE_INSTANT, eSleepVis, 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, 33)); // Sleep spell ID // Allow saving throw to resist if (!WillSave(oMember, nDC, 2)) // 2 = Sleep saving throw type { // Create the sleep effect effect eSleep = EffectSleep(); effect eVis = EffectVisualEffect(38); // Sleep visual effect effect eLink = EffectLinkEffects(eSleep, eVis); // Apply the sleep effect ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eLink, oMember, RoundsToSeconds(nCasterLevel)); // Set sleep condition flag SetLocalInt(oMember, "CONDITION_SLEEPING", 1); // Notify success FloatingTextStringOnCreature(GetName(oMember) + " falls asleep!", oCaster, TRUE); nAffected++; } else { // Notify resistance FloatingTextStringOnCreature(GetName(oMember) + " resisted sleep!", oCaster, TRUE); } } // Get next faction member oMember = GetNextFactionMember(oFaction); } // Final notification if (nAffected > 0) { FloatingTextStringOnCreature("KATINO: Put " + IntToString(nAffected) + " enemies to sleep!", oCaster, TRUE); } else { FloatingTextStringOnCreature("KATINO: No enemies affected", oCaster, TRUE); } } else { // Notify if no valid target FloatingTextStringOnCreature("KATINO: No valid target found", oCaster, TRUE); } }