Ejemplo n.º 1
0
//=========================================================
//=========================================================
void CHalfLifeMultiplay :: ClientDisconnected( edict_t *pClient )
{
	if ( pClient )
	{
		CBasePlayer *pPlayer = (CBasePlayer *)CBaseEntity::Instance( pClient );

		if ( pPlayer )
		{
			FireTargets( "game_playerleave", pPlayer, pPlayer, USE_TOGGLE, 0 );

#if !defined( THREEWAVE )

			UTIL_LogPrintf( "\"%s<%i><%s><%i>\" disconnected\n",  
				STRING( pPlayer->pev->netname ), 
				GETPLAYERUSERID( pPlayer->edict() ),
				GETPLAYERAUTHID( pPlayer->edict() ),
				GETPLAYERUSERID( pPlayer->edict() ) );
#else
			UTIL_LogPrintf( "\"%s<%i><%s><%s>\" disconnected\n",  
				STRING( pPlayer->pev->netname ), 
				GETPLAYERUSERID( pPlayer->edict() ),
				GETPLAYERAUTHID( pPlayer->edict() ),
				GetTeamName( pPlayer->pev->team ) );
#endif

			pPlayer->RemoveAllItems( TRUE );// destroy all of the players weapons and items
		}
	}
}
//=========================================================
//=========================================================
void CHalfLifeMultiplay :: ClientDisconnected( edict_t *pClient )
{
	if ( pClient )
	{
		CBasePlayer *pPlayer = (CBasePlayer *)CBaseEntity::Instance( pClient );

		if ( pPlayer )
		{
			FireTargets( "game_playerleave", pPlayer, pPlayer, USE_TOGGLE, 0 );

			// team match?
			if ( g_teamplay )
			{
				UTIL_LogPrintf( "\"%s<%i><%s><%s>\" disconnected\n",  
					STRING( pPlayer->pev->netname ), 
					GETPLAYERUSERID( pPlayer->edict() ),
					GETPLAYERAUTHID( pPlayer->edict() ),
					g_engfuncs.pfnInfoKeyValue( g_engfuncs.pfnGetInfoKeyBuffer( pPlayer->edict() ), "model" ) );
			}
			else
			{
				UTIL_LogPrintf( "\"%s<%i><%s><%i>\" disconnected\n",  
					STRING( pPlayer->pev->netname ), 
					GETPLAYERUSERID( pPlayer->edict() ),
					GETPLAYERAUTHID( pPlayer->edict() ),
					GETPLAYERUSERID( pPlayer->edict() ) );
			}

			pPlayer->RemoveAllItems( TRUE );// destroy all of the players weapons and items
		}
	}
}
Ejemplo n.º 3
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" ) );

#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();
	}
}
Ejemplo n.º 4
0
/*
========================
ClientUserInfoChanged

called after the player changes
userinfo - gives dll a chance to modify it before
it gets sent into the rest of the engine.
========================
*/
void ClientUserInfoChanged( edict_t *pEntity, char *infobuffer )
{
	// Is the client spawned yet?
	if ( !pEntity->pvPrivateData )
		return;

	// msg everyone if someone changes their name,  and it isn't the first time (changing no name to current name)
	if ( pEntity->v.netname && STRING(pEntity->v.netname)[0] != 0 && !FStrEq( STRING(pEntity->v.netname), g_engfuncs.pfnInfoKeyValue( infobuffer, "name" )) )
	{
		char sName[256];
		char *pName = g_engfuncs.pfnInfoKeyValue( infobuffer, "name" );
		strncpy( sName, pName, sizeof(sName) - 1 );
		sName[ sizeof(sName) - 1 ] = '\0';

		// 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 = ' ';
		}

		// Set the name
		g_engfuncs.pfnSetClientKeyValue( ENTINDEX(pEntity), infobuffer, "name", sName );

		char text[256];
		sprintf( text, "* %s changed name to %s\n", STRING(pEntity->v.netname), g_engfuncs.pfnInfoKeyValue( infobuffer, "name" ) );
		MESSAGE_BEGIN( MSG_ALL, gmsgSayText, NULL );
			WRITE_BYTE( ENTINDEX(pEntity) );
			WRITE_STRING( text );
		MESSAGE_END();

		// team match?
		if ( g_teamplay )
		{
			UTIL_LogPrintf( "\"%s<%i><%s><%s>\" changed name to \"%s\"\n", 
				STRING( pEntity->v.netname ), 
				GETPLAYERUSERID( pEntity ), 
				GETPLAYERAUTHID( pEntity ),
				g_engfuncs.pfnInfoKeyValue( infobuffer, "model" ), 
				g_engfuncs.pfnInfoKeyValue( infobuffer, "name" ) );
		}
		else
		{
			UTIL_LogPrintf( "\"%s<%i><%s><%i>\" changed name to \"%s\"\n", 
				STRING( pEntity->v.netname ), 
				GETPLAYERUSERID( pEntity ), 
				GETPLAYERAUTHID( pEntity ),
				GETPLAYERUSERID( pEntity ), 
				g_engfuncs.pfnInfoKeyValue( infobuffer, "name" ) );
		}
	}

	g_pGameRules->ClientUserInfoChanged( GetClassPtr((CBasePlayer *)&pEntity->v), infobuffer );
}
Ejemplo n.º 5
0
void CHalfLifeMultiplay :: InitHUD( CBasePlayer *pl )
{
	UTIL_LogPrintf( "\"%s<%i><%s><%i>\" entered the game\n",  
		STRING( pl->pev->netname ), 
		GETPLAYERUSERID( pl->edict() ),
		GETPLAYERAUTHID( pl->edict() ),
		GETPLAYERUSERID( pl->edict() ) );

	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 );
		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 )
		{
			ALERT( at_console, "Sending %s data to %s\n", STRING(plr->pev->netname), STRING( pl->pev->netname ) );

			MESSAGE_BEGIN( MSG_ONE, gmsgScoreInfo, NULL, pl->edict() );
				WRITE_BYTE( i );	// client number
				WRITE_SHORT( static_cast<int>(plr->pev->frags) );
				WRITE_SHORT( plr->m_iDeaths );
				WRITE_SHORT( plr->pev->playerclass );
				WRITE_SHORT( plr->pev->team );
			MESSAGE_END();

			// Send their spectator state
			MESSAGE_BEGIN( MSG_ONE, gmsgSpectator, NULL, pl->edict() );  
				WRITE_BYTE( i );
				WRITE_BYTE( (plr->pev->iuser1 != 0) );
			MESSAGE_END();
		}
	}

	if ( g_fGameOver )
	{
		MESSAGE_BEGIN( MSG_ONE, SVC_INTERMISSION, NULL, pl->edict() );
		MESSAGE_END();
	}
}
Ejemplo n.º 6
0
/*
========================
ClientUserInfoChanged

called after the player changes
userinfo - gives dll a chance to modify it before
it gets sent into the rest of the engine.
========================
*/
void ClientUserInfoChanged( edict_t *pEntity, char *infobuffer )
{
	// Is the client spawned yet?
	if ( !pEntity->pvPrivateData )
		return;

	// msg everyone if someone changes their name,  and it isn't the first time (changing no name to current name)
	if ( pEntity->v.netname && STRING(pEntity->v.netname)[0] != 0 && !FStrEq( STRING(pEntity->v.netname), g_engfuncs.pfnInfoKeyValue( infobuffer, "name" )) )
	{
		char sName[256];
		char *pName = g_engfuncs.pfnInfoKeyValue( infobuffer, "name" );
		strncpy( sName, pName, sizeof(sName) - 1 );
		sName[ sizeof(sName) - 1 ] = '\0';

		// 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 = ' ';
		}

		// Set the name
		g_engfuncs.pfnSetClientKeyValue( ENTINDEX(pEntity), infobuffer, "name", sName );

		char text[256];
		sprintf( text, "* %s changed name to %s\n", STRING(pEntity->v.netname), g_engfuncs.pfnInfoKeyValue( infobuffer, "name" ) );
		MESSAGE_BEGIN( MSG_ALL, gmsgSayText, NULL );
			WRITE_BYTE( ENTINDEX(pEntity) );
			WRITE_STRING( text );
		MESSAGE_END();

		UTIL_LogPrintf( "\"%s<%i><%s><%i>\" changed name to \"%s\"\n", 
			STRING( pEntity->v.netname ), 
			GETPLAYERUSERID( pEntity ), 
			GETPLAYERAUTHID( pEntity ),
			GETPLAYERUSERID( pEntity ), 
			g_engfuncs.pfnInfoKeyValue( infobuffer, "name" ) );
	}

	g_pGameRules->ClientUserInfoChanged( GetClassPtr((CBasePlayer *)&pEntity->v), infobuffer );

	// Override model
	if ( (!strcmp( "models/player/female/female.mdl", g_engfuncs.pfnInfoKeyValue( infobuffer, "model" ) )) )//&& (!strcmp( "models/player/hgrunt/hgrunt.mdl" )) )
		SET_MODEL( pEntity, "models/player/male/male.mdl" );
	g_engfuncs.pfnSetClientKeyValue( ENTINDEX( pEntity ), infobuffer, "model", "male" );

	// Set colors
	int iHue = GetHueFromRGB( g_iaDiscColors[ pEntity->v.team][0] / 255, g_iaDiscColors[pEntity->v.team][1] / 255, g_iaDiscColors[pEntity->v.team][2] / 255 );
	g_engfuncs.pfnSetClientKeyValue( ENTINDEX( pEntity ), infobuffer, "topcolor", UTIL_VarArgs("%d", iHue) );
	g_engfuncs.pfnSetClientKeyValue( ENTINDEX( pEntity ), infobuffer, "bottomcolor", UTIL_VarArgs("%d", iHue - 10) );
}
Ejemplo n.º 7
0
//=========================================================
//=========================================================
void CHalfLifeMultiplay :: ClientDisconnected( edict_t *pClient )
{
	if ( pClient )
	{
		CBasePlayer *pPlayer = (CBasePlayer *)CBaseEntity::Instance( pClient );

		if ( pPlayer )
		{
			FireTargets( "game_playerleave", pPlayer, pPlayer, USE_TOGGLE, 0 );

			UTIL_LogPrintf( "\"%s<%i><%s><%i>\" disconnected\n",  
				STRING( pPlayer->pev->netname ), 
				GETPLAYERUSERID( pPlayer->edict() ),
				GETPLAYERAUTHID( pPlayer->edict() ),
				GETPLAYERUSERID( pPlayer->edict() ) );

			pPlayer->RemoveAllItems( TRUE );// destroy all of the players weapons and items

			// Tell all clients this player isn't a spectator anymore
			MESSAGE_BEGIN( MSG_ALL, gmsgSpectator );  
				WRITE_BYTE( ENTINDEX(pClient) );
				WRITE_BYTE( 0 );
			MESSAGE_END();

			CBasePlayer *client = NULL;
			while ( ((client = (CBasePlayer*)UTIL_FindEntityByClassname( client, "player" )) != NULL) && (!FNullEnt(client->edict())) ) 
			{
				if ( !client->pev )
					continue;
				if ( client == pPlayer )
					continue;

				// If a spectator was chasing this player, move him/her onto the next player
				if ( client->m_hObserverTarget == pPlayer )
				{
					int iMode = client->pev->iuser1;
					client->pev->iuser1 = 0;
					client->m_hObserverTarget = NULL;
					client->Observer_SetMode( iMode );
				}
			}
		}
	}
}
Ejemplo n.º 8
0
void Bot::Kick (void)
{
   // this function kick off one bot from the server.

   ServerCommand ("kick #%d", GETPLAYERUSERID (GetEntity ()));
   CenterPrint ("Bot '%s' kicked", STRING (pev->netname));

   // balances quota
   if (g_botManager->GetBotsNum () - 1 < yb_quota.GetInt ())
      yb_quota.SetInt (g_botManager->GetBotsNum () - 1);
}
Ejemplo n.º 9
0
CPlayer *UTIL_PlayerByCID(int CID)
{
	int i=0;
	while (i++<gpGlobals->maxClients)
	{
		if (GETPLAYERUSERID(g_player[i].GetEdict())==CID)
		{
			return &g_player[i];
		}
	}

	return NULL;
}
Ejemplo n.º 10
0
//=========================================================
// ClientUserInfoChanged
//=========================================================
void CHalfLifeTeamplay::ClientUserInfoChanged( CBasePlayer *pPlayer, char *infobuffer )
{
	char text[1024];

	// prevent skin/color/model changes
	char *mdls = g_engfuncs.pfnInfoKeyValue( infobuffer, "model" );

	if ( !stricmp( mdls, pPlayer->TeamID() ) )
		return;

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

		g_engfuncs.pfnSetClientKeyValue( clientIndex, g_engfuncs.pfnGetInfoKeyBuffer( pPlayer->edict() ), "model", pPlayer->TeamID() );
		g_engfuncs.pfnSetClientKeyValue( clientIndex, g_engfuncs.pfnGetInfoKeyBuffer( pPlayer->edict() ), "team", pPlayer->TeamID() );
		sprintf( text, "* Not allowed to change teams in this game!\n" );
		UTIL_SayText( text, pPlayer );
		return;
	}

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

		g_engfuncs.pfnSetClientKeyValue( clientIndex, g_engfuncs.pfnGetInfoKeyBuffer( pPlayer->edict() ), "model", pPlayer->TeamID() );
		sprintf( text, "* Can't change team to \'%s\'\n", mdls );
		UTIL_SayText( text, pPlayer );
		sprintf( text, "* Server limits teams to \'%s\'\n", m_szTeamList );
		UTIL_SayText( text, pPlayer );
		return;
	}
	// notify everyone of the team change
	sprintf( text, "* %s has changed to team \'%s\'\n", STRING(pPlayer->pev->netname), mdls );
	UTIL_SayTextAll( text, pPlayer );

	UTIL_LogPrintf( "\"%s<%i><%s><%s>\" joined team \"%s\"\n", 
		STRING(pPlayer->pev->netname),
		GETPLAYERUSERID( pPlayer->edict() ),
#ifdef USE_UPP
				UPPUtil_GetNetworkID(pPlayer->edict()).c_str(),
#else
				AvHSUGetPlayerAuthIDString( pPlayer->edict() ).c_str(),
#endif
		pPlayer->TeamID(),
		mdls );

	ChangePlayerTeam( pPlayer, mdls, TRUE, TRUE );
	// recound stuff
	RecountTeams();
}
Ejemplo n.º 11
0
void CPlayer::onConnect(edict_t *pEdict) {
	m_pEnt = pEdict;
	m_cIndex = g_EngFuncs.pfnIndexOfEdict(pEdict);
	m_bHLTV = false;
	m_bHooked = false;
	m_strNickname = STRING(pEdict->v.netname);
	m_iUserId = GETPLAYERUSERID(pEdict);
	const char *strSteamId = GETPLAYERAUTHID(pEdict);
	m_SteamId = CSteamId();
	if( !strcmp(strSteamId, "HLTV") )
		m_bHLTV = true;
	else if( strcmp(strSteamId, "BOT") != 0 ) {
		m_SteamId = CSteamId(strSteamId);
	}

	m_bInGame = true;
}
Ejemplo n.º 12
0
//=========================================================
// Deathnotice. 
//=========================================================
void CHalfLifeMultiplay::DeathNotice( CBasePlayer *pVictim, entvars_t *pKiller, entvars_t *pevInflictor )
{
	// Work out what killed the player, and send a message to all clients about it
	CBaseEntity *Killer = CBaseEntity::Instance( pKiller );

	const char *killer_weapon_name = "world";		// by default, the player is killed by the world
	int killer_index = 0;
	
	// Hack to fix name change

	if ( pKiller->flags & FL_CLIENT )
	{
		killer_index = ENTINDEX(ENT(pKiller));
		
		if ( pevInflictor )
		{
			if ( pevInflictor == pKiller )
			{
				// If the inflictor is the killer,  then it must be their current weapon doing the damage
				CBasePlayer *pPlayer = (CBasePlayer*)CBaseEntity::Instance( pKiller );
				
				if ( pPlayer->m_pActiveItem )
				{
					killer_weapon_name = pPlayer->m_pActiveItem->pszName();
				}
			}
			else
			{
				killer_weapon_name = STRING( pevInflictor->classname );  // it's just that easy
			}
		}
	}
	else
	{
		killer_weapon_name = STRING( pevInflictor->classname );
	}

	// strip the monster_* or weapon_* from the inflictor's classname
	if ( strncmp( killer_weapon_name, "weapon_", 7 ) == 0 )
		killer_weapon_name += 7;
	else if ( strncmp( killer_weapon_name, "monster_", 8 ) == 0 )
		killer_weapon_name += 8;
	else if ( strncmp( killer_weapon_name, "func_", 5 ) == 0 )
		killer_weapon_name += 5;

	if ( pVictim->pev == pKiller )  
	{  
		UTIL_LogPrintf( "\"%s<%i><%s><%i>\" committed suicide with \"%s\"\n",  
			STRING( pVictim->pev->netname ), 
			GETPLAYERUSERID( pVictim->edict() ),
			GETPLAYERAUTHID( pVictim->edict() ),
			GETPLAYERUSERID( pVictim->edict() ),
			killer_weapon_name );	
		
		pKiller->frags -= 1;
	}
	else if ( pKiller->flags & FL_CLIENT )
	{
		if ( !strcmp( killer_weapon_name, "disc" ) )
		{
			int iTele = 0;
			if ( (pVictim->m_flLastDiscHitTeleport != 0) && (gpGlobals->time < pVictim->m_flLastDiscHitTeleport + MAX_SCORE_TIME_AFTER_HIT) )
				iTele = REWARD_TELEPORT;

			// Decapitated?
			if ( pVictim->m_LastHitGroup == HITGROUP_HEAD )
			{
				UTIL_LogPrintf( "\"%s<%i><%s><%i>\" killed \"%s<%i><%s><%i>\" with \"%s\" (decapitated)\n",  
					STRING( pKiller->netname ),
					GETPLAYERUSERID( ENT(pKiller) ),
					GETPLAYERAUTHID( ENT(pKiller) ),
					GETPLAYERUSERID( ENT(pKiller) ),
					STRING( pVictim->pev->netname ),
					GETPLAYERUSERID( pVictim->edict() ),
					GETPLAYERAUTHID( pVictim->edict() ),
					GETPLAYERUSERID( pVictim->edict() ),
					killer_weapon_name );

				// Tell the client to display the death message
				MESSAGE_BEGIN( MSG_ALL, gmsgDeathMsg );
					WRITE_BYTE( killer_index );						// the killer
					WRITE_BYTE( ENTINDEX(pVictim->edict()) );		// the victim
					WRITE_STRING( "decapitate" );					// what they were killed by (should this be a string?)
				MESSAGE_END();

				// Bonus point for teleport hit
				if ( iTele )
					pKiller->frags++;

				pKiller->frags += 1;

				// Bring up the reward window on the killer's screen
				MESSAGE_BEGIN( MSG_ONE, gmsgReward, NULL, Killer->edict() );
					WRITE_SHORT( REWARD_DECAPITATE | iTele );
				MESSAGE_END();

				return;
			}

			// Otherwise, calculate number of disc bounces
			if ( pVictim->m_iLastDiscBounces == 0 )
			{
				// Bring up the reward window on the killer's screen
				MESSAGE_BEGIN( MSG_ONE, gmsgReward, NULL, Killer->edict() );
					WRITE_SHORT( REWARD_BOUNCE_NONE | iTele );
				MESSAGE_END();
			}
			else if ( pVictim->m_iLastDiscBounces == 1 )
			{
				// Bring up the reward window on the killer's screen
				MESSAGE_BEGIN( MSG_ONE, gmsgReward, NULL, Killer->edict() );
					WRITE_SHORT( REWARD_BOUNCE_ONE | iTele );
				MESSAGE_END();
			}
			else
			{
				if ( pVictim->m_iLastDiscBounces == 2 )
				{
					// Bring up the reward window on the killer's screen
					MESSAGE_BEGIN( MSG_ONE, gmsgReward, NULL, Killer->edict() );
						WRITE_SHORT( REWARD_BOUNCE_TWO | iTele );
					MESSAGE_END();
				}
				else
				{
					// Bring up the reward window on the killer's screen
					MESSAGE_BEGIN( MSG_ONE, gmsgReward, NULL, Killer->edict() );
						WRITE_SHORT( REWARD_BOUNCE_THREE | iTele );
					MESSAGE_END();

					// Cap the number of frags a killer can get to 4
					pVictim->m_iLastDiscBounces = 3;
				}
			}

			UTIL_LogPrintf( "\"%s<%i><%s><%i>\" killed \"%s<%i><%s><%i>\" with \"%s\" (bounces \"%d\")\n",  
				STRING( pKiller->netname ),
				GETPLAYERUSERID( ENT(pKiller) ),
				GETPLAYERAUTHID( ENT(pKiller) ),
				GETPLAYERUSERID( ENT(pKiller) ),
				STRING( pVictim->pev->netname ),
				GETPLAYERUSERID( pVictim->edict() ),
				GETPLAYERAUTHID( pVictim->edict() ),
				GETPLAYERUSERID( pVictim->edict() ),
				killer_weapon_name,
				pVictim->m_iLastDiscBounces );

			char sz[1024];
			sprintf( sz, "%dbounce", pVictim->m_iLastDiscBounces );

			// Tell the client to display the death message
			MESSAGE_BEGIN( MSG_ALL, gmsgDeathMsg );
				WRITE_BYTE( killer_index );						// the killer
				WRITE_BYTE( ENTINDEX(pVictim->edict()) );		// the victim
				WRITE_STRING( sz );								// what they were killed by (should this be a string?)
			MESSAGE_END();

			pKiller->frags += (1 + pVictim->m_iLastDiscBounces);

			// Bonus point for teleport hit
			if ( iTele )
				pKiller->frags++;
		}
		else
		{
			UTIL_LogPrintf( "\"%s<%i><%s><%i>\" killed \"%s<%i><%s><%i>\" with \"%s\"\n",  
				STRING( pKiller->netname ),
				GETPLAYERUSERID( ENT(pKiller) ),
				GETPLAYERAUTHID( ENT(pKiller) ),
				GETPLAYERUSERID( ENT(pKiller) ),
				STRING( pVictim->pev->netname ),
				GETPLAYERUSERID( pVictim->edict() ),
				GETPLAYERAUTHID( pVictim->edict() ),
				GETPLAYERUSERID( pVictim->edict() ),
				killer_weapon_name );

			// Tell the client to display the death message
			MESSAGE_BEGIN( MSG_ALL, gmsgDeathMsg );
				WRITE_BYTE( killer_index );						// the killer
				WRITE_BYTE( ENTINDEX(pVictim->edict()) );		// the victim
				WRITE_STRING( killer_weapon_name );				// what they were killed by (should this be a string?)
			MESSAGE_END();

			pKiller->frags += 1;
		}
	}
	else
	{  
		pKiller->frags -= 1;

		// Fell to their death
		UTIL_LogPrintf( "\"%s<%i><%s><%i>\" committed suicide with \"world\"\n",
			STRING( pVictim->pev->netname ), 
			GETPLAYERUSERID( pVictim->edict() ), 
			GETPLAYERAUTHID( pVictim->edict() ),
			GETPLAYERUSERID( pVictim->edict() ),
			killer_weapon_name );		

		// Tell the client to display the death message
		MESSAGE_BEGIN( MSG_ALL, gmsgDeathMsg );
			WRITE_BYTE( killer_index );						// the killer
			WRITE_BYTE( ENTINDEX(pVictim->edict()) );		// the victim
			WRITE_STRING( "falling" );						// what they were killed by (should this be a string?)
		MESSAGE_END();
	}

	return;
}
Ejemplo n.º 13
0
void CGrenade::Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value)
{
	if (!m_bIsC4)
		return;

	CBasePlayer *pPlayer = GetClassPtr((CBasePlayer *)pActivator->pev);

	if (pPlayer->m_iTeam != TEAM_CT)
		return;

	if (m_bStartDefuse)
	{
		m_fNextDefuse = gpGlobals->time + 0.5;
		return;
	}

	g_engfuncs.pfnSetClientMaxspeed(pPlayer->edict(), 1);

	if (g_pGameRules->IsCareer())
	{
	}

	if (pPlayer->m_bHasDefuser == true)
	{
		UTIL_LogPrintf("\"%s<%i><%s><CT>\" triggered \"Begin_Bomb_Defuse_With_Kit\"\n", STRING(pPlayer->pev->netname), GETPLAYERUSERID(pPlayer->edict()), GETPLAYERAUTHID(pPlayer->edict()));
		ClientPrint(pPlayer->pev, HUD_PRINTCENTER, "#Defusing_Bomb_With_Defuse_Kit");
		EMIT_SOUND(ENT(pPlayer->pev), CHAN_ITEM, "weapons/c4_disarm.wav", VOL_NORM, ATTN_NORM);

		pPlayer->m_bIsDefusing = true;
		m_pBombDefuser = pCaller;
		m_bStartDefuse = true;
		m_flDefuseCountDown = gpGlobals->time + 5;
		m_fNextDefuse = gpGlobals->time + 0.5;
		pPlayer->SetProgressBarTime(5);
	}
	else
	{
		UTIL_LogPrintf("\"%s<%i><%s><CT>\" triggered \"Begin_Bomb_Defuse_Without_Kit\"\n", STRING(pPlayer->pev->netname), GETPLAYERUSERID(pPlayer->edict()), GETPLAYERAUTHID(pPlayer->edict()));
		ClientPrint(pPlayer->pev, HUD_PRINTCENTER, "#Defusing_Bomb_Without_Defuse_Kit");
		EMIT_SOUND(ENT(pPlayer->pev), CHAN_ITEM, "weapons/c4_disarm.wav", VOL_NORM, ATTN_NORM);

		pPlayer->m_bIsDefusing = true;
		m_pBombDefuser = pCaller;
		m_bStartDefuse = true;
		m_flDefuseCountDown = gpGlobals->time + 10;
		m_fNextDefuse = gpGlobals->time + 0.5;
		pPlayer->SetProgressBarTime(10);
	}
}
Ejemplo n.º 14
0
void CGrenade::C4Think(void)
{
	if (!IsInWorld())
	{
		UTIL_Remove(this);
		return;
	}

	pev->nextthink = gpGlobals->time + 0.12;

	if (gpGlobals->time >= m_flNextFreq)
	{
		m_flNextFreq = m_flNextFreqInterval + gpGlobals->time;
		m_flNextFreqInterval *= 0.9;

		switch (m_iCurWave)
		{
			case 0:
			{
				m_sBeepName = "weapons/c4_beep1.wav";
				m_fAttenu = 1.5;
				break;
			}

			case 1:
			{
				m_sBeepName = "weapons/c4_beep2.wav";
				m_fAttenu = 1;
				break;
			}

			case 2:
			{
				m_sBeepName = "weapons/c4_beep3.wav";
				m_fAttenu = 0.8;
				break;
			}

			case 3:
			{
				m_sBeepName = "weapons/c4_beep4.wav";
				m_fAttenu = 0.5;
				break;
			}

			case 4:
			{
				m_sBeepName = "weapons/c4_beep5.wav";
				m_fAttenu = 0.2;
				break;
			}
		}

		m_iCurWave++;
	}

	if (gpGlobals->time >= m_flNextBeep)
	{
		m_flNextBeep = gpGlobals->time + 1.4;
		EMIT_SOUND(ENT(pev), CHAN_VOICE, m_sBeepName, VOL_NORM, m_fAttenu);
	}

	if (gpGlobals->time >= m_flNextBlink)
	{
		m_flNextBlink = gpGlobals->time + 2;

		MESSAGE_BEGIN(MSG_PVS, SVC_TEMPENTITY, pev->origin);
		WRITE_BYTE(TE_GLOWSPRITE);
		WRITE_COORD(pev->origin.x);
		WRITE_COORD(pev->origin.y);
		WRITE_COORD(pev->origin.z + 5);
		WRITE_SHORT(g_sModelIndexC4Glow);
		WRITE_BYTE(1);
		WRITE_BYTE(3);
		WRITE_BYTE(255);
		MESSAGE_END();
	}

	if (m_flC4Blow <= gpGlobals->time)
	{
		MESSAGE_BEGIN(MSG_ALL, gmsgScenarioIcon);
		WRITE_BYTE(0);
		MESSAGE_END();

		if (m_pentCurBombTarget)
		{
			CBaseEntity *pEntity = CBaseEntity::Instance(m_pentCurBombTarget);

			if (pEntity)
			{
				CBaseEntity *pOwner = CBaseEntity::Instance(pev->owner);
				pEntity->Use(pOwner, this, USE_TOGGLE, 0);
			}
		}

		CBaseEntity *pOwner = CBaseEntity::Instance(pev->owner);
		pOwner->pev->frags += 3;

		MESSAGE_BEGIN(MSG_ALL, gmsgBombPickup);
		MESSAGE_END();

		g_pGameRules->m_bBombDropped = false;

		if (pev->waterlevel != 0)
			UTIL_Remove(this);
		else
			SetThink(&CGrenade::Detonate2);
	}

	if (m_bStartDefuse == true && m_pBombDefuser != NULL)
	{
		CBasePlayer *pDefuser = (CBasePlayer *)CBaseEntity::Instance(m_pBombDefuser);

		if (m_flDefuseCountDown > gpGlobals->time)
		{
			int fOnGround = m_pBombDefuser->pev->flags & FL_ONGROUND;

			if (m_fNextDefuse < gpGlobals->time || !fOnGround)
			{
				if (!fOnGround)
					ClientPrint(m_pBombDefuser->pev, HUD_PRINTCENTER, "#C4_Defuse_Must_Be_On_Ground");

				pDefuser->ResetMaxSpeed();
				pDefuser->m_bIsDefusing = false;
				pDefuser->SetProgressBarTime(0);
				m_bStartDefuse = false;
				m_pBombDefuser = NULL;
				m_flDefuseCountDown = 0;
			}
		}
		else
		{
			if (m_pBombDefuser->pev->deadflag == DEAD_NO)
			{
				Broadcast("BOMBDEF");

				MESSAGE_BEGIN(MSG_SPEC, SVC_DIRECTOR);
				WRITE_BYTE(9);
				WRITE_BYTE(DRC_CMD_EVENT);
				WRITE_SHORT(ENTINDEX(ENT(m_pBombDefuser->pev)));
				WRITE_SHORT(0);
				WRITE_LONG(15 | DRC_FLAG_FINAL | DRC_FLAG_FACEPLAYER | DRC_FLAG_DRAMATIC);
				MESSAGE_END();

				UTIL_LogPrintf("\"%s<%i><%s><CT>\" triggered \"Defused_The_Bomb\"\n", STRING(m_pBombDefuser->pev->netname), GETPLAYERUSERID(m_pBombDefuser->edict()), GETPLAYERAUTHID(m_pBombDefuser->edict()));
				UTIL_EmitAmbientSound(ENT(pev), pev->origin, "weapons/c4_beep5.wav", 0, ATTN_NONE, SND_STOP, 0);
				EMIT_SOUND(ENT(m_pBombDefuser->pev), CHAN_WEAPON, "weapons/c4_disarmed.wav", VOL_NORM, ATTN_NORM);
				UTIL_Remove(this);

				m_bJustBlew = true;
				pDefuser->ResetMaxSpeed();
				pDefuser->m_bIsDefusing = false;

				MESSAGE_BEGIN(MSG_ALL, gmsgScenarioIcon);
				WRITE_BYTE(0);
				MESSAGE_END();

				if (g_pGameRules->IsCareer())
				{
					if (!pDefuser->IsBot())
					{
					}
				}

				g_pGameRules->m_bBombDefused = true;
				g_pGameRules->CheckWinConditions();
				pDefuser->pev->frags += 3;

				MESSAGE_BEGIN(MSG_ALL, gmsgBombPickup);
				MESSAGE_END();

				g_pGameRules->m_bBombDropped = false;
				m_bStartDefuse = false;
				m_pBombDefuser = NULL;
			}
			else
			{
				pDefuser->ResetMaxSpeed();
				pDefuser->m_bIsDefusing = false;
				m_bStartDefuse = false;
				m_pBombDefuser = NULL;
			}
		}
	}
}
//=========================================================
// Deathnotice. 
//=========================================================
void CHalfLifeMultiplay::DeathNotice( CBasePlayer *pVictim, entvars_t *pKiller, entvars_t *pevInflictor )
{
	// Work out what killed the player, and send a message to all clients about it
	CBaseEntity *Killer = CBaseEntity::Instance( pKiller );

	const char *killer_weapon_name = "world";		// by default, the player is killed by the world
	int killer_index = 0;
	
	// Hack to fix name change
	char *tau = "tau_cannon";
	char *gluon = "gluon gun";

	if ( pKiller->flags & FL_CLIENT )
	{
		killer_index = ENTINDEX(ENT(pKiller));
		
		if ( pevInflictor )
		{
			if ( pevInflictor == pKiller )
			{
				// If the inflictor is the killer,  then it must be their current weapon doing the damage
				CBasePlayer *pPlayer = (CBasePlayer*)CBaseEntity::Instance( pKiller );
				
				if ( pPlayer->m_pActiveItem )
				{
					killer_weapon_name = pPlayer->m_pActiveItem->pszName();
				}
			}
			else
			{
				killer_weapon_name = STRING( pevInflictor->classname );  // it's just that easy
			}
		}
	}
	else
	{
		killer_weapon_name = STRING( pevInflictor->classname );
	}

	// strip the monster_* or weapon_* from the inflictor's classname
	if ( strncmp( killer_weapon_name, "weapon_", 7 ) == 0 )
		killer_weapon_name += 7;
	else if ( strncmp( killer_weapon_name, "monster_", 8 ) == 0 )
		killer_weapon_name += 8;
	else if ( strncmp( killer_weapon_name, "func_", 5 ) == 0 )
		killer_weapon_name += 5;

	MESSAGE_BEGIN( MSG_ALL, gmsgDeathMsg );
		WRITE_BYTE( killer_index );						// the killer
		WRITE_BYTE( ENTINDEX(pVictim->edict()) );		// the victim
		WRITE_STRING( killer_weapon_name );		// what they were killed by (should this be a string?)
	MESSAGE_END();

	// replace the code names with the 'real' names
	if ( !strcmp( killer_weapon_name, "egon" ) )
		killer_weapon_name = gluon;
	else if ( !strcmp( killer_weapon_name, "gauss" ) )
		killer_weapon_name = tau;

	if ( pVictim->pev == pKiller )  
	{
		// killed self

		// team match?
		if ( g_teamplay )
		{
			UTIL_LogPrintf( "\"%s<%i><%s><%s>\" committed suicide with \"%s\"\n",  
				STRING( pVictim->pev->netname ), 
				GETPLAYERUSERID( pVictim->edict() ),
				GETPLAYERAUTHID( pVictim->edict() ),
				g_engfuncs.pfnInfoKeyValue( g_engfuncs.pfnGetInfoKeyBuffer( pVictim->edict() ), "model" ),
				killer_weapon_name );		
		}
		else
		{
			UTIL_LogPrintf( "\"%s<%i><%s><%i>\" committed suicide with \"%s\"\n",  
				STRING( pVictim->pev->netname ), 
				GETPLAYERUSERID( pVictim->edict() ),
				GETPLAYERAUTHID( pVictim->edict() ),
				GETPLAYERUSERID( pVictim->edict() ),
				killer_weapon_name );		
		}
	}
	else if ( pKiller->flags & FL_CLIENT )
	{
		// team match?
		if ( g_teamplay )
		{
			UTIL_LogPrintf( "\"%s<%i><%s><%s>\" killed \"%s<%i><%s><%s>\" with \"%s\"\n",  
				STRING( pKiller->netname ),
				GETPLAYERUSERID( ENT(pKiller) ),
				GETPLAYERAUTHID( ENT(pKiller) ),
				g_engfuncs.pfnInfoKeyValue( g_engfuncs.pfnGetInfoKeyBuffer( ENT(pKiller) ), "model" ),
				STRING( pVictim->pev->netname ),
				GETPLAYERUSERID( pVictim->edict() ),
				GETPLAYERAUTHID( pVictim->edict() ),
				g_engfuncs.pfnInfoKeyValue( g_engfuncs.pfnGetInfoKeyBuffer( pVictim->edict() ), "model" ),
				killer_weapon_name );
		}
		else
		{
			UTIL_LogPrintf( "\"%s<%i><%s><%i>\" killed \"%s<%i><%s><%i>\" with \"%s\"\n",  
				STRING( pKiller->netname ),
				GETPLAYERUSERID( ENT(pKiller) ),
				GETPLAYERAUTHID( ENT(pKiller) ),
				GETPLAYERUSERID( ENT(pKiller) ),
				STRING( pVictim->pev->netname ),
				GETPLAYERUSERID( pVictim->edict() ),
				GETPLAYERAUTHID( pVictim->edict() ),
				GETPLAYERUSERID( pVictim->edict() ),
				killer_weapon_name );
		}
	}
	else
	{ 
		// killed by the world

		// team match?
		if ( g_teamplay )
		{
			UTIL_LogPrintf( "\"%s<%i><%s><%s>\" committed suicide with \"%s\" (world)\n",
				STRING( pVictim->pev->netname ), 
				GETPLAYERUSERID( pVictim->edict() ), 
				GETPLAYERAUTHID( pVictim->edict() ),
				g_engfuncs.pfnInfoKeyValue( g_engfuncs.pfnGetInfoKeyBuffer( pVictim->edict() ), "model" ),
				killer_weapon_name );		
		}
		else
		{
			UTIL_LogPrintf( "\"%s<%i><%s><%i>\" committed suicide with \"%s\" (world)\n",
				STRING( pVictim->pev->netname ), 
				GETPLAYERUSERID( pVictim->edict() ), 
				GETPLAYERAUTHID( pVictim->edict() ),
				GETPLAYERUSERID( pVictim->edict() ),
				killer_weapon_name );		
		}
	}

	MESSAGE_BEGIN( MSG_SPEC, SVC_DIRECTOR );
		WRITE_BYTE ( 9 );	// command length in bytes
		WRITE_BYTE ( DRC_CMD_EVENT );	// player killed
		WRITE_SHORT( ENTINDEX(pVictim->edict()) );	// index number of primary entity
		if (pevInflictor)
			WRITE_SHORT( ENTINDEX(ENT(pevInflictor)) );	// index number of secondary entity
		else
			WRITE_SHORT( ENTINDEX(ENT(pKiller)) );	// index number of secondary entity
		WRITE_LONG( 7 | DRC_FLAG_DRAMATIC);   // eventflags (priority and flags)
	MESSAGE_END();

//  Print a standard message
	// TODO: make this go direct to console
	return; // just remove for now
/*
	char	szText[ 128 ];

	if ( pKiller->flags & FL_MONSTER )
	{
		// killed by a monster
		strcpy ( szText, STRING( pVictim->pev->netname ) );
		strcat ( szText, " was killed by a monster.\n" );
		return;
	}

	if ( pKiller == pVictim->pev )
	{
		strcpy ( szText, STRING( pVictim->pev->netname ) );
		strcat ( szText, " commited suicide.\n" );
	}
	else if ( pKiller->flags & FL_CLIENT )
	{
		strcpy ( szText, STRING( pKiller->netname ) );

		strcat( szText, " : " );
		strcat( szText, killer_weapon_name );
		strcat( szText, " : " );

		strcat ( szText, STRING( pVictim->pev->netname ) );
		strcat ( szText, "\n" );
	}
	else if ( FClassnameIs ( pKiller, "worldspawn" ) )
	{
		strcpy ( szText, STRING( pVictim->pev->netname ) );
		strcat ( szText, " fell or drowned or something.\n" );
	}
	else if ( pKiller->solid == SOLID_BSP )
	{
		strcpy ( szText, STRING( pVictim->pev->netname ) );
		strcat ( szText, " was mooshed.\n" );
	}
	else
	{
		strcpy ( szText, STRING( pVictim->pev->netname ) );
		strcat ( szText, " died mysteriously.\n" );
	}

	UTIL_ClientPrintAll( szText );
*/
}
Ejemplo n.º 16
0
void CHostage::IdleThink(void)
{
	pev->nextthink = gpGlobals->time + (1.0 / 30);
	DispatchAnimEvents(StudioFrameAdvance());

	if (gpGlobals->time >= m_flNextFullThink)
	{
		m_flNextFullThink = gpGlobals->time + 0.1;

		if (pev->deadflag == DEAD_DEAD)
		{
			UTIL_SetSize(pev, Vector(0, 0, 0), Vector(0, 0, 0));
			return;
		}

		if (m_hTargetEnt != NULL)
		{
			if ((m_bStuck != FALSE && gpGlobals->time - m_flStuckTime > 5) || m_hTargetEnt->pev->deadflag != DEAD_NO)
			{
				m_State = STAND;
				m_hTargetEnt = NULL;
				m_bStuck = FALSE;
			}
		}

		if (m_hTargetEnt != 0 || m_improv)
		{
			CBasePlayer *pPlayer;

			if (m_improv)
			{
			}
			else
				pPlayer = GetClassPtr((CBasePlayer *)m_hTargetEnt->pev);

			if (!pPlayer || pPlayer->m_iTeam == TEAM_CT)
			{
				if (!g_pGameRules->m_bMapHasRescueZone)
				{
					BOOL hasRescueZone = FALSE;

					if (UTIL_FindEntityByClassname(NULL, "info_hostage_rescue"))
						hasRescueZone = TRUE;

					CBaseEntity *pEntity = NULL;

					while ((pEntity = UTIL_FindEntityByClassname(pEntity, "info_hostage_rescue")) != NULL)
					{
						if ((pEntity->pev->origin - pev->origin).Length() < 256)
						{
							m_bRescueMe = TRUE;
							break;
						}
					}

					if (!hasRescueZone)
					{
						pEntity = NULL;

						while ((pEntity = UTIL_FindEntityByClassname(pEntity, "info_player_start")) != NULL)
						{
							if ((pEntity->pev->origin - pev->origin).Length() < 256)
							{
								m_bRescueMe = TRUE;
								break;
							}
						}
					}
				}

				if (m_bRescueMe)
				{
					if (g_pGameRules->IsCareer() && pPlayer && !pPlayer->IsBot())
					{
					}

					if (pPlayer)
					{
						pev->deadflag = DEAD_RESPAWNABLE;
						pPlayer->AddAccount(1000);
						UTIL_LogPrintf("\"%s<%i><%s><CT>\" triggered \"Rescued_A_Hostage\"\n", STRING(pPlayer->pev->netname), GETPLAYERUSERID(pPlayer->edict()), GETPLAYERAUTHID(pPlayer->edict()));
					}

					SendHostageEventMsg();

					MESSAGE_BEGIN(MSG_SPEC, SVC_DIRECTOR);
					WRITE_BYTE(9);
					WRITE_BYTE(DRC_CMD_EVENT);
					WRITE_SHORT(pPlayer ? ENTINDEX(pPlayer->edict()) : 0);
					WRITE_SHORT(ENTINDEX(edict()));
					WRITE_LONG(15);
					MESSAGE_END();

					pev->effects |= EF_NODRAW;
					Remove();

					g_pGameRules->m_iHostagesRescued++;
					g_pGameRules->CheckWinConditions();

					if (pPlayer)
						Broadcast("rescued");
					else
						Broadcast("escaped");
				}
			}
		}

		DoFollow();

		if (pev->deadflag != DEAD_DEAD && !(pev->effects & EF_NODRAW))
		{
			if (m_flNextRadarTime <= gpGlobals->time)
			{
				if ((m_vOldPos - pev->origin).Length() > 1)
				{
					m_vOldPos = pev->origin;

					if (!g_pGameRules->m_fTeamCount)
						SendHostagePositionMsg();
				}

				m_flNextRadarTime = gpGlobals->time + 1;
			}
		}

		if (m_flFlinchTime <= gpGlobals->time)
		{
			if (pev->velocity.Length() > 160)
				SetActivity(ACT_RUN);
			else if (pev->velocity.Length() > 15)
				SetActivity(ACT_WALK);
			else
				SetActivity(ACT_IDLE);
		}
	}
}
Ejemplo n.º 17
0
//=========================================================
// Deathnotice. 
//=========================================================
void CHalfLifeMultiplay::DeathNotice( CBasePlayer *pVictim, entvars_t *pKiller, entvars_t *pevInflictor )
{
	// Work out what killed the player, and send a message to all clients about it
	CBaseEntity *Killer = CBaseEntity::Instance( pKiller );

	const char *killer_weapon_name = "world";		// by default, the player is killed by the world
	int killer_index = 0;
	
	// Hack to fix name change
	char *tau = "tau_cannon";
	char *gluon = "gluon gun";

	// QUAKECLASSIC
	// Might have overridden
	if (g_szDeathType)
	{
		killer_weapon_name = g_szDeathType;
	}
	else
	{
		if ( pKiller->flags & FL_CLIENT )
		{
			killer_index = ENTINDEX(ENT(pKiller));
			
			if ( pevInflictor )
			{
				if ( pevInflictor == pKiller )
				{
					// If the inflictor is the killer,  then it must be their current weapon doing the damage
					CBasePlayer *pPlayer = (CBasePlayer*)CBaseEntity::Instance( pKiller );
					
					switch( pPlayer->m_iQuakeWeapon )
					{
						case IT_AXE: killer_weapon_name = "weapon_axe"; break;
						case IT_SHOTGUN: killer_weapon_name = "weapon_shotgun"; break;
						case IT_SUPER_SHOTGUN: killer_weapon_name = "weapon_doubleshotgun"; break;
						case IT_NAILGUN: killer_weapon_name = "weapon_nailgun"; break;
						case IT_SUPER_NAILGUN: killer_weapon_name = "weapon_supernail"; break;
						case IT_GRENADE_LAUNCHER: killer_weapon_name = "weapon_grenadel"; break;
						case IT_ROCKET_LAUNCHER: killer_weapon_name = "weapon_rocketl"; break;
						case IT_LIGHTNING: killer_weapon_name = "weapon_lightning"; break;
							
						default:
							killer_weapon_name = "Empty";
					} 
				
				}
				else
				{
					killer_weapon_name = STRING( pevInflictor->classname );  // it's just that easy
				}
			}
		}
		else
		{
			killer_weapon_name = STRING( pevInflictor->classname );
		}

		// strip the monster_* or weapon_* from the inflictor's classname
		if ( strncmp( killer_weapon_name, "weapon_", 7 ) == 0 )
			killer_weapon_name += 7;
		else if ( strncmp( killer_weapon_name, "monster_", 8 ) == 0 )
			killer_weapon_name += 8;
		else if ( strncmp( killer_weapon_name, "func_", 5 ) == 0 )
			killer_weapon_name += 5;
	}

	MESSAGE_BEGIN( MSG_ALL, gmsgDeathMsg );
		WRITE_BYTE( killer_index );						// the killer
		WRITE_BYTE( ENTINDEX(pVictim->edict()) );		// the victim
		WRITE_STRING( killer_weapon_name );		// what they were killed by (should this be a string?)
	MESSAGE_END();

	// replace the code names with the 'real' names
	if ( !strcmp( killer_weapon_name, "egon" ) )
		killer_weapon_name = gluon;
	else if ( !strcmp( killer_weapon_name, "gauss" ) )
		killer_weapon_name = tau;

	if ( pVictim->pev == pKiller )  
	{  
		// killed self
#if !defined( THREEWAVE )
		UTIL_LogPrintf( "\"%s<%i><%s><%i>\" committed suicide with \"%s\"\n",  
			STRING( pVictim->pev->netname ), 
			GETPLAYERUSERID( pVictim->edict() ),
			GETPLAYERAUTHID( pVictim->edict() ),
			GETPLAYERUSERID( pVictim->edict() ),
			killer_weapon_name );		
#else
		UTIL_LogPrintf( "\"%s<%i><%s><%s>\" committed suicide with \"%s\"\n",  
			STRING( pVictim->pev->netname ), 
			GETPLAYERUSERID( pVictim->edict() ),
			GETPLAYERAUTHID( pVictim->edict() ),
			GetTeamName( pVictim->pev->team ),
			killer_weapon_name );		
#endif
	}
	else if ( pKiller->flags & FL_CLIENT )
	{
#if !defined( THREEWAVE )
		UTIL_LogPrintf( "\"%s<%i><%s><%i>\" killed \"%s<%i><%s><%i>\" with \"%s\"\n",  
			STRING( pKiller->netname ),
			GETPLAYERUSERID( ENT(pKiller) ),
			GETPLAYERAUTHID( ENT(pKiller) ),
			GETPLAYERUSERID( ENT(pKiller) ),
			STRING( pVictim->pev->netname ),
			GETPLAYERUSERID( pVictim->edict() ),
			GETPLAYERAUTHID( pVictim->edict() ),
			GETPLAYERUSERID( pVictim->edict() ),
			killer_weapon_name );
#else
		UTIL_LogPrintf( "\"%s<%i><%s><%s>\" killed \"%s<%i><%s><%s>\" with \"%s\"\n",  
			STRING( pKiller->netname ),
			GETPLAYERUSERID( ENT(pKiller) ),
			GETPLAYERAUTHID( ENT(pKiller) ),
			GetTeamName( pKiller->team ),
			STRING( pVictim->pev->netname ),
			GETPLAYERUSERID( pVictim->edict() ),
			GETPLAYERAUTHID( pVictim->edict() ),
			GetTeamName( pVictim->pev->team ),
			killer_weapon_name );
#endif
	}
	else
	{  
		// killed by the world
#if !defined( THREEWAVE )
		UTIL_LogPrintf( "\"%s<%i><%s><%i>\" committed suicide with \"%s\" (world)\n",
			STRING( pVictim->pev->netname ), 
			GETPLAYERUSERID( pVictim->edict() ), 
			GETPLAYERAUTHID( pVictim->edict() ),
			GETPLAYERUSERID( pVictim->edict() ),
			killer_weapon_name );				
#else
		UTIL_LogPrintf( "\"%s<%i><%s><%s>\" committed suicide with \"%s\" (world)\n",
			STRING( pVictim->pev->netname ), 
			GETPLAYERUSERID( pVictim->edict() ), 
			GETPLAYERAUTHID( pVictim->edict() ),
			GetTeamName( pVictim->pev->team ),
			killer_weapon_name );				
#endif
	}

	g_szDeathType = NULL;

	// HLTV event msg
	MESSAGE_BEGIN( MSG_SPEC, SVC_DIRECTOR );
		WRITE_BYTE ( 9 );	// command length in bytes
		WRITE_BYTE ( DRC_CMD_EVENT );	// player killed
		WRITE_SHORT( ENTINDEX(pVictim->edict()) );	// index number of primary entity
		if (pevInflictor)
			WRITE_SHORT( ENTINDEX(ENT(pevInflictor)) );	// index number of secondary entity
		else
			WRITE_SHORT( ENTINDEX(ENT(pKiller)) );	// index number of secondary entity
		WRITE_LONG( 7 | DRC_FLAG_DRAMATIC);   // eventflags (priority and flags)
	MESSAGE_END();

//  Print a standard message
	// TODO: make this go direct to console
	return; // just remove for now

}
Ejemplo n.º 18
0
void CHostage::AnnounceDeath(CBasePlayer *pAttacker)
{
	ClientPrint(pAttacker->pev, HUD_PRINTCENTER, "#Killed_Hostage");

	if (!(pAttacker->m_flDisplayHistory & DHF_HOSTAGE_KILLED))
	{
		pAttacker->HintMessage("#Hint_lost_money");
		pAttacker->m_flDisplayHistory |= DHF_HOSTAGE_KILLED;
	}

	if (!g_pGameRules->IsMultiplayer())
		CHalfLifeTraining::HostageDied();

	UTIL_LogPrintf("\"%s<%i><%s><%s>\" triggered \"Killed_A_Hostage\"\n", STRING(pAttacker->pev->netname), GETPLAYERUSERID(pAttacker->edict()), GETPLAYERAUTHID(pAttacker->edict()), GetTeam(pAttacker->m_iTeam));

	MESSAGE_BEGIN(MSG_SPEC, SVC_DIRECTOR);
	WRITE_BYTE(9);
	WRITE_BYTE(DRC_CMD_EVENT);
	WRITE_SHORT(ENTINDEX(pAttacker->edict()));
	WRITE_SHORT(ENTINDEX(edict()));
	WRITE_LONG(15);
	MESSAGE_END();
}
Ejemplo n.º 19
0
void CHostage::GiveCTTouchBonus(CBasePlayer *pPlayer)
{
	if (m_bTouched != TRUE)
	{
		m_bTouched = TRUE;
		g_pGameRules->m_iAccountCT += 100;
		pPlayer->AddAccount(150);
		UTIL_LogPrintf("\"%s<%i><%s><CT>\" triggered \"Touched_A_Hostage\"\n", STRING(pPlayer->pev->netname), GETPLAYERUSERID(pPlayer->edict()), GETPLAYERAUTHID(pPlayer->edict()));
	}
}
Ejemplo n.º 20
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);
}
Ejemplo n.º 21
0
void CGrenade::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value )
{
    int barTime;

    if( !m_fPlantedC4 )
    {
        return;
    }

    CBasePlayer* pPlayer = GetClassPtr( (CBasePlayer *)pActivator->pev );

    if( pPlayer->m_iTeam == TEAM_CT )
    {
        if( m_fStartDefuse )
        {
            m_flNextDefuseTime = gpGlobals->time + 0.5;
            return;
        }

        SET_CLIENT_MAXSPEED( ENT( pPlayer->pev ), 1.0 );

        // TODO: Adds support for bots.
        // TheBots->OnEvent( EVENT_BOMB_DEFUSING, pActivator, NULL );

        if( g_pGameRules->IsCareer() )
        {
            // TODO: implements this.
            // TheCareerTasks->HandleEvent( EVENT_BOMB_DEFUSING, NULL, NULL );
        }

        if( pPlayer->m_fHasDefuseKit )
        {
            UTIL_LogPrintf(	"\"%s<%i><%s><CT>\" triggered \"Begin_Bomb_Defuse_With_Kit\"\n",
                            STRING( pPlayer->pev->netname ),
                            GETPLAYERAUTHID( pPlayer->edict() ),
                            GETPLAYERUSERID( pPlayer->edict() ) );

            ClientPrint( pPlayer->pev, HUD_PRINTCENTER, "#Defusing_Bomb_With_Defuse_Kit" );
            EMIT_SOUND( ENT( pPlayer->pev ), CHAN_ITEM, "weapons/c4_disarm.wav", VOL_NORM, ATTN_NORM );

            pPlayer->m_fBombDefusing = TRUE;

            m_hActivator	= pActivator;
            m_fStartDefuse	= TRUE;

            m_flDefuseCountDown	= gpGlobals->time + 5.0;
            m_flNextDefuseTime	= gpGlobals->time + 0.5;

            barTime = 5;
        }
        else
        {
            UTIL_LogPrintf(	"\"%s<%i><%s><CT>\" triggered \"Begin_Bomb_Defuse_Without_Kit\"\n",
                            STRING( pPlayer->pev->netname ),
                            GETPLAYERAUTHID( pPlayer->edict() ),
                            GETPLAYERUSERID( pPlayer->edict() ) );

            ClientPrint( pPlayer->pev, HUD_PRINTCENTER, "#Defusing_Bomb_Without_Defuse_Kit" );
            EMIT_SOUND( ENT( pPlayer->pev ), CHAN_ITEM, "weapons/c4_disarm.wav", VOL_NORM, ATTN_NORM );

            pPlayer->m_fBombDefusing = TRUE;

            m_hActivator	= pActivator;
            m_fStartDefuse	= TRUE;

            m_flDefuseCountDown	= gpGlobals->time + 10.0;
            m_flNextDefuseTime	= gpGlobals->time + 0.5;

            barTime = 10;
        }

        pPlayer->SetProgressBarTime( barTime );
    }
}
Ejemplo n.º 22
0
size_t atcprintf(D *buffer, size_t maxlen, const S *format, AMX *amx, cell *params, int *param)
{
	int		arg;
	int		args = params[0] / sizeof(cell);
	D		*buf_p;
	D		ch;
	int		flags;
	int		width;
	int		prec;
	int		n;
	//char	sign;
	const S	*fmt;
	size_t	llen = maxlen;

	buf_p = buffer;
	arg = *param;
	fmt = format;

	while (true)
	{
		// run through the format string until we hit a '%' or '\0'
		for (ch = static_cast<D>(*fmt); 
			llen && ((ch = static_cast<D>(*fmt)) != '\0' && ch != '%');
			fmt++)
		{
			*buf_p++ = static_cast<D>(ch);
			llen--;
		}
		if (ch == '\0' || llen <= 0)
			goto done;

		// skip over the '%'
		fmt++;

		// reset formatting state
		flags = 0;
		width = 0;
		prec = -1;
		//sign = '\0';

rflag:
		ch = static_cast<D>(*fmt++);
reswitch:
		switch(ch)
		{
		case '-':
			flags |= LADJUST;
			goto rflag;
		case '.':
			n = 0;
			while( is_digit( ( ch = static_cast<D>(*fmt++)) ) )
				n = 10 * n + ( ch - '0' );
			prec = n < 0 ? -1 : n;
			goto reswitch;
		case '0':
			flags |= ZEROPAD;
			goto rflag;
		case '1':
		case '2':
		case '3':
		case '4':
		case '5':
		case '6':
		case '7':
		case '8':
		case '9':
			n = 0;
			do {
				n = 10 * n + ( ch - '0' );
				ch = static_cast<D>(*fmt++);
			} while( is_digit( ch ) );
			width = n;
			goto reswitch;
		case 'c':
			CHECK_ARGS(0);
			*buf_p++ = static_cast<D>(*get_amxaddr(amx, params[arg]));
			llen--;
			arg++;
			break;
		case 'b':
			CHECK_ARGS(0);
			AddBinary(&buf_p, llen, *get_amxaddr(amx, params[arg]), width, flags);
			arg++;
			break;
		case 'd':
		case 'i':
			CHECK_ARGS(0);
			AddInt(&buf_p, llen, *get_amxaddr(amx, params[arg]), width, flags);
			arg++;
			break;
		case 'u':
			CHECK_ARGS(0);
			AddUInt(&buf_p, llen, static_cast<unsigned int>(*get_amxaddr(amx, params[arg])), width, flags);
			arg++;
			break;
		case 'f':
			CHECK_ARGS(0);
			AddFloat(&buf_p, llen, amx_ctof(*get_amxaddr(amx, params[arg])), width, prec, flags);
			arg++;
			break;
		case 'X':
			CHECK_ARGS(0);
			flags |= UPPERDIGITS;
			AddHex(&buf_p, llen, static_cast<unsigned int>(*get_amxaddr(amx, params[arg])), width, flags);
			arg++;
			break;
		case 'x':
			CHECK_ARGS(0);
			AddHex(&buf_p, llen, static_cast<unsigned int>(*get_amxaddr(amx, params[arg])), width, flags);
			arg++;
			break;
		case 'a':
			{
				CHECK_ARGS(0);
				// %a is passed a pointer directly to a cell string.
				cell* ptr=reinterpret_cast<cell*>(*get_amxaddr(amx, params[arg]));
				if (!ptr)
				{
					LogError(amx, AMX_ERR_NATIVE, "Invalid vector string handle provided (%d)", *get_amxaddr(amx, params[arg]));
					return 0;
				}

				AddString(&buf_p, llen, ptr, width, prec);
				arg++;
				break;
			}
		case 's':
			CHECK_ARGS(0);
			AddString(&buf_p, llen, get_amxaddr(amx, params[arg]), width, prec);
			arg++;
			break;
		case 'L':
		case 'l':
			{
				const char *lang;
				int len;
				if (ch == 'L')
				{
					CHECK_ARGS(1);
					auto currParam = params[arg++];
					lang = playerlang(*get_amxaddr(amx, currParam));
					if (!lang)
						lang = get_amxstring(amx, currParam, 2, len);
				}
				else
				{
					CHECK_ARGS(0);
					lang = playerlang(g_langMngr.GetDefLang());
				}
				const char *key = get_amxstring(amx, params[arg++], 3, len);
				const char *def = translate(amx, lang, key);
				if (!def)
				{
					static char buf[255];
					ke::SafeSprintf(buf, sizeof(buf), "ML_NOTFOUND: %s", key);
					def = buf;
				}
				size_t written = atcprintf(buf_p, llen, def, amx, params, &arg);
				buf_p += written;
				llen -= written;
				break;
			}
		case 'N':
			{
				CHECK_ARGS(0);
				cell *addr = get_amxaddr(amx, params[arg]);
				char buffer[255];
				if (*addr)
				{
					CPlayer *player = NULL;

					if (*addr >= 1 && *addr <= gpGlobals->maxClients)
					{
						player = GET_PLAYER_POINTER_I(*addr);
					}

					if (!player || !player->initialized)
					{
						LogError(amx, AMX_ERR_NATIVE, "Client index %d is invalid", *addr);
						return 0;
					}

					const char *auth = GETPLAYERAUTHID(player->pEdict);
					if (!auth || auth[0] == '\0')
					{
						auth = "STEAM_ID_PENDING";
					}

					int userid = GETPLAYERUSERID(player->pEdict);
					ke::SafeSprintf(buffer, sizeof(buffer), "%s<%d><%s><%s>", player->name.chars(), userid, auth, player->team.chars());
				}
				else
				{
					ke::SafeSprintf(buffer, sizeof(buffer), "Console<0><Console><Console>");
				}

				AddString(&buf_p, llen, buffer, width, prec);
				arg++;
				break;
			}
		case 'n':
			{
				CHECK_ARGS(0);
				cell *addr = get_amxaddr(amx, params[arg]);
				const char *name = "Console";

				if (*addr)
				{
					CPlayer *player = NULL;

					if (*addr >= 1 && *addr <= gpGlobals->maxClients)
					{
						player = GET_PLAYER_POINTER_I(*addr);
					}

					if (!player || !player->initialized)
					{
						LogError(amx, AMX_ERR_NATIVE, "Client index %d is invalid", *addr);
						return 0;
					}

					name = player->name.chars();
				}
			
				AddString(&buf_p, llen, name, width, prec);
				arg++;
				break;
			}
		case '%':
			*buf_p++ = static_cast<D>(ch);
			if (!llen)
				goto done;
			llen--;
			break;
		case '\0':
			*buf_p++ = static_cast<D>('%');
			if (!llen)
				goto done;
			llen--;
			goto done;
			break;
		default:
			*buf_p++ = static_cast<D>(ch);
			if (!llen)
				goto done;
			llen--;
			break;
		}
	}

done:
	*buf_p = static_cast<D>(0);
	*param = arg;

	/* if max buffer length consumed, make sure we don't truncate a multi-byte character */
	if (llen <= 0 && *(buf_p - 1) & 1 << 7)
	{
		llen += UTIL_CheckValidChar(buf_p - 1);
		*(buf_p - llen) = static_cast<D>(0);
	}

	return maxlen-llen;
}
Ejemplo n.º 23
0
//// HOST_SAY
// String comes in as
// say blah blah blah
// or as
// blah blah blah
//
void Host_Say( edict_t *pEntity, int teamonly )
{
	CBasePlayer *client;
	int		j;
	char	*p;
	char	text[128];
	char    szTemp[256];
	const char *cpSay = "say";
	const char *cpSayTeam = "say_team";
	const char *pcmd = CMD_ARGV(0);

	// We can get a raw string now, without the "say " prepended
	if ( CMD_ARGC() == 0 )
		return;

	entvars_t *pev = &pEntity->v;
	CBasePlayer* player = GetClassPtr((CBasePlayer *)pev);

	//Not yet.
	if ( player->m_flNextChatTime > gpGlobals->time )
		 return;

	if ( !stricmp( pcmd, cpSay) || !stricmp( pcmd, cpSayTeam ) )
	{
		if ( CMD_ARGC() >= 2 )
		{
			p = (char *)CMD_ARGS();
		}
		else
		{
			// say with a blank message, nothing to do
			return;
		}
	}
	else  // Raw text, need to prepend argv[0]
	{
		if ( CMD_ARGC() >= 2 )
		{
			sprintf( szTemp, "%s %s", ( char * )pcmd, (char *)CMD_ARGS() );
		}
		else
		{
			// Just a one word command, use the first word...sigh
			sprintf( szTemp, "%s", ( char * )pcmd );
		}
		p = szTemp;
	}

// remove quotes if present
	if (*p == '"')
	{
		p++;
		p[strlen(p)-1] = 0;
	}

// make sure the text has content
	char *pc;
	for ( pc = p; pc != NULL && *pc != 0; pc++ )
	{
		if ( !isspace( *pc ) )
		{
			pc = NULL;	// we've found an alphanumeric character,  so text is valid
			break;
		}
	}
	if ( pc != NULL )
		return;  // no character found, so say nothing

// turn on color set 2  (color on,  no sound)
	if ( teamonly )
		sprintf( text, "%c(TEAM) %s: ", 2, STRING( pEntity->v.netname ) );
	else
		sprintf( text, "%c%s: ", 2, STRING( pEntity->v.netname ) );

	j = sizeof(text) - 2 - strlen(text);  // -2 for /n and null terminator
	if ( (int)strlen(p) > j )
		p[j] = 0;

	strcat( text, p );
	strcat( text, "\n" );


	player->m_flNextChatTime = gpGlobals->time + CHAT_INTERVAL;

	// loop through all players
	// Start with the first player.
	// This may return the world in single player if the client types something between levels or during spawn
	// so check it, or it will infinite loop

	client = NULL;
	while ( ((client = (CBasePlayer*)UTIL_FindEntityByClassname( client, "player" )) != NULL) && (!FNullEnt(client->edict())) ) 
	{
		if ( !client->pev )
			continue;
		
		if ( client->edict() == pEntity )
			continue;

		if ( !(client->IsNetClient()) )	// Not a client ? (should never be true)
			continue;

		// can the receiver hear the sender? or has he muted him?
		if ( g_VoiceGameMgr.PlayerHasBlockedPlayer( client, player ) )
			continue;

		if ( teamonly && g_pGameRules->PlayerRelationship(client, CBaseEntity::Instance(pEntity)) != GR_TEAMMATE )
			continue;

		MESSAGE_BEGIN( MSG_ONE, gmsgSayText, NULL, client->pev );
			WRITE_BYTE( ENTINDEX(pEntity) );
			WRITE_STRING( text );
		MESSAGE_END();

	}

	// print to the sending client
	MESSAGE_BEGIN( MSG_ONE, gmsgSayText, NULL, &pEntity->v );
		WRITE_BYTE( ENTINDEX(pEntity) );
		WRITE_STRING( text );
	MESSAGE_END();

	// echo to server console
	g_engfuncs.pfnServerPrint( text );

	char * temp;
	if ( teamonly )
		temp = "say_team";
	else
		temp = "say";
	
	// team match?
	if ( g_teamplay )
	{
		UTIL_LogPrintf( "\"%s<%i><%s><%s>\" %s \"%s\"\n", 
			STRING( pEntity->v.netname ), 
			GETPLAYERUSERID( pEntity ),
			GETPLAYERAUTHID( pEntity ),
			g_engfuncs.pfnInfoKeyValue( g_engfuncs.pfnGetInfoKeyBuffer( pEntity ), "model" ),
			temp,
			p );
	}
	else
	{
		UTIL_LogPrintf( "\"%s<%i><%s><%i>\" %s \"%s\"\n", 
			STRING( pEntity->v.netname ), 
			GETPLAYERUSERID( pEntity ),
			GETPLAYERAUTHID( pEntity ),
			GETPLAYERUSERID( pEntity ),
			temp,
			p );
	}
}
Ejemplo n.º 24
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);
}
Ejemplo n.º 25
0
void CGrenade::C4Think( void )
{
    if( !IsInWorld() )
    {
        UTIL_Remove( this );
        return;
    }

    pev->nextthink = gpGlobals->time + 0.12;

    if( m_flNextFreq <= gpGlobals->time )
    {
        m_flNextFreq = gpGlobals->time + m_flNextFreqInterval;
        m_flNextFreqInterval *= 0.9;

        switch( m_iC4Beep )
        {
        case 0 :
        {
            m_flAttenu = 1.5;
            m_sBeepName = "weapons/c4_beep1.wav";

            if( UTIL_IsGame( "czero" ) )
            {
                MESSAGE_BEGIN( MSG_ALL, gmsgScenarioIcon );
                WRITE_BYTE( 1 );
                WRITE_STRING( "bombticking" );
                WRITE_BYTE( 255 );
                WRITE_SHORT( 140 );
                WRITE_SHORT( 0 );
                MESSAGE_END();
            }

            break;
        }
        case 1 :
        {
            m_flAttenu = 1.0;
            m_sBeepName = "weapons/c4_beep2.wav";

            if( UTIL_IsGame( "czero" ) )
            {
                MESSAGE_BEGIN( MSG_ALL, gmsgScenarioIcon );
                WRITE_BYTE( 1 );
                WRITE_STRING( "bombticking" );
                WRITE_BYTE( 255 );
                WRITE_SHORT( 70 );
                WRITE_SHORT( 0 );
                MESSAGE_END();
            }

            break;
        }
        case 2 :
        {
            m_flAttenu = 0.8;
            m_sBeepName = "weapons/c4_beep3.wav";

            if( UTIL_IsGame( "czero" ) )
            {
                MESSAGE_BEGIN( MSG_ALL, gmsgScenarioIcon );
                WRITE_BYTE( 1 );
                WRITE_STRING( "bombticking" );
                WRITE_BYTE( 255 );
                WRITE_SHORT( 40 );
                WRITE_SHORT( 0 );
                MESSAGE_END();
            }

            break;
        }
        case 3 :
        {
            m_flAttenu = 0.5;
            m_sBeepName = "weapons/c4_beep4.wav";

            if( UTIL_IsGame( "czero" ) )
            {
                MESSAGE_BEGIN( MSG_ALL, gmsgScenarioIcon );
                WRITE_BYTE( 1 );
                WRITE_STRING( "bombticking" );
                WRITE_BYTE( 255 );
                WRITE_SHORT( 30 );
                WRITE_SHORT( 0 );
                MESSAGE_END();
            }

            break;
        }
        case 4 :
        {
            m_flAttenu = 0.2;
            m_sBeepName = "weapons/c4_beep5.wav";

            if( UTIL_IsGame( "czero" ) )
            {
                MESSAGE_BEGIN( MSG_ALL, gmsgScenarioIcon );
                WRITE_BYTE( 1 );
                WRITE_STRING( "bombticking" );
                WRITE_BYTE( 255 );
                WRITE_SHORT( 20 );
                WRITE_SHORT( 0 );
                MESSAGE_END();
            }

            break;
        }
        }

        ++m_iC4Beep;
    }

    if( m_flNextBeep <= gpGlobals->time )
    {
        m_flNextBeep = gpGlobals->time + 1.4;
        EMIT_SOUND( ENT( pev ), CHAN_VOICE, m_sBeepName, VOL_NORM, m_flAttenu );

        // TODO: Adds support for bots.
        // TheBots->OnEvent( EVENT_BOMB_BEEP, this, NULL );
    }

    if( m_flNextBlink <= gpGlobals->time )
    {
        m_flNextBlink = gpGlobals->time	+ 2.0;

        MESSAGE_BEGIN( MSG_PVS, SVC_TEMPENTITY, pev->origin );
        WRITE_BYTE( TE_GLOWSPRITE );
        WRITE_COORD( pev->origin.x );
        WRITE_COORD( pev->origin.y );
        WRITE_COORD( pev->origin.z + 5.0 );
        WRITE_SHORT( g_sModelIndexC4Glow );
        WRITE_BYTE( 1 );
        WRITE_BYTE( 3 );
        WRITE_BYTE( 255 );
        MESSAGE_END();
    }

    if( m_flC4Blow <= gpGlobals->time )
    {
        // TODO: Adds support for bots.
        // TheBots->OnEvent( EVENT_BOMB_EXPLODED, NULL, NULL );

        MESSAGE_BEGIN( MSG_ALL, gmsgScenarioIcon );
        WRITE_BYTE( 0 );
        MESSAGE_END();

        if( m_pentCurBombTarget )
        {
            CBaseEntity *pEntity = CBaseEntity::Instance( m_pentCurBombTarget->pev );

            if( pEntity )
            {
                CBaseEntity* pPlayer = CBaseEntity::Instance( pev->owner );

                if( pPlayer )
                {
                    pEntity->Use( pPlayer, this, USE_TOGGLE, 0 );
                }
            }
        }

        CBasePlayer* pPlayer = (CBasePlayer *)CBaseEntity::Instance( pev->owner );

        if( pPlayer )
        {
            pPlayer->pev->frags += 3;
        }

        MESSAGE_BEGIN( MSG_ALL, gmsgBombPickup );
        MESSAGE_END();

        g_pGameRules->m_fBombDropped = FALSE;

        if( pev->waterlevel )
            UTIL_Remove( this );
        else
            SetThink( &CGrenade::Detonate2 );
    }

    if( m_fStartDefuse )
    {
        CBasePlayer* pDefuser = (CBasePlayer *)((CBaseEntity *)m_hDefuser);

        if( pDefuser && m_flDefuseCountDown > gpGlobals->time )
        {
            BOOL isOnGround = !!( pDefuser->pev->flags & FL_ONGROUND );

            if( m_flNextDefuseTime < gpGlobals->time || !isOnGround )
            {
                if( !isOnGround )
                {
                    ClientPrint( m_hDefuser->pev, HUD_PRINTCENTER, "#C4_Defuse_Must_Be_On_Ground" );
                }

                pDefuser->ResetMaxSpeed();
                pDefuser->SetProgressBarTime( 0 );
                pDefuser->m_fBombDefusing = FALSE;

                m_fStartDefuse = FALSE;
                m_flDefuseCountDown = 0.0;

                // TODO: Adds support for bots.
                // TheBots->OnEvent( EVENT_DEFUSE_ABORTED, NULL, NULL );
            }
        }
        else
        {
            // TODO: Adds support for bots.
            // TheBots->OnEvent( EVENT_BOMB_DEFUSED, pDefuser, NULL );

            Broadcast( "BOMBDEF" );

            MESSAGE_BEGIN( MSG_SPEC, SVC_DIRECTOR );
            WRITE_BYTE( 9 );
            WRITE_BYTE( DRC_CMD_EVENT );
            WRITE_SHORT( ENTINDEX( this->edict() ) );
            WRITE_SHORT( NULL );
            WRITE_ENTITY( DRC_FLAG_FINAL | DRC_FLAG_FACEPLAYER | DRC_FLAG_DRAMATIC | 15 );
            MESSAGE_END();

            UTIL_LogPrintf(	"\"%s<%i><%s><CT>\" triggered \"Defused_The_Bomb\"\n",
                            STRING( pDefuser->pev->netname ),
                            GETPLAYERAUTHID( pDefuser->edict() ),
                            GETPLAYERUSERID( pDefuser->edict() ) );

            UTIL_EmitAmbientSound( ENT( pev ), pev->origin, "weapons/c4_beep5.wav", 0, ATTN_NONE, SND_STOP, 0 );
            EMIT_SOUND( ENT( pDefuser->pev ), CHAN_WEAPON, "weapons/c4_disarmed.wav", 0.8, ATTN_NORM );

            UTIL_Remove( this );
            m_fJustBlew = TRUE;

            pDefuser->ResetMaxSpeed();
            pDefuser->m_fBombDefusing = FALSE;

            MESSAGE_BEGIN( MSG_ALL, gmsgScenarioIcon );
            WRITE_BYTE( 0 );
            MESSAGE_END();

            if( g_pGameRules->IsCareer() )
            {
                // TODO: Adds support for bots.
                //TheCareerTasks->HandleEvents( EVEN_BOMB_DEFUSED, pDefuser, NULL );
            }

            g_pGameRules->m_bBombDefused = TRUE;
            g_pGameRules->CheckWinConditions();

            pDefuser->pev->frags += 3;

            MESSAGE_BEGIN( MSG_ALL, gmsgBombPickup );
            MESSAGE_END();

            g_pGameRules->m_fBombDropped = FALSE;
            m_fStartDefuse = FALSE;
        }
    }
}
Ejemplo n.º 26
0
/*
========================
ClientUserInfoChanged

called after the player changes
userinfo - gives dll a chance to modify it before
it gets sent into the rest of the engine.
========================
*/
void ClientUserInfoChanged( edict_t *pEntity, char *infobuffer )
{
	// Is the client spawned yet?
	if ( !pEntity->pvPrivateData )
		return;

	// msg everyone if someone changes their name,  and it isn't the first time (changing no name to current name)
	if ( pEntity->v.netname && STRING(pEntity->v.netname)[0] != 0 && !FStrEq( STRING(pEntity->v.netname), g_engfuncs.pfnInfoKeyValue( infobuffer, "name" )) )
	{
		char text[256];
		sprintf( text, "* %s changed name to %s\n", STRING(pEntity->v.netname), g_engfuncs.pfnInfoKeyValue( infobuffer, "name" ) );
		MESSAGE_BEGIN( MSG_ALL, gmsgSayText, NULL );
			WRITE_BYTE( ENTINDEX(pEntity) );
			WRITE_STRING( text );
		MESSAGE_END();

		UTIL_LogPrintf( "\"%s<%i>\" changed name to \"%s<%i>\"\n", STRING( pEntity->v.netname ), GETPLAYERUSERID( pEntity ), g_engfuncs.pfnInfoKeyValue( infobuffer, "name" ), GETPLAYERUSERID( pEntity ) );
	}

	g_pGameRules->ClientUserInfoChanged( GetClassPtr((CBasePlayer *)&pEntity->v), infobuffer );
}