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 | |
---|
34 | namespace 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 | |
---|
75 | } |
---|
76 | void Actionpoint::setActionXML( std::string val) |
---|
77 | { |
---|
78 | this->actionName_ = getUppercase( val ); |
---|
79 | orxout(internal_error) << "action = " << this->actionName_ << endl; |
---|
80 | } |
---|
81 | |
---|
82 | std::string Actionpoint::getActionXML() |
---|
83 | { |
---|
84 | return this->actionName_; |
---|
85 | } |
---|
86 | void Actionpoint::setProtectXML( std::string val) |
---|
87 | { |
---|
88 | this->protectName_ = getUppercase( val ); |
---|
89 | } |
---|
90 | |
---|
91 | std::string Actionpoint::getProtectXML() |
---|
92 | { |
---|
93 | return this->protectName_; |
---|
94 | } |
---|
95 | void Actionpoint::setEnemyXML( std::string val) |
---|
96 | { |
---|
97 | this->enemyName_ = getUppercase( val ); |
---|
98 | } |
---|
99 | |
---|
100 | std::string Actionpoint::getEnemyXML() |
---|
101 | { |
---|
102 | return this->enemyName_; |
---|
103 | } |
---|
104 | void Actionpoint::setProtect( ControllableEntity* protect) |
---|
105 | { |
---|
106 | this->protect_ = protect; |
---|
107 | } |
---|
108 | ControllableEntity* Actionpoint::getProtect() |
---|
109 | { |
---|
110 | return this->protect_; |
---|
111 | } |
---|
112 | void Actionpoint::setEnemy( ControllableEntity* enemy) |
---|
113 | { |
---|
114 | this->enemy_ = enemy; |
---|
115 | } |
---|
116 | ControllableEntity* Actionpoint::getEnemy() |
---|
117 | { |
---|
118 | return this->enemy_; |
---|
119 | } |
---|
120 | void Actionpoint::setTargetPosition(const Vector3& target) |
---|
121 | { |
---|
122 | this->targetPosition_ = target; |
---|
123 | } |
---|
124 | Vector3 Actionpoint::getTargetPosition () |
---|
125 | { |
---|
126 | return this->targetPosition_; |
---|
127 | } |
---|
128 | |
---|
129 | } |
---|