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));
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,18 +6,21 @@
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();
if (hideItems)
{
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));
}
}
}
ItemStack PickpocketItemModel::getItem (ModelIndex index)
{

@ -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…
Cancel
Save