forked from teamnwah/openmw-tes3coop
parent
2bf1dd8f46
commit
aa6ebcd75c
6 changed files with 30 additions and 8 deletions
|
@ -129,7 +129,9 @@ namespace MWBase
|
|||
/// @return false if the attack was considered a "friendly hit" and forgiven
|
||||
virtual bool actorAttacked (const MWWorld::Ptr& victim, const MWWorld::Ptr& attacker) = 0;
|
||||
/// Utility to check if taking this item is illegal and calling commitCrime if so
|
||||
virtual void itemTaken (const MWWorld::Ptr& ptr, const MWWorld::Ptr& item, int count) = 0;
|
||||
/// @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,
|
||||
int count) = 0;
|
||||
/// 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;
|
||||
/// Attempt sleeping in a bed. If this is illegal, call commitCrime.
|
||||
|
|
|
@ -285,7 +285,7 @@ namespace MWGui
|
|||
if (mPtr.getClass().isActor() && mPtr.getClass().getCreatureStats(mPtr).isDead())
|
||||
return true;
|
||||
else
|
||||
MWBase::Environment::get().getMechanicsManager()->itemTaken(player, item.mBase, count);
|
||||
MWBase::Environment::get().getMechanicsManager()->itemTaken(player, item.mBase, mPtr, count);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -624,7 +624,7 @@ namespace MWGui
|
|||
throw std::runtime_error("Added item not found");
|
||||
mDragAndDrop->startDrag(i, mSortModel, mTradeModel, mItemView, count);
|
||||
|
||||
MWBase::Environment::get().getMechanicsManager()->itemTaken(player, newObject, count);
|
||||
MWBase::Environment::get().getMechanicsManager()->itemTaken(player, newObject, MWWorld::Ptr(), count);
|
||||
|
||||
if (MWBase::Environment::get().getWindowManager()->getSpellWindow())
|
||||
MWBase::Environment::get().getWindowManager()->getSpellWindow()->updateSpells();
|
||||
|
|
|
@ -936,11 +936,29 @@ namespace MWMechanics
|
|||
commitCrime(ptr, victim, OT_Trespassing);
|
||||
}
|
||||
|
||||
void MechanicsManager::itemTaken(const MWWorld::Ptr &ptr, const MWWorld::Ptr &item, int count)
|
||||
void MechanicsManager::itemTaken(const MWWorld::Ptr &ptr, const MWWorld::Ptr &item, const MWWorld::Ptr& container,
|
||||
int count)
|
||||
{
|
||||
MWWorld::Ptr victim;
|
||||
|
||||
if (!container.isEmpty())
|
||||
{
|
||||
// Inherit the owner of the container
|
||||
if (isAllowedToUse(ptr, container, victim))
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (isAllowedToUse(ptr, item, victim))
|
||||
return;
|
||||
|
||||
if (!item.getCellRef().hasContentFile())
|
||||
{
|
||||
// this is a manually placed item, which means it was already stolen
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
commitCrime(ptr, victim, OT_Theft, item.getClass().getValue(item) * count);
|
||||
}
|
||||
|
||||
|
|
|
@ -121,7 +121,9 @@ namespace MWMechanics
|
|||
/// @return false if the attack was considered a "friendly hit" and forgiven
|
||||
virtual bool actorAttacked (const MWWorld::Ptr& victim, const MWWorld::Ptr& attacker);
|
||||
/// Utility to check if taking this item is illegal and calling commitCrime if so
|
||||
virtual void itemTaken (const MWWorld::Ptr& ptr, const MWWorld::Ptr& item, int count);
|
||||
/// @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,
|
||||
int count);
|
||||
/// 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);
|
||||
/// Attempt sleeping in a bed. If this is illegal, call commitCrime.
|
||||
|
|
|
@ -16,7 +16,7 @@ namespace MWWorld
|
|||
void ActionTake::executeImp (const Ptr& actor)
|
||||
{
|
||||
MWBase::Environment::get().getMechanicsManager()->itemTaken(
|
||||
actor, getTarget(), getTarget().getRefData().getCount());
|
||||
actor, getTarget(), MWWorld::Ptr(), getTarget().getRefData().getCount());
|
||||
actor.getClass().getContainerStore (actor).add (getTarget(), getTarget().getRefData().getCount(), actor);
|
||||
MWBase::Environment::get().getWorld()->deleteObject (getTarget());
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue