Index: code/branches/modularships/src/orxonox/items/PartDestructionEvent.cc
===================================================================
--- code/branches/modularships/src/orxonox/items/PartDestructionEvent.cc	(revision 10054)
+++ code/branches/modularships/src/orxonox/items/PartDestructionEvent.cc	(revision 10055)
@@ -38,5 +38,7 @@
 #include "worldentities/pawns/Pawn.h"
 #include "worldentities/pawns/ModularSpaceShip.h"
+#include "items/Engine.h"
 #include "gametypes/Gametype.h"
+#include "chat/ChatManager.h"
 
 
@@ -63,7 +65,8 @@
         XMLPortParam(PartDestructionEvent, "targetType", setTargetType, getTargetType, xmlelement, mode).defaultValues("NULL");
         XMLPortParam(PartDestructionEvent, "targetName", setTargetName, getTargetName, xmlelement, mode).defaultValues("NULL");
+        XMLPortParam(PartDestructionEvent, "operation", setOperation, getOperation, xmlelement, mode).defaultValues("NULL");
         XMLPortParam(PartDestructionEvent, "targetParam", setTargetParam, getTargetParam, xmlelement, mode).defaultValues("NULL");
-        XMLPortParam(PartDestructionEvent, "operation", setOperation, getOperation, xmlelement, mode).defaultValues("NULL");
         XMLPortParam(PartDestructionEvent, "value", setEventValue, getEventValue, xmlelement, mode).defaultValues(0);
+        XMLPortParam(PartDestructionEvent, "message", setMessage, getMessage, xmlelement, mode).defaultValues("NULL");
 
         /*
@@ -74,6 +77,12 @@
     }
 
+    /**
+    @brief
+        Executes this event.
+    */
     void PartDestructionEvent::execute()
     {
+        orxout() << "Executing PartDestructionEvent " << this->getName() << endl;
+
         // Do not execute if this event is invalid
         if(!isValid())
@@ -83,4 +92,9 @@
         }
 
+        // Output the destruction-message to the chat
+        if(this->message_ != "NULL")
+            ChatManager::message(this->message_);
+
+        // Modify parameters as configured for all cases
         if (this->targetType_ == "ship")
         {
@@ -89,4 +103,10 @@
                 this->parent_->getParent()->setShieldHealth(operate(this->parent_->getParent()->getShieldHealth()));
                 break;
+            case boostpower:
+                this->parent_->getParent()->setInitialBoostPower(operate(this->parent_->getParent()->getInitialBoostPower()));
+                break;
+            case boostpowerrate:
+                this->parent_->getParent()->setBoostPowerRate(operate(this->parent_->getParent()->getBoostPowerRate()));
+                break;
             default:
                 break;
@@ -95,4 +115,33 @@
             return;
         }
+
+        if (this->targetType_ == "engine")
+        {
+            switch (this->targetParam_) {
+            case null:
+                for(unsigned int i = 0; i < this->parent_->getParent()->getEngineList().size(); i++) // FIXME: (noep) segfault on .size()
+                {
+                    if(this->parent_->getParent()->getEngine(i)->getName() == this->targetName_)
+                    {
+                        orxout() << "engine found" << endl;
+                        this->parent_->getParent()->removeEngine(this->parent_->getParent()->getEngine(i));
+                        break;
+                    }
+                }
+                break;
+            case boostfactor:
+                for(unsigned int i = 0; i < this->parent_->getParent()->getEngineList().size(); i++)
+                {
+                    if(this->parent_->getParent()->getEngine(i)->getName() == this->targetName_)
+                        this->parent_->getParent()->getEngine(i)->setBoostFactor(operate(this->parent_->getParent()->getEngine(i)->getBoostFactor()));
+                    break;
+                }
+                break;
+            default:
+                break;
+            }
+            this->setValid(false);
+            return;
+        }
     }
 
@@ -102,7 +151,12 @@
     }
 
+    /**
+    @brief
+        Set type of the target
+    @param param
+        The desired target-type as string. Valid target-types: ship engine weapon
+    */
     void PartDestructionEvent::setTargetType(std::string type)
     {
-        // ship engine weapon
         if ((type == "ship") || (type == "engine") || (type == "weapon"))
         {
@@ -129,6 +183,13 @@
     }
 
+    /**
+    @brief
+        Set the operation to be applied.
+    @param param
+        The desired parameter as string. Valid parameters: c.f. @ref orxnox::PartDestructionEvent::TargetParam
+    */
     void PartDestructionEvent::setTargetParam(std::string param)
     {
+        // A target-type needs to be defined in order to choose a parameter.
         if (this->targetType_ == "NULL")
         {
@@ -138,10 +199,35 @@
         }
 
-        // ship: shieldhealth maxshieldhealth shieldabsorption shieldrechargerate
-
-        // engine:
+        // engine: NULL boostfactor speedfront accelerationfront
+        if (this->targetType_ == "engine")
+        {
+            if (param == "NULL")
+            {
+                this->targetParam_ = null;
+                return;
+            }
+            if (param == "boostfactor")
+            {
+                this->targetParam_ = boostfactor;
+                return;
+            }
+            if (param == "speedfront")
+            {
+                this->targetParam_ = speedfront;
+                return;
+            }
+            if (param == "accelerationfront")
+            {
+                this->targetParam_ = accelerationfront;
+                return;
+            }
+
+            orxout(internal_warning) << "\"" << param << "\" is not a valid target-param for a PartDestructionEvent with target-type \"engine\". Valid types are: boostfactor speedfront accelerationfront" << endl;
+            return;
+        }
 
         // weapon:
 
+        // ship: shieldhealth (maxshieldhealth shieldabsorption shieldrechargerate) boostpower boostpowerrate
         if (this->targetType_ == "ship")
         {
@@ -151,6 +237,16 @@
                 return;
             }
-
-            orxout(internal_warning) << "\"" << param << "\" is not a valid target-param for a PartDestructionEvent with target-type \"ship\". Valid types are: shieldhealth maxshieldhealth shieldabsorption shieldrechargerate" << endl;
+            if (param == "boostpower")
+            {
+                this->targetParam_ = boostpower;
+                return;
+            }
+            if (param == "boostpowerrate")
+            {
+                this->targetParam_ = boostpowerrate;
+                return;
+            }
+
+            orxout(internal_warning) << "\"" << param << "\" is not a valid target-param for a PartDestructionEvent with target-type \"ship\". Valid types are: shieldhealth maxshieldhealth shieldabsorption shieldrechargerate boostpower boostpowerrate" << endl;
             return;
         }
@@ -160,4 +256,10 @@
     }
 
+    /**
+    @brief
+        Set the operation to be applied.
+    @param operation
+        The desired operator as string. Valid operators: * + - destroy
+    */
     void PartDestructionEvent::setOperation(std::string operation)
     {
@@ -172,4 +274,24 @@
     }
 
+    /**
+    @brief
+        Set the message to be shown upon execution of the vent.
+    @param msg
+        The desired message as string.
+    */
+    void PartDestructionEvent::setMessage(std::string msg)
+    {
+        this->message_ = msg;
+    }
+
+
+    /**
+    @brief
+        Apply the configured operation and value to an input.
+    @param input
+        The value which should be modified
+    @return
+        Returns the product / sum / difference of input and configured value, or 0 if the operation is "destroy"
+    */
     float PartDestructionEvent::operate(float input)
     {
@@ -187,4 +309,10 @@
     }
 
+    /**
+    @brief
+        Sets the value applied with the chosen operation.
+    @param value
+        The value as float.
+    */
     void PartDestructionEvent::setEventValue(float value)
     {
Index: code/branches/modularships/src/orxonox/items/PartDestructionEvent.h
===================================================================
--- code/branches/modularships/src/orxonox/items/PartDestructionEvent.h	(revision 10054)
+++ code/branches/modularships/src/orxonox/items/PartDestructionEvent.h	(revision 10055)
@@ -38,4 +38,38 @@
 namespace orxonox // tolua_export
 { // tolua_export
+    /**
+        @brief
+            In order to assign attached entities to a ShipPart, a ShipPart with the same name as the corresponding entity needs to be created in the <parts> tag.
+            Here is a (primitive) example of a ModularSpaceShip with ShipParts and PartDestructionEvents defined in XML:
+            @code
+            <ModularSpaceShip
+                ...
+                >
+                    <attached>
+                        <StaticEntity name="generator"  . . .  />
+                        <StaticEntity name="tail" . . . />
+                    </attached>
+                    <parts>
+                        <ShipPart name="generator" . . . >
+                            <destructionevents>
+                                <PartDestructionEvent targetType="ship" targetParam="boostpowerrate" operation="-" value="0.5" message="Your boost-regeneration is reduced!" />
+                            </destructionevents>
+                        </ShipPart>
+                        <ShipPart name="tail" . . . >
+                            <destructionevents>
+                                <PartDestructionEvent ... />
+                            </destructionevents>
+                        </ShipPart>
+                    </parts>
+                    <engines>
+                        <Engine />
+                        <Engine />
+                    </engines>
+                </ModularSpaceShip>
+            @endcode
+
+        @author
+            Fabian 'x3n' Landau, Noe Pedrazzini
+        */
     class _OrxonoxExport PartDestructionEvent // tolua_export
         : public Item
@@ -44,4 +78,8 @@
         public:
 
+            /**
+                @brief
+                    List of all allowed parameters.
+                */
             enum TargetParam
             {
@@ -50,4 +88,9 @@
                 shieldabsorption,
                 shieldrechargerate,
+                boostpower,         // Amount of available boost
+                boostpowerrate,     // Recharge-rate of boost
+                boostfactor,
+                speedfront,
+                accelerationfront,
                 null
             };
@@ -85,4 +128,8 @@
                 { return this->operation_; }
 
+            void setMessage(std::string msg);
+            inline std::string getMessage()
+                { return this->message_; }
+
             float operate(float input);
 
@@ -95,13 +142,14 @@
         private:
 
-            ShipPart* parent_;
-            bool valid_;
+            ShipPart* parent_;          //!< Pointer to the ShipPart this event belongs to
+            bool valid_;                //!< Whether this event is valid or not.
 
-            std::string targetType_;
-            std::string targetName_;
-            TargetParam targetParam_;
-            std::string operation_;
+            std::string targetType_;    //!< The type of the target. (ship weapon engine)
+            std::string targetName_;    //!< The name of the target.
+            TargetParam targetParam_;   //!< The parameter to be modified
+            std::string operation_;     //!< The operation to be applied
+            float value_;               //!< The value used to do the operation
+            std::string message_;       //!< The message which is shown in chat when the event is executed.
 
-            float value_;
 
 
Index: code/branches/modularships/src/orxonox/items/ShipPart.cc
===================================================================
--- code/branches/modularships/src/orxonox/items/ShipPart.cc	(revision 10054)
+++ code/branches/modularships/src/orxonox/items/ShipPart.cc	(revision 10055)
@@ -90,4 +90,10 @@
     }
 
+    /**
+    @brief
+        Is called when the ShipPart dies.
+        Executes PartDestructionEvents.
+        Tells the ModularSpaceShip to remove this ShipPart.
+    */
     void ShipPart::death()
     {
Index: code/branches/modularships/src/orxonox/items/ShipPart.h
===================================================================
--- code/branches/modularships/src/orxonox/items/ShipPart.h	(revision 10054)
+++ code/branches/modularships/src/orxonox/items/ShipPart.h	(revision 10055)
@@ -102,5 +102,5 @@
         protected:
             ModularSpaceShip* parent_;
-            unsigned int parentID_; // Object ID of the SpaceShip the Part is mounted on.
+            unsigned int parentID_;     // Object ID of the SpaceShip the Part is mounted on.
 
             float damageAbsorption_;
@@ -110,5 +110,5 @@
 
         private:
-            std::vector<StaticEntity*> entityList_; // list of all entities which belong to this part
+            std::vector<StaticEntity*> entityList_;         // List of all entities which belong to this part
             std::vector<PartDestructionEvent*> eventList_;  // The list of all PartDestructionEvent assigned to this ShipPart.
 
Index: code/branches/modularships/src/orxonox/worldentities/pawns/ModularSpaceShip.cc
===================================================================
--- code/branches/modularships/src/orxonox/worldentities/pawns/ModularSpaceShip.cc	(revision 10054)
+++ code/branches/modularships/src/orxonox/worldentities/pawns/ModularSpaceShip.cc	(revision 10055)
@@ -37,4 +37,5 @@
 #include "util/Math.h"
 #include "gametypes/Gametype.h"
+#include "core/command/ConsoleCommand.h"
 
 #include "items/ShipPart.h"
@@ -48,6 +49,10 @@
 namespace orxonox
 {
+    SetConsoleCommand("ModularSpaceShip", "killshippart", &ModularSpaceShip::killShipPart);
+
     RegisterClass(ModularSpaceShip);
 
+    std::map<StaticEntity*, ShipPart*>* ModularSpaceShip::partMap_s = 0;
+
     ModularSpaceShip::ModularSpaceShip(Context* context) : SpaceShip(context)
     {
@@ -55,4 +60,6 @@
 
         this->registerVariables();
+
+        ModularSpaceShip::partMap_s = &(this->partMap_);
 
     }
@@ -77,4 +84,8 @@
     }
 
+    /**
+    @brief
+        Searches for ShipParts matching to StaticEntities.
+    */
     void ModularSpaceShip::updatePartAssignment()
     {
@@ -115,4 +126,12 @@
     }
 
+    /**
+    @brief
+        Creates a new assignment for the given StaticEntity and ShipPart in the partMap_
+    @param entity
+        A pointer to the StaticEntity
+    @param part
+        A pointer to the ShipPart.
+    */
     void ModularSpaceShip::addPartEntityAssignment(StaticEntity* entity, ShipPart* part)
     {
@@ -150,69 +169,33 @@
     }
 
-    //FIXME: (noep) finish
-    // void ModularSpaceShip::attach
-
+    /**
+    @brief
+        If the damage occurred on an attached StaticEntity, the damage is given to the corresponding ShipPart to handle.
+    */
     void ModularSpaceShip::damage(float damage, float healthdamage, float shielddamage, Pawn* originator, const btCollisionShape* cs)
     {
-        /*orxout() << "Mdamage(): Collision detected on " << this->getRadarName() << ", btCS*: " << cs << endl;
-        orxout() << "UserPtr of said collisionShape: " << cs->getUserPointer() << endl;
-
-
-            // Print all attached objects & parts
-        /*
-        orxout() << "  " << this->getName() << " has the following Objects attached:" << endl;
-
-        for (int i=0; i<50; i++)
-        {
-            if (this->getAttachedObject(i)==NULL)
-                break;
-            orxout() << " " << i << ": " << this->getAttachedObject(i) << " (" << this->getAttachedObject(i)->getName() << ")";
-            orxout() << endl;
-        }
-
-        orxout() << "  Attached ShipParts:" << endl;
-        for(unsigned int i=0; i < this->partList_.size(); i++)
-        {
-            orxout() << "  " << i << ": " << this->partList_[i] << " (" << this->partList_[i]->getName() << ")" << endl;
-        }*/
-
-
-        //int collisionShapeIndex = this->isMyCollisionShape(cs);
-        //orxout() << collisionShapeIndex << endl;
-
-        //orxout() << "ShipPart of Entity " << cs->getUserPointer() << ": " << this->getPartOfEntity((StaticEntity*)(cs->getUserPointer())) << endl;
-
         if (this->getPartOfEntity((StaticEntity*)(cs->getUserPointer())) != NULL)
             this->getPartOfEntity((StaticEntity*)(cs->getUserPointer()))->handleHit(damage, healthdamage, shielddamage, originator);
         else
             SpaceShip::damage(damage, healthdamage, shielddamage, originator, cs);
-
-        /*
-        // Applies multiplier given by the DamageBoost Pickup.
-        if (originator)
-            damage *= originator->getDamageMultiplier();
-
-        if (this->getGametype() && this->getGametype()->allowPawnDamage(this, originator))
-        {
-            if (shielddamage >= this->getShieldHealth())
-            {
-                this->setShieldHealth(0);
-                this->setHealth(this->health_ - (healthdamage + damage));
-            }
-            else
-            {
-                this->setShieldHealth(this->shieldHealth_ - shielddamage);
-
-                // remove remaining shieldAbsorpton-Part of damage from shield
-                shielddamage = damage * this->shieldAbsorption_;
-                shielddamage = std::min(this->getShieldHealth(),shielddamage);
-                this->setShieldHealth(this->shieldHealth_ - shielddamage);
-
-                // set remaining damage to health
-                this->setHealth(this->health_ - (damage - shielddamage) - healthdamage);
-            }
-
-            this->lastHitOriginator_ = originator;
-        }*/
+    }
+
+    /**
+    @brief
+        Kills the ShipPart with the given name. Used from the console-command "ModularSpaceShip killshippart [string]".
+    @param name
+        The name of the part to be killed.
+    */
+    void ModularSpaceShip::killShipPart(std::string name)
+    {
+        for (std::map<StaticEntity*, ShipPart*>::const_iterator it = ModularSpaceShip::partMap_s->begin(); it != ModularSpaceShip::partMap_s->end(); ++it)
+        {
+            if (it->second->getName() == name)
+            {
+                it->second->death();
+                return;
+            }
+        }
+        orxout(internal_warning) << "Could not apply damage to ShipPart \"" << name << "\". Part not found." << endl;
     }
 
@@ -261,4 +244,11 @@
     }
 
+
+    /**
+    @brief
+        Removes a ShipPart from the SpaceShip, destroying the corresponding StaticEntity
+    @param part
+        The ShipPart to be removed.
+    */
     void ModularSpaceShip::removeShipPart(ShipPart* part)
     {
@@ -309,5 +299,5 @@
         orxout() << "MSS: detach()" << endl;
 
-        this->printBtChildShapes((btCompoundShape*)(this->getWorldEntityCollisionShape()->getCollisionShape()), 2, 0);
+        //this->printBtChildShapes((btCompoundShape*)(this->getWorldEntityCollisionShape()->getCollisionShape()), 2, 0);
         this->detachCollisionShape(object->collisionShape_);  // after succeeding, causes a crash in the collision handling
         //this->printBtChildShapes((btCompoundShape*)(this->getWorldEntityCollisionShape()->getCollisionShape()), 2, 0);
Index: code/branches/modularships/src/orxonox/worldentities/pawns/ModularSpaceShip.h
===================================================================
--- code/branches/modularships/src/orxonox/worldentities/pawns/ModularSpaceShip.h	(revision 10054)
+++ code/branches/modularships/src/orxonox/worldentities/pawns/ModularSpaceShip.h	(revision 10055)
@@ -113,4 +113,6 @@
             virtual void damage(float damage, float healthdamage = 0.0f, float shielddamage = 0.0f, Pawn* originator = NULL, const btCollisionShape* cs = NULL);
 
+            static void killShipPart(std::string name);
+
             void addShipPart(ShipPart* part);
             ShipPart* getShipPart(unsigned int index);
@@ -127,8 +129,7 @@
         private:
             void registerVariables();
-            std::vector<ShipPart*> partList_;  // The list of all Parts mounted on this ModularSpaceShip.
-            std::vector<SmartPtr<StaticEntity>*> entityPtrList_;
-            std::vector<SmartPtr<CollisionShape>*> csPtrList_;
-            std::map<StaticEntity*, ShipPart*> partMap_;
+            std::vector<ShipPart*> partList_;                       // The list of all Parts mounted on this ModularSpaceShip.
+            std::map<StaticEntity*, ShipPart*> partMap_;            // Map of Part-Entity-assignments
+            static std::map<StaticEntity*, ShipPart*>* partMap_s;
         
     };
