Make sure cast chance checks mana when necessary (bug #5112)

pull/2456/head
capostrophic 5 years ago
parent 134631ad72
commit a9c4b18d38

@ -121,6 +121,7 @@
Bug #5104: Black Dart's enchantment doesn't trigger at low Enchant levels
Bug #5105: NPCs start combat with werewolves from any distance
Bug #5110: ModRegion with a redundant numerical argument breaks script execution
Bug #5112: Insufficient magicka for current spell not reflected on HUD icon
Bug #5123: Script won't run on respawn
Bug #5124: Arrow remains attached to actor if pulling animation was cancelled
Feature #1774: Handle AvoidNode

@ -71,7 +71,7 @@ namespace MWGui
{
newSpell.mType = Spell::Type_Spell;
std::string cost = std::to_string(spell->mData.mCost);
std::string chance = std::to_string(int(MWMechanics::getSpellSuccessChance(spell, mActor, nullptr, true, true)));
std::string chance = std::to_string(int(MWMechanics::getSpellSuccessChance(spell, mActor)));
newSpell.mCostColumn = cost + "/" + chance;
}
else

@ -241,7 +241,7 @@ namespace MWMechanics
float castChance = 100.f;
if (spell != nullptr && !caster.isEmpty() && caster.getClass().isActor())
{
castChance = getSpellSuccessChance(spell, caster, nullptr, false); // Uncapped casting chance
castChance = getSpellSuccessChance(spell, caster, nullptr, false, false); // Uncapped casting chance
}
if (castChance > 0)
x *= 50 / castChance;
@ -939,7 +939,7 @@ namespace MWMechanics
bool fail = false;
// Check success
float successChance = getSpellSuccessChance(spell, mCaster);
float successChance = getSpellSuccessChance(spell, mCaster, nullptr, true, false);
if (Misc::Rng::roll0to99() >= successChance)
{
if (mCaster == getPlayer())

@ -39,8 +39,8 @@ namespace MWMechanics
* @note actor can be an NPC or a creature
* @return success chance from 0 to 100 (in percent), if cap=false then chance above 100 may be returned.
*/
float getSpellSuccessChance (const ESM::Spell* spell, const MWWorld::Ptr& actor, int* effectiveSchool = nullptr, bool cap=true, bool checkMagicka=false);
float getSpellSuccessChance (const std::string& spellId, const MWWorld::Ptr& actor, int* effectiveSchool = nullptr, bool cap=true, bool checkMagicka=false);
float getSpellSuccessChance (const ESM::Spell* spell, const MWWorld::Ptr& actor, int* effectiveSchool = nullptr, bool cap=true, bool checkMagicka=true);
float getSpellSuccessChance (const std::string& spellId, const MWWorld::Ptr& actor, int* effectiveSchool = nullptr, bool cap=true, bool checkMagicka=true);
int getSpellSchool(const std::string& spellId, const MWWorld::Ptr& actor);
int getSpellSchool(const ESM::Spell* spell, const MWWorld::Ptr& actor);

@ -122,9 +122,6 @@ namespace MWMechanics
return 0.f;
}
if (spell->mData.mCost > stats.getMagicka().getCurrent())
return 0.f;
// Spells don't stack, so early out if the spell is still active on the target
int types = getRangeTypes(spell->mEffects);
if ((types & Self) && stats.getActiveSpells().isSpellActive(spell->mId))

Loading…
Cancel
Save