| 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 _Actionpoint_H__ | 
|---|
| 30 | #define _Actionpoint_H__ | 
|---|
| 31 |  | 
|---|
| 32 | #include <string>                           //need string for XML input | 
|---|
| 33 |  | 
|---|
| 34 | #include "core/XMLPort.h"                   //need XMLPort | 
|---|
| 35 | #include "worldentities/StaticEntity.h"     //this is a child of StaticEntity | 
|---|
| 36 |  | 
|---|
| 37 | namespace orxonox | 
|---|
| 38 | { | 
|---|
| 39 | /** | 
|---|
| 40 | @brief | 
|---|
| 41 | Actionpoints are used by ActionpointController and all derived classes. | 
|---|
| 42 | Such classes will execute actions set in Actionpoints. | 
|---|
| 43 |  | 
|---|
| 44 | In XML file one can pass an array of Actionpoints to a controller. Each | 
|---|
| 45 | Actionpoint can take action type, string and boolean or | 
|---|
| 46 | action and two booleans as an argument. | 
|---|
| 47 | If action is set to fly, Actionpoint's position is assumed to be the desired | 
|---|
| 48 | location. | 
|---|
| 49 | Example XML code: | 
|---|
| 50 |  | 
|---|
| 51 | <SpaceShip position="-2000, 1500, -1000" lookat="0,0,0" team=0 name="thisShipName"> | 
|---|
| 52 | <templates> | 
|---|
| 53 | <Template link=spaceshipassff /> | 
|---|
| 54 | </templates> | 
|---|
| 55 | <controller> | 
|---|
| 56 | <DivisionController team=0 formationMode="WALL"> | 
|---|
| 57 | <actionpoints> | 
|---|
| 58 | <Actionpoint position="0,0,0" action="FLY" /> | 
|---|
| 59 | <Actionpoint position="-1000,750,-500" action="ATTACK" attack="someShipName" /> | 
|---|
| 60 | <Actionpoint position="-1000,750,-500" action="PROTECT" protectMe=true /> | 
|---|
| 61 | <Actionpoint position="-1000,750,-500" action="PROTECT" protect="otherShipName" /> | 
|---|
| 62 | <Actionpoint position="-1000,750,-500" action="FIGHTALL" /> | 
|---|
| 63 | </actionpoints> | 
|---|
| 64 | </DivisionController> | 
|---|
| 65 | </controller> | 
|---|
| 66 | </SpaceShip> | 
|---|
| 67 |  | 
|---|
| 68 | Example with loops: | 
|---|
| 69 |  | 
|---|
| 70 | <SpaceShip position="-1500, 1500, -1000" lookat="0,0,0" team=0 name="thisShipName"> | 
|---|
| 71 | <templates> | 
|---|
| 72 | <Template link=spaceshipassff /> | 
|---|
| 73 | </templates> | 
|---|
| 74 | <controller> | 
|---|
| 75 | <DivisionController team=0 formationMode="finger4"> | 
|---|
| 76 | <actionpoints> | 
|---|
| 77 | <Actionpoint position="  0,2000,-600" action="FLY" loopStart=true/> | 
|---|
| 78 | <Actionpoint position="  0,2000,-700" action="FLY"  /> | 
|---|
| 79 | <Actionpoint position="100,2000,-700" action="FLY" /> | 
|---|
| 80 | <Actionpoint position="100,2000,-600" action="FLY" loopEnd=true /> | 
|---|
| 81 | </actionpoints> | 
|---|
| 82 | </DivisionController> | 
|---|
| 83 | </controller> | 
|---|
| 84 | </SpaceShip> | 
|---|
| 85 |  | 
|---|
| 86 | One can also use other Worldentities instead of Actionpoints just like Waypoints, but those points | 
|---|
| 87 | will be included in loop. | 
|---|
| 88 | For more information read descriptions of the methods. | 
|---|
| 89 | */ | 
|---|
| 90 | class _OrxonoxExport Actionpoint : public StaticEntity | 
|---|
| 91 | { | 
|---|
| 92 | public: | 
|---|
| 93 | Actionpoint(Context* context); | 
|---|
| 94 | virtual ~Actionpoint() = default; | 
|---|
| 95 |  | 
|---|
| 96 | virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override; | 
|---|
| 97 |  | 
|---|
| 98 | /** @brief Decides what AI will do. @param val action to execute */ | 
|---|
| 99 | void setActionXML(std::string val) | 
|---|
| 100 | { this->actionName_ = getUppercase (val); } | 
|---|
| 101 | std::string getActionXML() const | 
|---|
| 102 | { return this->actionName_; } | 
|---|
| 103 |  | 
|---|
| 104 | /** @brief Makes AI follow an entity. @param val name of entity to protect */ | 
|---|
| 105 | void setProtectXML(std::string val) | 
|---|
| 106 | { this->name_ = val; } | 
|---|
| 107 | std::string getProtectXML() const | 
|---|
| 108 | { return this->name_; } | 
|---|
| 109 |  | 
|---|
| 110 | /** @brief Makes AI attack an entity. @param val name of entity to attack */ | 
|---|
| 111 | void setAttackXML(std::string val) | 
|---|
| 112 | { this->name_ = val; } | 
|---|
| 113 | std::string getAttackXML() const | 
|---|
| 114 | { return this->name_; } | 
|---|
| 115 |  | 
|---|
| 116 | /** @brief Makes AI follow human player. @param c protect Human? */ | 
|---|
| 117 | void setProtectMeXML(bool c) | 
|---|
| 118 | { this->bProtectMe_ = c; } | 
|---|
| 119 | bool getProtectMeXML() const | 
|---|
| 120 | { return this->bProtectMe_; } | 
|---|
| 121 |  | 
|---|
| 122 | /** @brief Starts a loop of Actionpoints. @param value start loop? */ | 
|---|
| 123 | void setLoopStart(bool value) | 
|---|
| 124 | { this->bLoopStart_ = value; } | 
|---|
| 125 | bool getLoopStart() const | 
|---|
| 126 | { return this->bLoopStart_; } | 
|---|
| 127 | /** @brief Ends a loop of Actionpoints. @param value end loop? */ | 
|---|
| 128 | void setLoopEnd (bool value) | 
|---|
| 129 | { this->bLoopEnd_ = value; } | 
|---|
| 130 | bool getLoopEnd() const | 
|---|
| 131 | { return this->bLoopEnd_; } | 
|---|
| 132 |  | 
|---|
| 133 | std::string getName() const; | 
|---|
| 134 |  | 
|---|
| 135 | private: | 
|---|
| 136 | std::string actionName_;    //!< can be set to "FLY", "ATTACK", | 
|---|
| 137 | //!< "PROTECT", "FIGHT", "FIGHTALL" | 
|---|
| 138 | //!< or "NONE". | 
|---|
| 139 |  | 
|---|
| 140 | std::string name_;          //!< name of the ship that is to be | 
|---|
| 141 | //!< attacked or protected. | 
|---|
| 142 |  | 
|---|
| 143 | bool bLoopStart_;           //!< if true, this and all following Actionpoints | 
|---|
| 144 | //!< until the first Actionpoint with bLoopEnd_ | 
|---|
| 145 | //!< set to true are executed in a loop. | 
|---|
| 146 |  | 
|---|
| 147 | bool bLoopEnd_;             //!< if true, this is the last element of | 
|---|
| 148 | //!< a loop started by loopStart=true argument | 
|---|
| 149 |  | 
|---|
| 150 | bool bProtectMe_;           //!< if player is to be protected, | 
|---|
| 151 | //!< instead of passing name, one has | 
|---|
| 152 | //!< to set protectMe to true. | 
|---|
| 153 | }; | 
|---|
| 154 | } | 
|---|
| 155 |  | 
|---|
| 156 | #endif /* _Actionpoint_H__ */ | 
|---|