[2825] | 1 | /* |
---|
| 2 | * ORXONOX - the hottest 3D action shooter ever to exist |
---|
| 3 | * > www.orxonox.net < |
---|
| 4 | * |
---|
| 5 | * |
---|
| 6 | * License notice: |
---|
| 7 | * |
---|
| 8 | * This program is free software; you can redistribute it and/or |
---|
| 9 | * modify it under the terms of the GNU General Public License |
---|
| 10 | * as published by the Free Software Foundation; either version 2 |
---|
| 11 | * of the License, or (at your option) any later version. |
---|
| 12 | * |
---|
| 13 | * This program is distributed in the hope that it will be useful, |
---|
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 16 | * GNU General Public License for more details. |
---|
| 17 | * |
---|
| 18 | * You should have received a copy of the GNU General Public License |
---|
| 19 | * along with this program; if not, write to the Free Software |
---|
| 20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
---|
| 21 | * |
---|
| 22 | * Author: |
---|
| 23 | * Fabian 'x3n' Landau |
---|
| 24 | * Co-authors: |
---|
| 25 | * ... |
---|
| 26 | * |
---|
| 27 | */ |
---|
| 28 | |
---|
| 29 | #include "TeamDeathmatch.h" |
---|
| 30 | |
---|
| 31 | #include "core/CoreIncludes.h" |
---|
[9348] | 32 | #include "chat/ChatManager.h" |
---|
| 33 | #include "infos/PlayerInfo.h" |
---|
[5735] | 34 | #include "worldentities/pawns/Pawn.h" |
---|
[2825] | 35 | |
---|
| 36 | namespace orxonox |
---|
| 37 | { |
---|
| 38 | CreateUnloadableFactory(TeamDeathmatch); |
---|
| 39 | |
---|
[9348] | 40 | TeamDeathmatch::TeamDeathmatch(BaseObject* creator) : TeamGametype(creator) |
---|
[2825] | 41 | { |
---|
| 42 | RegisterObject(TeamDeathmatch); |
---|
[9348] | 43 | } |
---|
[2825] | 44 | |
---|
[9348] | 45 | void TeamDeathmatch::start() |
---|
| 46 | { |
---|
| 47 | TeamGametype::start(); |
---|
[2825] | 48 | |
---|
[9348] | 49 | std::string message("The match has started!"); |
---|
| 50 | ChatManager::message(message); |
---|
[2825] | 51 | } |
---|
| 52 | |
---|
[9348] | 53 | void TeamDeathmatch::end() |
---|
[2825] | 54 | { |
---|
[9348] | 55 | TeamGametype::end(); |
---|
[2825] | 56 | |
---|
[9348] | 57 | std::string message("The match has ended."); |
---|
| 58 | ChatManager::message(message); |
---|
[2825] | 59 | } |
---|
| 60 | |
---|
| 61 | void TeamDeathmatch::playerEntered(PlayerInfo* player) |
---|
| 62 | { |
---|
[9348] | 63 | TeamGametype::playerEntered(player); |
---|
[2825] | 64 | |
---|
[9348] | 65 | const std::string& message = player->getName() + " entered the game"; |
---|
| 66 | ChatManager::message(message); |
---|
[2825] | 67 | } |
---|
| 68 | |
---|
| 69 | bool TeamDeathmatch::playerLeft(PlayerInfo* player) |
---|
| 70 | { |
---|
[9348] | 71 | bool valid_player = TeamGametype::playerLeft(player); |
---|
[2825] | 72 | |
---|
| 73 | if (valid_player) |
---|
[9348] | 74 | { |
---|
| 75 | const std::string& message = player->getName() + " left the game"; |
---|
| 76 | ChatManager::message(message); |
---|
| 77 | } |
---|
[2825] | 78 | |
---|
| 79 | return valid_player; |
---|
| 80 | } |
---|
[9348] | 81 | bool TeamDeathmatch::playerChangedName(PlayerInfo* player) |
---|
[2825] | 82 | { |
---|
[9348] | 83 | bool valid_player = TeamGametype::playerChangedName(player); |
---|
[2825] | 84 | |
---|
[9348] | 85 | if (valid_player) |
---|
| 86 | { |
---|
| 87 | const std::string& message = player->getOldName() + " changed name to " + player->getName(); |
---|
| 88 | ChatManager::message(message); |
---|
| 89 | } |
---|
[2825] | 90 | |
---|
[9348] | 91 | return valid_player; |
---|
[2825] | 92 | } |
---|
| 93 | |
---|
[9348] | 94 | void TeamDeathmatch::pawnKilled(Pawn* victim, Pawn* killer) |
---|
[2825] | 95 | { |
---|
[9348] | 96 | if (victim && victim->getPlayer()) |
---|
[2825] | 97 | { |
---|
[9348] | 98 | std::string message; |
---|
| 99 | if (killer) |
---|
[2825] | 100 | { |
---|
[9348] | 101 | if (killer->getPlayer()) |
---|
| 102 | message = victim->getPlayer()->getName() + " was killed by " + killer->getPlayer()->getName(); |
---|
| 103 | else |
---|
| 104 | message = victim->getPlayer()->getName() + " was killed"; |
---|
[2825] | 105 | } |
---|
[9348] | 106 | else |
---|
| 107 | message = victim->getPlayer()->getName() + " died"; |
---|
[2825] | 108 | |
---|
[9348] | 109 | ChatManager::message(message); |
---|
[2825] | 110 | } |
---|
| 111 | |
---|
[9348] | 112 | Gametype::pawnKilled(victim, killer); |
---|
[2825] | 113 | } |
---|
| 114 | |
---|
[9348] | 115 | void TeamDeathmatch::playerScored(PlayerInfo* player, int score) |
---|
[2825] | 116 | { |
---|
[9348] | 117 | TeamGametype::playerScored(player, score); |
---|
[2825] | 118 | |
---|
[9348] | 119 | if (player) |
---|
[2825] | 120 | { |
---|
[9348] | 121 | const std::string& message = player->getName() + " scores!"; |
---|
| 122 | ChatManager::message(message); |
---|
[2825] | 123 | } |
---|
| 124 | } |
---|
| 125 | |
---|
| 126 | } |
---|