Index: trunk/src/world_entities/WorldEntities.am
===================================================================
--- trunk/src/world_entities/WorldEntities.am	(revision 8846)
+++ trunk/src/world_entities/WorldEntities.am	(revision 8894)
@@ -16,4 +16,5 @@
                 world_entities/character_attributes.cc \
                 world_entities/test_entity.cc \
+                world_entities/door.cc \
                 world_entities/planet.cc \
                 world_entities/bsp_entity.cc \
@@ -26,4 +27,5 @@
                 world_entities/weapons/hyperblaster.cc \
                 world_entities/weapons/aim.cc \
+                world_entities/weapons/fps_sniper_rifle.cc \
                 \
                 world_entities/projectiles/bomb.cc \
@@ -74,4 +76,5 @@
                 character_attributes.h \
                 test_entity.h \
+                door.h \
                 planet.h \
                 bsp_entity.h \
@@ -84,4 +87,5 @@
                 weapons/targeting_turret.h \
                 weapons/aim.h \
+                weapons/fps_sniper_rifle.h \
                 \
                 projectiles/bomb.h \
Index: trunk/src/world_entities/creatures/fps_player.cc
===================================================================
--- trunk/src/world_entities/creatures/fps_player.cc	(revision 8846)
+++ trunk/src/world_entities/creatures/fps_player.cc	(revision 8894)
@@ -26,4 +26,5 @@
 #include "weapons/turret.h"
 #include "weapons/cannon.h"
+#include "weapons/fps_sniper_rifle.h"
 
 #include "key_mapper.h"
@@ -35,4 +36,12 @@
 
 CREATE_FACTORY(FPSPlayer, CL_FPS_PLAYER);
+
+#include "script_class.h"
+CREATE_SCRIPTABLE_CLASS(FPSPlayer, CL_FPS_PLAYER,
+                        addMethod("setAbsCoor", ExecutorLua3<PNode,float,float,float>(&PNode::setAbsCoor))
+                            ->addMethod("getAbsCoorX", ExecutorLua0ret<PNode, float>(&PNode::getAbsCoorX))
+                            ->addMethod("getAbsCoorY", ExecutorLua0ret<PNode, float>(&PNode::getAbsCoorY))
+                            ->addMethod("getAbsCoorZ", ExecutorLua0ret<PNode, float>(&PNode::getAbsCoorZ))
+                       );
 
 
@@ -101,16 +110,17 @@
   dynamic_cast<Element2D*>(this->getWeaponManager().getFixedTarget())->setVisibility( false);
 
-  Weapon* wpRight = new TestGun(0);
+  Weapon* wpRight = new FPSSniperRifle(0);
   wpRight->setName("testGun Right");
-  Weapon* wpLeft = new TestGun(1);
+/*  Weapon* wpLeft = new TestGun(1);*/
 //   Weapon* wpLeft = new Turret();
-  wpLeft->setName("testGun Left");
-
-  this->addWeapon(wpLeft, 1, 0);
-  this->addWeapon(wpRight,1 ,1);
+//   wpLeft->setName("testGun Left");
+
+//   this->addWeapon(wpLeft, 1, 0);
+  this->addWeapon(wpRight,1, 0);
   this->getWeaponManager().changeWeaponConfig(1);
 
   this->getWeaponManager().setSlotCount(2);
-  this->getWeaponManager().setSlotPosition(0, Vector(-0.5, .2, -1.9));
+  this->getWeaponManager().setSlotPosition(0, Vector(0.0, 5.0, 0.0));
+  this->getWeaponManager().setSlotDirection(1, Quaternion(M_PI_4*.5, Vector(0,1,0)));
   this->getWeaponManager().setSlotCapability(0, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);
   this->getWeaponManager().setSlotPosition(1, Vector(-0.5, .2, 1.9));
Index: trunk/src/world_entities/door.cc
===================================================================
--- trunk/src/world_entities/door.cc	(revision 8894)
+++ trunk/src/world_entities/door.cc	(revision 8894)
@@ -0,0 +1,189 @@
+
+
+/*
+   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 "door.h"
+#include "class_list.h"
+
+
+using namespace std;
+
+
+CREATE_FACTORY(Door, CL_DOOR);
+
+
+
+//! list of all different animations a std md2model supports
+sAnim Door::animationList[2] =
+{
+ // begin, end, fps, interruptable
+  {   0,  15,  9,  0 },   //!< OPEN
+  {   15, 30,  9,  0 }    //!< CLOSE
+};
+
+
+
+Door::Door ()
+{
+  this->init();
+}
+
+
+Door::Door(const TiXmlElement* root)
+{
+
+  this->setClassID(CL_DOOR, "Door");
+  this->scale = 1.0f;
+
+  if( root != NULL)
+    this->loadParams(root);
+
+  this->toList(OM_COMMON);
+  this->bLocked = false;
+
+  this->loadMD2Texture("maps/doors.jpg");
+  this->loadModel("models/creatures/doors.md2", this->scale);
+  this->setAnimation(DOOR_CLOSE, MD2_ANIM_ONCE);
+}
+
+
+Door::~Door ()
+{}
+
+
+
+/**
+ * loads the Settings of a MD2Creature from an XML-element.
+ * @param root the XML-element to load the MD2Creature's properties from
+ */
+void Door::loadParams(const TiXmlElement* root)
+{
+  WorldEntity::loadParams(root);
+
+  LoadParam(root, "action-radius", this, Door, setActionRadius)
+      .describe("sets the action radius of the door")
+      .defaultValues(3.0);
+  LoadParam(root, "scale", this, Door, setScale)
+      .describe("sets the scale of the door")
+      .defaultValues(1.0);
+}
+
+
+/**
+ * sets the animatin of this entity
+ */
+void  Door::setAnimation(int animNum, int playbackMode)
+{
+  if( likely(this->getModel(0) != NULL))
+    ((InteractiveModel*)this->getModel(0))->setAnimation(animationList[animNum].firstFrame,
+                                                         animationList[animNum].lastFrame,
+                                                         animationList[animNum].fps,
+                                                         animationList[animNum].bStoppable,
+                                                         playbackMode);
+}
+
+
+/**
+ * ticks the door
+ * @param time: time since last tick
+ */
+void Door::tick (float time)
+{
+  if( likely(this->getModel(0) != NULL))
+    ((InteractiveModel*)this->getModel(0))->tick(time);
+
+  if( this->checkOpen() && !this->bOpen)
+    this->open();
+  else if( bOpen)
+    this->close();
+
+}
+
+
+/**
+ * open the door
+ */
+void Door::open()
+{
+  if( this->bLocked)
+    return;
+
+  this->setAnimation(DOOR_OPEN, MD2_ANIM_ONCE);
+  this->bOpen = true;
+}
+
+
+/**
+ * close the door
+ */
+void Door::close()
+{
+  this->setAnimation(DOOR_CLOSE, MD2_ANIM_ONCE);
+  this->bOpen = false;
+}
+
+
+
+/**
+ * checks if the door is open
+ */
+bool Door::checkOpen()
+{
+
+  std::list<BaseObject*>::const_iterator it;
+  const std::list<BaseObject*>* list = ClassList::getList(CL_PLAYABLE);
+  WorldEntity* entity;
+  float distance;
+
+  if( list == NULL)
+    return false;
+
+  // for all players
+  for( it = list->begin(); it != list->end(); it++)
+  {
+    entity = dynamic_cast<WorldEntity*>(*it);
+
+    distance = fabs((this->getAbsCoor() - entity->getAbsCoor()).len());
+    if( distance < this->actionRadius)
+      return true;
+  }
+
+
+  list = ClassList::getList(CL_GENERIC_NPC);
+  if( list == NULL)
+    return false;
+  for( it = list->begin(); it != list->end(); it++)
+  {
+    entity = dynamic_cast<WorldEntity*>(*it);
+
+    distance = fabs((this->getAbsCoor() - entity->getAbsCoor()).len());
+    if( distance < this->actionRadius)
+      return true;
+  }
+
+  return false;
+}
+
+
+
Index: trunk/src/world_entities/door.h
===================================================================
--- trunk/src/world_entities/door.h	(revision 8894)
+++ trunk/src/world_entities/door.h	(revision 8894)
@@ -0,0 +1,60 @@
+#ifndef _DOOR_H
+#define _DOOR_H
+
+#include "world_entity.h"
+
+#include "md2/md2Model.h"
+
+class TiXmlElement;
+
+
+//! animation names enumeration
+typedef enum DoorAnimType
+{
+  DOOR_OPEN = 0,
+  DOOR_CLOSE,
+
+  DOOR_MAX_ANIMATIONS
+};
+
+
+class Door : public WorldEntity
+{
+  public:
+    Door ();
+    Door(const TiXmlElement* root);
+    virtual ~Door ();
+
+    virtual void loadParams(const TiXmlElement* root);
+
+    void setActionRadius(float radius) { this->actionRadius = radius; }
+    void setScale(float scale) { this->scale = scale; }
+
+    void open();
+    void close();
+
+    void lock() { this->bLocked = true; }
+    void unlock() { this->bLocked = false; }
+    bool isLocked() const { return this->bLocked; }
+
+
+    virtual void tick (float time);
+
+
+  private:
+    bool checkOpen();
+    void setAnimation(int animNum, int playbackMode = 0);
+
+
+  private:
+    bool           bOpen;             //!< true if the door is open
+    bool           bLocked;           //!< true if this door is locked
+    float          actionRadius;      //!< action radius
+    float          scale;             //!< the scale of the model
+
+    static sAnim   animationList[2];  //!< list of the animations
+
+
+};
+
+#endif /* _DOOR_H */
Index: trunk/src/world_entities/npcs/generic_npc.cc
===================================================================
--- trunk/src/world_entities/npcs/generic_npc.cc	(revision 8846)
+++ trunk/src/world_entities/npcs/generic_npc.cc	(revision 8894)
@@ -38,4 +38,22 @@
 CREATE_FACTORY(GenericNPC, CL_GENERIC_NPC);
 
+#include "script_class.h"
+CREATE_SCRIPTABLE_CLASS(GenericNPC, CL_GENERIC_NPC,
+                       // Move
+                        addMethod("walkTo", ExecutorLua3ret<GenericNPC,float,float,float,float>(&GenericNPC::walkTo))
+                        ->addMethod("setTime", ExecutorLua1<GenericNPC,float>(&GenericNPC::setTime))
+                        ->addMethod("turnTo", ExecutorLua4ret<GenericNPC,bool,float,float,float,float>(&GenericNPC::turnTo))
+                       // Display
+                        ->addMethod("hide", ExecutorLua0<WorldEntity>(&WorldEntity::hide))
+                        ->addMethod("unhide", ExecutorLua0<WorldEntity>(&WorldEntity::unhide))
+                       // Coordinates
+                        ->addMethod("getAbsCoorX", ExecutorLua0ret<PNode, float>(&PNode::getAbsCoorX))
+                        ->addMethod("getAbsCoorY", ExecutorLua0ret<PNode, float>(&PNode::getAbsCoorY))
+                        ->addMethod("getAbsCoorZ", ExecutorLua0ret<PNode, float>(&PNode::getAbsCoorZ))
+                        ->addMethod("setAbsCoor", ExecutorLua3<PNode,float,float,float>(&PNode::setAbsCoor))
+                        ->addMethod("setAbsDir", ExecutorLua4<PNode,float,float,float,float>(&PNode::setAbsDir))
+                            
+                       );
+
 
 
@@ -52,4 +70,10 @@
 }
 
+
+GenericNPC::GenericNPC()
+  : NPC(NULL)
+{
+
+}
 
 /**
@@ -75,4 +99,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);
@@ -136,10 +161,10 @@
 
   // check if this is the current goal
-  if( this->destCoor != destCoor && this->destDir != destDir)
+  if( this->destCoor != destCoor || this->destDir != destDir)
   {
-    this->destCoor = Vector(x, y, 0.0f);
-    this->destDir = Quaternion(Vector(qx, qy, qz), qu);
-
-    float time = 5.0f;
+    this->destCoor = destCoor;
+    this->destDir = destDir;
+
+    //float time = 100.0f;
 
     if( this->currentAnim != NULL)
@@ -147,6 +172,12 @@
 
     this->currentAnim = new Animation3D(this);
-    this->currentAnim->addKeyFrame(this->getAbsCoor(), this->getAbsDir(), 0.0f);
-    this->currentAnim->addKeyFrame(this->destCoor, this->destDir, time);
+    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->setInfinity(ANIM_INF_CONSTANT);
+    this->currentAnim->play();
+
+    this->setAnimation(RUN, MD2_ANIM_LOOP);
   }
 
@@ -157,4 +188,21 @@
 
 
+/**
+ * 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);
+}
 
 /**
@@ -188,4 +236,247 @@
 
 
+
+/**
+ * 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)
+      delete this->currentAnim;
+
+    this->currentAnim = new Animation3D(this);
+    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;
+
+
+    if( this->currentAnim != NULL)
+      delete this->currentAnim;
+
+    this->currentAnim = new Animation3D(this);
+    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(CROUCH_WALK, MD2_ANIM_LOOP);
+  }
+
+  // calculate the distance
+  Vector distance = this->getAbsCoor() - this->destCoor;
+  return distance.len();
+}
+
+
+/**
+ * couch 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::crouchTo(float x, float y, float qu, float qx, float qy, float qz)
+{
+  this->crouchTo(x, y, 0.0f, qu, qx, qy, qz);
+}
+
+
+
+/**
+ * crouch to a specific place with direction
+ *
+ * @param coor: vector place
+ * @param dir: direction
+ *
+ */
+float GenericNPC::crouchTo(const Vector& coordinate, const Quaternion& dir)
+{
+  this->crouchTo(coordinate.x, coordinate.y, coordinate.z, dir.w, dir.v.x, dir.v.y, dir.v.z);
+}
+
+
+/**
+ * stops the generic animation
+ */
+void GenericNPC::stop()
+{
+  if( this->currentAnim != NULL)
+  {
+    this->currentAnim->stop();
+    delete this->currentAnim;
+    this->currentAnim = NULL;
+
+    this->setAnimation(STAND, MD2_ANIM_LOOP);
+  }
+}
+
+
+/**
+ * lookat a world entity
+ * @param worldEntity: the worldentity to look at
+ */
+float GenericNPC::lookAt(WorldEntity* worldEntity)
+{}
+
+
+/**
+ * turns to a given direction
+ */
+bool GenericNPC::turnTo(float qu, float qx, float qy, float qz)
+{
+  Quaternion destDir = Quaternion(Vector(qx, qy, qz).getNormalized(), qu);
+
+  printf("Turning: %f, %f, %f, %f \n",qu,qx,qy,qz);
+  // check if this is the current goal
+  if( this->destDir != destDir)
+  {
+//     if( this->currentAnim != NULL)
+//       this->currentAnim->stop();
+//
+    PRINTF(0)("SET ANIMATION\n");
+    this->destDir = destDir;
+//
+
+
+    if( this->currentAnim != NULL)
+      delete this->currentAnim;
+
+    this->setAbsDir(destDir);
+/*
+    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->getAbsCoor(), this->destDir, time, ANIM_LINEAR, ANIM_LINEAR);
+
+
+    this->currentAnim->setInfinity(ANIM_INF_CONSTANT);
+    this->currentAnim->play();*/
+
+    this->setAnimation(STAND, MD2_ANIM_LOOP);
+  }
+
+  // calculate the distance
+  Vector distance = this->getAbsCoor() - this->destCoor;
+  return distance.len();
+}
+
+
+
+/**
+ * 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)
+ */
+float 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
@@ -196,4 +487,5 @@
   if( likely(this->getModel(0) != NULL))
     ((InteractiveModel*)this->getModel(0))->tick(time);
+
 }
 
Index: trunk/src/world_entities/npcs/generic_npc.h
===================================================================
--- trunk/src/world_entities/npcs/generic_npc.h	(revision 8846)
+++ trunk/src/world_entities/npcs/generic_npc.h	(revision 8894)
@@ -28,4 +28,5 @@
 {
  public:
+  GenericNPC();
   GenericNPC(const TiXmlElement* root);
   virtual ~GenericNPC ();
@@ -38,29 +39,48 @@
   inline void setVolume(float vol) { this->soundVolume = vol; }
 
-  void playAnimation(int animationIndex, int animPlaybackMode);
 
-  void playSound(std::string filename);
-  void playSound(int i);
+  /* npc controlling functions */
 
-  float lookAt(WorldEntity* worldEntity);
-
+  /* walking functions */
   float walkTo(const Vector& coordinate, const Quaternion& dir);
+  float walkTo(float x, float y, float z);
   float walkTo(float x, float y, float z, float qu, float qx, float qy, float qz);
   float walkTo(float x, float y, float qu, float qx, float qy, float qz);
 
+  /* running functions */
   float runTo(const Vector& coordinate, const Quaternion& dir);
   float runTo(float x, float y, float z, float qu, float qx, float qy, float qz);
   float runTo(float x, float y, float qu, float qx, float qy, float qz);
 
+  /* couching functinos */
   float crouchTo(const Vector& coordinate, const Quaternion& dir);
   float crouchTo(float x, float y, float z, float qu, float qx, float qy, float qz);
   float crouchTo(float x, float y, float qu, float qx, float qy, float qz);
 
+  /* stopping the movement */
+  void stop();
+
+  /* some oriantation functions */
+  float lookAt(WorldEntity* worldEntity);
+  bool turnTo(float qu, float qx, float qy, float qz);
+
+  /* talking funcitons*/
   float talkTo(WorldEntity* worldEntity, int dialogNr);
+
+  /* shooting functions */
+  void shootAt(WorldEntity* entity);
+
+
+  /* some generic control funtions */
+  void playAnimation(int animationIndex, int animPlaybackMode);
+  void playSound(std::string filename);
+  void playSound(int i);
+
+  void setTime(float newTime){ this->time = newTime; };
+  
+  virtual void tick (float time);
 
 
   void destroy();
-
-  virtual void tick (float time);
 
 
@@ -74,4 +94,5 @@
 
    Animation3D*                            currentAnim;
+   float                                   time;          //!< Duration of the action
 };
 
Index: trunk/src/world_entities/npcs/npc.cc
===================================================================
--- trunk/src/world_entities/npcs/npc.cc	(revision 8846)
+++ trunk/src/world_entities/npcs/npc.cc	(revision 8894)
@@ -50,5 +50,6 @@
 void NPC::loadParams(const TiXmlElement* root)
 {
-  WorldEntity::loadParams(root);
+  if(root != NULL)
+   WorldEntity::loadParams(root);
 }
 
Index: trunk/src/world_entities/script_trigger.cc
===================================================================
--- trunk/src/world_entities/script_trigger.cc	(revision 8846)
+++ trunk/src/world_entities/script_trigger.cc	(revision 8894)
@@ -24,7 +24,7 @@
 CREATE_SCRIPTABLE_CLASS(ScriptTrigger, CL_SCRIPT_TRIGGER,
                             addMethod("setAbsCoor", ExecutorLua3<PNode,float,float,float>(&PNode::setAbsCoor))
-                                ->addMethod("getAbsCoorX", ExecutorLua0ret<PNode, float>(&PNode::getAbsCoorX))
-                                ->addMethod("getAbsCoorY", ExecutorLua0ret<PNode, float>(&PNode::getAbsCoorY))
-                                ->addMethod("getAbsCoorZ", ExecutorLua0ret<PNode, float>(&PNode::getAbsCoorZ))
+                            ->addMethod("getAbsCoorX", ExecutorLua0ret<PNode, float>(&PNode::getAbsCoorX))
+                            ->addMethod("getAbsCoorY", ExecutorLua0ret<PNode, float>(&PNode::getAbsCoorY))
+                            ->addMethod("getAbsCoorZ", ExecutorLua0ret<PNode, float>(&PNode::getAbsCoorZ))
                        );
 
@@ -41,10 +41,10 @@
 
   returnCount = 1;
-  actionFinished = false;
+  scriptFinished = false;
   doDebugDraw = false;
   invert = false;
   scriptCalled = false;
   scriptIsOk = false;
-  triggerLasts = false;
+  triggerLasts = true;
   addToScript = false;
   
@@ -54,5 +54,5 @@
   loadParams(root);
   
-  if(addToScript)
+  if(addToScript && scriptIsOk)
   {
     script->addObject( "ScriptTrigger", this->getName());
@@ -102,19 +102,16 @@
         .describe("The name of the parent as it is in the *.oxw file")
         .defaultValues("");
-    LoadParam(root, "callonce", this, ScriptTrigger, setCallOnce)
-        .describe("True if the script shoul only be called once")
-        .defaultValues("");
     LoadParam(root, "invert", this, ScriptTrigger, setInvert)
         .describe("")
-        .defaultValues("");
+        .defaultValues("false");
     LoadParam(root, "triggerlasts", this, ScriptTrigger, setTriggerLasts)
         .describe("")
-        .defaultValues("");
+        .defaultValues("true");
     LoadParam(root, "debugdraw", this, ScriptTrigger, setDebugDraw)
-        .describe("True if the script should only be called once")
-        .defaultValues("");
+        .describe("")
+        .defaultValues("false");
     LoadParam(root, "addtoscript", this, ScriptTrigger, setAddToScript)
         .describe("True if this scripttrigger should be aviable in the script")
-        .defaultValues("");
+        .defaultValues("false");
 }
 
@@ -159,5 +156,5 @@
 void ScriptTrigger::tick(float timestep)
 {
-  if(actionFinished) return;
+  if(scriptFinished) return;
 
   if(triggerLasts && scriptCalled)
@@ -169,28 +166,12 @@
   if( !invert && this->distance(target) < radius)
  {
-  if(!callOnce)
-   {
     executeAction(timestep);
     scriptCalled = true;
-   }
-  else if(callOnce && !scriptCalled)
-  {
-   executeAction(timestep);
-   scriptCalled = true;
-  }
   
  }
  else if( invert && this->distance(target) > radius)
  {
-   if(!callOnce)
-   {
-     executeAction(timestep);
-   }
-   else if(callOnce && !scriptCalled)
-   {
-     executeAction(timestep);
+     executeAction(timestep); 
      scriptCalled = true;
-   }
-   
  }
  //else
@@ -202,4 +183,5 @@
 void ScriptTrigger::executeAction(float timestep)
 {
+  
      if(scriptIsOk)
      {
@@ -213,5 +195,5 @@
        printf("Error ScriptTrigger: Execution of %s in %s failed.\n",functionName.c_str(), script->getFileName().c_str());
      
-     actionFinished = script->getReturnedBool();
+     scriptFinished = script->getReturnedBool();
      }
      
Index: trunk/src/world_entities/script_trigger.h
===================================================================
--- trunk/src/world_entities/script_trigger.h	(revision 8846)
+++ trunk/src/world_entities/script_trigger.h	(revision 8894)
@@ -35,5 +35,4 @@
     void setTarget(WorldEntity* target) { if(target!=NULL) this->target=target; }
     void setTriggerParent(const std::string& name);
-    void setCallOnce(const bool call) { this->callOnce = call; }
     void setTriggerLasts(const bool lasts) { this->triggerLasts = lasts; }
     void setInvert(const bool inv) { this->invert = invert; }
@@ -51,5 +50,4 @@
 
     WorldEntity* target;
-    bool         callOnce;
     bool         triggerLasts;
     bool         invert;
@@ -63,5 +61,5 @@
     bool         scriptCalled;
     bool         scriptIsOk;
-    bool         actionFinished;
+    bool         scriptFinished;
     int          returnCount;        //TODO: set return count correctly
 
Index: trunk/src/world_entities/weapons/fps_sniper_rifle.cc
===================================================================
--- trunk/src/world_entities/weapons/fps_sniper_rifle.cc	(revision 8894)
+++ trunk/src/world_entities/weapons/fps_sniper_rifle.cc	(revision 8894)
@@ -0,0 +1,150 @@
+
+
+/*
+   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:
+
+
+   @todo: direction in which the projectile flights
+   @todo: a target to set/hit
+*/
+#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_WEAPON
+
+#include "world_entities/projectiles/projectile.h"
+
+#include "world_entity.h"
+#include "static_model.h"
+#include "weapon_manager.h"
+#include "util/loading/factory.h"
+
+
+#include "fast_factory.h"
+
+#include "fps_sniper_rifle.h"
+
+
+using namespace std;
+
+
+CREATE_FACTORY(FPSSniperRifle, CL_FPS_SNIPER_RIFLE);
+
+/**
+ *  standard constructor
+
+   creates a new weapon
+*/
+FPSSniperRifle::FPSSniperRifle ( int leftRight)
+  : Weapon()
+{
+  this->init();
+
+  this->leftRight = leftRight;
+}
+
+
+FPSSniperRifle::FPSSniperRifle(const TiXmlElement* root)
+{
+  this->init();
+
+  if (root != NULL)
+    this->loadParams(root);
+}
+
+/**
+ *  standard deconstructor
+*/
+FPSSniperRifle::~FPSSniperRifle ()
+{
+  // model will be deleted from WorldEntity-destructor
+}
+
+
+void FPSSniperRifle::init()
+{
+  this->setClassID(CL_FPS_SNIPER_RIFLE, "FPSSniperRifle");
+
+  this->loadModel("models/guns/fps_sniper_rifle.obj", 0.1);
+
+  this->setStateDuration(WS_SHOOTING, .1);
+  this->setStateDuration(WS_RELOADING, .1);
+  this->setStateDuration(WS_ACTIVATING, .4);
+  this->setStateDuration(WS_DEACTIVATING, .4);
+
+  this->setEnergyMax(100000);
+  this->increaseEnergy(100000);
+  //this->minCharge = 2;
+
+  this->setActionSound(WA_SHOOT, "sound/laser.wav");
+  this->setActionSound(WA_ACTIVATE, "sound/voices/lasers.wav");
+
+
+  this->setCapability(WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);
+  this->setProjectileType(CL_LASER);
+  this->prepareProjectiles(20);
+
+}
+
+
+void FPSSniperRifle::loadParams(const TiXmlElement* root)
+{
+  Weapon::loadParams(root);
+
+}
+
+
+/**
+ *  this activates the weapon
+
+   This is needed, since there can be more than one weapon on a ship. the
+   activation can be connected with an animation. for example the weapon is
+   been armed out.
+*/
+void FPSSniperRifle::activate()
+{
+}
+
+
+/**
+ *  this deactivates the weapon
+
+   This is needed, since there can be more than one weapon on a ship. the
+   activation can be connected with an animation. for example the weapon is
+   been armed out.
+*/
+void FPSSniperRifle::deactivate()
+{
+}
+
+
+/**
+ *  fires the weapon
+
+   this is called from the player.cc, when fire-button is been pushed
+   @todo: the ObjectManager deliveres Projectiles not TestBullets! this should be diffrent
+*/
+void FPSSniperRifle::fire()
+{
+  Projectile* pj =  this->getProjectile();
+  if (pj == NULL)
+    return;
+
+  pj->setParent(PNode::getNullParent());
+
+  pj->setVelocity(this->getAbsDir().apply(Vector(1,0,0))*250 + VECTOR_RAND(5));
+
+  pj->setAbsCoor(this->getEmissionPoint());
+  pj->setAbsDir(this->getAbsDir());
+  pj->activate();
+}
+
+
Index: trunk/src/world_entities/weapons/fps_sniper_rifle.h
===================================================================
--- trunk/src/world_entities/weapons/fps_sniper_rifle.h	(revision 8894)
+++ trunk/src/world_entities/weapons/fps_sniper_rifle.h	(revision 8894)
@@ -0,0 +1,57 @@
+/*!
+    @file weapon.h
+  *  a weapon that a player can use
+
+    A Player has a list of weapons, that can be choosen to shoot projectiles
+    (projectiles.{cc,h}) at enemies. These weapons can be shooted sequentially
+    or (if able) combined. Therefore you can choose the weapon mode = choose
+    a weapon.
+
+    A weapon is characterized by:
+     o firing-rate: the initial firing rate of a weapon (1/s = Herz)
+     o slowdown-factor: this is a factor d: exp(-d*x), d is element of all positive R. it determines how fast the firing-rate will slow down. if no slowdown: d=0, the bigger d is, the faster the weapon will slow down!
+     o energy-consumption: this determines the energy that has to be used to produce this projectile = costs per projectile
+
+    Furthermore there are some other attributes, that will help to represent a firing
+    weapon in this world:
+     o sound file/ressource: this is a pointer to the sound-file/ressource. however it may be represented
+     o shooting animation
+
+*/
+
+
+#ifndef _FPS_SNIPER_RIFLE_H
+#define _FPS_SNIPER_RIFLE_H
+
+#include "weapon.h"
+
+
+//! a weapon can be left or right sided
+/**
+ * @todo this will be reset with mirror X/Y/Z
+ */
+#define    W_LEFT        0
+#define    W_RIGHT       1
+
+
+class FPSSniperRifle : public Weapon
+  {
+  public:
+    FPSSniperRifle (int leftRight);
+    FPSSniperRifle (const TiXmlElement* root);
+    virtual ~FPSSniperRifle ();
+
+    void init();
+    virtual void loadParams(const TiXmlElement* root);
+
+    virtual void activate();
+    virtual void deactivate();
+
+    virtual void fire();
+
+
+  private:
+    int leftRight;   // this will become an enum
+
+  };
+#endif /* _FPS_SNIPER_RIFLE_H */
Index: trunk/src/world_entities/world_entity.cc
===================================================================
--- trunk/src/world_entities/world_entity.cc	(revision 8846)
+++ trunk/src/world_entities/world_entity.cc	(revision 8894)
@@ -193,5 +193,5 @@
         PRINTF(1)("OBJ-File %s not found.\n", fileName.c_str());
 
-      if( modelNumber == 0)
+      if( modelNumber == 0 && !this->isA(CL_WEAPON))
         this->buildObbTree(obbTreeDepth);
     }
@@ -418,5 +418,5 @@
   CollisionEvent* c = CREngine::getInstance()->popCollisionEventObject();
   assert(c != NULL); // if this should fail: we got not enough precached CollisionEvents: alter value in cr_defs.h
-  c->collide(entityA, entityB, bvA, bvB);
+  c->collide(COLLISION_TYPE_OBB, entityA, entityB, bvA, bvB);
 
   for( int i = 0; i < CREngine::CR_NUMBER; ++i)
@@ -433,5 +433,5 @@
  *  @param position it collides on the plane
  */
-bool WorldEntity::registerCollision(WorldEntity* entity, WorldEntity* groundEntity, Vector normal, Vector position)
+bool WorldEntity::registerCollision(int type, WorldEntity* entity, WorldEntity* groundEntity, Vector normal, Vector position, bool bInWall)
 {
   // is there any handler listening?
@@ -442,5 +442,5 @@
   CollisionEvent* c = CREngine::getInstance()->popCollisionEventObject();
   assert(c != NULL); // if this should fail: we got not enough precached CollisionEvents: alter value in cr_defs.h
-  c->collide(entity, groundEntity, normal, position);
+  c->collide(type, entity, groundEntity, normal, position, bInWall);
 
   for( int i = 0; i < CREngine::CR_NUMBER; ++i)
Index: trunk/src/world_entities/world_entity.h
===================================================================
--- trunk/src/world_entities/world_entity.h	(revision 8846)
+++ trunk/src/world_entities/world_entity.h	(revision 8894)
@@ -88,5 +88,5 @@
 
   bool registerCollision(WorldEntity* entityA, WorldEntity* entityB, BoundingVolume* bvA, BoundingVolume* bvB);
-  bool registerCollision(WorldEntity* entity, WorldEntity* groundEntity, Vector normal, Vector position);
+  bool registerCollision(int type, WorldEntity* entity, WorldEntity* groundEntity, Vector normal, Vector position, bool bInWall = false);
   /** @return true if there is at least on collision reaction subscribed */
   inline bool isReactive() const { return this->bReactive; }
@@ -115,4 +115,8 @@
   /** @returns a Reference to the Iterator */
   ObjectManager::EntityList::iterator& getEntityIterator() { return this->objectListIterator; }
+
+  void hide() { if( this->objectListNumber != OM_DEAD) this->lastObjectListNumber = this->objectListNumber; this->toList(OM_DEAD); }
+  void unhide() { this->toList(this->lastObjectListNumber); }
+
 
   /* --- Character Attribute Block --- */
@@ -176,4 +180,5 @@
   OM_LIST                 objectListNumber;                //!< The ObjectList from ObjectManager this Entity is in.
   ObjectManager::EntityList::iterator objectListIterator;  //!< The iterator position of this Entity in the given list of the ObjectManager.
+  OM_LIST                 lastObjectListNumber;            //!< the last ObjectList from the ObjectManager this Entity was is in
 
 
