Open inventory when activating an unconscious actor (Fixes #1848)

deque
scrawl 10 years ago
parent fc7ed05da8
commit 10a0e2434e

@ -863,9 +863,9 @@ namespace MWClass
return boost::shared_ptr<MWWorld::Action>(new MWWorld::ActionOpen(ptr, true)); return boost::shared_ptr<MWWorld::Action>(new MWWorld::ActionOpen(ptr, true));
if(ptr.getClass().getCreatureStats(ptr).getAiSequence().isInCombat()) if(ptr.getClass().getCreatureStats(ptr).getAiSequence().isInCombat())
return boost::shared_ptr<MWWorld::Action>(new MWWorld::FailedAction("#{sActorInCombat}")); 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 return boost::shared_ptr<MWWorld::Action>(new MWWorld::ActionOpen(ptr)); // stealing
// Can't talk to werewolfs // Can't talk to werewolfs
if(ptr.getClass().isNpc() && ptr.getClass().getNpcStats(ptr).isWerewolf()) if(ptr.getClass().isNpc() && ptr.getClass().getNpcStats(ptr).isWerewolf())
return boost::shared_ptr<MWWorld::Action> (new MWWorld::FailedAction("")); return boost::shared_ptr<MWWorld::Action> (new MWWorld::FailedAction(""));

@ -244,7 +244,8 @@ namespace MWGui
{ {
// we are stealing stuff // we are stealing stuff
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr(); 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 else
mModel = new InventoryItemModel(container); mModel = new InventoryItemModel(container);
@ -368,7 +369,9 @@ namespace MWGui
bool ContainerWindow::onTakeItem(const ItemStack &item, int count) bool ContainerWindow::onTakeItem(const ItemStack &item, int count)
{ {
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr(); 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); MWMechanics::Pickpocket pickpocket(player, mPtr);
if (pickpocket.pick(item.mBase, count)) if (pickpocket.pick(item.mBase, count))

@ -6,16 +6,19 @@
namespace MWGui namespace MWGui
{ {
PickpocketItemModel::PickpocketItemModel(const MWWorld::Ptr& thief, ItemModel *sourceModel) PickpocketItemModel::PickpocketItemModel(const MWWorld::Ptr& thief, ItemModel *sourceModel, bool hideItems)
{ {
mSourceModel = sourceModel; mSourceModel = sourceModel;
int chance = thief.getClass().getSkill(thief, ESM::Skill::Sneak); int chance = thief.getClass().getSkill(thief, ESM::Skill::Sneak);
mSourceModel->update(); mSourceModel->update();
for (size_t i = 0; i<mSourceModel->getItemCount(); ++i) if (hideItems)
{ {
if (std::rand() / static_cast<float>(RAND_MAX) * 100 > chance) for (size_t i = 0; i<mSourceModel->getItemCount(); ++i)
mHiddenItems.push_back(mSourceModel->getItem(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 class PickpocketItemModel : public ProxyItemModel
{ {
public: public:
PickpocketItemModel (const MWWorld::Ptr& thief, ItemModel* sourceModel); PickpocketItemModel (const MWWorld::Ptr& thief, ItemModel* sourceModel, bool hideItems=true);
virtual ItemStack getItem (ModelIndex index); virtual ItemStack getItem (ModelIndex index);
virtual size_t getItemCount(); virtual size_t getItemCount();
virtual void update(); virtual void update();

Loading…
Cancel
Save