Index: trunk/src/lib/script_engine/script.cc
===================================================================
--- trunk/src/lib/script_engine/script.cc	(revision 9246)
+++ trunk/src/lib/script_engine/script.cc	(revision 9298)
@@ -17,5 +17,5 @@
 #include "script_class.h"
 #include "luaincl.h"
-
+#include "debug.h"
 #include "util/loading/resource_manager.h"
 
@@ -50,4 +50,23 @@
 
 
+Script::Script(const std::string& filename)
+{
+  this->setClassID(CL_SCRIPT, "Script");
+
+  returnCount = argumentCount = 0;
+
+  luaState = lua_open();
+
+  luaopen_base(luaState);
+  luaopen_table(luaState);
+  luaopen_io(luaState);
+  luaopen_string(luaState);
+  luaopen_math(luaState);
+  luaopen_debug(luaState);
+  
+  this->loadFile(filename);
+
+}
+
 Script::~Script()
 {
@@ -59,13 +78,13 @@
 void Script::loadParams(const TiXmlElement* root)
 {
-  //printf("Loading params for %p \n",this);
+  //printf(("Loading params for %p \n",this);
   BaseObject::loadParams(root);
 
-  LOAD_PARAM_START_CYCLE(root, object);
+ LOAD_PARAM_START_CYCLE(root, object);
   {
     LoadParam_CYCLE(object, "object", this, Script, addObject)
-        .describe("The name of an object that is needed by a script");
+       .describe("The name of an object that is needed by a script");
   }
-  LOAD_PARAM_END_CYCLE(object);
+ LOAD_PARAM_END_CYCLE(object);
 
 
@@ -87,5 +106,5 @@
    if(currentFile.length() != 0)
    {
-     printf("Could not load %s because an other file is already loaded: %s\n",filename.c_str(), currentFile.c_str());
+     printf("SCRIPT %s : ERROR: Could not load %s because an other file is already loaded: %s\n",currentFile.c_str(),filename.c_str(), currentFile.c_str());
      return false;
     }
@@ -104,5 +123,5 @@
      else
      {
-       printf("ERROR while loading file %s: \n",filename.c_str());
+       printf("SCRIPT %s : ERROR: while loading file %s: \n",currentFile.c_str(),filename.c_str());
        reportError(error);
      }
@@ -111,5 +130,5 @@
    else
    {
-     printf("ERROR while loading file %s: \n",filename.c_str());
+     printf("SCRIPT %s : ERROR: while loading file %s: \n",currentFile.c_str(),filename.c_str());
      reportError(error);
    }
@@ -121,8 +140,8 @@
  void Script::addObject(const std::string& className, const std::string& objectName)
  {
-   //printf("Script %s: I am about to add %s of class %s\n",this->getName(),objectName.c_str(),className.c_str());
+   //printf(("Script %s: I am about to add %s of class %s\n",this->getName(),objectName.c_str(),className.c_str());
 
    BaseObject* scriptClass = ClassList::getObject(className, CL_SCRIPT_CLASS);
-  // printf("The script class for %s is at %p \n",className.c_str(),scriptClass);
+  // printf(("The script class for %s is at %p \n",className.c_str(),scriptClass);
    WorldObject tmpObj;
    if (scriptClass != NULL)
@@ -135,5 +154,5 @@
 
      BaseObject* object = ClassList::getObject(objectName, className);
-    // printf("%s is at %p \n",objectName.c_str(),object);
+    // printf(("%s is at %p \n",objectName.c_str(),object);
      if (object != NULL && !objectIsAdded(objectName))
      {
@@ -150,5 +169,5 @@
  bool Script::executeFile()
  {
-   printf("WARNING: script.executeFile is not implemented yet");
+   PRINT(2)("WARNING: script.executeFile is not implemented yet\n");
    /*if(currentFile.length() != 0)
    {
@@ -183,5 +202,5 @@
    }
    else
-     printf("There is an other function active ( %s ) or there are unremoved return values on the stack. Please remove them first.\n",currentFunction.c_str());
+     printf("SCRIPT %s : ERROR: There is an other function active ( %s ) or there are unremoved return values on the stack. Please remove them first.\n",currentFile.c_str(),currentFunction.c_str());
    return false;
  }
@@ -195,5 +214,5 @@
     if(error != 0)
     {
-     printf("ERROR while executing function %s: \n",currentFunction.c_str());
+      printf("SCRIPT %s : ERROR: Failed to execute function %s: \n",currentFile.c_str(),currentFunction.c_str());
      reportError(error);
      //clean up
@@ -210,5 +229,5 @@
    }
    else
-     printf("Error: no function selected.\n");
+     printf("SCRIPT %s : ERROR: no function selected.\n",currentFile.c_str());
 
    return false;
@@ -227,5 +246,5 @@
    else
    {
-    printf("Couldn't add parameter because the wrong function is selected: %s instead of %s\n", currentFunction.c_str(), toFunction.c_str());
+     printf("SCRIPT %s : ERROR: Couldn't add parameter because the wrong function is selected: %s instead of %s\n",currentFile.c_str(), currentFunction.c_str(), toFunction.c_str());
     return false;
    }
@@ -244,5 +263,5 @@
    else
    {
-     printf("Couldn't add parameter because the wrong function is selected: %s instead of %s\n", currentFunction.c_str(), toFunction.c_str());
+     printf("SCRIPT %s : ERROR: Couldn't add parameter because the wrong function is selected: %s instead of %s\n",currentFile.c_str(), currentFunction.c_str(), toFunction.c_str());
      return false;
    }
@@ -260,5 +279,5 @@
    else
    {
-     printf("Couldn't add parameter because the wrong function is selected: %s instead of %s\n", currentFunction.c_str(), toFunction.c_str());
+     printf("SCRIPT %s : ERROR: Couldn't add parameter because the wrong function is selected: %s instead of %s\n",currentFile.c_str(), currentFunction.c_str(), toFunction.c_str());
      return false;
    }
@@ -295,5 +314,5 @@
      }
      else
-       printf("ERROR: Form %s : trying to retreive non bolean value",this->currentFile.c_str());
+       printf("SCRIPT %s : ERROR: Trying to retreive non bolean value\n",this->currentFile.c_str());
    }
    return returnValue;
@@ -346,6 +365,6 @@
  {
   const char *msg = lua_tostring(luaState, -1);
-  if (msg == NULL) msg = "(error with no message)";
-  fprintf(stderr, "ERROR: %s\n", msg);
+  if (msg == NULL) msg = "(error with no message)\n";
+  printf("ERROR: %s\n", msg);
   lua_pop(luaState, 1);
  }
@@ -368,5 +387,5 @@
  {
    BaseObject* scriptClass = ClassList::getObject(className, CL_SCRIPT_CLASS);
-   //printf("The script class for %s is at %p \n",className.c_str(),scriptClass);
+   //printf(("The script class for %s is at %p \n",className.c_str(),scriptClass);
    WorldObject tmpObj;
    if (scriptClass != NULL)
Index: trunk/src/lib/script_engine/script.h
===================================================================
--- trunk/src/lib/script_engine/script.h	(revision 9246)
+++ trunk/src/lib/script_engine/script.h	(revision 9298)
@@ -24,4 +24,5 @@
   public:
     Script(const TiXmlElement* root = NULL);
+    Script(const std::string& filename);
     ~Script();
 
Index: trunk/src/world_entities/npcs/gate.cc
===================================================================
--- trunk/src/world_entities/npcs/gate.cc	(revision 9246)
+++ trunk/src/world_entities/npcs/gate.cc	(revision 9298)
@@ -13,5 +13,5 @@
    ### File Specific
    main-programmer: Patrick Boenzli
-   co-programmer:
+   co-programmer: Silvan Nellen
 */
 #define DEBUG_SPECIAL_MODULE DEBUG_MODULE_WORLD_ENTITY
@@ -41,5 +41,5 @@
                             addMethod("hide", ExecutorLua0<WorldEntity>(&WorldEntity::hide))
                             ->addMethod("unhide", ExecutorLua0<WorldEntity>(&WorldEntity::unhide))
-                           // ->addMethod("destroy", ExecutorLua0<Gate>(&Gate::destroy()))    
+                            ->addMethod("destroy", ExecutorLua0<Gate>(&Gate::destroy))    
                             ->addMethod("setAbsCoor", ExecutorLua3<PNode,float,float,float>(&PNode::setAbsCoor))
                             ->addMethod("getAbsCoorX", ExecutorLua0ret<PNode, float>(&PNode::getAbsCoorX))
@@ -66,4 +66,5 @@
   this->scale = 1.0f;
   this->actionRadius = 1.0;
+  this->destroyed = false;
 
   if( root != NULL)
@@ -151,5 +152,5 @@
 void Gate::open()
 {
-  if( this->bLocked)
+  if( this->bLocked || this->destroyed)
     return;
 
@@ -164,4 +165,8 @@
 void Gate::close()
 {
+  
+  if( this->destroyed)
+    return;
+  
   this->setAnimation(GATE_CLOSE, MD2_ANIM_ONCE);
   this->bOpen = false;
@@ -171,7 +176,13 @@
 void Gate::destroy()
 {
+  if( this->destroyed)
+    return;
+  
   this->setAnimation(GATE_DIE, MD2_ANIM_ONCE);
 
-  Explosion::explode(this, Vector(10,10,10));
+  Explosion::explode(this, Vector(this->getScaling()/160,this->getScaling()/160,this->getScaling()/160));
+  
+  
+  this->destroyed = true;
 }
 
Index: trunk/src/world_entities/npcs/gate.h
===================================================================
--- trunk/src/world_entities/npcs/gate.h	(revision 9246)
+++ trunk/src/world_entities/npcs/gate.h	(revision 9298)
@@ -50,4 +50,5 @@
 
   private:
+    bool           destroyed;         //!< true if the door is destroyed
     bool           bOpen;             //!< true if the door is open
     bool           bLocked;           //!< true if this door is locked
Index: trunk/src/world_entities/projectiles/guided_missile.cc
===================================================================
--- trunk/src/world_entities/projectiles/guided_missile.cc	(revision 9246)
+++ trunk/src/world_entities/projectiles/guided_missile.cc	(revision 9298)
@@ -43,5 +43,5 @@
   this->lifeSpan = 4.0;
   this->agility = 3.5;
-  this->maxVelocity = 75;
+  this->maxVelocity = 100;
 
   this->emitter = new DotEmitter(100, 5, M_2_PI);
Index: trunk/src/world_entities/script_trigger.cc
===================================================================
--- trunk/src/world_entities/script_trigger.cc	(revision 9246)
+++ trunk/src/world_entities/script_trigger.cc	(revision 9298)
@@ -32,5 +32,6 @@
              ->addMethod("setTarget", ExecutorLua1<ScriptTrigger, const std::string&>(&ScriptTrigger::setTarget))
              ->addMethod("setTriggerParent", ExecutorLua1<ScriptTrigger, const std::string&>(&ScriptTrigger::setTriggerParent))
-             ->addMethod("setTriggerLasts", ExecutorLua1<ScriptTrigger, bool>(&ScriptTrigger::setTriggerLasts))
+             ->addMethod("setTriggerRemains", ExecutorLua1<ScriptTrigger, bool>(&ScriptTrigger::setTriggerRemains))
+             ->addMethod("setActiveOnCreation", ExecutorLua1<ScriptTrigger, bool>(&ScriptTrigger::setActiveOnCreation))
              ->addMethod("setInvert", ExecutorLua1<ScriptTrigger, bool>(&ScriptTrigger::setInvert))
              ->addMethod("setRadius", ExecutorLua1<ScriptTrigger, float>(&ScriptTrigger::setRadius))
@@ -48,5 +49,5 @@
  */
 ScriptTrigger::ScriptTrigger(const TiXmlElement* root)
-{
+{ PRINT(1)("testerror\n");
   this->setClassID(CL_SCRIPT_TRIGGER, "ScriptTrigger");
   this->toList(OM_COMMON);
@@ -59,6 +60,7 @@
   scriptCalled = false;
   scriptIsOk = false;
-  triggerLasts = true;
+  triggerRemains = true;
   addToScript = false;
+  this->activeOnCreation = false;
   
   if(root != NULL)
@@ -119,5 +121,5 @@
       .describe("")
       .defaultValues(false);
-  LoadParam(root, "triggerlasts", this, ScriptTrigger, setTriggerLasts)
+  LoadParam(root, "triggerRemains", this, ScriptTrigger, setTriggerRemains)
       .describe("")
       .defaultValues(true);
@@ -172,5 +174,11 @@
   if(scriptFinished) return;
 
-  if(triggerLasts && scriptCalled)
+  if(activeOnCreation)
+   {
+     executeAction(timestep);
+     return;
+   }
+   
+  if(triggerRemains && scriptCalled)
   {
     executeAction(timestep);
@@ -182,4 +190,5 @@
     executeAction(timestep);
     scriptCalled = true;
+    return;
   
   }
@@ -188,4 +197,5 @@
     executeAction(timestep); 
     scriptCalled = true;
+    return;
   }
  //else
@@ -202,10 +212,10 @@
        //testScriptingFramework();
     if(!(script->selectFunction(this->functionName,returnCount)) )
-      printf("Error ScriptTrigger: Selection of %s in %s failed.\n",functionName.c_str(), script->getFileName().c_str());
+      PRINT(1)("Error ScriptTrigger: Selection of %s in %s failed.\n",functionName.c_str(), script->getFileName().c_str());
      
     script->pushParam( timestep, this->functionName);
      
     if( !(script->executeFunction()) )
-      printf("Error ScriptTrigger: Execution of %s in %s failed.\n",functionName.c_str(), script->getFileName().c_str());
+      PRINT(1)("Error ScriptTrigger: Execution of %s in %s failed.\n",functionName.c_str(), script->getFileName().c_str());
      
     scriptFinished = script->getReturnedBool();
Index: trunk/src/world_entities/script_trigger.h
===================================================================
--- trunk/src/world_entities/script_trigger.h	(revision 9246)
+++ trunk/src/world_entities/script_trigger.h	(revision 9298)
@@ -35,5 +35,6 @@
     void setTarget(WorldEntity* target) { if(target!=NULL) this->target=target; }
     void setTriggerParent(const std::string& name);
-    void setTriggerLasts(const bool lasts) { this->triggerLasts = lasts; }
+    void setTriggerRemains(const bool lasts) { this->triggerRemains = lasts; }
+    void setActiveOnCreation(const bool avtive) { this->activeOnCreation = avtive; }
     void setInvert(const bool inv) { this->invert = invert; }
     void setDelay(float delay) { this->delay = delay; };
@@ -50,5 +51,6 @@
 
     WorldEntity* target;
-    bool         triggerLasts;
+    bool         triggerRemains;
+    bool         activeOnCreation;
     bool         invert;
     float        radius;
Index: trunk/src/world_entities/space_ships/spacecraft_2d.cc
===================================================================
--- trunk/src/world_entities/space_ships/spacecraft_2d.cc	(revision 9246)
+++ trunk/src/world_entities/space_ships/spacecraft_2d.cc	(revision 9298)
@@ -498,5 +498,5 @@
     this->bForward = event.bPressed; //this->shiftCoor(0,.1,0);
   else if( event.type == KeyMapper::PEV_BACKWARD)
-    this->bBackward = event.bPressed; //this->shiftCoor(0,-.1,0);
+  {this->bBackward = event.bPressed; printf(" %f, %f, %f \n",getAbsCoorX(),getAbsCoorY(),getAbsCoorZ());} //this->shiftCoor(0,-.1,0);
   else if( event.type == EV_MOUSE_MOTION)
   {
Index: trunk/src/world_entities/weapons/aiming_system.cc
===================================================================
--- trunk/src/world_entities/weapons/aiming_system.cc	(revision 9246)
+++ trunk/src/world_entities/weapons/aiming_system.cc	(revision 9298)
@@ -115,5 +115,5 @@
   if( this->owner != killer)
   {
-    PRINTF(0)("real hit: %s\n", killer->getClassName());
+    //PRINTF(0)("real hit: %s\n", killer->getClassName());
     this->selectionList.push_back(killer);
   }
Index: trunk/src/world_entities/world_entity.h
===================================================================
--- trunk/src/world_entities/world_entity.h	(revision 9246)
+++ trunk/src/world_entities/world_entity.h	(revision 9298)
@@ -129,4 +129,6 @@
 
   /* --- Character Attribute Block --- */
+  /** @returns the scaling of the model */
+  float getScaling(){return this->scaling;}
   /** @returns the damage dealt by this world entity */
   float getDamage() const { return this->damage; }
