Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8827 in orxonox.OLD for branches/multi_player_map/src/util


Ignore:
Timestamp:
Jun 27, 2006, 2:46:40 PM (19 years ago)
Author:
rennerc
Message:

SpawningPoint works now

Location:
branches/multi_player_map/src/util
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/multi_player_map/src/util/multiplayer_team_deathmatch.cc

    r8809 r8827  
    487487  stats.setPlayableUniqueId( playable.getUniqueID() );
    488488  stats.setModelFileName( playableModel );
     489 
     490  this->respawnPlayable( &playable, stats.getPreferedTeamId(), 0.0f );
    489491
    490492  if ( oldPlayable )
     
    734736  }
    735737 
     738  this->respawnPlayable( killedStats.getPlayable(), killedStats.getTeamId(), 3.0f );
     739}
     740
     741/**
     742 * this function is called on player respawn
     743 * @param userId
     744 */
     745void MultiplayerTeamDeathmatch::onRespawn( int userId )
     746{
     747  if ( userId == SharedNetworkData::getInstance()->getHostID() )
     748  {
     749    this->bLocalPlayerDead = false;
     750    this->hideStats();
     751  }
     752}
     753
     754/**
     755 * this function is called on player respawn
     756 * @param we
     757 */
     758void MultiplayerTeamDeathmatch::registerSpawn( WorldEntity * we )
     759{
     760  onRespawn( we->getOwner() );
     761}
     762
     763void MultiplayerTeamDeathmatch::respawnPlayable( Playable * playable, int teamId, float delay )
     764{
    736765  const std::list<BaseObject*> * list = ClassList::getList( CL_SPAWNING_POINT );
    737766 
     
    744773    SpawningPoint * sp = dynamic_cast<SpawningPoint*>(*it);
    745774   
    746     if ( sp->getTeamId() < 0 || sp->getTeamId() == killedStats.getTeamId() )
     775    if ( sp->getTeamId() == teamId )
    747776      spList.push_back( sp );
    748777  }
     778 
     779  if ( spList.size() == 0 )
     780  {
     781    for ( std::list<BaseObject*>::const_iterator it = list->begin(); it != list->end(); it++ )
     782    {
     783      SpawningPoint * sp = dynamic_cast<SpawningPoint*>(*it);
     784   
     785      if ( sp->getTeamId() < 0 )
     786        spList.push_back( sp );
     787    }
     788  }
     789 
     790  assert( spList.size() != 0 );
    749791 
    750   int n = spList.size()*rand();
    751  
    752   spList[n]->pushEntity( killedStats.getPlayable(), 3 );
    753 }
    754 
    755 /**
    756  * this function is called on player respawn
    757  * @param userId
    758  */
    759 void MultiplayerTeamDeathmatch::onRespawn( int userId )
    760 {
    761   if ( userId == SharedNetworkData::getInstance()->getHostID() )
    762   {
    763     this->bLocalPlayerDead = false;
    764     this->hideStats();
    765   }
    766 }
    767 
    768 /**
    769  * this function is called on player respawn
    770  * @param we
    771  */
    772 void MultiplayerTeamDeathmatch::registerSpawn( WorldEntity * we )
    773 {
    774   onRespawn( we->getOwner() );
    775 }
    776 
     792  int n = (int)((float)spList.size() * (float)rand()/(float)RAND_MAX);
     793 
     794  spList[n]->pushEntity( playable, delay );
     795}
     796
  • branches/multi_player_map/src/util/multiplayer_team_deathmatch.h

    r8802 r8827  
    6060   
    6161    virtual void handleChatMessage( int userId, const std::string & message, int messageType );
     62   
     63    void respawnPlayable( Playable * playable, int teamId, float delay );
    6264
    6365  protected:
Note: See TracChangeset for help on using the changeset viewer.