mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-29 17:45:32 +00:00
Move code to apps/openmw/mwmechanics/spellcasting.cpp, move reduce mana code to CastSpell::cast(const ESM::Spell*)
This commit is contained in:
parent
32096ae0cc
commit
ce32462358
3 changed files with 13 additions and 19 deletions
|
@ -8,7 +8,6 @@
|
|||
|
||||
#include "../mwmechanics/creaturestats.hpp"
|
||||
#include "../mwmechanics/spellcasting.hpp"
|
||||
#include "../mwmechanics/actorutil.hpp"
|
||||
|
||||
#include "../mwworld/esmstore.hpp"
|
||||
#include "../mwworld/inventorystore.hpp"
|
||||
|
@ -61,11 +60,7 @@ namespace MWGui
|
|||
{
|
||||
newSpell.mType = Spell::Type_Spell;
|
||||
std::string cost = std::to_string(spell->mData.mCost);
|
||||
std::string chance = std::to_string(
|
||||
(stats.getMagicka().getCurrent() >= spell->mData.mCost ||
|
||||
(mActor == MWMechanics::getPlayer() && MWBase::Environment::get().getWorld()->getGodModeState())
|
||||
) ? int(MWMechanics::getSpellSuccessChance(spell, mActor)) : 0
|
||||
);
|
||||
std::string chance = std::to_string(int(MWMechanics::getSpellSuccessChance(spell, mActor)));
|
||||
newSpell.mCostColumn = cost + "/" + chance;
|
||||
}
|
||||
else
|
||||
|
|
|
@ -126,7 +126,10 @@ namespace MWMechanics
|
|||
float castChance = calcSpellBaseSuccessChance(spell, actor, effectiveSchool) + castBonus;
|
||||
castChance *= stats.getFatigueTerm();
|
||||
|
||||
if (stats.getMagicEffects().get(ESM::MagicEffect::Silence).getMagnitude()&& !godmode)
|
||||
if (godmode)
|
||||
return 100;
|
||||
|
||||
if (stats.getMagicEffects().get(ESM::MagicEffect::Silence).getMagnitude())
|
||||
return 0;
|
||||
|
||||
if (spell->mData.mType == ESM::Spell::ST_Power)
|
||||
|
@ -135,14 +138,12 @@ namespace MWMechanics
|
|||
if (spell->mData.mType != ESM::Spell::ST_Spell)
|
||||
return 100;
|
||||
|
||||
if (stats.getMagicka().getCurrent() < spell->mData.mCost)
|
||||
return 0;
|
||||
|
||||
if (spell->mData.mFlags & ESM::Spell::F_Always)
|
||||
return 100;
|
||||
|
||||
if (godmode)
|
||||
{
|
||||
return 100;
|
||||
}
|
||||
|
||||
if (!cap)
|
||||
return std::max(0.f, castChance);
|
||||
else
|
||||
|
@ -888,6 +889,11 @@ namespace MWMechanics
|
|||
MWBase::Environment::get().getWindowManager()->messageBox("#{sMagicSkillFail}");
|
||||
fail = true;
|
||||
}
|
||||
|
||||
// Reduce mana
|
||||
MWMechanics::DynamicStat<float> magicka = stats.getMagicka();
|
||||
magicka.setCurrent(magicka.getCurrent() - spell->mData.mCost);
|
||||
stats.setMagicka(magicka);
|
||||
}
|
||||
|
||||
if (fail)
|
||||
|
|
|
@ -2718,13 +2718,6 @@ namespace MWWorld
|
|||
message = "#{sPowerAlreadyUsed}";
|
||||
fail = true;
|
||||
}
|
||||
|
||||
// Reduce mana
|
||||
if (!fail && !godmode)
|
||||
{
|
||||
magicka.setCurrent(magicka.getCurrent() - spell->mData.mCost);
|
||||
stats.setMagicka(magicka);
|
||||
}
|
||||
}
|
||||
|
||||
if (isPlayer && fail)
|
||||
|
|
Loading…
Reference in a new issue