mirror of
				https://github.com/OpenMW/openmw.git
				synced 2025-10-25 11:26:37 +00:00 
			
		
		
		
	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/player.hpp" | ||||||
| #include "../mwworld/class.hpp" | #include "../mwworld/class.hpp" | ||||||
| #include "../mwworld/inventorystore.hpp" | #include "../mwworld/inventorystore.hpp" | ||||||
|  | #include "../mwworld/actionequip.hpp" | ||||||
|  | #include "../mwworld/actiontake.hpp" | ||||||
| 
 | 
 | ||||||
| namespace | namespace | ||||||
| { | { | ||||||
|  | @ -709,27 +711,24 @@ bool CharacterController::updateNpcState(bool onground, bool inwater, bool isrun | ||||||
| 
 | 
 | ||||||
|     if (MWBase::Environment::get().getWorld()->isNight()) |     if (MWBase::Environment::get().getWorld()->isNight()) | ||||||
|     { |     { | ||||||
|       MWWorld::ContainerStoreIterator torch = inv.getSlot(MWWorld::InventoryStore::Slot_CarriedLeft); |       MWWorld::ContainerStoreIterator item = inv.getSlot(MWWorld::InventoryStore::Slot_CarriedLeft); | ||||||
|       if(torch != inv.end() && torch->getTypeName() == typeid(ESM::Light).name()) |       if (item != inv.end() && item->getTypeName() == typeid(ESM::Light).name()) | ||||||
|       { |       { | ||||||
|         mAnimation->showLights(true); |         mAnimation->showLights(true); | ||||||
|         if(!mAnimation->isPlaying("torch")) |         if (!mAnimation->isPlaying("torch")) | ||||||
|               mAnimation->play("torch", Priority_Torch, |         { | ||||||
|                                MWRender::Animation::Group_LeftArm, false, |           mAnimation->play("torch", Priority_Torch, MWRender::Animation::Group_LeftArm, | ||||||
|                                1.0f, "start", "stop", 0.0f, (~(size_t)0)); |             false, 1.0f, "start", "stop", 0.0f, (~(size_t)0)); | ||||||
|       } |         } | ||||||
|       else if (mAnimation->isPlaying("torch")) |  | ||||||
|       { |  | ||||||
|           mAnimation->disable("torch"); |  | ||||||
|           mAnimation->showLights(false); |  | ||||||
|           mAnimation->showShield(true); |  | ||||||
|       } |       } | ||||||
|     } |     } | ||||||
|     else |     else | ||||||
|     { |     { | ||||||
|  |       if (mAnimation->isPlaying("torch")) | ||||||
|  |       { | ||||||
|         mAnimation->disable("torch"); |         mAnimation->disable("torch"); | ||||||
|         mAnimation->showLights(false); |       } | ||||||
|         mAnimation->showShield(true); |       mAnimation->showLights(false); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     return forcestateupdate; |     return forcestateupdate; | ||||||
|  |  | ||||||
|  | @ -677,17 +677,17 @@ void NpcAnimation::showShield(bool show) | ||||||
| 
 | 
 | ||||||
| void NpcAnimation::showLights(bool show) | void NpcAnimation::showLights(bool show) | ||||||
| { | { | ||||||
|     mShowLights = show; |  | ||||||
|     MWWorld::InventoryStore &inv = MWWorld::Class::get(mPtr).getInventoryStore(mPtr); |     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); |         mShowLights = show; | ||||||
|         std::string mesh = MWWorld::Class::get(*shield).getModel(*shield); |         Ogre::Vector3 glowColor = getEnchantmentColor(*light); | ||||||
|  |         std::string mesh = MWWorld::Class::get(*light).getModel(*light); | ||||||
|         addOrReplaceIndividualPart(ESM::PRT_Shield, MWWorld::InventoryStore::Slot_CarriedLeft, 1, |         addOrReplaceIndividualPart(ESM::PRT_Shield, MWWorld::InventoryStore::Slot_CarriedLeft, 1, | ||||||
|                                    mesh, !shield->getClass().getEnchantment(*shield).empty(), &glowColor); |                                    mesh, !light->getClass().getEnchantment(*light).empty(), &glowColor); | ||||||
|         addExtraLight(mInsert->getCreator(), mObjectParts[ESM::PRT_Shield], shield->get<ESM::Light>()->mBase); |         addExtraLight(mInsert->getCreator(), mObjectParts[ESM::PRT_Shield], light->get<ESM::Light>()->mBase); | ||||||
|     } |     } | ||||||
|     else |     else | ||||||
|     { |     { | ||||||
|  |  | ||||||
		Loading…
	
		Reference in a new issue