Merged pull request #1619

pull/456/head
Marc Zinnschlag 7 years ago
commit 7899f44173

@ -1,7 +1,9 @@
0.45.0 0.45.0
------ ------
Bug #2835: Player able to slowly move when overencumbered
Bug #4221: Characters get stuck in V-shaped terrain Bug #4221: Characters get stuck in V-shaped terrain
Bug #4293: Faction members are not aware of faction ownerships in barter Bug #4293: Faction members are not aware of faction ownerships in barter
Bug #4327: Missing animations during spell/weapon stance switching
Bug #4426: RotateWorld behavior is incorrect Bug #4426: RotateWorld behavior is incorrect
Bug #4433: Guard behaviour is incorrect with Alarm = 0 Bug #4433: Guard behaviour is incorrect with Alarm = 0
Feature #4444: Per-group KF-animation files support Feature #4444: Per-group KF-animation files support

@ -749,6 +749,7 @@ void CharacterController::playRandomDeath(float startpoint)
CharacterController::CharacterController(const MWWorld::Ptr &ptr, MWRender::Animation *anim) CharacterController::CharacterController(const MWWorld::Ptr &ptr, MWRender::Animation *anim)
: mPtr(ptr) : mPtr(ptr)
, mWeapon(MWWorld::Ptr())
, mAnimation(anim) , mAnimation(anim)
, mIdleState(CharState_None) , mIdleState(CharState_None)
, mMovementState(CharState_None) , mMovementState(CharState_None)
@ -1156,17 +1157,26 @@ bool CharacterController::updateWeaponState()
const bool isWerewolf = cls.isNpc() && cls.getNpcStats(mPtr).isWerewolf(); const bool isWerewolf = cls.isNpc() && cls.getNpcStats(mPtr).isWerewolf();
std::string soundid; std::string upSoundId;
std::string downSoundId;
if (mPtr.getClass().hasInventoryStore(mPtr)) if (mPtr.getClass().hasInventoryStore(mPtr))
{ {
MWWorld::InventoryStore &inv = cls.getInventoryStore(mPtr); MWWorld::InventoryStore &inv = cls.getInventoryStore(mPtr);
MWWorld::ConstContainerStoreIterator weapon = getActiveWeapon(stats, inv, &weaptype); MWWorld::ContainerStoreIterator weapon = getActiveWeapon(stats, inv, &weaptype);
if(weapon != inv.end() && !(weaptype == WeapType_None && mWeaponType == WeapType_Spell)) if(stats.getDrawState() == DrawState_Spell)
{ weapon = inv.getSlot(MWWorld::InventoryStore::Slot_CarriedRight);
soundid = (weaptype == WeapType_None) ?
weapon->getClass().getDownSoundId(*weapon) : if(weapon != inv.end() && mWeaponType != WeapType_HandToHand && weaptype > WeapType_HandToHand && weaptype < WeapType_Spell)
weapon->getClass().getUpSoundId(*weapon); upSoundId = weapon->getClass().getUpSoundId(*weapon);
}
if(weapon != inv.end() && mWeaponType > WeapType_HandToHand && mWeaponType < WeapType_Spell)
downSoundId = weapon->getClass().getDownSoundId(*weapon);
// weapon->HtH switch: weapon is empty already, so we need to take sound from previous weapon
if(weapon == inv.end() && !mWeapon.isEmpty() && weaptype == WeapType_HandToHand && mWeaponType != WeapType_Spell)
downSoundId = mWeapon.getClass().getDownSoundId(mWeapon);
mWeapon = weapon != inv.end() ? *weapon : MWWorld::Ptr();
} }
MWRender::Animation::AnimPriority priorityWeapon(Priority_Weapon); MWRender::Animation::AnimPriority priorityWeapon(Priority_Weapon);
@ -1181,34 +1191,51 @@ bool CharacterController::updateWeaponState()
if(weaptype != mWeaponType && !isKnockedOut() && if(weaptype != mWeaponType && !isKnockedOut() &&
!isKnockedDown() && !isRecovery()) !isKnockedDown() && !isRecovery())
{ {
forcestateupdate = true;
mAnimation->showCarriedLeft(updateCarriedLeftVisible(weaptype));
std::string weapgroup; std::string weapgroup;
if(weaptype == WeapType_None) if ((!isWerewolf || mWeaponType != WeapType_Spell)
&& mUpperBodyState != UpperCharState_UnEquipingWeap
&& !isStillWeapon)
{ {
if (!isWerewolf || mWeaponType != WeapType_Spell) // Note: we do not disable unequipping animation automatically to avoid body desync
getWeaponGroup(mWeaponType, weapgroup);
mAnimation->play(weapgroup, priorityWeapon,
MWRender::Animation::BlendMask_All, false,
1.0f, "unequip start", "unequip stop", 0.0f, 0);
mUpperBodyState = UpperCharState_UnEquipingWeap;
if(!downSoundId.empty())
{ {
getWeaponGroup(mWeaponType, weapgroup); MWBase::SoundManager *sndMgr = MWBase::Environment::get().getSoundManager();
mAnimation->play(weapgroup, priorityWeapon, sndMgr->playSound3D(mPtr, downSoundId, 1.0f, 1.0f);
MWRender::Animation::BlendMask_All, true,
1.0f, "unequip start", "unequip stop", 0.0f, 0);
mUpperBodyState = UpperCharState_UnEquipingWeap;
} }
} }
else
float complete;
bool animPlaying = mAnimation->getInfo(mCurrentWeapon, &complete);
if (!animPlaying || complete >= 1.0f)
{ {
mUpperBodyState = UpperCharState_Nothing;
forcestateupdate = true;
mAnimation->showCarriedLeft(updateCarriedLeftVisible(weaptype));
getWeaponGroup(weaptype, weapgroup); getWeaponGroup(weaptype, weapgroup);
mAnimation->setWeaponGroup(weapgroup); mAnimation->setWeaponGroup(weapgroup);
if (!isStillWeapon) if (!isStillWeapon)
{ {
mAnimation->showWeapons(false); if (weaptype == WeapType_None)
mAnimation->play(weapgroup, priorityWeapon, {
MWRender::Animation::BlendMask_All, true, // Disable current weapon animation manually
1.0f, "equip start", "equip stop", 0.0f, 0); mAnimation->disable(mCurrentWeapon);
mUpperBodyState = UpperCharState_EquipingWeap; }
else
{
mAnimation->showWeapons(false);
mAnimation->play(weapgroup, priorityWeapon,
MWRender::Animation::BlendMask_All, true,
1.0f, "equip start", "equip stop", 0.0f, 0);
mUpperBodyState = UpperCharState_EquipingWeap;
}
} }
if(isWerewolf) if(isWerewolf)
@ -1221,16 +1248,16 @@ bool CharacterController::updateWeaponState()
sndMgr->playSound3D(mPtr, sound->mId, 1.0f, 1.0f); sndMgr->playSound3D(mPtr, sound->mId, 1.0f, 1.0f);
} }
} }
}
if(!soundid.empty() && !isStillWeapon) mWeaponType = weaptype;
{ getWeaponGroup(mWeaponType, mCurrentWeapon);
MWBase::SoundManager *sndMgr = MWBase::Environment::get().getSoundManager();
sndMgr->playSound3D(mPtr, soundid, 1.0f, 1.0f);
}
mWeaponType = weaptype; if(!upSoundId.empty() && !isStillWeapon)
getWeaponGroup(mWeaponType, mCurrentWeapon); {
MWBase::SoundManager *sndMgr = MWBase::Environment::get().getSoundManager();
sndMgr->playSound3D(mPtr, upSoundId, 1.0f, 1.0f);
}
}
} }
if(isWerewolf) if(isWerewolf)

@ -152,6 +152,7 @@ struct WeaponInfo;
class CharacterController : public MWRender::Animation::TextKeyListener class CharacterController : public MWRender::Animation::TextKeyListener
{ {
MWWorld::Ptr mPtr; MWWorld::Ptr mPtr;
MWWorld::Ptr mWeapon;
MWRender::Animation *mAnimation; MWRender::Animation *mAnimation;
struct AnimationQueueEntry struct AnimationQueueEntry

Loading…
Cancel
Save