Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7581


Ignore:
Timestamp:
Oct 25, 2010, 10:21:53 PM (14 years ago)
Author:
jo
Message:

Almost finished. Yeay.

Location:
code/branches/lastmanstanding
Files:
1 added
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/lastmanstanding/src/orxonox/gametypes/LastManStanding.cc

    r7579 r7581  
    236236            return 0;
    237237    }
    238     /*BUG-Description:
    239     *There are two ways for a player to be killed: Either receiving damage, or through the following function.
    240     *The function works fine - until the last call, when a player looses his last live. Than the kill part
    241     *(it->second.state_ = PlayerState::Dead;) somehow isn't executed:
    242     *The player isn't killed (he doesn't leave play). Although the corresponding code is reached.
    243     *
    244     *How to reproduce this bug: Start a new Lastmanstanding-Match. Immdiately add 8 bots(before actually entering the level).
    245     *Just fly around and wait. Don't shoot, since only passive behaviour triggers the killPlayer-Function.
    246     */
     238
    247239    void LastManStanding::killPlayer(PlayerInfo* player)
    248240    {
     
    252244        if (it != this->players_.end())
    253245        {
    254             if (playerLives_[player]<=1)//if player lost all lives
    255             {
    256                 this->playersAlive--;
    257                 const std::string& message = player->getName() + " is out";
    258                 COUT(0) << message << std::endl;
    259                 Host::Broadcast(message);
    260                 playerLives_[player]=playerLives_[player]-1;//-----------datapart
    261                 it->second.killed_++;
    262                 it->second.state_ = PlayerState::Dead;//-------------killpart
    263             }
    264             else
    265             {
    266                 playerLives_[player]=playerLives_[player]-1;//-----------datapart
    267                 it->second.killed_++;
    268                 it->second.state_ = PlayerState::Dead;//-------------killpart
    269 
    270                 this->timeToAct_[player]=timeRemaining+3.0f;//reset timer
    271             }
    272 
     246            if(!player->getControllableEntity())
     247                {return;}
     248            Pawn* pawn = dynamic_cast<Pawn*>(player->getControllableEntity());
     249            if(!pawn)
     250                {return;}
     251            pawn->kill();
     252            this->timeToAct_[player]=timeRemaining+3.0f;//reset timer
    273253        }
    274254    }
     
    277257    {
    278258        SUPER(LastManStanding, tick, dt);
    279         if(!this->hasEnded())
    280         {
    281             if ((this->hasStarted()&&(playersAlive==1)))//last player remaining
     259        if(this->hasStarted()&&(!this->hasEnded()))
     260        {
     261            if ((this->hasStarted()&&(playersAlive<=1)))//last player remaining
    282262            {
    283263            this->end();
Note: See TracChangeset for help on using the changeset viewer.