2025-04-26 15:20:45 -04:00

98 lines
3.7 KiB
Plaintext

//::///////////////////////////////////////////////
//:: Dilto (Darkness)
//:: dilto.nss
//:: Copyright (c) 2025 WizardryEE Project
//:://////////////////////////////////////////////
/*
Increases the armor class of a monster group by 2
for the duration of the combat.
Level 2 Mage spell.
In Wizardry: Proving Grounds of the Mad Overlord,
this is a Level 2 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: Increase monster group's AC by 2
// 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 duration (based on caster level)
int nCasterLevel = GetLevelByClass(CLASS_TYPE_WIZARD, oCaster);
if (nCasterLevel < 1) nCasterLevel = 2; // Minimum level 2 for this spell
float fDuration = RoundsToSeconds(nCasterLevel);
// Get the faction/group of the target
object oFaction = GetFactionLeader(oTarget);
// Create darkness visual effect at the target location
location lTarget = GetLocation(oTarget);
effect eDarkVis = EffectVisualEffect(37); // Darkness visual effect
ApplyEffectAtLocation(DURATION_TYPE_INSTANT, eDarkVis, 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))
{
// Create the AC increase effect
effect eAC = EffectACIncrease(2); // Increase AC by 2 (higher AC is worse)
effect eVis = EffectVisualEffect(36); // Darkness impact visual effect
effect eDur = EffectVisualEffect(15); // Negative duration visual effect
effect eLink = EffectLinkEffects(eAC, eDur);
// Signal spell cast at event
SignalEvent(oMember, EventSpellCastAt(oCaster, 34)); // Darkness spell ID
// Apply the effects
ApplyEffectToObject(DURATION_TYPE_INSTANT, eVis, oMember);
ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eLink, oMember, fDuration);
// Notify effect
FloatingTextStringOnCreature(GetName(oMember) + "'s AC increased by 2!", oCaster, TRUE);
nAffected++;
}
// Get next faction member
oMember = GetNextFactionMember(oFaction);
}
// Final notification
if (nAffected > 0)
{
FloatingTextStringOnCreature("DILTO: Affected " + IntToString(nAffected) + " enemies!", oCaster, TRUE);
}
else
{
FloatingTextStringOnCreature("DILTO: No enemies affected", oCaster, TRUE);
}
}
else
{
// Notify if no valid target
FloatingTextStringOnCreature("DILTO: No valid target found", oCaster, TRUE);
}
}