[Orxonox-commit 1884] r6601 - code/branches/ai/src/orxonox/controllers

solex at orxonox.net solex at orxonox.net
Mon Mar 22 17:33:42 CET 2010


Author: solex
Date: 2010-03-22 17:33:42 +0100 (Mon, 22 Mar 2010)
New Revision: 6601

Modified:
   code/branches/ai/src/orxonox/controllers/ArtificialController.cc
   code/branches/ai/src/orxonox/controllers/ArtificialController.h
   code/branches/ai/src/orxonox/controllers/WaypointPatrolController.cc
   code/branches/ai/src/orxonox/controllers/WaypointPatrolController.h
Log:
ArtificialController: sameTeam hacking

Modified: code/branches/ai/src/orxonox/controllers/ArtificialController.cc
===================================================================
--- code/branches/ai/src/orxonox/controllers/ArtificialController.cc	2010-03-22 15:27:28 UTC (rev 6600)
+++ code/branches/ai/src/orxonox/controllers/ArtificialController.cc	2010-03-22 16:33:42 UTC (rev 6601)
@@ -29,6 +29,7 @@
 #include "ArtificialController.h"
 
 #include "core/CoreIncludes.h"
+#include "core/XMLPort.h"
 #include "worldentities/ControllableEntity.h"
 #include "worldentities/pawns/Pawn.h"
 #include "worldentities/pawns/TeamBaseMatchBase.h"
@@ -42,6 +43,8 @@
         RegisterObject(ArtificialController);
 
         this->target_ = 0;
+	this->team_ = 0;//new
+	this->isMaster_ = false;//new
         this->bShooting_ = false;
         this->bHasTargetPosition_ = false;
         this->targetPosition_ = Vector3::ZERO;
@@ -53,6 +56,13 @@
     {
     }
 
+    void ArtificialController::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+    {
+        SUPER(ArtificialController, XMLPort, xmlelement, mode);
+
+        XMLPortParam(ArtificialController, "team", setTeam, getTeam, xmlelement, mode).defaultValues(0);
+    }
+
     void ArtificialController::moveToPosition(const Vector3& target)
     {
         if (!this->getControllableEntity())
@@ -187,17 +197,27 @@
         int team1 = -1;
         int team2 = -1;
 
-        if (entity1->getXMLController())
+        Controller* controller = 0;
+        if (entity1->getController())
+            controller = entity1->getController();
+        else
+            controller = entity1->getXMLController();
+        if (controller)
         {
-            WaypointPatrolController* wpc = orxonox_cast<WaypointPatrolController*>(entity1->getXMLController());
-            if (wpc)
-                team1 = wpc->getTeam();
+            ArtificialController* ac = orxonox_cast<ArtificialController*>(controller);
+            if (ac)
+                team1 = ac->getTeam();
         }
-        if (entity2->getXMLController())
+
+        if (entity1->getController())
+            controller = entity1->getController();
+        else
+            controller = entity1->getXMLController();
+        if (controller)
         {
-            WaypointPatrolController* wpc = orxonox_cast<WaypointPatrolController*>(entity2->getXMLController());
-            if (wpc)
-                team2 = wpc->getTeam();
+            ArtificialController* ac = orxonox_cast<ArtificialController*>(controller);
+            if (ac)
+                team2 = ac->getTeam();
         }
 
         TeamDeathmatch* tdm = orxonox_cast<TeamDeathmatch*>(gametype);

Modified: code/branches/ai/src/orxonox/controllers/ArtificialController.h
===================================================================
--- code/branches/ai/src/orxonox/controllers/ArtificialController.h	2010-03-22 15:27:28 UTC (rev 6600)
+++ code/branches/ai/src/orxonox/controllers/ArtificialController.h	2010-03-22 16:33:42 UTC (rev 6601)
@@ -42,8 +42,16 @@
             ArtificialController(BaseObject* creator);
             virtual ~ArtificialController();
 
+            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);//new
+
             void abandonTarget(Pawn* target);
 
+            inline void setTeam(int team)//new
+                { this->team_ = team; }
+            inline int getTeam() const
+                { return this->team_; }
+
+
         protected:
             void targetDied();
 
@@ -68,6 +76,9 @@
             WeakPtr<Pawn> target_;
             bool bShooting_;
 
+            bool isMaster_;//new
+            int team_;//new
+
         private:
     };
 }

Modified: code/branches/ai/src/orxonox/controllers/WaypointPatrolController.cc
===================================================================
--- code/branches/ai/src/orxonox/controllers/WaypointPatrolController.cc	2010-03-22 15:27:28 UTC (rev 6600)
+++ code/branches/ai/src/orxonox/controllers/WaypointPatrolController.cc	2010-03-22 16:33:42 UTC (rev 6601)
@@ -41,7 +41,7 @@
     {
         RegisterObject(WaypointPatrolController);
 
-        this->team_ = 0;
+        //this->team_ = 0;
         this->alertnessradius_ = 500;
 
         this->patrolTimer_.setTimer(rnd(), true, createExecutor(createFunctor(&WaypointPatrolController::searchEnemy, this)));
@@ -52,7 +52,7 @@
         SUPER(WaypointPatrolController, XMLPort, xmlelement, mode);
 
         XMLPortParam(WaypointPatrolController, "alertnessradius", setAlertnessRadius, getAlertnessRadius, xmlelement, mode).defaultValues(500.0f);
-        XMLPortParam(WaypointPatrolController, "team", setTeam, getTeam, xmlelement, mode).defaultValues(0);
+//        XMLPortParam(WaypointPatrolController, "team", setTeam, getTeam, xmlelement, mode).defaultValues(0);
     }
 
     void WaypointPatrolController::tick(float dt)

Modified: code/branches/ai/src/orxonox/controllers/WaypointPatrolController.h
===================================================================
--- code/branches/ai/src/orxonox/controllers/WaypointPatrolController.h	2010-03-22 15:27:28 UTC (rev 6600)
+++ code/branches/ai/src/orxonox/controllers/WaypointPatrolController.h	2010-03-22 16:33:42 UTC (rev 6601)
@@ -45,10 +45,10 @@
             virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
             virtual void tick(float dt);
 
-            inline void setTeam(int team)
+           /* inline void setTeam(int team)
                 { this->team_ = team; }
             inline int getTeam() const
-                { return this->team_; }
+                { return this->team_; } */
 
             inline void setAlertnessRadius(float radius)
                 { this->alertnessradius_ = radius; }
@@ -58,7 +58,7 @@
         protected:
             void searchEnemy();
 
-            int team_;
+            //int team_;
             float alertnessradius_;
             Timer patrolTimer_;
     };




More information about the Orxonox-commit mailing list