mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-02-04 21:40:03 +00:00
Fixes #845: NPCs hold torches during the day
Added equipping/unequipping torches. Signed-off-by: Lukasz Gromanowski <lgromanowski@gmail.com>
This commit is contained in:
parent
92072d968b
commit
6eb674e4e5
@ -712,6 +712,20 @@ bool CharacterController::updateNpcState(bool onground, bool inwater, bool isrun
|
|||||||
if (MWBase::Environment::get().getWorld()->isNight())
|
if (MWBase::Environment::get().getWorld()->isNight())
|
||||||
{
|
{
|
||||||
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())
|
||||||
|
{
|
||||||
|
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())
|
if (item != inv.end() && item->getTypeName() == typeid(ESM::Light).name())
|
||||||
{
|
{
|
||||||
mAnimation->showLights(true);
|
mAnimation->showLights(true);
|
||||||
@ -727,8 +741,14 @@ bool CharacterController::updateNpcState(bool onground, bool inwater, bool isrun
|
|||||||
if (mAnimation->isPlaying("torch"))
|
if (mAnimation->isPlaying("torch"))
|
||||||
{
|
{
|
||||||
mAnimation->disable("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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
mAnimation->showLights(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return forcestateupdate;
|
return forcestateupdate;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user