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

gania at orxonox.net gania at orxonox.net
Sat Nov 28 11:46:05 CET 2015


Author: gania
Date: 2015-11-28 11:46:05 +0100 (Sat, 28 Nov 2015)
New Revision: 10883

Modified:
   code/branches/campaignHS15/data/levels/AITest.oxw
   code/branches/campaignHS15/src/orxonox/controllers/ActionpointController.cc
   code/branches/campaignHS15/src/orxonox/controllers/DivisionController.cc
   code/branches/campaignHS15/src/orxonox/controllers/FightingController.cc
   code/branches/campaignHS15/src/orxonox/controllers/FightingController.h
   code/branches/campaignHS15/src/orxonox/controllers/SectionController.cc
   code/branches/campaignHS15/src/orxonox/controllers/WingmanController.cc
Log:
ships spread before fight

Modified: code/branches/campaignHS15/data/levels/AITest.oxw
===================================================================
--- code/branches/campaignHS15/data/levels/AITest.oxw	2015-11-28 09:16:31 UTC (rev 10882)
+++ code/branches/campaignHS15/data/levels/AITest.oxw	2015-11-28 10:46:05 UTC (rev 10883)
@@ -34,7 +34,7 @@
     <TeamSpawnPoint team=0 position="-1000,-1000,-1000" lookat="1,1,-1" spawnclass=SpaceShip pawndesign=spaceshipassff />
     
 <!-- HERE STARTS DEMO FOR THE "WAYPOINTS" -->
-      
+      <!-- 
     <Model mesh="cube.mesh" scale=8 position="  0,2000,-600" />
     <Model mesh="cube.mesh" scale=8 position="  0,2000,-800" />
     <Model mesh="cube.mesh" scale=8 position="200,2000,-800" />
@@ -56,7 +56,7 @@
         </DivisionController>
       </controller>
     </SpaceShip> 
-   
+    -->
 <!-- HERE ENDS DEMO FOR THE "WAYPOINTS" -->
 
 <!-- HERE STARTS DEMO FOR THE ACTIONPOINTS. 
@@ -127,7 +127,7 @@
 <!-- HERE ENDS DEMO FOR THE ACTIONPOINTS -->
 <!-- HERE STARTS DEMO FOR FIGHTING -->
     <!-- 
-    <SpaceShip position="-2000, 1500, -1000" lookat="0,0,0" team=0 name="ss2">
+    <SpaceShip position="-4000, 1500, -1000" lookat="0,0,0" team=0 name="ss2">
       <templates>
         <Template link=spaceshipassff />
       </templates>
@@ -139,7 +139,7 @@
         </DivisionController>
       </controller>
     </SpaceShip>
-    <SpaceShip position="-2000, 1900, -1000" lookat="0,0,0" team=0>
+    <SpaceShip position="-4000, 1900, -1000" lookat="0,0,0" team=0>
       <templates>
         <Template link=spaceshipassff />
       </templates>
@@ -148,7 +148,7 @@
         </SectionController>
       </controller>
     </SpaceShip>
-    <SpaceShip position="-2000, 2100, -1000" lookat="0,0,0" team=0>
+    <SpaceShip position="-4000, 2100, -1000" lookat="0,0,0" team=0>
       <templates>
         <Template link=spaceshipassff />
       </templates>
@@ -157,7 +157,7 @@
         </WingmanController>
       </controller>
     </SpaceShip>
-    <SpaceShip position="-2000, 2400, -1000" lookat="0,0,0" team=0>
+    <SpaceShip position="-4000, 2400, -1000" lookat="0,0,0" team=0>
       <templates>
         <Template link=spaceshipassff />
       </templates>
@@ -209,7 +209,7 @@
      -->
 <!-- HERE ENDS DEMO FOR FIGHTING -->
 <!-- HERE STARTS DEMO FOR FORMATIONS -->
-    <!-- 
+    
     <Model mesh="cube.mesh" scale=8 position="   0,2000,    0" />
     <Model mesh="cube.mesh" scale=8 position="   0,2000,-2000" />
     <Model mesh="cube.mesh" scale=8 position="2000,2000,-2000" />
@@ -258,7 +258,7 @@
         </WingmanController>
       </controller>
     </SpaceShip> 
-    -->
+   
 <!-- HERE ENDS DEMO FOR FORMATIONS -->
     <!-- 
     <SpaceShip position="2000, 2000, 2000" lookat="0,0,0" team=1 name="ss2">

Modified: code/branches/campaignHS15/src/orxonox/controllers/ActionpointController.cc
===================================================================
--- code/branches/campaignHS15/src/orxonox/controllers/ActionpointController.cc	2015-11-28 09:16:31 UTC (rev 10882)
+++ code/branches/campaignHS15/src/orxonox/controllers/ActionpointController.cc	2015-11-28 10:46:05 UTC (rev 10883)
@@ -40,6 +40,7 @@
 
     ActionpointController::ActionpointController(Context* context) : FightingController(context)
     {
+        this->actionCounter_ = 0;
         this->bInLoop_ = false;
         this->bLoop_ = false;
         this->bEndLoop_ = false;
@@ -418,7 +419,7 @@
         if (!this || !this->getControllableEntity())
             return;
         // orxout (internal_error) << "Size of actions is " << this->parsedActionpoints_.size() << endl;
-        if (this->actionCounter_ % 5 == 0)
+        if (this->actionCounter_ % 2 == 0)
             this->startAttackingEnemiesThatAreClose();
         //No action -> pop one from stack
         if (this->action_ == Action::NONE || this->bTakenOver_)

Modified: code/branches/campaignHS15/src/orxonox/controllers/DivisionController.cc
===================================================================
--- code/branches/campaignHS15/src/orxonox/controllers/DivisionController.cc	2015-11-28 09:16:31 UTC (rev 10882)
+++ code/branches/campaignHS15/src/orxonox/controllers/DivisionController.cc	2015-11-28 10:46:05 UTC (rev 10883)
@@ -38,7 +38,6 @@
     DivisionController::DivisionController(Context* context) : LeaderController(context)
     {
         RegisterObject(DivisionController);
-        this->actionCounter_ = 0;
         this->setFormationMode(FormationMode::DIAMOND);
         this->target_ = 0;
         this->myFollower_ = 0;

Modified: code/branches/campaignHS15/src/orxonox/controllers/FightingController.cc
===================================================================
--- code/branches/campaignHS15/src/orxonox/controllers/FightingController.cc	2015-11-28 09:16:31 UTC (rev 10882)
+++ code/branches/campaignHS15/src/orxonox/controllers/FightingController.cc	2015-11-28 10:46:05 UTC (rev 10883)
@@ -37,7 +37,7 @@
     
     FightingController::FightingController( Context* context ): FlyingController( context )
     {
-    	this->attackRange_ = 2500;
+    	this->attackRange_ = 2000;
         this->stopLookingAtTarget();
 
         RegisterObject( FightingController );
@@ -128,13 +128,19 @@
         bool bTargetIsLookingAtThis = CommonController::isLooking ( this->target_, getControllableEntity(), math::pi/20.0f );
         
         //too far? well, come closer then
-        if ( diffLength > this->attackRange_ )
+        if (diffLength > this->attackRange_)
         {
+            this->spread_ = 300;
+            this->formationMode_ = FormationMode::WALL;
+            this->bKeepFormation_ = true;
+            
             this->setTargetPosition( this->positionOfTarget_ );
         }
         //too close? How do u expect to dodge anything? Just attack!
         else if ( diffLength < 500 )
         {   
+            this->bKeepFormation_ = false;
+
             //at this point, just look and shoot
             if ( diffLength < 250 )
             {
@@ -149,11 +155,13 @@
         //Good distance? Check if target looks at us. It doesn't? Go hunt!
         else if ( !bTargetIsLookingAtThis )
         {
+            this->bKeepFormation_ = false;
             this->setTargetPosition( this->positionOfTarget_ );
         }
         //That's unfortunate, he is looking and probably shooting... try to dodge what we can...  
         else 
         {   
+            this->bKeepFormation_ = false;
             if (maneuverCounter_ == 0)
             {
                 this->setTargetPosition( this->positionOfTarget_ );   

Modified: code/branches/campaignHS15/src/orxonox/controllers/FightingController.h
===================================================================
--- code/branches/campaignHS15/src/orxonox/controllers/FightingController.h	2015-11-28 09:16:31 UTC (rev 10882)
+++ code/branches/campaignHS15/src/orxonox/controllers/FightingController.h	2015-11-28 10:46:05 UTC (rev 10883)
@@ -48,6 +48,7 @@
             bool hasTarget();
             ControllableEntity* getTarget()
                 { return this->target_; }
+            bool bKeepFormation_;
            
         protected:
             void setTarget(ControllableEntity* target);

Modified: code/branches/campaignHS15/src/orxonox/controllers/SectionController.cc
===================================================================
--- code/branches/campaignHS15/src/orxonox/controllers/SectionController.cc	2015-11-28 09:16:31 UTC (rev 10882)
+++ code/branches/campaignHS15/src/orxonox/controllers/SectionController.cc	2015-11-28 10:46:05 UTC (rev 10883)
@@ -123,76 +123,86 @@
         }
         else if (myDivisionLeader_)
         {
-            switch (myDivisionLeader_->getAction())
+            if (this->myDivisionLeader_->bKeepFormation_ || !(this->myDivisionLeader_->getAction() == Action::FIGHT 
+                || this->myDivisionLeader_->getAction() == Action::FIGHTALL
+                || this->myDivisionLeader_->getAction() == Action::ATTACK))
             {
-                case Action::FIGHT:
+                ControllableEntity* myEntity = this->getControllableEntity();
+                Vector3 myPosition = myEntity->getWorldPosition();
+                if (!this->myDivisionLeader_)
                 {
-                    if (!this->hasTarget())
-                    {
-                        this->chooseTarget();
-                    }
-                    break;
+                    return;
                 }
-                case Action::FIGHTALL:
+                ControllableEntity* leaderEntity = this->myDivisionLeader_->getControllableEntity();
+                Quaternion orient = leaderEntity->getWorldOrientation();
+                Vector3 leaderPosition = leaderEntity->getWorldPosition();
+
+                Vector3 targetRelativePosition = getFormationPosition();
+                if (!this->myDivisionLeader_)
                 {
-                    if (!this->hasTarget())
-                    {
-                        this->chooseTarget();
-                    }
-                    break;
+                    return;
                 }
-                case Action::ATTACK:
+                Vector3 targetAbsolutePosition = 
+                    (leaderPosition + (orient*WorldEntity::FRONT) * (leaderEntity->getVelocity().length()/5)
+                     + (orient* (targetRelativePosition)));
+                //let ship finish rotating. also don't call copyOrientation to often as it is a slow function.
+                if (this->actionCounter_ % 9 == 0 && !this->bHasTargetOrientation_)
+                    this->setAction (Action::FLY, targetAbsolutePosition, orient);
+                else
+                    this->setAction (Action::FLY, targetAbsolutePosition);
+
+                if ((targetAbsolutePosition - myPosition).length() > this->tolerance_ * 1.5f)
                 {
-                    if (!this->hasTarget())
-                    {
-                        this->chooseTarget();
-                    }
-                    break;
+                    this->boostControl();
                 }
-                default:
+                else
                 {
-                    //formation flight is executed in tick
-                    ControllableEntity* myEntity = this->getControllableEntity();
-            Vector3 myPosition = myEntity->getWorldPosition();
-            if (!this->myDivisionLeader_)
-            {
-                return;
+                   this->getControllableEntity()->boost(false);
+                }
             }
-            ControllableEntity* leaderEntity = this->myDivisionLeader_->getControllableEntity();
-            Quaternion orient = leaderEntity->getWorldOrientation();
-            Vector3 leaderPosition = leaderEntity->getWorldPosition();
-
-            Vector3 targetRelativePosition = getFormationPosition();
-            if (!this->myDivisionLeader_)
-            {
-                return;
-            }
-            Vector3 targetAbsolutePosition = 
-                (leaderPosition + (orient*WorldEntity::FRONT) * (leaderEntity->getVelocity().length()/5)
-                 + (orient* (targetRelativePosition)));
-            //let ship finish rotating. also don't call copyOrientation to often as it is a slow function.
-            if (this->actionCounter_ % 9 == 0 && !this->bHasTargetOrientation_)
-                this->setAction (Action::FLY, targetAbsolutePosition, orient);
             else
-                this->setAction (Action::FLY, targetAbsolutePosition);
-
-            if ((targetAbsolutePosition - myPosition).length() > this->tolerance_ * 1.5f)
             {
-                this->boostControl();
-            }
-            else
-            {
-               this->getControllableEntity()->boost(false);
-            }
+                switch (myDivisionLeader_->getAction())
+                {
+                    case Action::FIGHT:
+                    {
+                        if (!this->hasTarget())
+                        {
+                            this->chooseTarget();
+                        }
+                        break;
+                    }
+                    case Action::FIGHTALL:
+                    {
+                        if (!this->hasTarget())
+                        {
+                            this->chooseTarget();
+                        }
+                        break;
+                    }
+                    case Action::ATTACK:
+                    {
+                        if (!this->hasTarget())
+                        {
+                            this->chooseTarget();
+                        }
+                        break;
+                    }
+                    default:
+                    {
+                        //formation flight is executed in tick 
+                    }
                 }
+                if (this->hasTarget())
+                {
+                    //----choose where to go----
+                    this->maneuver();
+                    //----fire if you can----
+                    this->bShooting_ = this->canFire();                
+                }
             }
-            if (this->hasTarget())
-            {
-                //----choose where to go----
-                this->maneuver();
-                //----fire if you can----
-                this->bShooting_ = this->canFire();                
-            }
+            
+            
         }
         this->actionCounter_ += this->actionCounter_ < 100000 ? 1 : -this->actionCounter_ ;
 
@@ -262,6 +272,7 @@
     Vector3 SectionController::getFormationPosition ()
     {
         this->setFormationMode( this->myDivisionLeader_->getFormationMode() );
+        this->spread_ = this->myDivisionLeader_->getSpread();
         Vector3* targetRelativePosition;
         switch (this->formationMode_){
             case FormationMode::WALL:

Modified: code/branches/campaignHS15/src/orxonox/controllers/WingmanController.cc
===================================================================
--- code/branches/campaignHS15/src/orxonox/controllers/WingmanController.cc	2015-11-28 09:16:31 UTC (rev 10882)
+++ code/branches/campaignHS15/src/orxonox/controllers/WingmanController.cc	2015-11-28 10:46:05 UTC (rev 10883)
@@ -104,74 +104,83 @@
         }
         else if (this->myLeader_)
         {
-            switch (this->myLeader_->getAction())
+            if (this->myLeader_->bKeepFormation_ || !(this->myLeader_->getAction() == Action::FIGHT || this->myLeader_->getAction() == Action::FIGHTALL
+                || this->myLeader_->getAction() == Action::ATTACK))
             {
-                case Action::FIGHT:
+                ControllableEntity* myEntity = this->getControllableEntity();
+                Vector3 myPosition = myEntity->getWorldPosition();
+                if (!this->myLeader_)
                 {
-                    if (!this->hasTarget())
-                    {
-                        this->setTarget(this->myLeader_->getTarget());
-                    }
-                    break;
+                    return;
                 }
-                case Action::FIGHTALL:
+                ControllableEntity* leaderEntity = this->myLeader_->getControllableEntity();
+                Quaternion orient = leaderEntity->getWorldOrientation();
+                Vector3 leaderPosition = leaderEntity->getWorldPosition();
+                Vector3 targetRelativePosition = getFormationPosition();
+                if (!this->myLeader_)
                 {
-                    if (!this->hasTarget())
-                    {
-                        this->setTarget(this->myLeader_->getTarget());
-                    }
-                    break;
+                    return;
                 }
-                case Action::ATTACK:
+                Vector3 targetAbsolutePosition = 
+                    (leaderPosition + (orient*WorldEntity::FRONT) * (leaderEntity->getVelocity().length()/5)
+                     + (orient* (targetRelativePosition)));
+                //let ship finish rotating. also don't call copyOrientation to often as it is a slow function.
+                if (this->actionCounter_ % 9 == 0 && !this->bHasTargetOrientation_)
+                    this->setAction (Action::FLY, targetAbsolutePosition, orient);
+                else
+                    this->setAction (Action::FLY, targetAbsolutePosition);
+                if ((targetAbsolutePosition - myPosition).length() > this->tolerance_ * 1.5f)
                 {
-                    if (!this->hasTarget())
-                    {
-                        this->setTarget(this->myLeader_->getTarget());
-                    }
-                    break;
+                    this->boostControl();
                 }
-                default:
+                else
                 {
-                    
-            ControllableEntity* myEntity = this->getControllableEntity();
-            Vector3 myPosition = myEntity->getWorldPosition();
-            if (!this->myLeader_)
-            {
-                return;
+                   this->getControllableEntity()->boost(false);
+                }
             }
-            ControllableEntity* leaderEntity = this->myLeader_->getControllableEntity();
-            Quaternion orient = leaderEntity->getWorldOrientation();
-            Vector3 leaderPosition = leaderEntity->getWorldPosition();
-            Vector3 targetRelativePosition = getFormationPosition();
-            if (!this->myLeader_)
-            {
-                return;
-            }
-            Vector3 targetAbsolutePosition = 
-                (leaderPosition + (orient*WorldEntity::FRONT) * (leaderEntity->getVelocity().length()/5)
-                 + (orient* (targetRelativePosition)));
-            //let ship finish rotating. also don't call copyOrientation to often as it is a slow function.
-            if (this->actionCounter_ % 9 == 0 && !this->bHasTargetOrientation_)
-                this->setAction (Action::FLY, targetAbsolutePosition, orient);
             else
-                this->setAction (Action::FLY, targetAbsolutePosition);
-            if ((targetAbsolutePosition - myPosition).length() > this->tolerance_ * 1.5f)
             {
-                this->boostControl();
-            }
-            else
-            {
-               this->getControllableEntity()->boost(false);
-            }
+                switch (this->myLeader_->getAction())
+                {
+                    case Action::FIGHT:
+                    {
+                        if (!this->hasTarget())
+                        {
+                            this->setTarget(this->myLeader_->getTarget());
+                        }
+                        break;
+                    }
+                    case Action::FIGHTALL:
+                    {
+                        if (!this->hasTarget())
+                        {
+                            this->setTarget(this->myLeader_->getTarget());
+                        }
+                        break;
+                    }
+                    case Action::ATTACK:
+                    {
+                        if (!this->hasTarget())
+                        {
+                            this->setTarget(this->myLeader_->getTarget());
+                        }
+                        break;
+                    }
+                    default:
+                    {
+                    
+                    }
                 }
+                if (this->hasTarget())
+                {
+                    //----choose where to go----
+                    this->maneuver();
+                    //----fire if you can----
+                    this->bShooting_ = this->canFire();                
+                }
             }
-            if (this->hasTarget())
-            {
-                //----choose where to go----
-                this->maneuver();
-                //----fire if you can----
-                this->bShooting_ = this->canFire();                
-            }
+            
+            
         }
         this->actionCounter_ += this->actionCounter_ < 100000 ? 1 : -this->actionCounter_ ;
     }
@@ -181,7 +190,7 @@
     {
         this->setFormationMode( this->myLeader_->getFormationMode() );
         Vector3* targetRelativePosition;
-
+        this->spread_ = this->myLeader_->getSpread();
         if (this->myLeader_->getIdentifier()->getName() == "DivisionController")
         {
             switch (this->formationMode_){




More information about the Orxonox-commit mailing list