Skip to content

Commit

Permalink
Add unequip animation during stance switching (bug #4327)
Browse files Browse the repository at this point in the history
  • Loading branch information
akortunov committed Mar 2, 2018
1 parent b1b8e31 commit 5cd934a
Showing 1 changed file with 38 additions and 27 deletions.
65 changes: 38 additions & 27 deletions apps/openmw/mwmechanics/character.cpp
Expand Up @@ -1157,16 +1157,20 @@ bool CharacterController::updateWeaponState()

const bool isWerewolf = cls.isNpc() && cls.getNpcStats(mPtr).isWerewolf();

std::string soundid;
std::string upSoundId;
std::string downSoundId;
if (mPtr.getClass().hasInventoryStore(mPtr))
{
MWWorld::InventoryStore &inv = cls.getInventoryStore(mPtr);
MWWorld::ConstContainerStoreIterator weapon = getActiveWeapon(stats, inv, &weaptype);
if(weapon != inv.end() && !(weaptype == WeapType_None && mWeaponType == WeapType_Spell))
if(weapon != inv.end() && weaptype > WeapType_HandToHand && weaptype < WeapType_Spell)
{
soundid = (weaptype == WeapType_None) ?
weapon->getClass().getDownSoundId(*weapon) :
weapon->getClass().getUpSoundId(*weapon);
upSoundId = weapon->getClass().getUpSoundId(*weapon);
}

if(weapon != inv.end() && mWeaponType > WeapType_HandToHand && mWeaponType < WeapType_Spell)
{
downSoundId = weapon->getClass().getDownSoundId(*weapon);
}
}

Expand All @@ -1182,33 +1186,40 @@ bool CharacterController::updateWeaponState()
if(weaptype != mWeaponType && !isKnockedOut() &&
!isKnockedDown() && !isRecovery())
{
forcestateupdate = true;

mAnimation->showCarriedLeft(updateCarriedLeftVisible(weaptype));

std::string weapgroup;
if(weaptype == WeapType_None)
if ((!isWerewolf || mWeaponType != WeapType_Spell)
&& mUpperBodyState != UpperCharState_UnEquipingWeap
&& !isStillWeapon)
{
if ((!isWerewolf || mWeaponType != WeapType_Spell))
getWeaponGroup(mWeaponType, weapgroup);
mAnimation->play(weapgroup, priorityWeapon,
MWRender::Animation::BlendMask_All, true,
1.0f, "unequip start", "unequip stop", 0.0f, 0);
mUpperBodyState = UpperCharState_UnEquipingWeap;

if(!downSoundId.empty() && !isStillWeapon)
{
getWeaponGroup(mWeaponType, weapgroup);
mAnimation->play(weapgroup, priorityWeapon,
MWRender::Animation::BlendMask_All, true,
1.0f, "unequip start", "unequip stop", 0.0f, 0);
mUpperBodyState = UpperCharState_UnEquipingWeap;
MWBase::SoundManager *sndMgr = MWBase::Environment::get().getSoundManager();
sndMgr->playSound3D(mPtr, downSoundId, 1.0f, 1.0f);
}
}
else

float complete;
bool animPlaying = mAnimation->getInfo(mCurrentWeapon, &complete);
if (!animPlaying || complete > 0.95f)
{
forcestateupdate = true;
mAnimation->showCarriedLeft(updateCarriedLeftVisible(weaptype));

getWeaponGroup(weaptype, weapgroup);
mAnimation->setWeaponGroup(weapgroup);

if (!isStillWeapon)
{
mAnimation->showWeapons(false);
mAnimation->play(weapgroup, priorityWeapon,
MWRender::Animation::BlendMask_All, true,
1.0f, "equip start", "equip stop", 0.0f, 0);
MWRender::Animation::BlendMask_All, true,
1.0f, "equip start", "equip stop", 0.0f, 0);
mUpperBodyState = UpperCharState_EquipingWeap;
}

Expand All @@ -1222,16 +1233,16 @@ bool CharacterController::updateWeaponState()
sndMgr->playSound3D(mPtr, sound->mId, 1.0f, 1.0f);
}
}
}

if(!soundid.empty() && !isStillWeapon)
{
MWBase::SoundManager *sndMgr = MWBase::Environment::get().getSoundManager();
sndMgr->playSound3D(mPtr, soundid, 1.0f, 1.0f);
}
mWeaponType = weaptype;
getWeaponGroup(mWeaponType, mCurrentWeapon);

mWeaponType = weaptype;
getWeaponGroup(mWeaponType, mCurrentWeapon);
if(!upSoundId.empty() && !isStillWeapon)
{
MWBase::SoundManager *sndMgr = MWBase::Environment::get().getSoundManager();
sndMgr->playSound3D(mPtr, upSoundId, 1.0f, 1.0f);
}
}
}

if(isWerewolf)
Expand Down

0 comments on commit 5cd934a

Please sign in to comment.