[Orxonox-commit 4334] r9005 - code/branches/presentation2011/src/orxonox/controllers

willis at orxonox.net willis at orxonox.net
Mon Dec 19 14:43:04 CET 2011


Author: willis
Date: 2011-12-19 14:43:04 +0100 (Mon, 19 Dec 2011)
New Revision: 9005

Modified:
   code/branches/presentation2011/src/orxonox/controllers/AIController.cc
   code/branches/presentation2011/src/orxonox/controllers/FormationController.cc
   code/branches/presentation2011/src/orxonox/controllers/HumanController.cc
   code/branches/presentation2011/src/orxonox/controllers/HumanController.h
   code/branches/presentation2011/src/orxonox/controllers/NewHumanController.cc
Log:
fixed merging some merging bugs and some other bugs...

Modified: code/branches/presentation2011/src/orxonox/controllers/AIController.cc
===================================================================
--- code/branches/presentation2011/src/orxonox/controllers/AIController.cc	2011-12-18 19:19:08 UTC (rev 9004)
+++ code/branches/presentation2011/src/orxonox/controllers/AIController.cc	2011-12-19 13:43:04 UTC (rev 9005)
@@ -58,45 +58,47 @@
 
         if (this->state_ == FREE)
         {
-
+            
             if (this->formationFlight_)
             {
+
+                //changed order -> searchNewMaster MUSTN'T be called in SLAVE-state (bugfix for internal-error messages at quit)
+                random = rnd(maxrand);
+                if (random < 90 && (((!this->target_) || (random < 50 && this->target_)) && !this->forcedFree()))
+                       this->searchNewMaster();
+
                 // return to Master after being forced free
                 if (this->freedomCount_ == 1)
                 {
                     this->state_ = SLAVE;
                     this->freedomCount_ = 0;
                 }
-
-                random = rnd(maxrand);
-                if (random < 90 && (((!this->target_) || (random < 50 && this->target_)) && !this->forcedFree()))
-                    this->searchNewMaster();
             }
 
             this->defaultBehaviour(maxrand);
 
         }
 
-        if (this->state_ == SLAVE && this->formationMode_ == ATTACK) //TODO: add botlevel parameter
+        if (this->state_ == SLAVE && this->formationMode_ == ATTACK) 
         {
             // search enemy
             random = rnd(maxrand);
-            if (random < 75 && (!this->target_))
+            if (random < (botlevel_*100) && (!this->target_))
                 this->searchNewTarget();
 
             // next enemy
             random = rnd(maxrand);
-            if (random < 10 && (this->target_))
+            if (random < (botlevel_*30) && (this->target_))
                 this->searchNewTarget();
 
             // shoot
             random = rnd(maxrand);
-            if (!(this->passive_) && random < 75 && (this->target_ && !this->bShooting_))
+            if (!(this->passive_) && random < (botlevel_*100) && (this->target_ && !this->bShooting_))
                 this->bShooting_ = true;
 
             // stop shooting
             random = rnd(maxrand);
-            if (random < 25 && (this->bShooting_))
+            if (random < (1-botlevel_)*50 && (this->bShooting_))
                 this->bShooting_ = false;
 
         }

Modified: code/branches/presentation2011/src/orxonox/controllers/FormationController.cc
===================================================================
--- code/branches/presentation2011/src/orxonox/controllers/FormationController.cc	2011-12-18 19:19:08 UTC (rev 9004)
+++ code/branches/presentation2011/src/orxonox/controllers/FormationController.cc	2011-12-19 13:43:04 UTC (rev 9005)
@@ -382,7 +382,8 @@
 
     void FormationController::searchNewMaster()
     {
-
+        if (this->state_==SLAVE) 
+           return;
         if (!this->getControllableEntity())
             return;
 
@@ -587,12 +588,11 @@
     */
     void FormationController::takeLeadOfFormation()
     {
-        if (!this->getControllableEntity())
+        if (!this->getControllableEntity() || this->state_==MASTER)
             return;
 
-	if (this->state_==MASTER) return;
         //search new Master, then take lead
-        if (this->state_==FREE)
+        if (this->state_==FREE && this->myMaster_==0)
         {
           searchNewMaster();
         }

Modified: code/branches/presentation2011/src/orxonox/controllers/HumanController.cc
===================================================================
--- code/branches/presentation2011/src/orxonox/controllers/HumanController.cc	2011-12-18 19:19:08 UTC (rev 9004)
+++ code/branches/presentation2011/src/orxonox/controllers/HumanController.cc	2011-12-19 13:43:04 UTC (rev 9005)
@@ -77,11 +77,9 @@
         this->controlPaused_ = false;
         this->boosting_ = false;
         this->boosting_ = false;
-        this->tempMaster=NULL;
         HumanController::localController_s = this;
         this->boostingTimeout_.setTimer(HumanController::BOOSTING_TIME, false, createExecutor(createFunctor(&HumanController::terminateBoosting, this)));
         this->boostingTimeout_.stopTimer();
-        this->state_=FREE;
     }
 
     HumanController::~HumanController()

Modified: code/branches/presentation2011/src/orxonox/controllers/HumanController.h
===================================================================
--- code/branches/presentation2011/src/orxonox/controllers/HumanController.h	2011-12-18 19:19:08 UTC (rev 9004)
+++ code/branches/presentation2011/src/orxonox/controllers/HumanController.h	2011-12-19 13:43:04 UTC (rev 9005)
@@ -112,7 +112,6 @@
             bool boosting_; // Whether the HumanController is in boosting mode or not.
             Timer boostingTimeout_; // A timer to check whether the player is no longer boosting.
             static const float BOOSTING_TIME; // The time after it is checked, whether the player is no longer boosting.
-            FormationController* tempMaster;
 
     }; // tolua_export
 } // tolua_export

Modified: code/branches/presentation2011/src/orxonox/controllers/NewHumanController.cc
===================================================================
--- code/branches/presentation2011/src/orxonox/controllers/NewHumanController.cc	2011-12-18 19:19:08 UTC (rev 9004)
+++ code/branches/presentation2011/src/orxonox/controllers/NewHumanController.cc	2011-12-19 13:43:04 UTC (rev 9005)
@@ -276,7 +276,7 @@
         HumanController::tick(dt);
     }
 
-    void NewHumanController::doFire(unsigned int firemode)//TODO??
+    void NewHumanController::doFire(unsigned int firemode)
     {
         if (!this->controllableEntity_)
             return;
@@ -290,8 +290,7 @@
             HumanController::pitch(Vector2(this->currentPitch_, 0));
         }
         else
-            HumanController::localController_s->getControllableEntity()->fire(firemode);
-
+            HumanController::doFire(firemode); //call for formationflight
     }
 
     void NewHumanController::hit(Pawn* originator, btManifoldPoint& contactpoint, float damage)




More information about the Orxonox-commit mailing list