mirror of
				https://github.com/OpenMW/openmw.git
				synced 2025-10-26 14:56:39 +00:00 
			
		
		
		
	Implement Telekinesis magic effect. Remove some duplicate code.
This commit is contained in:
		
							parent
							
								
									531bef6193
								
							
						
					
					
						commit
						f6387d5979
					
				
					 1 changed files with 11 additions and 28 deletions
				
			
		|  | @ -796,32 +796,9 @@ namespace MWWorld | ||||||
| 
 | 
 | ||||||
|     MWWorld::Ptr World::getFacedObject() |     MWWorld::Ptr World::getFacedObject() | ||||||
|     { |     { | ||||||
|         std::pair<float, std::string> result; |         if (mFacedHandle.empty()) | ||||||
| 
 |  | ||||||
|         if (!mRendering->occlusionQuerySupported()) |  | ||||||
|             result = mPhysics->getFacedHandle (getMaxActivationDistance ()); |  | ||||||
|         else |  | ||||||
|             result = std::make_pair (mFacedDistance, mFacedHandle); |  | ||||||
| 
 |  | ||||||
|         if (result.second.empty()) |  | ||||||
|             return MWWorld::Ptr(); |             return MWWorld::Ptr(); | ||||||
| 
 |         return searchPtrViaHandle(mFacedHandle); | ||||||
|         MWWorld::Ptr object = searchPtrViaHandle (result.second); |  | ||||||
|         if (object.isEmpty()) |  | ||||||
|             return object; |  | ||||||
|         float ActivationDistance; |  | ||||||
| 
 |  | ||||||
|         if (MWBase::Environment::get().getWindowManager()->isConsoleMode()) |  | ||||||
|             ActivationDistance = getObjectActivationDistance ()*50; |  | ||||||
|         else if (object.getTypeName ().find("NPC") != std::string::npos) |  | ||||||
|             ActivationDistance = getNpcActivationDistance (); |  | ||||||
|         else |  | ||||||
|             ActivationDistance = getObjectActivationDistance (); |  | ||||||
| 
 |  | ||||||
|         if (result.first > ActivationDistance) |  | ||||||
|             return MWWorld::Ptr (); |  | ||||||
| 
 |  | ||||||
|         return object; |  | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     std::pair<MWWorld::Ptr,Ogre::Vector3> World::getHitContact(const MWWorld::Ptr &ptr, float distance) |     std::pair<MWWorld::Ptr,Ogre::Vector3> World::getHitContact(const MWWorld::Ptr &ptr, float distance) | ||||||
|  | @ -1346,6 +1323,12 @@ namespace MWWorld | ||||||
| 
 | 
 | ||||||
|     void World::updateFacedHandle () |     void World::updateFacedHandle () | ||||||
|     { |     { | ||||||
|  |         float telekinesisRangeBonus = | ||||||
|  |                 mPlayer->getPlayer().getClass().getCreatureStats(mPlayer->getPlayer()).getMagicEffects() | ||||||
|  |                 .get(ESM::MagicEffect::Telekinesis).mMagnitude * 22; | ||||||
|  | 
 | ||||||
|  |         float activationDistance = getMaxActivationDistance() + telekinesisRangeBonus; | ||||||
|  | 
 | ||||||
|         // send new query
 |         // send new query
 | ||||||
|         // figure out which object we want to test against
 |         // figure out which object we want to test against
 | ||||||
|         std::vector < std::pair < float, std::string > > results; |         std::vector < std::pair < float, std::string > > results; | ||||||
|  | @ -1353,13 +1336,13 @@ namespace MWWorld | ||||||
|         { |         { | ||||||
|             float x, y; |             float x, y; | ||||||
|             MWBase::Environment::get().getWindowManager()->getMousePosition(x, y); |             MWBase::Environment::get().getWindowManager()->getMousePosition(x, y); | ||||||
|             results = mPhysics->getFacedHandles(x, y, getMaxActivationDistance ()); |             results = mPhysics->getFacedHandles(x, y, activationDistance); | ||||||
|             if (MWBase::Environment::get().getWindowManager()->isConsoleMode()) |             if (MWBase::Environment::get().getWindowManager()->isConsoleMode()) | ||||||
|                 results = mPhysics->getFacedHandles(x, y, getMaxActivationDistance ()*50); |                 results = mPhysics->getFacedHandles(x, y, getMaxActivationDistance ()*50); | ||||||
|         } |         } | ||||||
|         else |         else | ||||||
|         { |         { | ||||||
|             results = mPhysics->getFacedHandles(getMaxActivationDistance ()); |             results = mPhysics->getFacedHandles(activationDistance); | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         // ignore the player and other things we're not interested in
 |         // ignore the player and other things we're not interested in
 | ||||||
|  |  | ||||||
		Loading…
	
		Reference in a new issue