Skip to content

Commit

Permalink
Merge branch 'followthecrab' into 'master'
Browse files Browse the repository at this point in the history
Stop combat when stacking a new AI package

Closes #7661

See merge request OpenMW/openmw!3665
  • Loading branch information
Capostrophic committed Dec 21, 2023
2 parents 78a8f9d + 8a1ca87 commit 51cb3b0
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@
Bug #7647: NPC walk cycle bugs after greeting player
Bug #7654: Tooltips for enchantments with invalid effects cause crashes
Bug #7660: Some inconsistencies regarding Invisibility breaking
Bug #7661: Player followers should stop attacking newly recruited actors
Bug #7665: Alchemy menu is missing the ability to deselect and choose different qualities of an apparatus
Bug #7675: Successful lock spell doesn't produce a sound
Bug #7679: Scene luminance value flashes when toggling shaders
Expand Down
16 changes: 16 additions & 0 deletions apps/openmw/mwmechanics/aisequence.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
#include <components/debug/debuglog.hpp>
#include <components/esm3/aisequence.hpp>

#include "../mwbase/environment.hpp"
#include "../mwbase/mechanicsmanager.hpp"
#include "../mwworld/class.hpp"
#include "actorutil.hpp"
#include "aiactivate.hpp"
Expand All @@ -17,6 +19,7 @@
#include "aipursue.hpp"
#include "aitravel.hpp"
#include "aiwander.hpp"
#include "creaturestats.hpp"

namespace MWMechanics
{
Expand Down Expand Up @@ -365,7 +368,20 @@ namespace MWMechanics

// Stop combat when a non-combat AI package is added
if (isActualAiPackage(package.getTypeId()))
{
if (package.getTypeId() == MWMechanics::AiPackageTypeId::Follow
|| package.getTypeId() == MWMechanics::AiPackageTypeId::Escort)
{
const auto& mechanicsManager = MWBase::Environment::get().getMechanicsManager();
std::vector<MWWorld::Ptr> newAllies = mechanicsManager->getActorsSidingWith(package.getTarget());
std::vector<MWWorld::Ptr> allies = mechanicsManager->getActorsSidingWith(actor);
for (const auto& ally : allies)
ally.getClass().getCreatureStats(ally).getAiSequence().stopCombat(newAllies);
for (const auto& ally : newAllies)
ally.getClass().getCreatureStats(ally).getAiSequence().stopCombat(allies);
}
stopCombat();
}

// We should return a wandering actor back after combat, casting or pursuit.
// The same thing for actors without AI packages.
Expand Down

0 comments on commit 51cb3b0

Please sign in to comment.