Changeset 8860 in orxonox.OLD for branches/multi_player_map/src/util
- Timestamp:
- Jun 28, 2006, 3:09:54 PM (18 years ago)
- Location:
- branches/multi_player_map/src/util
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/multi_player_map/src/util/multiplayer_team_deathmatch.cc
r8857 r8860 223 223 while ( this->killList.begin() != this->killList.end() ) 224 224 { 225 if ( this->killList.begin()->getKiller() != NULL && this->killList.begin()->getVictim() != NULL ) 226 onKill( this->killList.begin()->getKiller()->getOwner(), this->killList.begin()->getVictim()->getOwner() ); 225 onKill( this->killList.begin()->getVictim(), this->killList.begin()->getKiller() ); 227 226 this->killList.erase( this->killList.begin() ); 228 227 } … … 559 558 else if ( event.type == SDLK_TAB ) 560 559 { 561 if ( currentGameState == GAMESTATE_GAME && !event.bPressed && !EventHandler::getInstance()->isPressed( SDLK_RALT ) && !EventHandler::getInstance()->isPressed( SDLK_LALT ) )560 if ( currentGameState == GAMESTATE_GAME && event.bPressed && !EventHandler::getInstance()->isPressed( SDLK_RALT ) && !EventHandler::getInstance()->isPressed( SDLK_LALT ) ) 562 561 { 563 562 EventHandler::getInstance()->pushState( ES_MENU ); … … 716 715 * @param userId 717 716 */ 718 void MultiplayerTeamDeathmatch::onKill( int killedUserId, int userId ) 719 { 720 assert( PlayerStats::getStats( killedUserId ) ); 721 assert( PlayerStats::getStats( userId ) ); 722 723 PlayerStats & killedStats = *PlayerStats::getStats( killedUserId ); 724 PlayerStats & stats = *PlayerStats::getStats( userId ); 717 void MultiplayerTeamDeathmatch::onKill( WorldEntity * victim, WorldEntity * killer ) 718 { 719 if ( !victim ) 720 return; 721 if ( !killer ) 722 return; 723 724 int killerUserId = killer->getOwner(); 725 int victimUserId = victim->getOwner(); 726 727 PlayerStats & victimStats = *PlayerStats::getStats( victimUserId ); 728 PlayerStats & killerStats = *PlayerStats::getStats( killerUserId ); 729 730 if ( killerStats.getPlayable() != killer || victimStats.getPlayable() != victim ) 731 return; 725 732 726 733 //check for suicide 727 if ( kille dUserId != userId )734 if ( killerUserId != victimUserId ) 728 735 { 729 736 //check for teamkill 730 if ( stats.getTeamId() != killedStats.getTeamId() )731 { 732 stats.setScore( stats.getScore() + 1 );737 if ( victimStats.getTeamId() != killerStats.getTeamId() ) 738 { 739 killerStats.setScore( killerStats.getScore() + 1 ); 733 740 } 734 741 else 735 742 { 736 stats.setScore( stats.getScore() - 1 );743 killerStats.setScore( killerStats.getScore() - 1 ); 737 744 } 738 745 } 739 746 else 740 stats.setScore( stats.getScore() - 1 );741 742 if ( killedUserId == SharedNetworkData::getInstance()->getHostID() )747 killerStats.setScore( killerStats.getScore() - 1 ); 748 749 if ( victimUserId == SharedNetworkData::getInstance()->getHostID() ) 743 750 { 744 751 this->bLocalPlayerDead = true; … … 746 753 } 747 754 748 this->respawnPlayable( killedStats.getPlayable(), killedStats.getTeamId(), 3.0f );755 this->respawnPlayable( victimStats.getPlayable(), victimStats.getTeamId(), 3.0f ); 749 756 } 750 757 -
branches/multi_player_map/src/util/multiplayer_team_deathmatch.h
r8827 r8860 56 56 virtual void process(const Event &event); 57 57 58 void onKill( int killedUserId, int userId);58 void onKill( WorldEntity * victim, WorldEntity * killer ); 59 59 void onRespawn( int userId ); 60 60
Note: See TracChangeset
for help on using the changeset viewer.