Changeset 9008 in orxonox.OLD for trunk/src/util
- Timestamp:
- Jul 2, 2006, 2:22:19 PM (18 years ago)
- Location:
- trunk/src/util
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/util/game_rules.cc
r8802 r9008 90 90 if ( !SharedNetworkData::getInstance()->isGameServer() ) 91 91 return; 92 92 93 PRINTF(0)("Received Event: Kill\n"); 93 this->killList.push_back(kill); 94 95 this->killList.push_back( kill ); 94 96 } 95 97 -
trunk/src/util/game_rules.h
r8802 r9008 9 9 10 10 #include "base_object.h" 11 #include <list> 11 12 #include <vector> 12 13 … … 54 55 std::vector<MissionGoal*> missionList; //!< list of mission goals 55 56 56 std:: vector<Kill>killList; //!< list of kills in the world57 std::list<Kill> killList; //!< list of kills in the world 57 58 }; 58 59 -
trunk/src/util/multiplayer_team_deathmatch.cc
r8802 r9008 68 68 this->numTeams = 2; 69 69 this->currentGameState = GAMESTATE_PRE_GAME; 70 this->gameStateTimer = 10.0f;70 this->gameStateTimer = 3.0f; 71 71 this->bShowTeamChange = false; 72 72 … … 85 85 subscribeEvent( ES_MENU, SDLK_F1 ); 86 86 subscribeEvent( ES_MENU, KeyMapper::PEV_FIRE1 ); 87 87 88 88 this->notifier = new OrxGui::GLGuiNotifier(); 89 89 this->notifier->show(); … … 106 106 unsubscribeEvent( ES_MENU, SDLK_F1 ); 107 107 unsubscribeEvent( ES_MENU, KeyMapper::PEV_FIRE1 ); 108 108 109 109 if ( this->notifier ) 110 110 { … … 219 219 if ( !SharedNetworkData::getInstance()->isGameServer() ) 220 220 return; 221 221 222 222 //handle kills 223 for ( std::vector<Kill>::iterator it = this->killList.begin(); it != this->killList.end(); ) 224 { 225 std::vector<Kill>::iterator delit = it; 226 227 onKill( it->getKiller()->getOwner(), it->getVictim()->getOwner() ); 228 229 it++; 230 killList.erase( delit ); 223 while ( this->killList.begin() != this->killList.end() ) 224 { 225 onKill( this->killList.begin()->getVictim(), this->killList.begin()->getKiller() ); 226 this->killList.erase( this->killList.begin() ); 231 227 } 232 228 229 230 233 231 gameStateTimer -= dt; 234 232 //PRINTF(0)("TICK %f\n", gameStateTimer); … … 488 486 stats.setModelFileName( playableModel ); 489 487 488 this->respawnPlayable( &playable, stats.getPreferedTeamId(), 0.0f ); 489 490 490 if ( oldPlayable ) 491 491 { … … 558 558 else if ( event.type == SDLK_TAB ) 559 559 { 560 if ( !event.bPressed)560 if ( currentGameState == GAMESTATE_GAME && event.bPressed && !EventHandler::getInstance()->isPressed( SDLK_RALT ) && !EventHandler::getInstance()->isPressed( SDLK_LALT ) ) 561 561 { 562 562 EventHandler::getInstance()->pushState( ES_MENU ); … … 627 627 statsBox = new OrxGui::GLGuiBox(); 628 628 statsBox->setAbsCoor2D( 300, 100 ); 629 629 630 630 this->table = new OrxGui::GLGuiTable(0,0); 631 631 … … 645 645 statsBox = NULL; 646 646 } 647 647 648 648 EventHandler::getInstance()->popState(); 649 649 } … … 664 664 headers.push_back(""); 665 665 this->table->setHeader(headers); 666 666 667 667 std::map<int,std::string> fragsTeam0; 668 668 std::map<int,std::string> fragsTeam1; 669 669 670 670 const std::list<BaseObject*> * list = ClassList::getList( CL_PLAYER_STATS ); 671 671 672 672 if ( !list ) 673 673 return; 674 674 675 675 for ( std::list<BaseObject*>::const_iterator it = list->begin(); it != list->end(); it++ ) 676 676 { 677 677 PlayerStats & stats = *dynamic_cast<PlayerStats*>(*it); 678 678 679 679 if ( stats.getTeamId() == 0 || stats.getTeamId() == 1 ) 680 680 { … … 685 685 } 686 686 } 687 687 688 688 char st[10]; 689 689 int i = 0; 690 691 690 691 692 692 i = 2; 693 693 for ( std::map<int,std::string>::const_iterator it = fragsTeam0.begin(); it != fragsTeam0.end(); it++ ) … … 699 699 i++; 700 700 } 701 701 702 702 i = 2; 703 703 for ( std::map<int,std::string>::const_iterator it = fragsTeam1.begin(); it != fragsTeam1.end(); it++ ) … … 712 712 /** 713 713 * this function is called when a player kills another one or himself 714 * @param killedUserId 715 * @param userId 716 */ 717 void MultiplayerTeamDeathmatch::onKill( int killedUserId, int userId ) 718 { 719 assert( PlayerStats::getStats( killedUserId ) ); 720 assert( PlayerStats::getStats( userId ) ); 714 * @param killedUserId 715 * @param userId 716 */ 717 void MultiplayerTeamDeathmatch::onKill( WorldEntity * victim, WorldEntity * killer ) 718 { 719 if ( !victim ) 720 return; 721 if ( !killer ) 722 return; 721 723 722 PlayerStats & killedStats = *PlayerStats::getStats( killedUserId ); 723 PlayerStats & stats = *PlayerStats::getStats( userId ); 724 int killerUserId = killer->getOwner(); 725 int victimUserId = victim->getOwner(); 726 727 PlayerStats & victimStats = *PlayerStats::getStats( victimUserId ); 728 PlayerStats & killerStats = *PlayerStats::getStats( killerUserId ); 724 729 725 if ( killedUserId != userId ) 726 stats.setScore( stats.getScore() + 1 ); 730 if ( killerStats.getPlayable() != killer || victimStats.getPlayable() != victim ) 731 return; 732 733 //check for suicide 734 if ( killerUserId != victimUserId ) 735 { 736 //check for teamkill 737 if ( victimStats.getTeamId() != killerStats.getTeamId() ) 738 { 739 killerStats.setScore( killerStats.getScore() + 1 ); 740 } 741 else 742 { 743 killerStats.setScore( killerStats.getScore() - 1 ); 744 } 745 } 727 746 else 728 stats.setScore( stats.getScore() - 1 );729 730 if ( killedUserId == SharedNetworkData::getInstance()->getHostID() )747 killerStats.setScore( killerStats.getScore() - 1 ); 748 749 if ( victimUserId == SharedNetworkData::getInstance()->getHostID() ) 731 750 { 732 751 this->bLocalPlayerDead = true; 733 752 this->showStats(); 734 753 } 735 736 const std::list<BaseObject*> * list = ClassList::getList( CL_SPAWNING_POINT ); 737 738 assert( list ); 739 740 std::vector<SpawningPoint*> spList; 741 742 for ( std::list<BaseObject*>::const_iterator it = list->begin(); it != list->end(); it++ ) 743 { 744 SpawningPoint * sp = dynamic_cast<SpawningPoint*>(*it); 745 746 if ( sp->getTeamId() < 0 || sp->getTeamId() == killedStats.getTeamId() ) 747 spList.push_back( sp ); 748 } 749 750 int n = spList.size()*rand(); 751 752 spList[n]->pushEntity( killedStats.getPlayable(), 3 ); 754 755 this->respawnPlayable( victimStats.getPlayable(), victimStats.getTeamId(), 3.0f ); 753 756 } 754 757 755 758 /** 756 759 * this function is called on player respawn 757 * @param userId 760 * @param userId 758 761 */ 759 762 void MultiplayerTeamDeathmatch::onRespawn( int userId ) … … 768 771 /** 769 772 * this function is called on player respawn 770 * @param we 773 * @param we 771 774 */ 772 775 void MultiplayerTeamDeathmatch::registerSpawn( WorldEntity * we ) … … 775 778 } 776 779 780 781 void MultiplayerTeamDeathmatch::respawnPlayable( Playable * playable, int teamId, float delay ) 782 { 783 const std::list<BaseObject*> * list = ClassList::getList( CL_SPAWNING_POINT ); 784 785 assert( list ); 786 787 std::vector<SpawningPoint*> spList; 788 789 for ( std::list<BaseObject*>::const_iterator it = list->begin(); it != list->end(); it++ ) 790 { 791 SpawningPoint * sp = dynamic_cast<SpawningPoint*>(*it); 792 793 if ( sp->getTeamId() == teamId ) 794 spList.push_back( sp ); 795 } 796 797 if ( spList.size() == 0 ) 798 { 799 for ( std::list<BaseObject*>::const_iterator it = list->begin(); it != list->end(); it++ ) 800 { 801 SpawningPoint * sp = dynamic_cast<SpawningPoint*>(*it); 802 803 if ( sp->getTeamId() < 0 ) 804 spList.push_back( sp ); 805 } 806 } 807 808 assert( spList.size() != 0 ); 809 810 int n = (int)((float)spList.size() * (float)rand()/(float)RAND_MAX); 811 812 spList[n]->pushEntity( playable, delay ); 813 } 814 -
trunk/src/util/multiplayer_team_deathmatch.h
r8802 r9008 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 61 61 virtual void handleChatMessage( int userId, const std::string & message, int messageType ); 62 63 void respawnPlayable( Playable * playable, int teamId, float delay ); 62 64 63 65 protected: -
trunk/src/util/object_manager.cc
r8362 r9008 212 212 "background", 213 213 "common", 214 215 "players", 216 "players-proj", 214 217 215 218 "group00",
Note: See TracChangeset
for help on using the changeset viewer.