[Orxonox-commit 4699] r9370 - in code/branches/release2012: data/levels src/orxonox/gametypes

jo at orxonox.net jo at orxonox.net
Tue Sep 4 18:13:04 CEST 2012


Author: jo
Date: 2012-09-04 18:13:03 +0200 (Tue, 04 Sep 2012)
New Revision: 9370

Modified:
   code/branches/release2012/data/levels/underAttack.oxw
   code/branches/release2012/src/orxonox/gametypes/TeamGametype.cc
   code/branches/release2012/src/orxonox/gametypes/TeamGametype.h
   code/branches/release2012/src/orxonox/gametypes/UnderAttack.cc
   code/branches/release2012/src/orxonox/gametypes/UnderAttack.h
Log:
The transporter's life is now set depending on the number of players.

Modified: code/branches/release2012/data/levels/underAttack.oxw
===================================================================
--- code/branches/release2012/data/levels/underAttack.oxw	2012-09-04 09:07:26 UTC (rev 9369)
+++ code/branches/release2012/data/levels/underAttack.oxw	2012-09-04 16:13:03 UTC (rev 9370)
@@ -45,6 +45,10 @@
       </MovableEntity>
     <?lua end ?>
 
+
+
+
+
     <Destroyer
       position          = "100,150,0"
       collisionType     = dynamic
@@ -52,17 +56,17 @@
       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 />
+        <TeamSpawnPoint team=1 position="150,0,-50" direction="-1,0,0" roll=90 yaw=0 spawnclass=SpaceShip pawndesign=spaceshipassff />
+        <TeamSpawnPoint team=1 position="0,0,-50" lookat="-1,0,0" roll="90"  yaw=0 spawnclass=SpaceShip pawndesign=spaceshipassff />
+        <TeamSpawnPoint team=1 position="-50,0,-50" 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="50,0,-50" lookat="-1,0,0" roll="90" yaw=0 spawnclass=SpaceShip pawndesign=spaceshipassff />
         <?lua for i = 1, 100, 1 do ?>
           <TeamSpawnPoint
             team=0

Modified: code/branches/release2012/src/orxonox/gametypes/TeamGametype.cc
===================================================================
--- code/branches/release2012/src/orxonox/gametypes/TeamGametype.cc	2012-09-04 09:07:26 UTC (rev 9369)
+++ code/branches/release2012/src/orxonox/gametypes/TeamGametype.cc	2012-09-04 16:13:03 UTC (rev 9370)
@@ -187,6 +187,29 @@
         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;

Modified: code/branches/release2012/src/orxonox/gametypes/TeamGametype.h
===================================================================
--- code/branches/release2012/src/orxonox/gametypes/TeamGametype.h	2012-09-04 09:07:26 UTC (rev 9369)
+++ code/branches/release2012/src/orxonox/gametypes/TeamGametype.h	2012-09-04 16:13:03 UTC (rev 9370)
@@ -62,8 +62,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;
             bool pawnsAreInTheSameTeam(Pawn* pawn1, Pawn* pawn2);

Modified: code/branches/release2012/src/orxonox/gametypes/UnderAttack.cc
===================================================================
--- code/branches/release2012/src/orxonox/gametypes/UnderAttack.cc	2012-09-04 09:07:26 UTC (rev 9369)
+++ code/branches/release2012/src/orxonox/gametypes/UnderAttack.cc	2012-09-04 16:13:03 UTC (rev 9370)
@@ -38,6 +38,8 @@
 namespace orxonox
 {
     CreateUnloadableFactory(UnderAttack);
+    static const int attacker_ = 0; // teamnumber of the attacking team
+    static const int defender_ = 1; // defender's teamnumber
 
     UnderAttack::UnderAttack(BaseObject* creator) : TeamDeathmatch(creator)
     {
@@ -50,6 +52,7 @@
 
         this->setConfigValues();
         this->timesequence_ = static_cast<int>(this->gameTime_);
+
     }
 
     void UnderAttack::setConfigValues()
@@ -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_)*3500.0f + this->getHumansInTeam(attacker_)*1500.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/branches/release2012/src/orxonox/gametypes/UnderAttack.h
===================================================================
--- code/branches/release2012/src/orxonox/gametypes/UnderAttack.h	2012-09-04 09:07:26 UTC (rev 9369)
+++ code/branches/release2012/src/orxonox/gametypes/UnderAttack.h	2012-09-04 16:13:03 UTC (rev 9370)
@@ -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