Index: /code/branches/campaignHS15/data/levels/AITest.oxw
===================================================================
--- /code/branches/campaignHS15/data/levels/AITest.oxw	(revision 10858)
+++ /code/branches/campaignHS15/data/levels/AITest.oxw	(revision 10859)
@@ -34,158 +34,228 @@
     <TeamSpawnPoint team=0 position="-1000,-1000,-1000" lookat="1,1,-1" spawnclass=SpaceShip pawndesign=spaceshipassff />
     
-<!-- 
-    <?lua
-      for i = 0, 5, 1 do
-    ?>
-
+<!-- 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,-700" />
+    <Model mesh="cube.mesh" scale=8 position="100,2000,-700" />
+    <Model mesh="cube.mesh" scale=8 position="100,2000,-600" />
+    <Model mesh="cube.mesh" scale=8 position="0,0,0" />
+
+    <SpaceShip position="-1500, 1500, -1000" lookat="0,0,0" team=0 name="ss1">
+      <templates>
+        <Template link=spaceshipassff />
+      </templates>
+      <controller>
+        <DivisionController team=0 formationMode="finger4">
+          <actionpoints>
+            <Actionpoint position="  0,2000,-600" action="FLY" loopStart=true/>
+            <Actionpoint position="  0,2000,-700" action="FLY"  />
+            <Actionpoint position="100,2000,-700" action="FLY" />
+            <Actionpoint position="100,2000,-600" action="FLY" loopEnd=true />
+          </actionpoints>
+        </DivisionController>
+      </controller>
+    </SpaceShip> 
+    -->
+<!-- HERE ENDS DEMO FOR THE "WAYPOINTS" -->
+
+<!-- HERE STARTS DEMO FOR THE ACTIONPOINTS -->
+       
+    <Model mesh="cube.mesh" scale=8 position="0,0,0" />
+
+    <SpaceShip position="-2000, 1500, -1000" lookat="0,0,0" team=0 name="ss2">
+      <templates>
+        <Template link=spaceshipassff />
+      </templates>
+      <controller>
+        <DivisionController team=0 formationMode="finger4">
+          <actionpoints>
+            <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>
+        </DivisionController>
+      </controller>
+    </SpaceShip>
+    <SpaceShip position="-2000, 1900, -1000" lookat="0,0,0" team=0>
+      <templates>
+        <Template link=spaceshipassff />
+      </templates>
+      <controller>
+        <SectionController team=0>
+        </SectionController>
+      </controller>
+    </SpaceShip>
+    <SpaceShip position="-2000, 2100, -1000" lookat="0,0,0" team=0>
+      <templates>
+        <Template link=spaceshipassff />
+      </templates>
+      <controller>
+        <WingmanController team=0>
+        </WingmanController>
+      </controller>
+    </SpaceShip>
+    <SpaceShip position="-2000, 2400, -1000" lookat="0,0,0" team=0>
+      <templates>
+        <Template link=spaceshipassff />
+      </templates>
+      <controller>
+        <WingmanController team=0>
+        </WingmanController>
+      </controller>
+    </SpaceShip>
+    <SpaceShip position="0, 0, 0" lookat="0,0,0" team=2 name="ss4">
+      <templates>
+        <Template link=spaceshipassff />
+      </templates>
+    </SpaceShip>
+    <SpaceShip position="3000, 1000, 2000" lookat="0,0,0" team=2 name="ss3">
+      <templates>
+        <Template link=spaceshipassff />
+      </templates>
+    </SpaceShip>
+    <SpaceShip position="-500, -300, -300" lookat="0,0,0" team=0 name="fuck">
+      <templates>
+        <Template link=spaceshipassff />
+      </templates>
+    </SpaceShip> 
+   
+<!-- HERE ENDS DEMO FOR THE ACTIONPOINTS -->
+<!-- HERE STARTS DEMO FOR FIGHTING -->
+   <!--  
+    <SpaceShip position="-2000, 1500, -1000" lookat="0,0,0" team=0 name="ss2">
+      <templates>
+        <Template link=spaceshipassff />
+      </templates>
+      <controller>
+        <DivisionController team=0 formationMode="finger4">
+          <actionpoints>
+            <Actionpoint position="0,0,0" action="ATTACK" attack="ss3" />
+          </actionpoints>
+        </DivisionController>
+      </controller>
+    </SpaceShip>
+    <SpaceShip position="-2000, 1900, -1000" lookat="0,0,0" team=0>
+      <templates>
+        <Template link=spaceshipassff />
+      </templates>
+      <controller>
+        <SectionController team=0>
+        </SectionController>
+      </controller>
+    </SpaceShip>
+    <SpaceShip position="-2000, 2100, -1000" lookat="0,0,0" team=0>
+      <templates>
+        <Template link=spaceshipassff />
+      </templates>
+      <controller>
+        <WingmanController team=0>
+        </WingmanController>
+      </controller>
+    </SpaceShip>
+    <SpaceShip position="-2000, 2400, -1000" lookat="0,0,0" team=0>
+      <templates>
+        <Template link=spaceshipassff />
+      </templates>
+      <controller>
+        <WingmanController team=0>
+        </WingmanController>
+      </controller>
+    </SpaceShip>
+
+    <SpaceShip position="2000, -1500, 1000" lookat="0,0,0" team=1 name="ss3">
+      <templates>
+        <Template link=spaceshipassff />
+      </templates>
+      <controller>
+        <DivisionController team=1 formationMode="WALL">
+          <actionpoints>
+            <Actionpoint position="0,0,0" action="ATTACk" attack="ss2" />
+          </actionpoints>
+        </DivisionController>
+      </controller>
+    </SpaceShip>
+    <SpaceShip position="2000, -1900, 1000" lookat="0,0,0" team=1>
+      <templates>
+        <Template link=spaceshipassff />
+      </templates>
+      <controller>
+        <SectionController team=1>
+        </SectionController>
+      </controller>
+    </SpaceShip>
+    <SpaceShip position="2000, -2100, 1000" lookat="0,0,0" team=1>
+      <templates>
+        <Template link=spaceshipassff />
+      </templates>
+      <controller>
+        <WingmanController team=1>
+        </WingmanController>
+      </controller>
+    </SpaceShip>
+    <SpaceShip position="2000, -2400, 1000" lookat="0,0,0" team=1>
+      <templates>
+        <Template link=spaceshipassff />
+      </templates>
+      <controller>
+        <WingmanController team=1>
+        </WingmanController>
+      </controller>
+    </SpaceShip> 
+     -->
+<!-- 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" />
+    <Model mesh="cube.mesh" scale=8 position="2000,2000,    0" />
+
+    <SpaceShip position="-1500, 1500, -1000" lookat="0,0,0" team=0 name="ss1">
+      <templates>
+        <Template link=spaceshipassff />
+      </templates>
+      <controller>
+        <DivisionController team=0 formationMode="DIAMOND">
+          <actionpoints>
+            <Actionpoint position="   0,2000,    0" action="FLY" loopStart=true/>
+            <Actionpoint position="   0,2000,-2000" action="FLY"  />
+            <Actionpoint position="2000,2000,-2000" action="FLY" />
+            <Actionpoint position="2000,2000,    0" action="FLY" loopEnd=true />
+          </actionpoints>
+        </DivisionController>
+      </controller>
+    </SpaceShip>
+
+    <SpaceShip position="-2000, 1900, -1000" lookat="0,0,0" team=0>
+      <templates>
+        <Template link=spaceshipassff />
+      </templates>
+      <controller>
+        <SectionController team=0>
+        </SectionController>
+      </controller>
+    </SpaceShip>
+    <SpaceShip position="-2000, 2100, -1000" lookat="0,0,0" team=0>
+      <templates>
+        <Template link=spaceshipassff />
+      </templates>
+      <controller>
+        <WingmanController team=0>
+        </WingmanController>
+      </controller>
+    </SpaceShip>
+    <SpaceShip position="-2000, 2400, -1000" lookat="0,0,0" team=0>
+      <templates>
+        <Template link=spaceshipassff />
+      </templates>
+      <controller>
+        <WingmanController team=0>
+        </WingmanController>
+      </controller>
+    </SpaceShip> 
+    -->
+<!-- HERE ENDS DEMO FOR FORMATIONS -->
     
-    <SpaceShip position="<?lua print(-1600+i*200) ?>,<?lua print(-3000-i*500) ?>, -1500 ?>" lookat="0,0,0">
-      <templates>
-        <Template link=spaceshipassff />
-      </templates>
-      <controller>
-        <AIController accuracy=10 team=2>
-        </AIController>
-      </controller>
-    </SpaceShip>
-    <?lua end ?> -->
- 
-<!--                 <ActionPoint position="12,34,56" action="FIGHT" enemy="ss" />
- -->
-<!--     <SpaceShip position="2000, 1500, -1000" lookat="0,0,0" team=0 name="ss1">
-      <templates>
-        <Template link=spaceshipassff />
-      </templates>
-      <controller>
-        <DivisionController formationMode="wall" action="PROTECT" protect="FUCK" team=0>
-        </DivisionController>
-      </controller>
-    </SpaceShip> -->
-    <SpaceShip position="-1500, 1500, -1000" lookat="0,0,0" team=0 name="ss1">
-      <templates>
-        <Template link=spaceshipassff />
-      </templates>
-      <controller>
-        <DivisionController team=0 formationMode="finger4">
-          <actionpoints>
-            <Actionpoint position="-1000,1000,-1000" action="FLY" loopStart=true />
-            <Actionpoint position="-1250,1250,-500" action="FLY" />
-            <Actionpoint position="-1500,1500,-1000" action="FLY" loopEnd=true />
-          </actionpoints>
-        </DivisionController>
-      </controller>
-    </SpaceShip>
-    <SpaceShip position="-2000, 1500, -1000" lookat="0,0,0" team=0 name="ss2">
-      <templates>
-        <Template link=spaceshipassff />
-      </templates>
-      <controller>
-        <DivisionController team=0 formationMode="finger4">
-          <actionpoints>
-            <Actionpoint position="0,0,0" action="FLY" />
-            <Actionpoint position="-1000,750,-500" action="ATTACK" enemy="ss3" />
-            <Actionpoint position="-1000,750,-500" action="PROTECt" protect="fuck" />
-          </actionpoints>
-        </DivisionController>
-      </controller>
-    </SpaceShip>
-    <SpaceShip position="-2000, 1900, -1000" lookat="0,0,0" team=0>
-      <templates>
-        <Template link=spaceshipassff />
-      </templates>
-      <controller>
-        <SectionController team=0>
-        </SectionController>
-      </controller>
-    </SpaceShip>
-    <SpaceShip position="0, 0, 0" lookat="0,0,0" team=2 name="ss4">
-      <templates>
-        <Template link=spaceshipassff />
-      </templates>
-    </SpaceShip>
-    <SpaceShip position="1000, 300, 200" lookat="0,0,0" team=2 name="ss3">
-      <templates>
-        <Template link=spaceshipassff />
-      </templates>
-    </SpaceShip>
-    <SpaceShip position="-500, -300, -300" lookat="0,0,0" team=0 name="fuck">
-      <templates>
-        <Template link=spaceshipassff />
-      </templates>
-    </SpaceShip> 
-   <!--  <SpaceShip position="4000 ,1500, -1600 " lookat="0,0,0" team=0>
-      <templates>
-        <Template link=spaceshipassff />
-      </templates>
-      <controller>
-        <WingmanController team=0>
-        </WingmanController>
-      </controller>
-    </SpaceShip>
-    <SpaceShip position="4000, 1500, -2200" lookat="0,0,0" team=0>
-      <templates>
-        <Template link=spaceshipassff />
-      </templates>
-      <controller>
-        <WingmanController team=0>
-        </WingmanController>
-      </controller>
-    </SpaceShip>
-    <SpaceShip position="4000, 1500, -2800 " lookat="0,0,0" team=0>
-      <templates>
-        <Template link=spaceshipassff />
-      </templates>
-      <controller>
-        <SectionController team=0>
-        </SectionController>
-      </controller>
-    </SpaceShip>
-    <SpaceShip position="-4000, 1500, -2800 " lookat="0,0,0" team=0 name="FUCK">
-      <templates>
-        <Template link=spaceshipassff />
-      </templates>
-      <controller>
-        <SectionController team=0>
-        </SectionController>
-      </controller>
-    </SpaceShip> -->
-    
-    <!-- <SpaceShip position="-4000, 1500, -5000" lookat="0,0,0">
-      <templates>
-        <Template link=spaceshipassff />
-      </templates>
-      <controller>
-        <DivisionController team=2 formationMode="wall" action="FIGHT">
-        </DivisionController>
-      </controller>
-    </SpaceShip>
-    <SpaceShip position="-4000 , 1500, -5600" lookat="0,0,0">
-      <templates>
-        <Template link=spaceshipassff />
-      </templates>
-      <controller>
-        <WingmanController team=2>
-        </WingmanController>
-      </controller>
-    </SpaceShip>
-    <SpaceShip position="-4000, 1500, -6200" lookat="0,0,0">
-      <templates>
-        <Template link=spaceshipassff />
-      </templates>
-      <controller>
-        <WingmanController team=2>
-        </WingmanController>
-      </controller>
-    </SpaceShip>
-    <SpaceShip position="-4000, 1500, -6800 " lookat="0,0,0">
-      <templates>
-        <Template link=spaceshipassff />
-      </templates>
-      <controller>
-        <SectionController team=2>
-        </SectionController>
-      </controller>
-    </SpaceShip> -->
-
     
    
Index: /code/branches/campaignHS15/src/orxonox/controllers/CommonController.cc
===================================================================
--- /code/branches/campaignHS15/src/orxonox/controllers/CommonController.cc	(revision 10858)
+++ /code/branches/campaignHS15/src/orxonox/controllers/CommonController.cc	(revision 10859)
@@ -63,5 +63,5 @@
     CommonController::CommonController( Context* context ): Controller( context )
     {
-        this->squaredaccuracy_ = 10000;
+        this->squaredaccuracy_ = 2500;
         this->bFirstTick_ = true;
         this->tolerance_ = 50;
@@ -71,9 +71,11 @@
         this->bInLoop_ = false;
         this->bLoop_ = false;
+        this->bEndLoop_ = false;
+        this->parsedActionpoints_.clear();
         RegisterObject( CommonController );
+
     }
     CommonController::~CommonController() 
     {
-       
     }
     void CommonController::tick(float dt)
@@ -161,5 +163,5 @@
         Vector3 position;
         std::string targetName;
-        bool inLoop;
+        bool inLoop = false;
         Point p;
         if (static_cast<Actionpoint*> (actionpoint))
@@ -170,11 +172,15 @@
             position = ap->getWorldPosition();
 
-            if (!this->bInLoop_ && ap->getStartLoop())
+            if (this->bEndLoop_)
+            {
+                this->bInLoop_ = false;
+            }
+            if (!this->bInLoop_ && ap->getLoopStart())
             {
                 this->bInLoop_ = true;
             }
-            if (this->bInLoop_ && ap->getEndLoop())
-            {
-                this->bInLoop_ = false;
+            if (this->bInLoop_ && ap->getLoopEnd())
+            {
+                this->bEndLoop_ = true;
             }
             inLoop = this->bInLoop_;
@@ -197,5 +203,4 @@
                 ThrowException( ParseError, std::string( "Attempting to set an unknown Action: '" )+ actionName + "'." );
             p.action = value; p.name = targetName; p.position = position; p.inLoop = inLoop;
-            parsedActionpoints_.push_back(p);
         }
         else
@@ -519,5 +524,5 @@
         while( diff>math::twoPi )diff-=math::twoPi;
         while( diff<-math::twoPi )diff+=math::twoPi;
-        this->getControllableEntity() ->rotateRoll( diff*ROTATEFACTOR * dt );
+        this->getControllableEntity() ->rotateRoll( diff*0.2f*ROTATEFACTOR * dt );
     }
     void CommonController::copyTargetOrientation( float dt )
@@ -975,4 +980,6 @@
     void CommonController::nextActionpoint()
     {
+        if (!this || !this->getControllableEntity())
+            return;
         if (this->bLoop_)
         {
@@ -1019,4 +1026,7 @@
     void CommonController::action()
     {
+        if (!this || !this->getControllableEntity())
+            return;
+        orxout (internal_error) << "Size of actions is " << this->parsedActionpoints_.size() << endl;
         this->startAttackingEnemiesThatAreClose();
         //No action -> pop one from stack
@@ -1126,6 +1136,6 @@
       this->bLoop_ = b;
       this->setAction (Action::NONE);
-      this->setTarget(0);
-      this->setTargetPosition (this->getControllableEntity()->getWorldPosition());
+      // this->setTarget(0);
+      // this->setTargetPosition (this->getControllableEntity()->getWorldPosition());
       orxout(internal_error) << "Top action is " << this->parsedActionpoints_.back().action << endl;
     }
Index: /code/branches/campaignHS15/src/orxonox/controllers/CommonController.h
===================================================================
--- /code/branches/campaignHS15/src/orxonox/controllers/CommonController.h	(revision 10858)
+++ /code/branches/campaignHS15/src/orxonox/controllers/CommonController.h	(revision 10859)
@@ -138,5 +138,6 @@
                 virtual void stayNearProtect();
                 virtual void action(); //<! action() is called in regular intervals managing the bot's behaviour.
-            
+                 virtual void takeActionpoints (std::vector<Point > vector, std::vector<Point > loop, bool b);
+   
         protected:
             //----[Flying methods]----
@@ -227,7 +228,7 @@
                 bool bFirstTick_; 
                 bool bInLoop_;
-                bool bLoop_;                   
+                bool bLoop_;   
+                bool bEndLoop_;                
             //----[/"Private" variables]----    
-        virtual void takeActionpoints (std::vector<Point > vector, std::vector<Point > loop, bool b);
            
     };
Index: /code/branches/campaignHS15/src/orxonox/controllers/DivisionController.cc
===================================================================
--- /code/branches/campaignHS15/src/orxonox/controllers/DivisionController.cc	(revision 10858)
+++ /code/branches/campaignHS15/src/orxonox/controllers/DivisionController.cc	(revision 10859)
@@ -50,16 +50,19 @@
     DivisionController::~DivisionController()
     {
-        if (this->myFollower_)
-        {
-            this->myFollower_->takeActionpoints(this->parsedActionpoints_, this->loopActionpoints_, this->bLoop_);
-            if (this->myWingman_)
-            {
-                this->myWingman_->setAction(Action::FIGHTALL);
-            }
-        }
-        else if (this->myWingman_)
-        {
-            this->myWingman_->takeActionpoints(this->parsedActionpoints_, this->loopActionpoints_, this->bLoop_);
-        }
+        // if (!(this->parsedActionpoints_.empty() && this->loopActionpoints_.empty()))
+        // {
+        //     if (this->myFollower_)
+        //     {
+        //         this->myFollower_->takeActionpoints(this->parsedActionpoints_, this->loopActionpoints_, this->bLoop_);
+        //         if (this->myWingman_)
+        //         {
+        //             this->myWingman_->setAction(Action::FIGHTALL);
+        //         }
+        //     }
+        //     else if (this->myWingman_)
+        //     {
+        //         this->myWingman_->takeActionpoints(this->parsedActionpoints_, this->loopActionpoints_, this->bLoop_);
+        //     }    
+        // }
         for (size_t i = 0; i < this->actionpoints_.size(); ++i)
         {
@@ -85,5 +88,8 @@
     void DivisionController::action()
     {   
+        if (!this || !this->getControllableEntity())
+            return;
         CommonController::action();
+        
     }
     void DivisionController::stayNearProtect()
Index: /code/branches/campaignHS15/src/orxonox/controllers/LeaderController.cc
===================================================================
--- /code/branches/campaignHS15/src/orxonox/controllers/LeaderController.cc	(revision 10858)
+++ /code/branches/campaignHS15/src/orxonox/controllers/LeaderController.cc	(revision 10859)
@@ -52,5 +52,5 @@
     }
     
-
+    
 
 }
Index: /code/branches/campaignHS15/src/orxonox/controllers/SectionController.cc
===================================================================
--- /code/branches/campaignHS15/src/orxonox/controllers/SectionController.cc	(revision 10858)
+++ /code/branches/campaignHS15/src/orxonox/controllers/SectionController.cc	(revision 10859)
@@ -51,8 +51,8 @@
     SectionController::~SectionController()
     {
-        if (this->myWingman_)
-        {
-            this->myWingman_->takeActionpoints(this->parsedActionpoints_, this->loopActionpoints_, this->bLoop_);
-        }
+        // if (this->myWingman_)
+        // {
+        //     this->myWingman_->takeActionpoints(this->parsedActionpoints_, this->loopActionpoints_, this->bLoop_);
+        // }
        for (size_t i = 0; i < this->actionpoints_.size(); ++i)
         {
@@ -82,4 +82,6 @@
     void SectionController::action()
     {
+        if (!this || !this->getControllableEntity())
+            return;
 
         //----If no leader, find one----  
Index: /code/branches/campaignHS15/src/orxonox/controllers/WingmanController.cc
===================================================================
--- /code/branches/campaignHS15/src/orxonox/controllers/WingmanController.cc	(revision 10858)
+++ /code/branches/campaignHS15/src/orxonox/controllers/WingmanController.cc	(revision 10859)
@@ -130,4 +130,5 @@
                         return;
                     }
+                    
                     ControllableEntity* leaderEntity = this->myLeader_->getControllableEntity();
                     Quaternion orient = leaderEntity->getWorldOrientation();
@@ -176,15 +177,15 @@
                 case FormationMode::WALL:
                 {
-                    targetRelativePositionOfWingman = new Vector3 (400, 0, 0);  
+                    targetRelativePosition = new Vector3 (400, 0, 0);  
                     break;
                 }
                 case FormationMode::FINGER4: 
                 {
-                    targetRelativePositionOfWingman = new Vector3 (400, 0, 200);  
+                    targetRelativePosition = new Vector3 (400, 0, 200);  
                     break;
                 }
                 case FormationMode::DIAMOND: 
                 {
-                    targetRelativePositionOfWingman = new Vector3 (400, 0, 200);                  
+                    targetRelativePosition = new Vector3 (400, 0, 200);                  
                     break;
                 }
@@ -193,18 +194,19 @@
         else
         {
+
             switch (this->formationMode_){
                 case FormationMode::WALL:
                 {
-                    targetRelativePositionOfWingman = new Vector3 (-400, 0, 0);  
+                    targetRelativePosition = new Vector3 (-400, 0, 0);  
                     break;
                 }
                 case FormationMode::FINGER4: 
                 {
-                    targetRelativePositionOfWingman = new Vector3 (-400, 0, 200);  
+                    targetRelativePosition = new Vector3 (-400, 0, 200);  
                     break;
                 }
                 case FormationMode::DIAMOND: 
                 {
-                    targetRelativePositionOfWingman = new Vector3 (400, -200, 0);                  
+                    targetRelativePosition = new Vector3 (400, -200, 0);                  
                     break;
                 }
