mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-02-07 12:40:01 +00:00
Added checkMagicka parameter
This commit is contained in:
parent
9fe5a4d236
commit
2abb1a2ec2
@ -60,7 +60,7 @@ namespace MWGui
|
|||||||
{
|
{
|
||||||
newSpell.mType = Spell::Type_Spell;
|
newSpell.mType = Spell::Type_Spell;
|
||||||
std::string cost = std::to_string(spell->mData.mCost);
|
std::string cost = std::to_string(spell->mData.mCost);
|
||||||
std::string chance = std::to_string(int(MWMechanics::getSpellSuccessChance(spell, mActor)));
|
std::string chance = std::to_string(int(MWMechanics::getSpellSuccessChance(spell, mActor, NULL, true, true)));
|
||||||
newSpell.mCostColumn = cost + "/" + chance;
|
newSpell.mCostColumn = cost + "/" + chance;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -115,7 +115,7 @@ namespace MWMechanics
|
|||||||
return castChance;
|
return castChance;
|
||||||
}
|
}
|
||||||
|
|
||||||
float getSpellSuccessChance (const ESM::Spell* spell, const MWWorld::Ptr& actor, int* effectiveSchool, bool cap)
|
float getSpellSuccessChance (const ESM::Spell* spell, const MWWorld::Ptr& actor, int* effectiveSchool, bool cap, bool checkMagicka)
|
||||||
{
|
{
|
||||||
bool godmode = actor == MWMechanics::getPlayer() && MWBase::Environment::get().getWorld()->getGodModeState();
|
bool godmode = actor == MWMechanics::getPlayer() && MWBase::Environment::get().getWorld()->getGodModeState();
|
||||||
|
|
||||||
@ -135,7 +135,7 @@ namespace MWMechanics
|
|||||||
if (spell->mData.mType != ESM::Spell::ST_Spell)
|
if (spell->mData.mType != ESM::Spell::ST_Spell)
|
||||||
return 100;
|
return 100;
|
||||||
|
|
||||||
if (stats.getMagicka().getCurrent() < spell->mData.mCost && !godmode)
|
if (checkMagicka && stats.getMagicka().getCurrent() < spell->mData.mCost && !godmode)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (spell->mData.mFlags & ESM::Spell::F_Always)
|
if (spell->mData.mFlags & ESM::Spell::F_Always)
|
||||||
@ -152,11 +152,11 @@ namespace MWMechanics
|
|||||||
return std::max(0.f, std::min(100.f, castChance));
|
return std::max(0.f, std::min(100.f, castChance));
|
||||||
}
|
}
|
||||||
|
|
||||||
float getSpellSuccessChance (const std::string& spellId, const MWWorld::Ptr& actor, int* effectiveSchool, bool cap)
|
float getSpellSuccessChance (const std::string& spellId, const MWWorld::Ptr& actor, int* effectiveSchool, bool cap, bool checkMagicka)
|
||||||
{
|
{
|
||||||
const ESM::Spell* spell =
|
const ESM::Spell* spell =
|
||||||
MWBase::Environment::get().getWorld()->getStore().get<ESM::Spell>().find(spellId);
|
MWBase::Environment::get().getWorld()->getStore().get<ESM::Spell>().find(spellId);
|
||||||
return getSpellSuccessChance(spell, actor, effectiveSchool, cap);
|
return getSpellSuccessChance(spell, actor, effectiveSchool, cap, checkMagicka);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -31,11 +31,12 @@ namespace MWMechanics
|
|||||||
* @param actor calculate spell success chance for this actor (depends on actor's skills)
|
* @param actor calculate spell success chance for this actor (depends on actor's skills)
|
||||||
* @param effectiveSchool the spell's effective school (relevant for skill progress) will be written here
|
* @param effectiveSchool the spell's effective school (relevant for skill progress) will be written here
|
||||||
* @param cap cap the result to 100%?
|
* @param cap cap the result to 100%?
|
||||||
|
* @param checkMagicka check magicka?
|
||||||
* @note actor can be an NPC or a creature
|
* @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.
|
* @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 = NULL, bool cap=true);
|
float getSpellSuccessChance (const ESM::Spell* spell, const MWWorld::Ptr& actor, int* effectiveSchool = NULL, bool cap=true, bool checkMagicka=false);
|
||||||
float getSpellSuccessChance (const std::string& spellId, const MWWorld::Ptr& actor, int* effectiveSchool = NULL, bool cap=true);
|
float getSpellSuccessChance (const std::string& spellId, const MWWorld::Ptr& actor, int* effectiveSchool = NULL, bool cap=true, bool checkMagicka=false);
|
||||||
|
|
||||||
int getSpellSchool(const std::string& spellId, const MWWorld::Ptr& actor);
|
int getSpellSchool(const std::string& spellId, const MWWorld::Ptr& actor);
|
||||||
int getSpellSchool(const ESM::Spell* spell, const MWWorld::Ptr& actor);
|
int getSpellSchool(const ESM::Spell* spell, const MWWorld::Ptr& actor);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user