mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-02-06 04:15:33 +00:00
Open inventory when activating an unconscious actor (Fixes #1848)
This commit is contained in:
parent
fc7ed05da8
commit
10a0e2434e
4 changed files with 15 additions and 9 deletions
|
@ -863,9 +863,9 @@ namespace MWClass
|
|||
return boost::shared_ptr<MWWorld::Action>(new MWWorld::ActionOpen(ptr, true));
|
||||
if(ptr.getClass().getCreatureStats(ptr).getAiSequence().isInCombat())
|
||||
return boost::shared_ptr<MWWorld::Action>(new MWWorld::FailedAction("#{sActorInCombat}"));
|
||||
if(getCreatureStats(actor).getStance(MWMechanics::CreatureStats::Stance_Sneak))
|
||||
if(getCreatureStats(actor).getStance(MWMechanics::CreatureStats::Stance_Sneak)
|
||||
|| ptr.getClass().getCreatureStats(ptr).getKnockedDown())
|
||||
return boost::shared_ptr<MWWorld::Action>(new MWWorld::ActionOpen(ptr)); // stealing
|
||||
|
||||
// Can't talk to werewolfs
|
||||
if(ptr.getClass().isNpc() && ptr.getClass().getNpcStats(ptr).isWerewolf())
|
||||
return boost::shared_ptr<MWWorld::Action> (new MWWorld::FailedAction(""));
|
||||
|
|
|
@ -244,7 +244,8 @@ namespace MWGui
|
|||
{
|
||||
// we are stealing stuff
|
||||
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr();
|
||||
mModel = new PickpocketItemModel(player, new InventoryItemModel(container));
|
||||
mModel = new PickpocketItemModel(player, new InventoryItemModel(container),
|
||||
!mPtr.getClass().getCreatureStats(mPtr).getKnockedDown());
|
||||
}
|
||||
else
|
||||
mModel = new InventoryItemModel(container);
|
||||
|
@ -368,7 +369,9 @@ namespace MWGui
|
|||
bool ContainerWindow::onTakeItem(const ItemStack &item, int count)
|
||||
{
|
||||
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr();
|
||||
if (dynamic_cast<PickpocketItemModel*>(mModel))
|
||||
// TODO: move to ItemModels
|
||||
if (dynamic_cast<PickpocketItemModel*>(mModel)
|
||||
&& !mPtr.getClass().getCreatureStats(mPtr).getKnockedDown())
|
||||
{
|
||||
MWMechanics::Pickpocket pickpocket(player, mPtr);
|
||||
if (pickpocket.pick(item.mBase, count))
|
||||
|
|
|
@ -6,16 +6,19 @@
|
|||
namespace MWGui
|
||||
{
|
||||
|
||||
PickpocketItemModel::PickpocketItemModel(const MWWorld::Ptr& thief, ItemModel *sourceModel)
|
||||
PickpocketItemModel::PickpocketItemModel(const MWWorld::Ptr& thief, ItemModel *sourceModel, bool hideItems)
|
||||
{
|
||||
mSourceModel = sourceModel;
|
||||
int chance = thief.getClass().getSkill(thief, ESM::Skill::Sneak);
|
||||
|
||||
mSourceModel->update();
|
||||
for (size_t i = 0; i<mSourceModel->getItemCount(); ++i)
|
||||
if (hideItems)
|
||||
{
|
||||
if (std::rand() / static_cast<float>(RAND_MAX) * 100 > chance)
|
||||
mHiddenItems.push_back(mSourceModel->getItem(i));
|
||||
for (size_t i = 0; i<mSourceModel->getItemCount(); ++i)
|
||||
{
|
||||
if (std::rand() / static_cast<float>(RAND_MAX) * 100 > chance)
|
||||
mHiddenItems.push_back(mSourceModel->getItem(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ namespace MWGui
|
|||
class PickpocketItemModel : public ProxyItemModel
|
||||
{
|
||||
public:
|
||||
PickpocketItemModel (const MWWorld::Ptr& thief, ItemModel* sourceModel);
|
||||
PickpocketItemModel (const MWWorld::Ptr& thief, ItemModel* sourceModel, bool hideItems=true);
|
||||
virtual ItemStack getItem (ModelIndex index);
|
||||
virtual size_t getItemCount();
|
||||
virtual void update();
|
||||
|
|
Loading…
Reference in a new issue