Change default argument, fix GetDisposition

move
scrawl 9 years ago
parent bc5adfa4fe
commit 12ec90f9e7

@ -97,7 +97,7 @@ namespace MWBase
virtual int getBarterOffer(const MWWorld::Ptr& ptr,int basePrice, bool buying) = 0; virtual int getBarterOffer(const MWWorld::Ptr& ptr,int basePrice, bool buying) = 0;
///< This is used by every service to determine the price of objects given the trading skills of the player and NPC. ///< This is used by every service to determine the price of objects given the trading skills of the player and NPC.
virtual int getDerivedDisposition(const MWWorld::Ptr& ptr, bool addTemporaryDispositionChange = false) = 0; virtual int getDerivedDisposition(const MWWorld::Ptr& ptr, bool addTemporaryDispositionChange = true) = 0;
///< Calculate the diposition of an NPC toward the player. ///< Calculate the diposition of an NPC toward the player.
virtual int countDeaths (const std::string& id) const = 0; virtual int countDeaths (const std::string& id) const = 0;

@ -535,7 +535,7 @@ namespace MWDialogue
mPermanentDispositionChange += perm; mPermanentDispositionChange += perm;
// change temp disposition so that final disposition is between 0...100 // change temp disposition so that final disposition is between 0...100
float curDisp = static_cast<float>(MWBase::Environment::get().getMechanicsManager()->getDerivedDisposition(mActor)); float curDisp = static_cast<float>(MWBase::Environment::get().getMechanicsManager()->getDerivedDisposition(mActor, false));
if (curDisp + mTemporaryDispositionChange < 0) if (curDisp + mTemporaryDispositionChange < 0)
mTemporaryDispositionChange = -curDisp; mTemporaryDispositionChange = -curDisp;
else if (curDisp + mTemporaryDispositionChange > 100) else if (curDisp + mTemporaryDispositionChange > 100)

@ -145,7 +145,7 @@ bool MWDialogue::Filter::testDisposition (const ESM::DialInfo& info, bool invert
if (isCreature) if (isCreature)
return true; return true;
int actorDisposition = MWBase::Environment::get().getMechanicsManager()->getDerivedDisposition(mActor, true); int actorDisposition = MWBase::Environment::get().getMechanicsManager()->getDerivedDisposition(mActor);
// For service refusal, the disposition check is inverted. However, a value of 0 still means "always succeed". // For service refusal, the disposition check is inverted. However, a value of 0 still means "always succeed".
return invert ? (info.mData.mDisposition == 0 || actorDisposition < info.mData.mDisposition) return invert ? (info.mData.mDisposition == 0 || actorDisposition < info.mData.mDisposition)
: (actorDisposition >= info.mData.mDisposition); : (actorDisposition >= info.mData.mDisposition);

@ -640,7 +640,7 @@ namespace MWGui
if(mMainWidget->getVisible() && mEnabled && mPtr.getTypeName() == typeid(ESM::NPC).name()) if(mMainWidget->getVisible() && mEnabled && mPtr.getTypeName() == typeid(ESM::NPC).name())
{ {
int disp = std::max(0, std::min(100, int disp = std::max(0, std::min(100,
MWBase::Environment::get().getMechanicsManager()->getDerivedDisposition(mPtr, true))); MWBase::Environment::get().getMechanicsManager()->getDerivedDisposition(mPtr)));
mDispositionBar->setProgressRange(100); mDispositionBar->setProgressRange(100);
mDispositionBar->setProgressPosition(disp); mDispositionBar->setProgressPosition(disp);
mDispositionText->setCaption(MyGUI::utility::toString(disp)+std::string("/100")); mDispositionText->setCaption(MyGUI::utility::toString(disp)+std::string("/100"));

@ -346,7 +346,7 @@ namespace MWGui
else else
d = int(100 * (b - a) / a); d = int(100 * (b - a) / a);
int clampedDisposition = std::max(0, std::min(MWBase::Environment::get().getMechanicsManager()->getDerivedDisposition(mPtr, true),100)); int clampedDisposition = std::max(0, std::min(MWBase::Environment::get().getMechanicsManager()->getDerivedDisposition(mPtr),100));
const MWMechanics::CreatureStats &sellerStats = mPtr.getClass().getCreatureStats(mPtr); const MWMechanics::CreatureStats &sellerStats = mPtr.getClass().getCreatureStats(mPtr);
const MWMechanics::CreatureStats &playerStats = player.getClass().getCreatureStats(player); const MWMechanics::CreatureStats &playerStats = player.getClass().getCreatureStats(player);

@ -581,7 +581,7 @@ namespace MWMechanics
mUpdatePlayer = true; mUpdatePlayer = true;
} }
int MechanicsManager::getDerivedDisposition(const MWWorld::Ptr& ptr, bool addTemporaryDispositionChange/* = false */) int MechanicsManager::getDerivedDisposition(const MWWorld::Ptr& ptr, bool addTemporaryDispositionChange)
{ {
const MWMechanics::NpcStats& npcSkill = ptr.getClass().getNpcStats(ptr); const MWMechanics::NpcStats& npcSkill = ptr.getClass().getNpcStats(ptr);
float x = static_cast<float>(npcSkill.getBaseDisposition()); float x = static_cast<float>(npcSkill.getBaseDisposition());
@ -672,7 +672,7 @@ namespace MWMechanics
// I suppose the temporary disposition change (second param to getDerivedDisposition()) _has_ to be considered here, // I suppose the temporary disposition change (second param to getDerivedDisposition()) _has_ to be considered here,
// otherwise one would get different prices when exiting and re-entering the dialogue window... // otherwise one would get different prices when exiting and re-entering the dialogue window...
int clampedDisposition = std::max(0, std::min(getDerivedDisposition(ptr, true),100)); int clampedDisposition = std::max(0, std::min(getDerivedDisposition(ptr),100));
float a = static_cast<float>(std::min(playerStats.getSkill(ESM::Skill::Mercantile).getModified(), 100)); float a = static_cast<float>(std::min(playerStats.getSkill(ESM::Skill::Mercantile).getModified(), 100));
float b = std::min(0.1f * playerStats.getAttribute(ESM::Attribute::Luck).getModified(), 10.f); float b = std::min(0.1f * playerStats.getAttribute(ESM::Attribute::Luck).getModified(), 10.f);
float c = std::min(0.2f * playerStats.getAttribute(ESM::Attribute::Personality).getModified(), 10.f); float c = std::min(0.2f * playerStats.getAttribute(ESM::Attribute::Personality).getModified(), 10.f);
@ -719,7 +719,7 @@ namespace MWMechanics
float playerRating1, playerRating2, playerRating3; float playerRating1, playerRating2, playerRating3;
getPersuasionRatings(playerStats, playerRating1, playerRating2, playerRating3, true); getPersuasionRatings(playerStats, playerRating1, playerRating2, playerRating3, true);
int currentDisposition = std::min(100, std::max(0, int(getDerivedDisposition(npc) + currentTemporaryDispositionDelta))); int currentDisposition = std::min(100, std::max(0, int(getDerivedDisposition(npc, false) + currentTemporaryDispositionDelta)));
float d = 1 - 0.02f * abs(currentDisposition - 50); float d = 1 - 0.02f * abs(currentDisposition - 50);
float target1 = d * (playerRating1 - npcRating1 + 50); float target1 = d * (playerRating1 - npcRating1 + 50);
@ -1547,7 +1547,7 @@ namespace MWMechanics
{ {
int disposition = 50; int disposition = 50;
if (ptr.getClass().isNpc()) if (ptr.getClass().isNpc())
disposition = getDerivedDisposition(ptr); disposition = getDerivedDisposition(ptr, false);
int fight = std::max(0, ptr.getClass().getCreatureStats(ptr).getAiSetting(CreatureStats::AI_Fight).getModified() int fight = std::max(0, ptr.getClass().getCreatureStats(ptr).getAiSetting(CreatureStats::AI_Fight).getModified()
+ static_cast<int>(getFightDistanceBias(ptr, target) + getFightDispositionBias(static_cast<float>(disposition)))); + static_cast<int>(getFightDistanceBias(ptr, target) + getFightDispositionBias(static_cast<float>(disposition))));

Loading…
Cancel
Save