1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-02-10 21:40:15 +00:00

on dialogue start run through the info records of dialogue record 'hello'; currently no testing done -> the first info recrod will match

This commit is contained in:
Marc Zinnschlag 2010-08-08 11:34:03 +02:00
parent b5d59edd44
commit 9d25e74a05
2 changed files with 68 additions and 0 deletions

View File

@ -1,17 +1,78 @@
#include "dialoguemanager.hpp" #include "dialoguemanager.hpp"
#include <components/esm/loadinfo.hpp>
#include <components/esm/loaddial.hpp>
#include <components/esm_store/store.hpp>
#include "../mwworld/class.hpp" #include "../mwworld/class.hpp"
#include "../mwworld/environment.hpp"
#include "../mwworld/world.hpp"
#include <iostream> #include <iostream>
namespace MWDialogue namespace MWDialogue
{ {
bool DialogueManager::isMatching (const MWWorld::Ptr& actor, const ESM::DialInfo& info) const
{
// TODO check actor id
// TODO check actor race
// TODO check actor class
// TODO check actor faction
// TODO check player faction
// TODO check cell
// TODO check DATAstruct
// TODO check select structures
std::cout
<< "unchecked entries:" << std::endl
<< " actor id: " << info.actor << std::endl
<< " actor race: " << info.race << std::endl
<< " actor class: " << info.clas << std::endl
<< " actor faction: " << info.npcFaction << std::endl
<< " player faction: " << info.pcFaction << std::endl
<< " cell: " << info.cell << std::endl
<< " DATAstruct" << std::endl;
for (std::vector<ESM::DialInfo::SelectStruct>::const_iterator iter (info.selects.begin());
iter != info.selects.end(); ++iter)
std::cout << " select: " << iter->selectRule << std::endl;
return true;
}
DialogueManager::DialogueManager (MWWorld::Environment& environment) : mEnvironment (environment) {} DialogueManager::DialogueManager (MWWorld::Environment& environment) : mEnvironment (environment) {}
void DialogueManager::startDialogue (const MWWorld::Ptr& actor) void DialogueManager::startDialogue (const MWWorld::Ptr& actor)
{ {
std::cout << "talking with " << MWWorld::Class::get (actor).getName (actor) << std::endl; std::cout << "talking with " << MWWorld::Class::get (actor).getName (actor) << std::endl;
const ESM::Dialogue *dialogue = mEnvironment.mWorld->getStore().dialogs.find ("hello");
for (std::vector<ESM::DialInfo>::const_iterator iter (dialogue->mInfo.begin());
iter!=dialogue->mInfo.end(); ++iter)
{
if (isMatching (actor, *iter))
{
// start dialogue
std::cout << "found matching info record" << std::endl;
std::cout << "response: " << iter->response << std::endl;
if (!iter->sound.empty())
{
// TODO play sound
}
if (!iter->resultScript.empty())
{
// TODO execute script
}
break;
}
}
} }
} }

View File

@ -3,6 +3,11 @@
#include "../mwworld/ptr.hpp" #include "../mwworld/ptr.hpp"
namespace ESM
{
struct DialInfo;
}
namespace MWWorld namespace MWWorld
{ {
class Environment; class Environment;
@ -14,6 +19,8 @@ namespace MWDialogue
{ {
MWWorld::Environment& mEnvironment; MWWorld::Environment& mEnvironment;
bool isMatching (const MWWorld::Ptr& actor, const ESM::DialInfo& info) const;
public: public:
DialogueManager (MWWorld::Environment& environment); DialogueManager (MWWorld::Environment& environment);