Reset friendly hits at the end of combat and don't count hits while in combat

pull/3234/head
Evil Eye 11 months ago
parent 62f2f4a011
commit 6c2ddc635d

@ -25,6 +25,7 @@
Bug #5280: Unskinned shapes in skinned equipment are rendered in the wrong place
Bug #5371: Keyframe animation tracks are used for any file that begins with an X
Bug #5714: Touch spells cast using ExplodeSpell don't always explode
Bug #5755: Reset friendly hit counter
Bug #5849: Paralysis breaks landing
Bug #5870: Disposing of actors who were selected in the console doesn't deselect them like vanilla
Bug #5883: Immobile creatures don't cause water ripples

@ -82,7 +82,11 @@ namespace MWMechanics
void AiSequence::onPackageRemoved(const AiPackage& package)
{
if (package.getTypeId() == AiPackageTypeId::Combat)
{
mNumCombatPackages--;
if (mNumCombatPackages == 0)
mResetFriendlyHits = true;
}
else if (package.getTypeId() == AiPackageTypeId::Pursue)
mNumPursuitPackages--;
@ -246,6 +250,12 @@ namespace MWMechanics
return;
}
if (mResetFriendlyHits)
{
actor.getClass().getCreatureStats(actor).resetFriendlyHits();
mResetFriendlyHits = false;
}
if (mPackages.empty())
{
mLastAiPackage = AiPackageTypeId::None;

@ -39,6 +39,7 @@ namespace MWMechanics
/// Finished with top AIPackage, set for one frame
bool mDone{};
bool mResetFriendlyHits{};
int mNumCombatPackages{};
int mNumPursuitPackages{};

@ -674,6 +674,8 @@ namespace MWMechanics
return false;
MWMechanics::CreatureStats& statsTarget = target.getClass().getCreatureStats(target);
if (statsTarget.getAiSequence().isInCombat())
return true;
statsTarget.friendlyHit();
if (statsTarget.getFriendlyHits() >= 4)
return false;

@ -319,6 +319,11 @@ namespace MWMechanics
++mFriendlyHits;
}
void CreatureStats::resetFriendlyHits()
{
mFriendlyHits = 0;
}
bool CreatureStats::hasTalkedToPlayer() const
{
return mTalkedTo;

@ -200,6 +200,8 @@ namespace MWMechanics
void friendlyHit();
///< Increase number of friendly hits by one.
void resetFriendlyHits();
bool hasTalkedToPlayer() const;
///< Has this creature talked with the player before?
@ -294,7 +296,7 @@ namespace MWMechanics
bool wasTeleported() const { return mTeleported; }
void setTeleported(bool v) { mTeleported = v; }
const std::map<ESM::RefId, AttributeValue> getAttributes() const { return mAttributes; }
const std::map<ESM::RefId, AttributeValue>& getAttributes() const { return mAttributes; }
};
}

@ -1701,6 +1701,8 @@ namespace MWMechanics
// We don't care about dialogue filters since the target is invalid.
// We still want to play the combat taunt.
MWBase::Environment::get().getDialogueManager()->say(ptr, ESM::RefId::stringRefId("attack"));
if (!stats.getAiSequence().isInCombat())
stats.resetFriendlyHits();
return;
}

Loading…
Cancel
Save