Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/campaignHS15/src/orxonox/worldentities/ActionPoint.cc @ 10856

Last change on this file since 10856 was 10855, checked in by gania, 9 years ago

introduced loops

File size: 4.7 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 *      Fabian 'x3n' Landau
24 *   Co-authors:
25 *      ...
26 *
27 */
28
29#include "Actionpoint.h"
30
31#include "core/CoreIncludes.h"
32#include "core/XMLPort.h"
33
34namespace orxonox
35{
36    RegisterClass(Actionpoint);
37
38    Actionpoint::Actionpoint(Context* context) : StaticEntity(context)
39    {
40        RegisterObject(Actionpoint);
41
42    }
43    //usage:
44    // <DivisionController team=12>
45    //     <Actionpoints>
46    //          <Actionpoint position="12,34,56" action="FIGHT" enemy="enemyName" />, position irrelevant
47    //          <Actionpoint position="12,34,56" action="PROTECT" protect="protectName" />, position irrelevant
48    //          <Actionpoint position="12,34,56" action="FLY" />, position relevant: makes ship fly to the position of Actionpoint
49    //     </Actionpoints>
50    // </DivisonController>
51    //DivisionController will firstly fight enemy that it will find by name "enemyName", if finds nothing or when beats enemy,
52    //it will protect ship that it will find by name "protectName", when it's dead or if it doesn't find the ship,
53    //it will fly towards "12,34,56"
54    //when it finishes all, it stays at that location.
55    //At all the times it will check if there are enemies near DivisionController, if yes, it will fight them
56    //another usage:
57    // <DivisionController team=12>
58    //     <Actionpoints>
59    //          <Actionpoint position="12,34,56" action="PROTECT" protectMe=true />, position irrelevant
60    //          <Actionpoint position="12,34,56" action="FIGHT" fightAll=true />, position irrelevant
61    //     </Actionpoints>
62    // </DivisonController>
63    //DivisionController will protect the first NewHumanController it finds, when it dies or if no controller found,
64    //it will fight closest enemies one after another
65    void Actionpoint::XMLPort(Element& xmlelement, XMLPort::Mode mode)
66    {
67        SUPER(Actionpoint, XMLPort, xmlelement, mode);
68       
69        XMLPortParam( Actionpoint, "action", setActionXML, getActionXML,  xmlelement, mode );
70        XMLPortParam( Actionpoint, "protect", setProtectXML, getProtectXML,  xmlelement, mode );
71        XMLPortParam( Actionpoint, "enemy", setEnemyXML, getEnemyXML,  xmlelement, mode );
72        XMLPortParam( Actionpoint, "protectMe", setProtectMeXML, getProtectMeXML,  xmlelement, mode ).defaultValues(false);
73        XMLPortParam( Actionpoint, "fightAll", setFightAllXML, getFightAllXML,  xmlelement, mode ).defaultValues(false);
74        XMLPortParam( Actionpoint, "loopStart", setLoopStart, getLoopStart,  xmlelement, mode ).defaultValues(false);
75        XMLPortParam( Actionpoint, "loopEnd", setLoopEnd, getLoopEnd,  xmlelement, mode ).defaultValues(false);
76
77    }
78    void Actionpoint::setActionXML( std::string val)
79    {
80        this->actionName_ = getUppercase( val );
81        orxout(internal_error) << "action = " << this->actionName_ << endl;
82    }
83
84    std::string Actionpoint::getActionXML()
85    {
86        return this->actionName_;
87    }
88    void Actionpoint::setProtectXML( std::string val)
89    {
90        this->protectName_ = getUppercase( val );
91    }
92
93    std::string Actionpoint::getProtectXML()
94    {
95        return this->protectName_;
96    }
97    void Actionpoint::setEnemyXML( std::string val)
98    {
99        this->enemyName_ = getUppercase( val );
100    }
101
102    std::string Actionpoint::getEnemyXML()
103    {
104        return this->enemyName_;
105    }
106    void Actionpoint::setProtect( ControllableEntity* protect)
107    {
108        this->protect_ = protect;
109    }
110    ControllableEntity* Actionpoint::getProtect()
111    {
112        return this->protect_;
113    }
114    void Actionpoint::setEnemy( ControllableEntity* enemy)
115    {
116        this->enemy_ = enemy;
117    }
118    ControllableEntity* Actionpoint::getEnemy()
119    {
120        return this->enemy_;
121    }
122    void Actionpoint::setTargetPosition(const Vector3& target)
123    {
124        this->targetPosition_ = target;
125    }
126    Vector3 Actionpoint::getTargetPosition ()
127    {
128        return this->targetPosition_;
129    }
130   
131}
Note: See TracBrowser for help on using the repository browser.