[Orxonox-commit 67] r2768 - in branches/miniprojects/src/orxonox: gamestates objects objects/gametypes objects/worldentities objects/worldentities/pawns

landauf at orxonox.net landauf at orxonox.net
Mon Mar 9 03:21:12 CET 2009


Author: landauf
Date: 2009-03-09 03:21:12 +0100 (Mon, 09 Mar 2009)
New Revision: 2768

Added:
   branches/miniprojects/src/orxonox/objects/Teamcolourable.cc
   branches/miniprojects/src/orxonox/objects/Teamcolourable.h
   branches/miniprojects/src/orxonox/objects/gametypes/TeamGametype.cc
   branches/miniprojects/src/orxonox/objects/gametypes/TeamGametype.h
   branches/miniprojects/src/orxonox/objects/worldentities/TeamSpawnPoint.cc
   branches/miniprojects/src/orxonox/objects/worldentities/TeamSpawnPoint.h
Modified:
   branches/miniprojects/src/orxonox/gamestates/GSLevel.cc
   branches/miniprojects/src/orxonox/objects/CMakeLists.txt
   branches/miniprojects/src/orxonox/objects/Level.cc
   branches/miniprojects/src/orxonox/objects/gametypes/CMakeLists.txt
   branches/miniprojects/src/orxonox/objects/gametypes/Gametype.cc
   branches/miniprojects/src/orxonox/objects/gametypes/Gametype.h
   branches/miniprojects/src/orxonox/objects/worldentities/Billboard.h
   branches/miniprojects/src/orxonox/objects/worldentities/CMakeLists.txt
   branches/miniprojects/src/orxonox/objects/worldentities/Light.h
   branches/miniprojects/src/orxonox/objects/worldentities/pawns/Pawn.cc
Log:
added TeamGametype

Modified: branches/miniprojects/src/orxonox/gamestates/GSLevel.cc
===================================================================
--- branches/miniprojects/src/orxonox/gamestates/GSLevel.cc	2009-03-09 00:12:39 UTC (rev 2767)
+++ branches/miniprojects/src/orxonox/gamestates/GSLevel.cc	2009-03-09 02:21:12 UTC (rev 2768)
@@ -48,7 +48,7 @@
 
 namespace orxonox
 {
-    SetCommandLineArgument(level, "presentation.oxw").shortcut("l");
+    SetCommandLineArgument(level, "presentation_dm.oxw").shortcut("l");
 
     GSLevel::GSLevel()
 //        : GameState<GSGraphics>(name)

Modified: branches/miniprojects/src/orxonox/objects/CMakeLists.txt
===================================================================
--- branches/miniprojects/src/orxonox/objects/CMakeLists.txt	2009-03-09 00:12:39 UTC (rev 2767)
+++ branches/miniprojects/src/orxonox/objects/CMakeLists.txt	2009-03-09 02:21:12 UTC (rev 2768)
@@ -7,6 +7,7 @@
   Radar.cc
   RadarListener.cc
   RadarViewable.cc
+  Teamcolourable.cc
   Tickable.cc
   Test.cc
   Scene.cc

Modified: branches/miniprojects/src/orxonox/objects/Level.cc
===================================================================
--- branches/miniprojects/src/orxonox/objects/Level.cc	2009-03-09 00:12:39 UTC (rev 2767)
+++ branches/miniprojects/src/orxonox/objects/Level.cc	2009-03-09 02:21:12 UTC (rev 2768)
@@ -104,19 +104,28 @@
     void Level::setGametypeString(const std::string& gametype)
     {
         Identifier* identifier = ClassByString(gametype);
-        if (identifier && identifier->isA(Class(Gametype)))
+
+        if (!identifier || !identifier->isA(Class(Gametype)))
         {
+            COUT(0) << "Error: \"" << gametype << "\" is not a valid gametype." << std::endl;
+            identifier = Class(Gametype);
+            this->gametype_ = "Gametype";
+        }
+        else
             this->gametype_ = gametype;
 
-            Gametype* rootgametype = dynamic_cast<Gametype*>(identifier->fabricate(this));
-            this->setGametype(rootgametype);
+std::cout << "Load Gametype: " << this->gametype_ << std::endl;
 
-            for (std::list<BaseObject*>::iterator it = this->objects_.begin(); it != this->objects_.end(); ++it)
-                (*it)->setGametype(rootgametype);
+        Gametype* rootgametype = dynamic_cast<Gametype*>(identifier->fabricate(this));
+        this->setGametype(rootgametype);
 
-            if (LevelManager::getInstancePtr())
-                LevelManager::getInstance().requestActivity(this);
-        }
+std::cout << "root gametype: " << rootgametype->getIdentifier()->getName() << std::endl;
+
+        for (std::list<BaseObject*>::iterator it = this->objects_.begin(); it != this->objects_.end(); ++it)
+            (*it)->setGametype(rootgametype);
+
+        if (LevelManager::getInstancePtr())
+            LevelManager::getInstance().requestActivity(this);
     }
 
 

Added: branches/miniprojects/src/orxonox/objects/Teamcolourable.cc
===================================================================
--- branches/miniprojects/src/orxonox/objects/Teamcolourable.cc	                        (rev 0)
+++ branches/miniprojects/src/orxonox/objects/Teamcolourable.cc	2009-03-09 02:21:12 UTC (rev 2768)
@@ -0,0 +1,39 @@
+/*
+ *   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:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+#include "Teamcolourable.h"
+#include "core/CoreIncludes.h"
+
+namespace orxonox
+{
+    Teamcolourable::Teamcolourable()
+    {
+        RegisterRootObject(Teamcolourable);
+    }
+}

Added: branches/miniprojects/src/orxonox/objects/Teamcolourable.h
===================================================================
--- branches/miniprojects/src/orxonox/objects/Teamcolourable.h	                        (rev 0)
+++ branches/miniprojects/src/orxonox/objects/Teamcolourable.h	2009-03-09 02:21:12 UTC (rev 2768)
@@ -0,0 +1,49 @@
+/*
+ *   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:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _Teamcolourable_H__
+#define _Teamcolourable_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include "util/Math.h"
+#include "core/OrxonoxClass.h"
+
+namespace orxonox
+{
+    class _OrxonoxExport Teamcolourable : virtual public OrxonoxClass
+    {
+        public:
+            virtual void setTeamColour(const ColourValue& colour) = 0;
+
+        protected:
+            Teamcolourable();
+    };
+}
+
+#endif /* _Teamcolourable_H__ */

Modified: branches/miniprojects/src/orxonox/objects/gametypes/CMakeLists.txt
===================================================================
--- branches/miniprojects/src/orxonox/objects/gametypes/CMakeLists.txt	2009-03-09 00:12:39 UTC (rev 2767)
+++ branches/miniprojects/src/orxonox/objects/gametypes/CMakeLists.txt	2009-03-09 02:21:12 UTC (rev 2768)
@@ -1,3 +1,4 @@
 ADD_SOURCE_FILES(ORXONOX_SRC_FILES
   Gametype.cc
+  TeamGametype.cc
 )

Modified: branches/miniprojects/src/orxonox/objects/gametypes/Gametype.cc
===================================================================
--- branches/miniprojects/src/orxonox/objects/gametypes/Gametype.cc	2009-03-09 00:12:39 UTC (rev 2767)
+++ branches/miniprojects/src/orxonox/objects/gametypes/Gametype.cc	2009-03-09 02:21:12 UTC (rev 2768)
@@ -65,8 +65,6 @@
 
         this->setConfigValues();
 
-        this->addBots(this->numberOfBots_);
-
         // load the corresponding score board
         if (Core::showsGraphics() && this->scoreboardTemplate_ != "")
         {
@@ -104,6 +102,8 @@
 
     void Gametype::start()
     {
+        this->addBots(this->numberOfBots_);
+
         COUT(0) << "game started" << std::endl;
         this->gtinfo_.bStarted_ = true;
 
@@ -167,6 +167,29 @@
     {
     }
 
+    void Gametype::playerPreSpawn(PlayerInfo* player)
+    {
+    }
+
+    void Gametype::playerPostSpawn(PlayerInfo* player)
+    {
+    }
+
+    bool Gametype::allowPawnHit(Pawn* victim, Pawn* originator)
+    {
+        return true;
+    }
+
+    bool Gametype::allowPawnDamage(Pawn* victim, Pawn* originator)
+    {
+        return true;
+    }
+
+    bool Gametype::allowPawnDeath(Pawn* victim, Pawn* originator)
+    {
+        return true;
+    }
+
     void Gametype::pawnKilled(Pawn* victim, Pawn* killer)
     {
         if (victim && victim->getPlayer())
@@ -335,8 +358,10 @@
         SpawnPoint* spawnpoint = this->getBestSpawnPoint(player);
         if (spawnpoint)
         {
+            this->playerPreSpawn(player);
             player->startControl(spawnpoint->spawn());
             this->players_[player].state_ = PlayerState::Alive;
+            this->playerPostSpawn(player);
         }
         else
         {

Modified: branches/miniprojects/src/orxonox/objects/gametypes/Gametype.h
===================================================================
--- branches/miniprojects/src/orxonox/objects/gametypes/Gametype.h	2009-03-09 00:12:39 UTC (rev 2767)
+++ branches/miniprojects/src/orxonox/objects/gametypes/Gametype.h	2009-03-09 02:21:12 UTC (rev 2768)
@@ -90,9 +90,15 @@
 
             virtual void playerScored(Player& player);
 
+            virtual bool allowPawnHit(Pawn* victim, Pawn* originator = 0);
+            virtual bool allowPawnDamage(Pawn* victim, Pawn* originator = 0);
+            virtual bool allowPawnDeath(Pawn* victim, Pawn* originator = 0);
+
             virtual void pawnKilled(Pawn* victim, Pawn* killer = 0);
             virtual void pawnPreSpawn(Pawn* pawn);
             virtual void pawnPostSpawn(Pawn* pawn);
+            virtual void playerPreSpawn(PlayerInfo* player);
+            virtual void playerPostSpawn(PlayerInfo* player);
 
             inline const std::map<PlayerInfo*, Player>& getPlayers() const
                 { return this->players_; }
@@ -111,7 +117,7 @@
             inline unsigned int getNumberOfPlayers() const
                 { return this->players_.size(); }
 
-        private:
+        protected:
             virtual SpawnPoint* getBestSpawnPoint(PlayerInfo* player) const;
 
             void addPlayer(PlayerInfo* player);

Added: branches/miniprojects/src/orxonox/objects/gametypes/TeamGametype.cc
===================================================================
--- branches/miniprojects/src/orxonox/objects/gametypes/TeamGametype.cc	                        (rev 0)
+++ branches/miniprojects/src/orxonox/objects/gametypes/TeamGametype.cc	2009-03-09 02:21:12 UTC (rev 2768)
@@ -0,0 +1,189 @@
+/*
+ *   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:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+#include "TeamGametype.h"
+
+#include "core/CoreIncludes.h"
+#include "core/ConfigValueIncludes.h"
+#include "objects/Teamcolourable.h"
+#include "objects/worldentities/TeamSpawnPoint.h"
+#include "objects/infos/PlayerInfo.h" // remove this
+
+namespace orxonox
+{
+    CreateUnloadableFactory(TeamGametype);
+
+    TeamGametype::TeamGametype(BaseObject* creator) : Gametype(creator)
+    {
+        RegisterObject(TeamGametype);
+
+        this->teams_ = 2;
+
+        this->setConfigValues();
+    }
+
+    void TeamGametype::setConfigValues()
+    {
+        SetConfigValue(teams_, 2);
+
+        static ColourValue colours[] =
+        {
+            ColourValue(1.0, 0.3, 0.3),
+            ColourValue(0.3, 0.3, 1.0),
+            ColourValue(0.3, 1.0, 0.3),
+            ColourValue(1.0, 1.0, 0.0)
+        };
+        static std::vector<ColourValue> defaultcolours(colours, colours + sizeof(colours) / sizeof(ColourValue));
+
+        SetConfigValueVector(teamcolours_, defaultcolours);
+    }
+
+    void TeamGametype::playerEntered(PlayerInfo* player)
+    {
+        Gametype::playerEntered(player);
+
+        std::vector<unsigned int> playersperteam(this->teams_, 0);
+
+        for (std::map<PlayerInfo*, int>::iterator it = this->teamnumbers_.begin(); it != this->teamnumbers_.end(); ++it)
+            if (it->second < this->teams_ && it->second >= 0)
+                playersperteam[it->second]++;
+
+        unsigned int minplayers = (unsigned int)-1;
+        size_t minplayersteam = 0;
+        for (size_t i = 0; i < this->teams_; ++i)
+        {
+            if (playersperteam[i] < minplayers)
+            {
+                minplayers = playersperteam[i];
+                minplayersteam = i;
+            }
+        }
+
+        this->teamnumbers_[player] = minplayersteam;
+    }
+
+    void TeamGametype::playerLeft(PlayerInfo* player)
+    {
+        Gametype::playerLeft(player);
+
+        this->players_.erase(player);
+    }
+
+    bool TeamGametype::allowPawnHit(Pawn* victim, Pawn* originator)
+    {
+        return (!this->pawnsAreInTheSameTeam(victim, originator));
+    }
+
+    bool TeamGametype::allowPawnDamage(Pawn* victim, Pawn* originator)
+    {
+        return (!this->pawnsAreInTheSameTeam(victim, originator));
+    }
+
+    bool TeamGametype::allowPawnDeath(Pawn* victim, Pawn* originator)
+    {
+        return (!this->pawnsAreInTheSameTeam(victim, originator));
+    }
+
+    SpawnPoint* TeamGametype::getBestSpawnPoint(PlayerInfo* player) const
+    {
+        int desiredTeamNr = -1;
+        std::map<PlayerInfo*, int>::const_iterator it_player = this->teamnumbers_.find(player);
+        if (it_player != this->teamnumbers_.end())
+            desiredTeamNr = it_player->second;
+
+        // Only use spawnpoints of the own team (or non-team-spawnpoints)
+        std::set<SpawnPoint*> teamSpawnPoints = this->spawnpoints_;
+        for (std::set<SpawnPoint*>::const_iterator it = teamSpawnPoints.begin(); it != teamSpawnPoints.end(); )
+        {
+            if ((*it)->isA(Class(TeamSpawnPoint)))
+            {
+                TeamSpawnPoint* tsp = dynamic_cast<TeamSpawnPoint*>(*it);
+                if (tsp && tsp->getTeamNumber() != desiredTeamNr)
+                {
+                    teamSpawnPoints.erase(it++);
+                    continue;
+                }
+            }
+
+            ++it;
+        }
+
+        if (teamSpawnPoints.size() > 0)
+        {
+            unsigned int randomspawn = (unsigned int)rnd(teamSpawnPoints.size());
+            unsigned int index = 0;
+            for (std::set<SpawnPoint*>::const_iterator it = teamSpawnPoints.begin(); it != teamSpawnPoints.end(); ++it)
+            {
+                if (index == randomspawn)
+                    return (*it);
+
+                ++index;
+            }
+        }
+
+        return 0;
+    }
+
+    void TeamGametype::playerPostSpawn(PlayerInfo* player)
+    {
+        if (!player)
+            return;
+
+        // Set the team colour
+        std::map<PlayerInfo*, int>::const_iterator it_player = this->teamnumbers_.find(player);
+        if (it_player != this->teamnumbers_.end() && it_player->second >= 0 && it_player->second < this->teamcolours_.size())
+        {
+            if (player->getControllableEntity())
+            {
+                std::set<WorldEntity*> pawnAttachments = player->getControllableEntity()->getAttachedObjects();
+                for (std::set<WorldEntity*>::iterator it = pawnAttachments.begin(); it != pawnAttachments.end(); ++it)
+                {
+                    if ((*it)->isA(Class(Teamcolourable)))
+                    {
+                        Teamcolourable* tc = dynamic_cast<Teamcolourable*>(*it);
+                        tc->setTeamColour(this->teamcolours_[it_player->second]);
+                    }
+                }
+            }
+        }
+    }
+
+    bool TeamGametype::pawnsAreInTheSameTeam(Pawn* pawn1, Pawn* pawn2)
+    {
+        if (pawn1 && pawn2)
+        {
+            std::map<PlayerInfo*, int>::const_iterator it1 = this->teamnumbers_.find(pawn1->getPlayer());
+            std::map<PlayerInfo*, int>::const_iterator it2 = this->teamnumbers_.find(pawn2->getPlayer());
+
+            if (it1 != this->teamnumbers_.end() && it2 != this->teamnumbers_.end())
+                return (it1->second == it2->second);
+        }
+        return false;
+    }
+}

Added: branches/miniprojects/src/orxonox/objects/gametypes/TeamGametype.h
===================================================================
--- branches/miniprojects/src/orxonox/objects/gametypes/TeamGametype.h	                        (rev 0)
+++ branches/miniprojects/src/orxonox/objects/gametypes/TeamGametype.h	2009-03-09 02:21:12 UTC (rev 2768)
@@ -0,0 +1,67 @@
+/*
+ *   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:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _TeamGametype_H__
+#define _TeamGametype_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include <vector>
+
+#include "Gametype.h"
+
+namespace orxonox
+{
+    class _OrxonoxExport TeamGametype : public Gametype
+    {
+        public:
+            TeamGametype(BaseObject* creator);
+            virtual ~TeamGametype() {}
+
+            void setConfigValues();
+
+            virtual void playerEntered(PlayerInfo* player);
+            virtual void playerLeft(PlayerInfo* player);
+
+            virtual bool allowPawnHit(Pawn* victim, Pawn* originator = 0);
+            virtual bool allowPawnDamage(Pawn* victim, Pawn* originator = 0);
+            virtual bool allowPawnDeath(Pawn* victim, Pawn* originator = 0);
+
+            virtual void playerPostSpawn(PlayerInfo* player);
+
+        protected:
+            virtual SpawnPoint* getBestSpawnPoint(PlayerInfo* player) const;
+            bool pawnsAreInTheSameTeam(Pawn* pawn1, Pawn* pawn2);
+
+            std::map<PlayerInfo*, int> teamnumbers_;
+            std::vector<ColourValue> teamcolours_;
+            unsigned int teams_;
+    };
+}
+
+#endif /* _TeamGametype_H__ */

Modified: branches/miniprojects/src/orxonox/objects/worldentities/Billboard.h
===================================================================
--- branches/miniprojects/src/orxonox/objects/worldentities/Billboard.h	2009-03-09 00:12:39 UTC (rev 2767)
+++ branches/miniprojects/src/orxonox/objects/worldentities/Billboard.h	2009-03-09 02:21:12 UTC (rev 2768)
@@ -33,10 +33,11 @@
 #include "StaticEntity.h"
 #include "util/Math.h"
 #include "tools/BillboardSet.h"
+#include "objects/Teamcolourable.h"
 
 namespace orxonox
 {
-    class _OrxonoxExport Billboard : public StaticEntity
+    class _OrxonoxExport Billboard : public StaticEntity, public Teamcolourable
     {
         public:
             Billboard(BaseObject* creator);
@@ -60,6 +61,9 @@
             inline const ColourValue& getColour() const
                 { return this->colour_; }
 
+            virtual void setTeamColour(const ColourValue& colour)
+                { this->setColour(colour); }
+
         protected:
             inline BillboardSet& getBillboardSet()
                 { return this->billboard_; }

Modified: branches/miniprojects/src/orxonox/objects/worldentities/CMakeLists.txt
===================================================================
--- branches/miniprojects/src/orxonox/objects/worldentities/CMakeLists.txt	2009-03-09 00:12:39 UTC (rev 2767)
+++ branches/miniprojects/src/orxonox/objects/worldentities/CMakeLists.txt	2009-03-09 02:21:12 UTC (rev 2768)
@@ -18,6 +18,7 @@
   ParticleSpawner.cc
   Planet.cc
   SpawnPoint.cc
+  TeamSpawnPoint.cc
 )
 
 ADD_SUBDIRECTORY(pawns)

Modified: branches/miniprojects/src/orxonox/objects/worldentities/Light.h
===================================================================
--- branches/miniprojects/src/orxonox/objects/worldentities/Light.h	2009-03-09 00:12:39 UTC (rev 2767)
+++ branches/miniprojects/src/orxonox/objects/worldentities/Light.h	2009-03-09 02:21:12 UTC (rev 2768)
@@ -36,10 +36,11 @@
 #include <OgreLight.h>
 
 #include "util/Math.h"
+#include "objects/Teamcolourable.h"
 
 namespace orxonox
 {
-    class _OrxonoxExport Light : public StaticEntity
+    class _OrxonoxExport Light : public StaticEntity, public Teamcolourable
     {
         public:
             Light(BaseObject* creator);
@@ -68,6 +69,9 @@
             inline const ColourValue& getSpecularColour() const
                 { return this->specular_; }
 
+            virtual void setTeamColour(const ColourValue& colour)
+                { this->setDiffuseColour(colour); this->setSpecularColour(colour); }
+
             /**
                 @brief Sets the attenuation parameters of the light source i.e. how it diminishes with distance.
 

Added: branches/miniprojects/src/orxonox/objects/worldentities/TeamSpawnPoint.cc
===================================================================
--- branches/miniprojects/src/orxonox/objects/worldentities/TeamSpawnPoint.cc	                        (rev 0)
+++ branches/miniprojects/src/orxonox/objects/worldentities/TeamSpawnPoint.cc	2009-03-09 02:21:12 UTC (rev 2768)
@@ -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:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+#include "TeamSpawnPoint.h"
+
+#include "core/CoreIncludes.h"
+#include "core/XMLPort.h"
+
+namespace orxonox
+{
+    CreateFactory(TeamSpawnPoint);
+
+    TeamSpawnPoint::TeamSpawnPoint(BaseObject* creator) : SpawnPoint(creator)
+    {
+        RegisterObject(TeamSpawnPoint);
+
+        this->teamNumber_ = 0;
+    }
+
+    void TeamSpawnPoint::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+    {
+        SUPER(TeamSpawnPoint, XMLPort, xmlelement, mode);
+
+        XMLPortParam(TeamSpawnPoint, "team", setTeamNumber, getTeamNumber, xmlelement, mode).defaultValues(0);
+    }
+}

Added: branches/miniprojects/src/orxonox/objects/worldentities/TeamSpawnPoint.h
===================================================================
--- branches/miniprojects/src/orxonox/objects/worldentities/TeamSpawnPoint.h	                        (rev 0)
+++ branches/miniprojects/src/orxonox/objects/worldentities/TeamSpawnPoint.h	2009-03-09 02:21:12 UTC (rev 2768)
@@ -0,0 +1,56 @@
+/*
+ *   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:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _TeamSpawnPoint_H__
+#define _TeamSpawnPoint_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include "SpawnPoint.h"
+
+namespace orxonox
+{
+    class _OrxonoxExport TeamSpawnPoint : public SpawnPoint
+    {
+        public:
+            TeamSpawnPoint(BaseObject* creator);
+            virtual ~TeamSpawnPoint() {}
+
+            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
+
+            void setTeamNumber(unsigned int team)
+                { this->teamNumber_ = team; }
+            unsigned int getTeamNumber() const
+                { return this->teamNumber_; }
+
+        private:
+            unsigned int teamNumber_;
+    };
+}
+
+#endif /* _TeamSpawnPoint_H__ */

Modified: branches/miniprojects/src/orxonox/objects/worldentities/pawns/Pawn.cc
===================================================================
--- branches/miniprojects/src/orxonox/objects/worldentities/pawns/Pawn.cc	2009-03-09 00:12:39 UTC (rev 2767)
+++ branches/miniprojects/src/orxonox/objects/worldentities/pawns/Pawn.cc	2009-03-09 02:21:12 UTC (rev 2768)
@@ -139,18 +139,24 @@
 
     void Pawn::damage(float damage, Pawn* originator)
     {
-        this->setHealth(this->health_ - damage);
-        this->lastHitOriginator_ = originator;
+        if (this->getGametype() && this->getGametype()->allowPawnDamage(this, originator))
+        {
+            this->setHealth(this->health_ - damage);
+            this->lastHitOriginator_ = originator;
 
-        // play damage effect
+            // play damage effect
+        }
     }
 
     void Pawn::hit(Pawn* originator, const Vector3& force, float damage)
     {
-        this->damage(damage, originator);
-        this->setVelocity(this->getVelocity() + force);
+        if (this->getGametype() && this->getGametype()->allowPawnHit(this, originator))
+        {
+            this->damage(damage, originator);
+            this->setVelocity(this->getVelocity() + force);
 
-        // play hit effect
+            // play hit effect
+        }
     }
 
     void Pawn::kill()
@@ -175,19 +181,24 @@
 
     void Pawn::death()
     {
-        // Set bAlive_ to false and wait for PawnManager to do the destruction
-        this->bAlive_ = false;
+        if (this->getGametype() && this->getGametype()->allowPawnDeath(this, this->lastHitOriginator_))
+        {
+            // Set bAlive_ to false and wait for PawnManager to do the destruction
+            this->bAlive_ = false;
 
-        this->setDestroyWhenPlayerLeft(false);
+            this->setDestroyWhenPlayerLeft(false);
 
-        if (this->getGametype())
-            this->getGametype()->pawnKilled(this, this->lastHitOriginator_);
+            if (this->getGametype())
+                this->getGametype()->pawnKilled(this, this->lastHitOriginator_);
 
-        if (this->getPlayer())
-            this->getPlayer()->stopControl(this);
+            if (this->getPlayer())
+                this->getPlayer()->stopControl(this);
 
-        if (Core::isMaster())
-            this->deatheffect();
+            if (Core::isMaster())
+                this->deatheffect();
+        }
+        else
+            this->setHealth(1);
     }
 
     void Pawn::deatheffect()




More information about the Orxonox-commit mailing list