[10719] | 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 | * ... |
---|
| 26 | * |
---|
| 27 | */ |
---|
| 28 | |
---|
| 29 | #ifndef _CommonController_H__ |
---|
| 30 | #define _CommonController_H__ |
---|
| 31 | |
---|
| 32 | |
---|
| 33 | #include "controllers/Controller.h" |
---|
| 34 | #include "worldentities/ControllableEntity.h" |
---|
[10759] | 35 | #include "worldentities/pawns/Pawn.h" |
---|
[10719] | 36 | |
---|
[10759] | 37 | |
---|
[10719] | 38 | namespace orxonox |
---|
| 39 | { |
---|
[10759] | 40 | |
---|
| 41 | namespace FormationMode |
---|
| 42 | { |
---|
| 43 | enum Value |
---|
| 44 | { |
---|
| 45 | VEE, FINGER4, DIAMOND, WALL |
---|
| 46 | }; |
---|
| 47 | } |
---|
| 48 | namespace Rank |
---|
| 49 | { |
---|
| 50 | enum Value |
---|
| 51 | { |
---|
| 52 | NONE, SECTIONLEADER, DIVISIONLEADER, WINGMAN |
---|
| 53 | }; |
---|
| 54 | |
---|
| 55 | } |
---|
[10761] | 56 | //none for a formation flight without attacking, neutral when opponent and this have no |
---|
| 57 | //advantage over each other, offensive when this spotted opponent first, |
---|
| 58 | //defensive otherwise |
---|
| 59 | namespace ManeuverType |
---|
| 60 | { |
---|
| 61 | enum Value |
---|
| 62 | { |
---|
| 63 | NONE, NEUTRAL, OFFENSIVE, DEFENCIVE |
---|
| 64 | }; |
---|
[10759] | 65 | |
---|
[10761] | 66 | } |
---|
| 67 | //none for a formation flight |
---|
| 68 | namespace Maneuver |
---|
| 69 | { |
---|
| 70 | enum Value |
---|
| 71 | { |
---|
| 72 | NONE, GUNSD, SCISSORS, COMBATSPREAD, DEFENSIVESPLIT, BREAK, BARRELROLL, SWOOP, IMMELMANN, |
---|
| 73 | WINGOVER, LOWYOYO, HIGHYOYO, LAGDISPLACEMENTROLL |
---|
| 74 | }; |
---|
| 75 | } |
---|
| 76 | |
---|
[10719] | 77 | class _OrxonoxExport CommonController : public Controller |
---|
| 78 | { |
---|
| 79 | public: |
---|
[10731] | 80 | |
---|
[10729] | 81 | static const float ACTION_INTERVAL = 1.0f; |
---|
| 82 | |
---|
[10731] | 83 | |
---|
| 84 | CommonController(Context* context); |
---|
| 85 | virtual ~CommonController(); |
---|
| 86 | |
---|
| 87 | |
---|
| 88 | |
---|
[10759] | 89 | |
---|
| 90 | |
---|
| 91 | virtual void setFormationMode(FormationMode::Value val) |
---|
[10725] | 92 | { this->formationMode_ = val; } |
---|
[10759] | 93 | inline FormationMode::Value getFormationMode() const |
---|
[10725] | 94 | { return this->formationMode_; } |
---|
[10759] | 95 | virtual void setFormationModeXML(std::string val); |
---|
| 96 | virtual std::string getFormationModeXML(); |
---|
[10725] | 97 | |
---|
[10759] | 98 | virtual void setRank(Rank::Value val) |
---|
[10731] | 99 | { this->rank_ = val; } |
---|
[10759] | 100 | inline Rank::Value getRank() const |
---|
[10731] | 101 | { return this->rank_; } |
---|
| 102 | |
---|
[10759] | 103 | virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); |
---|
[10731] | 104 | |
---|
| 105 | |
---|
| 106 | |
---|
[10719] | 107 | virtual bool setWingman(CommonController* wingman); |
---|
[10722] | 108 | virtual bool hasWingman(); |
---|
[10719] | 109 | |
---|
[10759] | 110 | void setTarget(ControllableEntity* target); |
---|
[10719] | 111 | |
---|
[10729] | 112 | void setTargetOrientation(const Quaternion& orient); |
---|
| 113 | void setTargetOrientation(ControllableEntity* target); |
---|
| 114 | void setTargetPosition(const Vector3& target); |
---|
| 115 | |
---|
[10731] | 116 | /*void spin(); |
---|
| 117 | void turn180();*/ |
---|
| 118 | |
---|
| 119 | |
---|
[10719] | 120 | protected: |
---|
[10731] | 121 | |
---|
[10725] | 122 | void moveToPosition(const Vector3& target); |
---|
[10731] | 123 | void moveToTargetPosition(); |
---|
[10737] | 124 | //enum Mode {ROCKET, ATTACK, MOVE, HOLD};//TODO; implement DEFENCE, MOVING modes |
---|
[10719] | 125 | |
---|
[10737] | 126 | //Mode mode_; |
---|
[10725] | 127 | void copyOrientation(const Quaternion& orient); |
---|
| 128 | void copyTargetOrientation(); |
---|
| 129 | |
---|
[10759] | 130 | bool isCloseAtTarget(float distance) const; |
---|
[10731] | 131 | void doFire(); |
---|
| 132 | void aimAtTarget(); |
---|
| 133 | bool isLookingAtTarget(float angle) const; |
---|
[10725] | 134 | |
---|
[10762] | 135 | //checks if spaceship points at enemy and if there are allies inbetween |
---|
| 136 | bool canFire(); |
---|
[10737] | 137 | std::map<std::string, int> weaponModes_; //<! Links each "weapon" to it's weaponmode - managed by setupWeapons() |
---|
| 138 | //std::vector<int> projectiles_; //<! Displays amount of projectiles of each weapon. - managed by setupWeapons() |
---|
| 139 | float timeout_; //<! Timeout for rocket usage. (If a rocket misses, a bot should stop using it.) |
---|
| 140 | void setupWeapons(); //<! Defines which weapons are available for a bot. Is recalled whenever a bot was killed. |
---|
| 141 | bool bSetupWorked; //<! If false, setupWeapons() is called. |
---|
| 142 | int getFiremode(std::string name); |
---|
| 143 | |
---|
[10759] | 144 | |
---|
[10725] | 145 | bool bHasTargetPosition_; |
---|
| 146 | Vector3 targetPosition_; |
---|
| 147 | bool bHasTargetOrientation_; |
---|
| 148 | Quaternion targetOrientation_; |
---|
| 149 | |
---|
[10731] | 150 | |
---|
[10761] | 151 | bool bHasObjectivePosition_; |
---|
| 152 | Vector3 objectivePosition_; |
---|
| 153 | bool bHasObjectiveOrientation_; |
---|
| 154 | Quaternion objectiveOrientation_; |
---|
| 155 | |
---|
[10725] | 156 | WeakPtr<ControllableEntity> target_; |
---|
| 157 | bool bShooting_; |
---|
[10761] | 158 | WeakPtr<ControllableEntity> objectiveTarget_; |
---|
[10725] | 159 | |
---|
[10731] | 160 | |
---|
[10761] | 161 | |
---|
[10759] | 162 | FormationMode::Value formationMode_; |
---|
| 163 | Rank::Value rank_; |
---|
[10761] | 164 | ManeuverType::Value maneuverType_; |
---|
| 165 | Maneuver::Value maneuver_; |
---|
[10719] | 166 | |
---|
| 167 | private: |
---|
| 168 | |
---|
| 169 | |
---|
| 170 | }; |
---|
| 171 | } |
---|
| 172 | |
---|
| 173 | #endif /* _CommonController_H__ */ |
---|