forked from teamnwah/openmw-tes3coop
Fixes #845: NPCs hold torches during the day
Simplified a bit code which shows and hides light. Signed-off-by: Lukasz Gromanowski <lgromanowski@gmail.com>
This commit is contained in:
parent
91a4d9a2eb
commit
92072d968b
2 changed files with 20 additions and 21 deletions
|
@ -36,6 +36,8 @@
|
|||
#include "../mwworld/player.hpp"
|
||||
#include "../mwworld/class.hpp"
|
||||
#include "../mwworld/inventorystore.hpp"
|
||||
#include "../mwworld/actionequip.hpp"
|
||||
#include "../mwworld/actiontake.hpp"
|
||||
|
||||
namespace
|
||||
{
|
||||
|
@ -709,27 +711,24 @@ bool CharacterController::updateNpcState(bool onground, bool inwater, bool isrun
|
|||
|
||||
if (MWBase::Environment::get().getWorld()->isNight())
|
||||
{
|
||||
MWWorld::ContainerStoreIterator torch = inv.getSlot(MWWorld::InventoryStore::Slot_CarriedLeft);
|
||||
if(torch != inv.end() && torch->getTypeName() == typeid(ESM::Light).name())
|
||||
MWWorld::ContainerStoreIterator item = inv.getSlot(MWWorld::InventoryStore::Slot_CarriedLeft);
|
||||
if (item != inv.end() && item->getTypeName() == typeid(ESM::Light).name())
|
||||
{
|
||||
mAnimation->showLights(true);
|
||||
if(!mAnimation->isPlaying("torch"))
|
||||
mAnimation->play("torch", Priority_Torch,
|
||||
MWRender::Animation::Group_LeftArm, false,
|
||||
1.0f, "start", "stop", 0.0f, (~(size_t)0));
|
||||
}
|
||||
else if (mAnimation->isPlaying("torch"))
|
||||
{
|
||||
mAnimation->disable("torch");
|
||||
mAnimation->showLights(false);
|
||||
mAnimation->showShield(true);
|
||||
if (!mAnimation->isPlaying("torch"))
|
||||
{
|
||||
mAnimation->play("torch", Priority_Torch, MWRender::Animation::Group_LeftArm,
|
||||
false, 1.0f, "start", "stop", 0.0f, (~(size_t)0));
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (mAnimation->isPlaying("torch"))
|
||||
{
|
||||
mAnimation->disable("torch");
|
||||
mAnimation->showLights(false);
|
||||
mAnimation->showShield(true);
|
||||
}
|
||||
mAnimation->showLights(false);
|
||||
}
|
||||
|
||||
return forcestateupdate;
|
||||
|
|
|
@ -677,17 +677,17 @@ void NpcAnimation::showShield(bool show)
|
|||
|
||||
void NpcAnimation::showLights(bool show)
|
||||
{
|
||||
mShowLights = show;
|
||||
MWWorld::InventoryStore &inv = MWWorld::Class::get(mPtr).getInventoryStore(mPtr);
|
||||
MWWorld::ContainerStoreIterator shield = inv.getSlot(MWWorld::InventoryStore::Slot_CarriedLeft);
|
||||
MWWorld::ContainerStoreIterator light = inv.getSlot(MWWorld::InventoryStore::Slot_CarriedLeft);
|
||||
|
||||
if(show && shield != inv.end() && shield->getTypeName() == typeid(ESM::Light).name())
|
||||
if(show && light != inv.end() && light->getTypeName() == typeid(ESM::Light).name())
|
||||
{
|
||||
Ogre::Vector3 glowColor = getEnchantmentColor(*shield);
|
||||
std::string mesh = MWWorld::Class::get(*shield).getModel(*shield);
|
||||
mShowLights = show;
|
||||
Ogre::Vector3 glowColor = getEnchantmentColor(*light);
|
||||
std::string mesh = MWWorld::Class::get(*light).getModel(*light);
|
||||
addOrReplaceIndividualPart(ESM::PRT_Shield, MWWorld::InventoryStore::Slot_CarriedLeft, 1,
|
||||
mesh, !shield->getClass().getEnchantment(*shield).empty(), &glowColor);
|
||||
addExtraLight(mInsert->getCreator(), mObjectParts[ESM::PRT_Shield], shield->get<ESM::Light>()->mBase);
|
||||
mesh, !light->getClass().getEnchantment(*light).empty(), &glowColor);
|
||||
addExtraLight(mInsert->getCreator(), mObjectParts[ESM::PRT_Shield], light->get<ESM::Light>()->mBase);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue