Index: trunk/src/world_entities/npcs/npc.cc
===================================================================
--- trunk/src/world_entities/npcs/npc.cc	(revision 10374)
+++ trunk/src/world_entities/npcs/npc.cc	(revision 10376)
@@ -18,26 +18,101 @@
 
 
+#include "movement_module.h"
+#include "ai_module.h"
+#include "ai_team.h"
+#include "ai_swarm.h"
+#include "ai_engine.h"
+
+#include "player.h"
+#include "playable.h"
+
+#include "weapons/test_gun.h"
+#include "weapons/turret.h"
+#include "weapons/cannon.h"
+
+#include "loading/factory.h"
+#include "debug.h"
+#include "loading/load_param.h"
+
+
 #include "npc.h"
 
 ObjectListDefinition(NPC);
+CREATE_FACTORY(NPC);
+
 
 NPC::NPC(const TiXmlElement* root)
+  : weaponMan(this)
 {
   this->registerObject(this, NPC::_objectList);
 
-  this->toList(OM_GROUP_00);
-
-}
-
-
-NPC::~NPC () {}
-
-
-
-/**
- * adds an AI to this NPC
- */
-void NPC::addAI(AI* ai)
-{}
+  this->toList(OM_GROUP_01);
+
+  if( root != NULL)
+	  this->loadParams(root);
+
+  std::cout << "Team Number: " << teamNumber << "\n";
+  std::cout << "Swarm Number:" << swarmNumber << "\n";
+
+  AIEngine::getInstance()->addAI(teamNumber,swarmNumber,(WorldEntity*)this,maxSpeed,attackDistance);
+
+  this->bFire = false;
+
+
+    // create the weapons and their manager
+
+
+  this->getWeaponManager().changeWeaponConfig(1);
+  Weapon* wpRight = new TestGun(0);
+  wpRight->setName("testGun Right");
+  Weapon* wpLeft = new TestGun(1);
+  wpLeft->setName("testGun Left");
+
+  wpRight->toList( this->getOMListNumber());
+  wpLeft->toList( this->getOMListNumber());
+
+
+  this->addWeapon(wpLeft, 1, 0);
+  this->addWeapon(wpRight,1 ,1);
+
+  wpLeft->increaseEnergy( 100);
+  wpRight->increaseEnergy( 100);
+
+  this->setHealthMax(100);
+  this->setHealth(80);
+
+  this->getWeaponManager().setSlotCount(7);
+
+  this->getWeaponManager().setSlotPosition(0, Vector(-2.6, .1, -3.0));
+  this->getWeaponManager().setSlotCapability(0, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);
+
+  this->getWeaponManager().setSlotPosition(1, Vector(-2.6, .1, 3.0));
+  this->getWeaponManager().setSlotCapability(1, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);
+
+  this->getWeaponManager().setSlotPosition(2, Vector(-1.5, .5, -.5));
+  this->getWeaponManager().setSlotDirection(2, Quaternion(-M_PI_4*.5, Vector(1,0,0)));
+
+  this->getWeaponManager().setSlotPosition(3, Vector(-1.5, .5, .5));
+  this->getWeaponManager().setSlotDirection(3, Quaternion(M_PI_4*.5, Vector(1,0,0)));
+
+  this->getWeaponManager().setSlotPosition(4, Vector(-1.5, -.5, .5));
+  this->getWeaponManager().setSlotDirection(4, Quaternion(-M_PI_4*.5+M_PI, Vector(1,0,0)));
+
+  this->getWeaponManager().setSlotPosition(5, Vector(-1.5, -.5, -.5));
+  this->getWeaponManager().setSlotDirection(5, Quaternion(+M_PI_4*.5-M_PI, Vector(1,0,0)));
+
+  this->getWeaponManager().setSlotPosition(6, Vector(-1, 0.0, 0));
+  this->getWeaponManager().setSlotCapability(6, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);
+
+  this->getWeaponManager().getFixedTarget()->setParent(this);
+  this->getWeaponManager().getFixedTarget()->setRelCoor(100000,0,0);
+
+}
+
+
+NPC::~NPC ()
+{
+  AIEngine::getInstance()->removeAI(teamNumber,swarmNumber,(WorldEntity*)this);
+}
 
 
@@ -50,4 +125,89 @@
 {
    WorldEntity::loadParams(root);
-}
-
+
+  LoadParam(root, "team", this, NPC, setTeamNumber)
+  .describe("this sets the team number")
+  .defaultValues(0);
+
+  LoadParam(root, "swarm", this, NPC, setSwarmNumber)
+  .describe("this sets the swarm number")
+  .defaultValues(0);
+
+  LoadParam(root, "maxSpeed", this, NPC, setMaxSpeed)
+  .describe("this sets the NPC max Speed")
+  .defaultValues(0);
+
+  LoadParam(root, "attackDistance", this, NPC, setAttackDistance)
+  .describe("this sets the NPC distance to target")
+  .defaultValues(0);
+}
+
+
+/**
+ * @brief adds a Weapon to the NPC.
+ * @param weapon the Weapon to add.
+ * @param configID the Configuration ID to add this weapon to.
+ * @param slotID the slotID to add the Weapon to.
+ */
+bool NPC::addWeapon(Weapon* weapon, int configID, int slotID)
+{
+  weapon->setOwner(this->getOwner());
+
+
+  if(this->weaponMan.addWeapon(weapon, configID, slotID))
+  {
+    return true;
+  }
+  else
+  {
+    if (weapon != NULL)
+      PRINTF(2)("Unable to add Weapon (%s::%s) to %s::%s\n",
+                weapon->getClassCName(), weapon->getCName(), this->getClassCName(), this->getCName());
+    else
+      PRINTF(2)("No weapon defined\n");
+    return false;
+
+  }
+}
+
+/**
+ * @brief removes a Weapon.
+ * @param weapon the Weapon to remove.
+ */
+void NPC::removeWeapon(Weapon* weapon)
+{
+  this->weaponMan.removeWeapon(weapon);
+
+}
+
+/**
+ * @brief jumps to the next WeaponConfiguration
+ */
+void NPC::nextWeaponConfig()
+{
+  this->weaponMan.nextWeaponConfig();
+}
+
+/**
+ * @brief moves to the last WeaponConfiguration
+ */
+void NPC::previousWeaponConfig()
+{
+  this->weaponMan.previousWeaponConfig();
+}
+
+
+
+
+/**
+ * ticking
+ * @param dt  time since last tick
+ */
+void NPC::tick(float dt)
+{
+	//std::cout << "fire..\n";
+  this->weaponMan.tick(dt);
+  if (this->bFire)
+    weaponMan.fire();
+  this->bFire = false;
+}
Index: trunk/src/world_entities/npcs/npc.h
===================================================================
--- trunk/src/world_entities/npcs/npc.h	(revision 10374)
+++ trunk/src/world_entities/npcs/npc.h	(revision 10376)
@@ -4,20 +4,51 @@
 
 #include "world_entity.h"
+#include "ai_module.h"
+#include "world_entities/weapons/weapon_manager.h"
 
 class AI;
 
-class NPC : public WorldEntity {
+class NPC : public WorldEntity
+{
   ObjectListDeclaration(NPC);
- public:
-   NPC (const TiXmlElement* root);
+
+public:
+  NPC(const TiXmlElement* root = NULL);
   virtual ~NPC ();
 
-  virtual void loadParams(const TiXmlElement* root = NULL);
+  virtual void loadParams(const TiXmlElement* root);
 
-  void addAI(AI* ai);
 
+  bool addWeapon(Weapon* weapon, int configID = -1, int slotID = -1);
+  void removeWeapon(Weapon* weapon);
+  void nextWeaponConfig();
+  void previousWeaponConfig();
+  inline WeaponManager& getWeaponManager() { return this->weaponMan; };
+
+
+  virtual void tick(float dt);
+  inline int getTeam()  { return teamNumber; }
+  inline void fire(){ this->bFire=true;}
+
+
+
+private:
+  inline void setTeamNumber(int number) { teamNumber=number; }
+  inline void setSwarmNumber(int number) { swarmNumber=number; }
+  inline void setMaxSpeed(float number) { maxSpeed=number; }
+  inline void setAttackDistance(float number) { attackDistance=number; }
 
  private:
 
+  int                   teamNumber;   //!< number of the team
+  int                   swarmNumber;  //!< number of the swarm
+  int                   difficulty;   //!< difficulty
+  float						maxSpeed;
+  float						attackDistance;
+
+  WeaponManager         weaponMan;    //!< weapon manager
+  bool                  bFire;        //!< fire
+
+  AIModule*             aiModule;
 };
 
Index: trunk/src/world_entities/npcs/npc_test.cc
===================================================================
--- trunk/src/world_entities/npcs/npc_test.cc	(revision 10374)
+++ trunk/src/world_entities/npcs/npc_test.cc	(revision 10376)
@@ -19,7 +19,6 @@
 
 #include "npc_test.h"
-#include "obb_tree.h"
+#include <stdio.h>
 
-#include "shader.h"
 #include "state.h"
 #include "debug.h"
@@ -28,5 +27,11 @@
 #include "loading/load_param.h"
 
-#include "effects/explosion.h"
+#include "md2/md2Model.h"
+#include "player.h"
+#include "playable.h"
+
+#include "weapons/test_gun.h"
+#include "weapons/turret.h"
+#include "weapons/cannon.h"
 
 
@@ -34,31 +39,59 @@
 CREATE_FACTORY(NPC2);
 
+
 NPC2::NPC2(const TiXmlElement* root)
-  : NPC(NULL)
 {
   this->registerObject(this, NPC2::_objectList);
 
-//   if ((float)rand()/RAND_MAX > .5f)
-//     this->loadModel("models/ships/bolido.obj", 6);
-//   else
-//     this->loadModel("models/ships/gobblin.obj", 6);
+  if (root != NULL)
+    this->loadParams(root);
 
 
+  // create the weapons and their manager
 
 
-  this->shader = NULL;
-//  if (likely(Shader::checkShaderAbility()))
-    //this->shader = Shader::getShader("shaders/toon.vert", "shaders/toon.frag");
+  this->getWeaponManager().changeWeaponConfig(1);
+  Weapon* wpRight = new TestGun(0);
+  wpRight->setName("testGun Right");
+  Weapon* wpLeft = new TestGun(1);
+  wpLeft->setName("testGun Left");
 
-  this->randomRotAxis = VECTOR_RAND(1);
+  this->addWeapon(wpLeft, 1, 0);
+  this->addWeapon(wpRight,1 ,1);
 
-  if (root != NULL)
-    this->loadParams(root);
+  this->setHealthMax(100);
+  this->setHealth(80);
+
+  this->getWeaponManager().setSlotCount(7);
+
+  this->getWeaponManager().setSlotPosition(0, Vector(-2.6, .1, -3.0));
+  this->getWeaponManager().setSlotCapability(0, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);
+
+  this->getWeaponManager().setSlotPosition(1, Vector(-2.6, .1, 3.0));
+  this->getWeaponManager().setSlotCapability(1, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);
+
+  this->getWeaponManager().setSlotPosition(2, Vector(-1.5, .5, -.5));
+  this->getWeaponManager().setSlotDirection(2, Quaternion(-M_PI_4*.5, Vector(1,0,0)));
+
+  this->getWeaponManager().setSlotPosition(3, Vector(-1.5, .5, .5));
+  this->getWeaponManager().setSlotDirection(3, Quaternion(M_PI_4*.5, Vector(1,0,0)));
+
+  this->getWeaponManager().setSlotPosition(4, Vector(-1.5, -.5, .5));
+  this->getWeaponManager().setSlotDirection(4, Quaternion(-M_PI_4*.5+M_PI, Vector(1,0,0)));
+
+  this->getWeaponManager().setSlotPosition(5, Vector(-1.5, -.5, -.5));
+  this->getWeaponManager().setSlotDirection(5, Quaternion(+M_PI_4*.5-M_PI, Vector(1,0,0)));
+
+  this->getWeaponManager().setSlotPosition(6, Vector(-1, 0.0, 0));
+  this->getWeaponManager().setSlotCapability(6, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);
+
+  this->getWeaponManager().getFixedTarget()->setParent(this);
+  this->getWeaponManager().getFixedTarget()->setRelCoor(100000,0,0);
+
 }
 
-
-NPC2::~NPC2 ()
-{}
-
+NPC2::~NPC2()
+{
+}
 
 void NPC2::loadParams(const TiXmlElement* root)
@@ -69,57 +102,16 @@
 
 
-void NPC2::destroy(WorldEntity* killer)
+
+void NPC2::tick(float dt)
 {
-  Explosion::explode(this, Vector(10,10,10));
-  this->toList(OM_DEAD);
 
+
+
+
+  // animating the md2 model
+  if( likely(this->getModel(0) != NULL) && this->getModel(0)->isA(MD2Model::staticClassID()))
+    ((MD2Model*)this->getModel(0))->tick(dt);
 }
 
 
 
-/**
- *  the entity is drawn onto the screen with this function
- *
- * This is a central function of an entity: call it to let the entity painted to the screen.
- * Just override this function with whatever you want to be drawn.
- */
-// void NPC2::draw() const
-// {
-//   glMatrixMode(GL_MODELVIEW);
-//   glPushMatrix();
-//   float matrix[4][4];
-//
-//   /* translate */
-//   glTranslatef (this->getAbsCoor ().x,
-//                 this->getAbsCoor ().y,
-//                 this->getAbsCoor ().z);
-//   /* rotate */
-//   this->getAbsDir ().matrix (matrix);
-//   glMultMatrixf((float*)matrix);
-//
-// //   if (this->shader != NULL && this->shader != Shader::getActiveShader())
-// //     shader->activateShader();
-//
-//   if( this->getModel())
-//     this->getModel()->draw();
-// //   shader->deactivateShader();
-//
-//
-// /*  if (this->model)
-//     this->model->draw();*/
-//   glPopMatrix();
-// }
-
-
-void NPC2::tick(float dt)
-{
-//  Vector direction = (State::getCameraTarget()->getAbsCoor() - this->getAbsCoor());
-
-  //if (directin.len() < 100)
-//  this->shiftCoor(direction *dt * 5 * exp(-direction.len() / 30.0));
-//  this->shiftDir(Quaternion(dt, this->randomRotAxis));
-
-}
-
-
-
Index: trunk/src/world_entities/npcs/npc_test.h
===================================================================
--- trunk/src/world_entities/npcs/npc_test.h	(revision 10374)
+++ trunk/src/world_entities/npcs/npc_test.h	(revision 10376)
@@ -5,26 +5,25 @@
 #include "npc.h"
 
+
+
 class AI;
 class Shader;
+class AIModule;
 
-class NPC2 : public NPC {
+class NPC2 : public NPC
+{
   ObjectListDeclaration(NPC2);
 
- public:
+public:
   NPC2 (const TiXmlElement* root);
   virtual ~NPC2 ();
+  virtual void loadParams(const TiXmlElement* root);
+  virtual void tick(float dt);
 
-  virtual void loadParams(const TiXmlElement* root);
 
-  void addAI(AI* ai);
 
-  virtual void destroy(WorldEntity* killer);
 
-  virtual void tick(float dt);
-//   virtual void draw() const;
+private:
 
- private:
-   Vector   randomRotAxis;
-   Shader*  shader;
 };
 
