Index: /branches/ai/src/ai/Makefile.am
===================================================================
--- /branches/ai/src/ai/Makefile.am	(revision 10265)
+++ /branches/ai/src/ai/Makefile.am	(revision 10266)
@@ -14,5 +14,6 @@
 			swarm_module.cc\
 			swarm_wait.cc\
-			swarm_gorel.cc
+			swarm_gorel.cc\
+			swarm_attack.cc
 
 noinst_HEADERS =        \
@@ -26,3 +27,4 @@
 			swarm_module.h\
 			swarm_wait.h\
-			swarm_gorel.h
+			swarm_gorel.h\
+			swarm_attack.h
Index: /branches/ai/src/ai/ai_engine.cc
===================================================================
--- /branches/ai/src/ai/ai_engine.cc	(revision 10265)
+++ /branches/ai/src/ai/ai_engine.cc	(revision 10266)
@@ -33,7 +33,8 @@
 		if(it->first!=0){
 			Player* pl = State::getPlayer();
-			if(pl != NULL)enemyList->push_back(pl->getPlayable());
+			if( pl!=NULL && pl->getPlayable()!=NULL )
+				enemyList->push_back(pl->getPlayable());
 		}
-	
+
 		//find other enemys for this team
 		for(ObjectList<NPC2>::const_iterator npc = NPC2::objectList().begin(); npc != NPC2::objectList().end(); ++npc)
@@ -60,5 +61,5 @@
 void AIEngine::removeAI(int teamNumber, int swarmNumber, WorldEntity* npc)
 {
-	std::map<int,AITeam*>::iterator it = teams.find(swarmNumber);
+	std::map<int,AITeam*>::iterator it = teams.find(teamNumber);
 	if(it==teams.end())return;
 	it->second->removeAI(swarmNumber,npc);
Index: /branches/ai/src/ai/ai_team.cc
===================================================================
--- /branches/ai/src/ai/ai_team.cc	(revision 10265)
+++ /branches/ai/src/ai/ai_team.cc	(revision 10266)
@@ -18,4 +18,5 @@
 #include "swarm_module.h"
 #include "swarm_wait.h"
+#include "swarm_attack.h"
 #include "debug.h"
 #include "player.h"
@@ -27,8 +28,8 @@
 	std::map<int,SwarmModule*>::iterator it;
 	for (it= swarms.begin(); it!= swarms.end(); it++ ){
-	
+
 		if(it->second->taskDone()){
 			std::cout << "Swarm Task Complete!\n";
-					
+
 			if(enemyList->size()==0){
 				changeSwarmModule(it, new SwarmWait);
@@ -37,36 +38,47 @@
 				continue;
 			}
-			
+
 			Vector position=it->second->getPosition();
 			Vector newPosition;
 			WorldEntity* target=enemyList->at(0);
-			
+
 			//check if enemy is the player..
 			bool isPlayer=(State::getPlayer()->getPlayable()==target);
 			float speed;
-			
+			float maxTime=10;
+
 			//find new Position
 			if(isPlayer){
-				float x=(target->getAbsCoor()).x;
-				float z=(target->getAbsCoor()).z;
-				int zNorm=(position.z>z)?1:-1;
-				
-				if(x+100 > position.x && x+20 < position.x){
-					newPosition=Vector(0,0,zNorm*80);		//just go away
+				Vector targetPos=target->getAbsCoor();
+				int zNorm=(position.z>targetPos.z)?1:-1;
+
+				if((position.z-targetPos.z)*zNorm>80){	//go to start position
+					std::cout << "Go Start Position\n";
+					changeSwarmModule(it, new SwarmGoRel);
+					newPosition=Vector(220,0,zNorm*60);
+					speed=100;
+				}else if(position.x > targetPos.x+150){	//go to attack position
+					std::cout << "Go Attack Position\n";
+					changeSwarmModule(it, new SwarmGoRel);
+					newPosition=Vector(100,0,0);
+					speed=60;
+				}else if(position.x > targetPos.x+90){	//go to attack mode
+					std::cout << "Go Attack Mode\n";
+					changeSwarmModule(it, new SwarmAttack);
+					newPosition=Vector(80,0,0);
 					speed=80;
-				}else if(x+100 < position.x){
-					newPosition=Vector(80,0,zNorm*30);	//attack
-					speed=70;
-				}else{
-					zNorm=1-2*(rand()%2); //-1 or 1
-					newPosition=Vector(200,0,zNorm*80);	//go to attack position
-					speed=100;
+					maxTime=(rand()%11);//0-10 Sekunden
+				}else{												//go to fallback point
+					std::cout << "Go  Fallback Point\n";
+					changeSwarmModule(it, new SwarmGoRel);
+					newPosition=Vector(0,0,zNorm*150);
+					speed=60;
 				}
 			}else{
-			
+
 			}
 
-			changeSwarmModule(it, new SwarmGoRel);
-		
+
+
 			if(enemyList->size()>0){
 				it->second->setEnemyList(enemyList);
@@ -75,5 +87,5 @@
 				it->second->orderSpeed(speed);
 				//it->second->orderView(Vector(0,0,1));
-				it->second->orderMaxTime((rand()%6)+5); //5-10
+				it->second->orderMaxTime(maxTime); //5-10
 				//it->second->newOrder();
 			}
Index: /branches/ai/src/ai/attack_module.cc
===================================================================
--- /branches/ai/src/ai/attack_module.cc	(revision 10265)
+++ /branches/ai/src/ai/attack_module.cc	(revision 10266)
@@ -114,5 +114,5 @@
 
 	Vector correction=		playerCollision*50*3
-								+	npcCollision*50*3
+								+	npcCollision*50*3 *6/myRadius
 								+	destinationMovement*2//-movement
 								+	(vectorToDestination-movement)*3
Index: /branches/ai/src/ai/movement_module.cc
===================================================================
--- /branches/ai/src/ai/movement_module.cc	(revision 10265)
+++ /branches/ai/src/ai/movement_module.cc	(revision 10266)
@@ -64,7 +64,9 @@
 	Player* pl = State::getPlayer();
 	if( pl == NULL)return;
+	WorldEntity* playable = pl->getPlayable();
+	if( playable == NULL)return;
+
 	Vector playerPosition = pl->getPlayable()->getAbsCoor();
 	float playerRadius=getRadius( pl->getPlayable() );
-
 
 	//get information about myself
@@ -104,5 +106,5 @@
 
 	Vector correction=		playerCollision*50*3
-								+	npcCollision*50*3
+								+	npcCollision*50*3 *6/myRadius
 								+	Vector(0,0,0)
 								+	destinationMovement*2//-movement
Index: /branches/ai/src/ai/swarm_gorel.cc
===================================================================
--- /branches/ai/src/ai/swarm_gorel.cc	(revision 10265)
+++ /branches/ai/src/ai/swarm_gorel.cc	(revision 10266)
@@ -21,5 +21,5 @@
 {
 	std::map<WorldEntity*,AIModule*>::iterator it;
-	
+
 	//calculate  movement parameters..
 	float averageRadius;
@@ -31,10 +31,10 @@
 	vMax=500/averageRadius;
 	viewChangeMax=90/averageRadius;
-	
+
 	//load correct ai-module..
 	for (it= members.begin(); it!= members.end(); it++ ){
 		changeAIModule(it, new MovementModule());
 	}
-	
+
 	//get swarm position..
 	//position=this->getPosition();
@@ -48,5 +48,5 @@
 	Vector correction=Vector(0,0,0);
 	Vector destination;
-	
+
 	if(taskRelObject!=NULL && taskMaxTime>0){
 		destination=taskRelObject->getAbsCoor()+taskRelPos;
@@ -57,5 +57,5 @@
 		taskComplete=true;
 	}
-	
+
 	float correctionLen=correction.len();
 	if(correctionLen>aMax*dt)correction=correction/correctionLen*aMax*dt;
@@ -66,8 +66,8 @@
 	float movementLen=movement.len();
 	if(movementLen>vMax)movement=movement/movementLen*vMax;
-	
+
 	float newSpeed=movement.len();
 	Vector newView=movement.getNormalized();
-	
+
 	if((newSpeed<=taskSpeed && speed>=taskSpeed)||(newSpeed>=taskSpeed && speed<=taskSpeed)){
 		newSpeed=taskSpeed;
@@ -75,5 +75,5 @@
 		newSpeed=taskSpeed;
 	}
-	
+
 	if(angleDeg(view,newView)>viewChangeMax){
 		std::cout << "alarm\n";
@@ -89,9 +89,9 @@
 		it->second->process(dt);
 	}
-	
+
 	//check if destination reached
 	if(!taskComplete){
 		//swarmPosition=this->getPosition();
-		if((destination-position).len()<10)taskComplete=true;
+		if((destination-position).len()<5)taskComplete=true;
 	}
 }
