1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-27 03:35:27 +00:00

Bug #1005: Hide torches/shields during spellcasting and hand-to-hand combat

This commit is contained in:
scrawl 2013-12-27 22:00:16 +01:00
parent 7265b427fe
commit 85ec80100c
4 changed files with 18 additions and 25 deletions

View File

@ -425,10 +425,10 @@ bool CharacterController::updateNpcState(bool onground, bool inwater, bool isrun
{ {
forcestateupdate = true; forcestateupdate = true;
// Shields shouldn't be visible during spellcasting // Shields/torches shouldn't be visible during spellcasting or hand-to-hand
// There seems to be no text keys for this purpose, except maybe for "[un]equip start/stop", // There seems to be no text keys for this purpose, except maybe for "[un]equip start/stop",
// but they are also present in weapon drawing animation. // but they are also present in weapon drawing animation.
mAnimation->showShield(weaptype != WeapType_Spell); mAnimation->showCarriedLeft(weaptype != WeapType_Spell && weaptype != WeapType_HandToHand);
std::string weapgroup; std::string weapgroup;
if(weaptype == WeapType_None) if(weaptype == WeapType_None)
@ -719,7 +719,8 @@ bool CharacterController::updateNpcState(bool onground, bool inwater, bool isrun
MWWorld::ContainerStoreIterator torch = inv.getSlot(MWWorld::InventoryStore::Slot_CarriedLeft); MWWorld::ContainerStoreIterator torch = inv.getSlot(MWWorld::InventoryStore::Slot_CarriedLeft);
if(torch != inv.end() && torch->getTypeName() == typeid(ESM::Light).name()) if(torch != inv.end() && torch->getTypeName() == typeid(ESM::Light).name()
&& mWeaponType != WeapType_Spell && mWeaponType != WeapType_HandToHand)
{ {
if(!mAnimation->isPlaying("torch")) if(!mAnimation->isPlaying("torch"))
mAnimation->play("torch", Priority_Torch, mAnimation->play("torch", Priority_Torch,

View File

@ -279,7 +279,7 @@ public:
virtual Ogre::Vector3 runAnimation(float duration); virtual Ogre::Vector3 runAnimation(float duration);
virtual void showWeapons(bool showWeapon); virtual void showWeapons(bool showWeapon);
virtual void showShield(bool show) {} virtual void showCarriedLeft(bool show) {}
void enableLights(bool enable); void enableLights(bool enable);

View File

@ -117,7 +117,7 @@ NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, Ogre::SceneNode* node, int v
mListenerDisabled(disableListener), mListenerDisabled(disableListener),
mViewMode(viewMode), mViewMode(viewMode),
mShowWeapons(false), mShowWeapons(false),
mShowShield(true), mShowCarriedLeft(true),
mFirstPersonOffset(0.f, 0.f, 0.f), mFirstPersonOffset(0.f, 0.f, 0.f),
mAlpha(1.f) mAlpha(1.f)
{ {
@ -319,7 +319,7 @@ void NpcAnimation::updateParts()
} }
showWeapons(mShowWeapons); showWeapons(mShowWeapons);
showShield(mShowShield); showCarriedLeft(mShowCarriedLeft);
// Remember body parts so we only have to search through the store once for each race/gender/viewmode combination // Remember body parts so we only have to search through the store once for each race/gender/viewmode combination
static std::map< std::pair<std::string,int>,std::vector<const ESM::BodyPart*> > sRaceMapping; static std::map< std::pair<std::string,int>,std::vector<const ESM::BodyPart*> > sRaceMapping;
@ -654,32 +654,24 @@ void NpcAnimation::showWeapons(bool showWeapon)
mAlpha = 1.f; mAlpha = 1.f;
} }
void NpcAnimation::showShield(bool show) void NpcAnimation::showCarriedLeft(bool show)
{ {
mShowShield = show; mShowCarriedLeft = show;
MWWorld::InventoryStore &inv = MWWorld::Class::get(mPtr).getInventoryStore(mPtr); MWWorld::InventoryStore &inv = MWWorld::Class::get(mPtr).getInventoryStore(mPtr);
MWWorld::ContainerStoreIterator shield = inv.getSlot(MWWorld::InventoryStore::Slot_CarriedLeft); MWWorld::ContainerStoreIterator iter = inv.getSlot(MWWorld::InventoryStore::Slot_CarriedLeft);
if (shield != inv.end() && shield->getTypeName() == typeid(ESM::Light).name()) if(show && iter != inv.end())
{ {
// ... Except for lights, which are still shown during spellcasting since they Ogre::Vector3 glowColor = getEnchantmentColor(*iter);
// have their own (one-handed) casting animations std::string mesh = MWWorld::Class::get(*iter).getModel(*iter);
show = true;
}
if(show && shield != inv.end())
{
Ogre::Vector3 glowColor = getEnchantmentColor(*shield);
std::string mesh = MWWorld::Class::get(*shield).getModel(*shield);
addOrReplaceIndividualPart(ESM::PRT_Shield, MWWorld::InventoryStore::Slot_CarriedLeft, 1, addOrReplaceIndividualPart(ESM::PRT_Shield, MWWorld::InventoryStore::Slot_CarriedLeft, 1,
mesh, !shield->getClass().getEnchantment(*shield).empty(), &glowColor); mesh, !iter->getClass().getEnchantment(*iter).empty(), &glowColor);
if (shield->getTypeName() == typeid(ESM::Light).name()) if (iter->getTypeName() == typeid(ESM::Light).name())
addExtraLight(mInsert->getCreator(), mObjectParts[ESM::PRT_Shield], shield->get<ESM::Light>()->mBase); addExtraLight(mInsert->getCreator(), mObjectParts[ESM::PRT_Shield], iter->get<ESM::Light>()->mBase);
} }
else else
{
removeIndividualPart(ESM::PRT_Shield); removeIndividualPart(ESM::PRT_Shield);
}
} }
void NpcAnimation::permanentEffectAdded(const ESM::MagicEffect *magicEffect, bool isNew, bool playSound) void NpcAnimation::permanentEffectAdded(const ESM::MagicEffect *magicEffect, bool isNew, bool playSound)

View File

@ -53,7 +53,7 @@ private:
std::string mHairModel; std::string mHairModel;
ViewMode mViewMode; ViewMode mViewMode;
bool mShowWeapons; bool mShowWeapons;
bool mShowShield; bool mShowCarriedLeft;
int mVisibilityFlags; int mVisibilityFlags;
@ -100,7 +100,7 @@ public:
virtual Ogre::Vector3 runAnimation(float timepassed); virtual Ogre::Vector3 runAnimation(float timepassed);
virtual void showWeapons(bool showWeapon); virtual void showWeapons(bool showWeapon);
virtual void showShield(bool showShield); virtual void showCarriedLeft(bool showa);
void setViewMode(ViewMode viewMode); void setViewMode(ViewMode viewMode);