[10844] | 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 | |
---|
[10847] | 29 | #include "Actionpoint.h" |
---|
[10844] | 30 | |
---|
| 31 | #include "core/CoreIncludes.h" |
---|
| 32 | #include "core/XMLPort.h" |
---|
| 33 | |
---|
| 34 | namespace orxonox |
---|
| 35 | { |
---|
[10847] | 36 | RegisterClass(Actionpoint); |
---|
[10844] | 37 | |
---|
[10847] | 38 | Actionpoint::Actionpoint(Context* context) : StaticEntity(context) |
---|
[10844] | 39 | { |
---|
[10847] | 40 | RegisterObject(Actionpoint); |
---|
[10844] | 41 | |
---|
| 42 | } |
---|
| 43 | //usage: |
---|
| 44 | // <DivisionController team=12> |
---|
[10847] | 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> |
---|
[10844] | 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> |
---|
[10847] | 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> |
---|
[10844] | 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 |
---|
[10847] | 65 | void Actionpoint::XMLPort(Element& xmlelement, XMLPort::Mode mode) |
---|
[10844] | 66 | { |
---|
[10847] | 67 | SUPER(Actionpoint, XMLPort, xmlelement, mode); |
---|
[10844] | 68 | |
---|
[10847] | 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); |
---|
[10844] | 74 | |
---|
| 75 | } |
---|
[10847] | 76 | void Actionpoint::setActionXML( std::string val) |
---|
[10844] | 77 | { |
---|
| 78 | this->actionName_ = getUppercase( val ); |
---|
[10847] | 79 | orxout(internal_error) << "action = " << this->actionName_ << endl; |
---|
[10844] | 80 | } |
---|
| 81 | |
---|
[10847] | 82 | std::string Actionpoint::getActionXML() |
---|
[10844] | 83 | { |
---|
| 84 | return this->actionName_; |
---|
| 85 | } |
---|
[10847] | 86 | void Actionpoint::setProtectXML( std::string val) |
---|
[10844] | 87 | { |
---|
| 88 | this->protectName_ = getUppercase( val ); |
---|
| 89 | } |
---|
| 90 | |
---|
[10847] | 91 | std::string Actionpoint::getProtectXML() |
---|
[10844] | 92 | { |
---|
| 93 | return this->protectName_; |
---|
| 94 | } |
---|
[10847] | 95 | void Actionpoint::setEnemyXML( std::string val) |
---|
[10844] | 96 | { |
---|
| 97 | this->enemyName_ = getUppercase( val ); |
---|
| 98 | } |
---|
| 99 | |
---|
[10847] | 100 | std::string Actionpoint::getEnemyXML() |
---|
[10844] | 101 | { |
---|
| 102 | return this->enemyName_; |
---|
| 103 | } |
---|
[10847] | 104 | void Actionpoint::setProtect( ControllableEntity* protect) |
---|
[10844] | 105 | { |
---|
[10847] | 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 | { |
---|
[10844] | 122 | this->targetPosition_ = target; |
---|
| 123 | } |
---|
[10847] | 124 | Vector3 Actionpoint::getTargetPosition () |
---|
[10844] | 125 | { |
---|
| 126 | return this->targetPosition_; |
---|
| 127 | } |
---|
| 128 | |
---|
| 129 | } |
---|