2025-04-30 12:23:15 -04:00

132 lines
4.5 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
//:://////////////////////////////////////////////
#include "prc_inc_spells"
#include "prc_add_spell_dc"
void main()
{
// Spell implementation for WizardryEE
// Core functionality: Cone of cold damage to enemies
// Spellcast Hook Code
if (!X2PreSpellCastCode()) return;
// Set spell school for proper record keeping
PRCSetSchool(SPELL_SCHOOL_EVOCATION);
// Declare major variables
object oCaster = OBJECT_SELF;
int nCasterLevel = PRCGetCasterLevel(oCaster);
int nMetaMagic = PRCGetMetaMagicFeat();
int nPenetr = nCasterLevel + SPGetPenetr();
int nDamage;
float fDelay;
// Limit caster level for damage purposes
if (nCasterLevel > 10)
{
nCasterLevel = 10; // Cap at 10d6 damage
}
// Get the target location
location lTargetLocation = PRCGetSpellTargetLocation();
// Create the cone effect
effect eVis = EffectVisualEffect(VFX_IMP_FROST_L);
// Get the elemental damage type (default to cold)
int EleDmg = ChangedElementalDamage(oCaster, DAMAGE_TYPE_COLD);
// Declare the spell shape, size and the location
object oTarget = MyFirstObjectInShape(SHAPE_SPELLCONE, 11.0, lTargetLocation, TRUE, OBJECT_TYPE_CREATURE | OBJECT_TYPE_DOOR | OBJECT_TYPE_PLACEABLE);
// Track affected targets
int nAffected = 0;
// Cycle through the targets within the spell shape
while (GetIsObjectValid(oTarget))
{
if (spellsIsTarget(oTarget, SPELL_TARGET_STANDARDHOSTILE, oCaster))
{
// Fire cast spell at event for the specified target
SignalEvent(oTarget, EventSpellCastAt(oCaster, GetSpellId()));
// Get the distance between the target and caster to delay the application of effects
fDelay = GetDistanceBetween(oCaster, oTarget)/20.0;
// Make SR check
if (!PRCDoResistSpell(oCaster, oTarget, nPenetr, fDelay) && (oTarget != oCaster))
{
// Calculate damage - 1d6 per caster level (max 10d6)
if (CheckMetaMagic(nMetaMagic, METAMAGIC_MAXIMIZE))
{
nDamage = 6 * nCasterLevel; // Maximum damage
}
else
{
nDamage = d6(nCasterLevel);
}
if (CheckMetaMagic(nMetaMagic, METAMAGIC_EMPOWER))
{
nDamage += nDamage / 2; // +50% damage
}
// Add bonus damage per die
nDamage += SpellDamagePerDice(oCaster, nCasterLevel);
// Adjust damage according to Reflex Save, Evasion or Improved Evasion
nDamage = PRCGetReflexAdjustedDamage(nDamage, oTarget, PRCGetSaveDC(oTarget, oCaster), SAVING_THROW_TYPE_COLD);
if (nDamage > 0)
{
// Create the damage effect
effect eCold = PRCEffectDamage(oTarget, nDamage, EleDmg);
// Apply delayed effects
DelayCommand(fDelay, SPApplyEffectToObject(DURATION_TYPE_INSTANT, eVis, oTarget));
DelayCommand(fDelay, SPApplyEffectToObject(DURATION_TYPE_INSTANT, eCold, oTarget));
// Apply any bonus damage effects
PRCBonusDamage(oTarget);
// Increment affected count
nAffected++;
}
}
}
// Select the next target within the spell shape
oTarget = MyNextObjectInShape(SHAPE_SPELLCONE, 11.0, lTargetLocation, TRUE, OBJECT_TYPE_CREATURE | OBJECT_TYPE_DOOR | OBJECT_TYPE_PLACEABLE);
}
// Final notification
if (nAffected > 0)
{
FloatingTextStringOnCreature("DILTO: Cold damage to " + IntToString(nAffected) + " enemies!", oCaster, TRUE);
}
else
{
FloatingTextStringOnCreature("DILTO: No enemies affected", oCaster, TRUE);
}
// Clean up spell school variable
PRCSetSchool();
}