persuasion dialog

actorid
scrawl 12 years ago
parent f6a9029c4b
commit ace9ee9c83

@ -85,6 +85,18 @@ namespace MWBase
virtual int countDeaths (const std::string& id) const = 0; virtual int countDeaths (const std::string& id) const = 0;
///< Return the number of deaths for actors with the given ID. ///< Return the number of deaths for actors with the given ID.
enum PersuasionType
{
PT_Admire,
PT_Intimidate,
PT_Taunt,
PT_Bribe10,
PT_Bribe100,
PT_Bribe1000
};
virtual float getPersuasionDispositionChange (MWWorld::Ptr npc, PersuasionType type, bool& success) const = 0;
///< Get amount to adjust temporary disposition for a given persuasion action on an NPC
}; };
} }

@ -95,7 +95,7 @@ namespace MWClass
data->mCreatureStats.setFatigue (ref->mBase->mNpdt52.mFatigue); data->mCreatureStats.setFatigue (ref->mBase->mNpdt52.mFatigue);
data->mCreatureStats.setLevel(ref->mBase->mNpdt52.mLevel); data->mCreatureStats.setLevel(ref->mBase->mNpdt52.mLevel);
data->mNpcStats.setDisposition(ref->mBase->mNpdt52.mDisposition); data->mNpcStats.setBaseDisposition(ref->mBase->mNpdt52.mDisposition);
} }
else else
{ {

@ -49,14 +49,87 @@ std::string::size_type find_str_ci(const std::string& str, const std::string& su
} }
PersuasionDialog::PersuasionDialog(MWBase::WindowManager &parWindowManager)
: WindowModal("openmw_persuasion_dialog.layout", parWindowManager)
{
getWidget(mCancelButton, "CancelButton");
getWidget(mAdmireButton, "AdmireButton");
getWidget(mIntimidateButton, "IntimidateButton");
getWidget(mTauntButton, "TauntButton");
getWidget(mBribe10Button, "Bribe10Button");
getWidget(mBribe100Button, "Bribe100Button");
getWidget(mBribe1000Button, "Bribe1000Button");
getWidget(mGoldLabel, "GoldLabel");
mCancelButton->eventMouseButtonClick += MyGUI::newDelegate(this, &PersuasionDialog::onCancel);
mAdmireButton->eventMouseButtonClick += MyGUI::newDelegate(this, &PersuasionDialog::onPersuade);
mIntimidateButton->eventMouseButtonClick += MyGUI::newDelegate(this, &PersuasionDialog::onPersuade);
mTauntButton->eventMouseButtonClick += MyGUI::newDelegate(this, &PersuasionDialog::onPersuade);
mBribe10Button->eventMouseButtonClick += MyGUI::newDelegate(this, &PersuasionDialog::onPersuade);
mBribe100Button->eventMouseButtonClick += MyGUI::newDelegate(this, &PersuasionDialog::onPersuade);
mBribe1000Button->eventMouseButtonClick += MyGUI::newDelegate(this, &PersuasionDialog::onPersuade);
}
void PersuasionDialog::onCancel(MyGUI::Widget *sender)
{
setVisible(false);
}
void PersuasionDialog::onPersuade(MyGUI::Widget *sender)
{
MWBase::MechanicsManager::PersuasionType type;
if (sender == mAdmireButton) type = MWBase::MechanicsManager::PT_Admire;
else if (sender == mIntimidateButton) type = MWBase::MechanicsManager::PT_Intimidate;
else if (sender == mTauntButton) type = MWBase::MechanicsManager::PT_Taunt;
else if (sender == mBribe10Button)
{
mWindowManager.getTradeWindow()->addOrRemoveGold(-10);
type = MWBase::MechanicsManager::PT_Bribe10;
}
else if (sender == mBribe100Button)
{
mWindowManager.getTradeWindow()->addOrRemoveGold(-100);
type = MWBase::MechanicsManager::PT_Bribe100;
}
else /*if (sender == mBribe1000Button)*/
{
mWindowManager.getTradeWindow()->addOrRemoveGold(-1000);
type = MWBase::MechanicsManager::PT_Bribe1000;
}
eventPersuade(type, true, 0);
setVisible(false);
}
void PersuasionDialog::open()
{
WindowModal::open();
center();
int playerGold = mWindowManager.getInventoryWindow()->getPlayerGold();
mBribe10Button->setEnabled (playerGold >= 10);
mBribe100Button->setEnabled (playerGold >= 100);
mBribe1000Button->setEnabled (playerGold >= 1000);
mGoldLabel->setCaptionWithReplacing("#{sGold}: " + boost::lexical_cast<std::string>(playerGold));
}
// --------------------------------------------------------------------------------------------------
DialogueWindow::DialogueWindow(MWBase::WindowManager& parWindowManager) DialogueWindow::DialogueWindow(MWBase::WindowManager& parWindowManager)
: WindowBase("openmw_dialogue_window.layout", parWindowManager) : WindowBase("openmw_dialogue_window.layout", parWindowManager)
, mPersuasionDialog(parWindowManager)
, mEnabled(false) , mEnabled(false)
, mServices(0) , mServices(0)
{ {
// Centre dialog // Centre dialog
center(); center();
mPersuasionDialog.setVisible(false);
mPersuasionDialog.eventPersuade += MyGUI::newDelegate(this, &DialogueWindow::onPersuade);
//History view //History view
getWidget(mHistory, "History"); getWidget(mHistory, "History");
mHistory->setOverflowToTheLeft(true); mHistory->setOverflowToTheLeft(true);
@ -137,6 +210,10 @@ void DialogueWindow::onSelectTopic(std::string topic)
mWindowManager.pushGuiMode(GM_Barter); mWindowManager.pushGuiMode(GM_Barter);
mWindowManager.getTradeWindow()->startTrade(mPtr); mWindowManager.getTradeWindow()->startTrade(mPtr);
} }
if (topic == gmst.find("sPersuasion")->getString())
{
mPersuasionDialog.setVisible(true);
}
else if (topic == gmst.find("sSpells")->getString()) else if (topic == gmst.find("sSpells")->getString())
{ {
mWindowManager.pushGuiMode(GM_SpellBuying); mWindowManager.pushGuiMode(GM_SpellBuying);
@ -187,6 +264,9 @@ void DialogueWindow::setKeywords(std::list<std::string> keyWords)
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 (mPtr.getTypeName() == typeid(ESM::NPC).name())
mTopicsList->addItem(gmst.find("sPersuasion")->getString());
if (mServices & Service_Trade) if (mServices & Service_Trade)
mTopicsList->addItem(gmst.find("sBarter")->getString()); mTopicsList->addItem(gmst.find("sBarter")->getString());
@ -311,6 +391,8 @@ void DialogueWindow::updateOptions()
void DialogueWindow::goodbye() void DialogueWindow::goodbye()
{ {
// Apply temporary disposition change to NPC's base disposition
mHistory->addDialogText("\n#572D21" + MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find("sGoodbye")->getString()); mHistory->addDialogText("\n#572D21" + MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find("sGoodbye")->getString());
mTopicsList->setEnabled(false); mTopicsList->setEnabled(false);
mEnabled = false; mEnabled = false;
@ -331,3 +413,24 @@ void DialogueWindow::onFrame()
mDispositionText->addText("#B29154"+boost::lexical_cast<std::string>(MWBase::Environment::get().getMechanicsManager()->getDerivedDisposition(mPtr))+std::string("/100")+"#B29154"); mDispositionText->addText("#B29154"+boost::lexical_cast<std::string>(MWBase::Environment::get().getMechanicsManager()->getDerivedDisposition(mPtr))+std::string("/100")+"#B29154");
} }
} }
void DialogueWindow::onPersuade(int type, bool success, float dispositionChange)
{
std::string text;
if (type == MWBase::MechanicsManager::PT_Admire)
text = "sAdmire";
else if (type == MWBase::MechanicsManager::PT_Taunt)
text = "sTaunt";
else if (type == MWBase::MechanicsManager::PT_Intimidate)
text = "sIntimidate";
else
text = "sBribe";
text += success ? "Fail" : "Success";
mHistory->addDialogHeading( MyGUI::LanguageManager::getInstance().replaceTags("#{"+text+"}"));
/// \todo text from INFO record, how to get the ID?
//mHistory->addDialogText();
}

@ -26,6 +26,31 @@ namespace MWGui
{ {
class DialogueHistory; class DialogueHistory;
class PersuasionDialog : public WindowModal
{
public:
PersuasionDialog(MWBase::WindowManager& parWindowManager);
virtual void open();
typedef MyGUI::delegates::CMultiDelegate3<int, bool, float> EventHandle_Persuade;
EventHandle_Persuade eventPersuade;
private:
MyGUI::Button* mCancelButton;
MyGUI::Button* mAdmireButton;
MyGUI::Button* mIntimidateButton;
MyGUI::Button* mTauntButton;
MyGUI::Button* mBribe10Button;
MyGUI::Button* mBribe100Button;
MyGUI::Button* mBribe1000Button;
MyGUI::TextBox* mGoldLabel;
void onCancel (MyGUI::Widget* sender);
void onPersuade (MyGUI::Widget* sender);
};
class DialogueWindow: public WindowBase, public ReferenceInterface class DialogueWindow: public WindowBase, public ReferenceInterface
{ {
public: public:
@ -86,6 +111,13 @@ namespace MWGui
Widgets::MWList* mTopicsList; Widgets::MWList* mTopicsList;
MyGUI::ProgressPtr mDispositionBar; MyGUI::ProgressPtr mDispositionBar;
MyGUI::EditPtr mDispositionText; MyGUI::EditPtr mDispositionText;
PersuasionDialog mPersuasionDialog;
float mTemporaryDispositionChange;
void onPersuade (int type, bool success, float dispositionChange);
}; };
} }
#endif #endif

@ -391,7 +391,7 @@ namespace MWMechanics
int MechanicsManager::getDerivedDisposition(const MWWorld::Ptr& ptr) int MechanicsManager::getDerivedDisposition(const MWWorld::Ptr& ptr)
{ {
MWMechanics::NpcStats npcSkill = MWWorld::Class::get(ptr).getNpcStats(ptr); MWMechanics::NpcStats npcSkill = MWWorld::Class::get(ptr).getNpcStats(ptr);
float x = npcSkill.getDisposition(); float x = npcSkill.getBaseDisposition();
MWWorld::LiveCellRef<ESM::NPC>* npc = ptr.get<ESM::NPC>(); MWWorld::LiveCellRef<ESM::NPC>* npc = ptr.get<ESM::NPC>();
MWWorld::Ptr playerPtr = MWBase::Environment::get().getWorld()->getPlayer().getPlayer(); MWWorld::Ptr playerPtr = MWBase::Environment::get().getWorld()->getPlayer().getPlayer();
@ -489,4 +489,10 @@ namespace MWMechanics
{ {
return mActors.countDeaths (id); return mActors.countDeaths (id);
} }
float MechanicsManager::getPersuasionDispositionChange (MWWorld::Ptr npc, PersuasionType type, bool& success) const
{
return 0.f;
}
} }

@ -88,6 +88,8 @@ namespace MWMechanics
virtual int countDeaths (const std::string& id) const; virtual int countDeaths (const std::string& id) const;
///< Return the number of deaths for actors with the given ID. ///< Return the number of deaths for actors with the given ID.
virtual float getPersuasionDispositionChange (MWWorld::Ptr npc, PersuasionType type, bool& success) const;
///< Get amount to adjust temporary disposition for a given persuasion action on an NPC
}; };
} }

@ -37,12 +37,12 @@ void MWMechanics::NpcStats::setDrawState (DrawState_ state)
mDrawState = state; mDrawState = state;
} }
int MWMechanics::NpcStats::getDisposition() const int MWMechanics::NpcStats::getBaseDisposition() const
{ {
return mDisposition; return mDisposition;
} }
void MWMechanics::NpcStats::setDisposition(int disposition) void MWMechanics::NpcStats::setBaseDisposition(int disposition)
{ {
mDisposition = disposition; mDisposition = disposition;
} }

@ -62,9 +62,9 @@ namespace MWMechanics
void setDrawState (DrawState_ state); void setDrawState (DrawState_ state);
int getDisposition() const; int getBaseDisposition() const;
void setDisposition(int disposition); void setBaseDisposition(int disposition);
bool getMovementFlag (Flag flag) const; bool getMovementFlag (Flag flag) const;

@ -23,7 +23,8 @@ namespace MWRender
mFreeLook(true), mFreeLook(true),
mHeight(128.f), mHeight(128.f),
mCameraDistance(300.f), mCameraDistance(300.f),
mDistanceAdjusted(false) mDistanceAdjusted(false),
mAnimation(NULL)
{ {
mVanity.enabled = false; mVanity.enabled = false;
mVanity.allowed = true; mVanity.allowed = true;

@ -80,6 +80,7 @@ set(MYGUI_FILES
openmw_enchanting_dialog.layout openmw_enchanting_dialog.layout
openmw_trainingwindow.layout openmw_trainingwindow.layout
openmw_travel_window.layout openmw_travel_window.layout
openmw_persuasion_dialog.layout
smallbars.png smallbars.png
VeraMono.ttf VeraMono.ttf
markers.png markers.png

Loading…
Cancel
Save