本文整理汇总了C++中CBaseCombatWeapon::GetName方法的典型用法代码示例。如果您正苦于以下问题:C++ CBaseCombatWeapon::GetName方法的具体用法?C++ CBaseCombatWeapon::GetName怎么用?C++ CBaseCombatWeapon::GetName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CBaseCombatWeapon
的用法示例。
在下文中一共展示了CBaseCombatWeapon::GetName方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CC_SwitchToPhyscannon
//
// Name: CC_SwitchToPhyscannon
// Author: Hekar Khani
// Description: Concommand. Switches between Physcannon and last weapon
// Notes:
//
void CC_SwitchToPhyscannon( void )
{
CBasePlayer *pPlayer = ToBasePlayer( UTIL_GetCommandClient() );
if ( pPlayer )
{
CBaseCombatWeapon *pWeapon = pPlayer->GetActiveWeapon();
if ( pWeapon )
{
// Tell the client to stop selecting weapons
engine->ClientCommand( UTIL_GetCommandClient()->edict(), "cancelselect" );
const char *strWeaponName = pWeapon->GetName();
if ( !Q_stricmp( strWeaponName, "weapon_lf_combat_cannon" ) )
{
pPlayer->SelectLastItem();
}
else
{
pPlayer->SelectItem( "weapon_lf_combat_cannon" );
}
}
}
}
示例2: OnTakeDamage
//-----------------------------------------------------------------------------
// Purpose: allows the crate to open up when hit by a crowbar
//-----------------------------------------------------------------------------
int CItem_AmmoCrate::OnTakeDamage( const CTakeDamageInfo &info )
{
// if it's the player hitting us with a crowbar, open up
CBasePlayer *player = ToBasePlayer(info.GetAttacker());
if (player)
{
CBaseCombatWeapon *weapon = player->GetActiveWeapon();
if (weapon && !stricmp(weapon->GetName(), "weapon_crowbar"))
{
// play the normal use sound
player->EmitSound( "HL2Player.Use" );
// open the crate
Use(info.GetAttacker(), info.GetAttacker(), USE_TOGGLE, 0.0f);
}
}
// don't actually take any damage
return 0;
}
示例3: RunCommand
//-----------------------------------------------------------------------------
// Purpose: Runs movement commands for the player
// Input : *player -
// *ucmd -
// *moveHelper -
// Output : void CPlayerMove::RunCommand
//-----------------------------------------------------------------------------
void CPlayerMove::RunCommand ( CBasePlayer *player, CUserCmd *ucmd, IMoveHelper *moveHelper )
{
StartCommand( player, ucmd );
// Set globals appropriately
gpGlobals->curtime = player->m_nTickBase * TICK_INTERVAL;
gpGlobals->frametime = player->m_bGamePaused ? 0 : TICK_INTERVAL;
if ( player->m_bGamePaused )
{
// If no clipping and cheats enabled and noclipduring game enabled, then leave
// forwardmove and angles stuff in usercmd
if ( player->GetMoveType() == MOVETYPE_NOCLIP &&
sv_cheats->GetBool() &&
sv_noclipduringpause.GetBool() )
{
gpGlobals->frametime = TICK_INTERVAL;
}
}
/*
// TODO: We can check whether the player is sending more commands than elapsed real time
cmdtimeremaining -= ucmd->msec;
if ( cmdtimeremaining < 0 )
{
// return;
}
*/
IGameSystem::FrameUpdatePrePlayerRunCommandAllSystems( player, ucmd );
// Do weapon selection
if ( ucmd->weaponselect != 0 )
{
CBaseCombatWeapon *weapon = dynamic_cast< CBaseCombatWeapon * >( CBaseEntity::Instance( ucmd->weaponselect ) );
if ( weapon )
{
VPROF( "player->SelectItem()" );
player->SelectItem( weapon->GetName(), ucmd->weaponsubtype );
}
}
IServerVehicle *pVehicle = player->GetVehicle();
// Latch in impulse.
if ( ucmd->impulse )
{
// Discard impulse commands unless the vehicle allows them.
// FIXME: UsingStandardWeapons seems like a bad filter for this. The flashlight is an impulse command, for example.
if ( !pVehicle || player->UsingStandardWeaponsInVehicle() )
{
player->m_nImpulse = ucmd->impulse;
}
}
// Update player input button states
VPROF_SCOPE_BEGIN( "player->UpdateButtonState" );
player->UpdateButtonState( ucmd->buttons );
VPROF_SCOPE_END();
CheckMovingGround( player, TICK_INTERVAL );
g_pMoveData->m_vecOldAngles = player->pl.v_angle;
// Copy from command to player unless game .dll has set angle using fixangle
if ( player->pl.fixangle == FIXANGLE_NONE )
{
player->pl.v_angle = ucmd->viewangles;
}
else if( player->pl.fixangle == FIXANGLE_RELATIVE )
{
player->pl.v_angle = ucmd->viewangles + player->pl.anglechange;
}
// Call standard client pre-think
RunPreThink( player );
// Call Think if one is set
RunThink( player, TICK_INTERVAL );
// Setup input.
SetupMove( player, ucmd, moveHelper, g_pMoveData );
// Let the game do the movement.
if ( !pVehicle )
{
VPROF( "g_pGameMovement->ProcessMovement()" );
Assert( g_pGameMovement );
g_pGameMovement->ProcessMovement( player, g_pMoveData );
}
else
{
VPROF( "pVehicle->ProcessMovement()" );
//.........这里部分代码省略.........
示例4: RunCommand
//-----------------------------------------------------------------------------
// Purpose: Runs movement commands for the player
// Input : *player -
// *ucmd -
// *moveHelper -
// Output : void CPlayerMove::RunCommand
//-----------------------------------------------------------------------------
void CPlayerMove::RunCommand ( CBasePlayer *player, CUserCmd *ucmd, IMoveHelper *moveHelper )
{
const float playerCurTime = player->m_nTickBase * TICK_INTERVAL;
const float playerFrameTime = player->m_bGamePaused ? 0 : TICK_INTERVAL;
const float flTimeAllowedForProcessing = player->ConsumeMovementTimeForUserCmdProcessing( playerFrameTime );
if ( !player->IsBot() && ( flTimeAllowedForProcessing < playerFrameTime ) )
{
// Make sure that the activity in command is erased because player cheated or dropped too many packets
double dblWarningFrequencyThrottle = sv_maxusrcmdprocessticks_warning.GetFloat();
if ( dblWarningFrequencyThrottle >= 0 )
{
static double s_dblLastWarningTime = 0;
double dblTimeNow = Plat_FloatTime();
if ( !s_dblLastWarningTime || ( dblTimeNow - s_dblLastWarningTime >= dblWarningFrequencyThrottle ) )
{
s_dblLastWarningTime = dblTimeNow;
Warning( "sv_maxusrcmdprocessticks_warning at server tick %u: Ignored client %s usrcmd (%.6f < %.6f)!\n", gpGlobals->tickcount, player->GetPlayerName(), flTimeAllowedForProcessing, playerFrameTime );
}
}
return; // Don't process this command
}
StartCommand( player, ucmd );
// Set globals appropriately
gpGlobals->curtime = playerCurTime;
gpGlobals->frametime = playerFrameTime;
// Prevent hacked clients from sending us invalid view angles to try to get leaf server code to crash
if ( !ucmd->viewangles.IsValid() || !IsEntityQAngleReasonable(ucmd->viewangles) )
{
ucmd->viewangles = vec3_angle;
}
// Add and subtract buttons we're forcing on the player
ucmd->buttons |= player->m_afButtonForced;
ucmd->buttons &= ~player->m_afButtonDisabled;
if ( player->m_bGamePaused )
{
// If no clipping and cheats enabled and noclipduring game enabled, then leave
// forwardmove and angles stuff in usercmd
if ( player->GetMoveType() == MOVETYPE_NOCLIP &&
sv_cheats->GetBool() &&
sv_noclipduringpause.GetBool() )
{
gpGlobals->frametime = TICK_INTERVAL;
}
}
/*
// TODO: We can check whether the player is sending more commands than elapsed real time
cmdtimeremaining -= ucmd->msec;
if ( cmdtimeremaining < 0 )
{
// return;
}
*/
g_pGameMovement->StartTrackPredictionErrors( player );
CommentarySystem_PePlayerRunCommand( player, ucmd );
// Do weapon selection
if ( ucmd->weaponselect != 0 )
{
CBaseCombatWeapon *weapon = dynamic_cast< CBaseCombatWeapon * >( CBaseEntity::Instance( ucmd->weaponselect ) );
if ( weapon )
{
VPROF( "player->SelectItem()" );
player->SelectItem( weapon->GetName(), ucmd->weaponsubtype );
}
}
IServerVehicle *pVehicle = player->GetVehicle();
// Latch in impulse.
if ( ucmd->impulse )
{
// Discard impulse commands unless the vehicle allows them.
// FIXME: UsingStandardWeapons seems like a bad filter for this. The flashlight is an impulse command, for example.
if ( !pVehicle || player->UsingStandardWeaponsInVehicle() )
{
player->m_nImpulse = ucmd->impulse;
}
}
// Update player input button states
VPROF_SCOPE_BEGIN( "player->UpdateButtonState" );
player->UpdateButtonState( ucmd->buttons );
VPROF_SCOPE_END();
CheckMovingGround( player, TICK_INTERVAL );
//.........这里部分代码省略.........