Changeset 10868
- Timestamp:
- Nov 26, 2015, 10:40:59 PM (9 years ago)
- Location:
- code/branches/campaignHS15
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/campaignHS15/data/levels/AITest.oxw
r10861 r10868 221 221 </templates> 222 222 <controller> 223 <DivisionController team=0 formationMode=" DIAMOND">223 <DivisionController team=0 formationMode="WALL" spread=100> 224 224 <actionpoints> 225 225 <Actionpoint position=" 0,2000, 0" action="FLY" loopStart=true/> -
code/branches/campaignHS15/src/orxonox/worldentities/Actionpoint.cc
r10863 r10868 29 29 #include "Actionpoint.h" 30 30 31 #include "core/CoreIncludes.h"32 #include "core/XMLPort.h"33 34 31 namespace orxonox 35 32 { … … 39 36 { 40 37 RegisterObject(Actionpoint); 41 38 39 this->actionName_ = ""; 40 this->name_ = ""; 41 42 this->bLoopStart_ = false; 43 this->bLoopEnd_ = false; 44 this->bProtectMe_ = false; 42 45 } 43 46 … … 46 49 SUPER(Actionpoint, XMLPort, xmlelement, mode); 47 50 48 XMLPortParam( Actionpoint, "action", setActionXML, getActionXML, xmlelement, mode ); 49 XMLPortParam( Actionpoint, "protect", setProtectXML, getProtectXML, xmlelement, mode ); 50 XMLPortParam( Actionpoint, "attack", setAttackXML, getAttackXML, xmlelement, mode ); 51 XMLPortParam( Actionpoint, "protectMe", setProtectMeXML, getProtectMeXML, xmlelement, mode ).defaultValues(false); 52 XMLPortParam( Actionpoint, "loopStart", setLoopStart, getLoopStart, xmlelement, mode ).defaultValues(false); 53 XMLPortParam( Actionpoint, "loopEnd", setLoopEnd, getLoopEnd, xmlelement, mode ).defaultValues(false); 54 51 XMLPortParam(Actionpoint, "action", setActionXML, getActionXML, xmlelement, mode); 52 XMLPortParam(Actionpoint, "protect", setProtectXML, getProtectXML, xmlelement, mode); 53 XMLPortParam(Actionpoint, "attack", setAttackXML, getAttackXML, xmlelement, mode); 54 XMLPortParam(Actionpoint, "protectMe", setProtectMeXML, getProtectMeXML, xmlelement, mode).defaultValues(false); 55 XMLPortParam(Actionpoint, "loopStart", setLoopStart, getLoopStart, xmlelement, mode).defaultValues(false); 56 XMLPortParam(Actionpoint, "loopEnd", setLoopEnd, getLoopEnd, xmlelement, mode).defaultValues(false); 55 57 } 56 void Actionpoint::setActionXML( std::string val) 58 /** 59 @brief 60 action is ATTACK -> returns name of object to attack 61 action is PROTECT -> returns name of object to protect 62 if asked to protect human, returns a special string. 63 @return 64 name of an object to interact with. 65 @note 66 never use more than one of following arguments for XMLPort: 67 attack, protect, protectMe or 68 loopStart and loopEnd. 69 */ 70 std::string Actionpoint::getName() const 57 71 { 58 this->actionName_ = getUppercase( val ); 59 orxout(internal_error) << "action = " << this->actionName_ << endl; 60 } 61 62 std::string Actionpoint::getActionXML() 63 { 64 return this->actionName_; 65 } 66 void Actionpoint::setProtectXML( std::string val) 67 { 68 this->protectName_ = val; 69 } 70 71 std::string Actionpoint::getProtectXML() 72 { 73 return this->protectName_; 74 } 75 void Actionpoint::setAttackXML( std::string val) 76 { 77 this->attackName_ = val; 78 } 79 80 std::string Actionpoint::getAttackXML() 81 { 82 return this->attackName_; 83 } 84 85 void Actionpoint::setTargetPosition(const Vector3& target) 86 { 87 this->targetPosition_ = target; 88 } 89 Vector3 Actionpoint::getTargetPosition () 90 { 91 return this->targetPosition_; 92 } 93 72 if (this->name_ != "") 73 { 74 return this->name_; 75 } 76 else if (this->bProtectMe_) 77 { 78 return "reservedKeyword:human"; 79 } 80 else 81 { 82 return ""; 83 } 84 } 94 85 } -
code/branches/campaignHS15/src/orxonox/worldentities/Actionpoint.h
r10863 r10868 36 36 #define _Actionpoint_H__ 37 37 38 #include "OrxonoxPrereqs.h"38 #include <string> //need string for XML input 39 39 40 #include <list> 41 #include <string> 42 #include "core/XMLNameListener.h" 43 #include "worldentities/StaticEntity.h" 40 #include "core/XMLPort.h" //need XMLPort 41 #include "worldentities/StaticEntity.h" //this is a child of StaticEntity 42 44 43 namespace orxonox 45 { 46 44 { 45 /** 46 @brief 47 Actionpoints are used by ActionpointController and all derived classes. 48 Such classes will execute actions set in Actionpoints. 49 50 In XML file one can pass an array of Actionpoints to a controller. Each 51 Actionpoint can take action type, string and boolean or 52 action and two booleans as an argument. 53 If action is set to fly, Actionpoint's position is assumed to be the desired 54 location. 55 Example XML code: 56 57 <SpaceShip position="-2000, 1500, -1000" lookat="0,0,0" team=0 name="thisShipName"> 58 <templates> 59 <Template link=spaceshipassff /> 60 </templates> 61 <controller> 62 <DivisionController team=0 formationMode="WALL"> 63 <actionpoints> 64 <Actionpoint position="0,0,0" action="FLY" /> 65 <Actionpoint position="-1000,750,-500" action="ATTACK" attack="someShipName" /> 66 <Actionpoint position="-1000,750,-500" action="PROTECT" protectMe=true /> 67 <Actionpoint position="-1000,750,-500" action="PROTECT" protect="otherShipName" /> 68 <Actionpoint position="-1000,750,-500" action="FIGHTALL" /> 69 </actionpoints> 70 </DivisionController> 71 </controller> 72 </SpaceShip> 73 74 Example with loops: 75 76 <SpaceShip position="-1500, 1500, -1000" lookat="0,0,0" team=0 name="thisShipName"> 77 <templates> 78 <Template link=spaceshipassff /> 79 </templates> 80 <controller> 81 <DivisionController team=0 formationMode="finger4"> 82 <actionpoints> 83 <Actionpoint position=" 0,2000,-600" action="FLY" loopStart=true/> 84 <Actionpoint position=" 0,2000,-700" action="FLY" /> 85 <Actionpoint position="100,2000,-700" action="FLY" /> 86 <Actionpoint position="100,2000,-600" action="FLY" loopEnd=true /> 87 </actionpoints> 88 </DivisionController> 89 </controller> 90 </SpaceShip> 91 92 For more information read descriptions of the methods. 93 */ 47 94 class _OrxonoxExport Actionpoint : public StaticEntity 48 95 { … … 51 98 virtual ~Actionpoint() {} 52 99 53 //----[XML data]---- 54 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 55 //----[Action data]---- 56 void setActionXML( std::string val); 57 std::string getActionXML(); 58 //----[/Action data]---- 59 //----[Protect data]---- 60 void setProtectXML( std::string val); 61 std::string getProtectXML(); 62 //----[/Protect data]---- 63 //----[Attack data]---- 64 void setAttackXML( std::string val); 65 std::string getAttackXML(); 66 //----[/Attack data]---- 67 //----[ProtectMe data]---- 68 inline void setProtectMeXML(bool c) 69 { 70 this->bProtectMe_ = c; 71 } 72 inline bool getProtectMeXML () 73 { 74 return this->bProtectMe_; 75 } 100 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 76 101 77 //----[/ProtectMe data]---- 102 /** @brief Decides what AI will do. @param val action to execute */ 103 void setActionXML(std::string val) 104 { this->actionName_ = getUppercase (val); } 105 std::string getActionXML() const 106 { return this->actionName_; } 78 107 79 //----[/XML data]---- 80 81 std::string getName() 82 { 83 if (protectName_ != "") 84 return protectName_; 85 else if (attackName_ != "") 86 return attackName_; 87 else if (bProtectMe_) 88 return "reservedKeyword:human"; 89 else 90 return ""; 91 } 92 void setLoopStart(bool value) 93 { 94 this->bLoopStart_ = value; 95 } 96 void setLoopEnd (bool value) 97 { 98 this->bLoopEnd_ = value; 99 } 100 //----["Waypoints" data]---- 101 void setTargetPosition(const Vector3& target); 102 Vector3 getTargetPosition (); 103 //----[/"Waypoints" data]---- 108 /** @brief Makes AI follow an entity. @param val name of entity to protect */ 109 void setProtectXML(std::string val) 110 { this->name_ = val; } 111 std::string getProtectXML() const 112 { return this->name_; } 104 113 105 bool getLoopStart() 106 { 107 return this->bLoopStart_; 108 } 109 bool getLoopEnd() 110 { 111 return this->bLoopEnd_; 112 } 113 private: 114 115 std::string actionName_; 116 std::string protectName_; 117 std::string attackName_; 114 /** @brief Makes AI attack an entity. @param val name of entity to attack */ 115 void setAttackXML(std::string val) 116 { this->name_ = val; } 117 std::string getAttackXML() const 118 { return this->name_; } 118 119 120 /** @brief Makes AI follow human player. @param c protect Human? */ 121 void setProtectMeXML(bool c) 122 { this->bProtectMe_ = c; } 123 bool getProtectMeXML() const 124 { return this->bProtectMe_; } 119 125 120 bool bLoopStart_; 121 bool bLoopEnd_; 122 bool bProtectMe_; 123 Vector3 targetPosition_; 126 /** @brief Starts a loop of Actionpoints. @param value start loop? */ 127 void setLoopStart(bool value) 128 { this->bLoopStart_ = value; } 129 bool getLoopStart() const 130 { return this->bLoopStart_; } 131 /** @brief Ends a loop of Actionpoints. @param value end loop? */ 132 void setLoopEnd (bool value) 133 { this->bLoopEnd_ = value; } 134 bool getLoopEnd() const 135 { return this->bLoopEnd_; } 136 137 std::string getName() const; 138 139 private: 140 std::string actionName_; //!< can be set to "FLY", "ATTACK", 141 //!< "PROTECT", "FIGHT", "FIGHTALL" 142 //!< or "NONE". 143 144 std::string name_; //!< name of the ship that is to be 145 //!< attacked or protected. 146 147 bool bLoopStart_; //!< if true, this and all following Actionpoints 148 //!< until the first Actionpoint with bLoopEnd_ 149 //!< set to true are executed in a loop. 150 151 bool bLoopEnd_; //!< if true, this is the last element of 152 //!< a loop started by loopStart=true argument 153 154 bool bProtectMe_; //!< if player is to be protected, 155 //!< instead of passing name, one has 156 //!< to set protectMe to true. 124 157 }; 125 158 }
Note: See TracChangeset
for help on using the changeset viewer.