Merge branch 'followmeifyouwanttohit' into 'master'
Release / Read .env file and expose it as output (push) Successful in 1m9s
Build and test / Read .env file and expose it as output (push) Successful in 1m9s
Build and test / Ubuntu (push) Failing after 29m22s
Build and test / MacOS (push) Canceled after 0s
Release / Windows (push) Canceled after 0s
Build and test / Windows (2019) (push) Canceled after 0s
Build and test / Windows (2022) (push) Canceled after 0s
Reusable Windows workflow / windows-${{ inputs.image }} (push) Canceled after 0s
Reusable Windows workflow / windows-${{ inputs.image }} (push) Canceled after 0s

Don't use attack strength as "hit ready" flag

See merge request OpenMW/openmw!4583
This commit is contained in:
Evil Eye
2025-03-15 12:02:35 +00:00
2 changed files with 10 additions and 7 deletions
+9 -7
View File
@@ -1104,10 +1104,10 @@ namespace MWMechanics
attackType = ESM::Weapon::AT_Thrust;
// We want to avoid hit keys that come out of nowhere (e.g. in the follow animation)
// and processing multiple hit keys for a single attack
if (mAttackStrength != -1.f)
if (mReadyToHit)
{
charClass.hit(mPtr, mAttackStrength, attackType, mAttackVictim, mAttackHitPos, mAttackSuccess);
mAttackStrength = -1.f;
mReadyToHit = false;
}
}
else if (isRandomAttackAnimation(groupname) && action == "start")
@@ -1153,10 +1153,10 @@ namespace MWMechanics
else if (action == "shoot release")
{
// See notes for melee release above
if (mAttackStrength != -1.f)
if (mReadyToHit)
{
mAnimation->releaseArrow(mAttackStrength);
mAttackStrength = -1.f;
mReadyToHit = false;
}
}
else if (action == "shoot follow attach")
@@ -1246,7 +1246,7 @@ namespace MWMechanics
void CharacterController::prepareHit()
{
if (mAttackStrength != -1.f)
if (mReadyToHit)
return;
auto& prng = MWBase::Environment::get().getWorld()->getPrng();
@@ -1261,6 +1261,8 @@ namespace MWMechanics
mAttackStrength = 0.f;
playSwishSound();
}
mReadyToHit = true;
}
bool CharacterController::updateWeaponState()
@@ -1520,6 +1522,7 @@ namespace MWMechanics
&& (mHitState == CharState_None || mHitState == CharState_Block))
{
mAttackStrength = -1.f;
mReadyToHit = false;
// Randomize attacks for non-bipedal creatures
if (!cls.isBipedal(mPtr)
@@ -1806,8 +1809,7 @@ namespace MWMechanics
stop = strength + ' ' + stop;
}
// Reset attack strength to make extra sure hits that come out of nowhere aren't processed
mAttackStrength = -1.f;
mReadyToHit = false;
if (animPlaying)
mAnimation->disable(mCurrentWeapon);
+1
View File
@@ -172,6 +172,7 @@ namespace MWMechanics
std::string mCurrentWeapon;
float mAttackStrength{ -1.f };
bool mReadyToHit{ false };
MWWorld::Ptr mAttackVictim;
osg::Vec3f mAttackHitPos;
bool mAttackSuccess{ false };