Allow talking with fleeing creatures (bug #7631)

macos_ci_fix
Alexei Kotov 1 year ago
parent a08ca11c34
commit ee5ca066fd

@ -78,6 +78,7 @@
Bug #7604: Goblins Grunt becomes idle once injured
Bug #7609: ForceGreeting should not open dialogue for werewolves
Bug #7630: Charm can be cast on creatures
Bug #7631: Cannot trade with/talk to Creeper or Mudcrab Merchant when they're fleeing
Feature #3537: Shader-based water ripples
Feature #5492: Let rain and snow collide with statics
Feature #6149: Dehardcode Lua API_REVISION

@ -464,18 +464,20 @@ namespace MWClass
}
const MWMechanics::CreatureStats& stats = getCreatureStats(ptr);
const MWMechanics::AiSequence& aiSequence = stats.getAiSequence();
const bool isInCombat = aiSequence.isInCombat();
if (stats.isDead())
{
// by default user can loot friendly actors during death animation
if (Settings::game().mCanLootDuringDeathAnimation && !stats.getAiSequence().isInCombat())
if (Settings::game().mCanLootDuringDeathAnimation && !isInCombat)
return std::make_unique<MWWorld::ActionOpen>(ptr);
// otherwise wait until death animation
if (stats.isDeathAnimationFinished())
return std::make_unique<MWWorld::ActionOpen>(ptr);
}
else if (!stats.getAiSequence().isInCombat() && !stats.getKnockedDown())
else if ((!isInCombat || aiSequence.isFleeing()) && !stats.getKnockedDown())
return std::make_unique<MWWorld::ActionTalk>(ptr);
// Tribunal and some mod companions oddly enough must use open action as fallback
@ -570,7 +572,8 @@ namespace MWClass
if (customData.mCreatureStats.isDead() && customData.mCreatureStats.isDeathAnimationFinished())
return true;
return !customData.mCreatureStats.getAiSequence().isInCombat();
const MWMechanics::AiSequence& aiSeq = customData.mCreatureStats.getAiSequence();
return !aiSeq.isInCombat() || aiSeq.isFleeing();
}
MWGui::ToolTipInfo Creature::getToolTipInfo(const MWWorld::ConstPtr& ptr, int count) const

@ -708,7 +708,7 @@ namespace MWMechanics
mFleeDest = ESM::Pathgrid::Point(0, 0, 0);
}
bool AiCombatStorage::isFleeing()
bool AiCombatStorage::isFleeing() const
{
return mFleeState != FleeState_None;
}

@ -70,7 +70,7 @@ namespace MWMechanics
void startFleeing();
void stopFleeing();
bool isFleeing();
bool isFleeing() const;
};
/// \brief Causes the actor to fight another actor

@ -135,6 +135,15 @@ namespace MWMechanics
return mNumPursuitPackages > 0;
}
bool AiSequence::isFleeing() const
{
if (!isInCombat())
return false;
const AiCombatStorage* storage = mAiState.getPtr<AiCombatStorage>();
return storage && storage->isFleeing();
}
bool AiSequence::isEngagedWithActor() const
{
if (!isInCombat())

@ -117,6 +117,9 @@ namespace MWMechanics
/// Is there any pursuit package.
bool isInPursuit() const;
/// Is the actor fleeing?
bool isFleeing() const;
/// Removes all packages using the specified id.
void removePackagesById(AiPackageTypeId id);

@ -38,6 +38,13 @@ namespace MWMechanics
return *result;
}
/// \brief returns pointer to stored object in the desired type
template <class Derived>
Derived* getPtr() const
{
return dynamic_cast<Derived*>(mStorage.get());
}
template <class Derived>
void copy(DerivedClassStorage& destination) const
{

Loading…
Cancel
Save