Skip to content

Commit 2b5d076

Browse files
committed
Merge branch 'followmeifyouwanttohit' into 'master'
Don't use attack strength as "hit ready" flag See merge request OpenMW/openmw!4583
2 parents 2ca1850 + 5354a5f commit 2b5d076

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

apps/openmw/mwmechanics/character.cpp

+9-7
Original file line numberDiff line numberDiff line change
@@ -1104,10 +1104,10 @@ namespace MWMechanics
11041104
attackType = ESM::Weapon::AT_Thrust;
11051105
// We want to avoid hit keys that come out of nowhere (e.g. in the follow animation)
11061106
// and processing multiple hit keys for a single attack
1107-
if (mAttackStrength != -1.f)
1107+
if (mReadyToHit)
11081108
{
11091109
charClass.hit(mPtr, mAttackStrength, attackType, mAttackVictim, mAttackHitPos, mAttackSuccess);
1110-
mAttackStrength = -1.f;
1110+
mReadyToHit = false;
11111111
}
11121112
}
11131113
else if (isRandomAttackAnimation(groupname) && action == "start")
@@ -1153,10 +1153,10 @@ namespace MWMechanics
11531153
else if (action == "shoot release")
11541154
{
11551155
// See notes for melee release above
1156-
if (mAttackStrength != -1.f)
1156+
if (mReadyToHit)
11571157
{
11581158
mAnimation->releaseArrow(mAttackStrength);
1159-
mAttackStrength = -1.f;
1159+
mReadyToHit = false;
11601160
}
11611161
}
11621162
else if (action == "shoot follow attach")
@@ -1246,7 +1246,7 @@ namespace MWMechanics
12461246

12471247
void CharacterController::prepareHit()
12481248
{
1249-
if (mAttackStrength != -1.f)
1249+
if (mReadyToHit)
12501250
return;
12511251

12521252
auto& prng = MWBase::Environment::get().getWorld()->getPrng();
@@ -1261,6 +1261,8 @@ namespace MWMechanics
12611261
mAttackStrength = 0.f;
12621262
playSwishSound();
12631263
}
1264+
1265+
mReadyToHit = true;
12641266
}
12651267

12661268
bool CharacterController::updateWeaponState()
@@ -1520,6 +1522,7 @@ namespace MWMechanics
15201522
&& (mHitState == CharState_None || mHitState == CharState_Block))
15211523
{
15221524
mAttackStrength = -1.f;
1525+
mReadyToHit = false;
15231526

15241527
// Randomize attacks for non-bipedal creatures
15251528
if (!cls.isBipedal(mPtr)
@@ -1806,8 +1809,7 @@ namespace MWMechanics
18061809
stop = strength + ' ' + stop;
18071810
}
18081811

1809-
// Reset attack strength to make extra sure hits that come out of nowhere aren't processed
1810-
mAttackStrength = -1.f;
1812+
mReadyToHit = false;
18111813

18121814
if (animPlaying)
18131815
mAnimation->disable(mCurrentWeapon);

apps/openmw/mwmechanics/character.hpp

+1
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ namespace MWMechanics
172172
std::string mCurrentWeapon;
173173

174174
float mAttackStrength{ -1.f };
175+
bool mReadyToHit{ false };
175176
MWWorld::Ptr mAttackVictim;
176177
osg::Vec3f mAttackHitPos;
177178
bool mAttackSuccess{ false };

0 commit comments

Comments
 (0)