forked from mirror/openmw-tes3mp
Clean up the NpcStats expelled interface. Show message box when expelled.
This commit is contained in:
parent
098f9712f1
commit
19d63f392f
5 changed files with 25 additions and 27 deletions
|
@ -507,9 +507,7 @@ bool MWDialogue::Filter::getSelectStructBoolean (const SelectWrapper& select) co
|
||||||
std::string faction =
|
std::string faction =
|
||||||
MWWorld::Class::get (mActor).getNpcStats (mActor).getFactionRanks().begin()->first;
|
MWWorld::Class::get (mActor).getNpcStats (mActor).getFactionRanks().begin()->first;
|
||||||
|
|
||||||
std::set<std::string>& expelled = MWWorld::Class::get (player).getNpcStats (player).getExpelled();
|
return player.getClass().getNpcStats(player).getExpelled(faction);
|
||||||
|
|
||||||
return expelled.find (faction)!=expelled.end();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
case SelectWrapper::Function_PcVampire:
|
case SelectWrapper::Function_PcVampire:
|
||||||
|
|
|
@ -470,7 +470,7 @@ namespace MWMechanics
|
||||||
it != MWBase::Environment::get().getWorld()->getStore().get<ESM::Faction>().find(Misc::StringUtils::lowerCase(npcFaction))->mReactions.end(); ++it)
|
it != MWBase::Environment::get().getWorld()->getStore().get<ESM::Faction>().find(Misc::StringUtils::lowerCase(npcFaction))->mReactions.end(); ++it)
|
||||||
{
|
{
|
||||||
if(Misc::StringUtils::lowerCase(it->mFaction) == Misc::StringUtils::lowerCase(npcFaction)
|
if(Misc::StringUtils::lowerCase(it->mFaction) == Misc::StringUtils::lowerCase(npcFaction)
|
||||||
&& playerStats.getExpelled().find(Misc::StringUtils::lowerCase(it->mFaction)) == playerStats.getExpelled().end())
|
&& !playerStats.getExpelled(it->mFaction))
|
||||||
reaction = it->mReaction;
|
reaction = it->mReaction;
|
||||||
}
|
}
|
||||||
rank = playerStats.getFactionRanks().find(Misc::StringUtils::lowerCase(npcFaction))->second;
|
rank = playerStats.getFactionRanks().find(Misc::StringUtils::lowerCase(npcFaction))->second;
|
||||||
|
|
|
@ -108,14 +108,26 @@ std::map<std::string, int>& MWMechanics::NpcStats::getFactionRanks()
|
||||||
return mFactionRank;
|
return mFactionRank;
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::set<std::string>& MWMechanics::NpcStats::getExpelled() const
|
bool MWMechanics::NpcStats::getExpelled(const std::string& factionID) const
|
||||||
{
|
{
|
||||||
return mExpelled;
|
return mExpelled.find(Misc::StringUtils::lowerCase(factionID)) != mExpelled.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::set<std::string>& MWMechanics::NpcStats::getExpelled()
|
void MWMechanics::NpcStats::expell(const std::string& factionID)
|
||||||
{
|
{
|
||||||
return mExpelled;
|
std::string lower = Misc::StringUtils::lowerCase(factionID);
|
||||||
|
if (mExpelled.find(lower) == mExpelled.end())
|
||||||
|
{
|
||||||
|
std::string message = "#{sExpelledMessage}";
|
||||||
|
message += MWBase::Environment::get().getWorld()->getStore().get<ESM::Faction>().find(factionID)->mName;
|
||||||
|
MWBase::Environment::get().getWindowManager()->messageBox(message);
|
||||||
|
mExpelled.insert(lower);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void MWMechanics::NpcStats::clearExpelled(const std::string& factionID)
|
||||||
|
{
|
||||||
|
mExpelled.erase(Misc::StringUtils::lowerCase(factionID));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MWMechanics::NpcStats::isSameFaction (const NpcStats& npcStats) const
|
bool MWMechanics::NpcStats::isSameFaction (const NpcStats& npcStats) const
|
||||||
|
|
|
@ -99,8 +99,10 @@ namespace MWMechanics
|
||||||
const std::map<std::string, int>& getFactionRanks() const;
|
const std::map<std::string, int>& getFactionRanks() const;
|
||||||
std::map<std::string, int>& getFactionRanks();
|
std::map<std::string, int>& getFactionRanks();
|
||||||
|
|
||||||
const std::set<std::string>& getExpelled() const;
|
const std::set<std::string>& getExpelled() const { return mExpelled; }
|
||||||
std::set<std::string>& getExpelled();
|
bool getExpelled(const std::string& factionID) const;
|
||||||
|
void expell(const std::string& factionID);
|
||||||
|
void clearExpelled(const std::string& factionID);
|
||||||
|
|
||||||
bool isSameFaction (const NpcStats& npcStats) const;
|
bool isSameFaction (const NpcStats& npcStats) const;
|
||||||
///< Do *this and \a npcStats share a faction?
|
///< Do *this and \a npcStats share a faction?
|
||||||
|
|
|
@ -905,15 +905,7 @@ namespace MWScript
|
||||||
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr();
|
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr();
|
||||||
if(factionID!="")
|
if(factionID!="")
|
||||||
{
|
{
|
||||||
std::set<std::string>& expelled = MWWorld::Class::get(player).getNpcStats(player).getExpelled ();
|
runtime.push(player.getClass().getNpcStats(player).getExpelled(factionID));
|
||||||
if (expelled.find (factionID) != expelled.end())
|
|
||||||
{
|
|
||||||
runtime.push(1);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
runtime.push(0);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -951,9 +943,7 @@ namespace MWScript
|
||||||
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr();
|
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr();
|
||||||
if(factionID!="")
|
if(factionID!="")
|
||||||
{
|
{
|
||||||
std::set<std::string>& expelled = MWWorld::Class::get(player).getNpcStats(player).getExpelled ();
|
player.getClass().getNpcStats(player).expell(factionID);
|
||||||
Misc::StringUtils::toLower(factionID);
|
|
||||||
expelled.insert(factionID);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -986,11 +976,7 @@ namespace MWScript
|
||||||
}
|
}
|
||||||
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr();
|
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr();
|
||||||
if(factionID!="")
|
if(factionID!="")
|
||||||
{
|
player.getClass().getNpcStats(player).clearExpelled(factionID);
|
||||||
std::set<std::string>& expelled = MWWorld::Class::get(player).getNpcStats(player).getExpelled ();
|
|
||||||
Misc::StringUtils::toLower(factionID);
|
|
||||||
expelled.erase (factionID);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue