mirror of
https://github.com/OpenMW/openmw.git
synced 2025-11-08 21:16:40 +00:00
Implemented service refusal
This commit is contained in:
parent
485b6c855a
commit
cebcbe11f8
6 changed files with 76 additions and 38 deletions
|
|
@ -41,6 +41,8 @@ namespace MWBase
|
||||||
virtual void goodbyeSelected() = 0;
|
virtual void goodbyeSelected() = 0;
|
||||||
virtual void questionAnswered (const std::string& answer) = 0;
|
virtual void questionAnswered (const std::string& answer) = 0;
|
||||||
|
|
||||||
|
virtual bool checkServiceRefused () = 0;
|
||||||
|
|
||||||
virtual void persuade (int type) = 0;
|
virtual void persuade (int type) = 0;
|
||||||
virtual int getTemporaryDispositionChange () const = 0;
|
virtual int getTemporaryDispositionChange () const = 0;
|
||||||
virtual void applyTemporaryDispositionChange (int delta) = 0;
|
virtual void applyTemporaryDispositionChange (int delta) = 0;
|
||||||
|
|
|
||||||
|
|
@ -518,6 +518,37 @@ namespace MWDialogue
|
||||||
mTemporaryDispositionChange += delta;
|
mTemporaryDispositionChange += delta;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool DialogueManager::checkServiceRefused()
|
||||||
|
{
|
||||||
|
Filter filter (mActor, mChoice, mTalkedTo);
|
||||||
|
|
||||||
|
const MWWorld::Store<ESM::Dialogue> &dialogues =
|
||||||
|
MWBase::Environment::get().getWorld()->getStore().get<ESM::Dialogue>();
|
||||||
|
|
||||||
|
const ESM::Dialogue& dialogue = *dialogues.find ("Service Refusal");
|
||||||
|
MWGui::DialogueWindow* win = MWBase::Environment::get().getWindowManager()->getDialogueWindow();
|
||||||
|
|
||||||
|
std::vector<const ESM::DialInfo *> infos = filter.list (dialogue, false, false, true);
|
||||||
|
if (!infos.empty())
|
||||||
|
{
|
||||||
|
const ESM::DialInfo* info = infos[0];
|
||||||
|
|
||||||
|
parseText (info->mResponse);
|
||||||
|
|
||||||
|
const MWWorld::Store<ESM::GameSetting>& gmsts =
|
||||||
|
MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>();
|
||||||
|
|
||||||
|
win->addTitle (gmsts.find ("sServiceRefusal")->getString());
|
||||||
|
|
||||||
|
MWScript::InterpreterContext interpreterContext(&mActor.getRefData().getLocals(),mActor);
|
||||||
|
win->addText (Interpreter::fixDefinesDialog(info->mResponse, interpreterContext));
|
||||||
|
|
||||||
|
executeScript (info->mResultScript);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
std::vector<HyperTextToken> ParseHyperText(const std::string& text)
|
std::vector<HyperTextToken> ParseHyperText(const std::string& text)
|
||||||
{
|
{
|
||||||
std::vector<HyperTextToken> result;
|
std::vector<HyperTextToken> result;
|
||||||
|
|
|
||||||
|
|
@ -65,6 +65,8 @@ namespace MWDialogue
|
||||||
virtual MWWorld::Ptr getActor() const;
|
virtual MWWorld::Ptr getActor() const;
|
||||||
///< Return the actor the player is currently talking to.
|
///< Return the actor the player is currently talking to.
|
||||||
|
|
||||||
|
virtual bool checkServiceRefused ();
|
||||||
|
|
||||||
//calbacks for the GUI
|
//calbacks for the GUI
|
||||||
virtual void keywordSelected (const std::string& keyword);
|
virtual void keywordSelected (const std::string& keyword);
|
||||||
virtual void goodbyeSelected();
|
virtual void goodbyeSelected();
|
||||||
|
|
|
||||||
|
|
@ -121,7 +121,7 @@ bool MWDialogue::Filter::testSelectStructs (const ESM::DialInfo& info) const
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MWDialogue::Filter::testDisposition (const ESM::DialInfo& info) const
|
bool MWDialogue::Filter::testDisposition (const ESM::DialInfo& info, bool invert) const
|
||||||
{
|
{
|
||||||
bool isCreature = (mActor.getTypeName() != typeid (ESM::NPC).name());
|
bool isCreature = (mActor.getTypeName() != typeid (ESM::NPC).name());
|
||||||
|
|
||||||
|
|
@ -129,8 +129,9 @@ bool MWDialogue::Filter::testDisposition (const ESM::DialInfo& info) const
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
int actorDisposition = MWBase::Environment::get().getMechanicsManager()->getDerivedDisposition(mActor);
|
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".
|
||||||
return actorDisposition >= info.mData.mDisposition;
|
return invert ? (info.mData.mDisposition == 0 || actorDisposition < info.mData.mDisposition)
|
||||||
|
: (actorDisposition >= info.mData.mDisposition);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MWDialogue::Filter::testSelectStruct (const SelectWrapper& select) const
|
bool MWDialogue::Filter::testSelectStruct (const SelectWrapper& select) const
|
||||||
|
|
@ -570,7 +571,7 @@ const ESM::DialInfo* MWDialogue::Filter::search (const ESM::Dialogue& dialogue,
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<const ESM::DialInfo *> MWDialogue::Filter::list (const ESM::Dialogue& dialogue,
|
std::vector<const ESM::DialInfo *> MWDialogue::Filter::list (const ESM::Dialogue& dialogue,
|
||||||
bool fallbackToInfoRefusal, bool searchAll) const
|
bool fallbackToInfoRefusal, bool searchAll, bool invertDisposition) const
|
||||||
{
|
{
|
||||||
std::vector<const ESM::DialInfo *> infos;
|
std::vector<const ESM::DialInfo *> infos;
|
||||||
|
|
||||||
|
|
@ -582,7 +583,7 @@ std::vector<const ESM::DialInfo *> MWDialogue::Filter::list (const ESM::Dialogue
|
||||||
{
|
{
|
||||||
if (testActor (*iter) && testPlayer (*iter) && testSelectStructs (*iter))
|
if (testActor (*iter) && testPlayer (*iter) && testSelectStructs (*iter))
|
||||||
{
|
{
|
||||||
if (testDisposition (*iter)) {
|
if (testDisposition (*iter, invertDisposition)) {
|
||||||
infos.push_back(&*iter);
|
infos.push_back(&*iter);
|
||||||
if (!searchAll)
|
if (!searchAll)
|
||||||
break;
|
break;
|
||||||
|
|
@ -604,7 +605,7 @@ std::vector<const ESM::DialInfo *> MWDialogue::Filter::list (const ESM::Dialogue
|
||||||
|
|
||||||
for (std::vector<ESM::DialInfo>::const_iterator iter = infoRefusalDialogue.mInfo.begin();
|
for (std::vector<ESM::DialInfo>::const_iterator iter = infoRefusalDialogue.mInfo.begin();
|
||||||
iter!=infoRefusalDialogue.mInfo.end(); ++iter)
|
iter!=infoRefusalDialogue.mInfo.end(); ++iter)
|
||||||
if (testActor (*iter) && testPlayer (*iter) && testSelectStructs (*iter) && testDisposition(*iter)) {
|
if (testActor (*iter) && testPlayer (*iter) && testSelectStructs (*iter) && testDisposition(*iter, invertDisposition)) {
|
||||||
infos.push_back(&*iter);
|
infos.push_back(&*iter);
|
||||||
if (!searchAll)
|
if (!searchAll)
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
|
|
@ -30,8 +30,8 @@ namespace MWDialogue
|
||||||
bool testSelectStructs (const ESM::DialInfo& info) const;
|
bool testSelectStructs (const ESM::DialInfo& info) const;
|
||||||
///< Are all select structs matching?
|
///< Are all select structs matching?
|
||||||
|
|
||||||
bool testDisposition (const ESM::DialInfo& info) const;
|
bool testDisposition (const ESM::DialInfo& info, bool invert=false) const;
|
||||||
///< Is the actor disposition toward the player high enough?
|
///< Is the actor disposition toward the player high enough (or low enough, if \a invert is true)?
|
||||||
|
|
||||||
bool testSelectStruct (const SelectWrapper& select) const;
|
bool testSelectStruct (const SelectWrapper& select) const;
|
||||||
|
|
||||||
|
|
@ -54,7 +54,7 @@ namespace MWDialogue
|
||||||
Filter (const MWWorld::Ptr& actor, int choice, bool talkedToPlayer);
|
Filter (const MWWorld::Ptr& actor, int choice, bool talkedToPlayer);
|
||||||
|
|
||||||
std::vector<const ESM::DialInfo *> list (const ESM::Dialogue& dialogue,
|
std::vector<const ESM::DialInfo *> list (const ESM::Dialogue& dialogue,
|
||||||
bool fallbackToInfoRefusal, bool searchAll) const;
|
bool fallbackToInfoRefusal, bool searchAll, bool invertDisposition=false) const;
|
||||||
|
|
||||||
const ESM::DialInfo* search (const ESM::Dialogue& dialogue, const bool fallbackToInfoRefusal) const;
|
const ESM::DialInfo* search (const ESM::Dialogue& dialogue, const bool fallbackToInfoRefusal) const;
|
||||||
///< Get a matching response for the requested dialogue.
|
///< Get a matching response for the requested dialogue.
|
||||||
|
|
|
||||||
|
|
@ -241,40 +241,42 @@ void DialogueWindow::onSelectTopic(const std::string& topic, int id)
|
||||||
const MWWorld::Store<ESM::GameSetting> &gmst =
|
const MWWorld::Store<ESM::GameSetting> &gmst =
|
||||||
MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>();
|
MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>();
|
||||||
|
|
||||||
if (topic == gmst.find("sBarter")->getString())
|
|
||||||
{
|
|
||||||
/// \todo check if the player is allowed to trade with this actor (e.g. faction rank high enough)?
|
|
||||||
mWindowManager.pushGuiMode(GM_Barter);
|
|
||||||
mWindowManager.getTradeWindow()->startTrade(mPtr);
|
|
||||||
}
|
|
||||||
if (topic == gmst.find("sPersuasion")->getString())
|
if (topic == gmst.find("sPersuasion")->getString())
|
||||||
{
|
{
|
||||||
mPersuasionDialog.setVisible(true);
|
mPersuasionDialog.setVisible(true);
|
||||||
}
|
}
|
||||||
else if (topic == gmst.find("sSpells")->getString())
|
else if (!MWBase::Environment::get().getDialogueManager()->checkServiceRefused())
|
||||||
{
|
{
|
||||||
mWindowManager.pushGuiMode(GM_SpellBuying);
|
if (topic == gmst.find("sBarter")->getString())
|
||||||
mWindowManager.getSpellBuyingWindow()->startSpellBuying(mPtr);
|
{
|
||||||
}
|
mWindowManager.pushGuiMode(GM_Barter);
|
||||||
else if (topic == gmst.find("sTravel")->getString())
|
mWindowManager.getTradeWindow()->startTrade(mPtr);
|
||||||
{
|
}
|
||||||
mWindowManager.pushGuiMode(GM_Travel);
|
else if (topic == gmst.find("sSpells")->getString())
|
||||||
mWindowManager.getTravelWindow()->startTravel(mPtr);
|
{
|
||||||
}
|
mWindowManager.pushGuiMode(GM_SpellBuying);
|
||||||
else if (topic == gmst.find("sSpellMakingMenuTitle")->getString())
|
mWindowManager.getSpellBuyingWindow()->startSpellBuying(mPtr);
|
||||||
{
|
}
|
||||||
mWindowManager.pushGuiMode(GM_SpellCreation);
|
else if (topic == gmst.find("sTravel")->getString())
|
||||||
mWindowManager.startSpellMaking (mPtr);
|
{
|
||||||
}
|
mWindowManager.pushGuiMode(GM_Travel);
|
||||||
else if (topic == gmst.find("sEnchanting")->getString())
|
mWindowManager.getTravelWindow()->startTravel(mPtr);
|
||||||
{
|
}
|
||||||
mWindowManager.pushGuiMode(GM_Enchanting);
|
else if (topic == gmst.find("sSpellMakingMenuTitle")->getString())
|
||||||
mWindowManager.startEnchanting (mPtr);
|
{
|
||||||
}
|
mWindowManager.pushGuiMode(GM_SpellCreation);
|
||||||
else if (topic == gmst.find("sServiceTrainingTitle")->getString())
|
mWindowManager.startSpellMaking (mPtr);
|
||||||
{
|
}
|
||||||
mWindowManager.pushGuiMode(GM_Training);
|
else if (topic == gmst.find("sEnchanting")->getString())
|
||||||
mWindowManager.startTraining (mPtr);
|
{
|
||||||
|
mWindowManager.pushGuiMode(GM_Enchanting);
|
||||||
|
mWindowManager.startEnchanting (mPtr);
|
||||||
|
}
|
||||||
|
else if (topic == gmst.find("sServiceTrainingTitle")->getString())
|
||||||
|
{
|
||||||
|
mWindowManager.pushGuiMode(GM_Training);
|
||||||
|
mWindowManager.startTraining (mPtr);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue