Index: code/trunk/src/orxonox/worldentities/pawns/CMakeLists.txt
===================================================================
--- code/trunk/src/orxonox/worldentities/pawns/CMakeLists.txt	(revision 6864)
+++ code/trunk/src/orxonox/worldentities/pawns/CMakeLists.txt	(revision 7163)
@@ -1,3 +1,4 @@
 ADD_SOURCE_FILES(ORXONOX_SRC_FILES
+  FpsPlayer.cc
   Spectator.cc
   Pawn.cc
Index: code/trunk/src/orxonox/worldentities/pawns/FpsPlayer.cc
===================================================================
--- code/trunk/src/orxonox/worldentities/pawns/FpsPlayer.cc	(revision 7163)
+++ code/trunk/src/orxonox/worldentities/pawns/FpsPlayer.cc	(revision 7163)
@@ -0,0 +1,307 @@
+/*
+ *   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:
+ *      Cyrill Frei
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "FpsPlayer.h"
+
+#include <OgreSceneNode.h>
+#include <BulletDynamics/Dynamics/btRigidBody.h>
+#include <LinearMath/btVector3.h>
+#include <BulletCollision/NarrowPhaseCollision/btManifoldPoint.h>
+#include <OgreSceneManager.h>
+#include <OgreSceneNode.h>
+#include <OgreEntity.h>
+
+#include "core/CoreIncludes.h"
+#include "core/ConfigValueIncludes.h"
+#include "core/Template.h"
+#include "core/XMLPort.h"
+#include "items/Engine.h"
+#include "Scene.h"
+#include "weaponsystem/WeaponPack.h"
+#include "weaponsystem/WeaponSlot.h"
+#include "weaponsystem/Weapon.h"
+
+#include <cmath>
+
+namespace orxonox
+{
+    const float orientationGain_ = 100;
+    const float jumpValue_ = 300;
+    CreateFactory(FpsPlayer);
+
+    FpsPlayer::FpsPlayer(BaseObject* creator) : Pawn(creator)
+    {
+        RegisterObject(FpsPlayer);
+        this->speed_ = 200;
+        this->localVelocity_ = Vector3::ZERO;
+/*
+ *        this->primaryThrust_  = 100;
+ *        this->auxilaryThrust_ =  30;
+ *        this->rotationThrust_ =  10;
+ *
+ *        this->localLinearAcceleration_.setValue(0, 0, 0);
+ *        this->localAngularAcceleration_.setValue(0, 0, 0);
+ *        this->bBoost_ = false;
+ *        this->bPermanentBoost_ = false;
+ *        this->steering_ = Vector3::ZERO;
+*/
+
+
+        this->bInvertYAxis_ = false;
+
+        this->setDestroyWhenPlayerLeft(true);
+
+        // FpsPlayer is always a physical object per default
+        // Be aware of this call: The collision type legality check will not reach derived classes!
+        this->setCollisionType(WorldEntity::Dynamic);
+        // Get notification about collisions
+        this->enableCollisionCallback();
+
+        this->setConfigValues();
+        this->registerVariables();
+
+        //this->weaponNode = this->cameraPositionRootNode_;
+        this->weaponNode_ = this->getScene()->getRootSceneNode()->createChildSceneNode();
+        this->attachNode(this->weaponNode_);
+    }
+
+    FpsPlayer::~FpsPlayer()
+    {
+        if (this->isInitialized())
+        {
+            if (this->mesh_.getEntity())
+                this->detachOgreObject(this->mesh_.getEntity());
+
+            if (this->weaponNode_ && this->getScene()->getSceneManager())
+                this->getScene()->getSceneManager()->destroySceneNode(this->weaponNode_->getName());
+        }
+    }
+
+    void FpsPlayer::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+    {
+        SUPER(FpsPlayer, XMLPort, xmlelement, mode);
+
+        XMLPortParamVariable(FpsPlayer, "primaryThrust",  primaryThrust_,  xmlelement, mode);
+        XMLPortParamVariable(FpsPlayer, "auxilaryThrust", auxilaryThrust_, xmlelement, mode);
+        XMLPortParamVariable(FpsPlayer, "rotationThrust", rotationThrust_, xmlelement, mode);
+        XMLPortParam(FpsPlayer, "weapon", setMeshSource, getMeshSource, xmlelement, mode);
+    }
+
+    void FpsPlayer::registerVariables()
+    {
+        registerVariable(this->primaryThrust_,  VariableDirection::ToClient);
+        registerVariable(this->auxilaryThrust_, VariableDirection::ToClient);
+        registerVariable(this->rotationThrust_, VariableDirection::ToClient);
+        registerVariable(this->weaponMashName_, VariableDirection::ToClient);
+    }
+
+
+
+    void FpsPlayer::setConfigValues()
+    {
+        SetConfigValue(bInvertYAxis_, false).description("Set this to true for joystick-like mouse behaviour (mouse up = targetting down).");
+    }
+
+    bool FpsPlayer::isCollisionTypeLegal(WorldEntity::CollisionType type) const
+    {
+        if (type != WorldEntity::Dynamic)
+        {
+            CCOUT(1) << "Error: Cannot tell a FpsPlayer not to be dynamic! Ignoring." << std::endl;
+            assert(false); // Only in debug mode
+            return false;
+        }
+        else
+            return true;
+    }
+
+    void FpsPlayer::tick(float dt)
+    {
+        if (this->hasLocalController())
+        {
+            this->setOrientation(savedOrientation_);
+
+            this->thisTickBoost_ = false;
+
+            float localSpeedSquared = this->localVelocity_.squaredLength();
+            float localSpeed;
+            if (localSpeedSquared > 1.0)
+                localSpeed = this->speed_ / sqrtf(localSpeedSquared);
+            else
+                localSpeed = this->speed_;
+
+            this->localVelocity_.x *= localSpeed;
+            this->localVelocity_.z *= localSpeed;
+            Vector3 temp = this->getOrientation() * this->localVelocity_;
+            if (localVelocity_.y == jumpValue_)
+                this->setVelocity(Vector3(temp.x, temp.y + this->getVelocity().y, temp.z));
+            else
+                this->setVelocity(Vector3(temp.x, this->getVelocity().y, temp.z));
+            this->localVelocity_.x = 0;
+            this->localVelocity_.y = 0;
+            this->localVelocity_.z = 0;
+
+            if (!this->isInMouseLook())
+            {
+                this->yaw(Radian(this->yaw_ * this->getMouseLookSpeed()), WorldEntity::Parent);
+
+                Radian pitch = this->cameraPositionRootNode_->getOrientation().getPitch();
+                if (pitch < Radian(1.5707) && pitch > Radian(-1.5707))
+                {
+                    this->cameraPositionRootNode_->pitch(Radian(this->pitch_ * this->getMouseLookSpeed()));
+                }
+                else if (pitch < Radian(-1.5707))
+                {
+                    if (this->pitch_ > 0.0)
+                        this->cameraPositionRootNode_->pitch(Radian(this->pitch_ * this->getMouseLookSpeed()));
+                    else if (pitch < Radian(-1.571))
+                        this->cameraPositionRootNode_->pitch(-pitch + Radian(-1.570796));
+                }
+                else if (pitch > Radian(1.5707))
+                {
+                    if (this->pitch_ < 0.0)
+                        this->cameraPositionRootNode_->pitch(Radian(this->pitch_ * this->getMouseLookSpeed()));
+                    else if (pitch > Radian(1.571))
+                        this->cameraPositionRootNode_->pitch(-pitch + Radian(1.570796));
+                }
+                this->weaponNode_->setOrientation(this->cameraPositionRootNode_->getOrientation());
+            }
+
+            this->yaw_ = this->pitch_ = this->roll_ = 0;
+
+            this->setAngularVelocity(0.0, 0.0, 0.0);
+            this->savedOrientation_ = this->getOrientation();
+        }
+
+        SUPER(FpsPlayer, tick, dt);
+    }
+
+    void FpsPlayer::changedMesh()
+    {
+        if (GameMode::showsGraphics())
+        {
+            if (this->mesh_.getEntity())
+                this->weaponNode_->detachObject(this->mesh_.getEntity());
+
+            this->mesh_.setMeshSource(this->getScene()->getSceneManager(), this->meshSrc_);
+
+            if (this->mesh_.getEntity())
+            {
+                this->weaponNode_->attachObject(this->mesh_.getEntity());
+            }
+        }
+    }
+
+    void FpsPlayer::setPlayer(PlayerInfo* player)
+    {
+        ControllableEntity::setPlayer(player);
+
+//        this->setSyncMode(ObjectDirection::ToClient);
+    }
+
+    void FpsPlayer::startLocalHumanControl()
+    {
+        ControllableEntity::startLocalHumanControl();
+    }
+
+    void FpsPlayer::moveFrontBack(const Vector2& value)
+    {
+        this->localVelocity_.z -= value.x;
+    }
+
+
+    void FpsPlayer::moveRightLeft(const Vector2& value)
+    {
+        this->localVelocity_.x += value.x;
+    }
+
+    void FpsPlayer::moveUpDown(const Vector2& value)
+    {
+        //this->localVelocity_.y += value.x;
+    }
+
+    void FpsPlayer::rotateYaw(const Vector2& value)
+    {
+        this->yaw_ += value.y;
+
+        ControllableEntity::rotateYaw(value);
+    }
+
+    void FpsPlayer::rotatePitch(const Vector2& value)
+    {
+        this->pitch_ += value.y;
+
+        ControllableEntity::rotatePitch(value);
+    }
+
+    void FpsPlayer::rotateRoll(const Vector2& value)
+    {
+        this->roll_ += value.y;
+
+        ControllableEntity::rotateRoll(value);
+    }
+
+    void FpsPlayer::fire()
+    {
+    }
+
+    void FpsPlayer::boost() //acctually jump
+    {
+        if (this->isFloor_)
+        {
+            if (!this->thisTickBoost_)
+                this->localVelocity_.y = jumpValue_;
+            //this->physicalBody_->applyCentralImpulse(btVector3(0, jumpvalue, 0));
+            this->thisTickBoost_ = true;
+            this->isFloor_ = false;
+        }
+    }
+
+    bool FpsPlayer::collidesAgainst(WorldEntity* otherObject, btManifoldPoint& contactPoint)
+    {
+        if (contactPoint.m_normalWorldOnB.y() > 0.6)
+            this->isFloor_ = true;
+        else
+            this->isFloor_ = false;
+
+        return false;
+    }
+
+    void FpsPlayer::addedWeaponPack(WeaponPack* wPack)
+    {
+        for (size_t i = 0; i < wPack->getNumWeapons(); ++i)
+        {
+            Weapon* weapon = wPack->getWeapon(i);
+            if (weapon->getWeaponSlot())
+            {
+                weapon->getWeaponSlot()->removeWeapon();
+                weapon->detachFromParent();
+                weapon->attachToNode(this->weaponNode_);
+            }
+        }
+    }
+}
Index: code/trunk/src/orxonox/worldentities/pawns/FpsPlayer.h
===================================================================
--- code/trunk/src/orxonox/worldentities/pawns/FpsPlayer.h	(revision 7163)
+++ code/trunk/src/orxonox/worldentities/pawns/FpsPlayer.h	(revision 7163)
@@ -0,0 +1,108 @@
+/*
+ *   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:
+ *      Cyrill Frei
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _FpsPlayer_H__
+#define _FpsPlayer_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include <string>
+#include <LinearMath/btVector3.h>
+#include "util/Math.h"
+#include "tools/Mesh.h"
+#include "Pawn.h"
+
+namespace orxonox
+{
+    class _OrxonoxExport FpsPlayer : public Pawn
+    {
+        public:
+            FpsPlayer(BaseObject* creator);
+            virtual ~FpsPlayer();
+
+            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
+            virtual void tick(float dt);
+            void registerVariables();
+            void setConfigValues();
+
+            virtual void moveFrontBack(const Vector2& value);
+            virtual void moveRightLeft(const Vector2& value);
+            virtual void moveUpDown(const Vector2& value);
+
+            virtual void rotateYaw(const Vector2& value);
+            virtual void rotatePitch(const Vector2& value);
+            virtual void rotateRoll(const Vector2& value);
+
+
+            inline void setMeshSource(const std::string& meshname)
+                { this->meshSrc_ = meshname; this->changedMesh(); }
+            inline const std::string& getMeshSource() const
+                { return this->meshSrc_; }
+
+            void boost(); //acctually jump
+
+            virtual void fire();
+
+            bool collidesAgainst(WorldEntity* otherObject, btManifoldPoint& contactPoint);
+
+            virtual void addedWeaponPack(WeaponPack* wPack);
+
+        protected:
+            virtual void setPlayer(PlayerInfo* player);
+            virtual void startLocalHumanControl();
+            bool bInvertYAxis_;
+
+            bool bBoost_;
+            bool bPermanentBoost_;
+            Vector3 steering_;
+            float primaryThrust_;
+            float auxilaryThrust_;
+            float rotationThrust_;
+            std::string weaponMashName_;
+            btVector3 localLinearAcceleration_;
+            btVector3 localAngularAcceleration_;
+
+        private:
+            virtual bool isCollisionTypeLegal(WorldEntity::CollisionType type) const;
+            float speed_;
+
+            void changedMesh();
+            Mesh mesh_;
+            std::string meshSrc_;
+            float yaw_;
+            float pitch_;
+            float roll_;
+            Vector3 localVelocity_;
+            bool isFloor_;
+            bool thisTickBoost_;
+            Quaternion savedOrientation_;
+            Ogre::SceneNode* weaponNode_;
+    };
+}
+
+#endif /* _FpsPlayer_H__ */
Index: code/trunk/src/orxonox/worldentities/pawns/Pawn.cc
===================================================================
--- code/trunk/src/orxonox/worldentities/pawns/Pawn.cc	(revision 6864)
+++ code/trunk/src/orxonox/worldentities/pawns/Pawn.cc	(revision 7163)
@@ -53,5 +53,7 @@
     CreateFactory(Pawn);
 
-    Pawn::Pawn(BaseObject* creator) : ControllableEntity(creator)
+    Pawn::Pawn(BaseObject* creator)
+        : ControllableEntity(creator)
+        , RadarViewable(creator, static_cast<WorldEntity*>(this))
     {
         RegisterObject(Pawn);
@@ -64,4 +66,6 @@
         this->maxHealth_ = 0;
         this->initialHealth_ = 0;
+        this->shieldHealth_ = 0;
+        this->shieldAbsorption_ = 0.5;
 
         this->lastHitOriginator_ = 0;
@@ -78,6 +82,4 @@
         else
             this->weaponSystem_ = 0;
-        
-        this->setCarrierName("Pawn");
 
         this->setRadarObjectColour(ColourValue::Red);
@@ -105,4 +107,8 @@
         XMLPortParam(Pawn, "maxhealth", setMaxHealth, getMaxHealth, xmlelement, mode).defaultValues(200);
         XMLPortParam(Pawn, "initialhealth", setInitialHealth, getInitialHealth, xmlelement, mode).defaultValues(100);
+
+        XMLPortParam(Pawn, "shieldhealth", setShieldHealth, getShieldHealth, xmlelement, mode).defaultValues(0);
+        XMLPortParam(Pawn, "shieldabsorption", setShieldAbsorption, getShieldAbsorption, xmlelement, mode).defaultValues(0);
+
         XMLPortParam(Pawn, "spawnparticlesource", setSpawnParticleSource, getSpawnParticleSource, xmlelement, mode);
         XMLPortParam(Pawn, "spawnparticleduration", setSpawnParticleDuration, getSpawnParticleDuration, xmlelement, mode).defaultValues(3.0f);
@@ -116,9 +122,11 @@
     void Pawn::registerVariables()
     {
-        registerVariable(this->bAlive_,        VariableDirection::ToClient);
-        registerVariable(this->health_,        VariableDirection::ToClient);
-        registerVariable(this->initialHealth_, VariableDirection::ToClient);
-        registerVariable(this->bReload_,       VariableDirection::ToServer);
-        registerVariable(this->aimPosition_,   Bidirectionality::ServerMaster, 0, true);
+        registerVariable(this->bAlive_,           VariableDirection::ToClient);
+        registerVariable(this->health_,           VariableDirection::ToClient);
+        registerVariable(this->initialHealth_,    VariableDirection::ToClient);
+        registerVariable(this->shieldHealth_,     VariableDirection::ToClient);
+        registerVariable(this->shieldAbsorption_, VariableDirection::ToClient);
+        registerVariable(this->bReload_,          VariableDirection::ToServer);
+        registerVariable(this->aimPosition_,      VariableDirection::ToServer);  // For the moment this variable gets only transfered to the server
     }
 
@@ -162,5 +170,22 @@
         if (this->getGametype() && this->getGametype()->allowPawnDamage(this, originator))
         {
-            this->setHealth(this->health_ - damage);
+            //share the dealt damage to the shield and the Pawn.
+            float shielddamage = damage*this->shieldAbsorption_;
+            float healthdamage = damage*(1-this->shieldAbsorption_);
+
+            // In case the shield can not take all the shield damage.
+            if (shielddamage > this->getShieldHealth())
+            {
+                healthdamage += shielddamage-this->getShieldHealth();
+                this->setShieldHealth(0);
+            }
+
+            this->setHealth(this->health_ - healthdamage);
+
+            if (this->getShieldHealth() > 0)
+            {
+                this->setShieldHealth(this->shieldHealth_ - shielddamage);
+            }
+
             this->lastHitOriginator_ = originator;
 
@@ -336,5 +361,8 @@
     {
         if (this->weaponSystem_)
+        {
             this->weaponSystem_->addWeaponPack(wPack);
+            this->addedWeaponPack(wPack);
+        }
     }
 
@@ -342,6 +370,10 @@
     {
         if (this->weaponSystem_)
+        {
             if (!this->weaponSystem_->addWeaponPack(wPack))
                 wPack->destroy();
+            else
+                this->addedWeaponPack(wPack);
+        }
     }
 
Index: code/trunk/src/orxonox/worldentities/pawns/Pawn.h
===================================================================
--- code/trunk/src/orxonox/worldentities/pawns/Pawn.h	(revision 6864)
+++ code/trunk/src/orxonox/worldentities/pawns/Pawn.h	(revision 7163)
@@ -50,5 +50,4 @@
             virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
             virtual void tick(float dt);
-            void registerVariables();
 
             inline bool isAlive() const
@@ -73,4 +72,14 @@
                 { return this->initialHealth_; }
 
+            inline void setShieldHealth(float shieldHealth)
+            { this->shieldHealth_ = shieldHealth; }
+            inline float getShieldHealth()
+            { return this->shieldHealth_; }
+
+            inline void setShieldAbsorption(float shieldAbsorption)
+            { this->shieldAbsorption_ = shieldAbsorption; }
+            inline float getShieldAbsorption()
+            { return this->shieldAbsorption_; }
+
             inline ControllableEntity* getLastHitOriginator() const
                 { return this->lastHitOriginator_; }
@@ -91,4 +100,6 @@
             void addWeaponPackXML(WeaponPack * wPack);
             WeaponPack * getWeaponPack(unsigned int index) const;
+
+            virtual void addedWeaponPack(WeaponPack* wPack) {}
 
             inline const WorldEntity* getWorldEntity() const
@@ -116,5 +127,5 @@
             Vector3 getAimPosition()
                 { return this->aimPosition_; }
-                
+
             virtual const Vector3& getCarrierPosition(void)
                 { return this->getWorldPosition(); };
@@ -141,4 +152,6 @@
             float maxHealth_;
             float initialHealth_;
+            float shieldHealth_;
+            float shieldAbsorption_; // Has to be between 0 and 1
 
             Pawn* lastHitOriginator_;
@@ -152,4 +165,5 @@
 
         private:
+            void registerVariables();
             inline void setWeaponSystem(WeaponSystem* weaponsystem)
                 { this->weaponSystem_ = weaponsystem; }
Index: code/trunk/src/orxonox/worldentities/pawns/SpaceShip.h
===================================================================
--- code/trunk/src/orxonox/worldentities/pawns/SpaceShip.h	(revision 6864)
+++ code/trunk/src/orxonox/worldentities/pawns/SpaceShip.h	(revision 7163)
@@ -47,5 +47,4 @@
             virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
             virtual void tick(float dt);
-            void registerVariables();
             void setConfigValues();
 
@@ -99,7 +98,7 @@
 
         private:
+            void registerVariables();
             virtual bool isCollisionTypeLegal(WorldEntity::CollisionType type) const;
 
-        private:
             void loadEngineTemplate();
 
Index: code/trunk/src/orxonox/worldentities/pawns/Spectator.h
===================================================================
--- code/trunk/src/orxonox/worldentities/pawns/Spectator.h	(revision 6864)
+++ code/trunk/src/orxonox/worldentities/pawns/Spectator.h	(revision 7163)
@@ -44,5 +44,4 @@
 
             void setConfigValues();
-            void registerVariables();
             virtual void tick(float dt);
 
@@ -63,4 +62,5 @@
 
         private:
+            void registerVariables();
             void changedGreeting();
             void changedFlareVisibility();
