Jaysyn904 102ba7dab6 Initial Commit
Initial Commit
2023-09-21 19:51:32 -04:00

57 lines
2.2 KiB
Plaintext

void main()
{
object oCaster = OBJECT_SELF;//get caster
object oItem = GetSpellCastItem();//get item from which was spell cast
int nSpellId = GetSpellId();//get spell id
int nClass = GetLastSpellCastClass();
int origCasterLevel = GetCasterLevel(oCaster);//get original caster level
int origDC = GetSpellSaveDC();//get original DC
int origMeta = GetMetaMagicFeat();//get original metamagic feat
SetLocalInt(oCaster,"SPELL_DC_OVERRIDE",0);//reset to default
SetLocalInt(oCaster,"SPELL_CASTER_LEVEL_OVERRIDE",0);//reset to default
if(oItem != OBJECT_INVALID && GetLocalInt(oCaster, "anc_castercheat") == FALSE) return;//if the spell was cast from item then exit because the bonuses shown here are not applicable for items
int newCasterLevel = origCasterLevel;
int newDC = origDC;
int newMeta = origMeta;
//Use the character's level if we want it to cheat
if (GetLocalInt(oCaster, "anc_castercheat") == TRUE) newCasterLevel = GetHitDice(oCaster);
//Add DD levels to bard or sorcerer caster level
if((nClass == CLASS_TYPE_SORCERER) || (nClass == CLASS_TYPE_BARD))
{
int nDDBonus = GetLevelByClass(CLASS_TYPE_DRAGON_DISCIPLE,oCaster)-5;
if (nDDBonus < 0) nDDBonus = 0;
newCasterLevel+= nDDBonus;
}
//Empower the spell if cast by an NPC allowed to do so
if(GetLocalString(oCaster, "sTrait1") == "damage" || GetLocalString(oCaster, "sTrait2") == "damage")
newMeta = METAMAGIC_MAXIMIZE;
//Increase the caster level if the NPC is allowed to do so
if(GetLocalString(oCaster, "sTrait1") == "attack" || GetLocalString(oCaster, "sTrait2") == "attack")
newCasterLevel += 5;
//Add to DC when cast by epic spellcasters
if(newCasterLevel >= 21) newDC += 1;
if(newCasterLevel >= 26) newDC += 1;
if(newCasterLevel >= 31) newDC += 1;
if(newCasterLevel >= 36) newDC += 1;
if(newCasterLevel >= 40) newDC += 1;
//Maximize spells if appropriate
if (GetLocalInt(oCaster, "anc_metamax") == TRUE) newMeta = METAMAGIC_MAXIMIZE;
//now when are we done, set the variables
SetLocalInt(oCaster,"SPELL_DC_OVERRIDE",newDC);
SetLocalInt(oCaster,"SPELL_CASTER_LEVEL_OVERRIDE",newCasterLevel);
SetLocalInt(oCaster,"SPELL_METAMAGIC_OVERRIDE",newMeta);
//done, the spell which is triggered right after this script ends will use these values
}