mirror of
https://github.com/OpenMW/openmw.git
synced 2025-02-23 20:39:57 +00:00
Feature #50: Don't allow ranged weapon attack when ammunition is empty
This commit is contained in:
parent
a07eaa0c0d
commit
8b8fb931a0
1 changed files with 14 additions and 1 deletions
|
@ -602,6 +602,19 @@ bool CharacterController::updateWeaponState()
|
||||||
if(isWeapon)
|
if(isWeapon)
|
||||||
weapSpeed = weapon->get<ESM::Weapon>()->mBase->mData.mSpeed;
|
weapSpeed = weapon->get<ESM::Weapon>()->mBase->mData.mSpeed;
|
||||||
|
|
||||||
|
// Cancel attack if we no longer have ammunition
|
||||||
|
bool ammunition = true;
|
||||||
|
MWWorld::ContainerStoreIterator ammo = inv.getSlot(MWWorld::InventoryStore::Slot_Ammunition);
|
||||||
|
if (mWeaponType == WeapType_Crossbow)
|
||||||
|
ammunition = (ammo != inv.end() && ammo->get<ESM::Weapon>()->mBase->mData.mType == ESM::Weapon::Bolt);
|
||||||
|
else if (mWeaponType == WeapType_BowAndArrow)
|
||||||
|
ammunition = (ammo != inv.end() && ammo->get<ESM::Weapon>()->mBase->mData.mType == ESM::Weapon::Arrow);
|
||||||
|
if (!ammunition && mUpperBodyState > UpperCharState_WeapEquiped)
|
||||||
|
{
|
||||||
|
mAnimation->disable(mCurrentWeapon);
|
||||||
|
mUpperBodyState = UpperCharState_WeapEquiped;
|
||||||
|
}
|
||||||
|
|
||||||
float complete;
|
float complete;
|
||||||
bool animPlaying;
|
bool animPlaying;
|
||||||
if(stats.getAttackingOrSpell())
|
if(stats.getAttackingOrSpell())
|
||||||
|
@ -706,7 +719,7 @@ bool CharacterController::updateWeaponState()
|
||||||
if(item.getRefData().getCount())
|
if(item.getRefData().getCount())
|
||||||
MWBase::Environment::get().getWindowManager()->setSelectedWeapon(item);
|
MWBase::Environment::get().getWindowManager()->setSelectedWeapon(item);
|
||||||
}
|
}
|
||||||
else
|
else if (ammunition)
|
||||||
{
|
{
|
||||||
if(mWeaponType == WeapType_Crossbow || mWeaponType == WeapType_BowAndArrow ||
|
if(mWeaponType == WeapType_Crossbow || mWeaponType == WeapType_BowAndArrow ||
|
||||||
mWeaponType == WeapType_Thrown)
|
mWeaponType == WeapType_Thrown)
|
||||||
|
|
Loading…
Reference in a new issue