[Orxonox-commit 2902] r7605 - in code/branches/lastmanstanding: data/levels src/orxonox/gametypes
jo at orxonox.net
jo at orxonox.net
Tue Nov 2 22:34:08 CET 2010
Author: jo
Date: 2010-11-02 22:34:07 +0100 (Tue, 02 Nov 2010)
New Revision: 7605
Modified:
code/branches/lastmanstanding/data/levels/gametype_lastmanstanding.oxw
code/branches/lastmanstanding/src/orxonox/gametypes/LastManStanding.cc
code/branches/lastmanstanding/src/orxonox/gametypes/LastManStanding.h
Log:
Various successful changes. But the part I commented out in punishPlayer(PlayerInfo* player) causes crashes.
Modified: code/branches/lastmanstanding/data/levels/gametype_lastmanstanding.oxw
===================================================================
--- code/branches/lastmanstanding/data/levels/gametype_lastmanstanding.oxw 2010-10-31 21:47:07 UTC (rev 7604)
+++ code/branches/lastmanstanding/data/levels/gametype_lastmanstanding.oxw 2010-11-02 21:34:07 UTC (rev 7605)
@@ -5,6 +5,7 @@
include("lastmanstandinghud.oxo")
include("templates/spaceship_assff.oxt")
include("templates/spaceship_pirate.oxt")
+ include("templates/pickup_representation_templates.oxt")
?>
<Level
@@ -20,14 +21,19 @@
ambientlight = "0.8, 0.8, 0.8"
skybox = "Orxonox/skypanoramagen1"
>
-<!----- Spawnpoints ----->
+
+ <?lua
+ include("includes/pickups.oxi")
+ ?>
+
+<!----- Spawnpoints
<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="-1150,0,0" lookat="0,0,0" spawnclass=SpaceShip pawndesign=spaceshipassff />
<SpawnPoint team=0 position="1150,0,0" lookat="0,0,0" spawnclass=SpaceShip pawndesign=spaceshipassff />
<SpawnPoint team=0 position="-700,0,700" lookat="0,0,0" spawnclass=SpaceShip pawndesign=spaceshipassff />
<SpawnPoint team=0 position="700,0,-700" lookat="0,0,0" spawnclass=SpaceShip pawndesign=spaceshipassff />
<SpawnPoint team=0 position="0,0,-1150" lookat="0,0,0" spawnclass=SpaceShip pawndesign=spaceshipassff />
- <SpawnPoint team=0 position="0,0,1150" lookat="0,0,0" spawnclass=SpaceShip pawndesign=spaceshipassff />
+ <SpawnPoint team=0 position="0,0,1150" lookat="0,0,0" spawnclass=SpaceShip pawndesign=spaceshipassff /> ----->
<Bot />
<!-- ------------ middle asteroid -------------- -->
@@ -40,12 +46,23 @@
<SphereCollisionShape radius="145" />
</collisionShapes>
</StaticEntity>
-<!--StaticEntity position="0,0,0" collisionType=static>
- <collisionShapes>
- <SphereCollisionShape radius="145" />
- </collisionShapes>
- </StaticEntity-->
+ <PickupSpawner position="-160,65,10" triggerDistance="10" respawnTime="5" maxSpawnedItems="10"><!--EasterEgg-->
+ <pickup>
+ <InvisiblePickup template=mediuminvisiblepickup />
+ </pickup>
+ </PickupSpawner>
+ <PickupSpawner position="-160,60,17" triggerDistance="10" respawnTime="5" maxSpawnedItems="10"><!--EasterEgg-->
+ <pickup>
+ <InvisiblePickup template=hugeinvisiblepickup />
+ </pickup>
+ </PickupSpawner>
+ <StaticEntity position="-160,60,28.4"><!--EasterEgg-Indicator-->
+ <attached>
+ <Model position="0,0,0" scale=1 mesh="sphere.mesh" />
+ </attached>
+ </StaticEntity>
+
<!-- ---------------asteroid dome----------------- -->
<?lua
max = 17
@@ -53,7 +70,6 @@
do
y = math.sin(i/max*6)*750
z = math.cos(i/max*6)*750
- x = i*10
?>
<?lua
for k = 1, 17, 1
@@ -61,9 +77,8 @@
j = math.random()
?>
+ <SpawnPoint team=0 position="<?lua print(y*1.4+z*0.2) ?>,0,<?lua print(z*1.4-y*0.2) ?>" lookat="0,0,0" spawnclass=SpaceShip pawndesign=spaceshipassff />
- <!--SpawnPoint team=0 position="<?lua print(y*1.4) ?>,0,<?lua print(z*1.4) ?>" spawnclass=SpaceShip pawndesign=spaceshipassff /-->
-
<StaticEntity position="<?lua print(y) ?>,0,<?lua print(z) ?>" scale=<?lua print(j * 2) ?> collisionType=static >
<attached>
<Model position="0,0,0" scale=15 mesh="ast<?lua print( math.mod(i,6) + 1) ?>.mesh">
@@ -82,7 +97,7 @@
<collisionShapes>
<BoxCollisionShape halfExtents="45,100,45" position = "0,0,0" />
</collisionShapes>
- </StaticEntity>#
+ </StaticEntity>
<StaticEntity position="<?lua print(y) ?>,200,<?lua print(z) ?>" scale=<?lua print(j * 2) ?> collisionType=static >
<attached>
@@ -115,7 +130,6 @@
</StaticEntity>
<!-- ---------Top Asteroid----------- -->
-
<StaticEntity position="<?lua print(y) ?>,300,<?lua print(z) ?>" scale=<?lua print(j * 2.1) ?> pitch="90" roll="180" yaw="<?lua print(-90+i*360/max) ?>" collisionType=static >
<attached>
<Model position="0,0,0" scale=25 mesh="ast6.mesh">
@@ -127,15 +141,11 @@
</StaticEntity>
-
<?lua
end
?>
<?lua end ?>
-
-
-
</Scene>
</Level>
Modified: code/branches/lastmanstanding/src/orxonox/gametypes/LastManStanding.cc
===================================================================
--- code/branches/lastmanstanding/src/orxonox/gametypes/LastManStanding.cc 2010-10-31 21:47:07 UTC (rev 7604)
+++ code/branches/lastmanstanding/src/orxonox/gametypes/LastManStanding.cc 2010-11-02 21:34:07 UTC (rev 7605)
@@ -34,7 +34,7 @@
#include "worldentities/pawns/Pawn.h"
#include "core/ConfigValueIncludes.h"
#include "util/Convert.h"
-//TODO: respawn delay
+
namespace orxonox
{
CreateUnloadableFactory(LastManStanding);
@@ -47,6 +47,9 @@
this->playersAlive=0;
this->timeRemaining=15.0f;
this->respawnDelay=4.0f;
+ this->noPunishment=false;
+ this->hardPunishment=false;
+ this->punishDamageRate=0.4f;
this->setHUDTemplate("LastmanstandingHUD");
}
@@ -83,6 +86,8 @@
SetConfigValue(lives, 4);
SetConfigValue(timeRemaining, 15.0f);
SetConfigValue(respawnDelay, 4.0f);
+ SetConfigValue(noPunishment, false);
+ SetConfigValue(hardPunishment, false);
}
bool LastManStanding::allowPawnDamage(Pawn* victim, Pawn* originator)
@@ -90,6 +95,15 @@
if (originator && originator->getPlayer())// only for safety
{
this->timeToAct_[originator->getPlayer()]=timeRemaining;
+
+ std::map<PlayerInfo*, Player>::iterator it = this->players_.find(originator->getPlayer());
+ if (it != this->players_.end())
+ {
+ if (it->first->getClientID()== CLIENTID_UNKNOWN)
+ return true;
+ const std::string& message = ""; // set blank - erases Camper-Warning-message
+ this->gtinfo_->sendFadingMessage(message,it->first->getClientID());
+ }
}
return true;
}
@@ -110,6 +124,19 @@
return true;
}
+ int LastManStanding::getMinLives()
+ {
+ int min=lives;
+ for (std::map<PlayerInfo*, int>::iterator it = this->playerLives_.begin(); it != this->playerLives_.end(); ++it)
+ {
+ if (it->second<=0)
+ continue;
+ if (it->second<lives)
+ min=it->second;
+ }
+ return min;
+ }
+
void LastManStanding::end()
{
Gametype::end();
@@ -126,13 +153,16 @@
}
}
+
void LastManStanding::playerEntered(PlayerInfo* player)
{
if (!player)// only for safety
return;
Deathmatch::playerEntered(player);
-
- playerLives_[player]=lives;
+ if (playersAlive<=1)
+ playerLives_[player]=lives;
+ else
+ playerLives_[player]=getMinLives();//new players only get minimum of lives
this->playersAlive++;
this->timeToAct_[player]=timeRemaining;
this->playerDelayTime_[player]=respawnDelay;
@@ -153,7 +183,9 @@
if (valid_player)
{
this->playersAlive--;
- //this->playerLives_[player].erase (player); not necessary?
+ this->playerLives_.erase (player);
+ this->playerDelayTime_.erase (player);
+ this->inGame_.erase (player);
//Update: EachPlayer's "Players in Game"-HUD
for (std::map<PlayerInfo*, Player>::iterator it = this->players_.begin(); it != this->players_.end(); ++it)
{
@@ -206,23 +238,34 @@
return 0;
}
- void LastManStanding::killPlayer(PlayerInfo* player)
+ void LastManStanding::punishPlayer(PlayerInfo* player)
{
if(!player)
return;
+ if(noPunishment)
+ return;
std::map<PlayerInfo*, Player>::iterator it = this->players_.find(player);
if (it != this->players_.end())
{
if(!player->getControllableEntity())
- {return;}
+ return;
Pawn* pawn = dynamic_cast<Pawn*>(player->getControllableEntity());
if(!pawn)
- {return;}
- pawn->kill();
- this->timeToAct_[player]=timeRemaining+3.0f+respawnDelay;//reset timer
+ return;
+ if(hardPunishment)
+ {
+ pawn->kill();
+ this->timeToAct_[player]=timeRemaining+3.0f+respawnDelay;//reset timer
+ }
+ /*else
+ {
+ float damage=pawn->getMaxHealth()*punishDamageRate*0.5;
+ pawn->removeHealth(damage);
+ this->timeToAct_[player]=timeRemaining;//reset timer
+ }*/
}
}
-
+
void LastManStanding::tick(float dt)
{
SUPER(LastManStanding, tick, dt);
@@ -230,7 +273,7 @@
{
if ((this->hasStarted()&&(playersAlive<=1)))//last player remaining
{
- this->end();
+ this->end();
}
for (std::map<PlayerInfo*, float>::iterator it = this->timeToAct_.begin(); it != this->timeToAct_.end(); ++it)
{
@@ -242,14 +285,20 @@
playerDelayTime_[it->first]-=dt;
if (playerDelayTime_[it->first]<=0)
this->inGame_[it->first]=true;
+
+ if (it->first->getClientID()== CLIENTID_UNKNOWN)
+ continue;
+ int output=1+playerDelayTime_[it->first];
+ const std::string& message = "Respawn in " +multi_cast<std::string>(output)+ " seconds." ;//Countdown
+ this->gtinfo_->sendFadingMessage(message,it->first->getClientID());
}
else if (it->second<0.0f)
{
it->second=timeRemaining+3.0f;//reset punishment-timer
if (playerGetLives(it->first)>0)
- this->killPlayer(it->first);
+ this->punishPlayer(it->first);
}
- else if (it->second<timeRemaining/6)//Warning message
+ else if (it->second<timeRemaining/5)//Warning message
{
if (it->first->getClientID()== CLIENTID_UNKNOWN)
continue;
Modified: code/branches/lastmanstanding/src/orxonox/gametypes/LastManStanding.h
===================================================================
--- code/branches/lastmanstanding/src/orxonox/gametypes/LastManStanding.h 2010-10-31 21:47:07 UTC (rev 7604)
+++ code/branches/lastmanstanding/src/orxonox/gametypes/LastManStanding.h 2010-11-02 21:34:07 UTC (rev 7605)
@@ -57,7 +57,11 @@
float respawnDelay;
std::map<PlayerInfo*, float> playerDelayTime_; //!< Stores each Player's delay time.
std::map<PlayerInfo*, bool> inGame_; //!< Indicates each Player's state.
- virtual void spawnDeadPlayersIfRequested(); //!< Prevents dead players to respawn
+ bool noPunishment;
+ bool hardPunishment;
+ float punishDamageRate;
+ virtual void spawnDeadPlayersIfRequested(); //!< Prevents dead players to respawn.
+ virtual int getMinLives(); //!< Returns minimum of each player's lives; players with 0 lives are skipped;
public:
LastManStanding(BaseObject* creator); //!< Default Constructor.
@@ -74,7 +78,7 @@
virtual void playerStopsControllingPawn(PlayerInfo* player, Pawn* pawn); //!< Manages the gametype's HUD. #Players alive via StaticMessage.
const int playerGetLives(PlayerInfo* player); //!< getFunction for the map "playerLives_".
- void killPlayer(PlayerInfo* player); //!< Function in order to kill a player. Punishment for hiding longer than "timeRemaining".
+ void punishPlayer(PlayerInfo* player); //!< Function in order to kill a player. Punishment for hiding longer than "timeRemaining".
void tick (float dt); //!< used to end the game
};
}
More information about the Orxonox-commit
mailing list