forked from mirror/openmw-tes3mp
more improvements to dialogue filters. Some of them are still missing.
This commit is contained in:
parent
f76e0e1941
commit
e7ef39cabc
2 changed files with 151 additions and 5 deletions
|
@ -9,6 +9,7 @@
|
||||||
|
|
||||||
#include <components/esm_store/store.hpp>
|
#include <components/esm_store/store.hpp>
|
||||||
|
|
||||||
|
|
||||||
#include "../mwworld/class.hpp"
|
#include "../mwworld/class.hpp"
|
||||||
#include "../mwworld/environment.hpp"
|
#include "../mwworld/environment.hpp"
|
||||||
#include "../mwworld/world.hpp"
|
#include "../mwworld/world.hpp"
|
||||||
|
@ -19,6 +20,8 @@
|
||||||
#include "../mwgui/dialogue.hpp"
|
#include "../mwgui/dialogue.hpp"
|
||||||
#include "../mwgui/window_manager.hpp"
|
#include "../mwgui/window_manager.hpp"
|
||||||
|
|
||||||
|
#include "journal.hpp"
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
|
@ -128,7 +131,7 @@ namespace MWDialogue
|
||||||
std::string name = select.selectRule.substr (5);
|
std::string name = select.selectRule.substr (5);
|
||||||
|
|
||||||
// TODO types 4, 5, 6, 7, 8, 9, A, B, C
|
// TODO types 4, 5, 6, 7, 8, 9, A, B, C
|
||||||
|
//new TOTO: 5,6,9
|
||||||
switch (type)
|
switch (type)
|
||||||
{
|
{
|
||||||
case '1': // function
|
case '1': // function
|
||||||
|
@ -169,12 +172,122 @@ namespace MWDialogue
|
||||||
mEnvironment.mWorld->getStore()))
|
mEnvironment.mWorld->getStore()))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
throw std::runtime_error (
|
||||||
|
"unsupported variable type in dialogue info select");
|
||||||
|
|
||||||
|
return true;
|
||||||
|
|
||||||
|
case '4'://journal
|
||||||
|
if(select.type==ESM::VT_Int)
|
||||||
|
{
|
||||||
|
//std::cout << "vtint: " << select.i << std::endl;
|
||||||
|
bool isInJournal;
|
||||||
|
if(mEnvironment.mJournal->begin()!=mEnvironment.mJournal->end())
|
||||||
|
{
|
||||||
|
for(std::deque<MWDialogue::StampedJournalEntry>::const_iterator it = mEnvironment.mJournal->begin();it!=mEnvironment.mJournal->end();it++)
|
||||||
|
{
|
||||||
|
|
||||||
|
if(it->mTopic == name) isInJournal = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
isInJournal = false;
|
||||||
|
if(!selectCompare<int,int>(comp,int(isInJournal),select.i)) return false;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
throw std::runtime_error (
|
throw std::runtime_error (
|
||||||
"unsupported variable type in dialogue info select");
|
"unsupported variable type in dialogue info select");
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
case '7':// not ID
|
||||||
|
if(select.type==ESM::VT_String ||select.type==ESM::VT_Int)//bug in morrowind here? it's not a short, it's a string
|
||||||
|
{
|
||||||
|
int isID = int(toLower(name)==toLower(MWWorld::Class::get (actor).getId (actor)));
|
||||||
|
if (selectCompare<int,int>(comp,!isID,select.i)) return false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
throw std::runtime_error (
|
||||||
|
"unsupported variable type in dialogue info select");
|
||||||
|
|
||||||
|
return true;
|
||||||
|
|
||||||
|
case '8':// not faction
|
||||||
|
if(select.type==ESM::VT_Int)
|
||||||
|
{
|
||||||
|
ESMS::LiveCellRef<ESM::NPC, MWWorld::RefData>* npc = actor.get<ESM::NPC>();
|
||||||
|
int isFaction = int(toLower(npc->base->faction) == toLower(name));
|
||||||
|
if(selectCompare<int,int>(comp,!isFaction,select.i))
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
throw std::runtime_error (
|
||||||
|
"unsupported variable type in dialogue info select");
|
||||||
|
|
||||||
|
return true;
|
||||||
|
|
||||||
|
case '9':// not class
|
||||||
|
if(select.type==ESM::VT_Int)
|
||||||
|
{
|
||||||
|
ESMS::LiveCellRef<ESM::NPC, MWWorld::RefData>* npc = actor.get<ESM::NPC>();
|
||||||
|
int isClass = int(toLower(npc->base->cls) == toLower(name));
|
||||||
|
if(selectCompare<int,int>(comp,!isClass,select.i))
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
throw std::runtime_error (
|
||||||
|
"unsupported variable type in dialogue info select");
|
||||||
|
|
||||||
|
return true;
|
||||||
|
|
||||||
|
case 'A'://not Race
|
||||||
|
if(select.type==ESM::VT_Int)
|
||||||
|
{
|
||||||
|
ESMS::LiveCellRef<ESM::NPC, MWWorld::RefData>* npc = actor.get<ESM::NPC>();
|
||||||
|
int isRace = int(toLower(npc->base->race) == toLower(name));
|
||||||
|
//std::cout << "isRace"<<isRace; mEnvironment.mWorld
|
||||||
|
if(selectCompare<int,int>(comp,!isRace,select.i))
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
throw std::runtime_error (
|
||||||
|
"unsupported variable type in dialogue info select");
|
||||||
|
|
||||||
|
return true;
|
||||||
|
|
||||||
|
case 'B'://not Cell
|
||||||
|
if(select.type==ESM::VT_Int)
|
||||||
|
{
|
||||||
|
int isCell = int(toLower(actor.getCell()->cell->name) == toLower(name));
|
||||||
|
if(selectCompare<int,int>(comp,!isCell,select.i))
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
throw std::runtime_error (
|
||||||
|
"unsupported variable type in dialogue info select");
|
||||||
|
return true;
|
||||||
|
|
||||||
|
case 'C'://not local
|
||||||
|
if (select.type==ESM::VT_Short || select.type==ESM::VT_Int ||
|
||||||
|
select.type==ESM::VT_Long)
|
||||||
|
{
|
||||||
|
if (checkLocal (comp, toLower (name), select.i, actor,
|
||||||
|
mEnvironment.mWorld->getStore()))
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else if (select.type==ESM::VT_Float)
|
||||||
|
{
|
||||||
|
if (checkLocal (comp, toLower (name), select.f, actor,
|
||||||
|
mEnvironment.mWorld->getStore()))
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
throw std::runtime_error (
|
||||||
|
"unsupported variable type in dialogue info select");
|
||||||
|
return true;
|
||||||
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
||||||
std::cout << "unchecked select: " << type << " " << comp << " " << name << std::endl;
|
std::cout << "unchecked select: " << type << " " << comp << " " << name << std::endl;
|
||||||
|
@ -186,11 +299,13 @@ namespace MWDialogue
|
||||||
|
|
||||||
bool DialogueManager::isMatching (const MWWorld::Ptr& actor, const ESM::DialInfo& info) const
|
bool DialogueManager::isMatching (const MWWorld::Ptr& actor, const ESM::DialInfo& info) const
|
||||||
{
|
{
|
||||||
|
//bool return true;//does the actor knows the topic?
|
||||||
// actor id
|
// actor id
|
||||||
if (!info.actor.empty())
|
if (!info.actor.empty())
|
||||||
if (toLower (info.actor)!=MWWorld::Class::get (actor).getId (actor))
|
if (toLower (info.actor)!=MWWorld::Class::get (actor).getId (actor))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
//NPC race
|
||||||
if (!info.race.empty())
|
if (!info.race.empty())
|
||||||
{
|
{
|
||||||
ESMS::LiveCellRef<ESM::NPC, MWWorld::RefData> *cellRef = actor.get<ESM::NPC>();
|
ESMS::LiveCellRef<ESM::NPC, MWWorld::RefData> *cellRef = actor.get<ESM::NPC>();
|
||||||
|
@ -202,6 +317,7 @@ namespace MWDialogue
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//NPC class
|
||||||
if (!info.clas.empty())
|
if (!info.clas.empty())
|
||||||
{
|
{
|
||||||
ESMS::LiveCellRef<ESM::NPC, MWWorld::RefData> *cellRef = actor.get<ESM::NPC>();
|
ESMS::LiveCellRef<ESM::NPC, MWWorld::RefData> *cellRef = actor.get<ESM::NPC>();
|
||||||
|
@ -213,6 +329,7 @@ namespace MWDialogue
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//NPC faction
|
||||||
if (!info.npcFaction.empty())
|
if (!info.npcFaction.empty())
|
||||||
{
|
{
|
||||||
ESMS::LiveCellRef<ESM::NPC, MWWorld::RefData> *cellRef = actor.get<ESM::NPC>();
|
ESMS::LiveCellRef<ESM::NPC, MWWorld::RefData> *cellRef = actor.get<ESM::NPC>();
|
||||||
|
@ -222,10 +339,32 @@ namespace MWDialogue
|
||||||
|
|
||||||
if (toLower (info.npcFaction)!=toLower (cellRef->base->faction))
|
if (toLower (info.npcFaction)!=toLower (cellRef->base->faction))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
//check NPC rank
|
||||||
|
if(cellRef->base->npdt52.gold != -10)
|
||||||
|
{
|
||||||
|
if(cellRef->base->npdt52.rank < info.data.rank) return false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if(cellRef->base->npdt12.rank < info.data.rank) return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO check player faction
|
// TODO check player faction
|
||||||
|
|
||||||
|
//check gender
|
||||||
|
ESMS::LiveCellRef<ESM::NPC, MWWorld::RefData>* npc = actor.get<ESM::NPC>();
|
||||||
|
if(npc->base->flags&npc->base->Female)
|
||||||
|
{
|
||||||
|
if(static_cast<int> (info.data.gender)==0) return false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if(static_cast<int> (info.data.gender)==1) return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// check cell
|
// check cell
|
||||||
if (!info.cell.empty())
|
if (!info.cell.empty())
|
||||||
if (mEnvironment.mWorld->getPlayer().getPlayer().getCell()->cell->name != info.cell)
|
if (mEnvironment.mWorld->getPlayer().getPlayer().getCell()->cell->name != info.cell)
|
||||||
|
@ -297,10 +436,14 @@ namespace MWDialogue
|
||||||
{
|
{
|
||||||
if (isMatching (actor, *iter))
|
if (isMatching (actor, *iter))
|
||||||
{
|
{
|
||||||
MWGui::DialogueWindow* win = mEnvironment.mWindowManager->getDialogueWindow();
|
if(knownTopics.find(toLower(it->first)) != knownTopics.end())
|
||||||
win->addKeyword(it->first,iter->response);
|
{
|
||||||
//std::cout << "match found!!";
|
MWGui::DialogueWindow* win = mEnvironment.mWindowManager->getDialogueWindow();
|
||||||
break;
|
win->addKeyword(it->first,iter->response);
|
||||||
|
//std::cout << it->first;
|
||||||
|
//std::cout << "match found!!";
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
#include <components/esm/loadinfo.hpp>
|
#include <components/esm/loadinfo.hpp>
|
||||||
|
|
||||||
#include "../mwworld/ptr.hpp"
|
#include "../mwworld/ptr.hpp"
|
||||||
|
#include <map>
|
||||||
|
|
||||||
namespace MWWorld
|
namespace MWWorld
|
||||||
{
|
{
|
||||||
|
@ -20,6 +21,8 @@ namespace MWDialogue
|
||||||
|
|
||||||
bool isMatching (const MWWorld::Ptr& actor, const ESM::DialInfo& info) const;
|
bool isMatching (const MWWorld::Ptr& actor, const ESM::DialInfo& info) const;
|
||||||
|
|
||||||
|
std::map<std::string,bool> knownTopics;// Those are the topics the player knows.
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
DialogueManager (MWWorld::Environment& environment);
|
DialogueManager (MWWorld::Environment& environment);
|
||||||
|
|
Loading…
Reference in a new issue