[Orxonox-commit 2782] r7485 - code/branches/lastmanstanding/src/orxonox/gametypes
jo at orxonox.net
jo at orxonox.net
Thu Sep 23 23:22:22 CEST 2010
Author: jo
Date: 2010-09-23 23:22:22 +0200 (Thu, 23 Sep 2010)
New Revision: 7485
Modified:
code/branches/lastmanstanding/src/orxonox/gametypes/LastManStanding.cc
code/branches/lastmanstanding/src/orxonox/gametypes/LastManStanding.h
Log:
Last Man Standing already works basically. All game rules are implemented and seem to work as intended.
Modified: code/branches/lastmanstanding/src/orxonox/gametypes/LastManStanding.cc
===================================================================
--- code/branches/lastmanstanding/src/orxonox/gametypes/LastManStanding.cc 2010-09-23 11:00:42 UTC (rev 7484)
+++ code/branches/lastmanstanding/src/orxonox/gametypes/LastManStanding.cc 2010-09-23 21:22:22 UTC (rev 7485)
@@ -25,10 +25,7 @@
* ...
*
*/
-//Haupt-Problem: Wie kann ich Spieler vom Spiel ausschliessen, wenn sie alle Leben verlohren haben? (Kann man respawn unterbinden?)
-//Aktuelle Notloesung: 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"
@@ -45,33 +42,22 @@
{
RegisterObject(LastManStanding);
this->bForceSpawn_=true;
- this->lives=2;
+ this->lives=4;
this->playersAlive=0;
this->timeRemaining=20.0f;
}
void LastManStanding::setConfigValues()
{
- SetConfigValue(lives, 2);
+ SetConfigValue(lives, 4);
+ SetConfigValue(timeRemaining, 20.0f);
}
- 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;
@@ -162,24 +148,6 @@
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())
@@ -228,19 +196,6 @@
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);*/
}
}
@@ -266,33 +221,15 @@
}
}
- /*void LastManStanding::removePlayer(PlayerInfo* player) //----------> Dieser Versuch führt zu einem Programmabsturz
+ void LastManStanding::spawnDeadPlayersIfRequested()
{
- std::map<PlayerInfo*, Player>::const_iterator it = this->players_.find(player);
- if (it != this->players_.end())
- {
- if (it->first->getControllableEntity())
+ for (std::map<PlayerInfo*, Player>::iterator it = this->players_.begin(); it != this->players_.end(); ++it)
+ if (it->second.state_ == PlayerState::Dead)
{
- ControllableEntity* oldentity = it->first->getControllableEntity();
+ bool alive = (0<playerLives_[it->first]);
+ if (alive&&(it->first->isReadyToSpawn() || this->bForceSpawn_))
+ this->spawnPlayer(it->first);
+ }
+ }
- 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);
- }
-
- }*/
-
}
Modified: code/branches/lastmanstanding/src/orxonox/gametypes/LastManStanding.h
===================================================================
--- code/branches/lastmanstanding/src/orxonox/gametypes/LastManStanding.h 2010-09-23 11:00:42 UTC (rev 7484)
+++ code/branches/lastmanstanding/src/orxonox/gametypes/LastManStanding.h 2010-09-23 21:22:22 UTC (rev 7485)
@@ -30,10 +30,10 @@
@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.
+//!You have to ADD BOTS (or any other further players) BEFORE actually starting a match!
+//Maybe a warning should be added in the menu, if a player starts a Last Man Standing match alone.
//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-
+//How "death" is managed: dead players cannot respawn.
*/
#ifndef _LastManStanding_H__
#define _LastManStanding_H__
@@ -54,19 +54,19 @@
Johannes Ritz
*/
protected:
- int lives; //!< Standard amount of lives.
+ int lives; //!< Standard amount of lives. Each player starts a game with so many 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.
+ virtual void spawnDeadPlayersIfRequested();
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 allowPawnDamage(Pawn* victim, Pawn* originator = 0); //!< If a player shoot's an opponet, his punishment countdown will be resetted.
virtual bool allowPawnDeath(Pawn* victim, Pawn* originator = 0); //!< Manages each lives.
virtual void start(); //!< Sends a start message.
@@ -75,13 +75,10 @@
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
};
}
More information about the Orxonox-commit
mailing list