本文整理汇总了C++中CBaseCombatWeapon类的典型用法代码示例。如果您正苦于以下问题:C++ CBaseCombatWeapon类的具体用法?C++ CBaseCombatWeapon怎么用?C++ CBaseCombatWeapon使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CBaseCombatWeapon类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetOwningWeapon
void CBaseViewModel::CalcIronsights( Vector &pos, QAngle &ang )
{
CBaseCombatWeapon *pWeapon = GetOwningWeapon();
if (!pWeapon)
return;
//get delta time for interpolation
float delta = (gpGlobals->curtime - pWeapon->m_flIronsightedTime) * 2.5f; //modify this value to adjust how fast the interpolation is
float exp = (pWeapon->IsIronsighted()) ?
(delta > 1.0f) ? 1.0f : delta : //normal blending
(delta > 1.0f) ? 0.0f : 1.0f - delta; //reverse interpolation
if (exp <= 0.001f) //fully not ironsighted; save performance
return;
Vector newPos = pos;
QAngle newAng = ang;
Vector vForward, vRight, vUp, vOffset;
AngleVectors(newAng, &vForward, &vRight, &vUp);
vOffset = pWeapon->GetIronsightPositionOffset();
newPos += vForward * vOffset.x;
newPos += vRight * vOffset.y;
newPos += vUp * vOffset.z;
newAng += pWeapon->GetIronsightAngleOffset();
//fov is handled by CBaseCombatWeapon
pos += (newPos - pos) * exp;
ang += (newAng - ang) * exp;
}
示例2: 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" );
}
}
}
}
示例3: PlayerUse
//-----------------------------------------------------------------------------
// Purpose: Called every usercmd by the player PreThink
//-----------------------------------------------------------------------------
void CBasePlayer::ItemPreFrame()
{
// Handle use events
PlayerUse();
CBaseCombatWeapon *pActive = GetActiveWeapon();
// Allow all the holstered weapons to update
for ( int i = 0; i < WeaponCount(); ++i )
{
CBaseCombatWeapon *pWeapon = GetWeapon( i );
if ( pWeapon == NULL )
continue;
if ( pActive == pWeapon )
continue;
pWeapon->ItemHolsterFrame();
}
if ( gpGlobals->curtime < m_flNextAttack )
return;
if (!pActive)
return;
#if defined( CLIENT_DLL )
// Not predicting this weapon
if ( !pActive->IsPredicted() )
return;
#endif
pActive->ItemPreFrame();
}
示例4: CreateEntityByName
CBaseEntity * CEntHost::GiveNamedItem( const char * szName, int iSubType, bool removeIfNotCarried )
{
// If I already own this type don't create one
if ( GetHost()->Weapon_OwnsThisType( szName, iSubType ) )
return NULL;
CBaseEntity *pEntity = CreateEntityByName( szName );
if ( !pEntity ) {
Msg( "NULL Ent in GiveNamedItem!\n" );
return NULL;
}
pEntity->SetLocalOrigin( GetLocalOrigin() );
pEntity->AddSpawnFlags( SF_NORESPAWN );
CBaseCombatWeapon *pWeapon = dynamic_cast<CBaseCombatWeapon *>(pEntity);
DispatchSpawn( pEntity );
if ( pWeapon ) {
pWeapon->SetSubType( iSubType );
GetHost()->Weapon_Equip( pWeapon );
}
else {
if ( pEntity && !(pEntity->IsMarkedForDeletion()) ) {
pEntity->Touch( GetHost() );
}
}
return pEntity;
}
示例5: ResupplyAmmo
//-----------------------------------------------------------------------------
// Purpose: Called on each respawn
//-----------------------------------------------------------------------------
void CPlayerClass::RespawnClass( void )
{
ResupplyAmmo( 100.0f, RESUPPLY_ALL_FROM_STATION );
GainedNewTechnology( NULL );
SetMaxHealth( GetMaxHealthCVarValue() );
SetMaxSpeed( GetMaxSpeed() );
CheckDeterioratingObjects();
SetupSizeData();
// Refill the clips of all my weapons
for (int i = 0; i < MAX_WEAPONS; i++)
{
CBaseCombatWeapon *pWeapon = m_pPlayer->GetWeapon(i);
if ( pWeapon )
{
if ( pWeapon->UsesClipsForAmmo1() )
{
pWeapon->m_iClip1 = pWeapon->GetDefaultClip1();
}
if ( pWeapon->UsesClipsForAmmo2() )
{
pWeapon->m_iClip2 = pWeapon->GetDefaultClip2();
}
}
}
}
示例6: while
int CBaseCombatWeapon::GetAvailableWeaponsInBox( CBaseCombatWeapon **pList, int listMax, const Vector &mins, const Vector &maxs )
{
// linear search all weapons
int count = 0;
int index = g_WeaponList.m_list.Head();
while ( index != g_WeaponList.m_list.InvalidIndex() )
{
CBaseCombatWeapon *pWeapon = g_WeaponList.m_list[index];
// skip any held weapon
if ( !pWeapon->GetOwner() )
{
// restrict to mins/maxs
if ( IsPointInBox( pWeapon->GetAbsOrigin(), mins, maxs ) )
{
if ( count < listMax )
{
pList[count] = pWeapon;
count++;
}
}
}
index = g_WeaponList.m_list.Next( index );
}
return count;
}
示例7: Weapon_OwnsThisType
void CHL2MP_Player::Weapon_Drop( CBaseCombatWeapon *pWeapon, const Vector *pvecTarget, const Vector *pVelocity )
{
//Drop a grenade if it's primed.
if ( GetActiveWeapon() )
{
CBaseCombatWeapon *pGrenade = Weapon_OwnsThisType("weapon_frag");
if ( GetActiveWeapon() == pGrenade )
{
if ( ( m_nButtons & IN_ATTACK ) || (m_nButtons & IN_ATTACK2) )
{
DropPrimedFragGrenade( this, pGrenade );
return;
}
//DHL - Skillet
else
{
pGrenade->Drop( *pVelocity );
return;
}
}
}
BaseClass::Weapon_Drop( pWeapon, pvecTarget, pVelocity );
}
示例8: CreateEntityByName
void CJaS_Marine_Jack::Spawn()
{
CASW_Marine_Resource *pResource = dynamic_cast<CASW_Marine_Resource *>( CreateEntityByName( "asw_marine_resource" ) );
pResource->SetProfileIndex( 6 );
pResource->SetMarineEntity( this );
SetMarineResource( pResource );
pResource->Spawn();
m_pProfileOverride = pResource->GetProfile();
SelectModelFromProfile();
SetModelFromProfile();
CBaseCombatWeapon *pWeapon = dynamic_cast<CBaseCombatWeapon *>( CreateEntityByName( "asw_weapon_sniper_rifle" ) );
if ( pWeapon )
{
pWeapon->Spawn();
pWeapon->GiveDefaultAmmo();
pWeapon->m_iClip1 = 9999;
GiveAmmo(9999, pWeapon->GetPrimaryAmmoType());
Weapon_Equip_In_Index( pWeapon, 0 );
Weapon_Switch( pWeapon );
}
m_bConstantSlowHeal = true;
m_hSquadFormation = static_cast<CASW_SquadFormation *>( CreateEntityByName( "asw_squadformation" ) );
m_hSquadFormation->Leader( this );
SetRenderColor( 0x99, 0x40, 0x40 );
BaseClass::Spawn();
}
示例9: SetCollisionBounds
void CHL2MP_Player::PostThink( void )
{
BaseClass::PostThink();
if ( GetFlags() & FL_DUCKING )
{
SetCollisionBounds( VEC_CROUCH_TRACE_MIN, VEC_CROUCH_TRACE_MAX );
}
m_PlayerAnimState.Update();
// Store the eye angles pitch so the client can compute its animation state correctly.
m_angEyeAngles = EyeAngles();
QAngle angles = GetLocalAngles();
angles[PITCH] = 0;
SetLocalAngles( angles );
if (!IsDead())
{
if (m_afButtonReleased & IN_KICK && m_flNextKickAttack < gpGlobals->curtime /* && m_flNextKickAttack < gpGlobals->curtime && !m_bIsKicking*/)
{
KickAttack();
m_bIsKicking = true;
}
}
CBaseCombatWeapon *pWeapon = this->GetActiveWeapon();
if (pWeapon != NULL)
{
if (m_afButtonPressed & IN_IRONSIGHT)
{
pWeapon->EnableIronsights();
}
else if (m_afButtonReleased & IN_IRONSIGHT)
{
pWeapon->DisableIronsights();
}
}
if (!IsDead())
{
if (m_flNextKickAttack < gpGlobals->curtime)
{
m_bIsKicking = false;
CBaseViewModel *vm = GetViewModel(1);
if (vm)
{
int idealSequence = vm->SelectWeightedSequence(ACT_VM_IDLE);
if (idealSequence >= 0)
{
vm->SendViewModelMatchingSequence(idealSequence);
}
}
}
}
}
示例10: CBaseCombatWeapon___tostring
static int CBaseCombatWeapon___tostring (lua_State *L) {
CBaseCombatWeapon *pWeapon = lua_toweapon(L, 1);
if (pWeapon == NULL)
lua_pushstring(L, "NULL");
else
lua_pushfstring(L, "CBaseCombatWeapon: %d %s", pWeapon->entindex(), pWeapon->GetClassname());
return 1;
}
示例11: DissolveThink
//-----------------------------------------------------------------------------
// Purpose: Dissolve all weapons within our volume
//-----------------------------------------------------------------------------
void CTriggerWeaponDissolve::DissolveThink( void )
{
int numWeapons = m_pWeapons.Count();
// Dissolve all the items within the volume
for ( int i = 0; i < numWeapons; i++ )
{
CBaseCombatWeapon *pWeapon = m_pWeapons[i];
Vector vecConduit = GetConduitPoint( pWeapon );
// The physcannon upgrades when this happens
if ( FClassnameIs( pWeapon, "weapon_physcannon" ) )
{
// This must be the last weapon for us to care
if ( numWeapons > 1 )
continue;
//FIXME: Make them do this on a stagger!
// All conduits send power to the weapon
for ( int i = 0; i < m_pConduitPoints.Count(); i++ )
{
CreateBeam( m_pConduitPoints[i]->GetAbsOrigin(), pWeapon, 4.0f );
}
PhysCannonBeginUpgrade( pWeapon );
m_OnChargingPhyscannon.FireOutput( this, this );
EmitSound( "WeaponDissolve.Beam" );
// We're done
m_pWeapons.Purge();
m_pConduitPoints.Purge();
SetContextThink( NULL, 0, s_pDissolveThinkContext );
return;
}
// Randomly dissolve them all
float flLifetime = random->RandomFloat( 2.5f, 4.0f );
CreateBeam( vecConduit, pWeapon, flLifetime );
pWeapon->Dissolve( NULL, gpGlobals->curtime + ( 3.0f - flLifetime ), false );
m_OnDissolveWeapon.FireOutput( this, this );
CPASAttenuationFilter filter( pWeapon );
EmitSound( filter, pWeapon->entindex(), "WeaponDissolve.Dissolve" );
// Beam looping sound
EmitSound( "WeaponDissolve.Beam" );
m_pWeapons.Remove( i );
SetContextThink( &CTriggerWeaponDissolve::DissolveThink, gpGlobals->curtime + random->RandomFloat( 0.5f, 1.5f ), s_pDissolveThinkContext );
return;
}
SetContextThink( &CTriggerWeaponDissolve::DissolveThink, gpGlobals->curtime + 0.1f, s_pDissolveThinkContext );
}
示例12: switch
//-----------------------------------------------------------------------------
// Purpose:
// Input : event -
//-----------------------------------------------------------------------------
void CPortalPlayerAnimState::DoAnimationEvent( PlayerAnimEvent_t event, int nData )
{
Activity iWeaponActivity = ACT_INVALID;
switch( event )
{
case PLAYERANIMEVENT_ATTACK_PRIMARY:
case PLAYERANIMEVENT_ATTACK_SECONDARY:
{
CPortal_Player *pPlayer = GetPortalPlayer();
if ( !pPlayer )
return;
CWeaponPortalBase *pWpn = pPlayer->GetActivePortalWeapon();
if ( pWpn )
{
// Weapon primary fire.
if ( GetBasePlayer()->GetFlags() & FL_DUCKING )
{
RestartGesture( GESTURE_SLOT_ATTACK_AND_RELOAD, ACT_MP_ATTACK_CROUCH_PRIMARYFIRE );
}
else
{
RestartGesture( GESTURE_SLOT_ATTACK_AND_RELOAD, ACT_MP_ATTACK_STAND_PRIMARYFIRE );
}
iWeaponActivity = ACT_VM_PRIMARYATTACK;
}
else // unarmed player
{
}
break;
}
default:
{
BaseClass::DoAnimationEvent( event, nData );
break;
}
}
#ifdef CLIENT_DLL
// Make the weapon play the animation as well
if ( iWeaponActivity != ACT_INVALID )
{
CBaseCombatWeapon *pWeapon = GetPortalPlayer()->GetActiveWeapon();
if ( pWeapon )
{
pWeapon->SendWeaponAnim( iWeaponActivity );
}
}
#endif
}
示例13: defined
void CBaseViewModel::CalcViewModelView( CBasePlayer *owner, const Vector& eyePosition, const QAngle& eyeAngles )
{
// UNDONE: Calc this on the server? Disabled for now as it seems unnecessary to have this info on the server
#if defined( CLIENT_DLL )
QAngle vmangoriginal = eyeAngles;
QAngle vmangles = eyeAngles;
Vector vmorigin = eyePosition;
Vector vecRight;
Vector vecUp;
Vector vecForward;
AngleVectors( vmangoriginal, &vecForward, &vecRight, &vecUp );
//Vector vecOffset = Vector( viewmodel_offset_x.GetFloat(), viewmodel_offset_y.GetFloat(), viewmodel_offset_z.GetFloat() );
vmorigin += (vecForward * viewmodel_offset_y.GetFloat()) + (vecUp * viewmodel_offset_z.GetFloat()) + (vecRight * viewmodel_offset_x.GetFloat());
// TrackIR
if ( IsHeadTrackingEnabled() )
{
vmorigin = owner->EyePosition();
VectorAngles( owner->GetAutoaimVector( AUTOAIM_5DEGREES ), vmangoriginal );
vmangles = vmangoriginal;
}
// TrackIR
CBaseCombatWeapon *pWeapon = m_hWeapon.Get();
//Allow weapon lagging
if ( pWeapon != NULL )
{
#if defined( CLIENT_DLL )
if ( !prediction->InPrediction() )
#endif
{
// add weapon-specific bob
pWeapon->AddViewmodelBob( this, vmorigin, vmangles );
}
}
// Add model-specific bob even if no weapon associated (for head bob for off hand models)
AddViewModelBob( owner, vmorigin, vmangles );
// Add lag
CalcViewModelLag( vmorigin, vmangles, vmangoriginal );
#if defined( CLIENT_DLL )
if ( !prediction->InPrediction() )
{
// Let the viewmodel shake at about 10% of the amplitude of the player's view
ACTIVE_SPLITSCREEN_PLAYER_GUARD_ENT( GetOwner() );
GetViewEffects()->ApplyShake( vmorigin, vmangles, 0.1 );
}
#endif
CalcIronsights( vmorigin, vmangles );
SetLocalOrigin( vmorigin );
SetLocalAngles( vmangles );
#endif
}
示例14: RestartGesture
void CTFPlayerAnimState::RestartGesture( int iGestureSlot, Activity iGestureActivity, bool bAutoKill )
{
CBaseCombatWeapon *pWeapon = m_pTFPlayer->GetActiveWeapon();
if ( pWeapon )
{
iGestureActivity = pWeapon->GetItem()->GetActivityOverride( m_pTFPlayer->GetTeamNumber(), iGestureActivity );
}
BaseClass::RestartGesture( iGestureSlot, iGestureActivity, bAutoKill );
}
示例15: ShouldFlipViewModel
inline bool C_BaseViewModel::ShouldFlipViewModel()
{
// If cl_righthand is set, then we want them all right-handed.
CBaseCombatWeapon *pWeapon = m_hWeapon.Get();
if (pWeapon)
{
const FileWeaponInfo_t *pInfo = &pWeapon->GetWpnData();
return pInfo->m_bAllowFlipping && pInfo->m_bBuiltRightHanded != cl_righthand.GetBool();
}
return false;
}