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

149 lines
4.9 KiB
Plaintext

//::///////////////////////////////////////////////
//:: Kadorto (Resurrection)
//:: kadorto.nss
//:: Copyright (c) 2025 WizardryEE Project
//:://////////////////////////////////////////////
/*
Attempts to resurrect a dead party member, even if
they've been turned to ashes. If successful, they
are revived with all hit points. If failed, they
are permanently lost.
Level 7 Priest spell.
In Wizardry: Proving Grounds of the Mad Overlord,
this is a Level 7 Priest healing/field spell that
targets one character.
*/
//:://////////////////////////////////////////////
//:: Created By: WizardryEE Project
//:: Created On: April 26, 2025
//:://////////////////////////////////////////////
#include "prc_inc_spells"
#include "prc_add_spell_dc"
#include "inc_dispel"
void main()
{
// Spell implementation for WizardryEE
// Core functionality: Attempt to resurrect a dead character
// Spellcast Hook Code
if (!X2PreSpellCastCode()) return;
// Set spell school for proper record keeping
PRCSetSchool(SPELL_SCHOOL_CONJURATION);
// Declare major variables
object oCaster = OBJECT_SELF;
object oTarget = PRCGetSpellTargetObject();
int nCasterLevel = PRCGetCasterLevel(oCaster);
int nMetaMagic = PRCGetMetaMagicFeat();
// Check if target is valid
if (!GetIsObjectValid(oTarget))
{
// Notify if no target selected
FloatingTextStringOnCreature("KADORTO: No target selected", oCaster, TRUE);
PRCSetSchool();
return;
}
// Check if target is dead
if (!GetIsDead(oTarget))
{
// Check for custom "ashes" condition
int bIsAshes = GetLocalInt(oTarget, "CONDITION_ASHES");
if (!bIsAshes)
{
// Notify if target is not dead
FloatingTextStringOnCreature("KADORTO: Target must be dead or ashes", oCaster, TRUE);
PRCSetSchool();
return;
}
}
// Calculate resurrection chance based on caster level
int nChance = 60 + (nCasterLevel * 5); // Base 60% + 5% per level
// Reduce chance if target is ashes
if (GetLocalInt(oTarget, "CONDITION_ASHES") == 1)
{
nChance -= 20; // 20% penalty for ashes
}
// Apply metamagic effects
if (CheckMetaMagic(nMetaMagic, METAMAGIC_MAXIMIZE))
{
nChance = 100; // Guaranteed success with Maximize
}
if (CheckMetaMagic(nMetaMagic, METAMAGIC_EMPOWER))
{
nChance += nChance / 2; // +50% chance with Empower
if (nChance > 100) nChance = 100; // Cap at 100%
}
// Signal spell cast at event
SignalEvent(oTarget, EventSpellCastAt(oCaster, GetSpellId(), FALSE));
// Create the resurrection effects
effect eVis = EffectVisualEffect(VFX_IMP_RAISE_DEAD);
effect eHeal = PRCEffectHeal(GetMaxHitPoints(oTarget), oTarget); // Full heal
// Attempt resurrection
if (d100() <= nChance)
{
// Success
// Apply resurrection effect
SPApplyEffectToObject(DURATION_TYPE_INSTANT, eVis, oTarget);
// Remove all effects
effect eAllEffects = GetFirstEffect(oTarget);
while (GetIsEffectValid(eAllEffects))
{
RemoveEffect(oTarget, eAllEffects);
eAllEffects = GetNextEffect(oTarget);
}
// Apply visual effect for condition removal
effect eRemove = EffectVisualEffect(VFX_IMP_REMOVE_CONDITION);
SPApplyEffectToObject(DURATION_TYPE_INSTANT, eRemove, oTarget);
// Remove custom condition flags
DeleteLocalInt(oTarget, "CONDITION_DEAD");
DeleteLocalInt(oTarget, "CONDITION_ASHES");
DeleteLocalInt(oTarget, "CONDITION_PARALYZED");
DeleteLocalInt(oTarget, "CONDITION_POISONED");
DeleteLocalInt(oTarget, "CONDITION_SLEEPING");
DeleteLocalInt(oTarget, "CONDITION_SILENCED");
DeleteLocalInt(oTarget, "CONDITION_BLINDED");
DeleteLocalInt(oTarget, "CONDITION_CONFUSED");
DeleteLocalInt(oTarget, "CONDITION_DISEASED");
// Apply resurrection and healing effects
effect eResurrect = EffectResurrection();
SPApplyEffectToObject(DURATION_TYPE_INSTANT, eResurrect, oTarget);
SPApplyEffectToObject(DURATION_TYPE_INSTANT, eHeal, oTarget);
// Notify success
FloatingTextStringOnCreature("KADORTO: " + GetName(oTarget) + " has been resurrected!", oCaster, TRUE);
}
else
{
// Failure - Character is permanently lost
// Apply visual effect for failure
effect eFailVis = EffectVisualEffect(VFX_FNF_SUMMON_UNDEAD);
SPApplyEffectToObject(DURATION_TYPE_INSTANT, eFailVis, oTarget);
// Mark as permanently lost
SetLocalInt(oTarget, "PERMANENTLY_LOST", 1);
// Notify failure
FloatingTextStringOnCreature("KADORTO: " + GetName(oTarget) + " has been permanently lost!", oCaster, TRUE);
}
// Clean up spell school variable
PRCSetSchool();
}