OpenMW
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
aicombat.hpp
Go to the documentation of this file.
1 #ifndef GAME_MWMECHANICS_AICOMBAT_H
2 #define GAME_MWMECHANICS_AICOMBAT_H
3 
4 #include "aipackage.hpp"
5 
6 #include <boost/shared_ptr.hpp>
7 
8 #include "../mwworld/cellstore.hpp" // for Doors
9 
10 #include "../mwbase/world.hpp"
11 
12 #include "pathfinding.hpp"
13 #include "movement.hpp"
14 #include "obstacle.hpp"
15 
16 namespace ESM
17 {
18  namespace AiSequence
19  {
20  struct AiCombat;
21  }
22 }
23 
24 namespace MWMechanics
25 {
26  class Action;
27 
28  struct AiCombatStorage;
29 
31  class AiCombat : public AiPackage
32  {
33  public:
35 
36  AiCombat(const MWWorld::Ptr& actor);
37 
38  AiCombat (const ESM::AiSequence::AiCombat* combat);
39 
40  void init();
41 
42  virtual AiCombat *clone() const;
43 
44  virtual bool execute (const MWWorld::Ptr& actor, CharacterController& characterController, AiState& state, float duration);
45 
46  virtual int getTypeId() const;
47 
48  virtual unsigned int getPriority() const;
49 
51  MWWorld::Ptr getTarget() const;
52 
53  virtual void writeState(ESM::AiSequence::AiSequence &sequence) const;
54 
55  virtual bool canCancel() const { return false; }
56  virtual bool shouldCancelPreviousAi() const { return false; }
57 
58  private:
59 
61 
63  bool attack(const MWWorld::Ptr& actor, const MWWorld::Ptr& target, AiCombatStorage& storage, CharacterController& characterController);
64 
65  void updateLOS(const MWWorld::Ptr& actor, const MWWorld::Ptr& target, float duration, AiCombatStorage& storage);
66 
67  void updateFleeing(const MWWorld::Ptr& actor, const MWWorld::Ptr& target, float duration, AiCombatStorage& storage);
68 
70  void updateActorsMovement(const MWWorld::Ptr& actor, float duration, AiCombatStorage& storage);
71  void rotateActorOnAxis(const MWWorld::Ptr& actor, int axis,
72  MWMechanics::Movement& actorMovementSettings, MWMechanics::Movement& desiredMovement);
73  };
74 
75 
76 }
77 
78 #endif
Causes the actor to fight another actor.
Definition: aicombat.hpp:31
MWWorld::Ptr getTarget() const
Returns target ID.
Definition: aicombat.cpp:464
void rotateActorOnAxis(const MWWorld::Ptr &actor, int axis, MWMechanics::Movement &actorMovementSettings, MWMechanics::Movement &desiredMovement)
Definition: aicombat.cpp:439
void init()
Definition: aicombat.cpp:113
bool attack(const MWWorld::Ptr &actor, const MWWorld::Ptr &target, AiCombatStorage &storage, CharacterController &characterController)
Returns true if combat should end.
Definition: aicombat.cpp:221
void updateFleeing(const MWWorld::Ptr &actor, const MWWorld::Ptr &target, float duration, AiCombatStorage &storage)
Definition: aicombat.cpp:334
Base class for AI packages.
Definition: aipackage.hpp:32
virtual AiCombat * clone() const
Clones the package.
Definition: aicombat.cpp:469
Definition: character.hpp:145
virtual int getTypeId() const
Definition: aicombat.cpp:454
void updateActorsMovement(const MWWorld::Ptr &actor, float duration, AiCombatStorage &storage)
Transfer desired movement (from AiCombatStorage) to Actor.
Definition: aicombat.cpp:427
Desired movement for an actor.
Definition: movement.hpp:9
virtual bool shouldCancelPreviousAi() const
Upon adding this Ai package, should the Ai Sequence attempt to cancel previous Ai packages (default t...
Definition: aicombat.hpp:56
virtual void writeState(ESM::AiSequence::AiSequence &sequence) const
Definition: aicombat.cpp:474
virtual bool canCancel() const
Can this Ai package be canceled? (default true)
Definition: aicombat.hpp:55
This class holds the variables AiCombat needs which are deleted if the package becomes inactive...
Definition: aicombat.cpp:38
virtual bool execute(const MWWorld::Ptr &actor, CharacterController &characterController, AiState &state, float duration)
Definition: aicombat.cpp:165
AiCombat(const MWWorld::Ptr &actor)
Constructor.
Definition: aicombat.cpp:104
Definition: aisequence.hpp:148
void updateLOS(const MWWorld::Ptr &actor, const MWWorld::Ptr &target, float duration, AiCombatStorage &storage)
Definition: aicombat.cpp:322
virtual unsigned int getPriority() const
Higher number is higher priority (0 being the lowest)
Definition: aicombat.cpp:459
Pointer to a LiveCellRef.
Definition: ptr.hpp:19
int mTargetActorId
Definition: aicombat.hpp:60
Definition: aisequence.hpp:125