1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-06-22 18:41:33 +00:00

Don't cancel the attack prematurely after running out of ammo

This commit is contained in:
Alexei Kotov 2022-08-08 20:21:11 +03:00
parent d280a29b18
commit a4b5bfc051

View file

@ -1314,7 +1314,6 @@ bool CharacterController::updateWeaponState()
sndMgr->stopSound3D(mPtr, "WolfRun"); sndMgr->stopSound3D(mPtr, "WolfRun");
} }
// Cancel attack if we no longer have ammunition
bool ammunition = true; bool ammunition = true;
float weapSpeed = 1.f; float weapSpeed = 1.f;
if (cls.hasInventoryStore(mPtr)) if (cls.hasInventoryStore(mPtr))
@ -1329,11 +1328,15 @@ bool CharacterController::updateWeaponState()
ammunition = ammo != inv.end() && ammo->get<ESM::Weapon>()->mBase->mData.mType == ammotype; ammunition = ammo != inv.end() && ammo->get<ESM::Weapon>()->mBase->mData.mType == ammotype;
} }
if (!ammunition && mUpperBodyState > UpperBodyState::WeaponEquipped) // Cancel attack if we no longer have ammunition
if (!ammunition)
{ {
if (!mCurrentWeapon.empty()) if (mUpperBodyState == UpperBodyState::AttackPreWindUp || mUpperBodyState == UpperBodyState::AttackWindUp)
{
mAnimation->disable(mCurrentWeapon); mAnimation->disable(mCurrentWeapon);
mUpperBodyState = UpperBodyState::WeaponEquipped; mUpperBodyState = UpperBodyState::WeaponEquipped;
}
setAttackingOrSpell(false);
} }
MWWorld::ConstContainerStoreIterator torch = inv.getSlot(MWWorld::InventoryStore::Slot_CarriedLeft); MWWorld::ConstContainerStoreIterator torch = inv.getSlot(MWWorld::InventoryStore::Slot_CarriedLeft);
@ -1360,7 +1363,7 @@ bool CharacterController::updateWeaponState()
ESM::WeaponType::Class weapclass = getWeaponType(mWeaponType)->mWeaponClass; ESM::WeaponType::Class weapclass = getWeaponType(mWeaponType)->mWeaponClass;
if(getAttackingOrSpell()) if(getAttackingOrSpell())
{ {
bool resetIdle = ammunition; bool resetIdle = true;
if (mUpperBodyState == UpperBodyState::WeaponEquipped && (mHitState == CharState_None || mHitState == CharState_Block)) if (mUpperBodyState == UpperBodyState::WeaponEquipped && (mHitState == CharState_None || mHitState == CharState_Block))
{ {
mAttackStrength = 0; mAttackStrength = 0;
@ -1522,7 +1525,7 @@ bool CharacterController::updateWeaponState()
if(!resultSound.empty()) if(!resultSound.empty())
sndMgr->playSound3D(target, resultSound, 1.0f, 1.0f); sndMgr->playSound3D(target, resultSound, 1.0f, 1.0f);
} }
else if (ammunition) else
{ {
std::string startKey; std::string startKey;
std::string stopKey; std::string stopKey;