[Orxonox-commit 6203] r10861 - in code/branches/campaignHS15: data/levels src/orxonox/controllers

gania at orxonox.net gania at orxonox.net
Wed Nov 25 20:46:09 CET 2015


Author: gania
Date: 2015-11-25 20:46:09 +0100 (Wed, 25 Nov 2015)
New Revision: 10861

Modified:
   code/branches/campaignHS15/data/levels/AITest.oxw
   code/branches/campaignHS15/src/orxonox/controllers/CommonController.cc
   code/branches/campaignHS15/src/orxonox/controllers/CommonController.h
   code/branches/campaignHS15/src/orxonox/controllers/DivisionController.cc
   code/branches/campaignHS15/src/orxonox/controllers/SectionController.cc
Log:
finished everything, demos are commented out in AITest.oxw

Modified: code/branches/campaignHS15/data/levels/AITest.oxw
===================================================================
--- code/branches/campaignHS15/data/levels/AITest.oxw	2015-11-25 19:34:39 UTC (rev 10860)
+++ code/branches/campaignHS15/data/levels/AITest.oxw	2015-11-25 19:46:09 UTC (rev 10861)
@@ -59,7 +59,8 @@
     -->
 <!-- HERE ENDS DEMO FOR THE "WAYPOINTS" -->
 
-<!-- HERE STARTS DEMO FOR THE ACTIONPOINTS -->
+<!-- HERE STARTS DEMO FOR THE ACTIONPOINTS. 
+P.S. Never set protectMe in the first actionpoint: if human didn't spawn, that actionpoint will be skipped -->
        
     <Model mesh="cube.mesh" scale=8 position="0,0,0" />
 
@@ -70,10 +71,12 @@
       <controller>
         <DivisionController team=0 formationMode="finger4">
           <actionpoints>
-            <Actionpoint position="0,0,0" action="FLY" />
+            <Actionpoint position="0,0,0" action="FLY" /> 
             <Actionpoint position="-1000,750,-500" action="ATTACK" attack="ss3" />
-            <Actionpoint position="-1000,750,-500" action="PROTECt" protect="fuck" />
-          </actionpoints>
+            <Actionpoint position="-1000,750,-500" action="PROTECt" protectMe=true />
+            <Actionpoint position="-1000,750,-500" action="PROTECt" protect="fuck" /> 
+            <Actionpoint position="-1000,750,-500" action="FIGHTALL" />
+           </actionpoints>
         </DivisionController>
       </controller>
     </SpaceShip>
@@ -119,6 +122,7 @@
         <Template link=spaceshipassff />
       </templates>
     </SpaceShip> 
+ 
    
 <!-- HERE ENDS DEMO FOR THE ACTIONPOINTS -->
 <!-- HERE STARTS DEMO FOR FIGHTING -->

Modified: code/branches/campaignHS15/src/orxonox/controllers/CommonController.cc
===================================================================
--- code/branches/campaignHS15/src/orxonox/controllers/CommonController.cc	2015-11-25 19:34:39 UTC (rev 10860)
+++ code/branches/campaignHS15/src/orxonox/controllers/CommonController.cc	2015-11-25 19:46:09 UTC (rev 10861)
@@ -73,10 +73,12 @@
         this->bEndLoop_ = false;
         this->parsedActionpoints_.clear();
         RegisterObject( CommonController );
-
+        this->bTakenOver_ = false;
     }
     CommonController::~CommonController() 
     {
+        parsedActionpoints_.clear();
+        actionpoints_.clear();
     }
     void CommonController::tick(float dt)
     {
@@ -96,6 +98,10 @@
         {
             std::reverse(parsedActionpoints_.begin(), parsedActionpoints_.end());
             std::reverse(actionpoints_.begin(), actionpoints_.end());
+            if (this->parsedActionpoints_.empty())
+            {
+                this->action_ = Action::FIGHTALL;
+            }
         }
         if (this->bFirstTick_)
             this->bFirstTick_ = false;
@@ -821,14 +827,26 @@
                     case Action::PROTECT:
                     {
                         std::string protectName = this->loopActionpoints_.back().name;
-
-                        for (ObjectList<Pawn>::iterator itP = ObjectList<Pawn>::begin(); itP; ++itP)
+                        if (protectName == "reservedKeyword:human")
                         {
-                            if (CommonController::getName(*itP) == protectName)
+                            for (ObjectList<Pawn>::iterator itP = ObjectList<Pawn>::begin(); itP; ++itP)
                             {
-                                this->setProtect (static_cast<ControllableEntity*>(*itP));
+                                if (orxonox_cast<ControllableEntity*>(*itP) && ((*itP)->getController()) && orxonox_cast <NewHumanController*> ((*itP)->getController()))
+                                {
+                                    this->setProtect (static_cast<ControllableEntity*>(*itP));
+                                }
                             }
                         }
+                        else
+                        {
+                            for (ObjectList<Pawn>::iterator itP = ObjectList<Pawn>::begin(); itP; ++itP)
+                            {
+                                if (CommonController::getName(*itP) == protectName)
+                                {
+                                    this->setProtect (static_cast<ControllableEntity*>(*itP));
+                                }
+                            }                            
+                        }
                         if (!this->getProtect())
                         {
                             this->nextActionpoint();
@@ -914,15 +932,28 @@
                     }
                     case Action::PROTECT:
                     {
+                        
                         std::string protectName = this->parsedActionpoints_.back().name;
-
-                        for (ObjectList<Pawn>::iterator itP = ObjectList<Pawn>::begin(); itP; ++itP)
+                        if (protectName == "reservedKeyword:human")
                         {
-                            if (CommonController::getName(*itP) == protectName)
+                            for (ObjectList<Pawn>::iterator itP = ObjectList<Pawn>::begin(); itP; ++itP)
                             {
-                                this->setProtect (static_cast<ControllableEntity*>(*itP));
+                                if (orxonox_cast<ControllableEntity*>(*itP) && ((*itP)->getController()) && orxonox_cast <NewHumanController*> ((*itP)->getController()))
+                                {
+                                    this->setProtect (static_cast<ControllableEntity*>(*itP));
+                                }
                             }
                         }
+                        else
+                        {
+                            for (ObjectList<Pawn>::iterator itP = ObjectList<Pawn>::begin(); itP; ++itP)
+                            {
+                                if (CommonController::getName(*itP) == protectName)
+                                {
+                                    this->setProtect (static_cast<ControllableEntity*>(*itP));
+                                }
+                            }                            
+                        }
                         if (!this->getProtect())
                         {
                             this->nextActionpoint();
@@ -1027,12 +1058,18 @@
     {
         if (!this || !this->getControllableEntity())
             return;
-        orxout (internal_error) << "Size of actions is " << this->parsedActionpoints_.size() << endl;
+        // orxout (internal_error) << "Size of actions is " << this->parsedActionpoints_.size() << endl;
         this->startAttackingEnemiesThatAreClose();
         //No action -> pop one from stack
-        if (this->action_ == Action::NONE)
+        if (this->action_ == Action::NONE || this->bTakenOver_)
         {
+            if (this->parsedActionpoints_.empty() && this->loopActionpoints_.empty())
+            {
+                Point p = { Action::FIGHTALL, "", Vector3::ZERO, false };
+                this->parsedActionpoints_.push_back (p);
+            }
             this->executeActionpoint();
+            this->bTakenOver_ = false;
         }
         //Action fightall -> fight till nobody alive
         if (this->action_ == Action::FIGHTALL)
@@ -1133,11 +1170,9 @@
     {
       this->parsedActionpoints_ = vector;
       this->loopActionpoints_ = loop;
-      this->bLoop_ = b;
-      this->setAction (Action::NONE);
-      // this->setTarget(0);
-      // this->setTargetPosition (this->getControllableEntity()->getWorldPosition());
-      orxout(internal_error) << "Top action is " << this->parsedActionpoints_.back().action << endl;
+      this->bLoop_ = this->bLoop_;
+      this->bTakenOver_ = true;
+      // orxout(internal_error) << "Top action is " << this->parsedActionpoints_.back().action << endl;
     }
     void CommonController::boostControl()
     {

Modified: code/branches/campaignHS15/src/orxonox/controllers/CommonController.h
===================================================================
--- code/branches/campaignHS15/src/orxonox/controllers/CommonController.h	2015-11-25 19:34:39 UTC (rev 10860)
+++ code/branches/campaignHS15/src/orxonox/controllers/CommonController.h	2015-11-25 19:46:09 UTC (rev 10861)
@@ -228,7 +228,8 @@
                 bool bFirstTick_; 
                 bool bInLoop_;
                 bool bLoop_;   
-                bool bEndLoop_;                
+                bool bEndLoop_;  
+                bool bTakenOver_;              
             //----[/"Private" variables]----    
            
     };

Modified: code/branches/campaignHS15/src/orxonox/controllers/DivisionController.cc
===================================================================
--- code/branches/campaignHS15/src/orxonox/controllers/DivisionController.cc	2015-11-25 19:34:39 UTC (rev 10860)
+++ code/branches/campaignHS15/src/orxonox/controllers/DivisionController.cc	2015-11-25 19:46:09 UTC (rev 10861)
@@ -82,14 +82,28 @@
     void DivisionController::tick(float dt)
     {   
         if (!this->isActive())
-            return;
+            return;   
         SUPER(DivisionController, tick, dt);
     }
     void DivisionController::action()
     {   
         if (!this || !this->getControllableEntity())
             return;
+        
         CommonController::action();
+        if (!this || !this->getControllableEntity())
+            return;
+        if (!(this->parsedActionpoints_.empty() && this->loopActionpoints_.empty()))
+        {
+            if (this->myFollower_)
+            {
+                this->myFollower_->takeActionpoints(this->parsedActionpoints_, this->loopActionpoints_, this->bLoop_);
+            }
+            else if (this->myWingman_)
+            {
+                this->myWingman_->takeActionpoints(this->parsedActionpoints_, this->loopActionpoints_, this->bLoop_);
+            }    
+        }
         
     }
     void DivisionController::stayNearProtect()

Modified: code/branches/campaignHS15/src/orxonox/controllers/SectionController.cc
===================================================================
--- code/branches/campaignHS15/src/orxonox/controllers/SectionController.cc	2015-11-25 19:34:39 UTC (rev 10860)
+++ code/branches/campaignHS15/src/orxonox/controllers/SectionController.cc	2015-11-25 19:46:09 UTC (rev 10861)
@@ -97,7 +97,17 @@
         }
         if (!myDivisionLeader_)
         {
+            
             CommonController::action();
+            if (!this || !this->getControllableEntity())
+                return;
+            if (!(this->parsedActionpoints_.empty() && this->loopActionpoints_.empty()))
+            {
+                if (this->myWingman_)
+                {
+                    this->myWingman_->takeActionpoints(this->parsedActionpoints_, this->loopActionpoints_, this->bLoop_);
+                }    
+            }
         }
         else if (myDivisionLeader_)
         {




More information about the Orxonox-commit mailing list