[Orxonox-commit 6211] r10868 - in code/branches/campaignHS15: data/levels src/orxonox/worldentities
gania at orxonox.net
gania at orxonox.net
Thu Nov 26 22:40:59 CET 2015
Author: gania
Date: 2015-11-26 22:40:59 +0100 (Thu, 26 Nov 2015)
New Revision: 10868
Modified:
code/branches/campaignHS15/data/levels/AITest.oxw
code/branches/campaignHS15/src/orxonox/worldentities/Actionpoint.cc
code/branches/campaignHS15/src/orxonox/worldentities/Actionpoint.h
Log:
first stable version
Modified: code/branches/campaignHS15/data/levels/AITest.oxw
===================================================================
--- code/branches/campaignHS15/data/levels/AITest.oxw 2015-11-26 13:39:07 UTC (rev 10867)
+++ code/branches/campaignHS15/data/levels/AITest.oxw 2015-11-26 21:40:59 UTC (rev 10868)
@@ -220,7 +220,7 @@
<Template link=spaceshipassff />
</templates>
<controller>
- <DivisionController team=0 formationMode="DIAMOND">
+ <DivisionController team=0 formationMode="WALL" spread=100>
<actionpoints>
<Actionpoint position=" 0,2000, 0" action="FLY" loopStart=true/>
<Actionpoint position=" 0,2000,-2000" action="FLY" />
Modified: code/branches/campaignHS15/src/orxonox/worldentities/Actionpoint.cc
===================================================================
--- code/branches/campaignHS15/src/orxonox/worldentities/Actionpoint.cc 2015-11-26 13:39:07 UTC (rev 10867)
+++ code/branches/campaignHS15/src/orxonox/worldentities/Actionpoint.cc 2015-11-26 21:40:59 UTC (rev 10868)
@@ -28,9 +28,6 @@
#include "Actionpoint.h"
-#include "core/CoreIncludes.h"
-#include "core/XMLPort.h"
-
namespace orxonox
{
RegisterClass(Actionpoint);
@@ -38,57 +35,51 @@
Actionpoint::Actionpoint(Context* context) : StaticEntity(context)
{
RegisterObject(Actionpoint);
-
+
+ this->actionName_ = "";
+ this->name_ = "";
+
+ this->bLoopStart_ = false;
+ this->bLoopEnd_ = false;
+ this->bProtectMe_ = false;
}
void Actionpoint::XMLPort(Element& xmlelement, XMLPort::Mode mode)
{
SUPER(Actionpoint, XMLPort, xmlelement, mode);
- XMLPortParam( Actionpoint, "action", setActionXML, getActionXML, xmlelement, mode );
- XMLPortParam( Actionpoint, "protect", setProtectXML, getProtectXML, xmlelement, mode );
- XMLPortParam( Actionpoint, "attack", setAttackXML, getAttackXML, xmlelement, mode );
- XMLPortParam( Actionpoint, "protectMe", setProtectMeXML, getProtectMeXML, xmlelement, mode ).defaultValues(false);
- XMLPortParam( Actionpoint, "loopStart", setLoopStart, getLoopStart, xmlelement, mode ).defaultValues(false);
- XMLPortParam( Actionpoint, "loopEnd", setLoopEnd, getLoopEnd, xmlelement, mode ).defaultValues(false);
-
+ XMLPortParam(Actionpoint, "action", setActionXML, getActionXML, xmlelement, mode);
+ XMLPortParam(Actionpoint, "protect", setProtectXML, getProtectXML, xmlelement, mode);
+ XMLPortParam(Actionpoint, "attack", setAttackXML, getAttackXML, xmlelement, mode);
+ XMLPortParam(Actionpoint, "protectMe", setProtectMeXML, getProtectMeXML, xmlelement, mode).defaultValues(false);
+ XMLPortParam(Actionpoint, "loopStart", setLoopStart, getLoopStart, xmlelement, mode).defaultValues(false);
+ XMLPortParam(Actionpoint, "loopEnd", setLoopEnd, getLoopEnd, xmlelement, mode).defaultValues(false);
}
- void Actionpoint::setActionXML( std::string val)
+ /**
+ @brief
+ action is ATTACK -> returns name of object to attack
+ action is PROTECT -> returns name of object to protect
+ if asked to protect human, returns a special string.
+ @return
+ name of an object to interact with.
+ @note
+ never use more than one of following arguments for XMLPort:
+ attack, protect, protectMe or
+ loopStart and loopEnd.
+ */
+ std::string Actionpoint::getName() const
{
- this->actionName_ = getUppercase( val );
- orxout(internal_error) << "action = " << this->actionName_ << endl;
- }
-
- std::string Actionpoint::getActionXML()
- {
- return this->actionName_;
- }
- void Actionpoint::setProtectXML( std::string val)
- {
- this->protectName_ = val;
- }
-
- std::string Actionpoint::getProtectXML()
- {
- return this->protectName_;
- }
- void Actionpoint::setAttackXML( std::string val)
- {
- this->attackName_ = val;
- }
-
- std::string Actionpoint::getAttackXML()
- {
- return this->attackName_;
- }
-
- void Actionpoint::setTargetPosition(const Vector3& target)
- {
- this->targetPosition_ = target;
- }
- Vector3 Actionpoint::getTargetPosition ()
- {
- return this->targetPosition_;
- }
-
+ if (this->name_ != "")
+ {
+ return this->name_;
+ }
+ else if (this->bProtectMe_)
+ {
+ return "reservedKeyword:human";
+ }
+ else
+ {
+ return "";
+ }
+ }
}
Modified: code/branches/campaignHS15/src/orxonox/worldentities/Actionpoint.h
===================================================================
--- code/branches/campaignHS15/src/orxonox/worldentities/Actionpoint.h 2015-11-26 13:39:07 UTC (rev 10867)
+++ code/branches/campaignHS15/src/orxonox/worldentities/Actionpoint.h 2015-11-26 21:40:59 UTC (rev 10868)
@@ -35,92 +35,125 @@
#ifndef _Actionpoint_H__
#define _Actionpoint_H__
-#include "OrxonoxPrereqs.h"
+#include <string> //need string for XML input
-#include <list>
-#include <string>
-#include "core/XMLNameListener.h"
-#include "worldentities/StaticEntity.h"
+#include "core/XMLPort.h" //need XMLPort
+#include "worldentities/StaticEntity.h" //this is a child of StaticEntity
+
namespace orxonox
-{
-
+{
+ /**
+ @brief
+ Actionpoints are used by ActionpointController and all derived classes.
+ Such classes will execute actions set in Actionpoints.
+
+ In XML file one can pass an array of Actionpoints to a controller. Each
+ Actionpoint can take action type, string and boolean or
+ action and two booleans as an argument.
+ If action is set to fly, Actionpoint's position is assumed to be the desired
+ location.
+ Example XML code:
+
+ <SpaceShip position="-2000, 1500, -1000" lookat="0,0,0" team=0 name="thisShipName">
+ <templates>
+ <Template link=spaceshipassff />
+ </templates>
+ <controller>
+ <DivisionController team=0 formationMode="WALL">
+ <actionpoints>
+ <Actionpoint position="0,0,0" action="FLY" />
+ <Actionpoint position="-1000,750,-500" action="ATTACK" attack="someShipName" />
+ <Actionpoint position="-1000,750,-500" action="PROTECT" protectMe=true />
+ <Actionpoint position="-1000,750,-500" action="PROTECT" protect="otherShipName" />
+ <Actionpoint position="-1000,750,-500" action="FIGHTALL" />
+ </actionpoints>
+ </DivisionController>
+ </controller>
+ </SpaceShip>
+
+ Example with loops:
+
+ <SpaceShip position="-1500, 1500, -1000" lookat="0,0,0" team=0 name="thisShipName">
+ <templates>
+ <Template link=spaceshipassff />
+ </templates>
+ <controller>
+ <DivisionController team=0 formationMode="finger4">
+ <actionpoints>
+ <Actionpoint position=" 0,2000,-600" action="FLY" loopStart=true/>
+ <Actionpoint position=" 0,2000,-700" action="FLY" />
+ <Actionpoint position="100,2000,-700" action="FLY" />
+ <Actionpoint position="100,2000,-600" action="FLY" loopEnd=true />
+ </actionpoints>
+ </DivisionController>
+ </controller>
+ </SpaceShip>
+
+ For more information read descriptions of the methods.
+ */
class _OrxonoxExport Actionpoint : public StaticEntity
{
public:
Actionpoint(Context* context);
virtual ~Actionpoint() {}
- //----[XML data]----
- virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
- //----[Action data]----
- void setActionXML( std::string val);
- std::string getActionXML();
- //----[/Action data]----
- //----[Protect data]----
- void setProtectXML( std::string val);
- std::string getProtectXML();
- //----[/Protect data]----
- //----[Attack data]----
- void setAttackXML( std::string val);
- std::string getAttackXML();
- //----[/Attack data]----
- //----[ProtectMe data]----
- inline void setProtectMeXML(bool c)
- {
- this->bProtectMe_ = c;
- }
- inline bool getProtectMeXML ()
- {
- return this->bProtectMe_;
- }
+ virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
- //----[/ProtectMe data]----
+ /** @brief Decides what AI will do. @param val action to execute */
+ void setActionXML(std::string val)
+ { this->actionName_ = getUppercase (val); }
+ std::string getActionXML() const
+ { return this->actionName_; }
- //----[/XML data]----
-
- std::string getName()
- {
- if (protectName_ != "")
- return protectName_;
- else if (attackName_ != "")
- return attackName_;
- else if (bProtectMe_)
- return "reservedKeyword:human";
- else
- return "";
- }
- void setLoopStart(bool value)
- {
- this->bLoopStart_ = value;
- }
- void setLoopEnd (bool value)
- {
- this->bLoopEnd_ = value;
- }
- //----["Waypoints" data]----
- void setTargetPosition(const Vector3& target);
- Vector3 getTargetPosition ();
- //----[/"Waypoints" data]----
+ /** @brief Makes AI follow an entity. @param val name of entity to protect */
+ void setProtectXML(std::string val)
+ { this->name_ = val; }
+ std::string getProtectXML() const
+ { return this->name_; }
- bool getLoopStart()
- {
- return this->bLoopStart_;
- }
- bool getLoopEnd()
- {
- return this->bLoopEnd_;
- }
- private:
-
- std::string actionName_;
- std::string protectName_;
- std::string attackName_;
+ /** @brief Makes AI attack an entity. @param val name of entity to attack */
+ void setAttackXML(std::string val)
+ { this->name_ = val; }
+ std::string getAttackXML() const
+ { return this->name_; }
+ /** @brief Makes AI follow human player. @param c protect Human? */
+ void setProtectMeXML(bool c)
+ { this->bProtectMe_ = c; }
+ bool getProtectMeXML() const
+ { return this->bProtectMe_; }
- bool bLoopStart_;
- bool bLoopEnd_;
- bool bProtectMe_;
- Vector3 targetPosition_;
+ /** @brief Starts a loop of Actionpoints. @param value start loop? */
+ void setLoopStart(bool value)
+ { this->bLoopStart_ = value; }
+ bool getLoopStart() const
+ { return this->bLoopStart_; }
+ /** @brief Ends a loop of Actionpoints. @param value end loop? */
+ void setLoopEnd (bool value)
+ { this->bLoopEnd_ = value; }
+ bool getLoopEnd() const
+ { return this->bLoopEnd_; }
+
+ std::string getName() const;
+
+ private:
+ std::string actionName_; //!< can be set to "FLY", "ATTACK",
+ //!< "PROTECT", "FIGHT", "FIGHTALL"
+ //!< or "NONE".
+
+ std::string name_; //!< name of the ship that is to be
+ //!< attacked or protected.
+
+ bool bLoopStart_; //!< if true, this and all following Actionpoints
+ //!< until the first Actionpoint with bLoopEnd_
+ //!< set to true are executed in a loop.
+
+ bool bLoopEnd_; //!< if true, this is the last element of
+ //!< a loop started by loopStart=true argument
+
+ bool bProtectMe_; //!< if player is to be protected,
+ //!< instead of passing name, one has
+ //!< to set protectMe to true.
};
}
More information about the Orxonox-commit
mailing list