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