Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/ai/src/orxonox/controllers/ArtificialController.h @ 7832

Last change on this file since 7832 was 7832, checked in by jo, 13 years ago

Now the ai use lensflare if the weapon is on board and if they are close enough to the target. Hardcoded version!

  • Property svn:eol-style set to native
File size: 4.9 KB
Line 
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"
33
34#include <vector>
35
36#include "util/Math.h"
37#include "Controller.h"
38#include "controllers/NewHumanController.h"
39#include "weaponsystem/WeaponSystem.h"
40
41namespace orxonox
42{
43    class _OrxonoxExport ArtificialController : public Controller
44    {
45        public:
46            ArtificialController(BaseObject* creator);
47            virtual ~ArtificialController();
48
49            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
50
51            void abandonTarget(Pawn* target);
52
53            inline void setTeam(int team)
54                { this->team_ = team; }
55            inline int getTeam() const
56                { return this->team_; }
57
58            inline void setFormationFlight(bool formation)
59                { this->formationFlight_ = formation; }
60            inline bool getFormationFlight() const
61                { return this->formationFlight_; }
62
63            inline void setFormationSize(int size)
64                { this->maxFormationSize_ = size; }
65            inline int getFormationSize() const
66                { return this->maxFormationSize_; }
67
68            inline void setPassive(bool passive)
69                { this->passive_ = passive; }
70            inline bool getPassive() const
71                { return this->passive_; }
72
73            virtual void changedControllableEntity();
74
75            static void formationflight(const bool form);
76            static void masteraction(const int action);
77            static void followme();
78            static void passivebehaviour(const bool passive);
79            static void formationsize(const int size);
80           
81            virtual void doFire();
82
83        protected:
84
85            int team_;
86            bool formationFlight_;
87            bool passive_;
88            unsigned int maxFormationSize_;
89            int freedomCount_;
90            enum State {SLAVE, MASTER, FREE};
91            State state_;
92            std::vector<ArtificialController*> slaves_;
93            ArtificialController *myMaster_;
94            enum SpecificMasterAction {NONE, HOLD, SPIN, TURN180, FOLLOW};
95            SpecificMasterAction specificMasterAction_;
96            int specificMasterActionHoldCount_;
97            float speedCounter_; //for speed adjustment when following
98
99            void moveToPosition(const Vector3& target);
100            void moveToTargetPosition();
101
102            void removeFromFormation();
103            void unregisterSlave();
104            void searchNewMaster();
105            void commandSlaves();
106            void setNewMasterWithinFormation();
107
108            void freeSlaves();
109            void forceFreeSlaves();
110            void loseMasterState();
111            void forceFreedom();
112            bool forcedFree();
113
114            void specificMasterActionHold();
115            void turn180Init();
116            void turn180();
117            void spinInit();
118            void spin();
119            void followInit(Pawn* pawn, const bool always = false, const int secondsToFollow = 100);
120            void followRandomHumanInit();
121            void follow();
122            void followForSlaves(const Vector3& target);
123
124            void setTargetPosition(const Vector3& target);
125            void searchRandomTargetPosition();
126
127            void setTarget(Pawn* target);
128            void searchNewTarget();
129            void forgetTarget();
130            void aimAtTarget();
131
132            bool isCloseAtTarget(float distance) const;
133            bool isLookingAtTarget(float angle) const;
134
135            void targetDied();
136
137            static bool sameTeam(ControllableEntity* entity1, ControllableEntity* entity2, Gametype* gametype); // hack
138
139            bool bHasTargetPosition_;
140            Vector3 targetPosition_;
141            WeakPtr<Pawn> target_;
142            bool bShooting_;
143           
144            int numberOfWeapons;
145            int weapons[WeaponSystem::MAX_WEAPON_MODES];
146
147        private:
148            void setupWeapons();
149            bool bSetupWorked;
150    };
151}
152
153#endif /* _ArtificialController_H__ */
Note: See TracBrowser for help on using the repository browser.