|
|
|
@ -13,6 +13,7 @@
|
|
|
|
|
#include "../mwworld/inventorystore.hpp"
|
|
|
|
|
#include "../mwworld/class.hpp"
|
|
|
|
|
#include "../mwworld/player.hpp"
|
|
|
|
|
#include "../mwworld/ptr.hpp"
|
|
|
|
|
|
|
|
|
|
#include "../mwbase/environment.hpp"
|
|
|
|
|
#include "../mwbase/world.hpp"
|
|
|
|
@ -829,8 +830,17 @@ namespace MWMechanics
|
|
|
|
|
mAI = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool MechanicsManager::isAllowedToUse (const MWWorld::Ptr& ptr, const MWWorld::CellRef& cellref, MWWorld::Ptr& victim)
|
|
|
|
|
bool MechanicsManager::isAllowedToUse (const MWWorld::Ptr& ptr, const MWWorld::ConstPtr& item, MWWorld::Ptr& victim)
|
|
|
|
|
{
|
|
|
|
|
const MWWorld::CellRef& cellref = item.getCellRef();
|
|
|
|
|
// there is no harm to use unlocked doors
|
|
|
|
|
if (item.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)
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
const std::string& owner = cellref.getOwner();
|
|
|
|
|
bool isOwned = !owner.empty() && owner != "player";
|
|
|
|
|
|
|
|
|
@ -872,7 +882,7 @@ namespace MWMechanics
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MWWorld::Ptr victim;
|
|
|
|
|
if (isAllowedToUse(ptr, bed.getCellRef(), victim))
|
|
|
|
|
if (isAllowedToUse(ptr, bed, victim))
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
if(commitCrime(ptr, victim, OT_SleepingInOwnedBed))
|
|
|
|
@ -887,7 +897,7 @@ namespace MWMechanics
|
|
|
|
|
void MechanicsManager::objectOpened(const MWWorld::Ptr &ptr, const MWWorld::Ptr &item)
|
|
|
|
|
{
|
|
|
|
|
MWWorld::Ptr victim;
|
|
|
|
|
if (isAllowedToUse(ptr, item.getCellRef(), victim))
|
|
|
|
|
if (isAllowedToUse(ptr, item, victim))
|
|
|
|
|
return;
|
|
|
|
|
commitCrime(ptr, victim, OT_Trespassing);
|
|
|
|
|
}
|
|
|
|
@ -1007,7 +1017,7 @@ namespace MWMechanics
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (isAllowedToUse(ptr, *ownerCellRef, victim))
|
|
|
|
|
if (isAllowedToUse(ptr, item, victim))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
Owner owner;
|
|
|
|
|