Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/campaignHS15/src/orxonox/worldentities/Actionpoint.h @ 10888

Last change on this file since 10888 was 10888, checked in by gania, 8 years ago

started working on pickups

File size: 6.4 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 *      Gani Aliguzhinov
24 *   Co-authors:
25 *      ...
26 *
27 */
28
29/**
30    @file Attacher.h
31    @brief Definition of the Attacher class.
32    @ingroup Objects
33*/
34
35#ifndef _Actionpoint_H__
36#define _Actionpoint_H__
37
38#include <string>                           //need string for XML input
39
40#include "core/XMLPort.h"                   //need XMLPort
41#include "worldentities/StaticEntity.h"     //this is a child of StaticEntity
42
43namespace orxonox
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        One can also use other Worldentities instead of Actionpoints just like Waypoints, but those points
93        will be included in loop.
94        For more information read descriptions of the methods.
95    */
96    class _OrxonoxExport Actionpoint : public StaticEntity
97    {
98        public:
99            Actionpoint(Context* context);
100            virtual ~Actionpoint() {}
101
102            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
103
104            /** @brief Decides what AI will do. @param val action to execute */
105            void setActionXML(std::string val)
106                { this->actionName_ = getUppercase (val); }
107            std::string getActionXML() const
108                { return this->actionName_; }
109
110            /** @brief Makes AI follow an entity. @param val name of entity to protect */
111            void setProtectXML(std::string val)
112                { this->name_ = val; }
113            std::string getProtectXML() const
114                { return this->name_; }
115
116            /** @brief Makes AI attack an entity. @param val name of entity to attack */
117            void setAttackXML(std::string val)
118                { this->name_ = val; }
119            std::string getAttackXML() const
120                { return this->name_; }
121
122            /** @brief Makes AI follow human player. @param c protect Human? */
123            void setProtectMeXML(bool c)
124                { this->bProtectMe_ = c; }
125            bool getProtectMeXML() const
126                { return this->bProtectMe_; }
127
128            /** @brief Starts a loop of Actionpoints. @param value start loop? */
129            void setLoopStart(bool value)
130                { this->bLoopStart_ = value; }
131            bool getLoopStart() const
132                { return this->bLoopStart_; }
133            /** @brief Ends a loop of Actionpoints. @param value end loop? */
134            void setLoopEnd (bool value)
135                { this->bLoopEnd_ = value; }
136            bool getLoopEnd() const
137                { return this->bLoopEnd_; }
138
139            std::string getName() const;
140
141        private:   
142            std::string actionName_;    //!< can be set to "FLY", "ATTACK",
143                                        //!< "PROTECT", "FIGHT", "FIGHTALL"
144                                        //!< or "NONE".
145
146            std::string name_;          //!< name of the ship that is to be
147                                        //!< attacked or protected.
148
149            bool bLoopStart_;           //!< if true, this and all following Actionpoints
150                                        //!< until the first Actionpoint with bLoopEnd_
151                                        //!< set to true are executed in a loop.
152
153            bool bLoopEnd_;             //!< if true, this is the last element of
154                                        //!< a loop started by loopStart=true argument
155
156            bool bProtectMe_;           //!< if player is to be protected,
157                                        //!< instead of passing name, one has
158                                        //!< to set protectMe to true.
159    };
160}
161
162#endif /* _Actionpoint_H__ */
Note: See TracBrowser for help on using the repository browser.