home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC Zone 125
/
DPPCZ0203B.7z
/
DPPCZ0203B.ISO
/
Demos
/
Neverwinter
/
data1.cab
/
override
/
nw_i0_spells.nss
< prev
next >
Wrap
Text File
|
2002-09-10
|
17KB
|
469 lines
//::///////////////////////////////////////////////
//:: Spells Include
//:: NW_I0_SPELLS
//:: Copyright (c) 2001 Bioware Corp.
//:://////////////////////////////////////////////
//:://////////////////////////////////////////////
//:: Created By: Preston Watamaniuk
//:: Created On: Jan 2, 2002
//:://////////////////////////////////////////////
// BRENT: Added a function for doing electrical traps
void TrapDoElectricalDamage(int ngDamageMaster, int nSaveDC, int nSecondary);
//Used to route the resist magic checks into this function to check for spell countering by SR, Globes or Mantles.
int MyResistSpell(object oCaster, object oTarget, float fDelay = 0.0);
//Used to route the saving throws through this function to check for spell countering by a saving throw.
int MySavingThrow(int nSavingThrow, object oTarget, int nDC, int nSaveType=SAVING_THROW_TYPE_NONE, object oSaveVersus = OBJECT_SELF, float fDelay = 0.0);
//Will pass back a linked effect for all the protection from alignment spells. The power represents the multiplier of strength.
//That is instead of +3 AC and +2 Saves a power of 2 will yield +6 AC and +4 Saves.
effect CreateProtectionFromAlignmentLink(int nAlignment, int nPower = 1);
//Will pass back a linked effect for all of the doom effects.
effect CreateDoomEffectsLink();
//Searchs through a persons effects and removes those from a particular spell by a particular caster.
void RemoveSpellEffects(int nSpell_ID, object oCaster, object oTarget);
//Searchs through a persons effects and removes all those of a specific type.
void RemoveSpecificEffect(int nEffectTypeID, object oTarget);
//Returns the time in seconds that the effect should be delayed before application.
float GetSpellEffectDelay(location SpellTargetLocation, object oTarget);
//This allows the application of a random delay to effects based on time parameters passed in. Min default = 0.4, Max default = 1.1
float GetRandomDelay(float fMinimumTime = 0.4, float MaximumTime = 1.1);
// Get Difficulty Duration
int GetScaledDuration(int nActualDuration, object oTarget);
// Get Scaled Effect
effect GetScaledEffect(effect eStandard, object oTarget);
//Remove all spell protections of a specific type
int RemoveProtections(int nSpell_ID, object oTarget, int nCount);
//
int GetSpellBreachProtection(int nLastChecked);
//Assigns a debug string to the Area of Effect Creator
void AssignAOEDebugString(string sString);
//Plays a random dragon battlecry based on age.
void PlayDragonBattleCry();
int MyResistSpell(object oCaster, object oTarget, float fDelay = 0.0)
{
if (fDelay > 0.5)
{
fDelay = fDelay - 0.1;
}
int nResist = ResistSpell(oCaster, oTarget);
effect eSR = EffectVisualEffect(VFX_IMP_MAGIC_RESISTANCE_USE);
effect eGlobe = EffectVisualEffect(VFX_IMP_GLOBE_USE);
effect eMantle = EffectVisualEffect(VFX_IMP_SPELL_MANTLE_USE);
if(nResist == 1) //Spell Resistance
{
DelayCommand(fDelay, ApplyEffectToObject(DURATION_TYPE_INSTANT, eSR, oTarget));
}
else if(nResist == 2) //Globe
{
DelayCommand(fDelay, ApplyEffectToObject(DURATION_TYPE_INSTANT, eGlobe, oTarget));
}
else if(nResist == 3) //Spell Mantle
{
if (fDelay > 0.5)
{
fDelay = fDelay - 0.1;
}
DelayCommand(fDelay, ApplyEffectToObject(DURATION_TYPE_INSTANT, eMantle, oTarget));
}
return nResist;
}
int MySavingThrow(int nSavingThrow, object oTarget, int nDC, int nSaveType=SAVING_THROW_TYPE_NONE, object oSaveVersus = OBJECT_SELF, float fDelay = 0.0)
{
//SpeakString(IntToString(nDC));
effect eVis;
int bValid = FALSE;
int nSpellID;
if(nSavingThrow == SAVING_THROW_FORT)
{
bValid = FortitudeSave(oTarget, nDC, nSaveType, oSaveVersus);
if(bValid == 1)
{
eVis = EffectVisualEffect(VFX_IMP_FORTITUDE_SAVING_THROW_USE);
}
}
else if(nSavingThrow == SAVING_THROW_REFLEX)
{
bValid = ReflexSave(oTarget, nDC, nSaveType, oSaveVersus);
if(bValid == 1)
{
eVis = EffectVisualEffect(VFX_IMP_REFLEX_SAVE_THROW_USE);
}
}
else if(nSavingThrow == SAVING_THROW_WILL)
{
bValid = WillSave(oTarget, nDC, nSaveType, oSaveVersus);
if(bValid == 1)
{
eVis = EffectVisualEffect(VFX_IMP_WILL_SAVING_THROW_USE);
}
}
nSpellID = GetSpellId();
/*
return 0 = FAILED SAVE
return 1 = SAVE SUCCESSFUL
return 2 = IMMUNE TO WHAT WAS BEING SAVED AGAINST
*/
if(bValid == 0)
{
if((nSaveType == SAVING_THROW_TYPE_DEATH
|| nSpellID == SPELL_WEIRD
|| nSpellID == SPELL_FINGER_OF_DEATH) &&
nSpellID != SPELL_HORRID_WILTING)
{
eVis = EffectVisualEffect(VFX_IMP_DEATH);
DelayCommand(fDelay, ApplyEffectToObject(DURATION_TYPE_INSTANT, eVis, oTarget));
}
}
if(bValid == 2)
{
eVis = EffectVisualEffect(VFX_IMP_MAGIC_RESISTANCE_USE);
}
if(bValid == 1 || bValid == 2)
{
if(bValid == 2)
{
/*
If the spell is save immune then the link must be applied in order to get the true immunity
to be resisted. That is the reason for returing false and not true. True blocks the
application of effects.
*/
bValid = FALSE;
}
DelayCommand(fDelay, ApplyEffectToObject(DURATION_TYPE_INSTANT, eVis, oTarget));
}
return bValid;
}
effect CreateProtectionFromAlignmentLink(int nAlignment, int nPower = 1)
{
int nFinal = nPower * 2;
effect eAC = EffectACIncrease(nFinal, AC_DEFLECTION_BONUS);
eAC = VersusAlignmentEffect(eAC, ALIGNMENT_ALL, nAlignment);
effect eSave = EffectSavingThrowIncrease(SAVING_THROW_ALL, nFinal);
eSave = VersusAlignmentEffect(eSave,ALIGNMENT_ALL, nAlignment);
effect eImmune = EffectImmunity(IMMUNITY_TYPE_MIND_SPELLS);
eImmune = VersusAlignmentEffect(eImmune,ALIGNMENT_ALL, nAlignment);
effect eDur;
if(nAlignment == ALIGNMENT_EVIL)
{
eDur = EffectVisualEffect(VFX_DUR_PROTECTION_GOOD_MINOR);
}
else if(nAlignment == ALIGNMENT_GOOD)
{
eDur = EffectVisualEffect(VFX_DUR_PROTECTION_EVIL_MINOR);
}
effect eDur2 = EffectVisualEffect(VFX_DUR_CESSATE_POSITIVE);
effect eLink = EffectLinkEffects(eImmune, eSave);
eLink = EffectLinkEffects(eLink, eAC);
eLink = EffectLinkEffects(eLink, eDur);
eLink = EffectLinkEffects(eLink, eDur2);
return eLink;
}
effect CreateDoomEffectsLink()
{
//Declare major variables
effect eSaves = EffectSavingThrowDecrease(SAVING_THROW_ALL, 2);
effect eAttack = EffectAttackDecrease(2);
effect eDamage = EffectDamageDecrease(2);
effect eSkill = EffectSkillDecrease(SKILL_ALL_SKILLS, 2);
effect eDur = EffectVisualEffect(VFX_DUR_CESSATE_NEGATIVE);
effect eLink = EffectLinkEffects(eAttack, eDamage);
eLink = EffectLinkEffects(eLink, eSaves);
eLink = EffectLinkEffects(eLink, eSkill);
eLink = EffectLinkEffects(eLink, eDur);
return eLink;
}
void RemoveSpellEffects(int nSpell_ID, object oCaster, object oTarget)
{
//Declare major variables
int bValid = FALSE;
effect eAOE;
if(GetHasSpellEffect(nSpell_ID, oTarget))
{
//Search through the valid effects on the target.
eAOE = GetFirstEffect(oTarget);
while (GetIsEffectValid(eAOE) && bValid == FALSE)
{
if (GetEffectCreator(eAOE) == oCaster)
{
//If the effect was created by the spell then remove it
if(GetEffectSpellId(eAOE) == nSpell_ID)
{
RemoveEffect(oTarget, eAOE);
bValid = TRUE;
}
}
//Get next effect on the target
eAOE = GetNextEffect(oTarget);
}
}
}
void RemoveSpecificEffect(int nEffectTypeID, object oTarget)
{
//Declare major variables
//Get the object that is exiting the AOE
int bValid = FALSE;
effect eAOE;
//Search through the valid effects on the target.
eAOE = GetFirstEffect(oTarget);
while (GetIsEffectValid(eAOE))
{
if (GetEffectType(eAOE) == nEffectTypeID)
{
//If the effect was created by the spell then remove it
bValid = TRUE;
RemoveEffect(oTarget, eAOE);
}
//Get next effect on the target
eAOE = GetNextEffect(oTarget);
}
}
float GetSpellEffectDelay(location SpellTargetLocation, object oTarget)
{
float fDelay;
return fDelay = GetDistanceBetweenLocations(SpellTargetLocation, GetLocation(oTarget))/20;
}
float GetRandomDelay(float fMinimumTime = 0.4, float MaximumTime = 1.1)
{
float fRandom = MaximumTime - fMinimumTime;
int nRandom;
if(fRandom < 0.0)
{
return 0.0;
}
else
{
nRandom = FloatToInt(fRandom * 10.0);
nRandom = Random(nRandom) + 1;
fRandom = IntToFloat(nRandom);
fRandom /= 10.0;
return fRandom + fMinimumTime;
}
}
int GetScaledDuration(int nActualDuration, object oTarget)
{
int nDiff = GetGameDifficulty();
int nNew = nActualDuration;
if(GetIsPC(oTarget) && nActualDuration > 3)
{
if(nDiff == GAME_DIFFICULTY_VERY_EASY || nDiff == GAME_DIFFICULTY_EASY)
{
nNew = nActualDuration / 4;
}
else if(nDiff == GAME_DIFFICULTY_NORMAL)
{
nNew = nActualDuration / 2;
}
if(nNew == 0)
{
nNew = 1;
}
}
return nNew;
}
effect GetScaledEffect(effect eStandard, object oTarget)
{
int nDiff = GetGameDifficulty();
effect eNew = eStandard;
object oMaster = GetMaster(oTarget);
if(GetIsPC(oTarget) || (GetIsObjectValid(oMaster) && GetIsPC(oMaster)))
{
if(GetEffectType(eStandard) == EFFECT_TYPE_FRIGHTENED && nDiff == GAME_DIFFICULTY_VERY_EASY)
{
eNew = EffectAttackDecrease(-2);
return eNew;
}
if(GetEffectType(eStandard) == EFFECT_TYPE_FRIGHTENED && nDiff == GAME_DIFFICULTY_EASY)
{
eNew = EffectAttackDecrease(-4);
return eNew;
}
if(nDiff == GAME_DIFFICULTY_VERY_EASY &&
(GetEffectType(eStandard) == EFFECT_TYPE_PARALYZE ||
GetEffectType(eStandard) == EFFECT_TYPE_STUNNED ||
GetEffectType(eStandard) == EFFECT_TYPE_CONFUSED))
{
eNew = EffectDazed();
return eNew;
}
else if(GetEffectType(eStandard) == EFFECT_TYPE_CHARMED || GetEffectType(eStandard) == EFFECT_TYPE_DOMINATED)
{
eNew = EffectDazed();
return eNew;
}
}
return eNew;
}
int RemoveProtections(int nSpell_ID, object oTarget, int nCount)
{
//Declare major variables
effect eProtection;
int nCnt = 0;
if(GetHasSpellEffect(nSpell_ID, oTarget))
{
//Search through the valid effects on the target.
eProtection = GetFirstEffect(oTarget);
while (GetIsEffectValid(eProtection))
{
//If the effect was created by the spell then remove it
if(GetEffectSpellId(eProtection) == nSpell_ID)
{
RemoveEffect(oTarget, eProtection);
//return 1;
nCnt++;
}
//Get next effect on the target
eProtection = GetNextEffect(oTarget);
}
}
if(nCnt > 0)
{
return 1;
}
else
{
return 0;
}
}
int GetSpellBreachProtection(int nLastChecked)
{
//nLastChecked++;
if(nLastChecked == 1) {return SPELL_GREATER_SPELL_MANTLE;}
else if (nLastChecked == 2){return SPELL_PREMONITION;}
else if(nLastChecked == 3) {return SPELL_SPELL_MANTLE;}
else if(nLastChecked == 4) {return SPELL_SHADOW_SHIELD;}
else if(nLastChecked == 5) {return SPELL_GREATER_STONESKIN;}
else if(nLastChecked == 6) {return SPELL_ETHEREAL_VISAGE;}
else if(nLastChecked == 7) {return SPELL_GLOBE_OF_INVULNERABILITY;}
else if(nLastChecked == 8) {return SPELL_ENERGY_BUFFER;}
else if(nLastChecked == 9) {return SPELL_MINOR_GLOBE_OF_INVULNERABILITY;}
else if(nLastChecked == 10) {return SPELL_STONESKIN;}
else if(nLastChecked == 11) {return SPELL_LESSER_SPELL_MANTLE;}
else if(nLastChecked == 12) {return SPELL_ELEMENTAL_SHIELD;}
else if(nLastChecked == 13) {return SPELL_PROTECTION_FROM_ELEMENTS;}
else if(nLastChecked == 14) {return SPELL_RESIST_ELEMENTS;}
else if(nLastChecked == 15) {return SPELL_GHOSTLY_VISAGE;}
else if(nLastChecked == 16) {return SPELL_ENDURE_ELEMENTS;}
else if(nLastChecked == 17) {return SPELL_MAGE_ARMOR;}
return nLastChecked;
}
void AssignAOEDebugString(string sString)
{
object oTarget = GetAreaOfEffectCreator();
AssignCommand(oTarget, SpeakString(sString));
}
void PlayDragonBattleCry()
{
if(d100() > 50)
{
PlayVoiceChat(VOICE_CHAT_BATTLECRY1);
}
else
{
PlayVoiceChat(VOICE_CHAT_BATTLECRY2);
}
}
void TrapDoElectricalDamage(int ngDamageMaster, int nSaveDC, int nSecondary)
{
//Declare major variables
object oTarget = GetEnteringObject();
object o2ndTarget;
effect eLightning = EffectBeam(VFX_BEAM_LIGHTNING, oTarget, BODY_NODE_CHEST);
int nDamageMaster = ngDamageMaster;
int nDamage = nDamageMaster;
effect eDam;
effect eVis = EffectVisualEffect(VFX_IMP_LIGHTNING_S);
location lTarget = GetLocation(oTarget);
int nCount = 0;
//Adjust the trap damage based on the feats of the target
if(!MySavingThrow(SAVING_THROW_REFLEX, oTarget, nSaveDC, SAVING_THROW_TYPE_ELECTRICITY))
{
if (GetHasFeat(FEAT_IMPROVED_EVASION, oTarget))
{
nDamage /= 2;
}
}
else if (GetHasFeat(FEAT_EVASION, oTarget) || GetHasFeat(FEAT_IMPROVED_EVASION, oTarget))
{
nDamage = 0;
}
else
{
nDamage /= 2;
}
if (nDamage > 0)
{
eDam = EffectDamage(nDamage, DAMAGE_TYPE_ELECTRICAL);
ApplyEffectToObject(DURATION_TYPE_INSTANT, eDam, oTarget);
ApplyEffectToObject(DURATION_TYPE_INSTANT, eVis, oTarget);
}
//Reset the damage;
nDamage = nDamageMaster;
o2ndTarget = GetFirstObjectInShape(SHAPE_SPHERE, RADIUS_SIZE_LARGE, lTarget);
while (GetIsObjectValid(o2ndTarget) && nCount <= nSecondary)
{
if(!GetIsReactionTypeFriendly(oTarget))
{
//check to see that the original target is not hit again.
if(o2ndTarget != oTarget)
{
//Adjust the trap damage based on the feats of the target
if(!MySavingThrow(SAVING_THROW_REFLEX, o2ndTarget, nSaveDC, SAVING_THROW_TYPE_ELECTRICITY))
{
if (GetHasFeat(FEAT_IMPROVED_EVASION, o2ndTarget))
{
nDamage /= 2;
}
}
else if (GetHasFeat(FEAT_EVASION, o2ndTarget) || GetHasFeat(FEAT_IMPROVED_EVASION, o2ndTarget))
{
nDamage = 0;
}
else
{
nDamage /= 2;
}
if (nDamage > 0)
{
//Set the damage effect
eDam = EffectDamage(nDamage, DAMAGE_TYPE_ELECTRICAL);
//Apply the VFX impact and damage effect
ApplyEffectToObject(DURATION_TYPE_INSTANT, eDam, o2ndTarget);
ApplyEffectToObject(DURATION_TYPE_INSTANT, eVis, o2ndTarget);
//Connect the lightning stream from one target to another.
ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eLightning, o2ndTarget, 0.75);
//Set the last target as the new start for the lightning stream
eLightning = EffectBeam(VFX_BEAM_LIGHTNING, o2ndTarget, BODY_NODE_CHEST);
}
}
//Reset the damage
nDamage = nDamageMaster;
//Increment the count
nCount++;
}
//Get next target in the shape.
o2ndTarget = GetNextObjectInShape(SHAPE_SPHERE, RADIUS_SIZE_LARGE, lTarget);
}
}