Index: trunk/src/world_entities/npcs/generic_npc.cc
===================================================================
--- trunk/src/world_entities/npcs/generic_npc.cc	(revision 8724)
+++ trunk/src/world_entities/npcs/generic_npc.cc	(revision 8724)
@@ -0,0 +1,172 @@
+
+
+/*
+   orxonox - the future of 3D-vertical-scrollers
+
+   Copyright (C) 2004 orx
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2, or (at your option)
+   any later version.
+
+   ### File Specific
+   main-programmer: Patrick Boenzli
+   co-programmer:
+*/
+#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_WORLD_ENTITY
+
+
+#include "util/loading/factory.h"
+#include "util/loading/load_param.h"
+
+#include "interactive_model.h"
+#include "md2/md2Model.h"
+
+#include "sound_buffer.h"
+
+#include "loading/resource_manager.h"
+
+#include "generic_npc.h"
+
+using namespace std;
+
+
+
+CREATE_FACTORY(GenericNPC, CL_GENERIC_NPC);
+
+
+
+/**
+ * constructor
+ */
+GenericNPC::GenericNPC(const TiXmlElement* root)
+  : NPC(root)
+{
+  this->init();
+
+  if (root != NULL)
+    this->loadParams(root);
+}
+
+
+/**
+ * deconstructor
+ */
+GenericNPC::~GenericNPC ()
+{}
+
+
+/**
+ * initializing the npc enity
+ */
+void GenericNPC::init()
+{
+  this->setClassID(CL_GENERIC_NPC, "GenericNPC");
+  this->toList(OM_GROUP_00);
+
+  if (this->soundBuffer != NULL)
+    ResourceManager::getInstance()->unload(this->soundBuffer);
+  this->soundBuffer = (OrxSound::SoundBuffer*)ResourceManager::getInstance()->load("sound/rain.wav", WAV);
+
+  // collision reaction registration
+//   this->subscribeReaction(CREngine::CR_PHYSICS_GROUND_WALK, CL_BSP_ENTITY);
+}
+
+
+/**
+ * loads the Settings of a MD2Creature from an XML-element.
+ * @param root the XML-element to load the MD2Creature's properties from
+ */
+void GenericNPC::loadParams(const TiXmlElement* root)
+{
+  NPC::loadParams(root);
+
+}
+
+
+/**
+ * sets the animation of this npc
+ * @param anumationIndex: the animation index
+ * @param anumPlaybackMode: the playback mode
+ */
+void GenericNPC::setAnimation(int animationIndex, int animPlaybackMode)
+{
+  if( likely(this->getModel(0) != NULL))
+    ((InteractiveModel*)this->getModel(0))->setAnimation(animationIndex, animPlaybackMode);
+}
+
+
+/**
+ * sets the animation of this npc
+ * @param anumationIndex: the animation index
+ * @param anumPlaybackMode: the playback mode
+ */
+void GenericNPC::playAnimation(int animationIndex, int animPlaybackMode)
+{
+  if( likely(this->getModel(0) != NULL))
+    ((InteractiveModel*)this->getModel(0))->setAnimation(animationIndex, animPlaybackMode);
+
+}
+
+
+/**
+ * play a sound
+ * @param filename: name of the file
+ */
+void GenericNPC::playSound(std::string filename)
+{
+
+}
+
+
+/**
+ * walt to
+ * @param coordinate: coordinate to go to
+ */
+bool GenericNPC::walkTo(const Vector& coordinate, float time)
+{
+
+  return true;
+}
+
+
+/**
+ * walt to
+ * @param coordinate: coordinate to go to
+ */
+bool GenericNPC::walkTo(float x, float y, float z, float time)
+{
+
+  return true;
+}
+
+
+/**
+ * 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::destroy()
+{
+  int randi = (int)(5.0f * (float)rand()/(float)RAND_MAX);
+
+  if( randi == 1)
+    this->setAnimation(DEATH_FALLBACK, MD2_ANIM_ONCE);
+  else if( randi == 2)
+    this->setAnimation(DEATH_FALLFORWARD, MD2_ANIM_ONCE);
+  else if( randi == 3)
+    this->setAnimation(DEATH_FALLBACKSLOW, MD2_ANIM_ONCE);
+  else if( randi == 4)
+    this->setAnimation(CROUCH_DEATH, MD2_ANIM_ONCE);
+  else
+    this->setAnimation(DEATH_FALLBACK, MD2_ANIM_ONCE);
+}
+
Index: trunk/src/world_entities/npcs/generic_npc.h
===================================================================
--- trunk/src/world_entities/npcs/generic_npc.h	(revision 8724)
+++ trunk/src/world_entities/npcs/generic_npc.h	(revision 8724)
@@ -0,0 +1,54 @@
+
+/*!
+ * @file generic_npc.h
+ * generic npc object
+ */
+
+#ifndef _GENERIC_ENTITY_H
+#define _GENERIC_ENTITY_H
+
+#include "npc.h"
+
+#include <string>
+//
+#include "sound_source.h"
+
+namespace OrxSound{ class SoundSource; }
+namespace OrxSound{ class SoundBuffer; }
+
+class TiXmlElement;
+
+
+class GenericNPC : public NPC
+{
+ public:
+  GenericNPC(const TiXmlElement* root);
+  virtual ~GenericNPC ();
+
+  void init();
+  virtual void loadParams(const TiXmlElement* root);
+
+  void setAnimation(int animationIndex, int animPlaybackMode);
+  /** sets the sound volume to @param vol: volume of the sound */
+  inline void setVolume(float vol) { this->soundVolume = vol; }
+
+  void playAnimation(int animationIndex, int animPlaybackMode);
+
+  void playSound(std::string filename);
+  void playSound(int i);
+
+  bool walkTo(const Vector& coordinate, float time);
+  bool walkTo(float x, float y, float z, float time);
+
+  void destroy();
+
+  virtual void tick (float time);
+
+
+ private:
+   OrxSound::SoundSource                   soundSource;
+   OrxSound::SoundBuffer*                  soundBuffer;
+   float                                   soundVolume;
+};
+
+#endif /* _GENERIC_ENTITY_H */
Index: trunk/src/world_entities/npcs/ground_turret.cc
===================================================================
--- trunk/src/world_entities/npcs/ground_turret.cc	(revision 7954)
+++ trunk/src/world_entities/npcs/ground_turret.cc	(revision 8724)
@@ -39,4 +39,5 @@
  */
 GroundTurret::GroundTurret(const TiXmlElement* root)
+  : NPC(root)
 {
   this->init();
Index: trunk/src/world_entities/npcs/npc.cc
===================================================================
--- trunk/src/world_entities/npcs/npc.cc	(revision 7954)
+++ trunk/src/world_entities/npcs/npc.cc	(revision 8724)
@@ -19,17 +19,13 @@
 
 #include "npc.h"
-#include "obb_tree.h"
 
-#include "state.h"
-#include "stdlibincl.h"
-#include "power_ups/turret_power_up.h"
-#include "power_ups/laser_power_up.h"
 
 using namespace std;
 
 
-NPC::NPC()
+NPC::NPC(const TiXmlElement* root)
 {
   this->setClassID(CL_NPC, "NPC");
+
   this->toList(OM_GROUP_00);
 }
@@ -39,48 +35,20 @@
 
 
-void NPC::collidesWith(WorldEntity* entity, const Vector& location)
-{
 
-  if (entity == collider)
-    return;
-  collider = entity;
-
-  if (entity->isA(CL_PROJECTILE))
-  {
-    this->decreaseHealth(entity->getHealth() *(float)rand()/(float)RAND_MAX);
-    // EXTREME HACK
-    if (this->getHealth() <= 0.0f)
-    {
-      this->destroy();
-    }
-  }
+/**
+ * adds an AI to this NPC
+ */
+void NPC::addAI(AI* ai)
+{}
 
 
-// //    PRINTF(3)("collision %s vs %s @ (%f,%f,%f)\n", this->getName(), entity->getName(), location.x, location.y, location.z);
-// //    this->applyForce(Vector(0,0,0)-location*1000);
-//     if ((float)rand()/RAND_MAX < .3)
-//     {
-//       WorldEntity* powerUp = new TurretPowerUp();
-//       powerUp->setAbsCoor(this->getAbsCoor());
-// //      powerUp->toList(OM_COMMON);
-//     }
-//     else if ((float)rand()/RAND_MAX < .3)
-//     {
-//       WorldEntity* powerUp = new LaserPowerUp();
-//       powerUp->setAbsCoor(this->getAbsCoor());
-//       powerUp->toList(OM_COMMON);
-//     }
-//     this->toList(OM_DEAD);
-//     this->removeNode();
-//
-//       this->collider = entity;
-//   }
-//   //  else if (entity->isA(CL_PLAYER))
-//   //    this->applyForce(Vector(0,0,0)-location*100);
-//   else if (entity->isA(CL_NPC))
-//   {
-//     this->setVisibiliy(false);
-//     this->toList(OM_DEAD);
-//     this->removeNode();
-//   }
+
+/**
+ * loads the xml tags
+ * @param root: root xml tag for this element
+ */
+void NPC::loadParams(const TiXmlElement* root)
+{
+  WorldEntity::loadParams(root);
 }
+
Index: trunk/src/world_entities/npcs/npc.h
===================================================================
--- trunk/src/world_entities/npcs/npc.h	(revision 7954)
+++ trunk/src/world_entities/npcs/npc.h	(revision 8724)
@@ -4,5 +4,4 @@
 
 #include "world_entity.h"
-#include "physics_interface.h"
 
 class AI;
@@ -11,17 +10,14 @@
 
  public:
-  NPC ();
+   NPC (const TiXmlElement* root);
   virtual ~NPC ();
 
+  virtual void loadParams(const TiXmlElement* root = NULL);
 
   void addAI(AI* ai);
-
-  virtual void collidesWith (WorldEntity* entity, const Vector& location);
 
 
  private:
 
-   WorldEntity* collider;
-
 };
 
Index: trunk/src/world_entities/npcs/npc_test.cc
===================================================================
--- trunk/src/world_entities/npcs/npc_test.cc	(revision 7954)
+++ trunk/src/world_entities/npcs/npc_test.cc	(revision 8724)
@@ -31,4 +31,5 @@
 
 NPC2::NPC2()
+  : NPC(NULL)
 {
   this->setClassID(CL_NPC_TEST2, "NPC2");
Index: trunk/src/world_entities/npcs/npc_test1.cc
===================================================================
--- trunk/src/world_entities/npcs/npc_test1.cc	(revision 7954)
+++ trunk/src/world_entities/npcs/npc_test1.cc	(revision 8724)
@@ -29,4 +29,5 @@
 
 NPCTest1::NPCTest1()
+  : NPC(NULL)
 {
   this->setClassID(CL_NPC_TEST1, "NPCTest1");
