[Orxonox-commit 191] r2864 - in branches/pickups/src/orxonox/objects: pickup weaponSystem/projectiles worldentities/pawns

danielh at orxonox.net danielh at orxonox.net
Mon Mar 30 14:27:26 CEST 2009


Author: danielh
Date: 2009-03-30 12:27:26 +0000 (Mon, 30 Mar 2009)
New Revision: 2864

Added:
   branches/pickups/src/orxonox/objects/pickup/BaseItem.cc
   branches/pickups/src/orxonox/objects/pickup/BaseItem.h
   branches/pickups/src/orxonox/objects/pickup/EquipmentItem.cc
   branches/pickups/src/orxonox/objects/pickup/EquipmentItem.h
   branches/pickups/src/orxonox/objects/pickup/ModifierPickup.cc
   branches/pickups/src/orxonox/objects/pickup/ModifierPickup.h
   branches/pickups/src/orxonox/objects/pickup/ModifierType.h
   branches/pickups/src/orxonox/objects/pickup/PassiveItem.cc
   branches/pickups/src/orxonox/objects/pickup/PassiveItem.h
   branches/pickups/src/orxonox/objects/pickup/PickupCollection.cc
   branches/pickups/src/orxonox/objects/pickup/PickupCollection.h
   branches/pickups/src/orxonox/objects/pickup/PickupSpawner.cc
   branches/pickups/src/orxonox/objects/pickup/PickupSpawner.h
   branches/pickups/src/orxonox/objects/pickup/UsableItem.cc
   branches/pickups/src/orxonox/objects/pickup/UsableItem.h
Modified:
   branches/pickups/src/orxonox/objects/pickup/CMakeLists.txt
   branches/pickups/src/orxonox/objects/weaponSystem/projectiles/Projectile.cc
   branches/pickups/src/orxonox/objects/worldentities/pawns/Pawn.cc
   branches/pickups/src/orxonox/objects/worldentities/pawns/Pawn.h
Log:
first commit of pickup system

- working PickupCollection
- working PickupSpawner
- base classes for items
- updated Pawn to include PickupCollection
- updated Projectile to use damage modifier on hit

Added: branches/pickups/src/orxonox/objects/pickup/BaseItem.cc
===================================================================
--- branches/pickups/src/orxonox/objects/pickup/BaseItem.cc	                        (rev 0)
+++ branches/pickups/src/orxonox/objects/pickup/BaseItem.cc	2009-03-30 12:27:26 UTC (rev 2864)
@@ -0,0 +1,84 @@
+/*
+ *   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:
+ *      Daniel 'Huty' Haggenmueller
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+    @file
+    @brief Implementation of BaseItem (base-class for items/pickups).
+*/
+
+#include "BaseItem.h"
+
+#include "PickupCollection.h"
+#include "objects/worldentities/pawns/Pawn.h"
+
+namespace orxonox
+{
+    /**
+        @brief Constructor. Registers the BaseItem.
+        @param creator Pointer to the object which created this item.
+    */
+    BaseItem::BaseItem(BaseObject* creator) : BaseObject(creator)
+    {
+        RegisterObject(BaseItem);
+
+        this->setOwner(0);
+        this->setPickupIdentifier(this->getName());
+    }
+    //! Deconstructor.
+    BaseItem::~BaseItem()
+    {
+    }
+    /**
+        @brief Method to add the item to a pawn.
+        @param pawn Pawn to which the item should get added.
+        @return Returns whether the pawn's PickupCollection accepted the item.
+    */
+    bool BaseItem::addTo(Pawn* pawn)
+    {
+        this->setOwner(pawn);
+
+        COUT(3) << "Adding '" << this->getPickupIdentifier() << "' item." << std::endl;
+
+        return pawn->getPickups().add(this);
+    }
+    /**
+        @brief Removes the item from a pawn.
+        @param pawn Pawn from which to remove the item.
+        @return Returns whether the pawn's PickupCollection was able to locate and remove the item.
+    */
+    bool BaseItem::removeFrom(Pawn* pawn)
+    {
+        this->setOwner(0);
+
+        COUT(3) << "Removing '" << this->getPickupIdentifier() << "' item." << std::endl;
+
+        pawn->getPickups().remove(this, false);
+
+        return true;
+    }
+}

Added: branches/pickups/src/orxonox/objects/pickup/BaseItem.h
===================================================================
--- branches/pickups/src/orxonox/objects/pickup/BaseItem.h	                        (rev 0)
+++ branches/pickups/src/orxonox/objects/pickup/BaseItem.h	2009-03-30 12:27:26 UTC (rev 2864)
@@ -0,0 +1,132 @@
+/*
+ *   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:
+ *      Daniel 'Huty' Haggenmueller
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+    @file
+    @brief Definition of BaseItem (base-class for items/pickups).
+*/
+
+#ifndef _BaseItem_H__
+#define _BaseItem_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include "core/BaseObject.h"
+
+namespace orxonox
+{
+    /**
+        @brief
+            Base class for all items/pickups.
+
+            Provides common methods to be used in derived classes.
+        @author
+            Daniel 'Huty' Haggenmueller
+    */
+    class _OrxonoxExport BaseItem : public BaseObject
+    {
+    public:
+        BaseItem(BaseObject* creator);
+        virtual ~BaseItem();
+
+        /**
+            @brief Checks how many instances of this item can be carried at a time.
+            @return How many of this item can be carried.
+        */
+        virtual int getMaxCarryAmount() const
+            { return 1; }
+
+        bool addTo(Pawn* pawn);             //!< Add the item to a pawn.
+        bool removeFrom(Pawn* pawn);        //!< Removes the item from a pawn.
+        /**
+            @brief
+                Method invoked when the item gets picked up.
+
+                Has to be overridden for an item to work,
+                should contain a call to addTo().
+
+            @param pawn Pawn who picks up the item.
+            @return Returns whether the pawn was able to pick up the item.
+        */
+        virtual bool pickedUp(Pawn* pawn)
+            { return false; }
+        /**
+            @brief
+                Method invoked when the item is dropped from a player.
+
+                Should be overridden by derived classes,
+                should also contain a call to removeFrom().
+
+            @param pawn Pawn which dropped the item.
+            @return Returns whether the item was able to get dropped by the pawn.
+        */
+        virtual bool dropped(Pawn* pawn)
+            { return false; }
+
+        /**
+            @brief Gets the current owner of the pickup.
+            @return Returns the current owner.
+        */
+        inline Pawn* getOwner() const
+            { return this->owner_; }
+        /**
+            @brief Sets the owner of the pickup.
+            @param owner New owner for the pickup.
+        */
+        inline void setOwner(Pawn* owner)
+            { this->owner_ = owner; }
+
+        /**
+            @brief Gets the pickupIdentifier of the item.
+            @return Returns the pickupIdentifier of the item.
+            @see pickupIdentifier_
+        */
+        inline const std::string& getPickupIdentifier() const
+            { return this->pickupIdentifier_; }
+        /**
+            @brief Sets the pickupIdentifier for the item.
+            @param identifier New pickupIdentifier for the item.
+            @see pickupIdentifier_
+        */
+        inline void setPickupIdentifier(const std::string& identifier)
+            { this->pickupIdentifier_ = identifier; }
+    private:
+        Pawn* owner_;   //!< The current owner of the item.
+
+        /**
+            @brief
+                The pickupIdentifier of the item..
+
+                Usually set to the template name used by a PickupSpawner,
+                used to index items in the PickupCollection.
+        */
+        std::string pickupIdentifier_;
+    };
+}
+
+#endif /* _BaseItem_H__ */

Modified: branches/pickups/src/orxonox/objects/pickup/CMakeLists.txt
===================================================================
--- branches/pickups/src/orxonox/objects/pickup/CMakeLists.txt	2009-03-29 22:26:52 UTC (rev 2863)
+++ branches/pickups/src/orxonox/objects/pickup/CMakeLists.txt	2009-03-30 12:27:26 UTC (rev 2864)
@@ -1,3 +1,9 @@
 ADD_SOURCE_FILES(ORXONOX_SRC_FILES
-
+  BaseItem.cc
+  EquipmentItem.cc
+  ModifierPickup.cc
+  PassiveItem.cc
+  PickupCollection.cc
+  PickupSpawner.cc
+  UsableItem.cc
 )

Added: branches/pickups/src/orxonox/objects/pickup/EquipmentItem.cc
===================================================================
--- branches/pickups/src/orxonox/objects/pickup/EquipmentItem.cc	                        (rev 0)
+++ branches/pickups/src/orxonox/objects/pickup/EquipmentItem.cc	2009-03-30 12:27:26 UTC (rev 2864)
@@ -0,0 +1,52 @@
+/*
+ *   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:
+ *      Daniel 'Huty' Haggenmueller
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+    @file
+    @brief Implementation of EquipmentItem.
+*/
+
+#include "EquipmentItem.h"
+
+#include "core/CoreIncludes.h"
+
+namespace orxonox
+{
+    /**
+        @brief Constructor. Registers the EquipmentItem.
+        @param creator Pointer to the object which created this item.
+    */
+    EquipmentItem::EquipmentItem(BaseObject* creator) : BaseItem(creator)
+    {
+        RegisterObject(EquipmentItem);
+    }
+    //! Deconstructor.
+    EquipmentItem::~EquipmentItem()
+    {
+    }
+}

Added: branches/pickups/src/orxonox/objects/pickup/EquipmentItem.h
===================================================================
--- branches/pickups/src/orxonox/objects/pickup/EquipmentItem.h	                        (rev 0)
+++ branches/pickups/src/orxonox/objects/pickup/EquipmentItem.h	2009-03-30 12:27:26 UTC (rev 2864)
@@ -0,0 +1,55 @@
+/*
+ *   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:
+ *      Daniel 'Huty' Haggenmueller
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+    @file
+    @brief Definition of EquipmentItem (base-class for equipment-type items).
+*/
+
+#ifndef _EquipmentPickup_H__
+#define _EquipmentPickup_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include "BaseItem.h"
+
+namespace orxonox
+{
+    /**
+        @brief Base class for all equipment-type items.
+        @author Daniel 'Huty' Haggenmueller
+    */
+    class _OrxonoxExport EquipmentItem : public BaseItem
+    {
+    public:
+        EquipmentItem(BaseObject* creator);
+        virtual ~EquipmentItem();
+    };
+}
+
+#endif /* _EquipmentPickup_H__ */

Added: branches/pickups/src/orxonox/objects/pickup/ModifierPickup.cc
===================================================================
--- branches/pickups/src/orxonox/objects/pickup/ModifierPickup.cc	                        (rev 0)
+++ branches/pickups/src/orxonox/objects/pickup/ModifierPickup.cc	2009-03-30 12:27:26 UTC (rev 2864)
@@ -0,0 +1,205 @@
+/*
+ *   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:
+ *      Daniel 'Huty' Haggenmueller
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+    @file
+    @brief Implementation of ModifierPickup (temporary(?) pickup for testing).
+*/
+
+#include "ModifierPickup.h"
+#include "PickupCollection.h"
+
+#include "core/CoreIncludes.h"
+#include "core/XMLPort.h"
+#include "core/Core.h"
+
+#include "objects/worldentities/pawns/Pawn.h"
+
+#include "util/Debug.h"
+
+namespace orxonox
+{
+    CreateFactory(ModifierPickup);
+
+    /**
+        @brief Constructor. Registers the ModifierPickup.
+        @param creator Pointer to the object which created this item.
+    */
+    ModifierPickup::ModifierPickup(BaseObject* creator) : PassiveItem(creator)
+    {
+        RegisterObject(ModifierPickup);
+
+        this->duration_ = 0.0f;
+    }
+    //! Deconstructor.
+    ModifierPickup::~ModifierPickup()
+    {
+    }
+    /**
+        @brief Method for loading information from a level file.
+        @param element XMLElement from which to read the data.
+        @param mode XMLPort mode to use.
+    */
+    void ModifierPickup::XMLPort(Element& element, XMLPort::Mode mode)
+    {
+        SUPER(ModifierPickup, XMLPort, element, mode);
+
+        XMLPortParam(ModifierPickup, "duration", setDuration, getDuration, element, mode);
+
+        XMLPortParamTemplate(ModifierPickup, "damageAdd", setAdditiveDamage, getAdditiveDamage, element, mode, float);
+        XMLPortParamTemplate(ModifierPickup, "damageMulti", setMultiplicativeDamage, getMultiplicativeDamage, element, mode, float);
+    }
+    /**
+        @brief
+            Invoked when a pawn picks up the pickup.
+
+            Adds the modifiers to the pawn and sets a timer (if effect is limited)
+            if the pickup could be added to the pawn's PickupCollection.
+
+        @param pawn Pawn which picked up the pickup.
+        @return Returns whether the pickup was able to be added to the pawn.
+    */
+    bool ModifierPickup::pickedUp(Pawn* pawn)
+    {
+        if (this->addTo(pawn))
+        {
+            std::map<ModifierType::Enum, float>::iterator it;
+
+            for (it = this->additiveModifiers_.begin(); it != this->additiveModifiers_.end(); it++)
+            {
+                pawn->getPickups().addAdditiveModifier((*it).first, (*it).second);
+            }
+
+            for (it = this->multiplicativeModifiers_.begin(); it != this->multiplicativeModifiers_.end(); it++)
+            {
+                pawn->getPickups().addMultiplicativeModifier((*it).first, (*it).second);
+            }
+
+            if (this->duration_ > 0.0f)
+            {
+                ExecutorMember<ModifierPickup>* executor = createExecutor(createFunctor(&ModifierPickup::timerCallback));
+                executor->setDefaultValues(pawn);
+                this->timer_.setTimer(this->duration_, false, this, executor);
+            }
+            
+            return true;
+        }
+        return false;
+    }
+    /**
+        @brief
+            Invoked when a pawn drops the pickup.
+
+            Removes the modifiers from the pawn if the pickup
+            was successfully removed from it's PickupCollection.
+
+        @param pawn Pawn which dropped the pickup.
+        @return Returns whether the pickup could be removed.
+    */
+    bool ModifierPickup::dropped(Pawn* pawn)
+    {
+        if (this->removeFrom(pawn))
+        {
+            std::map<ModifierType::Enum, float>::iterator it;
+
+            for (it = this->additiveModifiers_.begin(); it != this->additiveModifiers_.end(); it++)
+            {
+                pawn->getPickups().removeAdditiveModifier((*it).first, (*it).second);
+            }
+
+            for (it = this->multiplicativeModifiers_.begin(); it != this->multiplicativeModifiers_.end(); it++)
+            {
+                pawn->getPickups().removeMultiplicativeModifier((*it).first, (*it).second);
+            }
+            
+            if (this->timer_.getRemainingTime() > 0.0f)
+                this->timer_.stopTimer();
+
+            return true;
+        }
+        return false;
+    }
+    /**
+        @brief Invoked when the timer finished, calls dropped().
+    */
+    void ModifierPickup::timerCallback(Pawn* pawn)
+    {
+        if (!this->dropped(pawn))
+            COUT(2) << "Failed to remove modifier pickup after the timer ran out!" << std::endl;
+    }
+    /**
+        @brief Gets the additive modifier of a given type.
+        @param type ModifierType for which to return the modifier.
+        @return Returns the additive modifier for type (or 0 if not exists).
+    */
+    float ModifierPickup::getAdditiveModifier(ModifierType::Enum type) const
+    {
+        std::map<ModifierType::Enum, float>::const_iterator it = this->additiveModifiers_.find(type);
+        if (it != this->additiveModifiers_.end())
+            return (*it).second;
+        else
+            return 0.0f;
+    }
+    /**
+        @brief Gets the multiplicative modifier of a given type.
+        @param type ModifierType for which to return the modifier.
+        @return Returns the multiplicative modifier for type (or 1 if not exists).
+    */
+    float ModifierPickup::getMultiplicativeModifier(ModifierType::Enum type) const
+    {
+        std::map<ModifierType::Enum, float>::const_iterator it = this->multiplicativeModifiers_.find(type);
+        if (it != this->multiplicativeModifiers_.end())
+            return (*it).second;
+        else
+            return 1.0f;
+    }
+    /**
+        @brief Gets the additive modifier of a given type.
+        @param type ModifierType for which to return the modifier.
+        @param value The new additive modifier for type.
+    */
+    void ModifierPickup::setAdditiveModifier(ModifierType::Enum type, float value)
+    {
+        if (this->additiveModifiers_.find(type) == this->additiveModifiers_.end())
+            this->additiveModifiers_.insert( std::pair<ModifierType::Enum, float>(type, value) );
+        else
+            this->additiveModifiers_[type] = value;
+    }
+    /**
+        @brief Gets the multiplicative modifier of a given type.
+        @param type ModifierType for which to return the modifier.
+        @param value The new multiplicative modifier for type.
+    */
+    void ModifierPickup::setMultiplicativeModifier(ModifierType::Enum type, float value)
+    {
+        if (this->multiplicativeModifiers_.find(type) == this->multiplicativeModifiers_.end())
+            this->multiplicativeModifiers_.insert( std::pair<ModifierType::Enum, float>(type, value) );
+        else
+            this->multiplicativeModifiers_[type] = value;
+    }
+}

Added: branches/pickups/src/orxonox/objects/pickup/ModifierPickup.h
===================================================================
--- branches/pickups/src/orxonox/objects/pickup/ModifierPickup.h	                        (rev 0)
+++ branches/pickups/src/orxonox/objects/pickup/ModifierPickup.h	2009-03-30 12:27:26 UTC (rev 2864)
@@ -0,0 +1,114 @@
+/*
+ *   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:
+ *      Daniel 'Huty' Haggenmueller
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+    @file
+    @brief Definition of ModifierPickup (temporary(?) pickup for testing).
+*/
+
+#ifndef _ModifierPickup_H__
+#define _ModifierPickup_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include "PassiveItem.h"
+#include "ModifierType.h"
+#include "orxonox/tools/timer.h"
+
+namespace orxonox
+{
+    /**
+        @brief Class for a (temporary) modifier effect.
+        @author Daniel 'Huty' Haggenmueller
+    */
+    class _OrxonoxExport ModifierPickup : public PassiveItem
+    {
+    public:
+        ModifierPickup(BaseObject* creator);
+        virtual ~ModifierPickup();
+
+        virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);  //!< To create a ModifierPickup through the level file.
+
+        virtual bool pickedUp(Pawn* pawn);                              //!< Override of the BaseItem::pickedUp() method.
+        virtual bool dropped(Pawn* pawn);                               //!< Override of the BaseItem::dropped() method
+
+        /**
+            @brief Get the duration of this pickup.
+            @return Returns how long the effect holds on.
+        */
+        inline float getDuration() const
+            { return this->duration_; }
+        /**
+            @brief Set the duration of this pickup.
+            @param duration How long the effect should hold.
+        */
+        inline void setDuration(float duration)
+            { this->duration_ = duration; }
+
+        /**
+            @brief Get the amount of damage this pickup adds.
+            @return Returns how much damage this pickup adds.
+        */
+        inline float getAdditiveDamage() const
+            { return this->getAdditiveModifier(ModifierType::Damage); }
+        /**
+            @brief Get the factor by which this pickup multiplies the damage.
+            @return Returns the factor by which to multiply damage.
+        */
+        inline float getMultiplicativeDamage() const
+            { return this->getMultiplicativeModifier(ModifierType::Damage); }
+
+        /**
+            @brief Set the amount of damage this pickup adds.
+            @param value How much damage this pickup adds.
+        */
+        inline void setAdditiveDamage(float value)
+            { this->setAdditiveModifier(ModifierType::Damage, value); }
+        /**
+            @brief Set the factor by which this pickup multiplies the damage.
+            @param value Factor by which to multiply damage.
+        */
+        inline void setMultiplicativeDamage(float value)
+            { this->setMultiplicativeModifier(ModifierType::Damage, value); }
+
+        void timerCallback(Pawn* pawn);     //!< Method called when the timer runs out.
+    private:
+        float getAdditiveModifier(ModifierType::Enum type) const;               //!< Get the additive modifier for a given ModifierType.
+        float getMultiplicativeModifier(ModifierType::Enum type) const;         //!< Get the multiplicative modifier for a given ModifierType.
+        void setAdditiveModifier(ModifierType::Enum type, float value);         //!< Set the additive modifier for a given ModifierType.
+        void setMultiplicativeModifier(ModifierType::Enum type, float value);   //!< Set the multiplicative modifier for a given ModifierType
+
+        std::map<ModifierType::Enum, float> additiveModifiers_;                 //!< Map of additive modifiers, indexed by ModifierType.
+        std::map<ModifierType::Enum, float> multiplicativeModifiers_;           //!< Map of multiplicative modifiers, indexed by ModifierType.
+
+        float duration_;                                                        //!< Duration of this pickup's effect (0 for unlimited).
+        Timer<ModifierPickup> timer_;                                           //!< Timer used if the pickup's effect has a time limit.
+    };
+}
+
+#endif /* _ModifierPickup_H__ */

Added: branches/pickups/src/orxonox/objects/pickup/ModifierType.h
===================================================================
--- branches/pickups/src/orxonox/objects/pickup/ModifierType.h	                        (rev 0)
+++ branches/pickups/src/orxonox/objects/pickup/ModifierType.h	2009-03-30 12:27:26 UTC (rev 2864)
@@ -0,0 +1,52 @@
+/*
+ *   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:
+ *      Daniel 'Huty' Haggenmueller
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+    @file
+    @brief Contains enumeration for different types of modifiers.
+*/
+
+#ifndef _ModifierType_H__
+#define _ModifierType_H__
+
+namespace orxonox
+{
+    namespace ModifierType
+    {
+        /**
+            @brief Gives the available types for modifiers.
+        */
+        enum Enum
+        {
+            Unknown = 0,
+            Damage
+        };
+    }
+}
+
+#endif /* _ModifierType_H__ */

Added: branches/pickups/src/orxonox/objects/pickup/PassiveItem.cc
===================================================================
--- branches/pickups/src/orxonox/objects/pickup/PassiveItem.cc	                        (rev 0)
+++ branches/pickups/src/orxonox/objects/pickup/PassiveItem.cc	2009-03-30 12:27:26 UTC (rev 2864)
@@ -0,0 +1,47 @@
+/*
+ *   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:
+ *      Daniel 'Huty' Haggenmueller
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "PassiveItem.h"
+
+#include "core/CoreIncludes.h"
+
+namespace orxonox
+{
+    /**
+        @brief Constructor. Registers the PassiveItem.
+        @param creator Pointer to the object which created this item.
+    */
+    PassiveItem::PassiveItem(BaseObject* creator) : BaseItem(creator)
+    {
+        RegisterObject(PassiveItem);
+    }
+    //! Deconstructor.
+    PassiveItem::~PassiveItem()
+    {
+    }
+}

Added: branches/pickups/src/orxonox/objects/pickup/PassiveItem.h
===================================================================
--- branches/pickups/src/orxonox/objects/pickup/PassiveItem.h	                        (rev 0)
+++ branches/pickups/src/orxonox/objects/pickup/PassiveItem.h	2009-03-30 12:27:26 UTC (rev 2864)
@@ -0,0 +1,55 @@
+/*
+ *   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:
+ *      Daniel 'Huty' Haggenmueller
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+    @file
+    @brief Definition of PassiveItem (base class for passive items).
+*/
+
+#ifndef _PassiveItem_H__
+#define _PassiveItem_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include "BaseItem.h"
+
+namespace orxonox
+{
+    /**
+        @brief Base class for all passive items.
+        @author Daniel 'Huty' Haggenmueller
+    */
+    class _OrxonoxExport PassiveItem : public BaseItem
+    {
+    public:
+        PassiveItem(BaseObject* creator);
+        virtual ~PassiveItem();
+    };
+}
+
+#endif /* _PassiveItem_H__ */

Added: branches/pickups/src/orxonox/objects/pickup/PickupCollection.cc
===================================================================
--- branches/pickups/src/orxonox/objects/pickup/PickupCollection.cc	                        (rev 0)
+++ branches/pickups/src/orxonox/objects/pickup/PickupCollection.cc	2009-03-30 12:27:26 UTC (rev 2864)
@@ -0,0 +1,339 @@
+/*
+ *   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:
+ *      Daniel 'Huty' Haggenmueller
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+    @file
+    @brief Implementation of PickupCollection.
+*/
+
+#include "PickupCollection.h"
+
+#include "BaseItem.h"
+#include "EquipmentItem.h"
+#include "PassiveItem.h"
+#include "UsableItem.h"
+
+#include "objects/worldentities/pawns/Pawn.h"
+
+namespace orxonox
+{
+    //! Constructor
+    PickupCollection::PickupCollection()
+    {
+        this->bBlockRemovals_ = false;
+    }
+
+    /**
+        @brief
+            Add an item to the collection.
+            
+            Only adds the item if there's a free slot for it.
+
+        @param item Item to add to the collection.
+        @return Returns whether the item has been added to the collection.
+    */
+    bool PickupCollection::add(BaseItem* item)
+    {
+        if (this->checkSlot(item))
+        {
+            this->items_.insert( std::pair<std::string, BaseItem*> (item->getPickupIdentifier(), item) );
+            return true;
+        }
+        else
+            return false;
+    }
+    /**
+        @brief
+            Check if there's a free slot for an item.
+
+            Compares the amount of the item-type in the collection
+            against the maximal amount of the item that can be carried.
+
+        @param item Item to check for a slot.
+        @return Returns if there's a free slot for the item.
+    */
+    bool PickupCollection::checkSlot(BaseItem* item)
+    {
+        return (this->items_.count(item->getPickupIdentifier()) < item->getMaxCarryAmount());
+    }
+    /**
+        @brief
+            Empty the collection.
+
+            Calls dropped() on all the items in the collection,
+            then clears the collection.
+    */
+    void PickupCollection::clear()
+    {
+        this->bBlockRemovals_ = true;
+        for (std::multimap<std::string, BaseItem*>::iterator it = this->items_.begin(); it != this->items_.end(); it++)
+        {
+            (*it).second->dropped((*it).second->getOwner());
+
+            delete (*it).second;
+        }
+        this->items_.clear();
+        this->bBlockRemovals_ = false;
+    }
+    /**
+        @brief Check if an item/type of item is in the collection.
+        @param item Item to check.
+        @param anyOfType If it should look for any item of the item's type (default: false).
+        @return Whether the collection contains the item/type of item.
+    */
+    bool PickupCollection::contains(BaseItem* item, bool anyOfType)
+    {
+        if (anyOfType)
+        {
+            return (this->items_.count(item->getPickupIdentifier()) > 0);
+        }
+        else
+        {
+            std::multimap<std::string, BaseItem*>::_Pairii bounds = this->items_.equal_range(item->getPickupIdentifier());
+            for (std::multimap<std::string, BaseItem*>::iterator it = bounds.first; it != bounds.second && it != this->items_.end(); it++)
+            {
+                if ((*it).second == item)
+                {
+                    return true;
+                }
+            }
+            return false;
+        }
+    }
+    /**
+        @brief Remove an item/all of a type from the collection.
+        @param item Item to remove.
+        @param removeAllOfType Whether to remove all the items with the item's type (default: false).
+    */
+    void PickupCollection::remove(BaseItem* item, bool removeAllOfType)
+    {
+        if (!item || !this->contains(item, removeAllOfType) || this->bBlockRemovals_)
+            return;
+
+        if (removeAllOfType)
+        {
+            std::multimap<std::string, BaseItem*>::iterator it;
+            while ((it = this->items_.find(item->getPickupIdentifier())) != this->items_.end())
+            {
+                this->items_.erase(it);
+            }
+        }
+        else
+        {
+            std::multimap<std::string, BaseItem*>::_Pairii bounds = this->items_.equal_range(item->getPickupIdentifier());
+            for (std::multimap<std::string, BaseItem*>::iterator it = bounds.first; it != bounds.second && it != this->items_.end(); it++)
+            {
+                if ((*it).second == item)
+                {
+                    this->items_.erase(it);
+                    return;
+                }
+            }
+        }
+    }
+    /**
+        @brief Add an additive modifier.
+        @param type ModifierType to add.
+        @param value Value for the modifier.
+    */
+    void PickupCollection::addAdditiveModifier(ModifierType::Enum type, float value)
+    {
+        this->additiveModifiers_.insert( std::pair<ModifierType::Enum, float>(type, value) );
+    }
+    /**
+        @brief Get the total amount of an additive modifier.
+        @param type Type for which to get the total.
+        @return Returns the sum of the additive modifiers of the type.
+    */
+    float PickupCollection::getAdditiveModifier(ModifierType::Enum type)
+    {
+        float v = 0.0f;
+
+        std::multimap<ModifierType::Enum, float>::_Pairii range = this->additiveModifiers_.equal_range(type);
+
+        for (std::multimap<ModifierType::Enum, float>::iterator it = range.first; it != range.second && it != this->additiveModifiers_.end(); it++)
+        {
+            v += (*it).second;
+        }
+
+        return v;
+    }
+    /**
+        @brief Remove an additive modifier.
+        @param type Type of modifier.
+        @param value Value which is to be removed.
+    */
+    void PickupCollection::removeAdditiveModifier(ModifierType::Enum type, float value)
+    {
+        std::multimap<ModifierType::Enum, float>::_Pairii range = this->additiveModifiers_.equal_range(type);
+        for (std::multimap<ModifierType::Enum, float>::iterator it = range.first; it != range.second && it != this->additiveModifiers_.end(); it++)
+        {
+            if ((*it).second == value)
+            {
+                this->additiveModifiers_.erase(it);
+                return;
+            }
+        }
+    }
+    /**
+        @brief Add a multiplicative modifier.
+        @param type ModifierType to add.
+        @param value Value for the modifier.
+    */
+    void PickupCollection::addMultiplicativeModifier(ModifierType::Enum type, float value)
+    {
+        this->multiplicativeModifiers_.insert( std::pair<ModifierType::Enum, float>(type, value) );
+    }
+    /**
+        @brief Get the total amount of a multiplicative modifier.
+        @param type Type for which to get the total.
+        @return Returns the product of the multiplicative modifiers of the type.
+    */
+    float PickupCollection::getMultiplicativeModifier(ModifierType::Enum type)
+    {
+        float v = 1.0f;
+
+        std::multimap<ModifierType::Enum, float>::_Pairii range = this->multiplicativeModifiers_.equal_range(type);
+        for (std::multimap<ModifierType::Enum, float>::iterator it = range.first; it != range.second && it != this->multiplicativeModifiers_.end(); it++)
+        {
+            v *= (*it).second;
+        }
+
+        return v;
+    }
+    /**
+        @brief Remove a multiplicative modifier.
+        @param type Type of modifier.
+        @param value Value which is to be removed.
+    */
+    void PickupCollection::removeMultiplicativeModifier(ModifierType::Enum type, float value)
+    {
+        std::multimap<ModifierType::Enum, float>::_Pairii range = this->multiplicativeModifiers_.equal_range(type);
+        for (std::multimap<ModifierType::Enum, float>::iterator it = range.first; it != range.second && it != this->multiplicativeModifiers_.end(); it++)
+        {
+            if ((*it).second == value)
+            {
+                this->multiplicativeModifiers_.erase(it);
+                return;
+            }
+        }
+    }
+    /**
+        @brief Applies modifiers to a float.
+        @param type Type of modifier tp apply.
+        @param inputValue Value which is to be processed.
+        @param addBeforeMultiplication Whether to apply the additive modifier before the multiplicative one (default: false).
+        @return Returns the value after being processed.
+    */
+    float PickupCollection::processModifiers(ModifierType::Enum type, float inputValue, bool addBeforeMultiplication)
+    {
+        float outputValue = inputValue;
+
+        if (addBeforeMultiplication)
+            outputValue += this->getAdditiveModifier(type);
+
+        outputValue *= this->getMultiplicativeModifier(type);
+
+        if (!addBeforeMultiplication)
+            outputValue += this->getAdditiveModifier(type);
+
+        return outputValue;
+    }
+    /**
+        @brief Applies modifiers to a Vector3.
+        @param type Type of modifier tp apply.
+        @param inputValue Value which is to be processed.
+        @param addBeforeMultiplication Whether to apply the additive modifier before the multiplicative one (default: false).
+        @return Returns the value after being processed.
+    */
+    Vector3 PickupCollection::processModifiers(ModifierType::Enum type, Vector3 inputValue, bool addBeforeMultiplication)
+    {
+        Vector3 outputValue = inputValue;
+
+        if (addBeforeMultiplication)
+            outputValue += Vector3(this->getAdditiveModifier(type));
+
+        outputValue *= this->getMultiplicativeModifier(type);
+
+        if (!addBeforeMultiplication)
+            outputValue += Vector3(this->getAdditiveModifier(type));
+
+        return outputValue;
+    }
+    /**
+        @brief Get a list of equipment-type items.
+        @return Returns a list of all the equipment-type items in the collection.
+    */
+    std::set<BaseItem*> PickupCollection::getEquipmentItems()
+    {
+        std::set<BaseItem*> ret;
+        Identifier* ident = Class(EquipmentItem);
+
+        for (std::multimap<std::string, BaseItem*>::iterator it = this->items_.begin(); it != this->items_.end(); it++)
+        {
+            if ((*it).second->isA(ident))
+                ret.insert((*it).second);
+        }
+
+        return ret;
+    }
+    /**
+        @brief Get a list of passive items.
+        @return Returns a list of all the passive items in the collection.
+    */
+    std::set<BaseItem*> PickupCollection::getPassiveItems()
+    {
+        std::set<BaseItem*> ret;
+        Identifier* ident = Class(PassiveItem);
+
+        for (std::multimap<std::string, BaseItem*>::iterator it = this->items_.begin(); it != this->items_.end(); it++)
+        {
+            if ((*it).second->isA(ident))
+                ret.insert((*it).second);
+        }
+
+        return ret;
+    }
+    /**
+        @brief Get a list of usable items.
+        @return Returns a list of all the usable items in the collection.
+    */
+    std::set<BaseItem*> PickupCollection::getUsableItems()
+    {
+        std::set<BaseItem*> ret;
+        Identifier* ident = Class(UsableItem);
+
+        for (std::multimap<std::string, BaseItem*>::iterator it = this->items_.begin(); it != this->items_.end(); it++)
+        {
+            if ((*it).second->isA(ident))
+                ret.insert((*it).second);
+        }
+
+        return ret;
+    }
+}

Added: branches/pickups/src/orxonox/objects/pickup/PickupCollection.h
===================================================================
--- branches/pickups/src/orxonox/objects/pickup/PickupCollection.h	                        (rev 0)
+++ branches/pickups/src/orxonox/objects/pickup/PickupCollection.h	2009-03-30 12:27:26 UTC (rev 2864)
@@ -0,0 +1,117 @@
+/*
+ *   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:
+ *      Daniel 'Huty' Haggenmueller
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+    @file
+    @brief Definition of PickupCollection.
+*/
+
+#ifndef _PickupCollection_H__
+#define _PickupCollection_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include <map>
+#include <set>
+#include <string>
+
+#include "util/Math.h"  
+
+#include "ModifierType.h"
+
+namespace orxonox
+{
+    class BaseItem;
+    class Pawn;
+
+    /**
+        @brief PickupCollection for organising items.
+        @author Daniel 'Huty' Haggenmueller
+    */
+    class _OrxonoxExport PickupCollection
+    {
+    public:
+        PickupCollection();
+
+        bool add(BaseItem* item);       //!< Add an item to the collection.
+
+        bool checkSlot(BaseItem* item); //!< Check if there's a free slot in the collection for an item.
+
+        void clear();                   //!< Empty the collection
+        bool contains(BaseItem* item, bool anyOfType = false);                      //!< Check if the collection contains an item.
+
+        void remove(BaseItem* item, bool removeAllOfType = false);                  //!< Remove an item from the collection.
+
+        void addAdditiveModifier(ModifierType::Enum type, float value);             //!< Add an additive modifier.
+        void addMultiplicativeModifier(ModifierType::Enum type, float value);       //!< Add a multiplicative modifier.
+
+        float getAdditiveModifier(ModifierType::Enum type);                         //!< Get total additive modifier.
+        float getMultiplicativeModifier(ModifierType::Enum type);                   //!< Get total multiplicative modifier.
+
+        void removeAdditiveModifier(ModifierType::Enum type, float value);          //!< Remove an additive modifier.
+        void removeMultiplicativeModifier(ModifierType::Enum type, float value);    //!< Remove a multiplicative modifier.
+
+        float processModifiers(ModifierType::Enum type, float inputValue, bool addBeforeMultiplication = false);        //!< Apply the modifiers to a float.
+        Vector3 processModifiers(ModifierType::Enum type, Vector3 inputValue, bool addBeforeMultiplication = false);    //!< Apply the modifiers to a Vector3.
+
+        /**
+            @brief Get the map of contained items.
+            @return The map of items.
+        */
+        std::multimap<std::string, BaseItem*> getItems() const
+            { return this->items_; }
+
+        /**
+            @brief Get the owner of the PickupCollection.
+            @return Returns the pawn which owns the PickupCollection.
+        */
+        inline Pawn* getOwner() const 
+            { return this->owner_; }
+        /**
+            @brief Set the owner of the PickupCollection.
+            @param owner The new Pawn which owns the PickupCollection.
+        */
+        inline void setOwner(Pawn* owner)
+            { this->owner_ = owner; }
+
+        std::set<BaseItem*> getEquipmentItems();   //!< Get a list of equipment-type items.
+        std::set<BaseItem*> getPassiveItems();     //!< Get a list of passive items.
+        std::set<BaseItem*> getUsableItems();      //!< Get a list of usable items.
+    private:
+        Pawn* owner_;           //!< The owner of the PickupCollection.
+
+        bool bBlockRemovals_;   //!< Whether to block direct removals through remove().
+
+        std::multimap<ModifierType::Enum, float> additiveModifiers_;        //!< Contains additive modifiers (indexed by ModifierType).
+        std::multimap<ModifierType::Enum, float> multiplicativeModifiers_;  //!< Contains multiplicative modifiers (indexed by ModifierType).
+
+        std::multimap<std::string, BaseItem*> items_;                       //!< Map of items in the collection (indexed by pickupIdentifier of the items).
+    };
+}
+
+#endif /* _PickupCollection_H__ */

Added: branches/pickups/src/orxonox/objects/pickup/PickupSpawner.cc
===================================================================
--- branches/pickups/src/orxonox/objects/pickup/PickupSpawner.cc	                        (rev 0)
+++ branches/pickups/src/orxonox/objects/pickup/PickupSpawner.cc	2009-03-30 12:27:26 UTC (rev 2864)
@@ -0,0 +1,159 @@
+/*
+ *   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:
+ *      Daniel 'Huty' Haggenmueller
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+    @file
+    @brief Implementation of PickupSpawner.
+*/
+
+#include "PickupSpawner.h"
+#include "BaseItem.h"
+
+#include "core/CoreIncludes.h"
+#include "core/XMLPort.h"
+#include "core/Template.h"
+
+#include "objects/worldentities/pawns/Pawn.h"
+#include "objects/worldentities/triggers/DistanceTrigger.h"
+
+namespace orxonox
+{
+    CreateFactory(PickupSpawner);
+
+    /**
+        @brief Constructor. Registers the PickupSpawner.
+        @param creator Pointer to the object which created this item.
+    */
+    PickupSpawner::PickupSpawner(BaseObject* creator) : StaticEntity(creator)
+    {
+        RegisterObject(PickupSpawner);
+
+        this->itemTemplate_ = 0;
+        this->triggerDistance_ = 20;
+        this->respawnTime_ = 0.0f;
+    }
+    //! Deconstructor.
+    PickupSpawner::~PickupSpawner()
+    {
+    }
+    /**
+        @brief Method for creating a PickupSpawner through XML.
+        @param xmlelement XML element which contains the PickupSpawner.
+        @param mode XMLPort mode.
+    */
+    void PickupSpawner::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+    {
+        SUPER(PickupSpawner, XMLPort, xmlelement, mode);
+
+        XMLPortParam(PickupSpawner, "item", setItemTemplateName, getItemTemplateName, xmlelement, mode);
+        XMLPortParam(PickupSpawner, "triggerDistance", setTriggerDistance, getTriggerDistance, xmlelement, mode);
+        XMLPortParam(PickupSpawner, "respawnTime", setRespawnTime, getRespawnTime, xmlelement, mode);
+    }
+    /**
+        @brief Invoked when the activity has changed. Sets visibility of attached objects.
+    */
+    void PickupSpawner::changedActivity()
+    {
+        SUPER(PickupSpawner, changedActivity);
+
+        for (std::set<WorldEntity*>::const_iterator it = this->getAttachedObjects().begin(); it != this->getAttachedObjects().end(); it++)
+            (*it)->setVisible(this->isActive());
+    }
+    /**
+        @brief Set the template name of the item to spawn, also loads the template.
+        @param name Name of the new template.
+    */
+    void PickupSpawner::setItemTemplateName(const std::string& name)
+    {
+        this->itemTemplateName_ = name;
+        this->itemTemplate_ = Template::getTemplate(name);
+    }
+    /**
+        @brief Tick, checks if any Pawn is close enough to trigger.
+        @param dt Time since last tick.
+    */
+    void PickupSpawner::tick(float dt)
+    {
+        if (this->isActive())
+        {
+            for (ObjectList<Pawn>::iterator it = ObjectList<Pawn>::begin(); it != ObjectList<Pawn>::end(); it++)
+            {
+                Vector3 distance = it->getWorldPosition() - this->getWorldPosition();
+                if (distance.length() < this->triggerDistance_)
+                    this->trigger(*it);
+            }
+        }
+    }
+    /**
+        @brief
+            Trigger the PickupSpawner.
+
+            Adds the pickup to the Pawn that triggered,
+            sets the timer to re-activate and deactives the PickupSpawner.
+
+        @param pawn Pawn which triggered the PickupSpawner.
+    */
+    void PickupSpawner::trigger(Pawn* pawn)
+    {
+        if (this->isActive() && this->itemTemplate_ && this->itemTemplate_->getBaseclassIdentifier())
+        {
+            BaseObject* newObject = this->itemTemplate_->getBaseclassIdentifier()->fabricate(this);
+            BaseItem* asItem = dynamic_cast<BaseItem*>(newObject);
+            if (asItem)
+            {
+                asItem->setPickupIdentifier(this->itemTemplateName_);
+                asItem->addTemplate(this->itemTemplate_);
+
+                if (asItem->pickedUp(pawn))
+                {
+                    COUT(3) << this->itemTemplateName_ << " got picked up." << std::endl;
+
+                    if (this->respawnTime_ > 0.0f)
+                    {
+                        ExecutorMember<PickupSpawner>* executor = createExecutor(createFunctor(&PickupSpawner::respawnTimerCallback));
+                        this->respawnTimer_.setTimer(this->respawnTime_, false, this, executor);
+
+                        this->setActive(false);
+                        this->fireEvent();
+                    }
+                }
+                else
+                    delete newObject;
+            }
+        }
+    }
+    /**
+        @brief Invoked by the timer, re-activates the PickupSpawner.
+    */
+    void PickupSpawner::respawnTimerCallback()
+    {
+        COUT(3) << "PickupSpawner reactivated." << std::endl;
+
+        this->setActive(true);
+    }
+}

Added: branches/pickups/src/orxonox/objects/pickup/PickupSpawner.h
===================================================================
--- branches/pickups/src/orxonox/objects/pickup/PickupSpawner.h	                        (rev 0)
+++ branches/pickups/src/orxonox/objects/pickup/PickupSpawner.h	2009-03-30 12:27:26 UTC (rev 2864)
@@ -0,0 +1,116 @@
+/*
+ *   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:
+ *      Daniel 'Huty' Haggenmueller
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+    @file
+    @brief Definition of PickupSpawner.
+*/
+
+#ifndef _PickupSpawner_H__
+#define _PickupSpawner_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include "core/BaseObject.h"
+#include "objects/Tickable.h"
+#include "objects/worldentities/StaticEntity.h"
+#include "tools/timer.h"
+
+namespace orxonox
+{
+    class BaseItem;
+
+    /**
+        @brief PickupSpawner.
+        @author Daniel 'Huty' Haggenmueller
+    */
+    class _OrxonoxExport PickupSpawner : public StaticEntity, public Tickable
+    {
+    public:
+        PickupSpawner(BaseObject* creator);
+        virtual ~PickupSpawner();
+
+        virtual void changedActivity();                                 //!< Invoked when activity has changed (set visibilty).
+        virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);  //!< Method for creating a PickupSpawner through XML.
+        virtual void tick(float dt);
+
+        void trigger(Pawn* pawn);                                       //!< Method called when a Pawn is close enough.
+        void respawnTimerCallback();                                    //!< Method called when the timer runs out.
+
+        /**
+            @brief Get the template name for the item to spawn.
+            @return Returns the name of the template of the item to spawn.
+        */
+        inline const std::string& getItemTemplateName() const
+            { return this->itemTemplateName_; }
+        void setItemTemplateName(const std::string& name);              //!< Set the template name of the item to spawn.
+
+        /**
+            @brief Get the template for the item to spawn.
+            @return Returns the template of the item to spawn.
+        */
+        inline Template* getItemTemplate() const
+            { return this->itemTemplate_; }
+
+        /**
+            @brief Get the distance in which to trigger.
+            @return Returns the distance in which this gets triggered.
+        */
+        inline float getTriggerDistance() const
+            { return this->triggerDistance_; }
+        /**
+            @brief Set the distance in which to trigger.
+            @param value The new distance in which to trigger.
+        */
+        inline void setTriggerDistance(float value)
+            { this->triggerDistance_ = value; }
+
+        /**
+            @brief Get the time to respawn.
+            @returns Returns the time after which this gets re-actived.
+        */
+        inline float getRespawnTime() const
+            { return this->respawnTime_; }
+        /**
+            @brief Set the time to respawn.
+            @param time New time after which this gets re-actived.
+        */
+        inline void setRespawnTime(float time)
+            { this->respawnTime_ = time; }
+    private:
+        std::string itemTemplateName_;          //!< Template name of the item to spawn.
+        Template* itemTemplate_;                //!< Template of the item to spawn.
+
+        float triggerDistance_;                 //!< Distance in which this gets triggered.
+
+        float respawnTime_;                     //!< Time after which this gets re-actived.
+        Timer<PickupSpawner> respawnTimer_;     //!< Timer used for re-activating.
+    };
+}
+
+#endif /* _PickupSpawner_H__ */

Added: branches/pickups/src/orxonox/objects/pickup/UsableItem.cc
===================================================================
--- branches/pickups/src/orxonox/objects/pickup/UsableItem.cc	                        (rev 0)
+++ branches/pickups/src/orxonox/objects/pickup/UsableItem.cc	2009-03-30 12:27:26 UTC (rev 2864)
@@ -0,0 +1,52 @@
+/*
+ *   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:
+ *      Daniel 'Huty' Haggenmueller
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+    @file
+    @brief Implementation of UsableItem.
+*/
+
+#include "UsableItem.h"
+
+#include "core/CoreIncludes.h"
+
+namespace orxonox
+{
+    /**
+        @brief Constructor. Registers the UsableItem.
+        @param creator Pointer to the object which created this item.
+    */
+    UsableItem::UsableItem(BaseObject* creator) : BaseItem(creator) 
+    {
+        RegisterObject(UsableItem);
+    }
+    //! Deconstructor.
+    UsableItem::~UsableItem()
+    {
+    }
+}

Added: branches/pickups/src/orxonox/objects/pickup/UsableItem.h
===================================================================
--- branches/pickups/src/orxonox/objects/pickup/UsableItem.h	                        (rev 0)
+++ branches/pickups/src/orxonox/objects/pickup/UsableItem.h	2009-03-30 12:27:26 UTC (rev 2864)
@@ -0,0 +1,61 @@
+/*
+ *   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:
+ *      Daniel 'Huty' Haggenmueller
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+    @file
+    @brief Definition of UsableItem.
+*/
+
+#ifndef _UsableItem_H__
+#define _UsableItem_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include "BaseItem.h"
+
+namespace orxonox
+{
+    /**
+        @brief Base class for all usable items (not usable yet).
+        @author Daniel 'Huty' Haggenmueller
+    */
+    class _OrxonoxExport UsableItem : public BaseItem
+    {
+    public:
+        UsableItem(BaseObject* creator);
+        virtual ~UsableItem();
+
+        /**
+            @brief Method invoked if the item was used.
+            @param pawn Pawn which used the item.
+        */
+        virtual void used(Pawn* pawn) { }
+    };
+}
+
+#endif /* _UsableItem_H__ */

Modified: branches/pickups/src/orxonox/objects/weaponSystem/projectiles/Projectile.cc
===================================================================
--- branches/pickups/src/orxonox/objects/weaponSystem/projectiles/Projectile.cc	2009-03-29 22:26:52 UTC (rev 2863)
+++ branches/pickups/src/orxonox/objects/weaponSystem/projectiles/Projectile.cc	2009-03-30 12:27:26 UTC (rev 2864)
@@ -123,8 +123,13 @@
             }
 
             Pawn* victim = dynamic_cast<Pawn*>(otherObject);
+
+            float dmg = this->damage_;
+            if (this->owner_)
+                dmg = this->owner_->getPickups().processModifiers(ModifierType::Damage, dmg, false);
+
             if (victim)
-                victim->damage(this->damage_, this->owner_);
+                victim->damage(dmg, this->owner_);
         }
         return false;
     }

Modified: branches/pickups/src/orxonox/objects/worldentities/pawns/Pawn.cc
===================================================================
--- branches/pickups/src/orxonox/objects/worldentities/pawns/Pawn.cc	2009-03-29 22:26:52 UTC (rev 2863)
+++ branches/pickups/src/orxonox/objects/worldentities/pawns/Pawn.cc	2009-03-30 12:27:26 UTC (rev 2864)
@@ -32,7 +32,6 @@
 #include "core/Core.h"
 #include "core/CoreIncludes.h"
 #include "core/XMLPort.h"
-#include "util/Exception.h"
 #include "util/Math.h"
 #include "PawnManager.h"
 #include "objects/infos/PlayerInfo.h"
@@ -61,6 +60,8 @@
 
         this->spawnparticleduration_ = 3.0f;
 
+        this->getPickups().setOwner(this);
+
         if (Core::isMaster())
         {
             this->weaponSystem_ = new WeaponSystem(this);
@@ -203,6 +204,8 @@
 
             this->setDestroyWhenPlayerLeft(false);
 
+            this->dropItems();
+
             if (this->getGametype())
                 this->getGametype()->pawnKilled(this, this->lastHitOriginator_);
 
@@ -265,7 +268,7 @@
 
     void Pawn::dropItems()
     {
-        ThrowException(NotImplemented, "Pickupsystem not implemented yet.");
+        this->getPickups().clear();
     }
 
     void Pawn::setWeaponSlot(WeaponSlot * wSlot)

Modified: branches/pickups/src/orxonox/objects/worldentities/pawns/Pawn.h
===================================================================
--- branches/pickups/src/orxonox/objects/worldentities/pawns/Pawn.h	2009-03-29 22:26:52 UTC (rev 2863)
+++ branches/pickups/src/orxonox/objects/worldentities/pawns/Pawn.h	2009-03-30 12:27:26 UTC (rev 2864)
@@ -33,6 +33,7 @@
 #include "objects/worldentities/ControllableEntity.h"
 #include "objects/RadarViewable.h"
 #include "objects/weaponSystem/WeaponSystem.h"
+#include "objects/pickup/PickupCollection.h"
 
 namespace orxonox
 {
@@ -106,6 +107,8 @@
                 { return this->numexplosionchunks_; }
 
             virtual void dropItems();
+            inline PickupCollection& getPickups()
+                { return this->pickups_; }
 
         protected:
             virtual void death();
@@ -114,6 +117,7 @@
 
             bool bAlive_;
 
+            PickupCollection pickups_;
 
             float health_;
             float maxHealth_;




More information about the Orxonox-commit mailing list