Index: branches/ai/src/ai/ai_engine.cc
===================================================================
--- branches/ai/src/ai/ai_engine.cc	(revision 10137)
+++ branches/ai/src/ai/ai_engine.cc	(revision 10138)
@@ -16,4 +16,8 @@
 #include "ai_engine.h"
 #include "debug.h"
+#include "npcs/npc_test.h"
+#include "player.h"
+#include "playable.h"
+#include "state.h"
 
 AIEngine* AIEngine::singletonRef = NULL;
@@ -22,6 +26,26 @@
 {
 	std::map<int,AITeam*>::iterator it;
-	for (it= teams.begin(); it!= teams.end(); it++ )
+	std::vector<WorldEntity*>* enemyList=new std::vector<WorldEntity*>;
+	
+	for (it=teams.begin(); it!= teams.end(); it++ )
+	{
+		//find enemys for the team
+		for(ObjectList<NPC2>::const_iterator npc = NPC2::objectList().begin(); npc != NPC2::objectList().end(); ++npc)
+			if((*npc)->getTeam() != it->first)enemyList->push_back(*npc);
+		
+		//add player to enemys (player belongs to team 0)
+		if(it->first!=0){
+			//std::cout << "adding player to enemyList\n";
+			Player* pl = State::getPlayer();
+			if(pl != NULL)enemyList->push_back(pl->getPlayable());
+		}
+		
+		//process the team
+		it->second->setEnemyList(enemyList);
 		it->second->process(dt);
+		enemyList->clear();
+	}
+	
+	delete enemyList;
 }
 
Index: branches/ai/src/ai/ai_module.cc
===================================================================
--- branches/ai/src/ai/ai_module.cc	(revision 10137)
+++ branches/ai/src/ai/ai_module.cc	(revision 10138)
@@ -16,26 +16,4 @@
 */
 #define DEBUG_SPECIAL_MODULE DEBUG_MODULE_AI
-
 #include "ai_module.h"
-//#include "ai_engine.h"
-//#include "debug.h"
-
-
-
-AIModule::AIModule()
-{
-}
-
-
-void AIModule::setDifficulty(int newDifficulty)
-{
-	difficulty=newDifficulty;
-}
-
-
-
-void AIModule::setOwner(AITeamMember* newOwner)
-{
-	owner=newOwner;
-}
-
+#include "debug.h"
Index: branches/ai/src/ai/ai_module.h
===================================================================
--- branches/ai/src/ai/ai_module.h	(revision 10137)
+++ branches/ai/src/ai/ai_module.h	(revision 10138)
@@ -2,31 +2,23 @@
 #ifndef _AI_MODULE_H
 #define _AI_MODULE_H
-
-
+#include "world_entity.h"
 class NPC2;
-class AITeamMember;
-class WorldEntity;
-
 
 class AIModule {
  public:
-   AIModule();
-   virtual ~AIModule() {}
-
-   virtual void process() {}
-   virtual void process(float dt) {}
-
+   AIModule(){}
+   virtual ~AIModule(){}
+   virtual void process(float dt){}
+	
    void setDifficulty(int newDifficulty);
-   void setOwner(AITeamMember* newOwner);
-
-
+	inline void setEnemyList(std::vector<WorldEntity*>* enemyList){this->enemyList=enemyList;}
+	inline Vector getPosition(){return myWorldEntity->getAbsCoor();}
+	inline void setDestination(Vector destination){this->destination=destination;}
+	
  protected:
-   int difficulty;
-	int myTeam;
-	int mySwarm;
-
-   AITeamMember* owner;
    NPC2* myNPC;
-	WorldEntity* myWorldEnity;
+	WorldEntity* myWorldEntity;
+	std::vector<WorldEntity*>* enemyList;
+	Vector destination;
 };
 
Index: branches/ai/src/ai/ai_swarm.cc
===================================================================
--- branches/ai/src/ai/ai_swarm.cc	(revision 10137)
+++ branches/ai/src/ai/ai_swarm.cc	(revision 10138)
@@ -20,6 +20,15 @@
 {
 	std::set<AIModule*>::iterator it;
-	for (it= swarmMembers.begin(); it!= swarmMembers.end(); it++ )
+	it= swarmMembers.begin();
+	Vector leaderPosition=(*it)->getPosition();
+	(*it)->setDestination(destination);
+	(*it)->setEnemyList(enemyList);
+	(*it)->process(dt);
+		
+	for (it++; it!= swarmMembers.end(); it++ ){
+		(*it)->setDestination(leaderPosition);
+		(*it)->setEnemyList(enemyList);
 		(*it)->process(dt);
+	}
 }
 
@@ -36,6 +45,11 @@
 }
 
-int AISwarm::getSwarmSize()
+Vector AISwarm::getPosition()
 {
-	return swarmMembers.size();
+	Vector center=Vector(0,0,0);
+	std::set<AIModule*>::iterator it;
+	for (it= swarmMembers.begin(); it!= swarmMembers.end(); it++ )
+		center=center+(*it)->getPosition();
+
+	return center/swarmMembers.size();
 }
Index: branches/ai/src/ai/ai_swarm.h
===================================================================
--- branches/ai/src/ai/ai_swarm.h	(revision 10137)
+++ branches/ai/src/ai/ai_swarm.h	(revision 10138)
@@ -3,7 +3,6 @@
 #define _AI_SWARM_H
 
-//class AITeamMember;
-#include "ai_team_member.h"
-class NPC2;
+#include "world_entity.h"
+#include "ai_module.h"
 
 class AISwarm{
@@ -14,6 +13,11 @@
 		void addAI(AIModule* newMember);
 		void removeAI(AIModule* oldMember);
-		int getSwarmSize();
+		inline int getSwarmSize(){return swarmMembers.size();}
+		inline void setEnemyList(std::vector<WorldEntity*>* enemyList){this->enemyList=enemyList;}
+		inline void setDestination(Vector destination){this->destination=destination;}
+		Vector getPosition();
 	private:
+		Vector destination;
+		std::vector<WorldEntity*>* enemyList;
 		std::set<AIModule*> swarmMembers;
 };
Index: branches/ai/src/ai/ai_team.cc
===================================================================
--- branches/ai/src/ai/ai_team.cc	(revision 10137)
+++ branches/ai/src/ai/ai_team.cc	(revision 10138)
@@ -20,6 +20,10 @@
 {
 	std::map<int,AISwarm*>::iterator it;
-	for (it= swarms.begin(); it!= swarms.end(); it++ )
+	for (it= swarms.begin(); it!= swarms.end(); it++ ){
+		it->second->setEnemyList(enemyList);
+		if(enemyList->size()>0)
+			it->second->setDestination(enemyList->at(0)->getAbsCoor());
 		it->second->process(dt);
+	}
 }
 
@@ -43,7 +47,2 @@
 	}
 }
-
-int AITeam::getTeamSize()
-{
-	return swarms.size();
-}
Index: branches/ai/src/ai/ai_team.h
===================================================================
--- branches/ai/src/ai/ai_team.h	(revision 10137)
+++ branches/ai/src/ai/ai_team.h	(revision 10138)
@@ -9,10 +9,12 @@
 	~AITeam(){}
  	AITeam(){}
+ 	std::vector<WorldEntity*>* getEnemyList();
    void process(float dt);
 	void addAI(int swarmNumber, AIModule* aiModule);
 	void removeAI(int swarmNumber, AIModule* aiModule);
-	int getTeamSize();
-	
+	inline int getTeamSize(){ return swarms.size(); }
+	inline void setEnemyList(std::vector<WorldEntity*>* enemyList){this->enemyList=enemyList;}
  private:
+ 	std::vector<WorldEntity*>* enemyList;
 	std::map<int,AISwarm*> swarms;
 };
Index: branches/ai/src/ai/movement_module.cc
===================================================================
--- branches/ai/src/ai/movement_module.cc	(revision 10137)
+++ branches/ai/src/ai/movement_module.cc	(revision 10138)
@@ -25,21 +25,21 @@
 
 #include "shell_command.h"
-// SHELL_COMMAND(setDistanceToPlayer, MovementModule, setDistanceToPlayer);
-// SHELL_COMMAND(setDistanceToNPC, MovementModule, setDistanceToNPC);
-// SHELL_COMMAND(setMaxAccleartion, MovementModule, setMaxAccleartion);
-//
-// float MovementModule::distanceToPlayer=15;
-// float MovementModule::distanceToNPC=2;
-// float MovementModule::maxAccleration=200.0f;
-//
-// void MovementModule::setDistanceToPlayer(float newValue){ distanceToPlayer=newValue; }
-// void MovementModule::setDistanceToNPC(float newValue){ distanceToNPC=newValue; }
-// void MovementModule::setMaxAccleartion(float newValue){ maxAccleration=newValue; }
-//
-//
-//
-//
-//
-//
+SHELL_COMMAND(setDistanceToPlayer, MovementModule, setDistanceToPlayer);
+SHELL_COMMAND(setDistanceToNPC, MovementModule, setDistanceToNPC);
+SHELL_COMMAND(setMaxAccleartion, MovementModule, setMaxAccleartion);
+
+float MovementModule::distanceToPlayer=15;
+float MovementModule::distanceToNPC=2;
+float MovementModule::maxAccleration=200.0f;
+
+void MovementModule::setDistanceToPlayer(float newValue){ distanceToPlayer=newValue; }
+void MovementModule::setDistanceToNPC(float newValue){ distanceToNPC=newValue; }
+void MovementModule::setMaxAccleartion(float newValue){ maxAccleration=newValue; }
+
+
+
+
+
+
 // std::vector<Vector>	MovementModule::hidingPoint;
 // std::vector<float>	MovementModule::hidingPointSize;
@@ -62,7 +62,4 @@
 //
 //
-MovementModule::MovementModule(NPC2* object){ this->myNPC=object; }
-MovementModule::~MovementModule(){}
-
 
 
@@ -156,11 +153,9 @@
 	Player* pl = State::getPlayer();
 	if( pl == NULL)return;
-
 	Vector playerPosition = pl->getPlayable()->getAbsCoor();
 	float playerRadius=getRadius( pl->getPlayable() );
-
-
-// collectInformation(dt);
-
+	
+
+	//get information about myself
 	Vector myPosition = myNPC->getAbsCoor();
 	float myRadius = getRadius(myNPC);
@@ -171,7 +166,6 @@
 	Vector tmpVector;
 	float tmpFloat;
-
-// 	Vector npcCollision;
-// 	Vector swarmVector;
+	
+	Vector npcCollision;
 	Vector playerCollision;
 
@@ -180,41 +174,33 @@
 	//float a=200.0f;
 	float vMax=200.0f;
-	float maxAccleration=300.0f;
+	//float maxAccleration=300.0f;
 	//float safetyDistance=2.0f;
 
 
 	//Anti Player Collision
-	tmpFloat=vectorToPlayer.len()-playerRadius-myRadius-30;//distanceToPlayer;
+	tmpFloat=vectorToPlayer.len()-playerRadius-myRadius-distanceToPlayer;
 	if(tmpFloat<0.1)tmpFloat=0.1;
 	playerCollision=vectorToPlayer/(tmpFloat*tmpFloat)*(-1);
 
 
-
-// 	for (unsigned int i=0;i<npcList.size();i++)
-// 	{
-// 		if(npcList.at(i)==myNPC)continue;
-//
-// 		//Anti NPC Collision
-// 		tmpVector=myPosition-npcPosition.at(i);
-// 		tmpFloat=tmpVector.len()-myRadius-npcRadius.at(i)-distanceToNPC;
-//
-// 		if(tmpFloat<0.1)tmpFloat=0.1;
-// 		tmpVector=tmpVector/(tmpFloat*tmpFloat);
-//
-// 		npcCollision=npcCollision+tmpVector;
-//
-// 		//Schwarmverhalten
-// 		if(npcSwarm.at(i) == mySwarm){
-//
-//
-// 		}
-// 	}
-
-
-
-
-
-	//Vector correction=playerCollision*50+npcCollision*50+vectorToPlayer+Vector(70,0,0)-myMovement;
-	Vector correction=playerCollision*50+vectorToPlayer+Vector(50,0,0)-myMovement;
+	//Anti NPC Collision
+	for(ObjectList<WorldEntity>::const_iterator it = WorldEntity::objectList().begin(); it != WorldEntity::objectList().end(); ++it)
+	{
+		if(*it==myNPC)continue;
+
+		tmpVector=myPosition-(*it)->getAbsCoor();
+		tmpFloat=tmpVector.len()-myRadius-distanceToNPC-getRadius(*it);
+
+		if(tmpFloat<0.1)tmpFloat=0.1;
+		tmpVector=tmpVector/(tmpFloat*tmpFloat);
+
+		npcCollision=npcCollision+tmpVector;
+	}
+
+
+
+	Vector vectorToDestination=destination-myPosition;
+
+	Vector correction=playerCollision*50+npcCollision*50+vectorToDestination+Vector(0,0,0)-myMovement;
 
 	correction.y=0;
@@ -234,5 +220,5 @@
 	//	view = v.cross( Vector(0,1,0) ).getNormalized();
 	//}else{
-	view = myMovement.cross( Vector(0,-1,0) ).getNormalized();
+	view = myMovement.cross( Vector(0,1,0) ).getNormalized();
 	//}
 	//if(dist<keepDist)view=view*-1;
Index: branches/ai/src/ai/movement_module.h
===================================================================
--- branches/ai/src/ai/movement_module.h	(revision 10137)
+++ branches/ai/src/ai/movement_module.h	(revision 10138)
@@ -14,19 +14,14 @@
 	public:
 		MovementModule() {}
-		MovementModule(NPC2* object);
-		virtual ~MovementModule();
+		inline MovementModule(NPC2* object){ this->myNPC=object; this->myWorldEntity=(WorldEntity*)object;}
+		virtual ~MovementModule(){}
 		virtual void process(float dt);
 
-//    static void setDistanceToPlayer(float newValue);
-//    static void setDistanceToNPC(float newValue);
-//    static void setMaxAccleartion(float newValue);
+		static void setDistanceToPlayer(float newValue);
+		static void setDistanceToNPC(float newValue);
+		static void setMaxAccleartion(float newValue);
 //
 	private:
-// 	void collectInformation(float dt);
-//
-//
-// 	static std::vector<Vector>	hidingPoint;
-// 	static std::vector<float>	hidingPointSize;
-//
+
 // 	static std::vector<NPC2*> npcList;
 // 	static std::vector<Vector> npcPosition;
@@ -38,7 +33,5 @@
 // 	static Vector playerMovement;
 // 	static float playerRadius;
-//
-// 	static std::vector<Vector> swarmCenter;
-// 	static std::vector<int> swarmMemberCount;
+
 
 		Vector myMovement;
@@ -46,12 +39,9 @@
 		float myMaxSpeed;
 
+		float getRadius(WorldEntity* object);
 
-		float getRadius(WorldEntity* object);
-// 	static float aa;
-// 	float oldDT;
-//
-// 	static float maxAccleration;
-// 	static float distanceToPlayer;
-// 	static float distanceToNPC;
+		static float maxAccleration;
+		static float distanceToPlayer;
+		static float distanceToNPC;
 };
 
Index: branches/ai/src/world_entities/npcs/npc.h
===================================================================
--- branches/ai/src/world_entities/npcs/npc.h	(revision 10137)
+++ branches/ai/src/world_entities/npcs/npc.h	(revision 10138)
@@ -4,9 +4,8 @@
 
 #include "world_entity.h"
-#include "ai_team_member.h"
 
 class AI;
 
-class NPC : public AITeamMember {
+class NPC : public WorldEntity {
   ObjectListDeclaration(NPC);
  public:
Index: branches/ai/src/world_entities/npcs/npc_test.cc
===================================================================
--- branches/ai/src/world_entities/npcs/npc_test.cc	(revision 10137)
+++ branches/ai/src/world_entities/npcs/npc_test.cc	(revision 10138)
@@ -51,14 +51,12 @@
 	std::cout << "Team Number: " << teamNumber << "\n";
 	std::cout << "Swarm Number:" << swarmNumber << "\n";
-
-	AITeam* myTeam=AIEngine::getInstance()->getCreateTeam(teamNumber);
-	//std::cout << "Testpoint 4: " << myTeam << "\n";
-	AISwarm* mySwarm=myTeam->getCreateSwarm(swarmNumber);
-	//std::cout << "Testpoint 5: " << mySwarm << "\n";
-	mySwarm->addToSwarm(new MovementModule(this));
-
+	aiModule=new MovementModule(this);
+	AIEngine::getInstance()->addAI(teamNumber,swarmNumber,aiModule);
 }
 
-
+NPC2::~NPC2()
+{
+	AIEngine::getInstance()->removeAI(teamNumber,swarmNumber,aiModule);
+}
 
 void NPC2::loadParams(const TiXmlElement* root)
Index: branches/ai/src/world_entities/npcs/npc_test.h
===================================================================
--- branches/ai/src/world_entities/npcs/npc_test.h	(revision 10137)
+++ branches/ai/src/world_entities/npcs/npc_test.h	(revision 10138)
@@ -15,7 +15,8 @@
 	public:
 		NPC2 (const TiXmlElement* root);
-		virtual ~NPC2 (){};
+		virtual ~NPC2 ();
 		virtual void loadParams(const TiXmlElement* root);
 		virtual void tick(float dt);
+		inline int getTeam(){return teamNumber;}
 
 
Index: branches/ai/src/world_entities/space_ships/spacecraft_2d.cc
===================================================================
--- branches/ai/src/world_entities/space_ships/spacecraft_2d.cc	(revision 10137)
+++ branches/ai/src/world_entities/space_ships/spacecraft_2d.cc	(revision 10138)
@@ -151,5 +151,5 @@
   this->travelNode = new PNode();
 
-  this->loadModel("models/ships/mantawing.obj", 5.0f);
+  this->loadModel("models/ships/mantawing.obj", 2.5f);
 
   // camera - issue
