mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-04-01 13:20:29 +00:00
Handle item owners during pickpocketing
This commit is contained in:
parent
3694b6ec90
commit
a02124f884
@ -140,7 +140,7 @@ namespace MWBase
|
|||||||
/// Utility to check if taking this item is illegal and calling commitCrime if so
|
/// Utility to check if taking this item is illegal and calling commitCrime if so
|
||||||
/// @param container The container the item is in; may be empty for an item in the world
|
/// @param container The container the item is in; may be empty for an item in the world
|
||||||
virtual void itemTaken (const MWWorld::Ptr& ptr, const MWWorld::Ptr& item, const MWWorld::Ptr& container,
|
virtual void itemTaken (const MWWorld::Ptr& ptr, const MWWorld::Ptr& item, const MWWorld::Ptr& container,
|
||||||
int count) = 0;
|
int count, bool alarm = true) = 0;
|
||||||
/// Utility to check if opening (i.e. unlocking) this object is illegal and calling commitCrime if so
|
/// Utility to check if opening (i.e. unlocking) this object is illegal and calling commitCrime if so
|
||||||
virtual void objectOpened (const MWWorld::Ptr& ptr, const MWWorld::Ptr& item) = 0;
|
virtual void objectOpened (const MWWorld::Ptr& ptr, const MWWorld::Ptr& item) = 0;
|
||||||
/// Attempt sleeping in a bed. If this is illegal, call commitCrime.
|
/// Attempt sleeping in a bed. If this is illegal, call commitCrime.
|
||||||
@ -250,7 +250,6 @@ namespace MWBase
|
|||||||
virtual void cleanupSummonedCreature(const MWWorld::Ptr& caster, int creatureActorId) = 0;
|
virtual void cleanupSummonedCreature(const MWWorld::Ptr& caster, int creatureActorId) = 0;
|
||||||
|
|
||||||
virtual void confiscateStolenItemToOwner(const MWWorld::Ptr &player, const MWWorld::Ptr &item, const MWWorld::Ptr& victim, int count) = 0;
|
virtual void confiscateStolenItemToOwner(const MWWorld::Ptr &player, const MWWorld::Ptr &item, const MWWorld::Ptr& victim, int count) = 0;
|
||||||
|
|
||||||
virtual bool isAttackPrepairing(const MWWorld::Ptr& ptr) = 0;
|
virtual bool isAttackPrepairing(const MWWorld::Ptr& ptr) = 0;
|
||||||
virtual bool isRunning(const MWWorld::Ptr& ptr) = 0;
|
virtual bool isRunning(const MWWorld::Ptr& ptr) = 0;
|
||||||
virtual bool isSneaking(const MWWorld::Ptr& ptr) = 0;
|
virtual bool isSneaking(const MWWorld::Ptr& ptr) = 0;
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
#include "../mwmechanics/creaturestats.hpp"
|
#include "../mwmechanics/creaturestats.hpp"
|
||||||
#include "../mwmechanics/pickpocket.hpp"
|
#include "../mwmechanics/pickpocket.hpp"
|
||||||
|
|
||||||
|
#include "../mwworld/containerstore.hpp"
|
||||||
#include "../mwworld/class.hpp"
|
#include "../mwworld/class.hpp"
|
||||||
|
|
||||||
#include "../mwbase/environment.hpp"
|
#include "../mwbase/environment.hpp"
|
||||||
@ -76,7 +77,6 @@ namespace MWGui
|
|||||||
void PickpocketItemModel::removeItem (const ItemStack &item, size_t count)
|
void PickpocketItemModel::removeItem (const ItemStack &item, size_t count)
|
||||||
{
|
{
|
||||||
ProxyItemModel::removeItem(item, count);
|
ProxyItemModel::removeItem(item, count);
|
||||||
/// \todo check if player is detected
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PickpocketItemModel::allowedToInsertItems() const
|
bool PickpocketItemModel::allowedToInsertItems() const
|
||||||
@ -115,7 +115,14 @@ namespace MWGui
|
|||||||
if (mActor.getClass().getCreatureStats(mActor).getKnockedDown())
|
if (mActor.getClass().getCreatureStats(mActor).getKnockedDown())
|
||||||
return mSourceModel->onTakeItem(item, count);
|
return mSourceModel->onTakeItem(item, count);
|
||||||
|
|
||||||
return stealItem(item, count);
|
bool success = stealItem(item, count);
|
||||||
|
if (success)
|
||||||
|
{
|
||||||
|
MWWorld::Ptr player = MWMechanics::getPlayer();
|
||||||
|
MWBase::Environment::get().getMechanicsManager()->itemTaken(player, item, mActor, count, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PickpocketItemModel::stealItem(const MWWorld::Ptr &item, int count)
|
bool PickpocketItemModel::stealItem(const MWWorld::Ptr &item, int count)
|
||||||
|
@ -1024,7 +1024,7 @@ namespace MWMechanics
|
|||||||
}
|
}
|
||||||
|
|
||||||
void MechanicsManager::itemTaken(const MWWorld::Ptr &ptr, const MWWorld::Ptr &item, const MWWorld::Ptr& container,
|
void MechanicsManager::itemTaken(const MWWorld::Ptr &ptr, const MWWorld::Ptr &item, const MWWorld::Ptr& container,
|
||||||
int count)
|
int count, bool alarm)
|
||||||
{
|
{
|
||||||
if (ptr != getPlayer())
|
if (ptr != getPlayer())
|
||||||
return;
|
return;
|
||||||
@ -1053,18 +1053,28 @@ namespace MWMechanics
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
Owner owner;
|
Owner owner;
|
||||||
owner.first = ownerCellRef->getOwner();
|
|
||||||
owner.second = false;
|
owner.second = false;
|
||||||
|
if (!container.isEmpty() && container.getClass().isActor())
|
||||||
|
{
|
||||||
|
// "container" is an actor inventory, so just take actor's ID
|
||||||
|
owner.first = ownerCellRef->getRefId();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
owner.first = ownerCellRef->getOwner();
|
||||||
if (owner.first.empty())
|
if (owner.first.empty())
|
||||||
{
|
{
|
||||||
owner.first = ownerCellRef->getFaction();
|
owner.first = ownerCellRef->getFaction();
|
||||||
owner.second = true;
|
owner.second = true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Misc::StringUtils::lowerCaseInPlace(owner.first);
|
Misc::StringUtils::lowerCaseInPlace(owner.first);
|
||||||
|
|
||||||
if (!Misc::StringUtils::ciEqual(item.getCellRef().getRefId(), MWWorld::ContainerStore::sGoldId))
|
if (!Misc::StringUtils::ciEqual(item.getCellRef().getRefId(), MWWorld::ContainerStore::sGoldId))
|
||||||
mStolenItems[Misc::StringUtils::lowerCase(item.getCellRef().getRefId())][owner] += count;
|
mStolenItems[Misc::StringUtils::lowerCase(item.getCellRef().getRefId())][owner] += count;
|
||||||
|
|
||||||
|
if (alarm)
|
||||||
commitCrime(ptr, victim, OT_Theft, item.getClass().getValue(item) * count);
|
commitCrime(ptr, victim, OT_Theft, item.getClass().getValue(item) * count);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -135,7 +135,7 @@ namespace MWMechanics
|
|||||||
/// Utility to check if taking this item is illegal and calling commitCrime if so
|
/// Utility to check if taking this item is illegal and calling commitCrime if so
|
||||||
/// @param container The container the item is in; may be empty for an item in the world
|
/// @param container The container the item is in; may be empty for an item in the world
|
||||||
virtual void itemTaken (const MWWorld::Ptr& ptr, const MWWorld::Ptr& item, const MWWorld::Ptr& container,
|
virtual void itemTaken (const MWWorld::Ptr& ptr, const MWWorld::Ptr& item, const MWWorld::Ptr& container,
|
||||||
int count);
|
int count, bool alarm = true);
|
||||||
/// Utility to check if opening (i.e. unlocking) this object is illegal and calling commitCrime if so
|
/// Utility to check if opening (i.e. unlocking) this object is illegal and calling commitCrime if so
|
||||||
virtual void objectOpened (const MWWorld::Ptr& ptr, const MWWorld::Ptr& item);
|
virtual void objectOpened (const MWWorld::Ptr& ptr, const MWWorld::Ptr& item);
|
||||||
/// Attempt sleeping in a bed. If this is illegal, call commitCrime.
|
/// Attempt sleeping in a bed. If this is illegal, call commitCrime.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user