|
|
|
@ -840,17 +840,33 @@ 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;
|
|
|
|
|
|
|
|
|
|
if (target.getClass().getCreatureStats(target).getAiSequence().isInCombat())
|
|
|
|
|
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";
|
|
|
|
|
|
|
|
|
@ -1084,6 +1100,10 @@ namespace MWMechanics
|
|
|
|
|
if (it->getClass().getCreatureStats(*it).isDead())
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
// Unconsious actor can not report about crime
|
|
|
|
|
if (it->getClass().getCreatureStats(*it).getKnockedDown())
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
if ((*it == victim && victimAware)
|
|
|
|
|
|| (MWBase::Environment::get().getWorld()->getLOS(player, *it) && awarenessCheck(player, *it) )
|
|
|
|
|
// Murder crime can be reported even if no one saw it (hearing is enough, I guess).
|
|
|
|
@ -1195,12 +1215,16 @@ namespace MWMechanics
|
|
|
|
|
// Tell everyone (including the original reporter) in alarm range
|
|
|
|
|
for (std::vector<MWWorld::Ptr>::iterator it = neighbors.begin(); it != neighbors.end(); ++it)
|
|
|
|
|
{
|
|
|
|
|
if ( *it == player
|
|
|
|
|
if (*it == player
|
|
|
|
|
|| !it->getClass().isNpc() || it->getClass().getCreatureStats(*it).isDead()) continue;
|
|
|
|
|
|
|
|
|
|
if (it->getClass().getCreatureStats(*it).getAiSequence().isInCombat(victim))
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
// Unconsious actor can not report about crime and should not become hostile
|
|
|
|
|
if (it->getClass().getCreatureStats(*it).getKnockedDown())
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
// Player's followers should not attack player, or try to arrest him
|
|
|
|
|
if (it->getClass().getCreatureStats(*it).getAiSequence().hasPackage(AiPackage::TypeIdFollow))
|
|
|
|
|
{
|
|
|
|
|