Fixes #845: NPCs hold torches during the day

Added equipping/unequipping torches.

Signed-off-by: Lukasz Gromanowski <lgromanowski@gmail.com>
actorid
Lukasz Gromanowski 11 years ago
parent 92072d968b
commit 6eb674e4e5

@ -712,6 +712,20 @@ bool CharacterController::updateNpcState(bool onground, bool inwater, bool isrun
if (MWBase::Environment::get().getWorld()->isNight())
{
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())
{
mAnimation->showLights(true);
@ -727,8 +741,14 @@ bool CharacterController::updateNpcState(bool onground, bool inwater, bool isrun
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);
}
}
mAnimation->showLights(false);
}
return forcestateupdate;

Loading…
Cancel
Save