2012-08-11 15:30:55 +00:00
|
|
|
#ifndef GAME_MWMECHANICS_MECHANICSMANAGERIMP_H
|
|
|
|
#define GAME_MWMECHANICS_MECHANICSMANAGERIMP_H
|
2010-07-26 09:15:38 +00:00
|
|
|
|
2012-08-11 15:30:55 +00:00
|
|
|
#include "../mwbase/mechanicsmanager.hpp"
|
2010-07-27 12:05:05 +00:00
|
|
|
|
|
|
|
#include "../mwworld/ptr.hpp"
|
|
|
|
|
2010-07-27 13:59:41 +00:00
|
|
|
#include "creaturestats.hpp"
|
2010-09-21 15:42:07 +00:00
|
|
|
#include "npcstats.hpp"
|
2015-04-25 13:19:17 +00:00
|
|
|
#include "objects.hpp"
|
|
|
|
#include "actors.hpp"
|
2010-07-27 13:59:41 +00:00
|
|
|
|
2012-07-03 11:55:53 +00:00
|
|
|
namespace MWWorld
|
|
|
|
{
|
|
|
|
class CellStore;
|
|
|
|
}
|
|
|
|
|
2010-07-26 09:15:38 +00:00
|
|
|
namespace MWMechanics
|
|
|
|
{
|
2012-08-11 15:30:55 +00:00
|
|
|
class MechanicsManager : public MWBase::MechanicsManager
|
2010-07-26 09:15:38 +00:00
|
|
|
{
|
2010-07-27 13:59:41 +00:00
|
|
|
MWWorld::Ptr mWatched;
|
2016-06-27 12:17:06 +00:00
|
|
|
|
|
|
|
AttributeValue mWatchedAttributes[8];
|
|
|
|
SkillValue mWatchedSkills[27];
|
|
|
|
|
|
|
|
DynamicStat<float> mWatchedHealth;
|
|
|
|
DynamicStat<float> mWatchedMagicka;
|
|
|
|
DynamicStat<float> mWatchedFatigue;
|
|
|
|
|
|
|
|
float mWatchedTimeToStartDrowning;
|
|
|
|
|
2014-09-13 00:56:06 +00:00
|
|
|
bool mWatchedStatsEmpty;
|
2010-09-15 12:33:02 +00:00
|
|
|
bool mUpdatePlayer;
|
2010-09-26 08:01:30 +00:00
|
|
|
bool mClassSelected;
|
|
|
|
bool mRaceSelected;
|
2013-11-18 22:03:44 +00:00
|
|
|
bool mAI;///< is AI active?
|
2013-01-29 07:39:11 +00:00
|
|
|
|
2015-04-25 13:19:17 +00:00
|
|
|
Objects mObjects;
|
|
|
|
Actors mActors;
|
2010-09-13 20:59:28 +00:00
|
|
|
|
2015-02-04 20:18:43 +00:00
|
|
|
typedef std::pair<std::string, bool> Owner; // < Owner id, bool isFaction >
|
|
|
|
typedef std::map<Owner, int> OwnerMap; // < Owner, number of stolen items with this id from this owner >
|
|
|
|
typedef std::map<std::string, OwnerMap> StolenItemsMap;
|
|
|
|
StolenItemsMap mStolenItems;
|
|
|
|
|
2013-11-14 13:41:10 +00:00
|
|
|
public:
|
|
|
|
|
2010-09-15 11:31:26 +00:00
|
|
|
void buildPlayer();
|
|
|
|
///< build player according to stored class/race/birthsign information. Will
|
|
|
|
/// default to the values of the ESM::NPC object, if no explicit information is given.
|
|
|
|
|
2012-08-11 15:30:55 +00:00
|
|
|
MechanicsManager();
|
2010-09-13 20:59:28 +00:00
|
|
|
|
2013-01-29 07:39:11 +00:00
|
|
|
virtual void add (const MWWorld::Ptr& ptr);
|
|
|
|
///< Register an object for management
|
2010-07-27 12:43:46 +00:00
|
|
|
|
2013-01-29 07:39:11 +00:00
|
|
|
virtual void remove (const MWWorld::Ptr& ptr);
|
|
|
|
///< Deregister an object for management
|
2010-09-13 20:59:28 +00:00
|
|
|
|
2013-02-25 17:57:34 +00:00
|
|
|
virtual void updateCell(const MWWorld::Ptr &old, const MWWorld::Ptr &ptr);
|
2013-01-29 08:19:24 +00:00
|
|
|
///< Moves an object to a new cell
|
|
|
|
|
2013-01-29 07:39:11 +00:00
|
|
|
virtual void drop(const MWWorld::CellStore *cellStore);
|
|
|
|
///< Deregister all objects in the given cell.
|
2010-09-13 20:59:28 +00:00
|
|
|
|
2013-01-29 07:39:11 +00:00
|
|
|
virtual void watchActor(const MWWorld::Ptr& ptr);
|
2010-07-27 13:59:41 +00:00
|
|
|
///< On each update look for changes in a previously registered actor and update the
|
|
|
|
/// GUI accordingly.
|
2010-09-13 20:59:28 +00:00
|
|
|
|
2013-01-16 16:22:38 +00:00
|
|
|
virtual void update (float duration, bool paused);
|
2013-01-29 07:39:11 +00:00
|
|
|
///< Update objects
|
2012-03-30 15:01:55 +00:00
|
|
|
///
|
|
|
|
/// \param paused In game type does not currently advance (this usually means some GUI
|
|
|
|
/// component is up).
|
2010-09-13 20:59:28 +00:00
|
|
|
|
2013-11-19 15:42:24 +00:00
|
|
|
virtual void advanceTime (float duration);
|
|
|
|
|
2012-08-11 15:30:55 +00:00
|
|
|
virtual void setPlayerName (const std::string& name);
|
2010-09-13 20:59:28 +00:00
|
|
|
///< Set player name.
|
|
|
|
|
2012-11-10 07:41:12 +00:00
|
|
|
virtual void setPlayerRace (const std::string& id, bool male, const std::string &head, const std::string &hair);
|
2010-09-13 20:59:28 +00:00
|
|
|
///< Set player race.
|
|
|
|
|
2012-08-11 15:30:55 +00:00
|
|
|
virtual void setPlayerBirthsign (const std::string& id);
|
2010-09-13 20:59:28 +00:00
|
|
|
///< Set player birthsign.
|
|
|
|
|
2012-08-11 15:30:55 +00:00
|
|
|
virtual void setPlayerClass (const std::string& id);
|
2010-09-13 20:59:28 +00:00
|
|
|
///< Set player class to stock class.
|
|
|
|
|
2012-08-11 15:30:55 +00:00
|
|
|
virtual void setPlayerClass (const ESM::Class& class_);
|
2010-09-13 20:59:28 +00:00
|
|
|
///< Set player class to custom class.
|
2012-09-21 15:53:16 +00:00
|
|
|
|
2014-01-14 01:20:13 +00:00
|
|
|
virtual void rest(bool sleep);
|
|
|
|
///< If the player is sleeping or waiting, this should be called every hour.
|
|
|
|
/// @param sleep is the player sleeping or waiting?
|
2012-11-05 10:07:43 +00:00
|
|
|
|
2014-01-14 01:52:34 +00:00
|
|
|
virtual int getHoursToRest() const;
|
|
|
|
///< Calculate how many hours the player needs to rest in order to be fully healed
|
|
|
|
|
2012-11-09 13:42:09 +00:00
|
|
|
virtual int getBarterOffer(const MWWorld::Ptr& ptr,int basePrice, bool buying);
|
2012-11-05 10:07:43 +00:00
|
|
|
///< This is used by every service to determine the price of objects given the trading skills of the player and NPC.
|
|
|
|
|
2016-06-21 16:39:21 +00:00
|
|
|
virtual int getDerivedDisposition(const MWWorld::Ptr& ptr, bool addTemporaryDispositionChange = true);
|
2012-11-05 10:07:43 +00:00
|
|
|
///< Calculate the diposition of an NPC toward the player.
|
2012-11-08 22:16:40 +00:00
|
|
|
|
2012-10-27 09:33:18 +00:00
|
|
|
virtual int countDeaths (const std::string& id) const;
|
|
|
|
///< Return the number of deaths for actors with the given ID.
|
2013-11-19 08:10:48 +00:00
|
|
|
|
2016-03-17 23:39:19 +00:00
|
|
|
virtual void getPersuasionDispositionChange (const MWWorld::Ptr& npc, PersuasionType type, bool& success, float& tempChange, float& permChange);
|
2012-11-09 23:29:36 +00:00
|
|
|
///< Perform a persuasion action on NPC
|
2013-01-17 01:53:18 +00:00
|
|
|
|
2014-01-06 23:51:09 +00:00
|
|
|
/// Check if \a observer is potentially aware of \a ptr. Does not do a line of sight check!
|
|
|
|
virtual bool awarenessCheck (const MWWorld::Ptr& ptr, const MWWorld::Ptr& observer);
|
|
|
|
|
2014-05-05 22:13:31 +00:00
|
|
|
/// Makes \a ptr fight \a target. Also shouts a combat taunt.
|
|
|
|
virtual void startCombat (const MWWorld::Ptr& ptr, const MWWorld::Ptr& target);
|
|
|
|
|
2014-01-07 18:49:16 +00:00
|
|
|
/**
|
2014-06-16 02:03:53 +00:00
|
|
|
* @note victim may be empty
|
2014-01-07 18:49:16 +00:00
|
|
|
* @param arg Depends on \a type, e.g. for Theft, the value of the item that was stolen.
|
2014-12-19 20:45:26 +00:00
|
|
|
* @param victimAware Is the victim already aware of the crime?
|
|
|
|
* If this parameter is false, it will be determined by a line-of-sight and awareness check.
|
|
|
|
* @return was the crime seen?
|
2014-01-07 18:49:16 +00:00
|
|
|
*/
|
2014-01-08 16:19:43 +00:00
|
|
|
virtual bool commitCrime (const MWWorld::Ptr& ptr, const MWWorld::Ptr& victim,
|
2014-12-19 20:45:26 +00:00
|
|
|
OffenseType type, int arg=0, bool victimAware=false);
|
2014-09-26 20:08:07 +00:00
|
|
|
/// @return false if the attack was considered a "friendly hit" and forgiven
|
|
|
|
virtual bool actorAttacked (const MWWorld::Ptr& victim, const MWWorld::Ptr& attacker);
|
2015-07-18 18:39:45 +00:00
|
|
|
|
|
|
|
/// Notify that actor was killed, add a murder bounty if applicable
|
|
|
|
/// @note No-op for non-player attackers
|
|
|
|
virtual void actorKilled (const MWWorld::Ptr& victim, const MWWorld::Ptr& attacker);
|
|
|
|
|
2014-01-07 18:49:16 +00:00
|
|
|
/// Utility to check if taking this item is illegal and calling commitCrime if so
|
2015-02-03 22:43:56 +00:00
|
|
|
/// @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);
|
2014-01-10 20:26:24 +00:00
|
|
|
/// 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);
|
2014-01-08 16:19:43 +00:00
|
|
|
/// Attempt sleeping in a bed. If this is illegal, call commitCrime.
|
2014-04-25 02:47:45 +00:00
|
|
|
/// @return was it illegal, and someone saw you doing it? Also returns fail when enemies are nearby
|
2014-01-08 16:19:43 +00:00
|
|
|
virtual bool sleepInBed (const MWWorld::Ptr& ptr, const MWWorld::Ptr& bed);
|
2014-01-07 18:49:16 +00:00
|
|
|
|
2013-12-07 12:17:28 +00:00
|
|
|
virtual void forceStateUpdate(const MWWorld::Ptr &ptr);
|
2013-04-25 14:08:11 +00:00
|
|
|
|
2015-07-29 18:15:06 +00:00
|
|
|
/// Attempt to play an animation group
|
|
|
|
/// @return Success or error
|
2016-07-30 17:24:03 +00:00
|
|
|
virtual bool playAnimationGroup(const MWWorld::Ptr& ptr, const std::string& groupName, int mode, int number, bool persist=false);
|
2013-12-07 12:17:28 +00:00
|
|
|
virtual void skipAnimation(const MWWorld::Ptr& ptr);
|
|
|
|
virtual bool checkAnimationPlaying(const MWWorld::Ptr& ptr, const std::string &groupName);
|
2016-07-30 17:24:03 +00:00
|
|
|
virtual void persistAnimationStates();
|
2013-11-17 22:15:57 +00:00
|
|
|
|
|
|
|
/// Update magic effects for an actor. Usually done automatically once per frame, but if we're currently
|
|
|
|
/// paused we may want to do it manually (after equipping permanent enchantment)
|
|
|
|
virtual void updateMagicEffects (const MWWorld::Ptr& ptr);
|
|
|
|
|
2015-06-01 19:41:13 +00:00
|
|
|
virtual void getObjectsInRange (const osg::Vec3f& position, float radius, std::vector<MWWorld::Ptr>& objects);
|
|
|
|
virtual void getActorsInRange(const osg::Vec3f &position, float radius, std::vector<MWWorld::Ptr> &objects);
|
2014-01-20 12:00:43 +00:00
|
|
|
|
2015-12-06 22:32:49 +00:00
|
|
|
virtual std::list<MWWorld::Ptr> getActorsSidingWith(const MWWorld::Ptr& actor);
|
2015-12-19 14:11:07 +00:00
|
|
|
virtual std::list<MWWorld::Ptr> getActorsFollowing(const MWWorld::Ptr& actor);
|
2014-12-09 15:02:07 +00:00
|
|
|
virtual std::list<int> getActorsFollowingIndices(const MWWorld::Ptr& actor);
|
2014-01-28 11:33:31 +00:00
|
|
|
|
2014-04-25 02:47:45 +00:00
|
|
|
virtual std::list<MWWorld::Ptr> getActorsFighting(const MWWorld::Ptr& actor);
|
2016-06-06 23:53:16 +00:00
|
|
|
virtual std::list<MWWorld::Ptr> getEnemiesNearby(const MWWorld::Ptr& actor);
|
2014-04-25 02:47:45 +00:00
|
|
|
|
2016-12-20 11:38:51 +00:00
|
|
|
/// Recursive version of getActorsFollowing
|
|
|
|
virtual void getActorsFollowing(const MWWorld::Ptr& actor, std::set<MWWorld::Ptr>& out);
|
|
|
|
/// Recursive version of getActorsSidingWith
|
|
|
|
virtual void getActorsSidingWith(const MWWorld::Ptr& actor, std::set<MWWorld::Ptr>& out);
|
|
|
|
|
2014-03-26 18:55:52 +00:00
|
|
|
virtual bool toggleAI();
|
2013-12-07 12:17:28 +00:00
|
|
|
virtual bool isAIActive();
|
|
|
|
|
|
|
|
virtual void playerLoaded();
|
2014-06-12 23:24:58 +00:00
|
|
|
|
|
|
|
virtual int countSavedGameRecords() const;
|
|
|
|
|
|
|
|
virtual void write (ESM::ESMWriter& writer, Loading::Listener& listener) const;
|
|
|
|
|
2015-01-22 18:04:59 +00:00
|
|
|
virtual void readRecord (ESM::ESMReader& reader, uint32_t type);
|
2014-06-12 23:24:58 +00:00
|
|
|
|
|
|
|
virtual void clear();
|
2014-06-16 17:34:53 +00:00
|
|
|
|
2014-12-21 01:45:37 +00:00
|
|
|
virtual bool isAggressive (const MWWorld::Ptr& ptr, const MWWorld::Ptr& target);
|
2014-07-21 18:37:14 +00:00
|
|
|
|
2014-09-05 15:17:45 +00:00
|
|
|
virtual void keepPlayerAlive();
|
2014-12-12 15:49:22 +00:00
|
|
|
|
|
|
|
virtual bool isReadyToBlock (const MWWorld::Ptr& ptr) const;
|
2014-12-19 20:45:26 +00:00
|
|
|
|
2015-02-04 20:18:43 +00:00
|
|
|
virtual void confiscateStolenItems (const MWWorld::Ptr& player, const MWWorld::Ptr& targetContainer);
|
|
|
|
|
|
|
|
/// List the owners that the player has stolen this item from (the owner can be an NPC or a faction).
|
|
|
|
/// <Owner, item count>
|
|
|
|
virtual std::vector<std::pair<std::string, int> > getStolenItemOwners(const std::string& itemid);
|
|
|
|
|
|
|
|
/// Has the player stolen this item from the given owner?
|
|
|
|
virtual bool isItemStolenFrom(const std::string& itemid, const std::string& ownerid);
|
2015-07-17 14:32:35 +00:00
|
|
|
|
|
|
|
/// @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);
|
2015-02-04 20:18:43 +00:00
|
|
|
|
2015-12-26 17:22:21 +00:00
|
|
|
virtual void setWerewolf(const MWWorld::Ptr& actor, bool werewolf);
|
|
|
|
virtual void applyWerewolfAcrobatics(const MWWorld::Ptr& actor);
|
|
|
|
|
2016-06-12 00:43:33 +00:00
|
|
|
virtual void cleanupSummonedCreature(const MWWorld::Ptr& caster, int creatureActorId);
|
|
|
|
|
2014-12-19 20:45:26 +00:00
|
|
|
private:
|
|
|
|
void reportCrime (const MWWorld::Ptr& ptr, const MWWorld::Ptr& victim,
|
|
|
|
OffenseType type, int arg=0);
|
2015-02-04 20:18:43 +00:00
|
|
|
|
2015-07-17 14:32:35 +00:00
|
|
|
|
2010-07-26 09:15:38 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|