OpenMW
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Classes | Typedefs | Enumerations | Functions | Variables
MWMechanics Namespace Reference

Game mechanics and NPC-AI. More...

Classes

class  DynamicStat
 
class  ActiveSpells
 Lasting spell effects. More...
 
class  Actor
 Holds temporary state for an actor that will be discarded when the actor leaves the scene. More...
 
class  SoulTrap
 
class  ExpiryVisitor
 
class  Actors
 
class  AiActivate
 Causes actor to walk to activatable object and activate it. More...
 
class  AiAvoidDoor
 AiPackage to have an actor avoid an opening door. More...
 
struct  AiCombatStorage
 This class holds the variables AiCombat needs which are deleted if the package becomes inactive. More...
 
class  AiCombat
 Causes the actor to fight another actor. More...
 
class  Action
 
class  ActionFlee
 
class  ActionSpell
 
class  ActionEnchantedItem
 
class  ActionPotion
 
class  ActionWeapon
 
class  AiEscort
 AI Package to have an NPC lead the player to a specific point. More...
 
class  AiFace
 AiPackage which makes an actor face a certain direction. More...
 
struct  AiFollowStorage
 
class  AiFollow
 AiPackage for an actor to follow another actor/the PC. More...
 
class  AiPackage
 Base class for AI packages. More...
 
class  AiPursue
 Makes the actor very closely follow the actor. More...
 
class  DerivedClassStorage
 stores one object of any class derived from Base. Requesting a certain derived class via get() either returns the stored object if it has the correct type or otherwise replaces it with an object of the requested type. More...
 
class  AiSequence
 Sequence of AI-packages for a single actor. More...
 
struct  AiTemporaryBase
 base class for the temporary storage of AiPackages. More...
 
class  AiTravel
 Causes the AI to travel to the specified point. More...
 
struct  AiWanderStorage
 This class holds the variables AiWander needs which are deleted if the package becomes inactive. More...
 
class  AiWander
 Causes the Actor to wander within a specified range. More...
 
class  Alchemy
 Potion creation via alchemy skill. More...
 
struct  SchoolCaps
 
struct  StateInfo
 
class  FindCharState
 
struct  WeaponInfo
 
class  FindWeaponType
 
class  CharacterController
 
class  CoordinateConverter
 convert coordinates between world and local cell More...
 
class  CreatureStats
 Common creature stats. More...
 
class  Enchanting
 
struct  EffectKey
 
struct  EffectParam
 
struct  EffectSourceVisitor
 
class  MagicEffects
 Effects currently affecting a NPC or creature. More...
 
class  MechanicsManager
 
struct  Movement
 Desired movement for an actor. More...
 
class  NpcStats
 Additional stats for NPCs. More...
 
class  Objects
 
class  ObstacleCheck
 
class  PathFinder
 
class  PathgridGraph
 
class  Pickpocket
 
class  Repair
 
class  Security
 implementation of Security skill More...
 
class  CastSpell
 
class  Spells
 Spell list. More...
 
class  Stat
 
class  AttributeValue
 
class  SkillValue
 
struct  UpdateSummonedCreatures
 
class  Trading
 

Typedefs

typedef DerivedClassStorage
< AiTemporaryBase
AiState
 Container for AI package status. More...
 

Enumerations

enum  Priority {
  Priority_Default, Priority_WeaponLowerBody, Priority_SneakIdleLowerBody, Priority_SwimIdle,
  Priority_Jump, Priority_Movement, Priority_Hit, Priority_Weapon,
  Priority_Block, Priority_Knockdown, Priority_Torch, Priority_Storm,
  Priority_Death, Num_Priorities
}
 
enum  CharacterState {
  CharState_None, CharState_SpecialIdle, CharState_Idle, CharState_Idle2,
  CharState_Idle3, CharState_Idle4, CharState_Idle5, CharState_Idle6,
  CharState_Idle7, CharState_Idle8, CharState_Idle9, CharState_IdleSwim,
  CharState_IdleSneak, CharState_WalkForward, CharState_WalkBack, CharState_WalkLeft,
  CharState_WalkRight, CharState_SwimWalkForward, CharState_SwimWalkBack, CharState_SwimWalkLeft,
  CharState_SwimWalkRight, CharState_RunForward, CharState_RunBack, CharState_RunLeft,
  CharState_RunRight, CharState_SwimRunForward, CharState_SwimRunBack, CharState_SwimRunLeft,
  CharState_SwimRunRight, CharState_SneakForward, CharState_SneakBack, CharState_SneakLeft,
  CharState_SneakRight, CharState_TurnLeft, CharState_TurnRight, CharState_Jump,
  CharState_Death1, CharState_Death2, CharState_Death3, CharState_Death4,
  CharState_Death5, CharState_SwimDeath, CharState_DeathKnockDown, CharState_DeathKnockOut,
  CharState_Hit, CharState_KnockDown, CharState_KnockOut, CharState_Block
}
 
enum  WeaponType {
  WeapType_None, WeapType_HandToHand, WeapType_OneHand, WeapType_TwoHand,
  WeapType_TwoWide, WeapType_BowAndArrow, WeapType_Crossbow, WeapType_Thrown,
  WeapType_PickProbe, WeapType_Spell
}
 
enum  UpperBodyCharacterState {
  UpperCharState_Nothing, UpperCharState_EquipingWeap, UpperCharState_UnEquipingWeap, UpperCharState_WeapEquiped,
  UpperCharState_StartToMinAttack, UpperCharState_MinAttackToMaxAttack, UpperCharState_MaxAttackToMinHit, UpperCharState_MinHitToHit,
  UpperCharState_FollowStartToFollowStop, UpperCharState_CastingSpell
}
 
enum  JumpingState { JumpState_None, JumpState_InAir, JumpState_Landing }
 
enum  DrawState_ { DrawState_Nothing = 0, DrawState_Weapon = 1, DrawState_Spell = 2 }
 

Functions

MWWorld::Ptr getPlayer ()
 
bool isPlayerInCombat ()
 
float ratePotion (const MWWorld::Ptr &item, const MWWorld::Ptr &actor)
 
float rateWeapon (const MWWorld::Ptr &item, const MWWorld::Ptr &actor, const MWWorld::Ptr &enemy, int type, float arrowRating, float boltRating)
 
float rateSpell (const ESM::Spell *spell, const MWWorld::Ptr &actor, const MWWorld::Ptr &enemy)
 
float rateMagicItem (const MWWorld::Ptr &ptr, const MWWorld::Ptr &actor, const MWWorld::Ptr &enemy)
 
float rateEffect (const ESM::ENAMstruct &effect, const MWWorld::Ptr &actor, const MWWorld::Ptr &enemy)
 
float rateEffects (const ESM::EffectList &list, const MWWorld::Ptr &actor, const MWWorld::Ptr &enemy)
 
boost::shared_ptr< ActionprepareNextAction (const MWWorld::Ptr &actor, const MWWorld::Ptr &enemy)
 
float getDistanceMinusHalfExtents (const MWWorld::Ptr &actor1, const MWWorld::Ptr &actor2, bool minusZDist)
 
float getMaxAttackDistance (const MWWorld::Ptr &actor)
 
bool canFight (const MWWorld::Ptr &actor, const MWWorld::Ptr &enemy)
 
float vanillaRateSpell (const ESM::Spell *spell, const MWWorld::Ptr &actor, const MWWorld::Ptr &enemy)
 
float vanillaRateWeaponAndAmmo (const MWWorld::Ptr &weapon, const MWWorld::Ptr &ammo, const MWWorld::Ptr &actor, const MWWorld::Ptr &enemy)
 
float vanillaRateFlee (const MWWorld::Ptr &actor, const MWWorld::Ptr &enemy)
 
bool makeFleeDecision (const MWWorld::Ptr &actor, const MWWorld::Ptr &enemy, float antiFleeRating)
 
bool isActualAiPackage (int packageTypeId)
 
std::vector< std::string > autoCalcNpcSpells (const int *actorSkills, const int *actorAttributes, const ESM::Race *race)
 
std::vector< std::string > autoCalcPlayerSpells (const int *actorSkills, const int *actorAttributes, const ESM::Race *race)
 
bool attrSkillCheck (const ESM::Spell *spell, const int *actorSkills, const int *actorAttributes)
 
ESM::Skill::SkillEnum mapSchoolToSkill (int school)
 
void calcWeakestSchool (const ESM::Spell *spell, const int *actorSkills, int &effectiveSchool, float &skillTerm)
 
float calcAutoCastChance (const ESM::Spell *spell, const int *actorSkills, const int *actorAttributes, int effectiveSchool)
 
void getWeaponGroup (WeaponType weaptype, std::string &group)
 
MWWorld::ContainerStoreIterator getActiveWeapon (CreatureStats &stats, MWWorld::InventoryStore &inv, WeaponType *weaptype)
 
void split (const std::string &s, char delim, std::vector< std::string > &elems)
 
bool applyOnStrikeEnchantment (const MWWorld::Ptr &attacker, const MWWorld::Ptr &victim, const MWWorld::Ptr &object, const osg::Vec3f &hitPosition, const bool fromProjectile)
 
bool blockMeleeAttack (const MWWorld::Ptr &attacker, const MWWorld::Ptr &blocker, const MWWorld::Ptr &weapon, float damage, float attackStrength)
 
void resistNormalWeapon (const MWWorld::Ptr &actor, const MWWorld::Ptr &attacker, const MWWorld::Ptr &weapon, float &damage)
 
void projectileHit (const MWWorld::Ptr &attacker, const MWWorld::Ptr &victim, MWWorld::Ptr weapon, const MWWorld::Ptr &projectile, const osg::Vec3f &hitPosition, float attackStrength)
 
float getHitChance (const MWWorld::Ptr &attacker, const MWWorld::Ptr &victim, int skillValue)
 Get the chance (in percent) for attacker to successfully hit victim with a given weapon skill value. More...
 
void applyElementalShields (const MWWorld::Ptr &attacker, const MWWorld::Ptr &victim)
 Applies damage to attacker based on the victim's elemental shields. More...
 
void reduceWeaponCondition (float damage, bool hit, MWWorld::Ptr &weapon, const MWWorld::Ptr &attacker)
 
void adjustWeaponDamage (float &damage, const MWWorld::Ptr &weapon, const MWWorld::Ptr &attacker)
 Adjust weapon damage based on its condition. A used weapon will be less effective. More...
 
void getHandToHandDamage (const MWWorld::Ptr &attacker, const MWWorld::Ptr &victim, float &damage, bool &healthdmg, float attackStrength)
 
void applyFatigueLoss (const MWWorld::Ptr &attacker, const MWWorld::Ptr &weapon, float attackStrength)
 Apply the fatigue loss incurred by attacking with the given weapon (weapon may be empty = hand-to-hand) More...
 
bool isEnvironmentCompatible (const MWWorld::Ptr &attacker, const MWWorld::Ptr &victim)
 
float getFightDistanceBias (const MWWorld::Ptr &actor1, const MWWorld::Ptr &actor2)
 
void diseaseContact (MWWorld::Ptr actor, MWWorld::Ptr carrier)
 
std::string getLevelledItem (const ESM::LevelledListBase *levItem, bool creature, unsigned char failChance=0)
 
bool operator< (const EffectKey &left, const EffectKey &right)
 
EffectParam operator+ (const EffectParam &left, const EffectParam &right)
 
EffectParam operator- (const EffectParam &left, const EffectParam &right)
 
bool proximityToDoor (const MWWorld::Ptr &actor, float minSqr=MIN_DIST_TO_DOOR_SQUARED)
 tests actor's proximity to a closed door by default More...
 
MWWorld::Ptr getNearbyDoor (const MWWorld::Ptr &actor, float minSqr=MIN_DIST_TO_DOOR_SQUARED)
 Returns door pointer within range. No guarantee is given as to which one. More...
 
float sqrDistanceIgnoreZ (const ESM::Pathgrid::Point &point, float x, float y)
 
float distance (const ESM::Pathgrid::Point &point, float x, float y, float z)
 
float distance (const ESM::Pathgrid::Point &a, const ESM::Pathgrid::Point &b)
 
float getZAngleToDir (const osg::Vec3f &dir)
 
float getXAngleToDir (const osg::Vec3f &dir)
 
float getZAngleToPoint (const ESM::Pathgrid::Point &origin, const ESM::Pathgrid::Point &dest)
 
float getXAngleToPoint (const ESM::Pathgrid::Point &origin, const ESM::Pathgrid::Point &dest)
 
bool checkWayIsClear (const osg::Vec3f &from, const osg::Vec3f &to, float offsetXY)
 
ESM::Skill::SkillEnum spellSchoolToSkill (int school)
 
float getSpellSuccessChance (const ESM::Spell *spell, const MWWorld::Ptr &actor, int *effectiveSchool, bool cap)
 
float getSpellSuccessChance (const std::string &spellId, const MWWorld::Ptr &actor, int *effectiveSchool, bool cap)
 
int getSpellSchool (const std::string &spellId, const MWWorld::Ptr &actor)
 
int getSpellSchool (const ESM::Spell *spell, const MWWorld::Ptr &actor)
 
bool spellIncreasesSkill (const ESM::Spell *spell)
 Get whether or not the given spell contributes to skill progress. More...
 
bool spellIncreasesSkill (const std::string &spellId)
 
float getEffectResistanceAttribute (short effectId, const MagicEffects *actorEffects)
 
float getEffectResistance (short effectId, const MWWorld::Ptr &actor, const MWWorld::Ptr &caster, const ESM::Spell *spell, const MagicEffects *effects)
 
float getEffectMultiplier (short effectId, const MWWorld::Ptr &actor, const MWWorld::Ptr &caster, const ESM::Spell *spell, const MagicEffects *effects)
 
bool checkEffectTarget (int effectId, const MWWorld::Ptr &target, const MWWorld::Ptr &caster, bool castByPlayer)
 Check if the given effect can be applied to the target. If castByPlayer, emits a message box on failure. More...
 
int getEffectiveEnchantmentCastCost (float castCost, const MWWorld::Ptr &actor)
 
bool isSummoningEffect (int effectId)
 
bool disintegrateSlot (MWWorld::Ptr ptr, int slot, float disintegrate)
 
void adjustDynamicStat (CreatureStats &creatureStats, int index, float magnitude)
 
bool effectTick (CreatureStats &creatureStats, const MWWorld::Ptr &actor, const EffectKey &effectKey, float magnitude)
 
template<typename T >
bool operator== (const Stat< T > &left, const Stat< T > &right)
 
template<typename T >
bool operator!= (const Stat< T > &left, const Stat< T > &right)
 
template<typename T >
bool operator== (const DynamicStat< T > &left, const DynamicStat< T > &right)
 
template<typename T >
bool operator!= (const DynamicStat< T > &left, const DynamicStat< T > &right)
 
bool operator== (const AttributeValue &left, const AttributeValue &right)
 
bool operator!= (const AttributeValue &left, const AttributeValue &right)
 
bool operator== (const SkillValue &left, const SkillValue &right)
 
bool operator!= (const SkillValue &left, const SkillValue &right)
 
bool smoothTurn (const MWWorld::Ptr &actor, float targetAngleRadians, int axis, float epsilonRadians)
 
bool zTurn (const MWWorld::Ptr &actor, float targetAngleRadians, float epsilonRadians)
 
const float MAX_VEL_ANGULAR_RADIANS (10)
 

Variables

const float aiProcessingDistance = 7168
 
const float sqrAiProcessingDistance = aiProcessingDistance*aiProcessingDistance
 
const float AI_REACTION_TIME = 0.25f
 
static const int COUNT_BEFORE_RESET = 10
 
static const float DOOR_CHECK_INTERVAL = 1.5f
 
static const int GREETING_SHOULD_START = 4
 
static const int GREETING_SHOULD_END = 10
 
static const int DESTINATION_TOLERANCE = 64
 
static const int MINIMUM_WANDER_DISTANCE = DESTINATION_TOLERANCE * 2
 
static const StateInfo sMovementList []
 
static const StateInfosMovementListEnd = &sMovementList[sizeof(sMovementList)/sizeof(sMovementList[0])]
 
static const struct
MWMechanics::WeaponInfo 
sWeaponTypeList []
 
static const WeaponInfosWeaponTypeListEnd = &sWeaponTypeList[sizeof(sWeaponTypeList)/sizeof(sWeaponTypeList[0])]
 
static const float DIST_SAME_SPOT = 0.5f
 
static const float DURATION_SAME_SPOT = 1.5f
 
static const float DURATION_TO_EVADE = 0.4f
 
static const float MIN_DIST_TO_DOOR_SQUARED = 128*128
 NOTE: determined empirically based on in-game behaviour. More...
 
static const int NUM_EVADE_DIRECTIONS = 4
 
const float PATHFIND_Z_REACH = 50.0f
 
const float PATHFIND_SHORTCUT_RETRY_DIST = 300.0f
 

Detailed Description

Game mechanics and NPC-AI.

Typedef Documentation

Container for AI package status.

Enumeration Type Documentation

Enumerator
CharState_None 
CharState_SpecialIdle 
CharState_Idle 
CharState_Idle2 
CharState_Idle3 
CharState_Idle4 
CharState_Idle5 
CharState_Idle6 
CharState_Idle7 
CharState_Idle8 
CharState_Idle9 
CharState_IdleSwim 
CharState_IdleSneak 
CharState_WalkForward 
CharState_WalkBack 
CharState_WalkLeft 
CharState_WalkRight 
CharState_SwimWalkForward 
CharState_SwimWalkBack 
CharState_SwimWalkLeft 
CharState_SwimWalkRight 
CharState_RunForward 
CharState_RunBack 
CharState_RunLeft 
CharState_RunRight 
CharState_SwimRunForward 
CharState_SwimRunBack 
CharState_SwimRunLeft 
CharState_SwimRunRight 
CharState_SneakForward 
CharState_SneakBack 
CharState_SneakLeft 
CharState_SneakRight 
CharState_TurnLeft 
CharState_TurnRight 
CharState_Jump 
CharState_Death1 
CharState_Death2 
CharState_Death3 
CharState_Death4 
CharState_Death5 
CharState_SwimDeath 
CharState_DeathKnockDown 
CharState_DeathKnockOut 
CharState_Hit 
CharState_KnockDown 
CharState_KnockOut 
CharState_Block 
Note
The _ suffix is required to avoid a collision with a Windoze macro. Die, Microsoft! Die!
Enumerator
DrawState_Nothing 
DrawState_Weapon 
DrawState_Spell 
Enumerator
JumpState_None 
JumpState_InAir 
JumpState_Landing 
Enumerator
Priority_Default 
Priority_WeaponLowerBody 
Priority_SneakIdleLowerBody 
Priority_SwimIdle 
Priority_Jump 
Priority_Movement 
Priority_Hit 
Priority_Weapon 
Priority_Block 
Priority_Knockdown 
Priority_Torch 
Priority_Storm 
Priority_Death 
Num_Priorities 
Enumerator
UpperCharState_Nothing 
UpperCharState_EquipingWeap 
UpperCharState_UnEquipingWeap 
UpperCharState_WeapEquiped 
UpperCharState_StartToMinAttack 
UpperCharState_MinAttackToMaxAttack 
UpperCharState_MaxAttackToMinHit 
UpperCharState_MinHitToHit 
UpperCharState_FollowStartToFollowStop 
UpperCharState_CastingSpell 
Enumerator
WeapType_None 
WeapType_HandToHand 
WeapType_OneHand 
WeapType_TwoHand 
WeapType_TwoWide 
WeapType_BowAndArrow 
WeapType_Crossbow 
WeapType_Thrown 
WeapType_PickProbe 
WeapType_Spell 

Function Documentation

void MWMechanics::adjustDynamicStat ( CreatureStats &  creatureStats,
int  index,
float  magnitude 
)

Here is the call graph for this function:

Here is the caller graph for this function:

void MWMechanics::adjustWeaponDamage ( float &  damage,
const MWWorld::Ptr weapon,
const MWWorld::Ptr attacker 
)

Adjust weapon damage based on its condition. A used weapon will be less effective.

Here is the call graph for this function:

Here is the caller graph for this function:

void MWMechanics::applyElementalShields ( const MWWorld::Ptr attacker,
const MWWorld::Ptr victim 
)

Applies damage to attacker based on the victim's elemental shields.

Here is the call graph for this function:

Here is the caller graph for this function:

void MWMechanics::applyFatigueLoss ( const MWWorld::Ptr attacker,
const MWWorld::Ptr weapon,
float  attackStrength 
)

Apply the fatigue loss incurred by attacking with the given weapon (weapon may be empty = hand-to-hand)

Here is the call graph for this function:

Here is the caller graph for this function:

bool MWMechanics::applyOnStrikeEnchantment ( const MWWorld::Ptr attacker,
const MWWorld::Ptr victim,
const MWWorld::Ptr object,
const osg::Vec3f &  hitPosition,
const bool  fromProjectile 
)

Here is the call graph for this function:

Here is the caller graph for this function:

bool MWMechanics::attrSkillCheck ( const ESM::Spell spell,
const int actorSkills,
const int actorAttributes 
)

Here is the call graph for this function:

Here is the caller graph for this function:

std::vector< std::string > MWMechanics::autoCalcNpcSpells ( const int actorSkills,
const int actorAttributes,
const ESM::Race race 
)

Contains algorithm for calculating an NPC's spells based on stats

Note
We might want to move this code to a component later, so the editor can use it for preview purposes

Here is the call graph for this function:

Here is the caller graph for this function:

std::vector< std::string > MWMechanics::autoCalcPlayerSpells ( const int actorSkills,
const int actorAttributes,
const ESM::Race race 
)

Here is the call graph for this function:

Here is the caller graph for this function:

bool MWMechanics::blockMeleeAttack ( const MWWorld::Ptr attacker,
const MWWorld::Ptr blocker,
const MWWorld::Ptr weapon,
float  damage,
float  attackStrength 
)
Returns
can we block the attack?

Here is the call graph for this function:

Here is the caller graph for this function:

float MWMechanics::calcAutoCastChance ( const ESM::Spell spell,
const int actorSkills,
const int actorAttributes,
int  effectiveSchool 
)

Here is the call graph for this function:

Here is the caller graph for this function:

void MWMechanics::calcWeakestSchool ( const ESM::Spell spell,
const int actorSkills,
int effectiveSchool,
float &  skillTerm 
)

Here is the call graph for this function:

Here is the caller graph for this function:

bool MWMechanics::canFight ( const MWWorld::Ptr actor,
const MWWorld::Ptr enemy 
)

Here is the call graph for this function:

Here is the caller graph for this function:

bool MWMechanics::checkEffectTarget ( int  effectId,
const MWWorld::Ptr target,
const MWWorld::Ptr caster,
bool  castByPlayer 
)

Check if the given effect can be applied to the target. If castByPlayer, emits a message box on failure.

Here is the call graph for this function:

Here is the caller graph for this function:

bool MWMechanics::checkWayIsClear ( const osg::Vec3f &  from,
const osg::Vec3f &  to,
float  offsetXY 
)

Here is the call graph for this function:

Here is the caller graph for this function:

void MWMechanics::diseaseContact ( MWWorld::Ptr  actor,
MWWorld::Ptr  carrier 
)
inline

Call when actor has got in contact with carrier (e.g. hit by him, or loots him)

Parameters
actorThe actor that will potentially catch diseases. Currently only the player can catch diseases.
carrierThe disease carrier.

Here is the call graph for this function:

Here is the caller graph for this function:

bool MWMechanics::disintegrateSlot ( MWWorld::Ptr  ptr,
int  slot,
float  disintegrate 
)

Here is the call graph for this function:

Here is the caller graph for this function:

float MWMechanics::distance ( const ESM::Pathgrid::Point point,
float  x,
float  y,
float  z 
)

Here is the caller graph for this function:

float MWMechanics::distance ( const ESM::Pathgrid::Point a,
const ESM::Pathgrid::Point b 
)
bool MWMechanics::effectTick ( CreatureStats &  creatureStats,
const MWWorld::Ptr actor,
const MWMechanics::EffectKey effectKey,
float  magnitude 
)

Apply a magic effect that is applied in tick intervals until its remaining time ends or it is removed

Returns
Was the effect a tickable effect with a magnitude?

Here is the call graph for this function:

Here is the caller graph for this function:

MWWorld::ContainerStoreIterator MWMechanics::getActiveWeapon ( CreatureStats stats,
MWWorld::InventoryStore inv,
WeaponType weaptype 
)

Here is the call graph for this function:

Here is the caller graph for this function:

float MWMechanics::getDistanceMinusHalfExtents ( const MWWorld::Ptr actor1,
const MWWorld::Ptr actor2,
bool  minusZDist 
)

Here is the call graph for this function:

Here is the caller graph for this function:

int MWMechanics::getEffectiveEnchantmentCastCost ( float  castCost,
const MWWorld::Ptr actor 
)

Here is the call graph for this function:

Here is the caller graph for this function:

float MWMechanics::getEffectMultiplier ( short  effectId,
const MWWorld::Ptr actor,
const MWWorld::Ptr caster,
const ESM::Spell spell = NULL,
const MagicEffects *  effects = NULL 
)

Get an effect multiplier for applying an effect cast by the given actor in the given spell (optional).

Returns
effect multiplier from 0 to 2. (100% net resistance to 100% net weakness)
Parameters
effectsOverride the actor's current magicEffects. Useful if there are effects currently being applied (but not applied yet) that should also be considered.

Here is the call graph for this function:

Here is the caller graph for this function:

float MWMechanics::getEffectResistance ( short  effectId,
const MWWorld::Ptr actor,
const MWWorld::Ptr caster,
const ESM::Spell spell = NULL,
const MagicEffects *  effects = NULL 
)

Get the effective resistance against an effect casted by the given actor in the given spell (optional).

Returns
>=100 for fully resisted. can also return negative value for damage amplification.
Parameters
effectsOverride the actor's current magicEffects. Useful if there are effects currently being applied (but not applied yet) that should also be considered.

Here is the call graph for this function:

Here is the caller graph for this function:

float MWMechanics::getEffectResistanceAttribute ( short  effectId,
const MagicEffects *  actorEffects 
)

Get the resistance attribute against an effect for a given actor. This will add together ResistX and Weakness to X effects relevant against the given effect.

Here is the call graph for this function:

Here is the caller graph for this function:

float MWMechanics::getFightDistanceBias ( const MWWorld::Ptr actor1,
const MWWorld::Ptr actor2 
)

Here is the call graph for this function:

Here is the caller graph for this function:

void MWMechanics::getHandToHandDamage ( const MWWorld::Ptr attacker,
const MWWorld::Ptr victim,
float &  damage,
bool healthdmg,
float  attackStrength 
)

Here is the call graph for this function:

Here is the caller graph for this function:

float MWMechanics::getHitChance ( const MWWorld::Ptr attacker,
const MWWorld::Ptr victim,
int  skillValue 
)

Get the chance (in percent) for attacker to successfully hit victim with a given weapon skill value.

Here is the call graph for this function:

Here is the caller graph for this function:

std::string MWMechanics::getLevelledItem ( const ESM::LevelledListBase levItem,
bool  creature,
unsigned char  failChance = 0 
)
inline
Returns
ID of resulting item, or empty if none

Here is the call graph for this function:

Here is the caller graph for this function:

float MWMechanics::getMaxAttackDistance ( const MWWorld::Ptr actor)

Here is the call graph for this function:

Here is the caller graph for this function:

MWWorld::Ptr MWMechanics::getNearbyDoor ( const MWWorld::Ptr actor,
float  minSqr = MIN_DIST_TO_DOOR_SQUARED 
)

Returns door pointer within range. No guarantee is given as to which one.

Returns
Pointer to the door, or NULL if none exists

TODO: How to check whether the actor is facing a door? Below code is for the player, perhaps it can be adapted.

TODO: The in-game observation of rot[2] value seems to be the opposite of the code in World::activateDoor() ::confused::

Here is the call graph for this function:

Here is the caller graph for this function:

MWWorld::Ptr MWMechanics::getPlayer ( )

Here is the call graph for this function:

int MWMechanics::getSpellSchool ( const std::string &  spellId,
const MWWorld::Ptr actor 
)

Here is the call graph for this function:

Here is the caller graph for this function:

int MWMechanics::getSpellSchool ( const ESM::Spell spell,
const MWWorld::Ptr actor 
)

Here is the call graph for this function:

float MWMechanics::getSpellSuccessChance ( const ESM::Spell spell,
const MWWorld::Ptr actor,
int effectiveSchool = NULL,
bool  cap = true 
)
Parameters
spellspell to cast
actorcalculate spell success chance for this actor (depends on actor's skills)
effectiveSchoolthe spell's effective school (relevant for skill progress) will be written here
capcap the result to 100%?
Note
actor can be an NPC or a creature
Returns
success chance from 0 to 100 (in percent), if cap=false then chance above 100 may be returned.

Here is the call graph for this function:

Here is the caller graph for this function:

float MWMechanics::getSpellSuccessChance ( const std::string &  spellId,
const MWWorld::Ptr actor,
int effectiveSchool,
bool  cap 
)

Here is the call graph for this function:

void MWMechanics::getWeaponGroup ( WeaponType  weaptype,
std::string &  group 
)

Here is the caller graph for this function:

float MWMechanics::getXAngleToDir ( const osg::Vec3f &  dir)

Here is the caller graph for this function:

float MWMechanics::getXAngleToPoint ( const ESM::Pathgrid::Point origin,
const ESM::Pathgrid::Point dest 
)

Here is the call graph for this function:

Here is the caller graph for this function:

float MWMechanics::getZAngleToDir ( const osg::Vec3f &  dir)

Here is the caller graph for this function:

float MWMechanics::getZAngleToPoint ( const ESM::Pathgrid::Point origin,
const ESM::Pathgrid::Point dest 
)

Here is the call graph for this function:

Here is the caller graph for this function:

bool MWMechanics::isActualAiPackage ( int  packageTypeId)

Here is the caller graph for this function:

bool MWMechanics::isEnvironmentCompatible ( const MWWorld::Ptr attacker,
const MWWorld::Ptr victim 
)

Can attacker operate in victim's environment? e.g. If attacker is a fish, is victim in water? Or, if attacker can't swim, is victim on land?

Here is the call graph for this function:

bool MWMechanics::isPlayerInCombat ( )

Here is the call graph for this function:

Here is the caller graph for this function:

bool MWMechanics::isSummoningEffect ( int  effectId)

Here is the caller graph for this function:

bool MWMechanics::makeFleeDecision ( const MWWorld::Ptr actor,
const MWWorld::Ptr enemy,
float  antiFleeRating 
)

Here is the call graph for this function:

Here is the caller graph for this function:

ESM::Skill::SkillEnum MWMechanics::mapSchoolToSkill ( int  school)

Here is the caller graph for this function:

const float MWMechanics::MAX_VEL_ANGULAR_RADIANS ( 10  )

Here is the caller graph for this function:

template<typename T >
bool MWMechanics::operator!= ( const Stat< T > &  left,
const Stat< T > &  right 
)
inline
template<typename T >
bool MWMechanics::operator!= ( const DynamicStat< T > &  left,
const DynamicStat< T > &  right 
)
inline
bool MWMechanics::operator!= ( const AttributeValue &  left,
const AttributeValue &  right 
)
inline
bool MWMechanics::operator!= ( const SkillValue &  left,
const SkillValue &  right 
)
inline
EffectParam MWMechanics::operator+ ( const EffectParam &  left,
const EffectParam &  right 
)
inline
EffectParam MWMechanics::operator- ( const EffectParam &  left,
const EffectParam &  right 
)
inline
bool MWMechanics::operator< ( const EffectKey &  left,
const EffectKey &  right 
)
template<typename T >
bool MWMechanics::operator== ( const Stat< T > &  left,
const Stat< T > &  right 
)
inline

Here is the call graph for this function:

template<typename T >
bool MWMechanics::operator== ( const DynamicStat< T > &  left,
const DynamicStat< T > &  right 
)
inline
bool MWMechanics::operator== ( const AttributeValue &  left,
const AttributeValue &  right 
)
inline

Here is the call graph for this function:

bool MWMechanics::operator== ( const SkillValue &  left,
const SkillValue &  right 
)
inline

Here is the call graph for this function:

boost::shared_ptr< Action > MWMechanics::prepareNextAction ( const MWWorld::Ptr actor,
const MWWorld::Ptr enemy 
)

Here is the call graph for this function:

Here is the caller graph for this function:

void MWMechanics::projectileHit ( const MWWorld::Ptr attacker,
const MWWorld::Ptr victim,
MWWorld::Ptr  weapon,
const MWWorld::Ptr projectile,
const osg::Vec3f &  hitPosition,
float  attackStrength 
)
Note
for a thrown weapon, weapon == projectile, for bows/crossbows, projectile is the arrow/bolt
victim may be empty (e.g. for a hit on terrain), a non-actor (environment objects) or an actor

Here is the call graph for this function:

Here is the caller graph for this function:

bool MWMechanics::proximityToDoor ( const MWWorld::Ptr actor,
float  minSqr 
)

tests actor's proximity to a closed door by default

Here is the call graph for this function:

Here is the caller graph for this function:

float MWMechanics::rateEffect ( const ESM::ENAMstruct effect,
const MWWorld::Ptr actor,
const MWWorld::Ptr enemy 
)
Note
target may be empty

Here is the call graph for this function:

Here is the caller graph for this function:

float MWMechanics::rateEffects ( const ESM::EffectList list,
const MWWorld::Ptr actor,
const MWWorld::Ptr enemy 
)
Note
target may be empty

Here is the call graph for this function:

Here is the caller graph for this function:

float MWMechanics::rateMagicItem ( const MWWorld::Ptr ptr,
const MWWorld::Ptr actor,
const MWWorld::Ptr enemy 
)

Here is the call graph for this function:

Here is the caller graph for this function:

float MWMechanics::ratePotion ( const MWWorld::Ptr item,
const MWWorld::Ptr actor 
)

Here is the call graph for this function:

Here is the caller graph for this function:

float MWMechanics::rateSpell ( const ESM::Spell spell,
const MWWorld::Ptr actor,
const MWWorld::Ptr enemy 
)

Here is the call graph for this function:

Here is the caller graph for this function:

float MWMechanics::rateWeapon ( const MWWorld::Ptr item,
const MWWorld::Ptr actor,
const MWWorld::Ptr enemy,
int  type = -1,
float  arrowRating = 0.f,
float  boltRating = 0.f 
)
Parameters
typeSkip all weapons that are not of this type (i.e. return rating 0)

Here is the call graph for this function:

Here is the caller graph for this function:

void MWMechanics::reduceWeaponCondition ( float  damage,
bool  hit,
MWWorld::Ptr weapon,
const MWWorld::Ptr attacker 
)
Parameters
damageUnmitigated weapon damage of the attack
hitWas the attack successful?
weaponThe weapon used.
Note
if the weapon is unequipped as result of condition damage, a new Ptr will be assigned to weapon.

Here is the call graph for this function:

Here is the caller graph for this function:

void MWMechanics::resistNormalWeapon ( const MWWorld::Ptr actor,
const MWWorld::Ptr attacker,
const MWWorld::Ptr weapon,
float &  damage 
)

Here is the call graph for this function:

Here is the caller graph for this function:

bool MWMechanics::smoothTurn ( const MWWorld::Ptr actor,
float  targetAngleRadians,
int  axis,
float  epsilonRadians 
)

Here is the call graph for this function:

Here is the caller graph for this function:

bool MWMechanics::spellIncreasesSkill ( const ESM::Spell spell)

Get whether or not the given spell contributes to skill progress.

Here is the caller graph for this function:

bool MWMechanics::spellIncreasesSkill ( const std::string &  spellId)

Here is the call graph for this function:

ESM::Skill::SkillEnum MWMechanics::spellSchoolToSkill ( int  school)

Here is the caller graph for this function:

void MWMechanics::split ( const std::string &  s,
char  delim,
std::vector< std::string > &  elems 
)

Here is the caller graph for this function:

float MWMechanics::sqrDistanceIgnoreZ ( const ESM::Pathgrid::Point point,
float  x,
float  y 
)

Here is the caller graph for this function:

float MWMechanics::vanillaRateFlee ( const MWWorld::Ptr actor,
const MWWorld::Ptr enemy 
)

Here is the call graph for this function:

Here is the caller graph for this function:

float MWMechanics::vanillaRateSpell ( const ESM::Spell spell,
const MWWorld::Ptr actor,
const MWWorld::Ptr enemy 
)

Here is the call graph for this function:

Here is the caller graph for this function:

float MWMechanics::vanillaRateWeaponAndAmmo ( const MWWorld::Ptr weapon,
const MWWorld::Ptr ammo,
const MWWorld::Ptr actor,
const MWWorld::Ptr enemy 
)

Here is the call graph for this function:

Here is the caller graph for this function:

bool MWMechanics::zTurn ( const MWWorld::Ptr actor,
float  targetAngleRadians,
float  epsilonRadians = osg::DegreesToRadians(0.5) 
)

configure rotation settings for an actor to reach this target angle (eventually)

Returns
have we reached the target angle?

Here is the call graph for this function:

Here is the caller graph for this function:

Variable Documentation

const float MWMechanics::AI_REACTION_TIME = 0.25f
const float MWMechanics::aiProcessingDistance = 7168
const int MWMechanics::COUNT_BEFORE_RESET = 10
static
const int MWMechanics::DESTINATION_TOLERANCE = 64
static
const float MWMechanics::DIST_SAME_SPOT = 0.5f
static
const float MWMechanics::DOOR_CHECK_INTERVAL = 1.5f
static
const float MWMechanics::DURATION_SAME_SPOT = 1.5f
static
const float MWMechanics::DURATION_TO_EVADE = 0.4f
static
const int MWMechanics::GREETING_SHOULD_END = 10
static
const int MWMechanics::GREETING_SHOULD_START = 4
static
const float MWMechanics::MIN_DIST_TO_DOOR_SQUARED = 128*128
static

NOTE: determined empirically based on in-game behaviour.

const int MWMechanics::MINIMUM_WANDER_DISTANCE = DESTINATION_TOLERANCE * 2
static
const int MWMechanics::NUM_EVADE_DIRECTIONS = 4
static
const float MWMechanics::PATHFIND_SHORTCUT_RETRY_DIST = 300.0f
const float MWMechanics::PATHFIND_Z_REACH = 50.0f
const StateInfo MWMechanics::sMovementList[]
static
const StateInfo* MWMechanics::sMovementListEnd = &sMovementList[sizeof(sMovementList)/sizeof(sMovementList[0])]
static
const float MWMechanics::sqrAiProcessingDistance = aiProcessingDistance*aiProcessingDistance
const struct MWMechanics::WeaponInfo MWMechanics::sWeaponTypeList[]
static
Initial value:
= {
{ WeapType_HandToHand, "hh", "handtohand" },
{ WeapType_OneHand, "1h", "weapononehand" },
{ WeapType_TwoHand, "2c", "weapontwohand" },
{ WeapType_TwoWide, "2w", "weapontwowide" },
{ WeapType_BowAndArrow, "1h", "bowandarrow" },
{ WeapType_Crossbow, "crossbow", "crossbow" },
{ WeapType_Thrown, "1h", "throwweapon" },
{ WeapType_PickProbe, "1h", "pickprobe" },
{ WeapType_Spell, "spell", "spellcast" },
}
Definition: character.hpp:113
Definition: character.hpp:121
Definition: character.hpp:114
Definition: character.hpp:119
Definition: character.hpp:118
Definition: character.hpp:116
Definition: character.hpp:117
Definition: character.hpp:112
Definition: character.hpp:115
const WeaponInfo* MWMechanics::sWeaponTypeListEnd = &sWeaponTypeList[sizeof(sWeaponTypeList)/sizeof(sWeaponTypeList[0])]
static