110 lines
4.0 KiB
Plaintext
110 lines
4.0 KiB
Plaintext
|
//::///////////////////////////////////////////////
|
||
|
//:: Molito (Spark Storm)
|
||
|
//:: molito.nss
|
||
|
//:: Copyright (c) 2025 WizardryEE Project
|
||
|
//:://////////////////////////////////////////////
|
||
|
/*
|
||
|
Causes 3d6 (3-18) points of damage to half of a
|
||
|
monster group.
|
||
|
Level 3 Mage spell.
|
||
|
|
||
|
In Wizardry: Proving Grounds of the Mad Overlord,
|
||
|
this is a Level 3 Mage attack spell that targets
|
||
|
half of a monster group.
|
||
|
*/
|
||
|
//:://////////////////////////////////////////////
|
||
|
//:: Created By: WizardryEE Project
|
||
|
//:: Created On: April 26, 2025
|
||
|
//:://////////////////////////////////////////////
|
||
|
|
||
|
void main()
|
||
|
{
|
||
|
// Spell implementation for WizardryEE
|
||
|
// Core functionality: Deal 3d6 damage to half of 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))
|
||
|
{
|
||
|
// Get the faction/group of the target
|
||
|
object oFaction = GetFactionLeader(oTarget);
|
||
|
|
||
|
// Create the spark storm visual effect at the target location
|
||
|
location lTarget = GetLocation(oTarget);
|
||
|
effect eStormVis = EffectVisualEffect(42); // Lightning visual effect
|
||
|
ApplyEffectAtLocation(DURATION_TYPE_INSTANT, eStormVis, lTarget);
|
||
|
|
||
|
// Count total enemies in group
|
||
|
int nTotalEnemies = 0;
|
||
|
object oCounter = GetFirstFactionMember(oFaction);
|
||
|
while (GetIsObjectValid(oCounter))
|
||
|
{
|
||
|
if (GetIsEnemy(oCounter, oCaster))
|
||
|
{
|
||
|
nTotalEnemies++;
|
||
|
}
|
||
|
oCounter = GetNextFactionMember(oFaction);
|
||
|
}
|
||
|
|
||
|
// Calculate how many to affect (half, rounded up)
|
||
|
int nToAffect = (nTotalEnemies + 1) / 2;
|
||
|
|
||
|
// Apply to half of the faction/group members
|
||
|
object oMember = GetFirstFactionMember(oFaction);
|
||
|
int nAffected = 0;
|
||
|
|
||
|
while (GetIsObjectValid(oMember) && nAffected < nToAffect)
|
||
|
{
|
||
|
// Only affect enemies
|
||
|
if (GetIsEnemy(oMember, oCaster))
|
||
|
{
|
||
|
// Calculate damage
|
||
|
int nDamage = d6(3); // 3d6 damage
|
||
|
|
||
|
// Create the damage effect
|
||
|
effect eDamage = EffectDamage(nDamage, DAMAGE_TYPE_ELECTRICAL);
|
||
|
effect eVis = EffectVisualEffect(42); // Lightning visual effect
|
||
|
|
||
|
// Signal spell cast at event
|
||
|
SignalEvent(oMember, EventSpellCastAt(oCaster, 37)); // Lightning Bolt spell ID
|
||
|
|
||
|
// Apply the visual and damage effects
|
||
|
ApplyEffectToObject(DURATION_TYPE_INSTANT, eVis, oMember);
|
||
|
ApplyEffectToObject(DURATION_TYPE_INSTANT, eDamage, oMember);
|
||
|
|
||
|
// Notify damage
|
||
|
FloatingTextStringOnCreature("MOLITO: " + IntToString(nDamage) + " spark damage to " + GetName(oMember), oCaster, TRUE);
|
||
|
nAffected++;
|
||
|
}
|
||
|
|
||
|
// Get next faction member
|
||
|
oMember = GetNextFactionMember(oFaction);
|
||
|
}
|
||
|
|
||
|
// Final notification
|
||
|
if (nAffected > 0)
|
||
|
{
|
||
|
FloatingTextStringOnCreature("MOLITO: Hit " + IntToString(nAffected) + " out of " +
|
||
|
IntToString(nTotalEnemies) + " enemies!", oCaster, TRUE);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
FloatingTextStringOnCreature("MOLITO: No enemies affected", oCaster, TRUE);
|
||
|
}
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
// Notify if no valid target
|
||
|
FloatingTextStringOnCreature("MOLITO: No valid target found", oCaster, TRUE);
|
||
|
}
|
||
|
}
|