Consider taking items from unconscious NPC as a theft

pull/303/head
Andrei Kortunov 7 years ago
parent 04452b0949
commit 34895157f9

@ -238,7 +238,7 @@ namespace MWBase
/// Has the player stolen this item from the given owner?
virtual bool isItemStolenFrom(const std::string& itemid, const std::string& ownerid) = 0;
virtual bool isAllowedToUse (const MWWorld::Ptr& ptr, const MWWorld::ConstPtr& item, MWWorld::Ptr& victim) = 0;
virtual bool isAllowedToUse (const MWWorld::Ptr& ptr, const MWWorld::Ptr& target, MWWorld::Ptr& victim) = 0;
/// Turn actor into werewolf or normal form.
virtual void setWerewolf(const MWWorld::Ptr& actor, bool werewolf) = 0;

@ -325,7 +325,7 @@ namespace MWGui
}
}
void ToolTips::setFocusObject(const MWWorld::ConstPtr& focus)
void ToolTips::setFocusObject(const MWWorld::Ptr& focus)
{
mFocusObject = focus;

@ -59,7 +59,7 @@ namespace MWGui
void setDelay(float delay);
void setFocusObject(const MWWorld::ConstPtr& focus);
void setFocusObject(const MWWorld::Ptr& focus);
void setFocusObjectScreenCoords(float min_x, float min_y, float max_x, float max_y);
///< set the screen-space position of the tooltip for focused object
@ -96,7 +96,7 @@ namespace MWGui
private:
MyGUI::Widget* mDynamicToolTipBox;
MWWorld::ConstPtr mFocusObject;
MWWorld::Ptr mFocusObject;
MyGUI::IntSize getToolTipViaPtr (int count, bool image=true);
///< @return requested tooltip size

@ -1573,7 +1573,7 @@ namespace MWGui
mMessageBoxManager->clear();
mToolTips->setFocusObject(MWWorld::ConstPtr());
mToolTips->setFocusObject(MWWorld::Ptr());
mSelectedSpell.clear();
mCustomMarkers.clear();

@ -840,17 +840,30 @@ namespace MWMechanics
mAI = true;
}
bool MechanicsManager::isAllowedToUse (const MWWorld::Ptr& ptr, const MWWorld::ConstPtr& item, MWWorld::Ptr& victim)
bool MechanicsManager::isAllowedToUse (const MWWorld::Ptr& ptr, const MWWorld::Ptr& target, MWWorld::Ptr& victim)
{
const MWWorld::CellRef& cellref = item.getCellRef();
const MWWorld::CellRef& cellref = target.getCellRef();
// there is no harm to use unlocked doors
if (item.getClass().isDoor() && cellref.getLockLevel() <= 0 && ptr.getCellRef().getTrap().empty())
if (target.getClass().isDoor() && cellref.getLockLevel() <= 0 && ptr.getCellRef().getTrap().empty())
return true;
// TODO: implement a better check to check if item is owned bed
if (item.getClass().isActivator() && item.getClass().getScript(item).compare(0, 3, "Bed") != 0)
// TODO: implement a better check to check if target is owned bed
if (target.getClass().isActivator() && target.getClass().getScript(target).compare(0, 3, "Bed") != 0)
return true;
if (target.getClass().isNpc())
{
if (target.getClass().getCreatureStats(target).isDead())
return true;
// check if a player tries to pickpocket a target NPC
if(ptr.getClass().getCreatureStats(ptr).getStance(MWMechanics::CreatureStats::Stance_Sneak)
|| target.getClass().getCreatureStats(target).getKnockedDown())
return false;
return true;
}
const std::string& owner = cellref.getOwner();
bool isOwned = !owner.empty() && owner != "player";

@ -204,8 +204,8 @@ namespace MWMechanics
/// Has the player stolen this item from the given owner?
virtual bool isItemStolenFrom(const std::string& itemid, const std::string& ownerid);
/// @return is \a ptr allowed to take/use \a cellref or is it a crime?
virtual bool isAllowedToUse (const MWWorld::Ptr& ptr, const MWWorld::ConstPtr& item, MWWorld::Ptr& victim);
/// @return is \a ptr allowed to take/use \a target or is it a crime?
virtual bool isAllowedToUse (const MWWorld::Ptr& ptr, const MWWorld::Ptr& target, MWWorld::Ptr& victim);
virtual void setWerewolf(const MWWorld::Ptr& actor, bool werewolf);
virtual void applyWerewolfAcrobatics(const MWWorld::Ptr& actor);

Loading…
Cancel
Save