Exemplo n.º 1
0
// called by ClientKill and DeadThink
void respawn( CBaseEntity *pEdict, bool fCopyCorpse )
{
	/*CHL2MP_Player *pPlayer = ToHL2MPPlayer( pEdict );

	if ( pPlayer )
	{
		if ( gpGlobals->curtime > pPlayer->GetDeathTime() + DEATH_ANIMATION_TIME )
		{		
			// respawn player
			pPlayer->Spawn();			
		}
		else
		{
			pPlayer->SetNextThink( gpGlobals->curtime + 0.1f );
		}
	}*/
	CHL2MP_Player *pPlayer = ToHL2MPPlayer( pEdict );

	if ( pPlayer )
	{
		//BG2 - Draco - Start(this is the part that supresses respawns when mp_respawnstyle != 0)
		//if ( gpGlobals->curtime > pPlayer->GetDeathTime() + DEATH_ANIMATION_TIME )
		//BG2 - Tjoppen - assume this function only gets called if we're allowed to respawn/spawn

		// respawn player
		pPlayer->Spawn();
	}
}
Exemplo n.º 2
0
// called by ClientKill and DeadThink
void respawn( CBaseEntity *pEdict, bool fCopyCorpse )
{
	CHL2MP_Player *pPlayer = ToHL2MPPlayer( pEdict );
	if ( pPlayer )
	{
		if ( gpGlobals->curtime > pPlayer->GetDeathTime() + DEATH_ANIMATION_TIME )
			pPlayer->Spawn();
		else
			pPlayer->SetNextThink( gpGlobals->curtime + 0.1f );
	}
}
Exemplo n.º 3
0
//-----------------------------------------------------------------------------
// Purpose: Create a new Bot and put it in the game.
// Output : Pointer to the new Bot, or NULL if there's no free clients.
//-----------------------------------------------------------------------------
CBasePlayer *BotPutInServer( bool bFrozen, int iTeam )
{
    g_iNextBotTeam = iTeam;

    char botname[ 64 ];
    Q_snprintf( botname, sizeof( botname ), "Bot%02i", BotNumber );

    // This is an evil hack, but we use it to prevent sv_autojointeam from kicking in.

    edict_t *pEdict = engine->CreateFakeClient( botname );

    if (!pEdict)
    {
        Msg( "Failed to create Bot.\n");
        return NULL;
    }

    // Allocate a CBasePlayer for the bot, and call spawn
    //ClientPutInServer( pEdict, botname );
    CHL2MP_Player *pPlayer = ((CHL2MP_Player *)CBaseEntity::Instance( pEdict ));
    pPlayer->ClearFlags();
    pPlayer->AddFlag( FL_CLIENT | FL_FAKECLIENT );

    if ( bFrozen )
        pPlayer->AddEFlags( EFL_BOT_FROZEN );

    BotNumber++;

    g_BotData[pPlayer->entindex()-1].m_WantedTeam = iTeam;
    g_BotData[pPlayer->entindex()-1].m_flJoinTeamTime = gpGlobals->curtime + 0.3;

    //DHL - Skillet - Spawn the bot
    pPlayer->ChangeTeam( TEAM_UNASSIGNED ); //This is required for PickDefaultSpawnTeam() to work
    pPlayer->Spawn();
    //pPlayer->SetModelName( MAKE_STRING(bot_playermodel.GetString()) );
    if ( Q_strlen( bot_playermodel.GetString() ) > 2 )
        pPlayer->SetModel( bot_playermodel.GetString() );

    return pPlayer;
}
void CHL2MPRules::RestartGame()
{
	// bounds check
	if ( mp_timelimit.GetInt() < 0 )
	{
		mp_timelimit.SetValue( 0 );
	}
	m_flGameStartTime = gpGlobals->curtime;
	if ( !IsFinite( m_flGameStartTime.Get() ) )
	{
		Warning( "Trying to set a NaN game start time\n" );
		m_flGameStartTime.GetForModify() = 0.0f;
	}

	// Pre Map Cleanup
	for (int i = 1; i <= gpGlobals->maxClients; i++ )
	{
		CHL2MP_Player *pPlayer = (CHL2MP_Player*) UTIL_PlayerByIndex( i );

		if ( !pPlayer )
			continue;

		//Tony; if they aren't a spectator, make sure they get cleaned up before entities are removed!
		if ( pPlayer->GetTeamNumber() != TEAM_SPECTATOR )
		{
				// If they're in a vehicle, make sure they get out!
				if ( pPlayer->IsInAVehicle() )
					pPlayer->LeaveVehicle();

				QAngle angles = pPlayer->GetLocalAngles();

				angles.x = 0;
				angles.z = 0;

				pPlayer->SetLocalAngles( angles );
				CBaseCombatWeapon *pWeapon = (CBaseCombatWeapon*)pPlayer->GetActiveWeapon();
				if (pWeapon)
				{
					pPlayer->Weapon_Detach( pWeapon );
					UTIL_Remove( pWeapon );
				}
		}
		pPlayer->RemoveAllItems(true);
		pPlayer->ClearActiveWeapon();
		pPlayer->Reset();
	}

	CleanUpMap();
	
	// now that everything is cleaned up, respawn everyone.
	for (int i = 1; i <= gpGlobals->maxClients; i++ )
	{
		CHL2MP_Player *pPlayer = (CHL2MP_Player*) UTIL_PlayerByIndex( i );

		if ( !pPlayer )
			continue;

		//Tony; if they aren't a spectator, respawn them.
		if ( pPlayer->GetTeamNumber() != TEAM_SPECTATOR )
			pPlayer->Spawn();
	}

	CTeam *pRebels = GetGlobalTeam( TEAM_REBELS );
	CTeam *pCombine = GetGlobalTeam( TEAM_COMBINE );

	if ( pRebels )
	{
		pRebels->SetRoundScore( 0 );
	}

	if ( pCombine )
	{
		pCombine->SetRoundScore( 0 );
	}

	m_flIntermissionEndTime = 0;
	m_flRestartGameTime = 0.0;		
	m_bCompleteReset = false;

	IGameEvent * event = gameeventmanager->CreateEvent( "round_start" );
	if ( event )
	{
		event->SetInt("fraglimit", 0 );
		event->SetInt( "priority", 6 ); // HLTV event priority, not transmitted

		event->SetString("objective","DEATHMATCH");

		gameeventmanager->FireEvent( event );
	}
}