Changes nw_s0_vamptch

:://///////
:: Vampiric Touch
:: NW_S0_VampTch
:: Copyright (c) 2001 Bioware Corp.
:://////////
/*
drain 1d6
HP per 2 caster levels from the target.
*/
:://////////
:: Created By: Preston Watamaniuk
:: Created On: Oct 29, 2001
:://////////

/*
bugfix by Kovi 2002.07.22
- did double damage with maximize
- temporary hp was stacked
2002.08.25
- got temporary hp some immune creatures (Negative Energy Protection), lost
temporary hp against other resistant (SR, Shadow Shield)

Georg 2003-09-11
- Put in melee touch attack check, as the fixed attack bonus is now calculated correctly

*/

// (Update JLR - OEI 07/19/05) — Changed Dmg to 1d8/per 2 lvls
// PKM-OEI 09.16.06 — Reduced the damage back down to 1d6

#include "x0_I0_SPELLS"
#include "x2_inc_spellhook"
#include "nw_i0_invocatns"

void main()
{

//--------------
/* Spellcast Hook Code
Added 2003-06-20 by Georg
If you want to make changes to all spells,
check x2_inc_spellhook.nss to find out more
*/
//
--------------

if (!X2PreSpellCastCode())
{
return;
}
//--------------
// End of Spell Cast Hook
//
--------------

object oTarget = GetSpellTargetObject();
int nMetaMagic = GetMetaMagicFeat();

int nCasterLevel = GetCasterLevel(OBJECT_SELF);
int nDDice = nCasterLevel /2;
int nTouch = TouchAttackMelee(oTarget, GetSpellCastItem() == OBJECT_INVALID);

//PKM-OEI: 05.28.07: Do critical hit damage
if (nTouch == TOUCH_ATTACK_RESULT_CRITICAL)
{
nDDice = nDDice * 2;
}

if ((nDDice) == 0)
{
nDDice = 1;
}
//--------------
// GZ: Cap according to the book
//
--------------
else if (nDDice>10)
{
nDDice = 10;
}

int nDamage = d6(nDDice); // JLR - OEI 07/19/05

//--------------
//Enter Metamagic conditions
//
--------------

nDamage = MaximizeOrEmpower(8,nDDice,nMetaMagic); // JLR - OEI 07/19/05
int nDuration = nCasterLevel/2;

if (nMetaMagic == METAMAGIC_EXTEND)
{
nDuration *= 2;
}

//--------------
//Limit damage to max hp + 10
//
--------------
int nMax = GetCurrentHitPoints(oTarget) + 10;
if(nMax < nDamage)
{
nDamage = nMax;
}

effect eHeal = EffectTemporaryHitpoints(nDamage);
effect eDamage;
effect eVis;
// Added Eldritch Theurge Spellweave Ability

if ((GetHasFeat(FEAT_ELDRITCH_SPELLWEAVE)) && ( nMetaMagic & METAMAGIC_INVOC_BRIMSTONE_BLAST ))
{
eDamage = EffectDamage(nDamage, DAMAGE_TYPE_FIRE);
eVis = EffectVisualEffect(VFX_HIT_SPELL_FIRE);
}
else
{
eDamage = EffectDamage(nDamage, DAMAGE_TYPE_NEGATIVE);
eVis = EffectVisualEffect(VFX_HIT_SPELL_NECROMANCY);

effect eVisHeal = EffectVisualEffect(VFX_IMP_HEALING_S);
if(GetObjectType(oTarget) == OBJECT_TYPE_CREATURE)
{
if (spellsIsTarget(oTarget, SPELL_TARGET_STANDARDHOSTILE, OBJECT_SELF) &&
GetRacialType(oTarget) != RACIAL_TYPE_UNDEAD &&
GetRacialType(oTarget) != RACIAL_TYPE_CONSTRUCT &&
(!( nMetaMagic & METAMAGIC_INVOC_BRIMSTONE_BLAST )&&(GetHasSpellEffect(SPELL_NEGATIVE_ENERGY_PROTECTION, oTarget))))
{

SignalEvent(OBJECT_SELF, EventSpellCastAt(OBJECT_SELF, SPELL_VAMPIRIC_TOUCH, FALSE));
SignalEvent(oTarget, EventSpellCastAt(OBJECT_SELF, SPELL_VAMPIRIC_TOUCH, TRUE));
// GZ: * GetSpellCastItem() == OBJECT_INVALID is used to prevent feedback from showing up when used as OnHitCastSpell property
if (nTouch>0)
{
if(MyResistSpell(OBJECT_SELF, oTarget) == 0)
{
ApplyEffectToObject(DURATION_TYPE_INSTANT, eVis, oTarget);
ApplyEffectToObject(DURATION_TYPE_INSTANT, eDamage, oTarget);
ApplyEffectToObject(DURATION_TYPE_INSTANT, eVisHeal, OBJECT_SELF);
RemoveTempHitPoints();
ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eHeal, OBJECT_SELF, HoursToSeconds(nDuration));

/*////////////*/
// Draco Rayne: Added Eldritch Theurge Spellweave Ability
/*
//////////////*/

if (GetHasFeat(FEAT_ELDRITCH_SPELLWEAVE))
{
if ( nMetaMagic & METAMAGIC_INVOC_BRIMSTONE_BLAST ) DoETMetaBrimstoneBlast(OBJECT_SELF, oTarget);
if ( nMetaMagic & METAMAGIC_INVOC_FRIGHTFUL_BLAST ) DoETMetaFrightfulBlast(OBJECT_SELF, oTarget);
if ( nMetaMagic & METAMAGIC_INVOC_DRAINING_BLAST ) DoETMetaDrainingBlast(OBJECT_SELF, oTarget);
}

}
}
}
}
}
}

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License