Fix shields being visible during spellcasting

actorid
scrawl 11 years ago
parent d8c40562ae
commit d2ed77f3f2

@ -426,6 +426,11 @@ bool CharacterController::updateNpcState(bool onground, bool inwater, bool isrun
{
forcestateupdate = true;
// Shields shouldn't be visible during spellcasting
// 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.
mAnimation->showShield(weaptype != WeapType_Spell);
std::string weapgroup;
if(weaptype == WeapType_None)
{
@ -443,6 +448,7 @@ bool CharacterController::updateNpcState(bool onground, bool inwater, bool isrun
MWRender::Animation::Group_UpperBody, true,
1.0f, "equip start", "equip stop", 0.0f, 0);
mUpperBodyState = UpperCharState_EquipingWeap;
if(isWerewolf)
{
const MWWorld::ESMStore &store = MWBase::Environment::get().getWorld()->getStore();

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

@ -110,6 +110,7 @@ NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, Ogre::SceneNode* node, int v
mListenerDisabled(disableListener),
mViewMode(viewMode),
mShowWeapons(false),
mShowShield(true),
mFirstPersonOffset(0.f, 0.f, 0.f)
{
mNpc = mPtr.get<ESM::NPC>()->mBase;
@ -307,6 +308,7 @@ void NpcAnimation::updateParts()
}
showWeapons(mShowWeapons);
showShield(mShowShield);
// 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;
@ -635,6 +637,34 @@ void NpcAnimation::showWeapons(bool showWeapon)
}
}
void NpcAnimation::showShield(bool show)
{
mShowShield = show;
MWWorld::InventoryStore &inv = MWWorld::Class::get(mPtr).getInventoryStore(mPtr);
MWWorld::ContainerStoreIterator shield = inv.getSlot(MWWorld::InventoryStore::Slot_CarriedLeft);
if (shield != inv.end() && shield->getTypeName() == typeid(ESM::Light).name())
{
// ... Except for lights, which are still shown during spellcasting since they
// have their own (one-handed) casting animations
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,
mesh, !shield->getClass().getEnchantment(*shield).empty(), &glowColor);
if (shield->getTypeName() == typeid(ESM::Light).name())
addExtraLight(mInsert->getCreator(), mObjectParts[ESM::PRT_Shield], shield->get<ESM::Light>()->mBase);
}
else
{
removeIndividualPart(ESM::PRT_Shield);
}
}
void NpcAnimation::permanentEffectAdded(const ESM::MagicEffect *magicEffect, bool isNew, bool playSound)
{
// During first auto equip, we don't play any sounds.

@ -41,6 +41,7 @@ private:
std::string mHairModel;
ViewMode mViewMode;
bool mShowWeapons;
bool mShowShield;
int mVisibilityFlags;
@ -81,6 +82,7 @@ public:
virtual Ogre::Vector3 runAnimation(float timepassed);
virtual void showWeapons(bool showWeapon);
virtual void showShield(bool showShield);
void setViewMode(ViewMode viewMode);

Loading…
Cancel
Save