[Orxonox-commit 4087] r8758 - in code/branches/ai2/src: modules/weapons/weaponmodes orxonox/controllers orxonox/worldentities/pawns

jo at orxonox.net jo at orxonox.net
Thu Jul 14 22:29:18 CEST 2011


Author: jo
Date: 2011-07-14 22:29:18 +0200 (Thu, 14 Jul 2011)
New Revision: 8758

Modified:
   code/branches/ai2/src/modules/weapons/weaponmodes/FusionFire.cc
   code/branches/ai2/src/orxonox/controllers/AIController.cc
   code/branches/ai2/src/orxonox/controllers/ArtificialController.cc
   code/branches/ai2/src/orxonox/controllers/Controller.cc
   code/branches/ai2/src/orxonox/controllers/Controller.h
   code/branches/ai2/src/orxonox/worldentities/pawns/Pawn.cc
Log:
Code clean up.

Modified: code/branches/ai2/src/modules/weapons/weaponmodes/FusionFire.cc
===================================================================
--- code/branches/ai2/src/modules/weapons/weaponmodes/FusionFire.cc	2011-07-13 19:42:03 UTC (rev 8757)
+++ code/branches/ai2/src/modules/weapons/weaponmodes/FusionFire.cc	2011-07-14 20:29:18 UTC (rev 8758)
@@ -51,7 +51,6 @@
         this->speed_ = 1250;
 
         this->setMunitionName("FusionMunition");
-        this->setName("FUSION_FIRE");
     }
 
     /* Creates the projectile (BillboardProjectile) object, sets its properties to the FusionFire properties

Modified: code/branches/ai2/src/orxonox/controllers/AIController.cc
===================================================================
--- code/branches/ai2/src/orxonox/controllers/AIController.cc	2011-07-13 19:42:03 UTC (rev 8757)
+++ code/branches/ai2/src/orxonox/controllers/AIController.cc	2011-07-14 20:29:18 UTC (rev 8758)
@@ -195,6 +195,10 @@
                 if (random < ( (1- botlevel_)*25 ) && (this->bShooting_))
                     this->bShooting_ = false;
 
+                //boost
+                random = rnd(maxrand);
+                if (random < botlevel_*100 )
+                    this->boostControl(); //TEST
             }
         }
 
@@ -204,13 +208,7 @@
     {
         if (!this->isActive())
             return;
-        if(this->bDeathFlag_)//If a bot died recently, make him check his weaponsystem.
-        {
-            this->bSetupWorked = false;
-            this->numberOfWeapons = 0;
-            this->resetDeathFlag();
-        }
-        this->boostControl();//TEST
+
         float random;
         float maxrand = 100.0f / ACTION_INTERVAL;
         if(this->mode_ == DEFAULT)
@@ -228,7 +226,7 @@
                             this->aimAtTarget();
                             random = rnd(maxrand);
                             if(this->botlevel_*100 > random)
-                                this->follow();//If a bot is shooting a player, it shouldn't let him go away easily.
+                                this->follow();  //If a bot is shooting a player, it shouldn't let him go away easily.
                         }
                     }
 
@@ -276,7 +274,7 @@
         }//END_OF DEFAULT MODE
         else if (this->mode_ == ROCKET)//Rockets do not belong to a group of bots -> bot states are not relevant.
         {   //Vector-implementation: mode_.back() == ROCKET;
-            ControllableEntity *controllable = this->getControllableEntity(); 
+            ControllableEntity *controllable = this->getControllableEntity();
             if(controllable)
             {
                 if(controllable->getRocket())//Check wether the bot is controlling the rocket and if the timeout is over.

Modified: code/branches/ai2/src/orxonox/controllers/ArtificialController.cc
===================================================================
--- code/branches/ai2/src/orxonox/controllers/ArtificialController.cc	2011-07-13 19:42:03 UTC (rev 8757)
+++ code/branches/ai2/src/orxonox/controllers/ArtificialController.cc	2011-07-14 20:29:18 UTC (rev 8758)
@@ -316,6 +316,9 @@
     {
         if (!this->getControllableEntity())
             this->removeFromFormation();
+        this->bSetupWorked = false;        // reset weapon information
+        this->numberOfWeapons = 0;
+        COUT(0)<<"ArtificialController::changedControllableEntity()"<<endl; //why is this function called more than once ??
     }
 
     void ArtificialController::removeFromFormation()
@@ -1134,7 +1137,7 @@
     void ArtificialController::analyseWeapons(Pawn* pawn)
     {
         int max=10, i=0, j=0, k=0;
-        if(!pawn) {COUT(0)<<"NO PAWN"<<std::endl; return;}
+        if(!pawn) return;
         while(i<max)
         {
             WeaponPack* wPack = pawn->getWeaponPack(i); //WeaponSet* wSet = pawn->getWeaponSet(i);
@@ -1150,7 +1153,7 @@
                     WeaponMode* wMode = wpn->getWeaponmode(k);
                     k++;
                     if(wMode==NULL) continue;
-                    COUT(0)<<wMode->getName()<<": weaponpack "+multi_cast<std::string>(i-1)<<", weapon "<<multi_cast<std::string>(j-1)<<", weaponmode "<<multi_cast<std::string>(k-1)<<std::endl;
+                    COUT(0)<<wMode->getIdentifier()->getName()<<": weaponpack "+multi_cast<std::string>(i-1)<<", weapon "<<multi_cast<std::string>(j-1)<<", weaponmode "<<multi_cast<std::string>(k-1)<<std::endl;
                 }
             }
         }

Modified: code/branches/ai2/src/orxonox/controllers/Controller.cc
===================================================================
--- code/branches/ai2/src/orxonox/controllers/Controller.cc	2011-07-13 19:42:03 UTC (rev 8757)
+++ code/branches/ai2/src/orxonox/controllers/Controller.cc	2011-07-14 20:29:18 UTC (rev 8758)
@@ -41,7 +41,6 @@
         this->player_ = 0;
         this->controllableEntity_ = 0;
         this->bGodMode_ = false;
-        this->bDeathFlag_ = false;
     }
 
     Controller::~Controller()

Modified: code/branches/ai2/src/orxonox/controllers/Controller.h
===================================================================
--- code/branches/ai2/src/orxonox/controllers/Controller.h	2011-07-13 19:42:03 UTC (rev 8757)
+++ code/branches/ai2/src/orxonox/controllers/Controller.h	2011-07-14 20:29:18 UTC (rev 8758)
@@ -62,10 +62,6 @@
 
             inline ControllableEntity* getControllableEntity() const
                 { return this->controllableEntity_; }
-            inline void setDeathFlag()
-                { this->bDeathFlag_ = true; }
-            inline void resetDeathFlag()
-                { this->bDeathFlag_ = false; }
             virtual void changedControllableEntity() {}
 
         protected:
@@ -82,7 +78,6 @@
         protected:
             PlayerInfo* player_;
             ControllableEntity* controllableEntity_;
-            bool bDeathFlag_; //<! Signal, when a controlled entity died. Flag is set in Pawn.cc and used in AIController.
         private:
             bool bGodMode_;
     };

Modified: code/branches/ai2/src/orxonox/worldentities/pawns/Pawn.cc
===================================================================
--- code/branches/ai2/src/orxonox/worldentities/pawns/Pawn.cc	2011-07-13 19:42:03 UTC (rev 8757)
+++ code/branches/ai2/src/orxonox/worldentities/pawns/Pawn.cc	2011-07-14 20:29:18 UTC (rev 8758)
@@ -93,7 +93,7 @@
         this->registerVariables();
 
         this->isHumanShip_ = this->hasLocalController();
-        
+
         this->setSyncMode(ObjectDirection::Bidirectional); // needed to synchronise e.g. aimposition
     }
 
@@ -303,10 +303,6 @@
         this->setHealth(1);
         if (this->getGametype() && this->getGametype()->allowPawnDeath(this, this->lastHitOriginator_))
         {
-            if ( this->getController()&& (!this->isHumanShip_) ) //announce death to the ai
-            {
-                 this->getController()->setDeathFlag();
-            }
             // Set bAlive_ to false and wait for PawnManager to do the destruction
             this->bAlive_ = false;
 




More information about the Orxonox-commit mailing list