mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-04-01 10:06:42 +00:00
Fixes #845: NPCs hold torches during the day
Added check for Player character so it won't be affected by showing, or hidding torches. Signed-off-by: Lukasz Gromanowski <lgromanowski@gmail.com>
This commit is contained in:
parent
6eb674e4e5
commit
abc126e2af
1 changed files with 36 additions and 34 deletions
|
@ -709,48 +709,50 @@ bool CharacterController::updateNpcState(bool onground, bool inwater, bool isrun
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (MWBase::Environment::get().getWorld()->isNight())
|
if (mPtr.getRefData().getHandle() != "player")
|
||||||
{
|
{
|
||||||
MWWorld::ContainerStoreIterator item = inv.getSlot(MWWorld::InventoryStore::Slot_CarriedLeft);
|
if (MWBase::Environment::get().getWorld()->isNight())
|
||||||
if (item != inv.end() && item->getTypeName() != typeid(ESM::Light).name())
|
|
||||||
{
|
{
|
||||||
inv.unequipItem(*item, mPtr);
|
|
||||||
}
|
|
||||||
else if (item == inv.end())
|
|
||||||
{
|
|
||||||
MWWorld::Ptr itemPtr = inv.search("torch_infinite_time");
|
|
||||||
if (!itemPtr.isEmpty())
|
|
||||||
{
|
|
||||||
item = inv.add(itemPtr, mPtr);
|
|
||||||
inv.equip(MWWorld::InventoryStore::Slot_CarriedLeft, item, mPtr);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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);
|
|
||||||
MWWorld::ContainerStoreIterator item = inv.getSlot(MWWorld::InventoryStore::Slot_CarriedLeft);
|
MWWorld::ContainerStoreIterator item = inv.getSlot(MWWorld::InventoryStore::Slot_CarriedLeft);
|
||||||
if (item != inv.end() && item->getTypeName() == typeid(ESM::Light).name())
|
if (item != inv.end() && item->getTypeName() != typeid(ESM::Light).name())
|
||||||
{
|
{
|
||||||
inv.unequipItem(*item, mPtr);
|
inv.unequipItem(*item, mPtr);
|
||||||
inv.add(*item, mPtr);
|
}
|
||||||
|
else if (item == inv.end())
|
||||||
|
{
|
||||||
|
MWWorld::Ptr itemPtr = inv.search("torch_infinite_time");
|
||||||
|
if (!itemPtr.isEmpty())
|
||||||
|
{
|
||||||
|
item = inv.add(itemPtr, mPtr);
|
||||||
|
inv.equip(MWWorld::InventoryStore::Slot_CarriedLeft, item, mPtr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
MWWorld::ContainerStoreIterator item = inv.getSlot(MWWorld::InventoryStore::Slot_CarriedLeft);
|
||||||
|
if (item != inv.end() && item->getTypeName() == typeid(ESM::Light).name())
|
||||||
|
{
|
||||||
|
inv.unequipItem(*item, mPtr);
|
||||||
|
inv.add(*item, mPtr);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return forcestateupdate;
|
return forcestateupdate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue