Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Sep 2, 2012, 6:45:40 PM (12 years ago)
Author:
jo
Message:

Teamdeathmatch ends if a certain number of opponents have been killed. (friendlyfire is not concerned)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/release2012/src/orxonox/gametypes/TeamDeathmatch.cc

    r9348 r9363  
    3333#include "infos/PlayerInfo.h"
    3434#include "worldentities/pawns/Pawn.h"
     35#include "core/ConfigValueIncludes.h"
    3536
    3637namespace orxonox
     
    4142    {
    4243        RegisterObject(TeamDeathmatch);
     44
     45        this->setConfigValues();
     46    }
     47
     48    void TeamDeathmatch::setConfigValues()
     49    {
     50        SetConfigValue(maxScore_, 10);
    4351    }
    4452
     
    5765        std::string message("The match has ended.");
    5866        ChatManager::message(message);
     67       
     68        //find team that won the match
     69        int winnerTeam = 0;
     70        int highestScore = 0;
     71        for (std::map<PlayerInfo*, Player>::iterator it = this->players_.begin(); it != this->players_.end(); ++it)
     72        {
     73            if ( this->getTeamScore(it->first) > highestScore )
     74            {
     75                winnerTeam = this->getTeam(it->first);
     76                highestScore = this->getTeamScore(it->first);
     77            }
     78        }
     79
     80        //announce win
     81        this->announceTeamWin(winnerTeam);
    5982    }
    6083
     
    100123            {
    101124                if (killer->getPlayer())
     125                {
    102126                    message = victim->getPlayer()->getName() + " was killed by " + killer->getPlayer()->getName();
     127                    if(this->isExactlyA(Class(TeamDeathmatch)) && (this->getTeamScore(killer->getPlayer()) >= (this->maxScore_ -1)) )
     128                        this->end();
     129                }
    103130                else
    104131                    message = victim->getPlayer()->getName() + " was killed";
     
    109136            ChatManager::message(message);
    110137        }
    111 
    112138        Gametype::pawnKilled(victim, killer);
    113139    }
     
    121147            const std::string& message = player->getName() + " scores!";
    122148            ChatManager::message(message);
     149
    123150        }
    124151    }
Note: See TracChangeset for help on using the changeset viewer.