Index: /code/branches/newlevel2012/data/levels/towerDefense.oxw
===================================================================
--- /code/branches/newlevel2012/data/levels/towerDefense.oxw	(revision 9141)
+++ /code/branches/newlevel2012/data/levels/towerDefense.oxw	(revision 9142)
@@ -65,9 +65,10 @@
 	<!-- Spawns the camera, attached to a crate -->
 	<SpawnPoint team=0 position="0,0,0" spawnclass=Pawn pawndesign=centerpointmark />
+	<!--TeamSpawnPoint team=1 position="-7,7,4" direction="-1,0,0" roll=90 yaw=0 spawnclass=SpaceShip pawndesign=spaceshipassff /-->
 	
  	<!--SpawnPoint team=1 position="0,0,10" lookat="0,0,0" spawnclass=SpaceShip pawndesign=spaceshipassff  /-->
  	<!--SpawnPoint team=0 position="0,0,0" lookat="0,0,0" spawnclass=SpaceShip pawndesign=spaceshipassff /-->
  	
-	<!--SpaceShip position="-10,0,20" lookat="0,0,0">
+	<!--SpaceShip position="-10,0,20" lookat="0,0,0" scale=0.3>
       <templates>
         <Template link=spaceshipassff />
@@ -76,8 +77,8 @@
         <WaypointController accuracy=3>
           <waypoints>
-            <Model mesh="cube.mesh" scale=1 position="110,90,20" />
-            <Model mesh="cube.mesh" scale=2 position="290,90,20" />
-            <Model mesh="cube.mesh" scale=3 position="290,-90,20" />
-            <Model mesh="cube.mesh" scale=4 position="110,-90,20" />
+            <Model mesh="cube.mesh" scale=0.2 position="-8,-8,3" />
+            <Model mesh="cube.mesh" scale=0.2 position="8,8,3" />
+            <Model mesh="cube.mesh" scale=0.2 position="8,-8,3" />
+            <Model mesh="cube.mesh" scale=0.2 position="-8,8,3" />
           </waypoints>
         </WaypointController>
Index: /code/branches/newlevel2012/src/modules/towerdefense/TowerDefense.cc
===================================================================
--- /code/branches/newlevel2012/src/modules/towerdefense/TowerDefense.cc	(revision 9141)
+++ /code/branches/newlevel2012/src/modules/towerdefense/TowerDefense.cc	(revision 9142)
@@ -62,5 +62,9 @@
 #include "worldentities/pawns/Pawn.h"
 #include "worldentities/pawns/SpaceShip.h"
-
+#include "controllers/WaypointController.h"
+	 
+#include "graphics/Model.h"
+#include "infos/PlayerInfo.h"
+	 
 #include "chat/ChatManager.h"
 
@@ -78,5 +82,7 @@
 		/* Temporary hack to allow the player to add towers */
 		this->dedicatedAddTower_ = createConsoleCommand( "addTower", createExecutor( createFunctor(&TowerDefense::addTower, this) ) );
-		
+	
+		// Quick hack to test waypoints
+		createConsoleCommand( "aw", createExecutor( createFunctor(&TowerDefense::addWaypointsAndFirstEnemy, this) ) );
     }
 	
@@ -149,11 +155,56 @@
         SUPER(TowerDefense, tick, dt);
 		
-        static bool test = false;
-        if (!test)
+        static int test = 0;
+        if (++test == 10)
         {
-			orxout()<< "First tick." <<endl;
+			orxout()<< "10th tick." <<endl;
+			/*
+			for (std::set<SpawnPoint*>::iterator it = this->spawnpoints_.begin(); it != this->spawnpoints_.end(); it++)
+			{
+				orxout() << "checking spawnpoint with name " << (*it)->getSpawnClass()->getName() << endl;
+			}
+			*/
+			
+			//addWaypointsAndFirstEnemy();
+			
         }
-        test = true;
     }
+	
+	// Function to test if we can add waypoints using code only. Doesn't work yet
+	
+	// THE PROBLEM: WaypointController's getControllableEntity() returns null, so it won't track. How do we get the controlableEntity to NOT BE NULL???
+	
+	void TowerDefense::addWaypointsAndFirstEnemy()
+	{
+		SpaceShip *newShip = new SpaceShip(this->center_);
+		newShip->addTemplate("spaceshipassff");
+		
+		WaypointController *newController = new WaypointController(newShip);
+		newController->setAccuracy(3);
+		
+		Model *wayPoint1 = new Model(newController);
+		wayPoint1->setMeshSource("crate.mesh");	
+		wayPoint1->setPosition(7,-7,5);
+		wayPoint1->setScale(0.2);
+			
+		Model *wayPoint2 = new Model(newController);
+		wayPoint2->setMeshSource("crate.mesh");
+		wayPoint2->setPosition(7,7,5);
+		wayPoint2->setScale(0.2);
+			
+		newController->addWaypoint(wayPoint1);
+		newController->addWaypoint(wayPoint2);
+			
+		// The following line causes the game to crash
+//		newController -> getPlayer() -> startControl(newShip);
+		newShip->setController(newController);
+		newShip->setPosition(-7,-7,5);
+		newShip->setScale(0.1);
+		newShip->addSpeed(1);
+		
+		
+		
+//		this->center_->attach(newShip);
+	}
 	
 	/*
Index: /code/branches/newlevel2012/src/modules/towerdefense/TowerDefense.h
===================================================================
--- /code/branches/newlevel2012/src/modules/towerdefense/TowerDefense.h	(revision 9141)
+++ /code/branches/newlevel2012/src/modules/towerdefense/TowerDefense.h	(revision 9142)
@@ -58,4 +58,5 @@
 		//virtual void playerScored(PlayerInfo* player);
 		
+		
 		/*	Called by TowerDefenseCenterpoint upon game start 
 			The centerpoint is used to create towers
@@ -72,4 +73,6 @@
 //		WeakPtr<TowerDefenseCenterpoint> center_;
 		TowerDefenseCenterpoint *center_;
+		
+		void addWaypointsAndFirstEnemy();
     };
 }
Index: /code/branches/newlevel2012/src/orxonox/controllers/WaypointController.cc
===================================================================
--- /code/branches/newlevel2012/src/orxonox/controllers/WaypointController.cc	(revision 9141)
+++ /code/branches/newlevel2012/src/orxonox/controllers/WaypointController.cc	(revision 9142)
@@ -62,12 +62,19 @@
     void WaypointController::tick(float dt)
     {
-        if (!this->isActive())
+		if (!this->isActive())
             return;
+
+		orxout() << "(" << this->waypoints_.size() << ") entity: " << this->getControllableEntity() << endl;
+
 
         if (this->waypoints_.size() == 0 || !this->getControllableEntity())
             return;
 
+		printf("3");
+
         if (this->waypoints_[this->currentWaypoint_]->getWorldPosition().squaredDistance(this->getControllableEntity()->getPosition()) <= this->squaredaccuracy_)
             this->currentWaypoint_ = (this->currentWaypoint_ + 1) % this->waypoints_.size();
+
+		printf("4");
 
         this->moveToPosition(this->waypoints_[this->currentWaypoint_]->getWorldPosition());
