mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-21 00:53:52 +00:00
Implement crime-related dialogue globals as they are described in MSFD
This commit is contained in:
parent
d7f69205f6
commit
9bf7bf529c
5 changed files with 36 additions and 0 deletions
|
@ -448,6 +448,10 @@ namespace MWBase
|
|||
/// @note This also works for references in containers.
|
||||
virtual void listDetectedReferences (const MWWorld::Ptr& ptr, std::vector<MWWorld::Ptr>& out,
|
||||
DetectionType type) = 0;
|
||||
|
||||
/// Update the value of some globals according to the world state, which may be used by dialogue entries.
|
||||
/// This should be called when initiating a dialogue.
|
||||
virtual void updateDialogueGlobals() = 0;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -143,6 +143,7 @@ namespace MWDialogue
|
|||
|
||||
//setup the list of topics known by the actor. Topics who are also on the knownTopics list will be added to the GUI
|
||||
updateTopics();
|
||||
updateGlobals();
|
||||
|
||||
//greeting
|
||||
const MWWorld::Store<ESM::Dialogue> &dialogs =
|
||||
|
@ -298,6 +299,11 @@ namespace MWDialogue
|
|||
}
|
||||
}
|
||||
|
||||
void DialogueManager::updateGlobals()
|
||||
{
|
||||
MWBase::Environment::get().getWorld()->updateDialogueGlobals();
|
||||
}
|
||||
|
||||
void DialogueManager::updateTopics()
|
||||
{
|
||||
std::list<std::string> keywordList;
|
||||
|
|
|
@ -40,6 +40,7 @@ namespace MWDialogue
|
|||
void parseText (const std::string& text);
|
||||
|
||||
void updateTopics();
|
||||
void updateGlobals();
|
||||
|
||||
bool compile (const std::string& cmd,std::vector<Interpreter::Type_Code>& code);
|
||||
void executeScript (const std::string& script);
|
||||
|
|
|
@ -2420,4 +2420,25 @@ namespace MWWorld
|
|||
{
|
||||
return mPlayer->getPlayer();
|
||||
}
|
||||
|
||||
void World::updateDialogueGlobals()
|
||||
{
|
||||
MWWorld::Ptr player = getPlayerPtr();
|
||||
int bounty = player.getClass().getNpcStats(player).getBounty();
|
||||
int playerGold = player.getClass().getContainerStore(player).count(ContainerStore::sGoldId);
|
||||
|
||||
float fCrimeGoldDiscountMult = getStore().get<ESM::GameSetting>().find("fCrimeGoldDiscountMult")->getFloat();
|
||||
float fCrimeGoldTurnInMult = getStore().get<ESM::GameSetting>().find("fCrimeGoldTurnInMult")->getFloat();
|
||||
|
||||
int discount = bounty*fCrimeGoldDiscountMult;
|
||||
int turnIn = bounty * fCrimeGoldTurnInMult;
|
||||
|
||||
mGlobalVariables->setInt("pchascrimegold", (bounty <= playerGold) ? 1 : 0);
|
||||
|
||||
mGlobalVariables->setInt("pchasgolddiscount", (discount <= playerGold) ? 1 : 0);
|
||||
mGlobalVariables->setInt("crimegolddiscount", discount);
|
||||
|
||||
mGlobalVariables->setInt("crimegoldturnin", turnIn);
|
||||
mGlobalVariables->setInt("pchasturnin", (turnIn <= playerGold) ? 1 : 0);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -533,6 +533,10 @@ namespace MWWorld
|
|||
/// @note This also works for references in containers.
|
||||
virtual void listDetectedReferences (const MWWorld::Ptr& ptr, std::vector<MWWorld::Ptr>& out,
|
||||
DetectionType type);
|
||||
|
||||
/// Update the value of some globals according to the world state, which may be used by dialogue entries.
|
||||
/// This should be called when initiating a dialogue.
|
||||
virtual void updateDialogueGlobals();
|
||||
};
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue