mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-26 18:35:20 +00:00
Disposition is now calculated according to the Wiki. But: bouty and deacease are not implemented (for disposition at least), and there is still no temporary/permanent dispositons changes
This commit is contained in:
parent
aaf1b66c7e
commit
9ebe9cb40c
@ -12,6 +12,7 @@
|
|||||||
#include "../mwbase/dialoguemanager.hpp"
|
#include "../mwbase/dialoguemanager.hpp"
|
||||||
#include "../mwbase/world.hpp"
|
#include "../mwbase/world.hpp"
|
||||||
#include "../mwbase/windowmanager.hpp"
|
#include "../mwbase/windowmanager.hpp"
|
||||||
|
#include "../mwbase/mechanicsmanager.hpp"
|
||||||
|
|
||||||
#include "dialogue_history.hpp"
|
#include "dialogue_history.hpp"
|
||||||
#include "widgets.hpp"
|
#include "widgets.hpp"
|
||||||
@ -294,9 +295,9 @@ void DialogueWindow::updateOptions()
|
|||||||
mHistory->eraseText(0, mHistory->getTextLength());
|
mHistory->eraseText(0, mHistory->getTextLength());
|
||||||
|
|
||||||
mDispositionBar->setProgressRange(100);
|
mDispositionBar->setProgressRange(100);
|
||||||
mDispositionBar->setProgressPosition(40);
|
mDispositionBar->setProgressPosition(MWBase::Environment::get().getMechanicsManager()->disposition(mPtr));
|
||||||
mDispositionText->eraseText(0, mDispositionText->getTextLength());
|
mDispositionText->eraseText(0, mDispositionText->getTextLength());
|
||||||
mDispositionText->addText("#B29154"+std::string("40/100")+"#B29154");
|
mDispositionText->addText("#B29154"+boost::lexical_cast<std::string>(MWBase::Environment::get().getMechanicsManager()->disposition(mPtr))+std::string("/100")+"#B29154");
|
||||||
}
|
}
|
||||||
|
|
||||||
void DialogueWindow::goodbye()
|
void DialogueWindow::goodbye()
|
||||||
|
@ -325,22 +325,71 @@ namespace MWMechanics
|
|||||||
mUpdatePlayer = true;
|
mUpdatePlayer = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
float min(float a,float b)
|
std::string toLower (const std::string& name)
|
||||||
{
|
{
|
||||||
if(a<b) return a;
|
std::string lowerCase;
|
||||||
else return b;
|
|
||||||
}
|
|
||||||
|
|
||||||
float max(float a,float b)
|
std::transform (name.begin(), name.end(), std::back_inserter (lowerCase),
|
||||||
{
|
(int(*)(int)) std::tolower);
|
||||||
if(a>b) return a;
|
|
||||||
else return b;
|
return lowerCase;
|
||||||
}
|
}
|
||||||
|
|
||||||
int MechanicsManager::disposition(const MWWorld::Ptr& ptr)
|
int MechanicsManager::disposition(const MWWorld::Ptr& ptr)
|
||||||
{
|
{
|
||||||
MWMechanics::NpcStats npcSkill = MWWorld::Class::get(ptr).getNpcStats(ptr);
|
MWMechanics::NpcStats npcSkill = MWWorld::Class::get(ptr).getNpcStats(ptr);
|
||||||
return npcSkill.getDisposition();
|
float x = npcSkill.getDisposition();
|
||||||
|
|
||||||
|
MWWorld::LiveCellRef<ESM::NPC>* npc = ptr.get<ESM::NPC>();
|
||||||
|
MWWorld::Ptr playerPtr = MWBase::Environment::get().getWorld()->getPlayer().getPlayer();
|
||||||
|
MWWorld::LiveCellRef<ESM::NPC>* player = playerPtr.get<ESM::NPC>();
|
||||||
|
MWMechanics::CreatureStats playerStats = MWWorld::Class::get(playerPtr).getCreatureStats(playerPtr);
|
||||||
|
MWMechanics::NpcStats playerSkill = MWWorld::Class::get(playerPtr).getNpcStats(playerPtr);
|
||||||
|
|
||||||
|
if (toLower(npc->base->mRace) == toLower(player->base->mRace)) x += MWBase::Environment::get().getWorld()->getStore().gameSettings.find("fDispRaceMod")->getFloat();
|
||||||
|
|
||||||
|
x += MWBase::Environment::get().getWorld()->getStore().gameSettings.find("fDispPersonalityMult")->getFloat()
|
||||||
|
* (playerStats.getAttribute(ESM::Attribute::Personality).getModified() - MWBase::Environment::get().getWorld()->getStore().gameSettings.find("fDispPersonalityBase")->getFloat());
|
||||||
|
|
||||||
|
float reaction = 0;
|
||||||
|
int rank = 0;
|
||||||
|
std::string npcFaction = npcSkill.getFactionRanks().begin()->first;
|
||||||
|
const ESMS::ESMStore &store = MWBase::Environment::get().getWorld()->getStore();
|
||||||
|
|
||||||
|
if (playerSkill.getFactionRanks().find(toLower(npcFaction)) != playerSkill.getFactionRanks().end())
|
||||||
|
{
|
||||||
|
for(std::vector<ESM::Faction::Reaction>::const_iterator it = store.factions.find(toLower(npcFaction))->mReactions.begin();it != store.factions.find(toLower(npcFaction))->mReactions.end();it++)
|
||||||
|
{
|
||||||
|
if(toLower(it->mFaction) == toLower(npcFaction)) reaction = it->mReaction;
|
||||||
|
}
|
||||||
|
rank = playerSkill.getFactionRanks().find(toLower(npcFaction))->second;
|
||||||
|
}
|
||||||
|
else if (npcFaction != "")
|
||||||
|
{
|
||||||
|
std::cout << "npc has a faction!";
|
||||||
|
for(std::vector<ESM::Faction::Reaction>::const_iterator it = store.factions.find(toLower(npcFaction))->mReactions.begin();it != store.factions.find(toLower(npcFaction))->mReactions.end();it++)
|
||||||
|
{
|
||||||
|
if(playerSkill.getFactionRanks().find(toLower(it->mFaction)) != playerSkill.getFactionRanks().end() )
|
||||||
|
{
|
||||||
|
if(it->mReaction<reaction) reaction = it->mReaction;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
rank = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
reaction = 0;
|
||||||
|
rank = 0;
|
||||||
|
}
|
||||||
|
x += (MWBase::Environment::get().getWorld()->getStore().gameSettings.find("fDispFactionRankMult")->getFloat() * rank
|
||||||
|
+ MWBase::Environment::get().getWorld()->getStore().gameSettings.find("fDispFactionRankBase")->getFloat())
|
||||||
|
* MWBase::Environment::get().getWorld()->getStore().gameSettings.find("fDispFactionMod")->getFloat() * reaction;
|
||||||
|
//x -= MWBase::Environment::get().getWorld()->getStore().gameSettings.find("fDispCrimeMod") * pcBounty;
|
||||||
|
//if (pc has a disease) x += MWBase::Environment::get().getWorld()->getStore().gameSettings.find("fDispDiseaseMod");
|
||||||
|
if (playerSkill.getDrawState() == MWMechanics::DrawState_::DrawState_Weapon) x += MWBase::Environment::get().getWorld()->getStore().gameSettings.find("fDispWeaponDrawn")->getFloat();
|
||||||
|
|
||||||
|
int effective_disposition = std::max(0,std::min(int(x),100));//, normally clamped to [0..100] when used
|
||||||
|
return effective_disposition;
|
||||||
}
|
}
|
||||||
|
|
||||||
int MechanicsManager::barterOffer(const MWWorld::Ptr& ptr,int basePrice, bool buying)
|
int MechanicsManager::barterOffer(const MWWorld::Ptr& ptr,int basePrice, bool buying)
|
||||||
@ -352,13 +401,13 @@ namespace MWMechanics
|
|||||||
MWMechanics::NpcStats playerSkill = MWWorld::Class::get(playerPtr).getNpcStats(playerPtr);
|
MWMechanics::NpcStats playerSkill = MWWorld::Class::get(playerPtr).getNpcStats(playerPtr);
|
||||||
MWMechanics::CreatureStats playerStats = MWWorld::Class::get(playerPtr).getCreatureStats(playerPtr);
|
MWMechanics::CreatureStats playerStats = MWWorld::Class::get(playerPtr).getCreatureStats(playerPtr);
|
||||||
|
|
||||||
int clampedDisposition = min(disposition(ptr),100);
|
int clampedDisposition = std::min(disposition(ptr),100);
|
||||||
float a = min(playerSkill.getSkill(ESM::Skill::Mercantile).getModified(), 100);
|
float a = std::min<float>(playerSkill.getSkill(ESM::Skill::Mercantile).getModified(), 100);
|
||||||
float b = min(0.1 * playerStats.getAttribute(ESM::Attribute::Luck).getModified(), 10);
|
float b = std::min<float>(0.1 * playerStats.getAttribute(ESM::Attribute::Luck).getModified(), 10);
|
||||||
float c = min(0.2 * playerStats.getAttribute(ESM::Attribute::Personality).getModified(), 10);
|
float c = std::min<float>(0.2 * playerStats.getAttribute(ESM::Attribute::Personality).getModified(), 10);
|
||||||
float d = min(sellerSkill.getSkill(ESM::Skill::Mercantile).getModified(), 100);
|
float d = std::min<float>(sellerSkill.getSkill(ESM::Skill::Mercantile).getModified(), 100);
|
||||||
float e = min(0.1 * sellerStats.getAttribute(ESM::Attribute::Luck).getModified(), 10);
|
float e = std::min<float>(0.1 * sellerStats.getAttribute(ESM::Attribute::Luck).getModified(), 10);
|
||||||
float f = min(0.2 * sellerStats.getAttribute(ESM::Attribute::Personality).getModified(), 10);
|
float f = std::min<float>(0.2 * sellerStats.getAttribute(ESM::Attribute::Personality).getModified(), 10);
|
||||||
|
|
||||||
float pcTerm = (clampedDisposition - 50 + a + b + c) * playerStats.getFatigueTerm();
|
float pcTerm = (clampedDisposition - 50 + a + b + c) * playerStats.getFatigueTerm();
|
||||||
float npcTerm = (d + e + f) * sellerStats.getFatigueTerm();
|
float npcTerm = (d + e + f) * sellerStats.getFatigueTerm();
|
||||||
@ -367,13 +416,13 @@ namespace MWMechanics
|
|||||||
|
|
||||||
float x;
|
float x;
|
||||||
if(buying) x = buyTerm;
|
if(buying) x = buyTerm;
|
||||||
else x = min(buyTerm, sellTerm);
|
else x = std::min(buyTerm, sellTerm);
|
||||||
std::cout << "x" << x;
|
//std::cout << "x" << x;
|
||||||
int offerPrice;
|
int offerPrice;
|
||||||
if (x < 1) offerPrice = int(x * basePrice);
|
if (x < 1) offerPrice = int(x * basePrice);
|
||||||
if (x >= 1) offerPrice = basePrice + int((x - 1) * basePrice);
|
if (x >= 1) offerPrice = basePrice + int((x - 1) * basePrice);
|
||||||
offerPrice = max(1, offerPrice);
|
offerPrice = std::max(1, offerPrice);
|
||||||
std::cout <<"barteroffer"<< offerPrice << " " << basePrice << "\n";
|
//std::cout <<"barteroffer"<< offerPrice << " " << basePrice << "\n";
|
||||||
return offerPrice;
|
return offerPrice;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user