mirror of
https://github.com/OpenMW/openmw.git
synced 2025-02-01 12:15:35 +00:00
Player followers don't report crimes (Fixes #2457)
This commit is contained in:
parent
3c3bd7976e
commit
8286dc6c5a
1 changed files with 25 additions and 5 deletions
|
@ -1049,6 +1049,19 @@ namespace MWMechanics
|
|||
commitCrime(ptr, victim, OT_Theft, item.getClass().getValue(item) * count);
|
||||
}
|
||||
|
||||
|
||||
void getFollowers (const MWWorld::Ptr& actor, std::set<MWWorld::Ptr>& out)
|
||||
{
|
||||
std::list<MWWorld::Ptr> followers = MWBase::Environment::get().getMechanicsManager()->getActorsFollowing(actor);
|
||||
for(std::list<MWWorld::Ptr>::iterator it = followers.begin();it != followers.end();++it)
|
||||
{
|
||||
if (out.insert(*it).second)
|
||||
{
|
||||
getFollowers(*it, out);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool MechanicsManager::commitCrime(const MWWorld::Ptr &player, const MWWorld::Ptr &victim, OffenseType type, int arg, bool victimAware)
|
||||
{
|
||||
// NOTE: victim may be empty
|
||||
|
@ -1070,6 +1083,10 @@ namespace MWMechanics
|
|||
if (!victim.isEmpty() && (from - victim.getRefData().getPosition().asVec3()).length2() > radius*radius)
|
||||
neighbors.push_back(victim);
|
||||
|
||||
// get the player's followers / allies (works recursively) that will not report crimes
|
||||
std::set<MWWorld::Ptr> playerFollowers;
|
||||
getFollowers(player, playerFollowers);
|
||||
|
||||
// Did anyone see it?
|
||||
bool crimeSeen = false;
|
||||
for (std::vector<MWWorld::Ptr>::iterator it = neighbors.begin(); it != neighbors.end(); ++it)
|
||||
|
@ -1085,11 +1102,6 @@ namespace MWMechanics
|
|||
// TODO: Add mod support for stealth executions!
|
||||
|| (type == OT_Murder && *it != victim))
|
||||
{
|
||||
if (type == OT_Theft || type == OT_Pickpocket)
|
||||
MWBase::Environment::get().getDialogueManager()->say(*it, "thief");
|
||||
else if (type == OT_Trespassing)
|
||||
MWBase::Environment::get().getDialogueManager()->say(*it, "intruder");
|
||||
|
||||
// Crime reporting only applies to NPCs
|
||||
if (!it->getClass().isNpc())
|
||||
continue;
|
||||
|
@ -1097,6 +1109,14 @@ namespace MWMechanics
|
|||
if (it->getClass().getCreatureStats(*it).getAiSequence().isInCombat(victim))
|
||||
continue;
|
||||
|
||||
if (playerFollowers.find(*it) != playerFollowers.end())
|
||||
continue;
|
||||
|
||||
if (type == OT_Theft || type == OT_Pickpocket)
|
||||
MWBase::Environment::get().getDialogueManager()->say(*it, "thief");
|
||||
else if (type == OT_Trespassing)
|
||||
MWBase::Environment::get().getDialogueManager()->say(*it, "intruder");
|
||||
|
||||
crimeSeen = true;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue