diff --git a/apps/openmw/mwinput/inputmanagerimp.cpp b/apps/openmw/mwinput/inputmanagerimp.cpp index d15e95171..573fe389c 100644 --- a/apps/openmw/mwinput/inputmanagerimp.cpp +++ b/apps/openmw/mwinput/inputmanagerimp.cpp @@ -268,10 +268,6 @@ namespace MWInput case A_ToggleHUD: mWindows.toggleHud(); break; - case A_Use: - if (!MWBase::Environment::get().getWindowManager()->isGuiMode()) - mPlayer.use(); - break; } } } diff --git a/apps/openmw/mwmechanics/character.cpp b/apps/openmw/mwmechanics/character.cpp index 0a547b4d3..8aa797b0c 100644 --- a/apps/openmw/mwmechanics/character.cpp +++ b/apps/openmw/mwmechanics/character.cpp @@ -24,12 +24,14 @@ #include "movement.hpp" #include "npcstats.hpp" #include "creaturestats.hpp" +#include "security.hpp" #include "../mwrender/animation.hpp" #include "../mwbase/environment.hpp" #include "../mwbase/world.hpp" #include "../mwbase/soundmanager.hpp" +#include "../mwbase/windowmanager.hpp" #include "../mwworld/player.hpp" #include "../mwworld/class.hpp" @@ -465,7 +467,36 @@ bool CharacterController::updateNpcState() sndMgr->playSound3D(mPtr, schools[effect->mData.mSchool]+" cast", 1.0f, 1.0f); } } - else if(mWeaponType != WeapType_PickProbe) + else if(mWeaponType == WeapType_PickProbe) + { + MWWorld::Ptr item = *weapon; + MWWorld::Ptr target = MWBase::Environment::get().getWorld()->getFacedObject(); + std::string resultMessage, resultSound; + + if(!target.isEmpty()) + { + if(item.getTypeName() == typeid(ESM::Lockpick).name()) + Security(mPtr).pickLock(target, item, resultMessage, resultSound); + else if(item.getTypeName() == typeid(ESM::Probe).name()) + Security(mPtr).probeTrap(target, item, resultMessage, resultSound); + } + mAnimation->play(mCurrentWeapon, Priority_Weapon, + MWRender::Animation::Group_UpperBody, true, + 1.0f, "start", "stop", 0.0, 0); + mUpperBodyState = UpperCharState_FollowStartToFollowStop; + + if(!resultMessage.empty()) + MWBase::Environment::get().getWindowManager()->messageBox(resultMessage); + if(!resultSound.empty()) + MWBase::Environment::get().getSoundManager()->playSound(resultSound, 1.0f, 1.0f); + + // tool used up? + if(!item.getRefData().getCount()) + MWBase::Environment::get().getWindowManager()->unsetSelectedWeapon(); + else + MWBase::Environment::get().getWindowManager()->setSelectedWeapon(item); + } + else { if(mWeaponType == WeapType_Crossbow || mWeaponType == WeapType_BowAndArrow || mWeaponType == WeapType_ThowWeapon) diff --git a/apps/openmw/mwworld/player.cpp b/apps/openmw/mwworld/player.cpp index 0d9399c61..e26c2e2a5 100644 --- a/apps/openmw/mwworld/player.cpp +++ b/apps/openmw/mwworld/player.cpp @@ -11,10 +11,6 @@ #include "../mwmechanics/movement.hpp" #include "../mwmechanics/npcstats.hpp" -#include "../mwmechanics/character.hpp" -#include "../mwmechanics/security.hpp" - -#include "../mwrender/animation.hpp" #include "class.hpp" @@ -144,51 +140,6 @@ namespace MWWorld MWWorld::Class::get(ptr).getMovementSettings(ptr).mRotation[1] += roll; } - void Player::use() - { - MWWorld::InventoryStore& store = MWWorld::Class::get(getPlayer()).getInventoryStore(getPlayer()); - MWWorld::ContainerStoreIterator equipped = store.getSlot(MWWorld::InventoryStore::Slot_CarriedRight); - - if (getDrawState() == MWMechanics::DrawState_Weapon) - { - if (equipped != store.end()) - { - MWWorld::Ptr item = *equipped; - MWRender::Animation* anim = MWBase::Environment::get().getWorld()->getAnimation(getPlayer()); - MWWorld::Ptr target = MWBase::Environment::get().getWorld()->getFacedObject(); - - if (anim->isPriorityActive(MWMechanics::Priority_Weapon)) - return; - - std::string resultMessage, resultSound; - - if (item.getTypeName() == typeid(ESM::Lockpick).name()) - { - if (!target.isEmpty()) - MWMechanics::Security(getPlayer()).pickLock(target, item, resultMessage, resultSound); - anim->play("pickprobe", MWMechanics::Priority_Weapon, MWRender::Animation::Group_UpperBody, true, 1.0f, "start", "stop", 0.0, 0); - } - else if (item.getTypeName() == typeid(ESM::Probe).name()) - { - if (!target.isEmpty()) - MWMechanics::Security(getPlayer()).probeTrap(target, item, resultMessage, resultSound); - anim->play("pickprobe", MWMechanics::Priority_Weapon, MWRender::Animation::Group_UpperBody, true, 1.0f, "start", "stop", 0.0, 0); - } - - if (!resultMessage.empty()) - MWBase::Environment::get().getWindowManager()->messageBox(resultMessage); - if (!resultSound.empty()) - MWBase::Environment::get().getSoundManager()->playSound(resultSound,1,1); - - // tool used up? - if (!item.getRefData().getCount()) - MWBase::Environment::get().getWindowManager()->unsetSelectedWeapon(); - else - MWBase::Environment::get().getWindowManager()->setSelectedWeapon(item); - } - } - } - MWMechanics::DrawState_ Player::getDrawState() { MWWorld::Ptr ptr = getPlayer(); diff --git a/apps/openmw/mwworld/player.hpp b/apps/openmw/mwworld/player.hpp index 4660c6e9a..d78b1901c 100644 --- a/apps/openmw/mwworld/player.hpp +++ b/apps/openmw/mwworld/player.hpp @@ -58,9 +58,6 @@ namespace MWWorld void setForwardBackward (int value); void setUpDown(int value); - void use (); - ///< Use item equipped on right hand, or fists - void setRunState(bool run); void setSneak(bool sneak);