[Orxonox-commit 2777] r7480 - in code/branches/lastmanstanding: data/levels src/orxonox/gametypes
jo at orxonox.net
jo at orxonox.net
Wed Sep 22 23:22:03 CEST 2010
Author: jo
Date: 2010-09-22 23:22:03 +0200 (Wed, 22 Sep 2010)
New Revision: 7480
Added:
code/branches/lastmanstanding/data/levels/gametype_lastmanstanding.oxw
code/branches/lastmanstanding/src/orxonox/gametypes/LastManStanding.cc
code/branches/lastmanstanding/src/orxonox/gametypes/LastManStanding.h
Modified:
code/branches/lastmanstanding/data/levels/empty_level.oxw
code/branches/lastmanstanding/src/orxonox/gametypes/CMakeLists.txt
Log:
initial upload
Modified: code/branches/lastmanstanding/data/levels/empty_level.oxw
===================================================================
--- code/branches/lastmanstanding/data/levels/empty_level.oxw 2010-09-22 20:47:28 UTC (rev 7479)
+++ code/branches/lastmanstanding/data/levels/empty_level.oxw 2010-09-22 21:22:03 UTC (rev 7480)
@@ -10,8 +10,9 @@
?>
<Level
- name = "Sample"
- description = "Just a few tests"
+ name = "Last Man Standing"
+ description = "testmap for gametype last man standing"
+ gametype = "LastManStanding"
>
<templates>
<Template link=lodtemplate_default />
@@ -24,6 +25,11 @@
<Light type=directional position="0,0,0" direction="0.253, 0.593, -0.765" diffuse="1.0, 0.9, 0.9, 1.0" specular="1.0, 0.9, 0.9, 1.0"/>
<SpawnPoint team=0 position="-200,0,0" lookat="0,0,0" spawnclass=SpaceShip pawndesign=spaceshipassff />
+ <SpawnPoint team=0 position="-200,200,0" lookat="0,0,0" spawnclass=SpaceShip pawndesign=spaceshipassff />
+ <SpawnPoint team=0 position="-200,0,200" lookat="0,0,0" spawnclass=SpaceShip pawndesign=spaceshipassff />
+ <SpawnPoint team=0 position="200,0,0" lookat="0,0,0" spawnclass=SpaceShip pawndesign=spaceshipassff />
+ <SpawnPoint team=0 position="200,200,0" lookat="0,0,0" spawnclass=SpaceShip pawndesign=spaceshipassff />
+ <SpawnPoint team=0 position="200,0,200" lookat="0,0,0" spawnclass=SpaceShip pawndesign=spaceshipassff />
</Scene>
</Level>
Added: code/branches/lastmanstanding/data/levels/gametype_lastmanstanding.oxw
===================================================================
--- code/branches/lastmanstanding/data/levels/gametype_lastmanstanding.oxw (rev 0)
+++ code/branches/lastmanstanding/data/levels/gametype_lastmanstanding.oxw 2010-09-22 21:22:03 UTC (rev 7480)
@@ -0,0 +1,36 @@
+<?lua
+ include("stats.oxo")
+ include("hudtemplates3.oxo")
+ include("templates/lodinformation.oxt")
+?>
+
+<?lua
+ include("templates/spaceship_assff.oxt")
+ include("templates/spaceship_pirate.oxt")
+?>
+
+<Level
+ name = "Last Man Standing"
+ description = "testmap for gametype last man standing"
+ gametype = "LastManStanding"
+>
+ <templates>
+ <Template link=lodtemplate_default />
+ </templates>
+
+ <Scene
+ ambientlight = "0.8, 0.8, 0.8"
+ skybox = "Orxonox/Starbox"
+ >
+
+ <Light type=directional position="0,0,0" direction="0.253, 0.593, -0.765" diffuse="1.0, 0.9, 0.9, 1.0" specular="1.0, 0.9, 0.9, 1.0"/>
+ <SpawnPoint team=0 position="-200,0,0" lookat="0,0,0" spawnclass=SpaceShip pawndesign=spaceshipassff />
+ <SpawnPoint team=0 position="-200,200,0" lookat="0,0,0" spawnclass=SpaceShip pawndesign=spaceshipassff />
+ <SpawnPoint team=0 position="-200,0,200" lookat="0,0,0" spawnclass=SpaceShip pawndesign=spaceshipassff />
+ <SpawnPoint team=0 position="200,0,0" lookat="0,0,0" spawnclass=SpaceShip pawndesign=spaceshipassff />
+ <SpawnPoint team=0 position="200,200,0" lookat="0,0,0" spawnclass=SpaceShip pawndesign=spaceshipassff />
+ <SpawnPoint team=0 position="200,0,200" lookat="0,0,0" spawnclass=SpaceShip pawndesign=spaceshipassff />
+
+ </Scene>
+</Level>
+
Modified: code/branches/lastmanstanding/src/orxonox/gametypes/CMakeLists.txt
===================================================================
--- code/branches/lastmanstanding/src/orxonox/gametypes/CMakeLists.txt 2010-09-22 20:47:28 UTC (rev 7479)
+++ code/branches/lastmanstanding/src/orxonox/gametypes/CMakeLists.txt 2010-09-22 21:22:03 UTC (rev 7480)
@@ -6,4 +6,5 @@
UnderAttack.cc
Asteroids.cc
Dynamicmatch.cc
+ LastManStanding.cc
)
Added: code/branches/lastmanstanding/src/orxonox/gametypes/LastManStanding.cc
===================================================================
--- code/branches/lastmanstanding/src/orxonox/gametypes/LastManStanding.cc (rev 0)
+++ code/branches/lastmanstanding/src/orxonox/gametypes/LastManStanding.cc 2010-09-22 21:22:03 UTC (rev 7480)
@@ -0,0 +1,298 @@
+/*
+ * 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:
+ * Johannes Ritz
+ * Co-authors:
+ * ...
+ *
+ */
+//Haupt-Problem: Wie kann ich Spieler vom Spiel ausschliessen, wenn sie alle Leben verlohren haben? (Kann man respawn unterbinden?)
+//PfuschAmBau1: Spieler wird unsichtbar und kann keinen Schaden austeilen, aber: setradarinvisibility funktioniert scheinbar nicht
+//Lösungsidee2: Spieler werden als passive Drohnen respawned, wenn sie keine Leben mehr haben (noch nicht implementiert)
+//
+#include "LastManStanding.h"
+
+#include "core/CoreIncludes.h"
+#include "network/Host.h"
+#include "infos/PlayerInfo.h"
+#include "worldentities/pawns/Pawn.h"
+#include "core/ConfigValueIncludes.h"
+
+namespace orxonox
+{
+ CreateUnloadableFactory(LastManStanding);
+
+ LastManStanding::LastManStanding(BaseObject* creator) : Gametype(creator)
+ {
+ RegisterObject(LastManStanding);
+ this->bForceSpawn_=true;
+ this->lives=2;
+ this->playersAlive=0;
+ this->timeRemaining=20.0f;
+ }
+
+ void LastManStanding::setConfigValues()
+ {
+ SetConfigValue(lives, 2);
+ }
+
+ bool LastManStanding::allowPawnHit(Pawn* victim, Pawn* originator)
+ {
+ if (originator && originator->getPlayer())// only for safety
+ {
+ if(playerLives_[originator->getPlayer()]< 0) //dead players shouldn't be able to hit any pawn
+ return false;
+ }
+ return true;
+ }
+
+ bool LastManStanding::allowPawnDamage(Pawn* victim, Pawn* originator)
+ {
+ if (originator && originator->getPlayer())// only for safety
+ {
+ this->timeToAct_[originator->getPlayer()]=timeRemaining;
+ if(playerLives_[originator->getPlayer()]< 0) //dead players shouldn't be able to damage any pawn
+ return false;
+ }
+
+ return true;
+ }
+
+ bool LastManStanding::allowPawnDeath(Pawn* victim, Pawn* originator)
+ {
+ if (!victim)// only for safety
+ return true;
+ playerLives_[victim->getPlayer()]--;
+ if (!playerLives_[victim->getPlayer()])//if player lost all lives
+ {
+ this->playersAlive--;
+ const std::string& message = victim->getPlayer()->getName() + " has lost all lives";
+ COUT(0) << message << std::endl;
+ Host::Broadcast(message);
+ }
+ return true;
+ }
+
+ void LastManStanding::start()
+ {
+ Gametype::start();
+
+ std::string message("Try to survive!");
+ COUT(0) << message << std::endl;
+ Host::Broadcast(message);
+ }
+
+ void LastManStanding::end()
+ {
+ Gametype::end();
+
+ for (std::map<PlayerInfo*, int>::iterator it = this->playerLives_.begin(); it != this->playerLives_.end(); ++it)
+ {
+ if (it->first->getClientID() == CLIENTID_UNKNOWN)
+ continue;
+
+ if (it->second > 0)
+ this->gtinfo_->sendAnnounceMessage("You have won the match!", it->first->getClientID());
+ else
+ this->gtinfo_->sendAnnounceMessage("You have lost the match!", it->first->getClientID());
+ }
+ }
+
+ void LastManStanding::playerEntered(PlayerInfo* player)
+ {
+ if (!player)// only for safety
+ return;
+ Gametype::playerEntered(player);
+
+ playerLives_[player]=lives;
+ this->playersAlive++;
+ this->timeToAct_[player]=timeRemaining;
+ const std::string& message = player->getName() + " entered the game";
+ COUT(0) << message << std::endl;
+ Host::Broadcast(message);
+ }
+
+ bool LastManStanding::playerLeft(PlayerInfo* player)
+ {
+ bool valid_player = Gametype::playerLeft(player);
+
+ if (valid_player)
+ {
+ this->playersAlive--;
+ //this->playerLives_[player].erase (player); not necessary?
+ //
+ const std::string& message = player->getName() + " left the game";
+ COUT(0) << message << std::endl;
+ Host::Broadcast(message);
+ }
+
+ return valid_player;
+ }
+
+ bool LastManStanding::playerChangedName(PlayerInfo* player)
+ {
+ bool valid_player = Gametype::playerChangedName(player);
+
+ if (valid_player)
+ {
+ const std::string& message = player->getOldName() + " changed name to " + player->getName();
+ COUT(0) << message << std::endl;
+ Host::Broadcast(message);
+ }
+
+ return valid_player;
+ }
+
+ void LastManStanding::playerStartsControllingPawn(PlayerInfo* player, Pawn* pawn)//makes dead players invisible
+ {
+ if (playerLives_[pawn->getPlayer()]<=0)//if player is dead
+ {
+ pawn->setVisible(false);
+ pawn->setRadarVisibility(false);
+ //removePlayer(pawn->getPlayer());
+ }
+ }
+ void LastManStanding::pawnPostSpawn(Pawn* pawn)
+ {/*
+ if (playerLives_[pawn->getPlayer()]<=0)//if player is dead
+ {
+ pawn->setVisible(false); --->Seltsames Verhalten, wenn diese Zeile aktiv ist
+ pawn->setRadarVisibility(false);
+ } */
+ }
+
+ void LastManStanding::pawnKilled(Pawn* victim, Pawn* killer)
+ {
+ if (victim && victim->getPlayer())
+ {
+ std::string message;
+ if (killer)
+ {
+ if (killer->getPlayer())
+ message = victim->getPlayer()->getName() + " was killed by " + killer->getPlayer()->getName();
+ else
+ message = victim->getPlayer()->getName() + " was killed";
+ }
+ else
+ message = victim->getPlayer()->getName() + " died";
+
+ COUT(0) << message << std::endl;
+ Host::Broadcast(message);
+ }
+
+ Gametype::pawnKilled(victim, killer);
+ }
+
+ const int LastManStanding::playerGetLives(PlayerInfo* player)
+ {
+ if (player)
+ return playerLives_[player];
+ else
+ return 0;
+ }
+
+ void LastManStanding::killPlayer(PlayerInfo* player)
+ {
+ if(!player)
+ return;
+ std::map<PlayerInfo*, Player>::iterator it = this->players_.find(player);
+ if (it != this->players_.end())
+ {
+ it->second.state_ = PlayerState::Dead;//-------------killpart
+ it->second.killed_++;
+
+ playerLives_[player]--;//-----------datapart
+ if (!playerLives_[player])//if player lost all lives
+ {
+ this->playersAlive--;
+ const std::string& message = player->getName() + " has lost all lives";
+ COUT(0) << message << std::endl;
+ Host::Broadcast(message);
+ }
+ /*
+ ControllableEntity* entity = this->defaultControllableEntity_.fabricate(victim->getCreator());
+ if (victim->getCamera())
+ {
+ entity->setPosition(victim->getCamera()->getWorldPosition());
+ entity->setOrientation(victim->getCamera()->getWorldOrientation());
+ }
+ else
+ {
+ entity->setPosition(victim->getWorldPosition());
+ entity->setOrientation(victim->getWorldOrientation());
+ }
+ it->first->startControl(entity);*/
+ }
+ }
+
+
+ void LastManStanding::tick(float dt)
+ {
+ SUPER(LastManStanding, tick, dt);
+ if(!this->hasEnded())
+ {
+ if ((this->hasStarted()&&(playersAlive==1)))//last player remaining
+ {
+ this->end();
+ }
+ for (std::map<PlayerInfo*, float>::iterator it = this->timeToAct_.begin(); it != this->timeToAct_.end(); ++it)
+ {
+ it->second-=dt;
+ if (it->second<0.0f)
+ {
+ it->second=timeRemaining+3.0f;
+ this->killPlayer(it->first);
+ }
+ }
+ }
+ }
+
+ /*void LastManStanding::removePlayer(PlayerInfo* player) //----------> Dieser Versuch führt zu einem Programmabsturz
+ {
+ std::map<PlayerInfo*, Player>::const_iterator it = this->players_.find(player);
+ if (it != this->players_.end())
+ {
+ if (it->first->getControllableEntity())
+ {
+ ControllableEntity* oldentity = it->first->getControllableEntity();
+
+ ControllableEntity* entity = this->defaultControllableEntity_.fabricate(oldentity);
+ if (oldentity->getCamera())
+ {
+ entity->setPosition(oldentity->getCamera()->getWorldPosition());
+ entity->setOrientation(oldentity->getCamera()->getWorldOrientation());
+ }
+ else
+ {
+ entity->setPosition(oldentity->getWorldPosition());
+ entity->setOrientation(oldentity->getWorldOrientation());
+ }
+
+ it->first->startControl(entity);
+ }
+ else
+ this->spawnPlayerAsDefaultPawn(it->first);
+ }
+
+ }*/
+
+}
Added: code/branches/lastmanstanding/src/orxonox/gametypes/LastManStanding.h
===================================================================
--- code/branches/lastmanstanding/src/orxonox/gametypes/LastManStanding.h (rev 0)
+++ code/branches/lastmanstanding/src/orxonox/gametypes/LastManStanding.h 2010-09-22 21:22:03 UTC (rev 7480)
@@ -0,0 +1,89 @@
+/*
+ * 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:
+ * Johannes Ritz
+ * Co-authors:
+ * ...
+ *
+ */
+/**
+ @file LastManStanding.h
+ @brief Declaration of the Gametype "Last Man Standing".
+*/
+/* BY THE WAY
+//You have to add bots (or any other further players) before actually starting a match.
+//Whenever there is only on player in the game, this player will be declared as winner.
+//How "death" is managed: Death players become invisivle and aren't allowed to damage any player.
+//Though they can recieve damage and they are not invisible on the radar-
+*/
+#ifndef _LastManStanding_H__
+#define _LastManStanding_H__
+
+#include "OrxonoxPrereqs.h"
+#include "Gametype.h"
+#include <map>
+#include <vector>
+
+namespace orxonox
+{
+ class _OrxonoxExport LastManStanding : public Gametype
+ {
+ /**
+ @brief
+ Last Man Standing is a gametype where each player fights against each other, until one player remains.
+ @author
+ Johannes Ritz
+ */
+ protected:
+ int lives; //!< Standard amount of lives.
+ std::map< PlayerInfo*, int > playerLives_; //!< Each player's lives are stored here.
+ int playersAlive; //!< Counter counting players with more than 0 lives.
+ float timeRemaining; //!< Each player has a certain time where he or she has to hit an opponent or will be punished.
+ std::map<PlayerInfo*, float> timeToAct_; //!< Each player's time till she/he will be punished is stored here.
+
+ public:
+ LastManStanding(BaseObject* creator); //!< Default Constructor.
+ virtual ~LastManStanding() {} //!< Default Destructor.
+ void setConfigValues(); //!< Makes values configurable.
+
+ virtual bool allowPawnHit(Pawn* victim, Pawn* originator = 0); //!< Prevents hits by players with no lives.
+ virtual bool allowPawnDamage(Pawn* victim, Pawn* originator = 0); //!< If a player shoot's an opponet, his punishment countdown will be resetted. Prevents damage by players with no lives.
+ virtual bool allowPawnDeath(Pawn* victim, Pawn* originator = 0); //!< Manages each lives.
+
+ virtual void start(); //!< Sends a start message.
+ virtual void end(); //!< Sends an end message.
+ virtual void playerEntered(PlayerInfo* player);
+ virtual bool playerLeft(PlayerInfo* player);
+ virtual bool playerChangedName(PlayerInfo* player);
+
+ virtual void playerStartsControllingPawn(PlayerInfo* player, Pawn* pawn);//makes dead players invisible
+ virtual void pawnPostSpawn(Pawn* pawn); //just for test case
+ virtual void pawnKilled(Pawn* victim, Pawn* killer = 0);
+
+ const int playerGetLives(PlayerInfo* player);
+ void killPlayer(PlayerInfo* player);
+ //void removePlayer(PlayerInfo* player);
+ void tick (float dt);// used to end the game
+ };
+}
+
+#endif /* _LastManStanding_H__ */
More information about the Orxonox-commit
mailing list