1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-21 11:23:51 +00:00

Implement Telekinesis magic effect. Remove some duplicate code.

This commit is contained in:
scrawl 2014-01-01 23:30:58 +01:00
parent 531bef6193
commit f6387d5979

View file

@ -796,32 +796,9 @@ namespace MWWorld
MWWorld::Ptr World::getFacedObject() MWWorld::Ptr World::getFacedObject()
{ {
std::pair<float, std::string> result; if (mFacedHandle.empty())
return MWWorld::Ptr();
if (!mRendering->occlusionQuerySupported()) return searchPtrViaHandle(mFacedHandle);
result = mPhysics->getFacedHandle (getMaxActivationDistance ());
else
result = std::make_pair (mFacedDistance, mFacedHandle);
if (result.second.empty())
return MWWorld::Ptr ();
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