@ -68,7 +68,8 @@ namespace MWMechanics
if ( ! ( spell . mData . mFlags & ESM : : Spell : : F_Autocalc ) )
continue ;
static const int iAutoSpellTimesCanCast = gmst . find ( " iAutoSpellTimesCanCast " ) - > mValue . getInteger ( ) ;
if ( baseMagicka < iAutoSpellTimesCanCast * spell . mData . mCost )
int spellCost = MWMechanics : : calcSpellCost ( spell ) ;
if ( baseMagicka < iAutoSpellTimesCanCast * spellCost )
continue ;
if ( race & & race - > mPowers . exists ( spell . mId ) )
@ -83,7 +84,7 @@ namespace MWMechanics
assert ( school > = 0 & & school < 6 ) ;
SchoolCaps & cap = schoolCaps [ school ] ;
if ( cap . mReachedLimit & & spell . mData . m Cost < = cap . mMinCost )
if ( cap . mReachedLimit & & spell Cost < = cap . mMinCost )
continue ;
static const float fAutoSpellChance = gmst . find ( " fAutoSpellChance " ) - > mValue . getFloat ( ) ;
@ -102,6 +103,7 @@ namespace MWMechanics
for ( const std : : string & testSpellName : selectedSpells )
{
const ESM : : Spell * testSpell = spells . find ( testSpellName ) ;
int testSpellCost = MWMechanics : : calcSpellCost ( * testSpell ) ;
//int testSchool;
//float dummySkillTerm;
@ -115,9 +117,9 @@ namespace MWMechanics
// already erased it, and so the number of spells would often exceed the sum of limits.
// This bug cannot be fixed without significantly changing the results of the spell autocalc, which will not have been playtested.
//testSchool == school &&
testSpell - > mData . m Cost < cap . mMinCost )
testSpell Cost < cap . mMinCost )
{
cap . mMinCost = testSpell - > mData . m Cost;
cap . mMinCost = testSpell Cost;
cap . mWeakestSpell = testSpell - > mId ;
}
}
@ -128,10 +130,10 @@ namespace MWMechanics
if ( cap . mCount = = cap . mLimit )
cap . mReachedLimit = true ;
if ( spell . mData . m Cost < cap . mMinCost )
if ( spell Cost < cap . mMinCost )
{
cap . mWeakestSpell = spell . mId ;
cap . mMinCost = spell . mData . m Cost;
cap . mMinCost = spell Cost;
}
}
}
@ -159,11 +161,13 @@ namespace MWMechanics
continue ;
if ( ! ( spell . mData . mFlags & ESM : : Spell : : F_PCStart ) )
continue ;
if ( reachedLimit & & spell . mData . mCost < = minCost )
int spellCost = MWMechanics : : calcSpellCost ( spell ) ;
if ( reachedLimit & & spellCost < = minCost )
continue ;
if ( race & & std : : find ( race - > mPowers . mList . begin ( ) , race - > mPowers . mList . end ( ) , spell . mId ) ! = race - > mPowers . mList . end ( ) )
continue ;
if ( baseMagicka < spell . mData . m Cost)
if ( baseMagicka < spell Cost)
continue ;
static const float fAutoPCSpellChance = esmStore . get < ESM : : GameSetting > ( ) . find ( " fAutoPCSpellChance " ) - > mValue . getFloat ( ) ;
@ -185,19 +189,20 @@ namespace MWMechanics
for ( const std : : string & testSpellName : selectedSpells )
{
const ESM : : Spell * testSpell = esmStore . get < ESM : : Spell > ( ) . find ( testSpellName ) ;
if ( testSpell - > mData . mCost < minCost )
int testSpellCost = MWMechanics : : calcSpellCost ( * testSpell ) ;
if ( testSpellCost < minCost )
{
minCost = testSpell - > mData . m Cost;
minCost = testSpell Cost;
weakestSpell = testSpell ;
}
}
}
else
{
if ( spell . mData . m Cost < minCost )
if ( spell Cost < minCost )
{
weakestSpell = & spell ;
minCost = weakestSpell- > mData . mCost ;
minCost = MWMechanics: : calcSpellCost ( * weakestSpell ) ;
}
static const unsigned int iAutoPCSpellMax = esmStore . get < ESM : : GameSetting > ( ) . find ( " iAutoPCSpellMax " ) - > mValue . getInteger ( ) ;
if ( selectedSpells . size ( ) = = iAutoPCSpellMax )
@ -291,7 +296,9 @@ namespace MWMechanics
else
calcWeakestSchool ( spell , actorSkills , effectiveSchool , skillTerm ) ; // Note effectiveSchool is unused after this
float castChance = skillTerm - spell - > mData . mCost + 0.2f * actorAttributes [ ESM : : Attribute : : Willpower ] + 0.1f * actorAttributes [ ESM : : Attribute : : Luck ] ;
float castChance = skillTerm - MWMechanics : : calcSpellCost ( * spell )
+ 0.2f * actorAttributes [ ESM : : Attribute : : Willpower ]
+ 0.1f * actorAttributes [ ESM : : Attribute : : Luck ] ;
return castChance ;
}
}