Index: code/branches/presentationFS14/src/orxonox/items/CMakeLists.txt
===================================================================
--- code/branches/presentationFS14/src/orxonox/items/CMakeLists.txt	(revision 10069)
+++ code/branches/presentationFS14/src/orxonox/items/CMakeLists.txt	(revision 10073)
@@ -3,3 +3,5 @@
   Engine.cc
   MultiStateEngine.cc
+  ShipPart.cc
+  PartDestructionEvent.cc
 )
Index: code/branches/presentationFS14/src/orxonox/items/PartDestructionEvent.cc
===================================================================
--- code/branches/presentationFS14/src/orxonox/items/PartDestructionEvent.cc	(revision 10073)
+++ code/branches/presentationFS14/src/orxonox/items/PartDestructionEvent.cc	(revision 10073)
@@ -0,0 +1,352 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   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
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Noe Pedrazzini
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "PartDestructionEvent.h"
+
+#include <algorithm>
+
+#include "core/CoreIncludes.h"
+#include "core/GameMode.h"
+#include "core/XMLPort.h"
+#include "network/NetworkFunction.h"
+#include "Item.h"
+#include "worldentities/pawns/Pawn.h"
+#include "worldentities/pawns/ModularSpaceShip.h"
+#include "items/Engine.h"
+#include "gametypes/Gametype.h"
+#include "chat/ChatManager.h"
+
+
+namespace orxonox
+{
+    RegisterClass(PartDestructionEvent);
+
+    PartDestructionEvent::PartDestructionEvent(Context* context)
+        : Item(context)
+    {
+        RegisterObject(PartDestructionEvent);
+        this->setValid(true);
+    }
+
+    PartDestructionEvent::~PartDestructionEvent()
+    {
+
+    }
+
+    void PartDestructionEvent::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+    {
+        SUPER(PartDestructionEvent, XMLPort, xmlelement, mode);
+
+        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, "value", setEventValue, getEventValue, xmlelement, mode).defaultValues(0);
+        XMLPortParam(PartDestructionEvent, "message", setMessage, getMessage, xmlelement, mode).defaultValues("NULL");
+
+        /*
+        XMLPortParam(PartDestructionEvent, "health", setHealth, getHealth, xmlelement, mode).defaultValues(100);
+        XMLPortParam(PartDestructionEvent, "maxhealth", setMaxHealth, getMaxHealth, xmlelement, mode).defaultValues(200);
+        XMLPortParam(PartDestructionEvent, "initialhealth", setInitialHealth, getInitialHealth, xmlelement, mode).defaultValues(100);
+        */
+    }
+
+    /**
+    @brief
+        Executes this event.
+    */
+    void PartDestructionEvent::execute()
+    {
+        // Do not execute if this event is invalid
+        if(!isValid())
+        {
+            orxout(internal_warning) << "Attempted to execute an invalid PartDestructionEvent!" << endl;
+            return;
+        }
+
+        // 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")
+        {
+            switch (this->targetParam_) {
+            case shieldhealth:
+                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;
+            case rotationthrust:
+                this->parent_->getParent()->setRotationThrust(operate(this->parent_->getParent()->getRotationThrust()));
+                break;
+            default:
+                break;
+            }
+            this->setValid(false);
+            return;
+        }
+
+        if (this->targetType_ == "engine")
+        {
+            switch (this->targetParam_) {
+            case null:
+                this->parent_->getParent()->removeEngine(this->parent_->getParent()->getEngineByName(targetName_));
+                break;
+            case boostfactor:
+                this->parent_->getParent()->getEngineByName(targetName_)->setBoostFactor(operate(this->parent_->getParent()->getEngineByName(targetName_)->getBoostFactor()));
+                break;
+            case speedfront:
+                this->parent_->getParent()->getEngineByName(targetName_)->setMaxSpeedFront(operate(this->parent_->getParent()->getEngineByName(targetName_)->getMaxSpeedFront()));
+                break;
+            case accelerationfront:
+                this->parent_->getParent()->getEngineByName(targetName_)->setAccelerationFront(operate(this->parent_->getParent()->getEngineByName(targetName_)->getAccelerationFront()));
+                break;
+            default:
+                break;
+            }
+            this->setValid(false);
+            return;
+        }
+
+        if (this->targetType_ == "part")
+        {
+            switch (this->targetParam_) {
+            case null:
+                if (!this->parent_->getParent()->getShipPartByName(targetName_))
+                    return;
+                this->parent_->getParent()->getShipPartByName(targetName_)->setEventExecution(false);
+                this->parent_->getParent()->killShipPart(targetName_);
+                break;
+            default:
+                break;
+            }
+            this->setValid(false);
+            return;
+        }
+    }
+
+    void PartDestructionEvent::setParent(ShipPart* part)
+    {
+        this->parent_ = part;
+    }
+
+    /**
+    @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)
+    {
+        if ((type == "ship") || (type == "engine") || (type == "weapon") || (type == "part"))
+        {
+            this->targetType_ = type;
+            return;
+        }
+
+        // Error, if invalid target-type was entered.
+        orxout(internal_warning) << "\"" << type << "\" is not a valid target-type for a PartDestructionEvent. Valid types are: ship engine weapon part" << endl;
+        this->setValid(false);
+        return;
+    }
+
+    void PartDestructionEvent::setTargetName(std::string name)
+    {
+        // Error, if the target-type is "weapon" or "engine", but the name of said target was not defined.
+        if (((this->targetType_ == "weapon") || (this->targetType_ == "engine")) && (name == "NULL"))
+        {
+            orxout(internal_warning) << "The target-name of a PartDestructionEvent with target-type \"" << this->targetType_ << "\" needs to be defined!" << endl;
+            return;
+        }
+
+        this->targetName_ = name;
+    }
+
+    /**
+    @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")
+        {
+            orxout(internal_warning) << "No valid target-type defined. Cannot set target-param for this PartDestructionEvent." << endl;
+            this->setValid(false);
+            return;
+        }
+
+        // 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 rotationthrust
+        if (this->targetType_ == "ship")
+        {
+            if (param == "shieldhealth")
+            {
+                this->targetParam_ = shieldhealth;
+                return;
+            }
+            if (param == "boostpower")
+            {
+                this->targetParam_ = boostpower;
+                return;
+            }
+            if (param == "boostpowerrate")
+            {
+                this->targetParam_ = boostpowerrate;
+                return;
+            }
+            if (param == "rotationthrust")
+            {
+                this->targetParam_ = rotationthrust;
+                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 rotationthrust" << endl;
+            return;
+        }
+
+        if (this->targetType_ == "part")
+        {
+            if (param == "NULL")
+            {
+                this->targetParam_ = null;
+                return;
+            }
+
+            orxout(internal_warning) << "\"" << param << "\" is not a valid target-param for a PartDestructionEvent with target-type \"part\". Valid types are: NULL (set operation to \"destroy\")" << endl;
+            return;
+        }
+
+        orxout(internal_warning) << "No valid target-param defined. The chosen param is either invalid or not available for this target-type." << endl;
+        this->setValid(false);
+    }
+
+    /**
+    @brief
+        Set the operation to be applied.
+    @param operation
+        The desired operator as string. Valid operators: * + - destroy
+    */
+    void PartDestructionEvent::setOperation(std::string operation)
+    {
+        // * + - destroy
+        if ((operation == "*") || (operation == "+") || (operation == "-") || (operation == "set") || (operation == "destroy"))
+        {
+            this->operation_ = operation;
+            return;
+        }
+        this->operation_ = "NULL";
+        orxout(internal_warning) << "\"" << operation << "\" is not a valid operation for a PartDestructionEvent. Valid operations are: * + - set destroy" << endl;
+    }
+
+    /**
+    @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,
+        the configured value if the operation is "set",
+        or 0 if the operation is "destroy"
+    */
+    float PartDestructionEvent::operate(float input)
+    {
+        if (this->operation_ == "*")
+            return input * this->value_;
+        if (this->operation_ == "+")
+            return input + this->value_;
+        if (this->operation_ == "-")
+            return input - this->value_;
+        if (this->operation_ == "set")
+            return this->value_;
+        if (this->operation_ == "destroy")
+        {
+            return 0;
+        }
+        return 0;
+    }
+
+    /**
+    @brief
+        Sets the value applied with the chosen operation.
+    @param value
+        The value as float.
+    */
+    void PartDestructionEvent::setEventValue(float value)
+    {
+        this->value_ = value;
+    }
+}
Index: code/branches/presentationFS14/src/orxonox/items/PartDestructionEvent.h
===================================================================
--- code/branches/presentationFS14/src/orxonox/items/PartDestructionEvent.h	(revision 10073)
+++ code/branches/presentationFS14/src/orxonox/items/PartDestructionEvent.h	(revision 10073)
@@ -0,0 +1,160 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   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
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Noe Pedrazzini
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _PartDestructionEvent_H__
+#define _PartDestructionEvent_H__
+
+#include "OrxonoxPrereqs.h"
+#include "Item.h"
+
+#include <string>
+
+
+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
+    { // tolua_export
+
+        public:
+
+            /**
+                @brief
+                    List of all allowed parameters.
+                */
+            enum TargetParam
+            {
+                shieldhealth,
+                maxshieldhealth,
+                shieldabsorption,
+                shieldrechargerate,
+                boostpower,         // Amount of available boost
+                boostpowerrate,     // Recharge-rate of boost
+                rotationthrust,
+                boostfactor,
+                speedfront,
+                accelerationfront,
+                null
+            };
+
+            PartDestructionEvent(Context* context);
+            virtual ~PartDestructionEvent();
+
+            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
+
+            void execute();
+
+            inline void setValid(bool valid)
+                { this->valid_ = valid; }
+            inline bool isValid()
+                { return this->valid_; }
+
+            void setParent(ShipPart* parent);
+            inline ShipPart* getParent()
+                { return this->parent_; }
+
+            void setTargetType(std::string type);
+            inline std::string getTargetType()
+                { return this->targetType_; }
+
+            void setTargetName(std::string name);
+            inline std::string getTargetName()
+                { return this->targetName_; }
+
+            void setTargetParam(std::string param);
+            inline std::string getTargetParam()
+                { return this->targetName_; }
+
+            void setOperation(std::string operation);
+            inline std::string getOperation()
+                { return this->operation_; }
+
+            void setMessage(std::string msg);
+            inline std::string getMessage()
+                { return this->message_; }
+
+            float operate(float input);
+
+            void setEventValue(float value);
+            inline float getEventValue()
+                { return this->value_; }
+
+        protected:
+
+        private:
+
+            ShipPart* parent_;          //!< Pointer to the ShipPart this event belongs to
+            bool valid_;                //!< Whether this event is valid or not.
+
+            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.
+
+
+
+    }; // tolua_export
+} // tolua_export
+
+#endif /* _PartDestructionEvent_H__ */
Index: code/branches/presentationFS14/src/orxonox/items/ShipPart.cc
===================================================================
--- code/branches/presentationFS14/src/orxonox/items/ShipPart.cc	(revision 10073)
+++ code/branches/presentationFS14/src/orxonox/items/ShipPart.cc	(revision 10073)
@@ -0,0 +1,291 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   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
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Noe Pedrazzini
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "ShipPart.h"
+
+#include <algorithm>
+
+#include "core/CoreIncludes.h"
+#include "core/GameMode.h"
+#include "core/XMLPort.h"
+#include "network/NetworkFunction.h"
+#include "Item.h"
+#include "worldentities/pawns/Pawn.h"
+#include "worldentities/pawns/ModularSpaceShip.h"
+#include "gametypes/Gametype.h"
+#include "worldentities/StaticEntity.h"
+#include "items/PartDestructionEvent.h"
+#include "worldentities/BigExplosion.h"
+#include "chat/ChatManager.h"
+
+
+namespace orxonox
+{
+    RegisterClass(ShipPart);
+
+    ShipPart::ShipPart(Context* context)
+        : Item(context)
+    {
+        RegisterObject(ShipPart);
+        this->setAlive(true);
+        this->setEventExecution(true);
+        this->healthMem_ = 100;
+    }
+
+    ShipPart::~ShipPart()
+    {
+
+    }
+
+    void ShipPart::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+    {
+        SUPER(ShipPart, XMLPort, xmlelement, mode);
+
+        XMLPortParam(ShipPart, "health", setHealth, getHealth, xmlelement, mode).defaultValues(100);
+        XMLPortParam(ShipPart, "maxhealth", setMaxHealth, getMaxHealth, xmlelement, mode).defaultValues(200);
+        XMLPortParam(ShipPart, "initialhealth", setInitialHealth, getInitialHealth, xmlelement, mode).defaultValues(100);
+
+        XMLPortParam(ShipPart, "damageabsorption", setDamageAbsorption, getDamageAbsorption, xmlelement, mode).defaultValues(0.5);
+
+        XMLPortParamTemplate(ShipPart, "explosionposition", setExplosionPosition, getExplosionPosition, xmlelement, mode, Vector3);
+
+        XMLPortObject(ShipPart, PartDestructionEvent, "destructionevents", addDestructionEvent, getDestructionEvent, xmlelement, mode);
+    }
+
+    /**
+    @brief
+        Is called when the ShipPart dies.
+        Executes PartDestructionEvents.
+        Tells the ModularSpaceShip to remove this ShipPart.
+    */
+    void ShipPart::death()
+    {
+        //if (!(this->isAlive()))
+            //return;
+
+        this->explode();
+        this->setAlive(false);
+
+        if(eventExecution_)
+        {
+            // Execute all destruction events
+            for (unsigned int i = 0; i < this->eventList_.size(); i++)
+            {
+                this->getDestructionEvent(i)->execute();
+            }
+        }
+
+        // Remove this ShipPart from the parent.
+        this->parent_->removeShipPart(this);
+        delete this;
+    }
+
+    void ShipPart::explode()
+    {
+        BigExplosion* chunk = new BigExplosion(this->getContext());
+        chunk->setPosition(this->parent_->getPosition() + this->parent_->getOrientation() * (this->explosionPosition_));
+        //chunk->setPosition(this->parent_->getPosition() + this->parent_->getOrientation() * Vector3(this->entityList_[0]->getLocalInertia()));
+        chunk->setVelocity(this->parent_->getVelocity());
+
+        // this->explosionSound_->setPosition(this->parent_->getPosition());
+        // this->explosionSound_->play();
+    }
+
+    /**
+    @brief
+        Add a StaticEntity to the ShipPart.
+    @param engine
+        A pointer to the StaticEntity to be added.
+    */
+    void ShipPart::addEntity(StaticEntity* entity)
+    {
+        OrxAssert(entity != NULL, "The Entity cannot be NULL.");
+        this->entityList_.push_back(entity);
+    }
+
+    /**
+    @brief
+        Get the i-th StaticEntity of the ShipPart.
+    @return
+        Returns a pointer to the i-the StaticEntity. NULL if there is no StaticEntity with that index.
+    */
+    StaticEntity* ShipPart::getEntity(unsigned int index)
+    {
+        if(this->entityList_.size() >= index)
+            return NULL;
+        else
+            return this->entityList_[index];
+    }
+
+    /**
+    @brief
+        Check whether the ShipPart has a particular Entity.
+    @param engine
+        A pointer to the Entity to be checked.
+    */
+    bool ShipPart::hasEntity(StaticEntity* entity) const
+    {
+        for(unsigned int i = 0; i < this->entityList_.size(); i++)
+        {
+            if(this->entityList_[i] == entity)
+                return true;
+        }
+        return false;
+    }
+
+    /**
+    @brief
+        Add a PartDestructionEvent to the ShipPart.
+    @param engine
+        A pointer to the PartDestructionEvent to be added.
+    */
+    void ShipPart::addDestructionEvent(PartDestructionEvent* event)
+    {
+        OrxAssert(event != NULL, "The PartDestructionEvent cannot be NULL.");
+        event->setParent(this);
+        this->eventList_.push_back(event);
+    }
+
+    /**
+    @brief
+        Get the i-th PartDestructionEvent of the ShipPart.
+    @return
+        Returns a pointer to the i-the PartDestructionEvent. NULL if there is no PartDestructionEvent with that index.
+    */
+    PartDestructionEvent* ShipPart::getDestructionEvent(unsigned int index)
+    {
+        if(this->eventList_.size() <= index)
+            return NULL;
+        else
+            return this->eventList_[index];
+    }
+
+    void ShipPart::setDamageAbsorption(float value)
+    {
+        this->damageAbsorption_ = value;
+    }
+
+    void ShipPart::setParent(ModularSpaceShip* ship)
+    {
+        this->parent_ = ship;
+    }
+
+    /**
+    @brief
+        Sets the health of the ShipPart.
+    */
+    void ShipPart::setHealth(float health)
+    {
+        this->health_ = health;
+    }
+
+    void ShipPart::setAlive(bool var)
+    {
+        this->alive_ = var;
+        orxout() << "ShipPart " << this->getName() << " alive_: " << this->alive_ << endl;
+    }
+
+    /**
+    @brief
+        Handles a received hit.
+    */
+    void ShipPart::handleHit(float damage, float healthdamage, float shielddamage, Pawn* originator)
+    {
+        if (parent_->getGametype() && parent_->getGametype()->allowPawnDamage(parent_, originator))
+        {
+            if (shielddamage >= parent_->getShieldHealth())
+            {
+                parent_->setShieldHealth(0);
+                this->setHealth(this->health_ - (healthdamage + damage) * this->damageAbsorption_);
+                parent_->setHealth(parent_->getHealth() - (healthdamage + damage) * (1 - this->damageAbsorption_));
+            }
+            else
+            {
+                parent_->setShieldHealth(parent_->getShieldHealth() - shielddamage);
+
+                // remove remaining shieldAbsorpton-Part of damage from shield
+                shielddamage = damage * parent_->getShieldAbsorption();
+                shielddamage = std::min(parent_->getShieldHealth(),shielddamage);
+                parent_->setShieldHealth(parent_->getShieldHealth() - shielddamage);
+
+                // set remaining damage to health
+                this->setHealth(this->health_ - ((damage - shielddamage) - healthdamage) * this->damageAbsorption_);
+                parent_->setHealth(parent_->getHealth() - ((damage - shielddamage) - healthdamage) * (1- this->damageAbsorption_));
+            }
+        }
+        if (this->health_ < 0)
+            this->alive_ = false;
+            //this->death();
+
+        // (Ugly) Chatoutput of health, until a GUI for modularspaceships-shipparts is implemented.
+        if ((this->health_ < 0.2 * this->maxHealth_) && (this->healthMem_ == 40))
+        {
+            this->healthMem_ = 20;
+            ChatManager::message("ShipPart " + this->getName() + " remaining health is 20%!");
+            return;
+        }
+        if ((this->health_ < 0.4 * this->maxHealth_) && (this->healthMem_ == 60))
+        {
+            this->healthMem_ = 40;
+            ChatManager::message("ShipPart " + this->getName() + " remaining health is 40%!");
+            return;
+        }
+        if ((this->health_ < 0.6 * this->maxHealth_) && (this->healthMem_ == 80))
+        {
+            this->healthMem_ = 60;
+            ChatManager::message("ShipPart " + this->getName() + " remaining health is 60%!");
+            return;
+        }
+        if ((this->health_ < 0.8 * this->maxHealth_) && (this->healthMem_ == 100))
+        {
+            this->healthMem_ = 80;
+            ChatManager::message("ShipPart " + this->getName() + " remaining health is 80%!");
+            return;
+        }
+    }
+
+
+    /**
+    @brief
+        Adds the ShipPart to the input SpaceShip.
+    @param ship
+        A pointer to the SpaceShip to which the ShipPart is added.
+    */
+    /*void ShipPart::addToSpaceShip(ModularSpaceShip* ship)
+    {
+        this->parent_ = ship;
+
+        if (ship)
+        {
+            this->parentID_ = ship->getObjectID();
+            if (!ship->hasShipPart(this))
+                ship->addShipPart(this);
+        }
+    }*/
+
+}
Index: code/branches/presentationFS14/src/orxonox/items/ShipPart.h
===================================================================
--- code/branches/presentationFS14/src/orxonox/items/ShipPart.h	(revision 10073)
+++ code/branches/presentationFS14/src/orxonox/items/ShipPart.h	(revision 10073)
@@ -0,0 +1,134 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   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
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Noe Pedrazzini
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _ShipPart_H__
+#define _ShipPart_H__
+
+#include "OrxonoxPrereqs.h"
+#include "Item.h"
+#include "items/PartDestructionEvent.h"
+
+#include <string>
+
+
+namespace orxonox // tolua_export
+{ // tolua_export
+    class _OrxonoxExport ShipPart // tolua_export
+        : public Item
+    { // tolua_export
+
+        public:
+            ShipPart(Context* context);
+            virtual ~ShipPart();
+
+            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
+
+            virtual void handleHit(float damage, float healthdamage, float shielddamage, Pawn* originator);
+
+            virtual void death();
+            virtual void explode();
+
+            //virtual void attachTo(Pawn* newParent);
+            //virtual void detach();
+
+            void addEntity(StaticEntity* entity);
+            StaticEntity* getEntity(unsigned int index);
+            bool hasEntity(StaticEntity* entity) const;
+
+            void addDestructionEvent(PartDestructionEvent* event);
+            PartDestructionEvent* getDestructionEvent(unsigned int index);
+
+            virtual void setDamageAbsorption(float value);
+            inline float getDamageAbsorption()
+                { return this->damageAbsorption_; }
+
+            void setParent(ModularSpaceShip* ship);
+            inline ModularSpaceShip* getParent()
+                { return this->parent_; }
+
+            void setAlive(bool var);
+            inline bool isAlive()
+                { return this->alive_; }
+
+            inline void setEventExecution(bool var)
+                { this->eventExecution_ = var; }
+            inline bool isEventExecution()
+                { return this->eventExecution_; }
+
+            virtual void setHealth(float health);
+            inline void addHealth(float health)
+                { this->setHealth(this->health_ + health); }
+            inline void removeHealth(float health)
+                { this->setHealth(this->health_ - health); }
+            inline float getHealth() const
+                { return this->health_; }
+
+            inline void setMaxHealth(float maxhealth)
+                { this->maxHealth_ = maxhealth; this->setHealth(this->health_); }
+            inline float getMaxHealth() const
+                { return this->maxHealth_; }
+
+            inline void setInitialHealth(float initialhealth)
+                { this->initialHealth_ = initialhealth; this->setHealth(initialhealth); }
+            inline float getInitialHealth() const
+                { return this->initialHealth_; }
+
+            inline void setExplosionPosition(Vector3 pos)
+                { this->explosionPosition_ = pos; }
+            inline Vector3 getExplosionPosition()
+                { return this->explosionPosition_; }
+
+
+            // FIXME: (noep) Why doesn't this work? Works fine in Engine.h
+            //void addToSpaceShip(ModularSpaceShip* ship);
+
+        protected:
+            ModularSpaceShip* parent_;
+            unsigned int parentID_;     // Object ID of the SpaceShip the Part is mounted on.
+
+            float damageAbsorption_;
+            float health_;
+            float maxHealth_;
+            float initialHealth_;
+
+        private:
+            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.
+
+            bool alive_;
+            bool eventExecution_;
+
+            float healthMem_;
+
+            Vector3 explosionPosition_;
+
+
+    }; // tolua_export
+} // tolua_export
+
+#endif /* _ShipPart_H__ */
