Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7596


Ignore:
Timestamp:
Oct 28, 2010, 12:05:01 AM (14 years ago)
Author:
jo
Message:

Respawn delay added. One new bug has to be removed.

Location:
code/branches/lastmanstanding
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • code/branches/lastmanstanding/data/levels/gametype_lastmanstanding.oxw

    r7585 r7596  
    112112    </StaticEntity>
    113113
     114<!-- ---------Top Asteroid----------- -->
    114115
     116    <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 >
     117      <attached>
     118        <Model position="0,0,0" scale=25 mesh="ast6.mesh">
     119        </Model>
     120      </attached>
     121      <collisionShapes>
     122        <BoxCollisionShape    halfExtents="50,25,50" position="0,0,0" yaw="<?lua print(-90+i*360/max) ?>"/>
     123      </collisionShapes>
     124    </StaticEntity>
    115125
    116   <MovableEntity 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) ?>" >
    117        <attached>
    118            <Model position="0,0,0" scale=25 mesh="ast6.mesh" shadow=true />
    119        </attached>
    120       <!--collisionShapes>
    121         <BoxCollisionShape position="<?lua print(y) ?>,0,<?lua print(z) ?>"      halfExtents="5, 5, 5" />
    122       </collisionShapes-->
    123   </MovableEntity>
    124126
    125127
  • code/branches/lastmanstanding/src/orxonox/gametypes/LastManStanding.cc

    r7586 r7596  
    3535#include "core/ConfigValueIncludes.h"
    3636#include "util/Convert.h"
    37 
     37//TODO: respawn delay
    3838namespace orxonox
    3939{
     
    4747        this->playersAlive=0;
    4848        this->timeRemaining=20.0f;
     49        this->respawnDelay=4.0f;
    4950        this->setHUDTemplate("LastmanstandingHUD");
    5051    }
     
    5556            if (it->second.state_ == PlayerState::Dead)
    5657            {
    57                 bool alive = (0<playerLives_[it->first]);
     58                bool alive = (0<playerLives_[it->first]&&(inGame_[it->first]));
    5859                if (alive&&(it->first->isReadyToSpawn() || this->bForceSpawn_))
     60                {
    5961                    this->spawnPlayer(it->first);
    60              }
     62                }
     63                else if ((!inGame_[it->first])&&(0<playerLives_[it->first]))
     64                {
     65                    if (it->first->getClientID()== CLIENTID_UNKNOWN)
     66                        return;
     67                    const std::string& message = "Respawn in " +multi_cast<std::string>(respawnDelay)+ " seconds." ;
     68                    this->gtinfo_->sendFadingMessage(message,it->first->getClientID());
     69                }
     70                else if (0>=playerLives_[it->first])
     71                {
     72                    if (it->first->getClientID()== CLIENTID_UNKNOWN)
     73                        return;
     74                    const std::string& message2 = "You have lost all " +multi_cast<std::string>(lives)+ " lives." ;
     75                    this->gtinfo_->sendFadingMessage(message2,it->first->getClientID());
     76                }
     77            }
    6178    }
    6279
     
    6683        SetConfigValue(lives, 4);
    6784        SetConfigValue(timeRemaining, 20.0f);
     85        SetConfigValue(respawnDelay, 4.0f);
    6886    }
    6987
     
    82100            return true;
    83101        playerLives_[victim->getPlayer()]=playerLives_[victim->getPlayer()]-1;
     102        this->inGame_[victim->getPlayer()]=false;//if player dies he, isn't allowed to respawn immediately
    84103        if (playerLives_[victim->getPlayer()]<=0)//if player lost all lives
    85104        {
     
    117136        this->playersAlive++;
    118137        this->timeToAct_[player]=timeRemaining;
     138        this->playerDelayTime_[player]=respawnDelay;
     139        this->inGame_[player]=true;
    119140        //Update: EachPlayer's "Players in Game"-HUD
    120141        for (std::map<PlayerInfo*, Player>::iterator it = this->players_.begin(); it != this->players_.end(); ++it)
     
    151172        if (!player)
    152173            return;
    153         this->timeToAct_[player]=timeRemaining+3.0f;//reset timer
     174        this->timeToAct_[player]=timeRemaining+3.0f+respawnDelay;//reset timer
     175        this->playerDelayTime_[player]=respawnDelay;
    154176        //Update: Individual Players "lifes"-HUD
    155177        std::map<PlayerInfo*, Player>::iterator it2 = this->players_.find(player);
    156178        if (it2 != this->players_.end())
    157179        {
     180            if (it2->first->getClientID()== CLIENTID_UNKNOWN)
     181                return;
    158182            const std::string& message = "Your Lives: " +multi_cast<std::string>(playerLives_[player]);
    159183            this->gtinfo_->sendFadingMessage(message,it2->first->getClientID());
     
    170194            if (it->first->getClientID() == CLIENTID_UNKNOWN)
    171195                continue;
    172             const std::string& message1 = "Remaining Players : "+ multi_cast<std::string>(playersAlive);
     196            const std::string& message1 = "Remaining Players: "+ multi_cast<std::string>(playersAlive);
    173197            this->gtinfo_->sendStaticMessage(message1,it->first->getClientID(),ColourValue(1.0f, 1.0f, 0.5f));
    174198        }
     
    196220                {return;}
    197221            pawn->kill();
    198             this->timeToAct_[player]=timeRemaining+3.0f;//reset timer
     222            this->timeToAct_[player]=timeRemaining+3.0f+respawnDelay;//reset timer
    199223        }
    200224    }
     
    210234            }
    211235            for (std::map<PlayerInfo*, float>::iterator it = this->timeToAct_.begin(); it != this->timeToAct_.end(); ++it)
    212             {       
    213                 it->second-=dt;
    214                 if (it->second<timeRemaining/6)//Warning message
    215                 {
     236            {   
     237                if (playerGetLives(it->first)<=0)//Players without lives shouldn't be affected by time.
     238                    return;     
     239                it->second-=dt;//Decreases punishment time.
     240                if (!inGame_[it->first])//Manages respawn delay - player is forced to respawn after the delaytime is used up.
     241                {
     242                    playerDelayTime_[it->first]-=dt;
     243                    if (playerDelayTime_[it->first]<=0)
     244                    this->inGame_[it->first]=true;
     245                }
     246                else if (it->second<0.0f)
     247                {
     248                    it->second=timeRemaining+3.0f;//reset punishment-timer
     249                    if (playerGetLives(it->first)>0)
     250                        this->killPlayer(it->first);
     251                }
     252                else if (it->second<timeRemaining/6)//Warning message
     253                {
     254                    if (it->first->getClientID()== CLIENTID_UNKNOWN)
     255                        return;
    216256                    const std::string& message = "Camper Warning! Don't forget to shoot.";
    217257                    this->gtinfo_->sendFadingMessage(message,it->first->getClientID());
    218258                }
    219                 if (it->second<0.0f)
    220                 {
    221                     it->second=timeRemaining+3.0f;//reset timer
    222                     if (playerGetLives(it->first)>0)
    223                         this->killPlayer(it->first);
    224                 }
    225259            }
    226260        }
  • code/branches/lastmanstanding/src/orxonox/gametypes/LastManStanding.h

    r7583 r7596  
    5555            float timeRemaining; //!< Each player has a certain time where he or she has to hit an opponent or will be punished.
    5656            std::map<PlayerInfo*, float> timeToAct_; //!< Each player's time till she/he will be punished is stored here.
     57            float respawnDelay;
     58            std::map<PlayerInfo*, float> playerDelayTime_; //!< Stores each Player's delay time.
     59            std::map<PlayerInfo*, bool> inGame_; //!< Indicates each Player's state.
    5760            virtual void spawnDeadPlayersIfRequested(); //!< Prevents dead players to respawn
    5861
Note: See TracChangeset for help on using the changeset viewer.