Index: /branches/single_player_map/src/world_entities/npcs/generic_npc.cc
===================================================================
--- /branches/single_player_map/src/world_entities/npcs/generic_npc.cc	(revision 8822)
+++ /branches/single_player_map/src/world_entities/npcs/generic_npc.cc	(revision 8823)
@@ -42,4 +42,5 @@
                         //addMethod("walkTo", ExecutorLua7ret<GenericNPC,float, float, float, float, float, float, float, float>(&GenericNPC::walkTo))
                         addMethod("walkTo", ExecutorLua3ret<GenericNPC,float,float,float,float>(&GenericNPC::walkTo))
+                        ->addMethod("setTime", ExecutorLua1<GenericNPC,float>(&GenericNPC::setTime))
                        );
 
@@ -87,4 +88,5 @@
   this->soundBuffer = (OrxSound::SoundBuffer*)ResourceManager::getInstance()->load("sound/rain.wav", WAV);
 
+  time = 30.0f;
   // collision reaction registration
 //   this->subscribeReaction(CREngine::CR_PHYSICS_GROUND_WALK, CL_BSP_ENTITY);
@@ -153,5 +155,101 @@
     this->destDir = destDir;
 
-    float time = 10.0f;
+    float time = 100.0f;
+
+    if( this->currentAnim != NULL)
+      delete this->currentAnim;
+
+    this->currentAnim = new Animation3D(this);
+    this->currentAnim->addKeyFrame(this->getAbsCoor(), this->getAbsDir(), 0.0f, ANIM_LINEAR, ANIM_LINEAR);
+    this->currentAnim->addKeyFrame(this->getAbsCoor(), this->getAbsDir(),time, ANIM_LINEAR, ANIM_LINEAR);
+    this->currentAnim->addKeyFrame(this->destCoor, this->destDir, time, ANIM_LINEAR, ANIM_LINEAR);
+//     this->currentAnim->addKeyFrame(this->getAbsCoor(), this->getAbsDir(), time, ANIM_LINEAR, ANIM_LINEAR);
+//     this->currentAnim->addKeyFrame(this->destCoor, this->destDir, time, ANIM_LINEAR, ANIM_LINEAR);
+
+    this->currentAnim->setInfinity(ANIM_INF_CONSTANT);
+    this->currentAnim->play();
+
+    this->setAnimation(RUN, MD2_ANIM_LOOP);
+  }
+
+  // calculate the distance
+  Vector distance = this->getAbsCoor() - this->destCoor;
+  return distance.len();
+}
+
+
+/**
+ * walk to a specific place with direction
+ *
+ * @param x: x coordinate to go to
+ * @param y: y coordinate to go to
+ * @param z: z coordinate to go to
+ *
+ * without turning itself
+ */
+float GenericNPC::walkTo(float x, float y, float z)
+{
+  Quaternion q = this->getAbsDir();
+
+  //printf("%s moving to %f, %f, %f \n",this->getName(),x,y,z);
+
+  return this->walkTo(x, y, z, q.w, q.v.x, q.v.y, q.v.z);
+}
+
+/**
+ * walk to a specific place with direction
+ *
+ * @param x: x coordinate to go to
+ * @param y: y coordinate to go to
+ * @param qu: angle to rotate
+ * @param qx: x coordinate of rotation vector
+ * @param qy: y coordinate of rotation vector
+ * @param qz: z coordinate of rotation vector
+ *
+ */
+float GenericNPC::walkTo(float x, float y, float qu, float qx, float qy, float qz)
+{
+  return this->walkTo(x, y, 0.0f, qu, qx, qy, qz);
+}
+
+
+/**
+ * walk to a specific place with direction
+ *
+ * @param coor: vector place
+ * @param dir: direction
+ *
+ */
+float GenericNPC::walkTo(const Vector& coor, const Quaternion& dir)
+{
+  return this->walkTo(coor.x, coor.y, coor.z, dir.w, dir.v.x, dir.v.y, dir.v.z);
+}
+
+
+
+/**
+ * run to a specific place with direction
+ *
+ * @param x: x coordinate to go to
+ * @param y: y coordinate to go to
+ * @param z: z coordinate to go to
+ * @param qu: angle to rotate
+ * @param qx: x coordinate of rotation vector
+ * @param qy: y coordinate of rotation vector
+ * @param qz: z coordinate of rotation vector
+ *
+ */
+float GenericNPC::runTo(float x, float y, float z, float qu, float qx, float qy, float qz)
+{
+  Vector destCoor = Vector(x, y, z);
+  Quaternion destDir = Quaternion(Vector(qx, qy, qz), qu);
+
+  // check if this is the current goal
+  if( this->destCoor != destCoor || this->destDir != destDir)
+  {
+    this->destCoor = destCoor;
+    this->destDir = destDir;
+
+    float time = 5.0f;
 
     if( this->currentAnim != NULL)
@@ -177,23 +275,5 @@
 
 /**
- * walk to a specific place with direction
- *
- * @param x: x coordinate to go to
- * @param y: y coordinate to go to
- * @param z: z coordinate to go to
- *
- * without turning itself
- */
-float GenericNPC::walkTo(float x, float y, float z)
-{
-  Quaternion q = this->getAbsDir();
-
-  //printf("%s moving to %f, %f, %f \n",this->getName(),x,y,z);
-
-  return this->walkTo(x, y, z, q.w, q.v.x, q.v.y, q.v.z);
-}
-
-/**
- * walk to a specific place with direction
+ * run to a specific place with direction
  *
  * @param x: x coordinate to go to
@@ -205,12 +285,12 @@
  *
  */
-float GenericNPC::walkTo(float x, float y, float qu, float qx, float qy, float qz)
-{
-  return this->walkTo(x, y, 0.0f, qu, qx, qy, qz);
-}
-
-
-/**
- * walk to a specific place with direction
+float GenericNPC::runTo(float x, float y, float qu, float qx, float qy, float qz)
+{
+  this->runTo(x, y, 0.0f, qu, qx, qy, qz);
+}
+
+
+/**
+ * run to a specific place with direction
  *
  * @param coor: vector place
@@ -218,13 +298,12 @@
  *
  */
-float GenericNPC::walkTo(const Vector& coor, const Quaternion& dir)
-{
-  return this->walkTo(coor.x, coor.y, coor.z, dir.w, dir.v.x, dir.v.y, dir.v.z);
-}
-
-
-
-/**
- * run to a specific place with direction
+float GenericNPC::runTo(const Vector& coordinate, const Quaternion& dir)
+{
+  this->runTo(coordinate.x, coordinate.y, coordinate.z, dir.w, dir.v.x, dir.v.y, dir.v.z);
+}
+
+
+/**
+ * crouch to a specific place with direction
  *
  * @param x: x coordinate to go to
@@ -237,5 +316,5 @@
  *
  */
-float GenericNPC::runTo(float x, float y, float z, float qu, float qx, float qy, float qz)
+float GenericNPC::crouchTo(float x, float y, float z, float qu, float qx, float qy, float qz)
 {
   Vector destCoor = Vector(x, y, z);
@@ -248,5 +327,4 @@
     this->destDir = destDir;
 
-    float time = 5.0f;
 
     if( this->currentAnim != NULL)
@@ -254,84 +332,7 @@
 
     this->currentAnim = new Animation3D(this);
-    this->currentAnim->addKeyFrame(this->getAbsCoor(), this->getAbsDir(), 0.1f, ANIM_LINEAR, ANIM_LINEAR);
-    this->currentAnim->addKeyFrame(this->destCoor, this->destDir, time, ANIM_LINEAR, ANIM_LINEAR);
     this->currentAnim->addKeyFrame(this->getAbsCoor(), this->getAbsDir(), time, ANIM_LINEAR, ANIM_LINEAR);
     this->currentAnim->addKeyFrame(this->destCoor, this->destDir, time, ANIM_LINEAR, ANIM_LINEAR);
 
-    this->currentAnim->setInfinity(ANIM_INF_CONSTANT);
-    this->currentAnim->play();
-
-    this->setAnimation(RUN, MD2_ANIM_LOOP);
-  }
-
-  // calculate the distance
-  Vector distance = this->getAbsCoor() - this->destCoor;
-  return distance.len();
-}
-
-
-/**
- * run to a specific place with direction
- *
- * @param x: x coordinate to go to
- * @param y: y coordinate to go to
- * @param qu: angle to rotate
- * @param qx: x coordinate of rotation vector
- * @param qy: y coordinate of rotation vector
- * @param qz: z coordinate of rotation vector
- *
- */
-float GenericNPC::runTo(float x, float y, float qu, float qx, float qy, float qz)
-{
-  this->runTo(x, y, 0.0f, qu, qx, qy, qz);
-}
-
-
-/**
- * run to a specific place with direction
- *
- * @param coor: vector place
- * @param dir: direction
- *
- */
-float GenericNPC::runTo(const Vector& coordinate, const Quaternion& dir)
-{
-  this->runTo(coordinate.x, coordinate.y, coordinate.z, dir.w, dir.v.x, dir.v.y, dir.v.z);
-}
-
-
-/**
- * crouch to a specific place with direction
- *
- * @param x: x coordinate to go to
- * @param y: y coordinate to go to
- * @param z: z coordinate to go to
- * @param qu: angle to rotate
- * @param qx: x coordinate of rotation vector
- * @param qy: y coordinate of rotation vector
- * @param qz: z coordinate of rotation vector
- *
- */
-float GenericNPC::crouchTo(float x, float y, float z, float qu, float qx, float qy, float qz)
-{
-  Vector destCoor = Vector(x, y, z);
-  Quaternion destDir = Quaternion(Vector(qx, qy, qz), qu);
-
-  // check if this is the current goal
-  if( this->destCoor != destCoor || this->destDir != destDir)
-  {
-    this->destCoor = destCoor;
-    this->destDir = destDir;
-
-    float time = 5.0f;
-
-    if( this->currentAnim != NULL)
-      delete this->currentAnim;
-
-    this->currentAnim = new Animation3D(this);
-    this->currentAnim->addKeyFrame(this->getAbsCoor(), this->getAbsDir(), 0.1f, ANIM_LINEAR, ANIM_LINEAR);
-    this->currentAnim->addKeyFrame(this->destCoor, this->destDir, time, ANIM_LINEAR, ANIM_LINEAR);
-    this->currentAnim->addKeyFrame(this->getAbsCoor(), this->getAbsDir(), time, ANIM_LINEAR, ANIM_LINEAR);
-    this->currentAnim->addKeyFrame(this->destCoor, this->destDir, time, ANIM_LINEAR, ANIM_LINEAR);
 
     this->currentAnim->setInfinity(ANIM_INF_CONSTANT);
Index: /branches/single_player_map/src/world_entities/npcs/generic_npc.h
===================================================================
--- /branches/single_player_map/src/world_entities/npcs/generic_npc.h	(revision 8822)
+++ /branches/single_player_map/src/world_entities/npcs/generic_npc.h	(revision 8823)
@@ -76,5 +76,6 @@
   void playSound(int i);
 
-
+  void setTime(float newTime){ this->time = newTime; };
+  
   virtual void tick (float time);
 
@@ -91,4 +92,5 @@
 
    Animation3D*                            currentAnim;
+   float                                   time;          //!< Duration of the action
 };
 
