Index: branches/vs-enhencements/src/world_entities/npcs/actionbox_enemy.cc
===================================================================
--- branches/vs-enhencements/src/world_entities/npcs/actionbox_enemy.cc	(revision 10662)
+++ branches/vs-enhencements/src/world_entities/npcs/actionbox_enemy.cc	(revision 10667)
@@ -41,8 +41,10 @@
   this->dPitch = 0.0;
   
-  this->maxSpeed = 10;
+  this->maxSpeed = 30;
   this->acceleration = 3;
   this->speed = 0;
   
+  this->onEscape = false;
+  
   if ( root )
     this->loadParams( root );
@@ -60,4 +62,17 @@
 void ActionboxEnemy::tick( float dt )
 {
+  this->bFire = false;
+  
+  if ( !State::getPlayer() || !State::getPlayer()->getPlayable() )
+    return;
+  
+  Vector playerDir = State::getPlayer()->getPlayable()->getAbsDir().apply( Vector(1, 0, 0) );
+  Vector dist = this->getAbsCoor() - State::getPlayer()->getPlayable()->getAbsCoor();
+  
+  bool behindPlayer = playerDir.dot( dist ) < 0;
+  
+  if ( behindPlayer )
+    return;
+  
   myDir = this->getAbsDir();
   myCoor = this->getAbsCoor();
@@ -73,6 +88,4 @@
   qPitch = Quaternion( pitch, Vector( 1, 0, 0 ) );
   
-  moveTowardsBox( NULL, dt );
-    
   if ( isActive && State::getActionBox() )
   {
@@ -85,4 +98,5 @@
     {
       moveTowardsBox( box, dt );
+      onEscape = false;
     }
   }
@@ -96,14 +110,43 @@
 void ActionboxEnemy::attackPlayer( ActionBox * box, float dt )
 {
-}
-
-void ActionboxEnemy::moveTowardsBox( ActionBox * box, float dt )
-{
-  //Vector targetPos = State::getPlayer()->getPlayable()->getAbsCoor();
-  static float time = 0;
-  time += dt;
-  Vector targetPos = State::getPlayer()->getPlayable()->getAbsCoor() + State::getPlayer()->getPlayable()->getAbsDir().apply(Vector(1, 0, 0))*50*(1.5 + sin(time/5));
-  Vector targetDir = targetPos - myCoor;
-  
+  if ( !State::getPlayer() || !State::getPlayer()->getPlayable() || !box )
+    return;
+  
+  float distance = (State::getPlayer()->getPlayable()->getAbsCoor() - getAbsCoor() ).len();
+  
+  if ( distance > box->getDepth()/4.0 && !onEscape )
+  {
+    Vector targetPos = State::getPlayer()->getPlayable()->getAbsCoor();
+    Vector targetDir = State::getPlayer()->getPlayable()->getAbsCoor()-this->getAbsCoor();
+    moveTowards( targetPos, targetDir, dt );
+    if ( this->getAbsDir().apply( Vector(1, 0, 0) ).dot(targetDir) > 0.9 )
+    {
+      this->bFire = true;
+      PRINTF(0)("FIRE\n");
+    }
+  }
+  else
+  {
+    if ( !onEscape )
+    {
+      Vector ds = this->getAbsCoor() - State::getPlayer()->getPlayable()->getAbsCoor();
+      float projy = box->getAbsDir().apply( Vector(0, 1, 0) ).dot( ds );
+      float projz = box->getAbsDir().apply( Vector(0, 0, 1) ).dot( ds );
+      this->escapePoint = Vector( 0, projy, projz );
+      this->escapePoint.normalize();
+      this->escapePoint*= 2*box->getWidth_2();
+      PRINTF(0)("ESCAPE\n");
+    }
+    onEscape = true;
+    
+    Vector rEscapePoint = box->getAbsDir().apply(escapePoint);
+    Vector targetPos = State::getPlayer()->getPlayable()->getAbsCoor() + rEscapePoint;
+    Vector targetDir = State::getPlayer()->getPlayable()->getAbsCoor() + rEscapePoint - this->getAbsCoor();
+    moveTowards( targetPos, targetDir, dt );    
+  }
+}
+
+void ActionboxEnemy::moveTowards( Vector targetPos, Vector targetDir, float dt )
+{
   Quaternion cur = myDir;
   Quaternion rx( dt, Vector( 0, 0, 1 ) );
@@ -144,4 +187,13 @@
 }
 
+void ActionboxEnemy::moveTowardsBox( ActionBox * box, float dt )
+{
+    
+  Vector targetPos = box->getAbsCoor() + box->getAbsDir().apply( Vector( 1, 0, 0 ) )*box->getDepth()*0.66f;
+  Vector targetDir = targetPos - myCoor;
+  
+  moveTowards(targetPos, targetDir, dt);
+}
+
 void ActionboxEnemy::draw( ) const
 {
Index: branches/vs-enhencements/src/world_entities/npcs/actionbox_enemy.h
===================================================================
--- branches/vs-enhencements/src/world_entities/npcs/actionbox_enemy.h	(revision 10662)
+++ branches/vs-enhencements/src/world_entities/npcs/actionbox_enemy.h	(revision 10667)
@@ -33,6 +33,12 @@
     Vector     myCoor;
     
+    bool       bFire;
+    
+    Vector     escapePoint;
+    bool       onEscape;
+    
     void attackPlayer( ActionBox* box, float dt );
     void moveTowardsBox( ActionBox* box, float dt );
+    void moveTowards( Vector targetPos, Vector targetDir, float dt );
 };
 
Index: branches/vs-enhencements/src/world_entities/space_ships/space_ship.cc
===================================================================
--- branches/vs-enhencements/src/world_entities/space_ships/space_ship.cc	(revision 10662)
+++ branches/vs-enhencements/src/world_entities/space_ships/space_ship.cc	(revision 10667)
@@ -571,4 +571,5 @@
   if (!(State::getCamera()->getEventHandling()))
   {
+    //PRINTF(0)("\n\n\n\n\n\n\n\nSETCAMERA %x\n\n\n\n\n\n\n", State::getCamera());
     if( event.type == KeyMapper::PEV_VIEW0)
     {
@@ -851,6 +852,14 @@
         //State::getCameraTargetNode()->setParentSoft(this);
         //State::getCameraTargetNode()->setRelCoorSoft(0,0,0);
-        this->setCameraMode(Camera::ViewNormal);
+        //this->setCameraMode(Camera::ViewNormal);
         State::getCamera()->setEventHandling(false);
+        
+        PRINTF(0)("\n\n\n\n\n\n\n\nSETCAMERA %x\n\n\n\n\n\n\n", State::getCamera());
+        State::getCamera()->setViewMode(Camera::ViewNormal);
+        State::getCameraTargetNode()->setParent(this);
+        State::getCamera()->setParent(this);
+
+        
+        
         registerEvent(KeyMapper::PEV_VIEW0);
         registerEvent(KeyMapper::PEV_VIEW1);
