void FinishClientPutInServer( CSDKPlayer *pPlayer )
{
	pPlayer->InitialSpawn();
	pPlayer->Spawn();

	if (!pPlayer->IsBot())
	{
		// When the player first joins the server, they
		pPlayer->m_takedamage = DAMAGE_YES;
		pPlayer->pl.deadflag = false;
		pPlayer->m_lifeState = LIFE_ALIVE;
		pPlayer->RemoveEffects( EF_NODRAW );
		pPlayer->ChangeTeam( TEAM_UNASSIGNED );
		pPlayer->SetThink( NULL );
	}

	char sName[128];
	Q_strncpy( sName, pPlayer->GetPlayerName(), sizeof( sName ) );
	
	// First parse the name and remove any %'s
	for ( char *pApersand = sName; pApersand != NULL && *pApersand != 0; pApersand++ )
	{
		// Replace it with a space
		if ( *pApersand == '%' )
				*pApersand = ' ';
	}

	// notify other clients of player joining the game
	UTIL_ClientPrintAll( HUD_PRINTNOTIFY, "#Game_connected", sName[0] != 0 ? sName : "<unconnected>" );
}
Beispiel #2
0
void CHalfLifeMultiplay :: InitHUD( CBasePlayer *pl )
{
	// notify other clients of player joining the game
	UTIL_ClientPrintAll( HUD_PRINTNOTIFY, UTIL_VarArgs( "%s has joined the game\n", 
		( pl->pev->netname && STRING(pl->pev->netname)[0] != 0 ) ? STRING(pl->pev->netname) : "unconnected" ) );
	
	UTIL_LogPrintf( "%s entered the game\n", GetLogStringForPlayer( pl->edict() ).c_str() );
	
	pl->EffectivePlayerClassChanged();
	
	SendMOTDToClient( pl->edict() );
	
	// loop through all active players and send their score info to the new client
	for ( int i = 1; i <= gpGlobals->maxClients; i++ )
	{
		// FIXME:  Probably don't need to cast this just to read m_iDeaths
		CBasePlayer *plr = (CBasePlayer *)UTIL_PlayerByIndex( i );
		
		if ( plr )
		{
			plr->EffectivePlayerClassChanged();
		}
	}
	
	if ( g_fGameOver )
	{
		MESSAGE_BEGIN( MSG_ONE, SVC_INTERMISSION, NULL, pl->edict() );
		MESSAGE_END();
	}
}
Beispiel #3
0
void FinishClientPutInServer( CHL2MP_Player *pPlayer )
{
	pPlayer->InitialSpawn();
	pPlayer->Spawn();


	char sName[128];
	Q_strncpy( sName, pPlayer->GetPlayerName(), sizeof( sName ) );
	
	// First parse the name and remove any %'s
	for ( char *pApersand = sName; pApersand != NULL && *pApersand != 0; pApersand++ )
	{
		// Replace it with a space
		if ( *pApersand == '%' )
				*pApersand = ' ';
	}

	// notify other clients of player joining the game
	UTIL_ClientPrintAll( HUD_PRINTNOTIFY, "#Game_connected", sName[0] != 0 ? sName : "<unconnected>" );

	//ClientPrint( pPlayer, HUD_PRINTTALK, "You are on team %s1\n", pPlayer->GetTeam()->GetName() ); //BG2 - Don't need this. -HairyPotter

	const ConVar *hostname = cvar->FindVar( "hostname" );
	const char *title = (hostname) ? hostname->GetString() : "MESSAGE OF THE DAY";

	KeyValues *data = new KeyValues("data");
	data->SetString( "title", title );		// info panel title
	data->SetString( "type", "1" );			// show userdata from stringtable entry
	data->SetString( "msg",	"motd" );		// use this stringtable entry

	pPlayer->ShowViewPortPanel( PANEL_INFO, true, data );

	data->deleteThis();
}
Beispiel #4
0
void CGameRules::ClientSettingsChanged( CBasePlayer *pPlayer )
{
	const char *pszName = engine->GetClientConVarValue( pPlayer->entindex(), "name" );

	const char *pszOldName = pPlayer->GetPlayerName();

	// msg everyone if someone changes their name,  and it isn't the first time (changing no name to current name)
	// Note, not using FStrEq so that this is case sensitive
	if ( pszOldName[0] != 0 && Q_strcmp( pszOldName, pszName ) )
	{
		char text[256];
		Q_snprintf( text,sizeof(text), "%s changed name to %s\n", pszOldName, pszName );

		UTIL_ClientPrintAll( HUD_PRINTTALK, text );

		IGameEvent * event = gameeventmanager->CreateEvent( "player_changename" );
		if ( event )
		{
			event->SetInt( "userid", pPlayer->GetUserID() );
			event->SetString( "oldname", pszOldName );
			event->SetString( "newname", pszName );
			gameeventmanager->FireEvent( event );
		}
		
		pPlayer->SetPlayerName( pszName );
	}
} 
void CHL2MPRules::CheckRestartGame( void )
{
    // Restart the game if specified by the server
    int iRestartDelay = mp_restartgame.GetInt();

    if ( iRestartDelay > 0 )
    {
        if ( iRestartDelay > 60 )
            iRestartDelay = 60;


        // let the players know
        char strRestartDelay[64];
        Q_snprintf( strRestartDelay, sizeof( strRestartDelay ), "%d", iRestartDelay );
        UTIL_ClientPrintAll( HUD_PRINTCENTER, "Game will restart in %s1 %s2", strRestartDelay, iRestartDelay == 1 ? "SECOND" : "SECONDS" );
        UTIL_ClientPrintAll( HUD_PRINTCONSOLE, "Game will restart in %s1 %s2", strRestartDelay, iRestartDelay == 1 ? "SECOND" : "SECONDS" );

        m_flRestartGameTime = gpGlobals->curtime + iRestartDelay;
        m_bCompleteReset = true;
        mp_restartgame.SetValue( 0 );
    }

    if( mp_readyrestart.GetBool() )
    {
        m_bAwaitingReadyRestart = true;
        m_bHeardAllPlayersReady = false;


        const char *pszReadyString = mp_ready_signal.GetString();


        // Don't let them put anything malicious in there
        if( pszReadyString == NULL || Q_strlen(pszReadyString) > 16 )
        {
            pszReadyString = "ready";
        }

        IGameEvent *event = gameeventmanager->CreateEvent( "hl2mp_ready_restart" );
        if ( event )
            gameeventmanager->FireEvent( event );

        mp_readyrestart.SetValue( 0 );

        // cancel any restart round in progress
        m_flRestartGameTime = -1;
    }
}
void CHalfLifeMultiplay :: InitHUD( CBasePlayer *pl )
{
	// notify other clients of player joining the game
	UTIL_ClientPrintAll( HUD_PRINTNOTIFY, UTIL_VarArgs( "%s has joined the game\n", 
		( pl->pev->netname && STRING(pl->pev->netname)[0] != 0 ) ? STRING(pl->pev->netname) : "unconnected" ) );

#if !defined( THREEWAVE )
	
	UTIL_LogPrintf( "\"%s<%i><%s><%i>\" entered the game\n",  
		STRING( pl->pev->netname ), 
		GETPLAYERUSERID( pl->edict() ),
		GETPLAYERAUTHID( pl->edict() ),
		GETPLAYERUSERID( pl->edict() ) );
#else

	UTIL_LogPrintf( "\"%s<%i><%s><%s>\" entered the game\n",  
		STRING( pl->pev->netname ), 
		GETPLAYERUSERID( pl->edict() ),
		GETPLAYERAUTHID( pl->edict() ),
		GetTeamName( pl->pev->team ) );
#endif

	UpdateGameMode( pl );

	// sending just one score makes the hud scoreboard active;  otherwise
	// it is just disabled for single play
	MESSAGE_BEGIN( MSG_ONE, gmsgScoreInfo, NULL, pl->edict() );
		WRITE_BYTE( ENTINDEX(pl->edict()) );
		WRITE_SHORT( 0 );
		WRITE_SHORT( 0 );
		WRITE_SHORT( 0 );
	MESSAGE_END();

	SendMOTDToClient( pl->edict() );

	// loop through all active players and send their score info to the new client
	for ( int i = 1; i <= gpGlobals->maxClients; i++ )
	{
		// FIXME:  Probably don't need to cast this just to read m_iDeaths
		CBasePlayer *plr = (CBasePlayer *)UTIL_PlayerByIndex( i );

		if ( plr )
		{
			MESSAGE_BEGIN( MSG_ONE, gmsgScoreInfo, NULL, pl->edict() );
				WRITE_BYTE( i );	// client number
				WRITE_SHORT( plr->pev->frags );
				WRITE_SHORT( plr->m_iDeaths );
				WRITE_SHORT( plr->pev->team );
			MESSAGE_END();
		}
	}

	if ( g_fGameOver )
	{
		MESSAGE_BEGIN( MSG_ONE, SVC_INTERMISSION, NULL, pl->edict() );
		MESSAGE_END();
	}
}
// Display all the Team Scores
void TeamFortress_TeamShowScores(BOOL bLong, CBasePlayer *pPlayer)
{
	for (int i = 1; i < g_Teams.Count(); i++)
	{
		if (!bLong)
		{
			// Dump short scores
			UTIL_ClientPrintAll( HUD_PRINTNOTIFY, UTIL_VarArgs("%s: %d\n", g_szTeamColors[i], GetGlobalTeam(i)->GetScore()) );
		}
		else
		{
			// Dump long scores
			if (pPlayer == NULL)
				UTIL_ClientPrintAll( HUD_PRINTNOTIFY, UTIL_VarArgs("Team %d (%s): %d\n", i, g_szTeamColors[i], GetGlobalTeam(i)->GetScore()) );
			else // Print to just one client
				ClientPrint( pPlayer, HUD_PRINTNOTIFY,  UTIL_VarArgs("Team %d (%s): %d\n", i, g_szTeamColors[i], GetGlobalTeam(i)->GetScore()) );
		}
	}
}
static int errormessage(lua_State* inState)
{
	const char *s = lua_tostring(inState, 1);
	if (s == NULL) s = "(no message)";
	char theErrorMessage[2048];
	sprintf(theErrorMessage, "Script error: %s\n", s);

	//fprintf(stderr, "error: %s\n", s);
	UTIL_ClientPrintAll(HUD_PRINTNOTIFY, theErrorMessage);
	
	return 0;
}
Beispiel #9
0
/*
===========
ClientPutInServer

called when the player is first put in the server
============
*/
void ClientPutInServer( edict_t *pEntity )
{
	CBasePlayer *pPlayer;

	entvars_t *pev = &pEntity->v;

	pPlayer = GetClassPtr((CBasePlayer *)pev);
	pPlayer->SetCustomDecalFrames(-1); // Assume none;

	// Allocate a CBasePlayer for pev, and call spawn
	pPlayer->Spawn();

	pPlayer->m_bHasDisconnected = FALSE;

	// Reset interpolation during first frame
	pPlayer->pev->effects |= EF_NOINTERP;
	pPlayer->m_pCurrentArena = NULL;
	pPlayer->m_flKnownItemTime = gpGlobals->time + 0.3;
	pPlayer->m_iLastGameResult = GAME_DIDNTPLAY;	

	// Add to an Arena (1 maxplayer allows mapmakers to run around their map)
	if ( InArenaMode() )
	{
		AddClientToArena( pPlayer );
	}
	else
	{
		// Put everyone on different teams
		pPlayer->pev->team = ENTINDEX( pEntity );
		pPlayer->pev->iuser4 = pPlayer->pev->team;

		// Set colors
		int iHue = GetHueFromRGB( g_iaDiscColors[ pPlayer->pev->team][0] / 255, g_iaDiscColors[pPlayer->pev->team][1] / 255, g_iaDiscColors[pPlayer->pev->team][2] / 255 );
		g_engfuncs.pfnSetClientKeyValue( ENTINDEX( pEntity ), g_engfuncs.pfnGetInfoKeyBuffer( pPlayer->edict() ), "topcolor", UTIL_VarArgs("%d", iHue) );
		g_engfuncs.pfnSetClientKeyValue( ENTINDEX( pEntity ), g_engfuncs.pfnGetInfoKeyBuffer( pPlayer->edict() ), "bottomcolor", UTIL_VarArgs("%d", iHue - 10) );
	}

	static char sName[128];
	strcpy(sName,STRING(pPlayer->pev->netname));
	
	// First parse the name and remove any %'s
	for ( char *pApersand = sName; pApersand != NULL && *pApersand != 0; pApersand++ )
	{
		// Replace it with a space
		if ( *pApersand == '%' )
				*pApersand = ' ';
	}

	// notify other clients of player joining the game
	UTIL_ClientPrintAll( HUD_PRINTNOTIFY, "#Game_connected", sName[0] != 0 ? sName : "<unconnected>" );
}
//=========================================================
// Configura y termina de agregar al jugador.
//=========================================================
void FinishClientPutInServer(CIN_Player *pPlayer)
{
    char sName[128];
    Q_strncpy(sName, pPlayer->GetPlayerName(), sizeof(sName));

    // Removemos cualquier % y lo reemplazamos por un espacio.
    for ( char *pApersand = sName; pApersand != NULL && *pApersand != 0; pApersand++ )
    {
        if ( *pApersand == '%' )
            *pApersand = ' ';
    }

    // Imprimimos un mensaje en la consola.
    UTIL_ClientPrintAll(HUD_PRINTNOTIFY, "#Game_connected", sName[0] != 0 ? sName : "<unconnected>");

    pPlayer->EquipSuit();
}
Beispiel #11
0
void CGameRules::ClientSettingsChanged( CBasePlayer *pPlayer )
{
	const char *pszName = engine->GetClientConVarValue( pPlayer->entindex(), "name" );

	const char *pszOldName = pPlayer->GetPlayerName();

	// msg everyone if someone changes their name,  and it isn't the first time (changing no name to current name)
	// Note, not using FStrEq so that this is case sensitive
	if ( pszOldName[0] != 0 && Q_strcmp( pszOldName, pszName ) )
	{
		char text[256];
		Q_snprintf( text,sizeof(text), "%s changed name to %s\n", pszOldName, pszName );

		UTIL_ClientPrintAll( HUD_PRINTTALK, text );

		IGameEvent * event = gameeventmanager->CreateEvent( "player_changename" );
		if ( event )
		{
			event->SetInt( "userid", pPlayer->GetUserID() );
			event->SetString( "oldname", pszOldName );
			event->SetString( "newname", pszName );
			gameeventmanager->FireEvent( event );
		}
		
		pPlayer->SetPlayerName( pszName );
	}

	const char *pszFov = engine->GetClientConVarValue( pPlayer->entindex(), "fov_desired" );
	if ( pszFov )
	{
		int iFov = atoi(pszFov);
		iFov = clamp( iFov, 75, 90 );
		pPlayer->SetDefaultFOV( iFov );
	}

	// NVNT see if this user is still or has began using a haptic device
	const char *pszHH = engine->GetClientConVarValue( pPlayer->entindex(), "hap_HasDevice" );
	if( pszHH )
	{
		int iHH = atoi( pszHH );
		pPlayer->SetHaptics( iHH != 0 );
	}
}
void FinishClientPutInServer( CHL2MP_Player *pPlayer )
{
	pPlayer->InitialSpawn();
	//BB: we dont want players to spawn immediately when joining the server, we want them to auto spectate
	//pPlayer->Spawn();
	pPlayer->ChangeTeam( TEAM_SPECTATOR );


	char sName[128];
	Q_strncpy( sName, pPlayer->GetPlayerName(), sizeof( sName ) );
	
	// First parse the name and remove any %'s
	for ( char *pApersand = sName; pApersand != NULL && *pApersand != 0; pApersand++ )
	{
		// Replace it with a space
		if ( *pApersand == '%' )
				*pApersand = ' ';
	}

	// notify other clients of player joining the game
	UTIL_ClientPrintAll( HUD_PRINTNOTIFY, "#Game_connected", sName[0] != 0 ? sName : "<unconnected>" );

	if ( HL2MPRules()->IsTeamplay() == true )
	{
		ClientPrint( pPlayer, HUD_PRINTTALK, "You are on team %s1\n", pPlayer->GetTeam()->GetName() );
	}

	const ConVar *hostname = cvar->FindVar( "hostname" );
	const char *title = (hostname) ? hostname->GetString() : "MESSAGE OF THE DAY";

	KeyValues *data = new KeyValues("data");
	data->SetString( "title", title );		// info panel title
	data->SetString( "type", "1" );			// show userdata from stringtable entry
	data->SetString( "msg",	"motd" );		// use this stringtable entry
	data->SetBool( "unload", sv_motd_unload_on_dismissal.GetBool() );

	//BB: Display the team selection panel...
	pPlayer->ShowViewPortPanel( PANEL_TEAM, true, data );
	pPlayer->ShowViewPortPanel( PANEL_INFO, true, data );

	data->deleteThis();
}
Beispiel #13
0
/*
===========
ClientDisconnect

called when a player disconnects from a server

GLOBALS ASSUMED SET:  g_fGameOver
============
*/
void ClientDisconnect( edict_t *pEntity )
{
	// If they're in an arena, remove them
	CBasePlayer *pPlayer = (CBasePlayer *)GET_PRIVATE(pEntity);
	if ( pPlayer->m_pCurrentArena )
		pPlayer->m_pCurrentArena->RemoveClient( pPlayer );

	if (g_fGameOver)
		return;

//	char text[256];
//	sprintf( text, "- %s has left the game\n", STRING(pEntity->v.netname) );
//	MESSAGE_BEGIN( MSG_BROADCAST, gmsgSayText, NULL );
//		WRITE_BYTE( ENTINDEX(pEntity) );
//		WRITE_STRING( text );
//	MESSAGE_END();

	// notify other clients the player has left
	UTIL_ClientPrintAll( HUD_PRINTNOTIFY, "#Game_disconnected", STRING(pEntity->v.netname) );

	CSound *pSound;
	pSound = CSoundEnt::SoundPointerForIndex( CSoundEnt::ClientSoundIndex( pEntity ) );
	{
		// since this client isn't around to think anymore, reset their sound. 
		if ( pSound )
		{
			pSound->Reset();
		}
	}

// since the edict doesn't get deleted, fix it so it doesn't interfere.
	pEntity->v.takedamage = DAMAGE_NO;// don't attract autoaim
	pEntity->v.solid = SOLID_NOT;// nonsolid
	UTIL_SetOrigin ( &pEntity->v, pEntity->v.origin );

	g_pGameRules->ClientDisconnected( pEntity );

	pPlayer->m_bHasDisconnected = true;
}
Beispiel #14
0
void FinishClientPutInServer( CSDKPlayer *pPlayer )
{
	pPlayer->InitialSpawn();
	pPlayer->Spawn();

	//Tony; changed from old SDK, we want to start out dead etc beacuse we're using states.

//	if (!pPlayer->IsBot())	//Tony; even bots should start out like this; we finish a spawn sequence.
	{
		// When the player first joins the server, they
		pPlayer->m_takedamage = DAMAGE_NO;
		pPlayer->pl.deadflag = true;
		pPlayer->m_lifeState = LIFE_DEAD;
		pPlayer->AddEffects( EF_NODRAW );
		pPlayer->ChangeTeam( TEAM_UNASSIGNED );
		pPlayer->SetThink( NULL );

		// Move them to the first intro camera.
		pPlayer->MoveToNextIntroCamera();
		pPlayer->SetMoveType( MOVETYPE_NONE );
	}

	char sName[128];
	Q_strncpy( sName, pPlayer->GetPlayerName(), sizeof( sName ) );
	
	// First parse the name and remove any %'s
	for ( char *pApersand = sName; pApersand != NULL && *pApersand != 0; pApersand++ )
	{
		// Replace it with a space
		if ( *pApersand == '%' )
				*pApersand = ' ';
	}

	// notify other clients of player joining the game
	UTIL_ClientPrintAll( HUD_PRINTNOTIFY, "#Game_connected", sName[0] != 0 ? sName : "<unconnected>" );
}
/* a simple "print". based on the code in lbaselib.c */
static int print(lua_State* inState)
{
	int n = lua_gettop(inState);
	int i;
	string theString;
	
	for (i=1; i<=n; i++)
	{
		if (i>1) theString = "\t";
		if (lua_isstring(inState, i))
			theString += string(lua_tostring(inState, i));
		else
		{
			char theBuffer[512];
			sprintf(theBuffer, "%s:%p",lua_typename(inState, lua_type(inState, i)),lua_topointer(inState,i));
			theString += string(theBuffer);
		}
	}
	//theString += string("\n");
	
	UTIL_ClientPrintAll(HUD_PRINTNOTIFY, theString.c_str());
	
	return 0;
}
Beispiel #16
0
void CHL2MPRules::Think( void )
{

#ifndef CLIENT_DLL

    CGameRules::Think();

    if ( g_fGameOver )   // someone else quit the game already
    {
        // check to see if we should change levels now
        if ( m_flIntermissionEndTime < gpGlobals->curtime )
        {
            if ( !m_bChangelevelDone )
            {
                ChangeLevel(); // intermission is over
                m_bChangelevelDone = true;
            }
        }

        return;
    }

//	float flTimeLimit = mp_timelimit.GetFloat() * 60;
    float flFragLimit = fraglimit.GetFloat();

    if ( GetMapRemainingTime() < 0 )
    {
        GoToIntermission();
        return;
    }

    if ( flFragLimit )
    {
        if( IsTeamplay() == true )
        {
            CTeam *pCombine = g_Teams[TEAM_COMBINE];
            CTeam *pRebels = g_Teams[TEAM_REBELS];

            if ( pCombine->GetScore() >= flFragLimit || pRebels->GetScore() >= flFragLimit )
            {
                GoToIntermission();
                return;
            }
        }
        else
        {
            // check if any player is over the frag limit
            for ( int i = 1; i <= gpGlobals->maxClients; i++ )
            {
                CBasePlayer *pPlayer = UTIL_PlayerByIndex( i );

                if ( pPlayer && pPlayer->FragCount() >= flFragLimit )
                {
                    GoToIntermission();
                    return;
                }
            }
        }
    }

    if ( gpGlobals->curtime > m_tmNextPeriodicThink )
    {
        CheckAllPlayersReady();
        CheckRestartGame();
        m_tmNextPeriodicThink = gpGlobals->curtime + 1.0;
    }

    if ( m_flRestartGameTime > 0.0f && m_flRestartGameTime <= gpGlobals->curtime )
    {
        RestartGame();
    }

    if( m_bAwaitingReadyRestart && m_bHeardAllPlayersReady )
    {
        UTIL_ClientPrintAll( HUD_PRINTCENTER, "All players ready. Game will restart in 5 seconds" );
        UTIL_ClientPrintAll( HUD_PRINTCONSOLE, "All players ready. Game will restart in 5 seconds" );

        m_flRestartGameTime = gpGlobals->curtime + 5;
        m_bAwaitingReadyRestart = false;
    }

    ManageObjectRelocation();

#endif
}
//=========================================================
// ClientUserInfoChanged
//=========================================================
void CTeamplayRules::ClientSettingsChanged( CBasePlayer *pPlayer )
{
	/* TODO: handle skin, model & team changes 

  	char text[1024];

	// skin/color/model changes
	int iTeam = Q_atoi( engine->GetClientConVarValue( pPlayer->entindex(), "cl_team" ) );
	int iClass = Q_atoi( engine->GetClientConVarValue( pPlayer->entindex(), "cl_class" ) );

	if ( defaultteam.GetBool() )
	{
		// int clientIndex = pPlayer->entindex();

		// engine->SetClientKeyValue( clientIndex, "model", pPlayer->TeamName() );
		// engine->SetClientKeyValue( clientIndex, "team", pPlayer->TeamName() );
		UTIL_SayText( "Not allowed to change teams in this game!\n", pPlayer );
		return;
	}

	if ( defaultteam.GetFloat() || !IsValidTeam( mdls ) )
	{
		// int clientIndex = pPlayer->entindex();

		// engine->SetClientKeyValue( clientIndex, "model", pPlayer->TeamName() );
		Q_snprintf( text,sizeof(text), "Can't change team to \'%s\'\n", mdls );
		UTIL_SayText( text, pPlayer );
		Q_snprintf( text,sizeof(text), "Server limits teams to \'%s\'\n", m_szTeamList );
		UTIL_SayText( text, pPlayer );
		return;
	}

	ChangePlayerTeam( pPlayer, mdls, true, true );
	// recound stuff
	RecountTeams(); */

	const char * name = engine->GetClientConVarValue( pPlayer->entindex(), "name" );

	// msg everyone if someone changes their name,  and it isn't the first time (changing no name to current name)
	// Note, not using FStrEq so that this is case sensitive
	if ( pPlayer->pl.netname != NULL_STRING && 
		 STRING(pPlayer->pl.netname)[0] != 0 && 
		 Q_strcmp( STRING(pPlayer->pl.netname), name ) )
	{
		// TODO trigger that on clients by event
		char text[256];
		Q_snprintf( text,sizeof(text), "%s changed name to %s\n", STRING(pPlayer->pl.netname), name );

		UTIL_ClientPrintAll( HUD_PRINTTALK, text );

		IGameEvent * event = gameeventmanager->CreateEvent( "player_changename" );
		if ( event )
		{
			event->SetInt( "userid", pPlayer->GetUserID() );
			event->SetString( "oldname", STRING(pPlayer->pl.netname) );
			event->SetString( "newname", name );
			gameeventmanager->FireEvent( event );
		}
		
		pPlayer->pl.netname = AllocPooledString( name );
	}
}
Beispiel #18
0
void CHeadQuartersRules :: HeadQThink( void )
{
	if( !CurrentBase )
		SpawnNextBase();

	if( SpawnTime + 20 > gpGlobals->time )
	{
		State = STATE_NONACTIVE;
		return;
	}

	if( State == STATE_NONACTIVE )
	{
		State = STATE_IDLE;
		UTIL_ClientPrintAll( HUD_PRINTCENTER, "Capture base!" );
	}

	bool IDLE = true;

	if( State == STATE_IDLE )
	{
		for( int i = 1; i <= 32; i++ )
		{
			CBaseEntity *pEnt = UTIL_PlayerByIndex( i );
			if( pEnt && Vector( pEnt->pev->origin - CurrentBase->pev->origin ).Length() < 256 && pEnt->pev->team )
			{
				State = STATE_CAPTURE;
				StartTime = gpGlobals->time;
				EndTime = StartTime + 15;
				IDLE = false;
			}
		}
	}

	else if( State == STATE_CAPTURE )
	{
		int CTCount = 0, TCount = 0;
		for( int i = 1; i <= 32; i++ )
		{
			CBaseEntity *pEnt = UTIL_PlayerByIndex( i );
			if( pEnt && Vector( pEnt->pev->origin - CurrentBase->pev->origin ).Length() < 256 && pEnt->pev->team )
			{
				if( pEnt->pev->team == 1 )
					TCount++;
				else if( pEnt->pev->team == 2 )
					CTCount++;
				IDLE = false;
			}
		}

		if( TCount ==  0 && CTCount == 0 )
			State = STATE_IDLE;

		if( !TCount && CTCount )
			CurrentTeam = 2;
		else if( TCount && !CTCount )
			CurrentTeam = 1;
		else
			CurrentTeam = 0;

		if( !CurrentTeam )
		{
			EndTime += gpGlobals->time - LFT;
			StartTime += gpGlobals->time - LFT;
		}
		else if( CurrentTeam != LastCurrentTeam )
		{
			int Count = abs( TCount - CTCount );
			StartTime = gpGlobals->time;
			EndTime = StartTime + 15 / Count;
		}
		else
		{
			int Count = abs( TCount - CTCount );
			EndTime = StartTime + 15 / Count;
		}

		if( CurrentTeam )
			LastCurrentTeam = CurrentTeam;

		char MSG[256];
		sprintf( MSG, "%d %f %f %f", State, StartTime, gpGlobals->time, EndTime );
		UTIL_ClientPrintAll( HUD_PRINTCENTER, MSG );

		if( EndTime <= gpGlobals->time )
		{
			State = STATE_DEFENDING;
			StartTime = gpGlobals->time;
			EndTime = StartTime + 90;
			DefBaseCap = false;
		}
	}

	else if( State == STATE_DEFENDING )
	{
		if( CurrentTeam == 1 && !T_Alive() )
		{
			State = STATE_IDLE;
			SpawnNextBase();
			return;
		}
		else if( CurrentTeam == 2 && !CT_Alive() )
		{
			State = STATE_IDLE;
			SpawnNextBase();
			return;
		}

		bool f = false;
		for( int i = 1; i <= 32; i++ )
		{
			int Count = 0;
			bool StopDef = false;
			CBaseEntity *pEnt = UTIL_PlayerByIndex( i );
			if( pEnt && Vector( pEnt->pev->origin - CurrentBase->pev->origin ).Length() < 256 && pEnt->pev->team )
			{
				if( pEnt->pev->team == CurrentTeam )
					StopDef = true;
				else
				{
					f = true;
					Count++;
				}
			}

			if( f )
			{
				if( !DefBaseCap )
				{
					StartTime2 = gpGlobals->time;
					EndTime2 = gpGlobals->time + 15;
					DefBaseCap = true;
				}
			}
			else
			{
				DefBaseCap = false;
			}

			if( DefBaseCap )
			{
				if( StopDef )
				{
					EndTime += gpGlobals->time - LFT;
					StartTime += gpGlobals->time - LFT;
				}
				EndTime2 = StartTime2 + 15 / Count;
				if( gpGlobals->time >= EndTime2 )
				{
					SpawnNextBase();
					State = STATE_IDLE;
				}
			}
		}
		IDLE = false;
		char MSG[256];
		sprintf( MSG, "%d %f %f %f", State, StartTime, gpGlobals->time, EndTime );
		UTIL_ClientPrintAll( HUD_PRINTCENTER, MSG );
		if( EndTime <= gpGlobals->time )
		{
			SpawnNextBase();
			State = STATE_IDLE;
		}
	}

	if( IDLE )
		State = STATE_IDLE;

	LFT = gpGlobals->time;
}
Beispiel #19
0
// Pickup backpack
BOOL CItemBackpack::MyTouch( CBasePlayer *pPlayer )
{
	if (pPlayer->pev->health <= 0)
		return FALSE;
	if (gpGlobals->deathmatch == 4 && pPlayer->m_flInvincibleFinished > 0)
		return FALSE;


 
	if (gpGlobals->deathmatch == 4)
	{       
		pPlayer->pev->health += 10;
		ClientPrint( pPlayer->pev, HUD_PRINTNOTIFY, "#Additional_Health" );
		if ((pPlayer->pev->health > 250) && (pPlayer->pev->health < 300))
			EMIT_SOUND( ENT(pPlayer->pev), CHAN_ITEM, "items/protect3.wav", 1, ATTN_NORM );
		else
			EMIT_SOUND( ENT(pPlayer->pev), CHAN_ITEM, "weapons/lock4.wav", 1, ATTN_NORM );
		
		// Become invulnerable if the player's reached 300 health
		if (pPlayer->pev->health > 299)
		{               
			if (pPlayer->m_flInvincibleFinished == 0)
			{                       
				// Give player invincibility and quad
				pPlayer->m_flInvincibleFinished = gpGlobals->time + 30;
				pPlayer->m_flSuperDamageFinished = gpGlobals->time + 30;
				pPlayer->m_iQuakeItems |= (IT_INVULNERABILITY | IT_QUAD);
				pPlayer->m_iAmmoCells = 0;		

				// Make player glow red
				pPlayer->pev->renderfx = kRenderFxGlowShell;
				pPlayer->pev->rendercolor = Vector( 255, 128, 0 );	// RGB
				pPlayer->pev->renderamt = 100;	// Shell size

				EMIT_SOUND( ENT(pPlayer->pev), CHAN_VOICE, "items/sight1.wav", 1, ATTN_NORM );
				UTIL_ClientPrintAll( HUD_PRINTNOTIFY, "#Bonus_Power", STRING(pPlayer->pev->netname) );
			}
		}

		UTIL_Remove( this );

		// We've removed ourself, so don't let CQuakeItem handle respawn
		return FALSE;
	}

	BOOL bPrintComma = FALSE;

	// Get the weapon from the pack
	if (m_iItems)
	{
		if ( !(pPlayer->m_iQuakeItems & m_iItems) )
		{
			bPrintComma = TRUE;

			switch ( m_iItems )
			{
			case IT_SUPER_SHOTGUN:
				ClientPrint( pPlayer->pev, HUD_PRINTNOTIFY, "#You_Get_SS", UTIL_dtos1( ammo_shells ), UTIL_dtos2 ( ammo_nails ), UTIL_dtos3 ( ammo_rockets ), UTIL_dtos4 ( ammo_cells ) ); break;
			case IT_NAILGUN:
				ClientPrint( pPlayer->pev, HUD_PRINTNOTIFY, "#You_Get_NG", UTIL_dtos1( ammo_shells ), UTIL_dtos2 ( ammo_nails ), UTIL_dtos3 ( ammo_rockets ), UTIL_dtos4 ( ammo_cells ) ); break;
			case IT_SUPER_NAILGUN:
				ClientPrint( pPlayer->pev, HUD_PRINTNOTIFY, "#You_Get_SG", UTIL_dtos1( ammo_shells ), UTIL_dtos2 ( ammo_nails ), UTIL_dtos3 ( ammo_rockets ), UTIL_dtos4 ( ammo_cells ) ); break;
			case IT_GRENADE_LAUNCHER:
				ClientPrint( pPlayer->pev, HUD_PRINTNOTIFY, "#You_Get_GL", UTIL_dtos1( ammo_shells ), UTIL_dtos2 ( ammo_nails ), UTIL_dtos3 ( ammo_rockets ), UTIL_dtos4 ( ammo_cells ) ); break;
			case IT_ROCKET_LAUNCHER:
				ClientPrint( pPlayer->pev, HUD_PRINTNOTIFY, "#You_Get_RL", UTIL_dtos1( ammo_shells ), UTIL_dtos2 ( ammo_nails ), UTIL_dtos3 ( ammo_rockets ), UTIL_dtos4 ( ammo_cells ) ); break;
			case IT_LIGHTNING:
				ClientPrint( pPlayer->pev, HUD_PRINTNOTIFY, "#You_Get_LG", UTIL_dtos1( ammo_shells ), UTIL_dtos2 ( ammo_nails ), UTIL_dtos3 ( ammo_rockets ), UTIL_dtos4 ( ammo_cells ) ); break;
			}
		}
		else
			ClientPrint( pPlayer->pev, HUD_PRINTNOTIFY, "#You_Get_NoGun", UTIL_dtos1( ammo_shells ), UTIL_dtos2 ( ammo_nails ), UTIL_dtos3 ( ammo_rockets ), UTIL_dtos4 ( ammo_cells ) );
	}
 
	// Get ammo from pack
	pPlayer->m_iAmmoShells += ammo_shells;
	pPlayer->m_iAmmoNails += ammo_nails;
	pPlayer->m_iAmmoRockets += ammo_rockets;
	pPlayer->m_iAmmoCells += ammo_cells;
	pPlayer->CheckAmmo();

	int iNewWeapon = m_iItems;
	if (!iNewWeapon)
		iNewWeapon = pPlayer->m_iQuakeWeapon;
	int iOldWeapon = pPlayer->m_iQuakeItems;
	pPlayer->m_iQuakeItems |= m_iItems;

	// Give them at least 5 rockets in DM==3 and DM==5
	if ( (gpGlobals->deathmatch==3 || gpGlobals->deathmatch == 5) & ( (WeaponCode(iNewWeapon)==6) || (WeaponCode(iNewWeapon)==7) ) & (pPlayer->m_iAmmoRockets < 5) )
		pPlayer->m_iAmmoRockets = 5;

	EMIT_SOUND( ENT(pPlayer->pev), CHAN_ITEM, "weapons/lock4.wav", 1, ATTN_NORM );

	// Switch to a better weapon
	if ( WeaponCode(iNewWeapon) <= pPlayer->m_iBackpackSwitch )
	{
		if (pPlayer->pev->flags & FL_INWATER)
		{
			if (iNewWeapon != IT_LIGHTNING)
			{
				pPlayer->Deathmatch_Weapon(iOldWeapon, iNewWeapon);
			}
		}
		else
		{                
			pPlayer->Deathmatch_Weapon(iOldWeapon, iNewWeapon);
		}
	}
	pPlayer->W_SetCurrentAmmo();
	pPlayer->m_iClientQuakeWeapon  = -1;
	pPlayer->m_fWeapon = FALSE;
	pPlayer->m_fKnownItem = FALSE;
	pPlayer->UpdateClientData();

	UTIL_Remove( this );

	// We've removed ourself, so don't let CQuakeItem handle respawn
	return FALSE;
}
Beispiel #20
0
/* <2464e8> ../cstrike/dlls/wpn_shared/wpn_c4.cpp:152 */
void CC4::__MAKE_VHOOK(PrimaryAttack)(void)
{
	BOOL PlaceBomb;
	int inBombZone, onGround;

	if (m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0)
	{
		return;
	}

	inBombZone = (m_pPlayer->m_signals.GetState() & SIGNAL_BOMB) == SIGNAL_BOMB;
	onGround = (m_pPlayer->pev->flags & FL_ONGROUND) == FL_ONGROUND;
	PlaceBomb = (onGround && inBombZone);

	if (!m_bStartedArming)
	{
		if (!inBombZone)
		{
			ClientPrint(m_pPlayer->pev, HUD_PRINTCENTER, "#C4_Plant_At_Bomb_Spot");
			m_flNextPrimaryAttack = GetNextAttackDelay(1.0);
			return;
		}

		if (!onGround)
		{
			ClientPrint(m_pPlayer->pev, HUD_PRINTCENTER, "#C4_Plant_Must_Be_On_Ground");
			m_flNextPrimaryAttack = GetNextAttackDelay(1);
			return;
		}

		m_bStartedArming = true;
		m_bBombPlacedAnimation = false;
		m_fArmedTime = gpGlobals->time + C4_ARMING_ON_TIME;

		SendWeaponAnim(C4_ARM, UseDecrement() != FALSE);

		SET_CLIENT_MAXSPEED(m_pPlayer->edict(), 1.0);

		m_pPlayer->SetAnimation(PLAYER_ATTACK1);
		m_pPlayer->SetProgressBarTime(C4_ARMING_ON_TIME);
	}
	else
	{
		if (PlaceBomb)
		{
			CBaseEntity *pEntity = NULL;
			CBasePlayer *pTempPlayer = NULL;

			if (m_fArmedTime <= gpGlobals->time)
			{
				if (m_bStartedArming)
				{
					m_bStartedArming = false;
					m_fArmedTime = 0;

					Broadcast("BOMBPL");
					m_pPlayer->m_bHasC4 = false;

					if (pev->speed != 0 && g_pGameRules != NULL)
					{
						g_pGameRules->m_iC4Timer = (int)pev->speed;
					}

					CGrenade *pBomb = CGrenade::ShootSatchelCharge(m_pPlayer->pev, m_pPlayer->pev->origin, Vector(0, 0, 0));

					MESSAGE_BEGIN(MSG_SPEC, SVC_DIRECTOR);
						WRITE_BYTE(9);
						WRITE_BYTE(DRC_CMD_EVENT);
						WRITE_SHORT(m_pPlayer->entindex());
						WRITE_SHORT(0);
						WRITE_LONG(DRC_FLAG_FACEPLAYER | 11);
					MESSAGE_END();

					MESSAGE_BEGIN(MSG_ALL, gmsgBombDrop);
						WRITE_COORD(pBomb->pev->origin.x);
						WRITE_COORD(pBomb->pev->origin.y);
						WRITE_COORD(pBomb->pev->origin.z);
						WRITE_BYTE(1);
					MESSAGE_END();

					UTIL_ClientPrintAll(HUD_PRINTCENTER, "#Bomb_Planted");

					TheBots->OnEvent(EVENT_BOMB_PLANTED, m_pPlayer, pBomb);

					if (g_pGameRules->IsCareer() && !m_pPlayer->IsBot())
					{
						TheCareerTasks->HandleEvent(EVENT_BOMB_PLANTED, m_pPlayer);
					}

					UTIL_LogPrintf
					(
						"\"%s<%i><%s><TERRORIST>\" triggered \"Planted_The_Bomb\"\n",
						STRING(m_pPlayer->pev->netname),
						GETPLAYERUSERID(m_pPlayer->edict()),
						GETPLAYERAUTHID(m_pPlayer->edict())
					);

					g_pGameRules->m_bBombDropped = FALSE;
					EMIT_SOUND(edict(), CHAN_WEAPON, "weapons/c4_plant.wav", VOL_NORM, ATTN_NORM);

					m_pPlayer->pev->body = 0;
					m_pPlayer->ResetMaxSpeed();
					m_pPlayer->SetBombIcon(FALSE);

					m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType]--;

					if (!m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType])
					{
						RetireWeapon();
						return;
					}
				}
			}
			else
			{
				if (m_fArmedTime - 0.75 <= gpGlobals->time && !m_bBombPlacedAnimation)
				{
					m_bBombPlacedAnimation = true;

					SendWeaponAnim(C4_DROP, UseDecrement() != FALSE);
					m_pPlayer->SetAnimation(PLAYER_HOLDBOMB);
				}
			}
		}
		else
		{
			if (inBombZone)
				ClientPrint(m_pPlayer->pev, HUD_PRINTCENTER, "#C4_Plant_Must_Be_On_Ground");
			else
				ClientPrint(m_pPlayer->pev, HUD_PRINTCENTER, "#C4_Arming_Cancelled");

			m_bStartedArming = false;
			m_flNextPrimaryAttack = GetNextAttackDelay(1.5);

			m_pPlayer->ResetMaxSpeed();
			m_pPlayer->SetProgressBarTime(0);
			m_pPlayer->SetAnimation(PLAYER_HOLDBOMB);

			SendWeaponAnim(m_bBombPlacedAnimation ? C4_DRAW : C4_IDLE1, UseDecrement() != FALSE);
			return;
		}
	}

	m_flNextPrimaryAttack = GetNextAttackDelay(0.3);
	m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + RANDOM_FLOAT(10, 15);
}
Beispiel #21
0
void CC4::PrimaryAttack(void)
{
	if (m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0)
		return;

	BOOL onBombZone = m_pPlayer->m_signals.GetState() & SIGNAL_BOMB;
	BOOL onGround = m_pPlayer->pev->flags & FL_ONGROUND;

	if (!m_bStartedArming)
	{
		if (!onBombZone)
		{
			ClientPrint(m_pPlayer->pev, HUD_PRINTCENTER, "#C4_Plant_At_Bomb_Spot");
			m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 1;
			return;
		}

		if (!onGround)
		{
			ClientPrint(m_pPlayer->pev, HUD_PRINTCENTER, "#C4_Plant_Must_Be_On_Ground");
			m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 1;
			return;
		}

		m_bStartedArming = true;
		m_bBombPlacedAnimation = false;
		m_fArmedTime = gpGlobals->time + 3;
		SendWeaponAnim(C4_ARM, UseDecrement() != FALSE);
		g_engfuncs.pfnSetClientMaxspeed(ENT(m_pPlayer->pev), 1);
		m_pPlayer->SetAnimation(PLAYER_ATTACK1);
		m_pPlayer->SetProgressBarTime(3);
		m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.3;
		m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + RANDOM_FLOAT(10, 15);
	}
	else
	{
		if (!onGround || !onBombZone)
		{
			if (onBombZone)
				ClientPrint(m_pPlayer->pev, HUD_PRINTCENTER, "#C4_Plant_Must_Be_On_Ground");
			else
				ClientPrint(m_pPlayer->pev, HUD_PRINTCENTER, "#C4_Arming_Cancelled");

			m_bStartedArming = false;
			m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 1.5;
			m_pPlayer->ResetMaxSpeed();
			m_pPlayer->SetProgressBarTime(0);
			m_pPlayer->SetAnimation(PLAYER_HOLDBOMB);

			if (m_bBombPlacedAnimation == true)
				SendWeaponAnim(C4_DRAW, UseDecrement() != FALSE);
			else
				SendWeaponAnim(C4_IDLE1, UseDecrement() != FALSE);

			return;
		}

		if (gpGlobals->time > m_fArmedTime)
		{
			if (m_bStartedArming == true)
			{
				m_bStartedArming = false;
				m_fArmedTime = 0;
				Broadcast("BOMBPL");
				m_pPlayer->m_bHasC4 = false;

#ifndef CLIENT_WEAPONS
				if (pev->speed != 0 && g_pGameRules)
					g_pGameRules->m_iC4Timer = (int)pev->speed;
#endif

				CGrenade *pGrenade = CGrenade::ShootSatchelCharge(m_pPlayer->pev, m_pPlayer->pev->origin, Vector(0, 0, 0));

				MESSAGE_BEGIN(MSG_SPEC, SVC_DIRECTOR);
				WRITE_BYTE(9);
				WRITE_BYTE(DRC_CMD_EVENT);
				WRITE_SHORT(ENTINDEX(m_pPlayer->edict()));
				WRITE_SHORT(0);
				WRITE_LONG(11 | DRC_FLAG_FACEPLAYER);
				MESSAGE_END();

#ifndef CLIENT_WEAPONS
				MESSAGE_BEGIN(MSG_ALL, gmsgBombDrop);
				WRITE_COORD(pGrenade->pev->origin.x);
				WRITE_COORD(pGrenade->pev->origin.y);
				WRITE_COORD(pGrenade->pev->origin.z);
				WRITE_BYTE(1);
				MESSAGE_END();
#endif

				UTIL_ClientPrintAll(HUD_PRINTCENTER, "#Bomb_Planted");

#ifndef CLIENT_WEAPONS
				if (g_pGameRules->IsCareer() && !m_pPlayer->IsBot())
				{
				}
#endif

				UTIL_LogPrintf("\"%s<%i><%s><TERRORIST>\" triggered \"Planted_The_Bomb\"\n", STRING(m_pPlayer->pev->netname), GETPLAYERUSERID(m_pPlayer->edict()), GETPLAYERAUTHID(m_pPlayer->edict()));

#ifndef CLIENT_WEAPONS
				g_pGameRules->m_bBombDropped = false;
#endif
				EMIT_SOUND(ENT(pev), CHAN_WEAPON, "weapons/c4_plant.wav", VOL_NORM, ATTN_NORM);

				m_pPlayer->pev->body = 0;
				m_pPlayer->ResetMaxSpeed();
				m_pPlayer->SetBombIcon(FALSE);
				m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType]--;

				if (!m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType])
				{
					RetireWeapon();
					return;
				}
			}
		}
		else
		{
			if (gpGlobals->time >= m_fArmedTime - 0.75)
			{
				if (m_bBombPlacedAnimation == false)
				{
					m_bBombPlacedAnimation = true;
					SendWeaponAnim(C4_DROP, UseDecrement() != FALSE);
					m_pPlayer->SetAnimation(PLAYER_HOLDBOMB);
				}
			}
		}
	}

	m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.3;
	m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + RANDOM_FLOAT(10, 15);
}
void CC4::PrimaryAttack()
{
	bool	PlaceBomb = false;
	CCSPlayer *pPlayer = GetPlayerOwner();


	int onGround = FBitSet( pPlayer->GetFlags(), FL_ONGROUND );

	if( m_bStartedArming == false )
	{
		if( pPlayer->m_bInBombZone && onGround )
		{
			m_bStartedArming = true;
			m_fArmedTime = gpGlobals->curtime + WEAPON_C4_ARM_TIME;
			m_bBombPlacedAnimation = false;
			//SendWeaponAnim( C4_ARM, UseDecrement() ? 1: 0 );

#if !defined( CLIENT_DLL )			
			// freeze the player in place while planting
			pPlayer->SetMaxSpeed( 1 );

			// player "arming bomb" animation
			pPlayer->SetAnimation( PLAYER_ATTACK1 );

			pPlayer->SetProgressBarTime( 3 );	
#endif
		}
		else
		{
			if ( !pPlayer->m_bInBombZone )
			{
				ClientPrint( pPlayer, HUD_PRINTCENTER, "#C4_Plant_At_Bomb_Spot");
			}
			else
			{
				ClientPrint( pPlayer, HUD_PRINTCENTER, "#C4_Plant_Must_Be_On_Ground");
			}

			m_flNextPrimaryAttack = gpGlobals->curtime + 1.0;
			return;
		}
	}
	else
	{
		if ( !onGround || !pPlayer->m_bInBombZone )
		{
			if( !pPlayer->m_bInBombZone )
			{
				ClientPrint( pPlayer, HUD_PRINTCENTER, "#C4_Arming_Cancelled" );
			}
			else
			{
				ClientPrint( pPlayer, HUD_PRINTCENTER, "#C4_Plant_Must_Be_On_Ground" );
			}

			m_flNextPrimaryAttack = gpGlobals->curtime + 1.5;
			m_bStartedArming = false;

#if !defined( CLIENT_DLL )
			// release the player from being frozen, we've somehow left the bomb zone
			pPlayer->ResetMaxSpeed();

			pPlayer->SetProgressBarTime( 0 );

			//pPlayer->SetAnimation( PLAYER_HOLDBOMB );

#endif
			/*
			if(m_bBombPlacedAnimation == true) //this means the placement animation is canceled
			{
				SendWeaponAnim( C4_DRAW, UseDecrement() ? 1: 0 );
			}
			else
			{
				SendWeaponAnim( C4_IDLE1, UseDecrement() ? 1: 0 );
			}
			*/
			
			return;
		}
		else
		{
			if( gpGlobals->curtime >= m_fArmedTime ) //the c4 is ready to be armed
			{
				//check to make sure the player is still in the bomb target area
				PlaceBomb = true;
			}
			else if( ( gpGlobals->curtime >= (m_fArmedTime - 0.75) ) && ( !m_bBombPlacedAnimation ) )
			{
				//call the c4 Placement animation 
				m_bBombPlacedAnimation = true;
				//SendWeaponAnim( C4_DROP, UseDecrement() ? 1: 0 );
				
#if !defined( CLIENT_DLL )
				// player "place" animation
				//pPlayer->SetAnimation( PLAYER_HOLDBOMB );
#endif
			}
		}
	}

	if ( PlaceBomb && m_bStartedArming )
	{
		m_bStartedArming = false;
		m_fArmedTime = 0;
		
		if( pPlayer->m_bInBombZone )
		{
#if !defined( CLIENT_DLL )
			//Broadcast("BOMBPL");

			CPlantedC4::ShootSatchelCharge( pPlayer, pPlayer->GetAbsOrigin(), QAngle(0,0,0) );

			// send director message, that something important happened here
			/*
			MESSAGE_BEGIN( MSG_SPEC, SVC_DIRECTOR );
				WRITE_BYTE ( 9 );	// command length in bytes
				WRITE_BYTE ( DRC_CMD_EVENT ); // bomb placed
				WRITE_SHORT( ENTINDEX(pPlayer->edict()) );
				WRITE_SHORT( 0 );
				WRITE_LONG( 11 | DRC_FLAG_FACEPLAYER );   // eventflags (priority and flags)
			MESSAGE_END();
			*/

			// tell the Ts the bomb has been planted (on radar)
			CTeam *pTeam = GetGlobalTeam( TEAM_TERRORIST );
			for ( int iPlayer=0; iPlayer < pTeam->GetNumPlayers(); iPlayer++ )
			{
				CBasePlayer *pTempPlayer = pTeam->GetPlayer( iPlayer );
				
				if ( pTempPlayer->m_lifeState != LIFE_DEAD )
				{
					/*
					MESSAGE_BEGIN( MSG_ONE, gmsgBombDrop, NULL, pTempPlayer->pev );
						WRITE_COORD( pBomb->pev->origin.x );
						WRITE_COORD( pBomb->pev->origin.y );
						WRITE_COORD( pBomb->pev->origin.z );
						WRITE_BYTE( 1 ); // bomb was planted
					MESSAGE_END();
					*/
				}			
			}

			UTIL_ClientPrintAll( HUD_PRINTCENTER,"#Bomb_Planted" );
			pPlayer->SetProgressBarTime( 0 );

			// tell bots the bomb has been planted
			//g_pBotControl->OnEvent( EVENT_BOMB_PLANTED, pPlayer );

			CSGameRules()->m_bBombDropped = false;

			// Play the plant sound.
			CPASAttenuationFilter filter( this );
			EmitSound( filter, entindex(), "c4.plant" );

			// release the player from being frozen
			pPlayer->ResetMaxSpeed();

			// Remove the C4 icon from the HUD
			//pPlayer->SetBombIcon();

			// No more c4!
			pPlayer->Weapon_Drop( this, NULL, NULL );
			UTIL_Remove( this );
#endif

			return;
		}
		else
		{
			ClientPrint( pPlayer, HUD_PRINTCENTER, "#C4_Activated_At_Bomb_Spot" );

#if !defined( CLIENT_DLL )
			//pPlayer->SetAnimation( PLAYER_HOLDBOMB );

			// release the player from being frozen
			pPlayer->ResetMaxSpeed();
#endif

			m_flNextPrimaryAttack = gpGlobals->curtime + 1.0;
			return;
		}
	}

	m_flNextPrimaryAttack = gpGlobals->curtime + 0.3;
	m_flTimeWeaponIdle = gpGlobals->curtime + random->RandomFloat ( 10, 15 );
}
Beispiel #23
0
static int luasrc_UTIL_ClientPrintAll (lua_State *L) {
  UTIL_ClientPrintAll(luaL_checkint(L, 1), luaL_checkstring(L, 2));
  return 0;
}