Orxonox  0.0.5 Codename: Arcturus
ArtificialController.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  * Fabian 'x3n' Landau
24  * Co-authors:
25  * Dominik Solenicki
26  *
27  */
28 
29 #ifndef _ArtificialController_H__
30 #define _ArtificialController_H__
31 
32 #include "OrxonoxPrereqs.h"
34 
35 
36 namespace orxonox
37 {
39  {
40  public:
41  ArtificialController(Context* context);
42  virtual ~ArtificialController();
43 
44  virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override;
45 
46  void abandonTarget(Pawn* target);
47 
48  virtual void changedControllableEntity() override;
49 
50  virtual void doFire();
51  void setBotLevel(float level=1.0f);
52  inline float getBotLevel() const
53  { return this->botlevel_; }
54  static void setAllBotLevel(float level);
55  //WAYPOINT FUNCTIONS
56  void addWaypoint(WorldEntity* waypoint);
57  WorldEntity* getWaypoint(unsigned int index) const;
58 
59  inline void setAccuracy(float accuracy)
60  { this->squaredaccuracy_ = accuracy*accuracy; }
61  inline float getAccuracy() const
62  { return sqrt(this->squaredaccuracy_); }
63  void updatePointsOfInterest(std::string name, float distance);
64  void manageWaypoints();
65 
66 
67 
68  protected:
69 
70  void aimAtTarget();
71 
72  bool isCloseAtTarget(float distance) const;
73  bool isLookingAtTarget(float angle) const;
74 
75  float botlevel_; //<! Makes the level of a bot configurable.
76  enum Mode {DEFAULT, ROCKET, DEFENCE, MOVING};//TODO; implement DEFENCE, MOVING modes
77  Mode mode_; //TODO: replace single value with stack-like implementation: std::vector<Mode> mode_;
78  void setPreviousMode();
79 
80 
81  //WEAPONSYSTEM DATA
82  std::map<std::string, int> weaponModes_; //<! Links each "weapon" to it's weaponmode - managed by setupWeapons()
83  //std::vector<int> projectiles_; //<! Displays amount of projectiles of each weapon. - managed by setupWeapons()
84  float timeout_; //<! Timeout for rocket usage. (If a rocket misses, a bot should stop using it.)
85  void setupWeapons(); //<! Defines which weapons are available for a bot. Is recalled whenever a bot was killed.
86  bool bSetupWorked; //<! If false, setupWeapons() is called.
87  int getFiremode(std::string name);
88 
89 
90  //WAYPOINT DATA
91  std::vector<WeakPtr<WorldEntity>> waypoints_;
95 
96  void boostControl(); //<! Sets and resets the boost parameter of the spaceship. Bots alternate between boosting and saving boost.
97 
98  private:
99  };
100 }
101 
102 #endif /* _ArtificialController_H__ */
Everything in Orxonox that has a health attribute is a Pawn.
Definition: Pawn.h:56
std::vector< WeakPtr< WorldEntity > > waypoints_
Definition: ArtificialController.h:91
::std::string string
Definition: gtest-port.h:756
float getBotLevel() const
Definition: ArtificialController.h:52
WorldEntity * defaultWaypoint_
Definition: ArtificialController.h:94
The WorldEntity represents everything that can be put in a Scene at a certain location.
Definition: WorldEntity.h:72
Definition: ArtificialController.h:76
xmlelement
Definition: Super.h:519
Definition: FormationController.h:44
Die Wagnis Klasse hat die folgenden Aufgaben:
Definition: ApplicationPaths.cc:66
Mode
Definition: CorePrereqs.h:102
Shared library macros, enums, constants and forward declarations for the orxonox library ...
float botlevel_
Definition: ArtificialController.h:75
Definition: Context.h:45
float squaredaccuracy_
Definition: ArtificialController.h:93
float timeout_
Definition: ArtificialController.h:84
#define _OrxonoxExport
Definition: OrxonoxPrereqs.h:60
Mode
Definition: ArtificialController.h:76
std::map< std::string, int > weaponModes_
Definition: ArtificialController.h:82
float getAccuracy() const
Definition: ArtificialController.h:61
void setAccuracy(float accuracy)
Definition: ArtificialController.h:59
size_t currentWaypoint_
Definition: ArtificialController.h:92
bool bSetupWorked
Definition: ArtificialController.h:86
Definition: ArtificialController.h:38
Mode mode_
Definition: ArtificialController.h:77