[Orxonox-commit 5278] r9941 - in code/trunk: data/gui/layouts data/gui/scripts data/levels src/modules/objects src/orxonox/gametypes
jo at orxonox.net
jo at orxonox.net
Sun Dec 29 20:06:44 CET 2013
Author: jo
Date: 2013-12-29 20:06:44 +0100 (Sun, 29 Dec 2013)
New Revision: 9941
Modified:
code/trunk/data/gui/layouts/CreditsMenu.layout
code/trunk/data/gui/scripts/MiscConfigMenu.lua
code/trunk/data/levels/missionOne.oxw
code/trunk/data/levels/underAttack.oxw
code/trunk/src/modules/objects/SpaceBoundaries.cc
code/trunk/src/orxonox/gametypes/LastTeamStanding.cc
code/trunk/src/orxonox/gametypes/TeamDeathmatch.cc
code/trunk/src/orxonox/gametypes/TeamDeathmatch.h
code/trunk/src/orxonox/gametypes/TeamGametype.cc
code/trunk/src/orxonox/gametypes/TeamGametype.h
code/trunk/src/orxonox/gametypes/UnderAttack.cc
code/trunk/src/orxonox/gametypes/UnderAttack.h
Log:
Adding most of the changes that were proposed in the release2012 branch.
Modified: code/trunk/data/gui/layouts/CreditsMenu.layout
===================================================================
--- code/trunk/data/gui/layouts/CreditsMenu.layout 2013-12-21 22:38:57 UTC (rev 9940)
+++ code/trunk/data/gui/layouts/CreditsMenu.layout 2013-12-29 19:06:44 UTC (rev 9941)
@@ -45,6 +45,10 @@
http://www.orxonox.net
Credits:
+ http://www.orxonox.net/wiki/credits
+
+ Thanks to AMIV:
+ https://www.amiv.ethz.ch/
</Property>
</Window>
</Window>
Modified: code/trunk/data/gui/scripts/MiscConfigMenu.lua
===================================================================
--- code/trunk/data/gui/scripts/MiscConfigMenu.lua 2013-12-21 22:38:57 UTC (rev 9940)
+++ code/trunk/data/gui/scripts/MiscConfigMenu.lua 2013-12-29 19:06:44 UTC (rev 9941)
@@ -32,6 +32,7 @@
table.insert(P.commandList, "Gametype numberOfBots_")
table.insert(P.commandList, "UnderAttack gameTime_")
table.insert(P.commandList, "TeamDeathmatch teams_")
+ table.insert(P.commandList, "TeamDeathmatch maxScore_")
table.insert(P.commandList, "HumanPlayer nick_")
table.insert(P.commandList, "ChatOverlay displayTime_")
table.insert(P.commandList, "Core bDevMode_")
@@ -55,6 +56,7 @@
table.insert(P.nameList, "Number of Bots")
table.insert(P.nameList, "UnderAttack: game time")
table.insert(P.nameList, "TeamDeathmatch: Number of teams")
+ table.insert(P.nameList, "TeamDeathmatch: Score needed to end the game")
table.insert(P.nameList, "Playername")
table.insert(P.nameList, "Chat: display time")
table.insert(P.nameList, "Developer's Mode")
Modified: code/trunk/data/levels/missionOne.oxw
===================================================================
--- code/trunk/data/levels/missionOne.oxw 2013-12-21 22:38:57 UTC (rev 9940)
+++ code/trunk/data/levels/missionOne.oxw 2013-12-29 19:06:44 UTC (rev 9941)
@@ -1,7 +1,7 @@
<!---->
<LevelInfo
name = "Mission One"
- description = "First Guided Steps in the Orxonoxian Universe."
+ description = "Codename: Awakening - First Guided Steps in the Orxonoxian Universe."
screenshot = "missionOne.png"
tags = "mission"
/>
Modified: code/trunk/data/levels/underAttack.oxw
===================================================================
--- code/trunk/data/levels/underAttack.oxw 2013-12-21 22:38:57 UTC (rev 9940)
+++ code/trunk/data/levels/underAttack.oxw 2013-12-29 19:06:44 UTC (rev 9941)
@@ -55,21 +55,22 @@
velocity = "-35,0,0"
angularDamping = 0.9999999
health = 10000
- maxhealth = 10000
+ maxhealth = 10000000
initialhealth = 10000
radarname = "Transporter"
>
<attached>
- <TeamSpawnPoint team=1 position="150,0,7" direction="-1,0,0" roll=90 yaw=0 spawnclass=SpaceShip pawndesign=spaceshipassff />
- <TeamSpawnPoint team=1 position="0,0,7" lookat="-1,0,0" roll="90" yaw=0 spawnclass=SpaceShip pawndesign=spaceshipassff />
- <TeamSpawnPoint team=1 position="-50,0,7" lookat="-1,0,0" roll="90" yaw=0 spawnclass=SpaceShip pawndesign=spaceshipassff />
- <TeamSpawnPoint team=1 position="100,0,7" lookat="-1,0,0" roll="90" yaw=0 spawnclass=SpaceShip pawndesign=spaceshipassff />
- <TeamSpawnPoint team=1 position="50,0,7" lookat="-1,0,0" roll="90" yaw=0 spawnclass=SpaceShip pawndesign=spaceshipassff />
+ <SpaceBoundaries position="1,2,3" maxDistance="1600" warnDistance="300" showDistance="300" reactionMode="1" healthDecrease="5.0" />
+ <TeamSpawnPoint team=1 position="200,0,20" direction="-1,0,0" roll=90 yaw=0 spawnclass=SpaceShip pawndesign=spaceshipassff />
+ <TeamSpawnPoint team=1 position="50,0,100" lookat="-1,0,0" roll="90" yaw=0 spawnclass=SpaceShip pawndesign=spaceshipassff />
+ <TeamSpawnPoint team=1 position="-200,0,-60" lookat="-1,0,0" roll="90" yaw=0 spawnclass=SpaceShip pawndesign=spaceshipassff />
+ <TeamSpawnPoint team=1 position="100,0,-50" lookat="-1,0,0" roll="90" yaw=0 spawnclass=SpaceShip pawndesign=spaceshipassff />
+ <TeamSpawnPoint team=1 position="400,0,20" lookat="-1,0,0" roll="90" yaw=0 spawnclass=SpaceShip pawndesign=spaceshipassff />
<?lua for i = 1, 100, 1 do ?>
<TeamSpawnPoint
team=0
- position="<?lua print((math.random() * 500 + 500) * (math.floor(math.random() + 0.5) * 2 - 1)) ?>,<?lua print((math.random() * 500 + 500) * (math.floor(math.random() + 0.5) * 2 - 1)) ?>,<?lua print((math.random() * 500 + 500) * (math.floor(math.random() + 0.5) * 2 - 1)) ?>"
+ position="<?lua print((math.random() * 450 + 450) * (math.floor(math.random() + 0.5) * 2 - 1)) ?>,<?lua print((math.random() * 450 + 450) * (math.floor(math.random() + 0.5) * 2 - 1)) ?>,<?lua print((math.random() * 450 + 450) * (math.floor(math.random() + 0.5) * 2 - 1)) ?>"
lookat="0,0,0"
spawnclass=SpaceShip
pawndesign=spaceshipassff
Modified: code/trunk/src/modules/objects/SpaceBoundaries.cc
===================================================================
--- code/trunk/src/modules/objects/SpaceBoundaries.cc 2013-12-21 22:38:57 UTC (rev 9940)
+++ code/trunk/src/modules/objects/SpaceBoundaries.cc 2013-12-29 19:06:44 UTC (rev 9941)
@@ -116,7 +116,7 @@
this->billboards_[current].billy->setColour(ColourValue(1, 1, 1, alpha));
this->billboards_[current].usedYet = true;
- Vector3 directionVector = (this->getPosition() - position).normalisedCopy(); // vector from the position of the billboard to the center of the sphere
+ Vector3 directionVector = (this->getWorldPosition() - position).normalisedCopy(); // vector from the position of the billboard to the center of the sphere
this->billboards_[current].billy->setCommonDirection(directionVector);
Vector3 upVector = Vector3(directionVector.z, directionVector.z, -(directionVector.x + directionVector.y)); // vector perpendicular to the direction vector
@@ -251,8 +251,8 @@
{
if(item != NULL)
{
- Vector3 itemPosition = item->getPosition();
- return (itemPosition.distance(this->getPosition()));
+ Vector3 itemPosition = item->getWorldPosition();
+ return (itemPosition.distance(this->getWorldPosition()));
} else {
return -1;
}
@@ -266,17 +266,17 @@
void SpaceBoundaries::displayBoundaries(Pawn *item, float alpha)
{
- Vector3 direction = item->getPosition() - this->getPosition();
+ Vector3 direction = item->getWorldPosition() - this->getWorldPosition();
direction.normalise();
- Vector3 boundaryPosition = this->getPosition() + direction * this->maxDistance_;
+ Vector3 boundaryPosition = this->getWorldPosition() + direction * this->maxDistance_;
this->positionBillboard(boundaryPosition, alpha);
}
void SpaceBoundaries::conditionalBounceBack(Pawn *item, float currentDistance, float dt)
{
- Vector3 normal = item->getPosition() - this->getPosition();
+ Vector3 normal = item->getWorldPosition() - this->getWorldPosition();
normal.normalise();
Vector3 velocity = item->getVelocity();
float normalSpeed = item->getVelocity().dotProduct(normal);
@@ -299,12 +299,12 @@
Vector3 acceleration = item->getAcceleration();
acceleration = acceleration.reflect(*normal);
- item->lookAt( *velocity + this->getPosition() );
+ item->lookAt( *velocity + this->getWorldPosition() );
item->setAcceleration(acceleration * dampingFactor);
item->setVelocity(*velocity * dampingFactor);
- item->setPosition( item->getPosition() - *normal * 10 ); // Set the position of the Pawn to be well inside the boundary.
+ item->setPosition( item->getWorldPosition() - *normal * 10 ); // Set the position of the Pawn to be well inside the boundary.
}
bool SpaceBoundaries::isHumanPlayer(Pawn *item)
Modified: code/trunk/src/orxonox/gametypes/LastTeamStanding.cc
===================================================================
--- code/trunk/src/orxonox/gametypes/LastTeamStanding.cc 2013-12-21 22:38:57 UTC (rev 9940)
+++ code/trunk/src/orxonox/gametypes/LastTeamStanding.cc 2013-12-29 19:06:44 UTC (rev 9941)
@@ -241,17 +241,10 @@
{
party = it2->second;
}
- //if (party < 0) return; //if search failed
+ if (party < 0) return; //if search failed
//victory message to all team members, loose message to everyone else
- for (std::map<PlayerInfo*, int>::iterator it3 = this->teamnumbers_.begin(); it3 != this->teamnumbers_.end(); ++it3)
- {
- if (it3->first->getClientID() == NETWORK_PEER_ID_UNKNOWN)
- continue;
- if (it3->second == party)
- {this->gtinfo_->sendAnnounceMessage("You have won the match!", it3->first->getClientID());}
- else
- {this->gtinfo_->sendAnnounceMessage("You have lost the match!", it3->first->getClientID());}
- }
+ this->announceTeamWin(party);
+
return;
}
}
Modified: code/trunk/src/orxonox/gametypes/TeamDeathmatch.cc
===================================================================
--- code/trunk/src/orxonox/gametypes/TeamDeathmatch.cc 2013-12-21 22:38:57 UTC (rev 9940)
+++ code/trunk/src/orxonox/gametypes/TeamDeathmatch.cc 2013-12-29 19:06:44 UTC (rev 9941)
@@ -32,6 +32,7 @@
#include "chat/ChatManager.h"
#include "infos/PlayerInfo.h"
#include "worldentities/pawns/Pawn.h"
+#include "core/config/ConfigValueIncludes.h"
namespace orxonox
{
@@ -40,8 +41,15 @@
TeamDeathmatch::TeamDeathmatch(Context* context) : TeamGametype(context)
{
RegisterObject(TeamDeathmatch);
+
+ this->setConfigValues();
}
+ void TeamDeathmatch::setConfigValues()
+ {
+ SetConfigValue(maxScore_, 10);
+ }
+
void TeamDeathmatch::start()
{
TeamGametype::start();
@@ -56,6 +64,21 @@
std::string message("The match has ended.");
ChatManager::message(message);
+
+ //find team that won the match
+ int winnerTeam = 0;
+ int highestScore = 0;
+ for (std::map<PlayerInfo*, Player>::iterator it = this->players_.begin(); it != this->players_.end(); ++it)
+ {
+ if ( this->getTeamScore(it->first) > highestScore )
+ {
+ winnerTeam = this->getTeam(it->first);
+ highestScore = this->getTeamScore(it->first);
+ }
+ }
+
+ //announce win
+ this->announceTeamWin(winnerTeam);
}
void TeamDeathmatch::playerEntered(PlayerInfo* player)
@@ -99,7 +122,11 @@
if (killer)
{
if (killer->getPlayer())
+ {
message = victim->getPlayer()->getName() + " was killed by " + killer->getPlayer()->getName();
+ if(this->isExactlyA(Class(TeamDeathmatch)) && (this->getTeamScore(killer->getPlayer()) >= (this->maxScore_ -1)) )
+ this->end();
+ }
else
message = victim->getPlayer()->getName() + " was killed";
}
Modified: code/trunk/src/orxonox/gametypes/TeamDeathmatch.h
===================================================================
--- code/trunk/src/orxonox/gametypes/TeamDeathmatch.h 2013-12-21 22:38:57 UTC (rev 9940)
+++ code/trunk/src/orxonox/gametypes/TeamDeathmatch.h 2013-12-29 19:06:44 UTC (rev 9941)
@@ -40,6 +40,7 @@
TeamDeathmatch(Context* context);
virtual ~TeamDeathmatch() {}
+ void setConfigValues();
virtual void start();
virtual void end();
virtual void playerEntered(PlayerInfo* player);
@@ -48,6 +49,8 @@
virtual void pawnKilled(Pawn* victim, Pawn* killer = 0);
virtual void playerScored(PlayerInfo* player, int score = 1);
+ protected:
+ int maxScore_;
};
}
Modified: code/trunk/src/orxonox/gametypes/TeamGametype.cc
===================================================================
--- code/trunk/src/orxonox/gametypes/TeamGametype.cc 2013-12-21 22:38:57 UTC (rev 9940)
+++ code/trunk/src/orxonox/gametypes/TeamGametype.cc 2013-12-29 19:06:44 UTC (rev 9941)
@@ -172,6 +172,44 @@
return (!this->pawnsAreInTheSameTeam(victim, originator) || !originator || this->allowFriendlyFire_);
}
+ int TeamGametype::getTeamScore(PlayerInfo* player)
+ {
+ int teamscore = 0;
+ if(!player || this->getTeam(player) == -1)
+ return 0;
+ for (std::map<PlayerInfo*, Player>::iterator it = this->players_.begin(); it != this->players_.end(); ++it)
+ {
+ if ( this->getTeam(it->first) == this->getTeam(player) )
+ {
+ teamscore += it->second.frags_;
+ }
+ }
+ return teamscore;
+ }
+
+ int TeamGametype::getTeamSize(int team)
+ {
+ int teamSize = 0;
+ for (std::map<PlayerInfo*, int>::iterator it = this->teamnumbers_.begin(); it != this->teamnumbers_.end(); ++it)
+ {
+ if (it->second == team)
+ teamSize++;
+ }
+ return teamSize;
+ }
+
+ int TeamGametype::getHumansInTeam(int team)
+ {
+ int teamSize = 0;
+ for (std::map<PlayerInfo*, int>::iterator it = this->teamnumbers_.begin(); it != this->teamnumbers_.end(); ++it)
+ {
+ if (it->second == team && it->first->isHumanPlayer())
+ teamSize++;
+ }
+ return teamSize;
+ }
+
+
SpawnPoint* TeamGametype::getBestSpawnPoint(PlayerInfo* player) const
{
int desiredTeamNr = -1;
@@ -335,4 +373,21 @@
}
}
+ void TeamGametype::announceTeamWin(int winnerTeam)
+ {
+ for (std::map<PlayerInfo*, int>::iterator it3 = this->teamnumbers_.begin(); it3 != this->teamnumbers_.end(); ++it3)
+ {
+ if (it3->first->getClientID() == NETWORK_PEER_ID_UNKNOWN)
+ continue;
+ if (it3->second == winnerTeam)
+ {
+ this->gtinfo_->sendAnnounceMessage("Your team has won the match!", it3->first->getClientID());
+ }
+ else
+ {
+ this->gtinfo_->sendAnnounceMessage("Your team has lost the match!", it3->first->getClientID());
+ }
+ }
+ }
+
}
Modified: code/trunk/src/orxonox/gametypes/TeamGametype.h
===================================================================
--- code/trunk/src/orxonox/gametypes/TeamGametype.h 2013-12-21 22:38:57 UTC (rev 9940)
+++ code/trunk/src/orxonox/gametypes/TeamGametype.h 2013-12-29 19:06:44 UTC (rev 9941)
@@ -61,6 +61,9 @@
inline const ColourValue& getTeamColour(int teamnr) const
{ return this->teamcolours_[teamnr]; }
+ int getTeamScore(PlayerInfo* player);
+ int getTeamSize(int team);
+ int getHumansInTeam(int team);
protected:
virtual SpawnPoint* getBestSpawnPoint(PlayerInfo* player) const;
@@ -76,6 +79,8 @@
void setTeamColour(PlayerInfo* player, Pawn* pawn);
void setDefaultObjectColour(Pawn* pawn);
void colourPawn(Pawn* pawn, int teamNr);
+ void announceTeamWin(int winnerTeam);
+
};
}
Modified: code/trunk/src/orxonox/gametypes/UnderAttack.cc
===================================================================
--- code/trunk/src/orxonox/gametypes/UnderAttack.cc 2013-12-21 22:38:57 UTC (rev 9940)
+++ code/trunk/src/orxonox/gametypes/UnderAttack.cc 2013-12-29 19:06:44 UTC (rev 9941)
@@ -37,6 +37,9 @@
namespace orxonox
{
+ const int attacker_ = 0; // teamnumber of the attacking team
+ const int defender_ = 1; // defender's teamnumber
+
RegisterUnloadableClass(UnderAttack);
UnderAttack::UnderAttack(Context* context) : TeamDeathmatch(context)
@@ -75,7 +78,7 @@
if (it->first->getClientID() == NETWORK_PEER_ID_UNKNOWN)
continue;
- if (it->second == 0)
+ if (it->second == attacker_)
this->gtinfo_->sendAnnounceMessage("You have won the match!", it->first->getClientID());
else
this->gtinfo_->sendAnnounceMessage("You have lost the match!", it->first->getClientID());
@@ -187,4 +190,26 @@
}
}
}
+
+ void UnderAttack::playerEntered(PlayerInfo* player)
+ {
+ if (!player)
+ return;
+ TeamDeathmatch::playerEntered(player);
+ this->setTransporterHealth();
+ }
+
+ void UnderAttack::setTransporterHealth()
+ {
+ if (this->destroyer_ != 0)
+ {
+ //Calculation: Each attacker deals about 3500 damage. A human attacker deals 1500 damage additionally.
+ //Each defender prevents 500 damage. If human 2000 damage will be additionally be prevented.
+ //TODO: use gametime and the damage dealt so far in order to calculate the transporter's life more precisely
+ float health = this->getTeamSize(attacker_)*2000.0f + this->getHumansInTeam(attacker_)*3000.0f - this->getTeamSize(defender_)*500.0f - this->getHumansInTeam(defender_)*2000.0f ;
+ this->destroyer_->setHealth(std::max(health, 5000.0f)); //the destoyer should have at least 5000.0f life.
+ }
+ }
+
+
}
Modified: code/trunk/src/orxonox/gametypes/UnderAttack.h
===================================================================
--- code/trunk/src/orxonox/gametypes/UnderAttack.h 2013-12-21 22:38:57 UTC (rev 9940)
+++ code/trunk/src/orxonox/gametypes/UnderAttack.h 2013-12-29 19:06:44 UTC (rev 9941)
@@ -50,9 +50,11 @@
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 playerEntered(PlayerInfo* player);
protected:
virtual void killedDestroyer();
+ void setTransporterHealth();
WeakPtr<Destroyer> destroyer_;
unsigned int teams_;
More information about the Orxonox-commit
mailing list