mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-04 02:41:19 +00:00
Take in account faction reaction changes
This commit is contained in:
parent
2438fb4c98
commit
1909ec121b
@ -2,6 +2,7 @@
|
||||
#define GAME_MWBASE_DIALOGUEMANAGER_H
|
||||
|
||||
#include <list>
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <vector>
|
||||
@ -108,11 +109,15 @@ namespace MWBase
|
||||
/// Changes faction1's opinion of faction2 by \a diff.
|
||||
virtual void modFactionReaction(const ESM::RefId& faction1, const ESM::RefId& faction2, int diff) = 0;
|
||||
|
||||
/// Set faction1's opinion of faction2.
|
||||
virtual void setFactionReaction(const ESM::RefId& faction1, const ESM::RefId& faction2, int absolute) = 0;
|
||||
|
||||
/// @return faction1's opinion of faction2
|
||||
virtual int getFactionReaction(const ESM::RefId& faction1, const ESM::RefId& faction2) const = 0;
|
||||
|
||||
/// @return all faction's opinion overrides
|
||||
virtual const std::map<ESM::RefId, int>* getFactionReactionOverrides(const ESM::RefId& faction) const = 0;
|
||||
|
||||
/// Removes the last added topic response for the given actor from the journal
|
||||
virtual void clearInfoActor(const MWWorld::Ptr& actor) const = 0;
|
||||
};
|
||||
|
@ -738,6 +738,17 @@ namespace MWDialogue
|
||||
return 0;
|
||||
}
|
||||
|
||||
const std::map<ESM::RefId, int>* DialogueManager::getFactionReactionOverrides(const ESM::RefId& faction) const
|
||||
{
|
||||
// Make sure the faction exists
|
||||
MWBase::Environment::get().getESMStore()->get<ESM::Faction>().find(faction);
|
||||
|
||||
const auto found = mChangedFactionReaction.find(faction);
|
||||
if (found != mChangedFactionReaction.end())
|
||||
return &found->second;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void DialogueManager::clearInfoActor(const MWWorld::Ptr& actor) const
|
||||
{
|
||||
if (actor == mActor && !mLastTopic.empty())
|
||||
|
@ -126,6 +126,8 @@ namespace MWDialogue
|
||||
/// @return faction1's opinion of faction2
|
||||
int getFactionReaction(const ESM::RefId& faction1, const ESM::RefId& faction2) const override;
|
||||
|
||||
const std::map<ESM::RefId, int>* getFactionReactionOverrides(const ESM::RefId& faction) const override;
|
||||
|
||||
/// Removes the last added topic response for the given actor from the journal
|
||||
void clearInfoActor(const MWWorld::Ptr& actor) const override;
|
||||
};
|
||||
|
@ -4,6 +4,9 @@
|
||||
#include <components/esm3/loadfact.hpp>
|
||||
#include <components/lua/luastate.hpp>
|
||||
|
||||
#include "../mwbase/dialoguemanager.hpp"
|
||||
#include "../mwbase/environment.hpp"
|
||||
|
||||
#include "../mwworld/store.hpp"
|
||||
|
||||
#include "idcollectionbindings.hpp"
|
||||
@ -70,6 +73,16 @@ namespace MWLua
|
||||
sol::table res(lua, sol::create);
|
||||
for (const auto& [factionId, reaction] : rec.mReactions)
|
||||
res[factionId.serializeText()] = reaction;
|
||||
|
||||
const auto* overrides
|
||||
= MWBase::Environment::get().getDialogueManager()->getFactionReactionOverrides(rec.mId);
|
||||
|
||||
if (overrides != nullptr)
|
||||
{
|
||||
for (const auto& [factionId, reaction] : *overrides)
|
||||
res[factionId.serializeText()] = reaction;
|
||||
}
|
||||
|
||||
return res;
|
||||
});
|
||||
factionT["attributes"] = sol::readonly_property([&lua](const ESM::Faction& rec) {
|
||||
|
Loading…
Reference in New Issue
Block a user