mirror of
https://github.com/OpenMW/openmw.git
synced 2025-02-22 09:39:42 +00:00
Merge inventory blocks in updateWeaponState
This commit is contained in:
parent
db8238e4fc
commit
ea78e904a9
1 changed files with 36 additions and 40 deletions
|
@ -1132,6 +1132,8 @@ bool CharacterController::updateWeaponState()
|
|||
std::string upSoundId;
|
||||
std::string downSoundId;
|
||||
bool weaponChanged = false;
|
||||
bool ammunition = true;
|
||||
float weapSpeed = 1.f;
|
||||
if (cls.hasInventoryStore(mPtr))
|
||||
{
|
||||
MWWorld::InventoryStore &inv = cls.getInventoryStore(mPtr);
|
||||
|
@ -1156,6 +1158,40 @@ bool CharacterController::updateWeaponState()
|
|||
mWeapon = newWeapon;
|
||||
weaponChanged = true;
|
||||
}
|
||||
|
||||
if (stats.getDrawState() == DrawState::Weapon && !mWeapon.isEmpty() && mWeapon.getType() == ESM::Weapon::sRecordId)
|
||||
{
|
||||
weapSpeed = mWeapon.get<ESM::Weapon>()->mBase->mData.mSpeed;
|
||||
MWWorld::ConstContainerStoreIterator ammo = inv.getSlot(MWWorld::InventoryStore::Slot_Ammunition);
|
||||
int ammotype = getWeaponType(mWeapon.get<ESM::Weapon>()->mBase->mData.mType)->mAmmoType;
|
||||
if (ammotype != ESM::Weapon::None)
|
||||
ammunition = ammo != inv.end() && ammo->get<ESM::Weapon>()->mBase->mData.mType == ammotype;
|
||||
}
|
||||
|
||||
// Cancel attack if we no longer have ammunition
|
||||
if (!ammunition)
|
||||
{
|
||||
if (mUpperBodyState == UpperBodyState::AttackPreWindUp || mUpperBodyState == UpperBodyState::AttackWindUp)
|
||||
{
|
||||
mAnimation->disable(mCurrentWeapon);
|
||||
mUpperBodyState = UpperBodyState::WeaponEquipped;
|
||||
}
|
||||
setAttackingOrSpell(false);
|
||||
}
|
||||
|
||||
MWWorld::ConstContainerStoreIterator torch = inv.getSlot(MWWorld::InventoryStore::Slot_CarriedLeft);
|
||||
if (torch != inv.end() && torch->getType() == ESM::Light::sRecordId && updateCarriedLeftVisible(mWeaponType))
|
||||
{
|
||||
if (mAnimation->isPlaying("shield"))
|
||||
mAnimation->disable("shield");
|
||||
|
||||
mAnimation->play("torch", Priority_Torch, MWRender::Animation::BlendMask_LeftArm,
|
||||
false, 1.0f, "start", "stop", 0.0f, std::numeric_limits<size_t>::max(), true);
|
||||
}
|
||||
else if (mAnimation->isPlaying("torch"))
|
||||
{
|
||||
mAnimation->disable("torch");
|
||||
}
|
||||
}
|
||||
|
||||
// For biped actors, blend weapon animations with lower body animations with higher priority
|
||||
|
@ -1314,46 +1350,6 @@ bool CharacterController::updateWeaponState()
|
|||
sndMgr->stopSound3D(mPtr, "WolfRun");
|
||||
}
|
||||
|
||||
bool ammunition = true;
|
||||
float weapSpeed = 1.f;
|
||||
if (cls.hasInventoryStore(mPtr))
|
||||
{
|
||||
MWWorld::InventoryStore &inv = cls.getInventoryStore(mPtr);
|
||||
if (stats.getDrawState() == DrawState::Weapon && !mWeapon.isEmpty() && mWeapon.getType() == ESM::Weapon::sRecordId)
|
||||
{
|
||||
weapSpeed = mWeapon.get<ESM::Weapon>()->mBase->mData.mSpeed;
|
||||
MWWorld::ConstContainerStoreIterator ammo = inv.getSlot(MWWorld::InventoryStore::Slot_Ammunition);
|
||||
int ammotype = getWeaponType(mWeapon.get<ESM::Weapon>()->mBase->mData.mType)->mAmmoType;
|
||||
if (ammotype != ESM::Weapon::None)
|
||||
ammunition = ammo != inv.end() && ammo->get<ESM::Weapon>()->mBase->mData.mType == ammotype;
|
||||
}
|
||||
|
||||
// Cancel attack if we no longer have ammunition
|
||||
if (!ammunition)
|
||||
{
|
||||
if (mUpperBodyState == UpperBodyState::AttackPreWindUp || mUpperBodyState == UpperBodyState::AttackWindUp)
|
||||
{
|
||||
mAnimation->disable(mCurrentWeapon);
|
||||
mUpperBodyState = UpperBodyState::WeaponEquipped;
|
||||
}
|
||||
setAttackingOrSpell(false);
|
||||
}
|
||||
|
||||
MWWorld::ConstContainerStoreIterator torch = inv.getSlot(MWWorld::InventoryStore::Slot_CarriedLeft);
|
||||
if (torch != inv.end() && torch->getType() == ESM::Light::sRecordId && updateCarriedLeftVisible(mWeaponType))
|
||||
{
|
||||
if (mAnimation->isPlaying("shield"))
|
||||
mAnimation->disable("shield");
|
||||
|
||||
mAnimation->play("torch", Priority_Torch, MWRender::Animation::BlendMask_LeftArm,
|
||||
false, 1.0f, "start", "stop", 0.0f, std::numeric_limits<size_t>::max(), true);
|
||||
}
|
||||
else if (mAnimation->isPlaying("torch"))
|
||||
{
|
||||
mAnimation->disable("torch");
|
||||
}
|
||||
}
|
||||
|
||||
// Combat for actors with persistent animations obviously will be buggy
|
||||
if (isPersistentAnimPlaying())
|
||||
return forcestateupdate;
|
||||
|
|
Loading…
Reference in a new issue