2014-07-20 16:22:52 +02:00
|
|
|
#include "difficultyscaling.hpp"
|
|
|
|
|
2016-06-17 23:07:16 +09:00
|
|
|
#include <components/settings/settings.hpp>
|
|
|
|
|
2014-07-20 16:22:52 +02:00
|
|
|
#include "../mwbase/world.hpp"
|
|
|
|
#include "../mwbase/environment.hpp"
|
|
|
|
#include "../mwworld/esmstore.hpp"
|
|
|
|
|
2015-08-21 21:12:39 +12:00
|
|
|
#include "actorutil.hpp"
|
|
|
|
|
2014-07-20 16:22:52 +02:00
|
|
|
float scaleDamage(float damage, const MWWorld::Ptr& attacker, const MWWorld::Ptr& victim)
|
|
|
|
{
|
2015-08-21 21:12:39 +12:00
|
|
|
const MWWorld::Ptr& player = MWMechanics::getPlayer();
|
2014-07-20 16:22:52 +02:00
|
|
|
|
2018-07-31 21:14:16 +04:00
|
|
|
// [-500, 500]
|
2014-07-20 16:22:52 +02:00
|
|
|
int difficultySetting = Settings::Manager::getInt("difficulty", "Game");
|
2018-07-31 21:14:16 +04:00
|
|
|
difficultySetting = std::min(difficultySetting, 500);
|
|
|
|
difficultySetting = std::max(difficultySetting, -500);
|
2014-07-20 16:22:52 +02:00
|
|
|
|
2018-08-29 18:38:12 +03:00
|
|
|
static const float fDifficultyMult = MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find("fDifficultyMult")->mValue.getFloat();
|
2014-07-20 16:22:52 +02:00
|
|
|
|
|
|
|
float difficultyTerm = 0.01f * difficultySetting;
|
|
|
|
|
|
|
|
float x = 0;
|
|
|
|
if (victim == player)
|
|
|
|
{
|
|
|
|
if (difficultyTerm > 0)
|
|
|
|
x = fDifficultyMult * difficultyTerm;
|
|
|
|
else
|
|
|
|
x = difficultyTerm / fDifficultyMult;
|
|
|
|
}
|
|
|
|
else if (attacker == player)
|
|
|
|
{
|
|
|
|
if (difficultyTerm > 0)
|
|
|
|
x = -difficultyTerm / fDifficultyMult;
|
|
|
|
else
|
|
|
|
x = fDifficultyMult * (-difficultyTerm);
|
|
|
|
}
|
|
|
|
|
|
|
|
damage *= 1 + x;
|
|
|
|
return damage;
|
|
|
|
}
|