mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-19 22:53:50 +00:00
Handle the pick/probe in the character controller
This commit is contained in:
parent
2cfe6db389
commit
eab4e09566
4 changed files with 32 additions and 57 deletions
|
@ -268,10 +268,6 @@ namespace MWInput
|
||||||
case A_ToggleHUD:
|
case A_ToggleHUD:
|
||||||
mWindows.toggleHud();
|
mWindows.toggleHud();
|
||||||
break;
|
break;
|
||||||
case A_Use:
|
|
||||||
if (!MWBase::Environment::get().getWindowManager()->isGuiMode())
|
|
||||||
mPlayer.use();
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,12 +24,14 @@
|
||||||
#include "movement.hpp"
|
#include "movement.hpp"
|
||||||
#include "npcstats.hpp"
|
#include "npcstats.hpp"
|
||||||
#include "creaturestats.hpp"
|
#include "creaturestats.hpp"
|
||||||
|
#include "security.hpp"
|
||||||
|
|
||||||
#include "../mwrender/animation.hpp"
|
#include "../mwrender/animation.hpp"
|
||||||
|
|
||||||
#include "../mwbase/environment.hpp"
|
#include "../mwbase/environment.hpp"
|
||||||
#include "../mwbase/world.hpp"
|
#include "../mwbase/world.hpp"
|
||||||
#include "../mwbase/soundmanager.hpp"
|
#include "../mwbase/soundmanager.hpp"
|
||||||
|
#include "../mwbase/windowmanager.hpp"
|
||||||
|
|
||||||
#include "../mwworld/player.hpp"
|
#include "../mwworld/player.hpp"
|
||||||
#include "../mwworld/class.hpp"
|
#include "../mwworld/class.hpp"
|
||||||
|
@ -465,7 +467,36 @@ bool CharacterController::updateNpcState()
|
||||||
sndMgr->playSound3D(mPtr, schools[effect->mData.mSchool]+" cast", 1.0f, 1.0f);
|
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 ||
|
if(mWeaponType == WeapType_Crossbow || mWeaponType == WeapType_BowAndArrow ||
|
||||||
mWeaponType == WeapType_ThowWeapon)
|
mWeaponType == WeapType_ThowWeapon)
|
||||||
|
|
|
@ -11,10 +11,6 @@
|
||||||
|
|
||||||
#include "../mwmechanics/movement.hpp"
|
#include "../mwmechanics/movement.hpp"
|
||||||
#include "../mwmechanics/npcstats.hpp"
|
#include "../mwmechanics/npcstats.hpp"
|
||||||
#include "../mwmechanics/character.hpp"
|
|
||||||
#include "../mwmechanics/security.hpp"
|
|
||||||
|
|
||||||
#include "../mwrender/animation.hpp"
|
|
||||||
|
|
||||||
#include "class.hpp"
|
#include "class.hpp"
|
||||||
|
|
||||||
|
@ -144,51 +140,6 @@ namespace MWWorld
|
||||||
MWWorld::Class::get(ptr).getMovementSettings(ptr).mRotation[1] += roll;
|
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()
|
MWMechanics::DrawState_ Player::getDrawState()
|
||||||
{
|
{
|
||||||
MWWorld::Ptr ptr = getPlayer();
|
MWWorld::Ptr ptr = getPlayer();
|
||||||
|
|
|
@ -58,9 +58,6 @@ namespace MWWorld
|
||||||
void setForwardBackward (int value);
|
void setForwardBackward (int value);
|
||||||
void setUpDown(int value);
|
void setUpDown(int value);
|
||||||
|
|
||||||
void use ();
|
|
||||||
///< Use item equipped on right hand, or fists
|
|
||||||
|
|
||||||
void setRunState(bool run);
|
void setRunState(bool run);
|
||||||
void setSneak(bool sneak);
|
void setSneak(bool sneak);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue