160 lines
5.3 KiB
Plaintext
160 lines
5.3 KiB
Plaintext
//::///////////////////////////////////////////////
|
|
//:: Di (Life)
|
|
//:: di.nss
|
|
//:: Copyright (c) 2025 WizardryEE Project
|
|
//:://////////////////////////////////////////////
|
|
/*
|
|
Attempts to resurrect a dead party member.
|
|
If successful, the dead character is revived with
|
|
only 1 hit point and decreased Vitality.
|
|
If failed, the dead character is turned to ashes.
|
|
Level 5 Priest spell.
|
|
|
|
In Wizardry: Proving Grounds of the Mad Overlord,
|
|
this is a Level 5 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"
|
|
|
|
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("DI: No target selected", oCaster, TRUE);
|
|
PRCSetSchool();
|
|
return;
|
|
}
|
|
|
|
// Check if target is dead
|
|
if (!GetIsDead(oTarget))
|
|
{
|
|
// Notify if target is not dead
|
|
FloatingTextStringOnCreature("DI: Target must be dead", oCaster, TRUE);
|
|
PRCSetSchool();
|
|
return;
|
|
}
|
|
|
|
// Check if target is ashes
|
|
if (GetLocalInt(oTarget, "CONDITION_ASHES") == 1)
|
|
{
|
|
// Notify if target is already ashes
|
|
FloatingTextStringOnCreature("DI: Target must not be ashes", oCaster, TRUE);
|
|
PRCSetSchool();
|
|
return;
|
|
}
|
|
|
|
// Calculate resurrection chance based on caster level
|
|
int nChance = 50 + (nCasterLevel * 5); // Base 50% + 5% per level
|
|
|
|
// Apply metamagic effects
|
|
if (CheckMetaMagic(nMetaMagic, METAMAGIC_MAXIMIZE))
|
|
{
|
|
nChance = 95; // Maximum chance with Maximize (still allow for failure)
|
|
}
|
|
|
|
if (CheckMetaMagic(nMetaMagic, METAMAGIC_EMPOWER))
|
|
{
|
|
nChance += nChance / 2; // +50% chance with Empower
|
|
if (nChance > 95) nChance = 95; // Cap at 95%
|
|
}
|
|
|
|
// 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(1, oTarget); // Heal 1 HP
|
|
|
|
// Attempt resurrection
|
|
if (d100() <= nChance)
|
|
{
|
|
// Success
|
|
// Apply resurrection effect
|
|
SPApplyEffectToObject(DURATION_TYPE_INSTANT, eVis, oTarget);
|
|
|
|
// Remove all effects
|
|
effect eEffect = GetFirstEffect(oTarget);
|
|
while (GetIsEffectValid(eEffect))
|
|
{
|
|
RemoveEffect(oTarget, eEffect);
|
|
eEffect = GetNextEffect(oTarget);
|
|
}
|
|
|
|
// Apply resurrection and healing effects
|
|
effect eResurrect = EffectResurrection();
|
|
SPApplyEffectToObject(DURATION_TYPE_INSTANT, eResurrect, oTarget);
|
|
SPApplyEffectToObject(DURATION_TYPE_INSTANT, eHeal, oTarget);
|
|
|
|
// Decrease Vitality (using Constitution as an analog)
|
|
effect eConDecrease = EffectAbilityDecrease(ABILITY_CONSTITUTION, 1);
|
|
SPApplyEffectToObject(DURATION_TYPE_PERMANENT, eConDecrease, oTarget);
|
|
|
|
// Apply protection effect (as a bonus for resurrection)
|
|
effect eAC = EffectACIncrease(2, AC_DEFLECTION_BONUS);
|
|
effect eSave = EffectSavingThrowIncrease(SAVING_THROW_ALL, 2);
|
|
effect eDur = EffectVisualEffect(VFX_DUR_PROTECTION_GOOD_MINOR);
|
|
effect eDur2 = EffectVisualEffect(VFX_DUR_CESSATE_POSITIVE);
|
|
|
|
// Link the effects
|
|
effect eLink = EffectLinkEffects(eSave, eAC);
|
|
eLink = EffectLinkEffects(eLink, eDur);
|
|
eLink = EffectLinkEffects(eLink, eDur2);
|
|
|
|
// Calculate duration (1 hour per caster level)
|
|
int nDuration = nCasterLevel;
|
|
if (CheckMetaMagic(nMetaMagic, METAMAGIC_EXTEND))
|
|
{
|
|
nDuration *= 2; // Duration is +100%
|
|
}
|
|
|
|
// Apply the protection effect
|
|
SPApplyEffectToObject(DURATION_TYPE_TEMPORARY, eLink, oTarget, HoursToSeconds(nDuration), TRUE, -1, nCasterLevel);
|
|
|
|
// Remove custom condition flag
|
|
DeleteLocalInt(oTarget, "CONDITION_DEAD");
|
|
|
|
// Notify success
|
|
FloatingTextStringOnCreature("DI: " + GetName(oTarget) + " has been resurrected!", oCaster, TRUE);
|
|
FloatingTextStringOnCreature("Vitality decreased by 1", oTarget, TRUE);
|
|
}
|
|
else
|
|
{
|
|
// Failure - Turn to ashes
|
|
// Apply visual effect for failure
|
|
effect eFailVis = EffectVisualEffect(VFX_FNF_SUMMON_UNDEAD);
|
|
SPApplyEffectToObject(DURATION_TYPE_INSTANT, eFailVis, oTarget);
|
|
|
|
// Set ashes condition
|
|
DeleteLocalInt(oTarget, "CONDITION_DEAD");
|
|
SetLocalInt(oTarget, "CONDITION_ASHES", 1);
|
|
|
|
// Notify failure
|
|
FloatingTextStringOnCreature("DI: " + GetName(oTarget) + " has been turned to ashes!", oCaster, TRUE);
|
|
}
|
|
|
|
// Clean up spell school variable
|
|
PRCSetSchool();
|
|
} |