PRC8/nwn/nwnprc/trunk/spells/nw_s0_elements.nss
Jaysyn904 6ec137a24e Updated AMS marker feats
Updated AMS marker feats.  Removed arcane & divine marker feats.  Updated Dread Necromancer for epic progression. Updated weapon baseitem models.  Updated new weapons for crafting & npc equip.
 Updated prefix.  Updated release archive.
2024-02-11 14:01:05 -05:00

91 lines
3.3 KiB
Plaintext

/*
nw_s0_elements
Endure, Resist, Protection from Elements
By: Flaming_Sword
Created: Jun 16, 2006
Modified: Jun 16, 2006
Consolidation of 3 scripts, cleaned up
*/
#include "prc_sp_func"
//Implements the spell impact, put code here
// if called in many places, return TRUE if
// stored charges should be decreased
// eg. touch attack hits
//
// Variables passed may be changed if necessary
int DoSpell(object oCaster, object oTarget, int nCasterLevel, int nEvent)
{
int nSpellID = PRCGetSpellId();
int nMetaMagic = PRCGetMetaMagicFeat();
float fDuration = (nSpellID == SPELL_RESIST_ELEMENTS) ? TurnsToSeconds(nCasterLevel) : HoursToSeconds(24);
int nResistance = 0;
switch(nSpellID)
{
case SPELL_PROTECTION_FROM_ELEMENTS: nResistance += 10;
case SPELL_RESIST_ELEMENTS: nResistance += 10;
case SPELL_ENDURE_ELEMENTS: nResistance += 10; break;
}
int nAmount = nResistance + 10;
effect eCold = EffectDamageResistance(DAMAGE_TYPE_COLD, nResistance, nAmount);
effect eFire = EffectDamageResistance(DAMAGE_TYPE_FIRE, nResistance, nAmount);
effect eAcid = EffectDamageResistance(DAMAGE_TYPE_ACID, nResistance, nAmount);
effect eSonic = EffectDamageResistance(DAMAGE_TYPE_SONIC, nResistance, nAmount);
effect eElec = EffectDamageResistance(DAMAGE_TYPE_ELECTRICAL, nResistance, nAmount);
effect eDur = EffectVisualEffect(VFX_DUR_PROTECTION_ELEMENTS);
effect eVis = EffectVisualEffect(VFX_IMP_ELEMENTAL_PROTECTION);
effect eDur2 = EffectVisualEffect(VFX_DUR_CESSATE_POSITIVE);
//Fire cast spell at event for the specified target
SignalEvent(oTarget, EventSpellCastAt(OBJECT_SELF, nSpellID, FALSE));
//Link Effects
effect eLink = EffectLinkEffects(eCold, eFire);
eLink = EffectLinkEffects(eLink, eAcid);
eLink = EffectLinkEffects(eLink, eSonic);
eLink = EffectLinkEffects(eLink, eElec);
eLink = EffectLinkEffects(eLink, eDur);
eLink = EffectLinkEffects(eLink, eDur2);
//Enter Metamagic conditions
if (nMetaMagic & METAMAGIC_EXTEND)
fDuration *= 2; //Duration is +100%
PRCRemoveEffectsFromSpell(oTarget, nSpellID);
//Apply the VFX impact and effects
SPApplyEffectToObject(DURATION_TYPE_TEMPORARY, eLink, oTarget, fDuration,TRUE,-1,nCasterLevel);
SPApplyEffectToObject(DURATION_TYPE_INSTANT, eVis, oTarget);
return TRUE; //return TRUE if spell charges should be decremented
}
void main()
{
object oCaster = OBJECT_SELF;
int nCasterLevel = PRCGetCasterLevel(oCaster);
PRCSetSchool(GetSpellSchool(PRCGetSpellId()));
if (!X2PreSpellCastCode()) return;
object oTarget = PRCGetSpellTargetObject();
int nEvent = GetLocalInt(oCaster, PRC_SPELL_EVENT); //use bitwise & to extract flags
if(!nEvent) //normal cast
{
if(GetLocalInt(oCaster, PRC_SPELL_HOLD) && oCaster == oTarget)
{ //holding the charge, casting spell on self
SetLocalSpellVariables(oCaster, 1); //change 1 to number of charges
return;
}
DoSpell(oCaster, oTarget, nCasterLevel, nEvent);
}
else
{
if(nEvent & PRC_SPELL_EVENT_ATTACK)
{
if(DoSpell(oCaster, oTarget, nCasterLevel, nEvent))
DecrementSpellCharges(oCaster);
}
}
PRCSetSchool();
}