Orxonox  0.0.5 Codename: Arcturus
ActionpointController.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  * ...
26  *
27  */
28 
29 #ifndef _ActionpointController_H__
30 #define _ActionpointController_H__
31 
33 #include "tools/Timer.h"
35 #include <map>
36 
37 namespace orxonox
38 {
63  enum class Action
64  {
66  };
67 
68  struct Point {
71  Vector3 position;
72  bool inLoop;
73  };
74 
76  {
77  public:
78 
80  virtual ~ActionpointController();
81  virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override;
82 
88  virtual void tick(float dt) override;
166  void addActionpoint(WorldEntity* actionpoint);
167  WorldEntity* getActionpoint(unsigned int index) const;
168  void setDefaultFightAll(bool value)
169  { this->bDefaultFightAll_ = value; }
171  { return this->bDefaultFightAll_; }
172  void setDefaultPatrol(bool value)
173  { this->bDefaultPatrol_ = value; }
175  { return this->bDefaultPatrol_; }
176 
177 
178  virtual void stayNearProtect();
179  virtual void action(); //<! action() is called in regular intervals managing the bot's behaviour. Only gets called by MasterController
180  virtual void takeActionpoints (const std::vector<Point>& vector, const std::vector<Point>& loop, bool b);
181 
182  virtual Action getAction ();
183  virtual std::string getActionName();
184 
185  void setAction (Action action);
186  void setAction (Action action, ControllableEntity* target);
187  void setAction (Action action, const Vector3& target);
188  void setAction (Action action, const Vector3& target, const Quaternion& orient );
189 
190  virtual bool setWingman(ActionpointController* wingman)
191  { return false; }
192  virtual bool hasWingman()
193  { return true; }
194  virtual bool setFollower(ActionpointController* myFollower)
195  { return false; }
196  virtual bool hasFollower()
197  { return true; }
198 
199 
200  protected:
201  void startAttackingEnemiesThatAreClose();
205  //----[Actionpoint information]----
209  std::vector<WeakPtr<WorldEntity>> actionpoints_;
211  std::vector<Point> parsedActionpoints_; //<! actionpoints as they are stored here after being parsed from XML
212  std::vector<Point> loopActionpoints_; //<! actionpoints that are to be looped
213  bool bInLoop_; //<! variable for addActionpoint method
214  bool bLoop_; //<! is state machine looping?
215  bool bEndLoop_; //<! variable for addActionpoint method
216  bool bTakenOver_; //<! are actionpoints taken over from the leader when he died? if yes, top actionpoint
217  //<! is to be executed for the state machine to start working
218  //----[/Actionpoint information]----
219  void setProtect (ControllableEntity* protect);
220  ControllableEntity* getProtect ();
221  WeakPtr<ControllableEntity> protect_; //<! entity that is to be protected if this->action_ == Action::PROTECT
222  void fillLoop(); //<! moves actionpoints that are should be in loop from parsedActionpoints_ to loopActionpoints_
223  void fillLoopReversed();
224  void moveBackToTop(); //<! analog of removing back actionpoint for loopActionpoints_: instead of removing it,
225  //<! move it to the top, so that it will be executed later on.
226  void setClosestTarget();
227  Pawn* closestTarget();
228  //----[Actionpoint methods]----
236  void executeActionpoint();
244  void nextActionpoint();
245  //----[Actionpoint methods]----
246 
247  bool bDefaultFightAll_; //<! if true, when no action set, this will fight all
248 
249  bool bPatrolling_; //<! true if current action_ is FIGHT because this found enemies that are close, need this to correctly go back to looping if was looping
250  bool bDefaultPatrol_; //<! if true, this will look out for enemies that are close if this is just flying or doing nothing
251  unsigned int ticks_; //<! local tick counter
252  };
253 }
254 
255 #endif /* _ActionpointController_H__ */
Everything in Orxonox that has a health attribute is a Pawn.
Definition: Pawn.h:56
std::vector< WeakPtr< WorldEntity > > actionpoints_
Definition: ActionpointController.h:209
bool bEndLoop_
Definition: ActionpointController.h:215
Definition: ActionpointController.h:68
bool bDefaultPatrol_
Definition: ActionpointController.h:250
bool bDefaultFightAll_
Definition: ActionpointController.h:247
bool bLoop_
Definition: ActionpointController.h:214
std::vector< Point > loopActionpoints_
Definition: ActionpointController.h:212
WeakPtr< ActionpointController > myWingman_
Definition: ActionpointController.h:202
Declaration of the Tickable interface.
bool getDefaultPatrol()
Definition: ActionpointController.h:174
bool bInLoop_
Definition: ActionpointController.h:213
void setDefaultFightAll(bool value)
Definition: ActionpointController.h:168
virtual bool setWingman(ActionpointController *wingman)
Definition: ActionpointController.h:190
::std::string string
Definition: gtest-port.h:756
WeakPtr< ActionpointController > myDivisionLeader_
Definition: ActionpointController.h:204
Action
ActionpointController is a state machine with states: 1) NONE 2) FLY: fly towards a point 3) FIGHT: f...
Definition: ActionpointController.h:63
bool bPatrolling_
Definition: ActionpointController.h:249
std::string targetName_
Definition: ActionpointController.h:208
unsigned int ticks_
Definition: ActionpointController.h:251
bool bTakenOver_
Definition: ActionpointController.h:216
bool inLoop
Definition: ActionpointController.h:72
WeakPtr wraps a pointer to an object, which becomes nullptr if the object is deleted.
Definition: CorePrereqs.h:236
The WorldEntity represents everything that can be put in a Scene at a certain location.
Definition: WorldEntity.h:72
xmlelement
Definition: Super.h:519
WeakPtr< ActionpointController > myFollower_
Definition: ActionpointController.h:203
std::vector< Point > parsedActionpoints_
Definition: ActionpointController.h:211
Vector3 position
Definition: ActionpointController.h:71
Declaration of the Timer class, used to call functions after a given time-interval.
Action action
Definition: ActionpointController.h:69
Die Wagnis Klasse hat die folgenden Aufgaben:
Definition: ApplicationPaths.cc:66
bool getDefaultFightAll()
Definition: ActionpointController.h:170
Mode
Definition: CorePrereqs.h:102
FightingController stores all the fighting methods and member variables of AI.
Definition: FightingController.h:45
virtual bool setFollower(ActionpointController *myFollower)
Definition: ActionpointController.h:194
std::string name
Definition: ActionpointController.h:70
Definition: Context.h:45
Definition: ActionpointController.h:75
virtual bool hasWingman()
Definition: ActionpointController.h:192
#define _OrxonoxExport
Definition: OrxonoxPrereqs.h:60
WeakPtr< ControllableEntity > protect_
Definition: ActionpointController.h:221
void setDefaultPatrol(bool value)
Definition: ActionpointController.h:172
std::string protectName_
Definition: ActionpointController.h:207
Action action_
Definition: ActionpointController.h:206
The Tickable interface provides a tick(dt) function, that gets called every frame.
Definition: Tickable.h:52
float squaredaccuracy_
Definition: ActionpointController.h:210
The ControllableEntity is derived from the orxonox::MobileEntity.
Definition: ControllableEntity.h:48
virtual bool hasFollower()
Definition: ActionpointController.h:196