本文整理汇总了C++中C_BaseCombatWeapon类的典型用法代码示例。如果您正苦于以下问题:C++ C_BaseCombatWeapon类的具体用法?C++ C_BaseCombatWeapon怎么用?C++ C_BaseCombatWeapon使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了C_BaseCombatWeapon类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: UpdateAmmoState
void UpdateAmmoState()
{
C_BasePlayer *player = C_BasePlayer::GetLocalPlayer();
C_BaseCombatWeapon *wpn = player ? player->GetActiveWeapon() : NULL;
if (player && wpn && wpn->UsesSecondaryAmmo())
{
SetAmmo(player->GetAmmoCount(wpn->GetSecondaryAmmoType()));
}
if ( m_hCurrentActiveWeapon != wpn )
{
if ( wpn->UsesSecondaryAmmo() )
{
// we've changed to a weapon that uses secondary ammo
GetClientMode()->GetViewportAnimationController()->StartAnimationSequence("WeaponUsesSecondaryAmmo");
}
else
{
// we've changed away from a weapon that uses secondary ammo
GetClientMode()->GetViewportAnimationController()->StartAnimationSequence("WeaponDoesNotUseSecondaryAmmo");
}
m_hCurrentActiveWeapon = wpn;
}
}
示例2: ShouldDraw
//-----------------------------------------------------------------------------
// Purpose: Save CPU cycles by letting the HUD system early cull
// costly traversal. Called per frame, return true if thinking and
// painting need to occur.
//-----------------------------------------------------------------------------
bool CHudCrosshair::ShouldDraw( void )
{
bool bNeedsDraw;
if ( m_bHideCrosshair )
return false;
C_BasePlayer* pPlayer = C_BasePlayer::GetLocalPlayer();
if ( !pPlayer )
return false;
C_BaseCombatWeapon *pWeapon = pPlayer->GetActiveWeapon();
if ( pWeapon && !pWeapon->ShouldDrawCrosshair() )
return false;
/* disabled to avoid assuming it's an HL2 player.
// suppress crosshair in zoom.
if ( pPlayer->m_HL2Local.m_bZooming )
return false;
*/
// draw a crosshair only if alive or spectating in eye
bNeedsDraw = m_pCrosshair &&
crosshair.GetInt() &&
!engine->IsDrawingLoadingImage() &&
!engine->IsPaused() &&
g_pClientMode->ShouldDrawCrosshair() &&
!( pPlayer->GetFlags() & FL_FROZEN ) &&
( pPlayer->entindex() == render->GetViewEntity() ) &&
//!pPlayer->IsInVGuiInputMode() &&
( pPlayer->IsAlive() || ( pPlayer->GetObserverMode() == OBS_MODE_IN_EYE ) || ( cl_observercrosshair.GetBool() && pPlayer->GetObserverMode() == OBS_MODE_ROAMING ) );
return ( bNeedsDraw && CHudElement::ShouldDraw() );
}
示例3: MarkMessageReceived
void CBeam::OnDataChanged( DataUpdateType_t updateType )
{
MarkMessageReceived();
// Make sure that the correct model is referenced for this entity
SetModelPointer( modelinfo->GetModel( GetModelIndex() ) );
// Convert weapon world models to viewmodels if they're weapons being carried by the local player
for (int i=0;i<MAX_BEAM_ENTS;i++)
{
C_BaseEntity *pEnt = m_hAttachEntity[i].Get();
if ( pEnt )
{
C_BaseCombatWeapon *pWpn = dynamic_cast<C_BaseCombatWeapon *>(pEnt);
if ( pWpn && pWpn->IsCarriedByLocalPlayer() )
{
C_BasePlayer *player = ToBasePlayer( pWpn->GetOwner() );
C_BaseViewModel *pViewModel = player ? player->GetViewModel( 0 ) : NULL;
if ( pViewModel )
{
// Get the viewmodel and use it instead
m_hAttachEntity.Set( i, pViewModel );
}
}
}
}
// Compute the bounds here...
Vector mins, maxs;
ComputeBounds( mins, maxs );
SetCollisionBounds( mins, maxs );
}
示例4:
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
C_BaseCombatWeapon *CBaseHudWeaponSelection::GetNextActivePos( int iSlot, int iSlotPos )
{
if ( iSlotPos >= MAX_WEAPON_POSITIONS || iSlot >= MAX_WEAPON_SLOTS )
return NULL;
int iLowestPosition = MAX_WEAPON_POSITIONS;
C_BaseCombatWeapon *pNextWeapon = NULL;
C_BasePlayer *player = C_BasePlayer::GetLocalPlayer();
if ( !player )
return NULL;
for ( int i = 0; i < MAX_WEAPONS; i++ )
{
C_BaseCombatWeapon *pWeapon = player->GetWeapon( i );
if ( !pWeapon )
continue;
if ( CanBeSelectedInHUD( pWeapon ) && pWeapon->GetSlot() == iSlot )
{
// If this weapon is lower in the slot than the current lowest, and above our desired position, it's our new winner
if ( pWeapon->GetPosition() <= iLowestPosition && pWeapon->GetPosition() >= iSlotPos )
{
iLowestPosition = pWeapon->GetPosition();
pNextWeapon = pWeapon;
}
}
}
return pNextWeapon;
}
示例5: MDLCACHE_CRITICAL_SECTION
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CHudWeapon::Paint( void )
{
C_GstringPlayer *player =LocalGstringPlayer();
if ( !player )
return;
// GSTRINGMIGRATION
if ( player->IsInSpacecraft() )
{
player->GetSpacecraft()->UpdateCrosshair( m_pCrosshair );
return;
}
// END GSTRINGMIGRATION
MDLCACHE_CRITICAL_SECTION();
C_BaseCombatWeapon *pWeapon = player->GetActiveWeapon();
if ( pWeapon )
{
pWeapon->Redraw();
}
else
{
if ( m_pCrosshair )
{
m_pCrosshair->ResetCrosshair();
}
}
}
示例6: UpdateAmmoState
void UpdateAmmoState()
{
C_BaseCombatWeapon *wpn = GetActiveWeapon();
C_BasePlayer *player = C_BasePlayer::GetLocalPlayer();
if (player && wpn && wpn->UsesSecondaryAmmo())
{
SetAmmo(player->GetAmmoCount(wpn->GetSecondaryAmmoType()));
}
if ( m_hCurrentActiveWeapon != wpn )
{
if ( wpn->UsesSecondaryAmmo() )
{
// we've changed to a weapon that uses secondary ammo
g_pClientMode->GetViewportAnimationController()->StartAnimationSequence("WeaponUsesSecondaryAmmo");
}
else
{
// we've changed away from a weapon that uses secondary ammo
g_pClientMode->GetViewportAnimationController()->StartAnimationSequence("WeaponDoesNotUseSecondaryAmmo");
}
m_hCurrentActiveWeapon = wpn;
// Get the icon we should be displaying
m_iconSecondaryAmmo = gWR.GetAmmoIconFromWeapon( m_hCurrentActiveWeapon->GetSecondaryAmmoType() );
}
}
示例7: EmitSound
//-----------------------------------------------------------------------------
// Purpose
//-----------------------------------------------------------------------------
void C_BaseViewModel::FireEvent( const Vector& origin, const QAngle& angles, int event, const char *options )
{
// We override sound requests so that we can play them locally on the owning player
if ( ( event == AE_CL_PLAYSOUND ) || ( event == CL_EVENT_SOUND ) )
{
// Only do this if we're owned by someone
if ( GetOwner() != NULL )
{
CLocalPlayerFilter filter;
EmitSound( filter, GetOwner()->GetSoundSourceIndex(), options, &GetAbsOrigin() );
return;
}
}
// Otherwise pass the event to our associated weapon
C_BaseCombatWeapon *pWeapon = GetActiveWeapon();
if ( pWeapon )
{
// NVNT notify the haptics system of our viewmodel's event
if ( haptics )
haptics->ProcessHapticEvent(4,"Weapons",pWeapon->GetName(),"AnimationEvents",VarArgs("%i",event));
bool bResult = pWeapon->OnFireEvent( this, origin, angles, event, options );
if ( !bResult )
{
BaseClass::FireEvent( origin, angles, event, options );
}
}
}
示例8: if
//-----------------------------------------------------------------------------
// Purpose: Think
//-----------------------------------------------------------------------------
void CHud::Think(void)
{
// Determine the visibility of all hud elements
for ( int i = 0; i < m_HudList.Size(); i++ )
{
// Visible?
bool visible = m_HudList[i]->ShouldDraw();
m_HudList[i]->SetActive( visible );
// If it's a vgui panel, hide/show as appropriate
vgui::Panel *pPanel = dynamic_cast<vgui::Panel*>(m_HudList[i]);
if ( pPanel && pPanel->IsVisible() != visible )
{
pPanel->SetVisible( visible );
}
else if ( !pPanel )
{
// All HUD elements should now derive from vgui!!!
Assert( 0 );
}
if ( visible )
{
m_HudList[i]->ProcessInput();
}
}
// Let the active weapon at the keybits
C_BaseCombatWeapon *pWeapon = GetActiveWeapon();
if ( pWeapon )
{
pWeapon->HandleInput();
}
}
示例9: EmitSound
//-----------------------------------------------------------------------------
// Purpose
//-----------------------------------------------------------------------------
void C_BaseViewModel::FireEvent( const Vector& origin, const QAngle& angles, int eventNum, const char *options )
{
// We override sound requests so that we can play them locally on the owning player
if ( ( eventNum == AE_CL_PLAYSOUND ) || ( eventNum == CL_EVENT_SOUND ) )
{
// Only do this if we're owned by someone
if ( GetOwner() != NULL )
{
CLocalPlayerFilter filter;
EmitSound( filter, GetOwner()->GetSoundSourceIndex(), options, &GetAbsOrigin() );
return;
}
}
C_BasePlayer *pOwner = ToBasePlayer( GetOwner() );
if ( !pOwner )
return;
ACTIVE_SPLITSCREEN_PLAYER_GUARD_ENT( pOwner );
// Otherwise pass the event to our associated weapon
C_BaseCombatWeapon *pWeapon = pOwner->GetActiveWeapon();
if ( pWeapon )
{
bool bResult = pWeapon->OnFireEvent( this, origin, angles, eventNum, options );
if ( !bResult )
{
if ( eventNum == AE_CLIENT_EFFECT_ATTACH && ::input->CAM_IsThirdPerson() )
return;
BaseClass::FireEvent( origin, angles, eventNum, options );
}
}
}
示例10: GetDrawPosition
void CHudCrosshair::Paint( void )
{
if ( !m_pCrosshair )
return;
if ( !IsCurrentViewAccessAllowed() )
return;
C_BasePlayer* pPlayer = C_BasePlayer::GetLocalPlayer();
if ( !pPlayer )
return;
float x, y;
bool bBehindCamera;
GetDrawPosition ( &x, &y, &bBehindCamera, m_vecCrossHairOffsetAngle );
if( bBehindCamera )
return;
float flWeaponScale = 1.f;
int iTextureW = m_pCrosshair->Width();
int iTextureH = m_pCrosshair->Height();
C_BaseCombatWeapon *pWeapon = pPlayer->GetActiveWeapon();
if ( pWeapon )
{
pWeapon->GetWeaponCrosshairScale( flWeaponScale );
}
float flPlayerScale = 1.0f;
#ifdef TF_CLIENT_DLL
Color clr( cl_crosshair_red.GetInt(), cl_crosshair_green.GetInt(), cl_crosshair_blue.GetInt(), 255 );
flPlayerScale = cl_crosshair_scale.GetFloat() / 32.0f; // the player can change the scale in the options/multiplayer tab
#else
Color clr = m_clrCrosshair;
#endif
float flWidth = flWeaponScale * flPlayerScale * (float)iTextureW;
float flHeight = flWeaponScale * flPlayerScale * (float)iTextureH;
int iWidth = (int)( flWidth + 0.5f );
int iHeight = (int)( flHeight + 0.5f );
int iX = (int)( x + 0.5f );
int iY = (int)( y + 0.5f );
if (pPlayer->IsInVGuiInputMode() && m_pVGUIHoverIcon)
m_pVGUIHoverIcon->DrawSelf(
iX - (m_pVGUIHoverIcon->Width() / 2),
iY - (m_pVGUIHoverIcon->Height() / 2),
m_pVGUIHoverIcon->Width(),
m_pVGUIHoverIcon->Height(),
Color(0, 255, 0, 255));
else
{
m_pCrosshair->DrawSelfCropped(
iX - (iWidth / 2), iY - (iHeight + 2),
0, 0,
iTextureW, iTextureH,
iWidth, iHeight,
clr);
}
}
示例11: HapticsHandleMsg_SPHapWeapEvent
//Might be able to handle this better...
void HapticsHandleMsg_SPHapWeapEvent( int iActivity )
{
C_BasePlayer* pPlayer = C_BasePlayer::GetLocalPlayer();
C_BaseCombatWeapon* weap = NULL;
if(pPlayer)
weap = pPlayer->GetActiveWeapon();
if(weap)
haptics->ProcessHapticEvent(4,"Weapons",weap->GetName(),"Activities",VarArgs("%i",iActivity));
}
示例12: defined
//-----------------------------------------------------------------------------
// Purpose: Think
//-----------------------------------------------------------------------------
void CHud::Think(void)
{
#if defined( REPLAY_ENABLED )
// Don't draw this
extern IEngineClientReplay *g_EngineClientReplay;
const bool bPlayingReplay = g_pEngineClientReplay && g_pEngineClientReplay->IsPlayingReplayDemo();
#endif
// Determine the visibility of all hud elements
for ( int i = 0; i < m_HudList.Size(); i++ )
{
// Visible?
bool visible = m_HudList[i]->ShouldDraw();
#if defined( REPLAY_ENABLED )
visible = visible && !bPlayingReplay;
#endif
m_HudList[i]->SetActive( visible );
// If it's a vgui panel, hide/show as appropriate
vgui::Panel *pPanel = dynamic_cast<vgui::Panel*>(m_HudList[i]);
if ( pPanel && pPanel->IsVisible() != visible )
{
pPanel->SetVisible( visible );
}
else if ( !pPanel )
{
// All HUD elements should now derive from vgui!!!
Assert( 0 );
}
if ( visible )
{
m_HudList[i]->ProcessInput();
}
}
// Let the active weapon at the keybits
C_BaseCombatWeapon *pWeapon = GetActiveWeapon();
if ( pWeapon )
{
pWeapon->HandleInput();
}
if ( ( m_flScreenShotTime > 0 ) && ( m_flScreenShotTime < gpGlobals->curtime ) )
{
if ( !IsX360() )
{
engine->ClientCmd( "screenshot" );
}
m_flScreenShotTime = -1;
}
}
示例13: GetFxBlend
//-----------------------------------------------------------------------------
// Purpose: Render the weapon. Draw the Viewmodel if the weapon's being carried
// by this player, otherwise draw the worldmodel.
//-----------------------------------------------------------------------------
int C_BaseViewModel::DrawModel( int flags )
{
if ( !m_bReadyToDraw )
return 0;
if ( flags & STUDIO_RENDER )
{
// Determine blending amount and tell engine
float blend = (float)( GetFxBlend() / 255.0f );
// Totally gone
if ( blend <= 0.0f )
return 0;
// Tell engine
render->SetBlend( blend );
float color[3];
GetColorModulation( color );
render->SetColorModulation( color );
}
C_BasePlayer *pPlayer = C_BasePlayer::GetLocalPlayer();
C_BaseCombatWeapon *pWeapon = GetOwningWeapon();
int ret;
// If the local player's overriding the viewmodel rendering, let him do it
if ( pPlayer && pPlayer->IsOverridingViewmodel() )
{
ret = pPlayer->DrawOverriddenViewmodel( this, flags );
}
else if ( pWeapon && pWeapon->IsOverridingViewmodel() )
{
ret = pWeapon->DrawOverriddenViewmodel( this, flags );
}
else
{
ret = BaseClass::DrawModel( flags );
}
// Now that we've rendered, reset the animation restart flag
if ( flags & STUDIO_RENDER )
{
if ( m_nOldAnimationParity != m_nAnimationParity )
{
m_nOldAnimationParity = m_nAnimationParity;
}
// Tell the weapon itself that we've rendered, in case it wants to do something
if ( pWeapon )
{
pWeapon->ViewModelDrawn( this );
}
}
return ret;
}
示例14: GetActiveWeapon
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void C_BaseViewModel::GetBoneControllers(float controllers[MAXSTUDIOBONECTRLS])
{
BaseClass::GetBoneControllers( controllers );
// Tell the weapon itself that we've rendered, in case it wants to do something
C_BaseCombatWeapon *pWeapon = GetActiveWeapon();
if ( pWeapon )
{
pWeapon->GetViewmodelBoneControllers( this, controllers );
}
}
示例15: UpdateValues
void Aimbot::UpdateValues()
{
C_BasePlayer* localplayer = (C_BasePlayer*) entityList->GetClientEntity(engine->GetLocalPlayer());
if (!localplayer || !localplayer->GetAlive())
return;
C_BaseCombatWeapon* activeWeapon = (C_BaseCombatWeapon*) entityList->GetClientEntityFromHandle(localplayer->GetActiveWeapon());
if (!activeWeapon)
return;
ItemDefinitionIndex index = ItemDefinitionIndex::INVALID;
if (Settings::Aimbot::weapons.find(*activeWeapon->GetItemDefinitionIndex()) != Settings::Aimbot::weapons.end())
index = *activeWeapon->GetItemDefinitionIndex();
const AimbotWeapon_t& currentWeaponSetting = Settings::Aimbot::weapons.at(index);
Settings::Aimbot::enabled = currentWeaponSetting.enabled;
Settings::Aimbot::silent = currentWeaponSetting.silent;
Settings::Aimbot::friendly = currentWeaponSetting.friendly;
Settings::Aimbot::bone = currentWeaponSetting.bone;
Settings::Aimbot::aimkey = currentWeaponSetting.aimkey;
Settings::Aimbot::aimkeyOnly = currentWeaponSetting.aimkeyOnly;
Settings::Aimbot::Smooth::enabled = currentWeaponSetting.smoothEnabled;
Settings::Aimbot::Smooth::value = currentWeaponSetting.smoothAmount;
Settings::Aimbot::Smooth::type = currentWeaponSetting.smoothType;
Settings::Aimbot::ErrorMargin::enabled = currentWeaponSetting.errorMarginEnabled;
Settings::Aimbot::ErrorMargin::value = currentWeaponSetting.errorMarginValue;
Settings::Aimbot::AutoAim::enabled = currentWeaponSetting.autoAimEnabled;
Settings::Aimbot::AutoAim::fov = currentWeaponSetting.autoAimFov;
Settings::Aimbot::AimStep::enabled = currentWeaponSetting.aimStepEnabled;
Settings::Aimbot::AimStep::value = currentWeaponSetting.aimStepValue;
Settings::Aimbot::AutoPistol::enabled = currentWeaponSetting.autoPistolEnabled;
Settings::Aimbot::AutoShoot::enabled = currentWeaponSetting.autoShootEnabled;
Settings::Aimbot::AutoShoot::autoscope = currentWeaponSetting.autoScopeEnabled;
Settings::Aimbot::RCS::enabled = currentWeaponSetting.rcsEnabled;
Settings::Aimbot::RCS::always_on = currentWeaponSetting.rcsAlwaysOn;
Settings::Aimbot::RCS::valueX = currentWeaponSetting.rcsAmountX;
Settings::Aimbot::RCS::valueY = currentWeaponSetting.rcsAmountY;
Settings::Aimbot::NoShoot::enabled = currentWeaponSetting.noShootEnabled;
Settings::Aimbot::IgnoreJump::enabled = currentWeaponSetting.ignoreJumpEnabled;
Settings::Aimbot::Smooth::Salting::enabled = currentWeaponSetting.smoothSaltEnabled;
Settings::Aimbot::Smooth::Salting::multiplier = currentWeaponSetting.smoothSaltMultiplier;
Settings::Aimbot::SmokeCheck::enabled = currentWeaponSetting.smokeCheck;
Settings::Aimbot::FlashCheck::enabled = currentWeaponSetting.flashCheck;
Settings::Aimbot::AutoWall::enabled = currentWeaponSetting.autoWallEnabled;
Settings::Aimbot::AutoWall::value = currentWeaponSetting.autoWallValue;
Settings::Aimbot::AutoSlow::enabled = currentWeaponSetting.autoSlow;
Settings::Aimbot::AutoSlow::minDamage = currentWeaponSetting.autoSlowMinDamage;
for (int i = (int) Hitbox::HITBOX_HEAD; i <= (int) Hitbox::HITBOX_ARMS; i++)
Settings::Aimbot::AutoWall::bones[i] = currentWeaponSetting.autoWallBones[i];
Settings::Aimbot::AutoAim::realDistance = currentWeaponSetting.autoAimRealDistance;
}