mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-19 22:23:51 +00:00
Owned crosshair improvements (bug #2789)
This commit is contained in:
parent
b73ed5ccac
commit
7c80ddc9de
9 changed files with 41 additions and 8 deletions
|
@ -7,6 +7,8 @@
|
||||||
#include <set>
|
#include <set>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#include "../mwworld/ptr.hpp"
|
||||||
|
|
||||||
namespace osg
|
namespace osg
|
||||||
{
|
{
|
||||||
class Vec3f;
|
class Vec3f;
|
||||||
|
@ -231,7 +233,7 @@ namespace MWBase
|
||||||
/// Has the player stolen this item from the given owner?
|
/// Has the player stolen this item from the given owner?
|
||||||
virtual bool isItemStolenFrom(const std::string& itemid, const std::string& ownerid) = 0;
|
virtual bool isItemStolenFrom(const std::string& itemid, const std::string& ownerid) = 0;
|
||||||
|
|
||||||
virtual bool isAllowedToUse (const MWWorld::Ptr& ptr, const MWWorld::CellRef& cellref, MWWorld::Ptr& victim) = 0;
|
virtual bool isAllowedToUse (const MWWorld::Ptr& ptr, const MWWorld::ConstPtr& item, MWWorld::Ptr& victim) = 0;
|
||||||
|
|
||||||
/// Turn actor into werewolf or normal form.
|
/// Turn actor into werewolf or normal form.
|
||||||
virtual void setWerewolf(const MWWorld::Ptr& actor, bool werewolf) = 0;
|
virtual void setWerewolf(const MWWorld::Ptr& actor, bool werewolf) = 0;
|
||||||
|
|
|
@ -51,6 +51,11 @@ namespace MWClass
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Activator::isActivator() const
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool Activator::useAnim() const
|
bool Activator::useAnim() const
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -42,6 +42,8 @@ namespace MWClass
|
||||||
|
|
||||||
virtual bool useAnim() const;
|
virtual bool useAnim() const;
|
||||||
///< Whether or not to use animated variant of model (default false)
|
///< Whether or not to use animated variant of model (default false)
|
||||||
|
|
||||||
|
virtual bool isActivator() const;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -76,6 +76,11 @@ namespace MWClass
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Door::isDoor() const
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool Door::useAnim() const
|
bool Door::useAnim() const
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -20,6 +20,8 @@ namespace MWClass
|
||||||
|
|
||||||
virtual void insertObject(const MWWorld::Ptr& ptr, const std::string& model, MWPhysics::PhysicsSystem& physics) const;
|
virtual void insertObject(const MWWorld::Ptr& ptr, const std::string& model, MWPhysics::PhysicsSystem& physics) const;
|
||||||
|
|
||||||
|
virtual bool isDoor() const;
|
||||||
|
|
||||||
virtual bool useAnim() const;
|
virtual bool useAnim() const;
|
||||||
|
|
||||||
virtual std::string getName (const MWWorld::ConstPtr& ptr) const;
|
virtual std::string getName (const MWWorld::ConstPtr& ptr) const;
|
||||||
|
|
|
@ -359,12 +359,11 @@ namespace MWGui
|
||||||
{
|
{
|
||||||
if(!mFocusObject.isEmpty())
|
if(!mFocusObject.isEmpty())
|
||||||
{
|
{
|
||||||
const MWWorld::CellRef& cellref = mFocusObject.getCellRef();
|
|
||||||
MWWorld::Ptr ptr = MWMechanics::getPlayer();
|
MWWorld::Ptr ptr = MWMechanics::getPlayer();
|
||||||
MWWorld::Ptr victim;
|
MWWorld::Ptr victim;
|
||||||
|
|
||||||
MWBase::MechanicsManager* mm = MWBase::Environment::get().getMechanicsManager();
|
MWBase::MechanicsManager* mm = MWBase::Environment::get().getMechanicsManager();
|
||||||
bool allowed = mm->isAllowedToUse(ptr, cellref, victim);
|
bool allowed = mm->isAllowedToUse(ptr, mFocusObject, victim);
|
||||||
|
|
||||||
return !allowed;
|
return !allowed;
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
#include "../mwworld/inventorystore.hpp"
|
#include "../mwworld/inventorystore.hpp"
|
||||||
#include "../mwworld/class.hpp"
|
#include "../mwworld/class.hpp"
|
||||||
#include "../mwworld/player.hpp"
|
#include "../mwworld/player.hpp"
|
||||||
|
#include "../mwworld/ptr.hpp"
|
||||||
|
|
||||||
#include "../mwbase/environment.hpp"
|
#include "../mwbase/environment.hpp"
|
||||||
#include "../mwbase/world.hpp"
|
#include "../mwbase/world.hpp"
|
||||||
|
@ -829,8 +830,17 @@ namespace MWMechanics
|
||||||
mAI = true;
|
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();
|
const std::string& owner = cellref.getOwner();
|
||||||
bool isOwned = !owner.empty() && owner != "player";
|
bool isOwned = !owner.empty() && owner != "player";
|
||||||
|
|
||||||
|
@ -872,7 +882,7 @@ namespace MWMechanics
|
||||||
}
|
}
|
||||||
|
|
||||||
MWWorld::Ptr victim;
|
MWWorld::Ptr victim;
|
||||||
if (isAllowedToUse(ptr, bed.getCellRef(), victim))
|
if (isAllowedToUse(ptr, bed, victim))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if(commitCrime(ptr, victim, OT_SleepingInOwnedBed))
|
if(commitCrime(ptr, victim, OT_SleepingInOwnedBed))
|
||||||
|
@ -887,7 +897,7 @@ namespace MWMechanics
|
||||||
void MechanicsManager::objectOpened(const MWWorld::Ptr &ptr, const MWWorld::Ptr &item)
|
void MechanicsManager::objectOpened(const MWWorld::Ptr &ptr, const MWWorld::Ptr &item)
|
||||||
{
|
{
|
||||||
MWWorld::Ptr victim;
|
MWWorld::Ptr victim;
|
||||||
if (isAllowedToUse(ptr, item.getCellRef(), victim))
|
if (isAllowedToUse(ptr, item, victim))
|
||||||
return;
|
return;
|
||||||
commitCrime(ptr, victim, OT_Trespassing);
|
commitCrime(ptr, victim, OT_Trespassing);
|
||||||
}
|
}
|
||||||
|
@ -1007,7 +1017,7 @@ namespace MWMechanics
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isAllowedToUse(ptr, *ownerCellRef, victim))
|
if (isAllowedToUse(ptr, item, victim))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Owner owner;
|
Owner owner;
|
||||||
|
|
|
@ -199,7 +199,7 @@ namespace MWMechanics
|
||||||
virtual bool isItemStolenFrom(const std::string& itemid, const std::string& ownerid);
|
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?
|
/// @return is \a ptr allowed to take/use \a cellref or is it a crime?
|
||||||
virtual bool isAllowedToUse (const MWWorld::Ptr& ptr, const MWWorld::CellRef& cellref, MWWorld::Ptr& victim);
|
virtual bool isAllowedToUse (const MWWorld::Ptr& ptr, const MWWorld::ConstPtr& item, MWWorld::Ptr& victim);
|
||||||
|
|
||||||
virtual void setWerewolf(const MWWorld::Ptr& actor, bool werewolf);
|
virtual void setWerewolf(const MWWorld::Ptr& actor, bool werewolf);
|
||||||
virtual void applyWerewolfAcrobatics(const MWWorld::Ptr& actor);
|
virtual void applyWerewolfAcrobatics(const MWWorld::Ptr& actor);
|
||||||
|
|
|
@ -301,6 +301,10 @@ namespace MWWorld
|
||||||
|
|
||||||
virtual Ptr copyToCell(const ConstPtr &ptr, CellStore &cell, const ESM::Position &pos, int count) const;
|
virtual Ptr copyToCell(const ConstPtr &ptr, CellStore &cell, const ESM::Position &pos, int count) const;
|
||||||
|
|
||||||
|
virtual bool isActivator() const {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
virtual bool isActor() const {
|
virtual bool isActor() const {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -309,6 +313,10 @@ namespace MWWorld
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
virtual bool isDoor() const {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
virtual bool isBipedal(const MWWorld::ConstPtr& ptr) const;
|
virtual bool isBipedal(const MWWorld::ConstPtr& ptr) const;
|
||||||
virtual bool canFly(const MWWorld::ConstPtr& ptr) const;
|
virtual bool canFly(const MWWorld::ConstPtr& ptr) const;
|
||||||
virtual bool canSwim(const MWWorld::ConstPtr& ptr) const;
|
virtual bool canSwim(const MWWorld::ConstPtr& ptr) const;
|
||||||
|
|
Loading…
Reference in a new issue