handle persuasion records properly

actorid
Marc Zinnschlag 12 years ago
parent a70a5282f4
commit caaffd1ec2

@ -238,6 +238,44 @@ namespace MWDialogue
}
}
void DialogueManager::executeTopic (const std::string& topic)
{
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 (topic);
if (const ESM::DialInfo *info = filter.search (dialogue))
{
parseText (info->mResponse);
MWGui::DialogueWindow* win = MWBase::Environment::get().getWindowManager()->getDialogueWindow();
if (dialogue.mType==ESM::Dialogue::Persuasion)
{
std::string modifiedTopic = "s" + topic;
modifiedTopic.erase (std::remove (modifiedTopic.begin(), modifiedTopic.end(), ' '), modifiedTopic.end());
const MWWorld::Store<ESM::GameSetting>& gmsts =
MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>();
win->addTitle (gmsts.find (modifiedTopic)->getString());
}
else
win->addTitle (topic);
win->addText (info->mResponse);
executeScript (info->mResultScript);
mLastTopic = topic;
mLastDialogue = *info;
}
}
void DialogueManager::updateTopics()
{
std::list<std::string> keywordList;
@ -332,24 +370,7 @@ namespace MWDialogue
ESM::Dialogue ndialogue = mDialogueMap[keyword];
if (mDialogueMap[keyword].mType == ESM::Dialogue::Topic)
{
Filter filter (mActor, mChoice, mTalkedTo);
if (const ESM::DialInfo *info = filter.search (mDialogueMap[keyword]))
{
std::string text = info->mResponse;
std::string script = info->mResultScript;
parseText (text);
MWGui::DialogueWindow* win = MWBase::Environment::get().getWindowManager()->getDialogueWindow();
win->addTitle (keyword);
win->addText (info->mResponse);
executeScript (script);
mLastTopic = keyword;
mLastDialogue = *info;
}
executeTopic (keyword);
}
}
}
@ -445,28 +466,22 @@ namespace MWDialogue
else if (curDisp + mTemporaryDispositionChange > 100)
mTemporaryDispositionChange = 100 - curDisp;
// add status message to dialogue window
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer();
MWWorld::Class::get(player).skillUsageSucceeded(player, ESM::Skill::Speechcraft, success ? 0 : 1);
std::string text;
if (type == MWBase::MechanicsManager::PT_Admire)
text = "sAdmire";
text = "Admire";
else if (type == MWBase::MechanicsManager::PT_Taunt)
text = "sTaunt";
text = "Taunt";
else if (type == MWBase::MechanicsManager::PT_Intimidate)
text = "sIntimidate";
text = "Intimidate";
else{
text = "sBribe";
text = "Bribe";
}
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer();
MWWorld::Class::get(player).skillUsageSucceeded(player, ESM::Skill::Speechcraft, success ? 0 : 1);
text += (success ? "Success" : "Fail");
MWGui::DialogueWindow* win = MWBase::Environment::get().getWindowManager()->getDialogueWindow();
win->addTitle(MyGUI::LanguageManager::getInstance().replaceTags("#{"+text+"}"));
/// \todo text from INFO record, how to get the ID?
executeTopic (text + (success ? " Success" : " Fail"));
}
int DialogueManager::getTemporaryDispositionChange() const

@ -23,7 +23,7 @@ namespace MWDialogue
MWScript::CompilerContext mCompilerContext;
std::ostream mErrorStream;
Compiler::StreamErrorHandler mErrorHandler;
MWWorld::Ptr mActor;
bool mTalkedTo;
@ -46,6 +46,8 @@ namespace MWDialogue
void printError (const std::string& error);
void executeTopic (const std::string& topic);
public:
DialogueManager (const Compiler::Extensions& extensions, bool scriptVerbose);

Loading…
Cancel
Save