yea to get correct DC in this exact case is a bit difficult, try this:
#include "x2_i0_spells"
int GetDCBonusFromFeats(string sSchool, object oCaster);
void main()
{
object oCaster = OBJECT_SELF;
object oItem = GetSpellCastItem();
int nSpellId = GetSpellId();
int casterLevel = GetCasterLevel(oCaster);
if(oItem != OBJECT_INVALID && GetBaseItemType(oItem) != BASE_ITEM_POTIONS && GetBaseItemType(oItem) != BASE_ITEM_ENCHANTED_POTION)
{//spell cast from item
string sInnate;
int nInnate;
int bestLevel, reqLevel;
int nLevel = GetLevelByclass(class_TYPE_BARD,oCaster);
if(nLevel > 0)
{
sInnate = Get2DAString("spells","Bard",nSpellId);
nInnate = StringToInt(sInnate);
if(nInnate == 0 && sInnate == "0" || nInnate > 0)
{
reqLevel = nInnate*2;
if(nLevel >= reqLevel && nLevel > bestLevel)
{
bestLevel = nLevel;
}
}
}
nLevel = GetLevelByclass(class_TYPE_CLERIC,oCaster);
if(nLevel > 0)
{
sInnate = Get2DAString("spells","Cleric",nSpellId);
nInnate = StringToInt(sInnate);
if(nInnate == 0 && sInnate == "0" || nInnate > 0)
{
reqLevel = (nInnate*2)-1;
if(nLevel >= reqLevel && nLevel > bestLevel)
{
bestLevel = nLevel;
}
}
}
nLevel = GetLevelByclass(class_TYPE_DRUID,oCaster);
if(nLevel > 0)
{
sInnate = Get2DAString("spells","Druid",nSpellId);
nInnate = StringToInt(sInnate);
if(nInnate == 0 && sInnate == "0" || nInnate > 0)
{
reqLevel = (nInnate*2)-1;
if(nLevel >= reqLevel && nLevel > bestLevel)
{
bestLevel = nLevel;
}
}
}
nLevel = GetLevelByclass(class_TYPE_PALADIN,oCaster);
if(nLevel > 0)
{
sInnate = Get2DAString("spells","Paladin",nSpellId);
nInnate = StringToInt(sInnate);
if(nInnate == 0 && sInnate == "0" || nInnate > 0)
{
reqLevel = nInnate*3+(nInnate > 1 ? 2 : 1);
if(nLevel >= reqLevel && nLevel > bestLevel)
{
bestLevel = nLevel;
}
}
}
nLevel = GetLevelByclass(class_TYPE_RANGER,oCaster);
if(nLevel > 0)
{
sInnate = Get2DAString("spells","Ranger",nSpellId);
nInnate = StringToInt(sInnate);
if(nInnate == 0 && sInnate == "0" || nInnate > 0)
{
reqLevel = nInnate*3+(nInnate > 1 ? 2 : 1);
if(nLevel >= reqLevel && nLevel > bestLevel)
{
bestLevel = nLevel;
}
}
}
nLevel = GetLevelByclass(class_TYPE_WIZARD,oCaster);
if(nLevel > 0)
{
sInnate = Get2DAString("spells","Wiz_Sorc",nSpellId);
nInnate = StringToInt(sInnate);
if(nInnate == 0 && sInnate == "0" || nInnate > 0)
{
reqLevel = (nInnate*2)-1;
if(nLevel >= reqLevel && nLevel > bestLevel)
{
bestLevel = nLevel;
}
}
}
nLevel = GetLevelByclass(class_TYPE_SORCERER,oCaster);
if(nLevel > 0)
{
sInnate = Get2DAString("spells","Wiz_Sorc",nSpellId);
nInnate = StringToInt(sInnate);
if(nInnate == 0 && sInnate == "0" || nInnate > 0)
{
reqLevel = nInnate*2;
if(nLevel >= reqLevel && nLevel > bestLevel)
{
bestLevel = nLevel;
}
}
}
if(bestLevel > casterLevel)
{
SetLocalInt(oItem,"ITEM_CASTER_LEVEL_OVERRIDE",bestLevel);
SendMessageToPC(oCaster,"DEBUG: caster level overriden: "+IntToString(bestLevel));
}
int nDC = GetSpellSaveDC()-3;//by default DC is 13+innate, normal DC should be 10+innate+caster ability+feats
nDC+= GetCasterAbilityModifier(oCaster);
string sSchool = Get2DAString("spells","School",nSpellId);
nDC+= GetDCBonusFromFeats(sSchool,oCaster);
SetLocalInt(oItem,"ITEM_DC_OVERRIDE",nDC);
SendMessageToPC(oCaster,"DEBUG: spell DC overriden: "+IntToString(nDC));
}
}
int GetDCBonusFromFeats(string sSchool, object oCaster)
{
if(sSchool == "A")
{
if(GetHasFeat(FEAT_EPIC_SPELL_FOCUS_ABJURATION,oCaster))
{
return 6;
}
else if(GetHasFeat(FEAT_GREATER_SPELL_FOCUS_ABJURATION,oCaster))
{
return 4;
}
else if(GetHasFeat(FEAT_SPELL_FOCUS_ABJURATION,oCaster))
{
return 2;
}
}
else if(sSchool == "C")
{
if(GetHasFeat(FEAT_EPIC_SPELL_FOCUS_CONJURATION,oCaster))
{
return 6;
}
else if(GetHasFeat(FEAT_GREATER_SPELL_FOCUS_CONJURATION,oCaster))
{
return 4;
}
else if(GetHasFeat(FEAT_SPELL_FOCUS_CONJURATION,oCaster))
{
return 2;
}
}
else if(sSchool == "D")
{
if(GetHasFeat(FEAT_EPIC_SPELL_FOCUS_DIVINATION,oCaster))
{
return 6;
}
else if(GetHasFeat(FEAT_GREATER_SPELL_FOCUS_DIVINATION,oCaster))
{
return 4;
}
else if(GetHasFeat(FEAT_SPELL_FOCUS_DIVINATION,oCaster))
{
return 2;
}
}
else if(sSchool == "E")
{
if(GetHasFeat(FEAT_EPIC_SPELL_FOCUS_ENCHANTMENT,oCaster))
{
return 6;
}
else if(GetHasFeat(FEAT_GREATER_SPELL_FOCUS_ENCHANTMENT,oCaster))
{
return 4;
}
else if(GetHasFeat(FEAT_SPELL_FOCUS_ENCHANTMENT,oCaster))
{
return 2;
}
}
else if(sSchool == "V")
{
if(GetHasFeat(FEAT_EPIC_SPELL_FOCUS_EVOCATION,oCaster))
{
return 6;
}
else if(GetHasFeat(FEAT_GREATER_SPELL_FOCUS_EVOCATION,oCaster))
{
return 4;
}
else if(GetHasFeat(FEAT_SPELL_FOCUS_EVOCATION,oCaster))
{
return 2;
}
}
else if(sSchool == "I")
{
if(GetHasFeat(FEAT_EPIC_SPELL_FOCUS_ILLUSION,oCaster))
{
return 6;
}
else if(GetHasFeat(FEAT_GREATER_SPELL_FOCUS_ILLUSION,oCaster))
{
return 4;
}
else if(GetHasFeat(FEAT_SPELL_FOCUS_ILLUSION,oCaster))
{
return 2;
}
}
else if(sSchool == "N")
{
if(GetHasFeat(FEAT_EPIC_SPELL_FOCUS_NECROMANCY,oCaster))
{
return 6;
}
else if(GetHasFeat(FEAT_GREATER_SPELL_FOCUS_NECROMANCY,oCaster))
{
return 4;
}
else if(GetHasFeat(FEAT_SPELL_FOCUS_NECROMANCY,oCaster))
{
return 2;
}
}
else if(sSchool == "T")
{
if(GetHasFeat(FEAT_EPIC_SPELL_FOCUS_TRANSMUTATION,oCaster))
{
return 6;
}
else if(GetHasFeat(FEAT_GREATER_SPELL_FOCUS_TRANSMUTATION,oCaster))
{
return 4;
}
else if(GetHasFeat(FEAT_SPELL_FOCUS_TRANSMUTATION,oCaster))
{
return 2;
}
}
return 0;
}
Modifié par ShaDoOoW, 17 janvier 2012 - 06:22 .