Orxonox  0.0.5 Codename: Arcturus
FightingController.h
Go to the documentation of this file.
1 /*
2  * ORXONOX - the hottest 3D action shooter ever to exist
3  * > www.orxonox.net <
4  *
5  *
6  * License notice:
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License
10  * as published by the Free Software Foundation; either version 2
11  * of the License, or (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21  *
22  * Author:
23  * Gani Aliguzhinov
24  * Co-authors:
25  * Fabian 'x3n' Landau, Dominik Solenicki
26  *
27  */
28 
29 #ifndef _FightingController_H__
30 #define _FightingController_H__
31 
32 
34 
35 namespace orxonox
36 {
46  {
47 
48  public:
49  FightingController(Context* context);
50  virtual ~FightingController();
51 
52  float squaredDistanceToTarget() const;
53  bool isLookingAtTarget(float angle) const;
54  bool hasTarget() const;
56  { return this->target_; }
57  bool bKeepFormation_; //even if action_ == FIGHT, you might still want to keep formation if far enough form the target
58  virtual void maneuver(); //<! sets this->targetPosition_, which is a Vector3 of where this ship flies. Decision is made based on
59  //<! the distance to enemy, if being attacked, dodge() is called, otherwise ship just flies towards this->target_.
60  bool bShooting_; //<! if true, ship shoots each tick
61  bool canFire(); //<! check if target_ is in radius and if this is looking at target_
62  protected:
63  void setTarget(ControllableEntity* target); //set a target to shoot at
64 
65  void setPositionOfTarget(const Vector3& target); //good to know where target is
66  void setOrientationOfTarget(const Quaternion& orient); //I don't really use that
67  void stopLookingAtTarget(); //<! target dead -> you need to be able to fly
68  void startLookingAtTarget(); //<! if close to target, no need to fly, just rotate yourself
69  void lookAtTarget(float dt); //<! rotate yourself towards target
70 
71  void dodge(const Vector3& thisPosition, float diffLength, Vector3& diffUnit); //<! choose a random Vector3 perpendicular to the difference vector between
72  //<! this and target_ plus or minus some amount in difference vector direction,
73  //<! depending on whether it is better to close up or survive.
74  void doFire(); //<! choose weapon, set aim at target_ and fire
76  void setClosestTarget();
77 
82  Pawn* closestTarget() const;
83 
84  bool bDodge_;
87  float deltaHp;
88  float previousHp;
90  //WEAPONSYSTEM DATA
92  int timeout_;
94  std::map<std::string, int> weaponModes_; //<! Links each "weapon" to it's weaponmode - managed by setupWeapons()
95  //std::vector<int> projectiles_; //<! Displays amount of projectiles of each weapon. - managed by setupWeapons()
96  void setupWeapons(); //<! Defines which weapons are available for a bot. Is recalled whenever a bot was killed.
97  bool bSetupWorked; //<! If false, setupWeapons() is called.
98  int getFiremode(const std::string& name);
99 
100  };
101 }
102 
103 #endif /* _FightingController_H__ */
Quaternion orientationOfTarget_
Definition: FightingController.h:81
Everything in Orxonox that has a health attribute is a Pawn.
Definition: Pawn.h:56
bool bFiredRocket_
Definition: FightingController.h:93
ControllableEntity * getTarget() const
Definition: FightingController.h:55
float previousHp
Definition: FightingController.h:88
::std::string string
Definition: gtest-port.h:756
float deltaHp
Definition: FightingController.h:87
bool bHasPositionOfTarget_
Definition: FightingController.h:78
bool bDodge_
Definition: FightingController.h:84
WeakPtr wraps a pointer to an object, which becomes nullptr if the object is deleted.
Definition: CorePrereqs.h:236
int rocketsLeft_
Definition: FightingController.h:91
std::map< std::string, int > weaponModes_
Definition: FightingController.h:94
bool bHasOrientationOfTarget_
Definition: FightingController.h:80
int attackRange_
Definition: FightingController.h:85
Die Wagnis Klasse hat die folgenden Aufgaben:
Definition: ApplicationPaths.cc:66
WeakPtr< ControllableEntity > target_
Definition: FightingController.h:75
bool bSetupWorked
Definition: FightingController.h:97
FightingController stores all the fighting methods and member variables of AI.
Definition: FightingController.h:45
Definition: FlyingController.h:48
Vector3 positionOfTarget_
Definition: FightingController.h:79
Definition: Context.h:45
bool bShooting_
Definition: FightingController.h:60
#define _OrxonoxExport
Definition: OrxonoxPrereqs.h:60
bool bLookAtTarget_
Definition: FightingController.h:86
bool bStartedDodging_
Definition: FightingController.h:89
int timeout_
Definition: FightingController.h:92
bool bKeepFormation_
Definition: FightingController.h:57
The ControllableEntity is derived from the orxonox::MobileEntity.
Definition: ControllableEntity.h:48