Index: /branches/single_player_map/src/world_entities/npcs/generic_npc.cc
===================================================================
--- /branches/single_player_map/src/world_entities/npcs/generic_npc.cc	(revision 8912)
+++ /branches/single_player_map/src/world_entities/npcs/generic_npc.cc	(revision 8913)
@@ -35,11 +35,11 @@
 #include "script_class.h"
 CREATE_SCRIPTABLE_CLASS(GenericNPC, CL_GENERIC_NPC,
-                       // Move
+                        // Move
                         addMethod("walkTo", ExecutorLua3<GenericNPC,float,float,float>(&GenericNPC::walkTo))
                         ->addMethod("turnTo", ExecutorLua1<GenericNPC,float>(&GenericNPC::turnTo))
-                       // Display
+                        // Display
                         ->addMethod("hide", ExecutorLua0<WorldEntity>(&WorldEntity::hide))
                         ->addMethod("unhide", ExecutorLua0<WorldEntity>(&WorldEntity::unhide))
-                       // Coordinates
+                        // Coordinates
                         ->addMethod("getAbsCoorX", ExecutorLua0ret<PNode, float>(&PNode::getAbsCoorX))
                         ->addMethod("getAbsCoorY", ExecutorLua0ret<PNode, float>(&PNode::getAbsCoorY))
@@ -56,5 +56,5 @@
  */
 GenericNPC::GenericNPC(const TiXmlElement* root)
-  : NPC(root)
+    : NPC(root)
 {
   this->init();
@@ -69,6 +69,5 @@
  */
 GenericNPC::~GenericNPC ()
-{
-}
+{}
 
 
@@ -87,5 +86,5 @@
   time = 30.0f;
   // collision reaction registration
-//   this->subscribeReaction(CREngine::CR_PHYSICS_GROUND_WALK, CL_BSP_ENTITY);
+  //   this->subscribeReaction(CREngine::CR_PHYSICS_GROUND_WALK, CL_BSP_ENTITY);
 }
 
@@ -132,7 +131,5 @@
  */
 void GenericNPC::playSound(std::string filename)
-{
-
-}
+{}
 
 
@@ -142,116 +139,12 @@
  */
 void GenericNPC::stop()
-{
-
-}
-
-
-void GenericNPC::walkTo(const Vector& coordinate)
-{
-  GenericNPC::Anim anim;
-  anim.v = coordinate;
-  anim.type = Walk;
-
-  this->behaviourList.push_back(anim);
-}
-
-void GenericNPC::walkTo(float x, float y, float z)
-{
-  this->walkTo(Vector(x,y,z));
-
-}
-
-/* running functions */
-void GenericNPC::runTo(const Vector& coordinate)
-{
-  GenericNPC::Anim anim;
-  anim.v = coordinate;
-  anim.type = Run;
-
-  this->behaviourList.push_back(anim);
-}
-
-void GenericNPC::runTo(float x, float y, float z)
-{
-  this->runTo(Vector(x,y,z));
-}
-
-/* couching functinos */
-void GenericNPC::crouchTo(const Vector& coordinate)
-{
-  GenericNPC::Anim anim;
-  anim.v = coordinate;
-  anim.type = Crouch;
-
-  this->behaviourList.push_back(anim);
-}
-void GenericNPC::crouchTo(float x, float y, float z)
-{
-  this->crouchTo(Vector(x,y,z));
-}
-
-
-
-void GenericNPC::turnTo(float degreeInY)
-{
-  GenericNPC::Anim anim;
-  anim.q = Quaternion(Vector(0,1,0), degreeInY);
-  anim.type = TurnTo;
-
-  this->behaviourList.push_back(anim);
-}
-
-
-
-/**
- * lookat a world entity
- * @param worldEntity: the worldentity to look at
- */
-void GenericNPC::lookAt(WorldEntity* worldEntity)
-{
-  GenericNPC::Anim anim;
-  anim.entity = worldEntity;
-  anim.type = LookAt;
-
-  this->behaviourList.push_back(anim);
-}
-
-
-
-
-/**
- * talk to a world entity and play a sound/music/voice
- * @param worldEntity: entity
- * @param dialogNr: sound nr to be played (from the xml load tags)
- */
-void GenericNPC::talkTo(WorldEntity* worldEntity, int dialogNr)
-{}
-
-
-/**
- * world entity to shoot at if there is any weapon on the npc
- * @param entity: entity to shoot entity
- */
-void GenericNPC::shootAt(WorldEntity* entity)
-{}
-
-
-
-
-
-
-
-
-
-
-/**
- * tick this world entity
- * @param time: time in seconds expirded since the last tick
- */
-void GenericNPC::tick (float time)
-{
-  if( likely(this->getModel(0) != NULL))
-    ((InteractiveModel*)this->getModel(0))->tick(time);
-
+{}
+
+void GenericNPC::nextStep()
+{
+  if (!this->behaviourList.empty())
+    this->behaviourList.pop_front();
+  else
+    return;
 
   if (!this->behaviourList.empty())
@@ -260,12 +153,164 @@
     {
       case Walk:
+        this->setAnimation(RUN, MD2_ANIM_LOOP);
         break;
       case Run:
+        this->setAnimation(RUN, MD2_ANIM_LOOP);
         break;
       case Crouch:
+        this->setAnimation(CROUCH_WALK, MD2_ANIM_LOOP);
         break;
       case LookAt:
+        this->setAnimation(STAND, MD2_ANIM_LOOP);
+
         break;
       case Shoot:
+        this->setAnimation(STAND, MD2_ANIM_LOOP);
+        break;
+
+      default:
+        this->setAnimation(STAND, MD2_ANIM_LOOP);
+        break;
+
+    }
+  }
+  else
+  {
+    this->setAnimation(STAND, MD2_ANIM_LOOP);
+  }
+}
+
+
+void GenericNPC::walkTo(const Vector& coordinate)
+{
+  GenericNPC::Anim anim;
+  anim.v = coordinate;
+  anim.type = Walk;
+
+  this->behaviourList.push_back(anim);
+}
+
+void GenericNPC::walkTo(float x, float y, float z)
+{
+  this->walkTo(Vector(x,y,z));
+
+}
+
+/* running functions */
+void GenericNPC::runTo(const Vector& coordinate)
+{
+  GenericNPC::Anim anim;
+  anim.v = coordinate;
+  anim.type = Run;
+
+  this->behaviourList.push_back(anim);
+}
+
+void GenericNPC::runTo(float x, float y, float z)
+{
+  this->runTo(Vector(x,y,z));
+}
+
+/* couching functinos */
+void GenericNPC::crouchTo(const Vector& coordinate)
+{
+  GenericNPC::Anim anim;
+  anim.v = coordinate;
+  anim.type = Crouch;
+
+  this->behaviourList.push_back(anim);
+}
+void GenericNPC::crouchTo(float x, float y, float z)
+{
+  this->crouchTo(Vector(x,y,z));
+}
+
+
+
+void GenericNPC::turnTo(float degreeInY)
+{
+  GenericNPC::Anim anim;
+  anim.q = Quaternion(Vector(0,1,0), degreeInY);
+  anim.type = TurnTo;
+
+  this->behaviourList.push_back(anim);
+}
+
+
+
+/**
+ * lookat a world entity
+ * @param worldEntity: the worldentity to look at
+ */
+void GenericNPC::lookAt(WorldEntity* worldEntity)
+{
+  GenericNPC::Anim anim;
+  anim.entity = worldEntity;
+  anim.type = LookAt;
+
+  this->behaviourList.push_back(anim);
+}
+
+
+
+
+/**
+ * talk to a world entity and play a sound/music/voice
+ * @param worldEntity: entity
+ * @param dialogNr: sound nr to be played (from the xml load tags)
+ */
+void GenericNPC::talkTo(WorldEntity* worldEntity, int dialogNr)
+{}
+
+
+/**
+ * world entity to shoot at if there is any weapon on the npc
+ * @param entity: entity to shoot entity
+ */
+void GenericNPC::shootAt(WorldEntity* entity)
+{}
+
+
+
+
+
+
+
+
+
+
+/**
+ * tick this world entity
+ * @param time: time in seconds expirded since the last tick
+ */
+void GenericNPC::tick (float time)
+{
+  if( likely(this->getModel(0) != NULL))
+    ((InteractiveModel*)this->getModel(0))->tick(time);
+
+
+  if (!this->behaviourList.empty())
+  {
+    switch(this->behaviourList.front().type)
+    {
+      case Walk:
+        Vector dir = this->getAbsCoor() - this->behaviourList.front().v;
+        if (dir.len() < .5)
+          this->nextStep();
+        else
+        {
+          this->shiftCoor(dir.normalize() * dt);
+        }
+        break;
+      case Run:
+        break;
+      case Crouch:
+        break;
+      case LookAt:
+        break;
+      case Shoot:
+        break;
+
+      default:
         break;
 
