本文整理汇总了C++中CASW_Player::GetCurrentUserCommand方法的典型用法代码示例。如果您正苦于以下问题:C++ CASW_Player::GetCurrentUserCommand方法的具体用法?C++ CASW_Player::GetCurrentUserCommand怎么用?C++ CASW_Player::GetCurrentUserCommand使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CASW_Player
的用法示例。
在下文中一共展示了CASW_Player::GetCurrentUserCommand方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PrimaryAttack
void CASW_Weapon_Sniper_Rifle::PrimaryAttack( void )
{
// If my clip is empty (and I use clips) start reload
if ( UsesClipsForAmmo1() && !m_iClip1 )
{
Reload();
return;
}
CASW_Player *pPlayer = GetCommander();
CASW_Marine *pMarine = GetMarine();
if ( !pMarine )
return;
// MUST call sound before removing a round from the clip of a CMachineGun
WeaponSound(SINGLE);
if (m_iClip1 <= AmmoClickPoint())
BaseClass::WeaponSound( EMPTY );
m_bIsFiring = true;
// tell the marine to tell its weapon to draw the muzzle flash
pMarine->DoMuzzleFlash();
// sets the animation on the weapon model iteself
//SendWeaponAnim( GetPrimaryAttackActivity() );
// sets the animation on the marine holding this weapon
//pMarine->SetAnimation( PLAYER_ATTACK1 );
#ifdef GAME_DLL // check for turning on lag compensation
if (pPlayer && pMarine->IsInhabited())
{
CASW_Lag_Compensation::RequestLagCompensation( pPlayer, pPlayer->GetCurrentUserCommand() );
}
#endif
FireBulletsInfo_t info;
info.m_vecSrc = pMarine->Weapon_ShootPosition( );
if ( pPlayer && pMarine->IsInhabited() )
{
info.m_vecDirShooting = pPlayer->GetAutoaimVectorForMarine(pMarine, GetAutoAimAmount(), GetVerticalAdjustOnlyAutoAimAmount()); // 45 degrees = 0.707106781187
}
else
{
#ifdef CLIENT_DLL
Msg("Error, clientside firing of a weapon that's being controlled by an AI marine\n");
#else
info.m_vecDirShooting = pMarine->GetActualShootTrajectory( info.m_vecSrc );
#endif
}
info.m_iShots = 1;
// Make sure we don't fire more than the amount in the clip
if ( UsesClipsForAmmo1() )
{
info.m_iShots = MIN( info.m_iShots, m_iClip1 );
m_iClip1 -= info.m_iShots;
#ifdef GAME_DLL
CASW_Marine *pMarine = GetMarine();
if (pMarine && m_iClip1 <= 0 && pMarine->GetAmmoCount(m_iPrimaryAmmoType) <= 0 )
{
// check he doesn't have ammo in an ammo bay
CASW_Weapon_Ammo_Bag* pAmmoBag = dynamic_cast<CASW_Weapon_Ammo_Bag*>(pMarine->GetASWWeapon(0));
if (!pAmmoBag)
pAmmoBag = dynamic_cast<CASW_Weapon_Ammo_Bag*>(pMarine->GetASWWeapon(1));
if (!pAmmoBag || !pAmmoBag->CanGiveAmmoToWeapon(this))
pMarine->OnWeaponOutOfAmmo(true);
}
#endif
}
else
{
info.m_iShots = MIN( info.m_iShots, pMarine->GetAmmoCount( m_iPrimaryAmmoType ) );
pMarine->RemoveAmmo( info.m_iShots, m_iPrimaryAmmoType );
}
info.m_flDistance = asw_weapon_max_shooting_distance.GetFloat();
info.m_iAmmoType = m_iPrimaryAmmoType;
info.m_iTracerFreq = 1;
info.m_flDamageForceScale = asw_weapon_force_scale.GetFloat();
info.m_vecSpread = GetBulletSpread();
info.m_flDamage = GetWeaponDamage();
#ifndef CLIENT_DLL
if (asw_debug_marine_damage.GetBool())
Msg("Weapon dmg = %f\n", info.m_flDamage);
info.m_flDamage *= pMarine->GetMarineResource()->OnFired_GetDamageScale();
#endif
int iPenetration = 1;
if ( pMarine->GetDamageBuffEndTime() > gpGlobals->curtime ) // sniper rifle penetrates more targets when marine is in a damage amp
{
iPenetration = 3;
}
pMarine->FirePenetratingBullets( info, iPenetration, 3.5f, 0, true, NULL, false );
// increment shooting stats
#ifndef CLIENT_DLL
//.........这里部分代码省略.........
示例2: PrimaryAttack
void CASW_Weapon_Shotgun::PrimaryAttack( void )
{
// If my clip is empty (and I use clips) start reload
if ( UsesClipsForAmmo1() && !m_iClip1 )
{
Reload();
return;
}
CASW_Player *pPlayer = GetCommander();
CASW_Marine *pMarine = GetMarine();
if (pMarine) // firing from a marine
{
// MUST call sound before removing a round from the clip of a CMachineGun
WeaponSound(SINGLE);
if (m_iClip1 <= AmmoClickPoint())
{
LowAmmoSound();
}
m_bIsFiring = true;
// tell the marine to tell its weapon to draw the muzzle flash
pMarine->DoMuzzleFlash();
// sets the animation on the weapon model iteself
SendWeaponAnim( GetPrimaryAttackActivity() );
#ifdef GAME_DLL // check for turning on lag compensation
if (pPlayer && pMarine->IsInhabited())
{
CASW_Lag_Compensation::RequestLagCompensation( pPlayer, pPlayer->GetCurrentUserCommand() );
}
#endif
Vector vecSrc = pMarine->Weapon_ShootPosition( );
// hull trace out to this shoot position, so we can be sure we're not firing from over an alien's head
trace_t tr;
CTraceFilterSimple tracefilter(pMarine, COLLISION_GROUP_NONE);
Vector vecMarineMiddle(pMarine->GetAbsOrigin());
vecMarineMiddle.z = vecSrc.z;
AI_TraceHull( vecMarineMiddle, vecSrc, Vector( -10, -10, -20 ), Vector( 10, 10, 10 ), MASK_SHOT, &tracefilter, &tr );
vecSrc = tr.endpos;
Vector vecAiming = vec3_origin;
if ( pPlayer && pMarine->IsInhabited() )
{
vecAiming = pPlayer->GetAutoaimVectorForMarine(pMarine, GetAutoAimAmount(), GetVerticalAdjustOnlyAutoAimAmount()); // 45 degrees = 0.707106781187
}
else
{
#ifndef CLIENT_DLL
vecAiming = pMarine->GetActualShootTrajectory( vecSrc );
#endif
}
if (true) // hitscan pellets
{
#ifndef CLIENT_DLL
if (asw_DebugAutoAim.GetBool())
{
NDebugOverlay::Line(vecSrc, vecSrc + vecAiming * asw_weapon_max_shooting_distance.GetFloat(), 64, 0, 64, false, 120.0);
}
#endif
int iPellets = GetNumPellets();
for (int i=0;i<iPellets;i++)
{
FireBulletsInfo_t info( 1, vecSrc, vecAiming, GetAngularBulletSpread(), asw_weapon_max_shooting_distance.GetFloat(), m_iPrimaryAmmoType );
info.m_pAttacker = pMarine;
info.m_iTracerFreq = 1;
info.m_nFlags = FIRE_BULLETS_NO_PIERCING_SPARK | FIRE_BULLETS_HULL | FIRE_BULLETS_ANGULAR_SPREAD;
info.m_flDamage = GetWeaponDamage();
info.m_flDamageForceScale = asw_weapon_force_scale.GetFloat();
#ifndef CLIENT_DLL
if (asw_debug_marine_damage.GetBool())
Msg("Weapon dmg = %f\n", info.m_flDamage);
info.m_flDamage *= pMarine->GetMarineResource()->OnFired_GetDamageScale();
#endif
// shotgun bullets have a base 50% chance of piercing
//float fPiercingChance = 0.5f;
//if (pMarine->GetMarineResource() && pMarine->GetMarineProfile() && pMarine->GetMarineProfile()->GetMarineClass() == MARINE_CLASS_SPECIAL_WEAPONS)
//fPiercingChance += MarineSkills()->GetSkillBasedValueByMarine(pMarine, ASW_MARINE_SKILL_PIERCING);
//pMarine->FirePenetratingBullets(info, 5, fPiercingChance);
//pMarine->FirePenetratingBullets(info, 5, 1.0f, i, false );
pMarine->FirePenetratingBullets(info, 0, 1.0f, i, false );
}
}
else // projectile pellets
{
#ifndef CLIENT_DLL
CShotManipulator Manipulator( vecAiming );
int iPellets = GetNumPellets();
for (int i=0;i<iPellets;i++)
{
// create a pellet at some random spread direction
//.........这里部分代码省略.........
示例3: PrimaryAttack
void CASW_Weapon::PrimaryAttack( void )
{
// If my clip is empty (and I use clips) start reload
if ( UsesClipsForAmmo1() && !m_iClip1 )
{
Reload();
return;
}
CASW_Player *pPlayer = GetCommander();
CASW_Marine *pMarine = GetMarine();
if ( !pMarine )
return;
m_bIsFiring = true;
// MUST call sound before removing a round from the clip of a CMachineGun
WeaponSound(SINGLE);
if (m_iClip1 <= AmmoClickPoint())
{
LowAmmoSound();
}
// tell the marine to tell its weapon to draw the muzzle flash
pMarine->DoMuzzleFlash();
// sets the animation on the weapon model itself
SendWeaponAnim( GetPrimaryAttackActivity() );
// sets the animation on the marine holding this weapon
//pMarine->SetAnimation( PLAYER_ATTACK1 );
#ifdef GAME_DLL // check for turning on lag compensation
if (pPlayer && pMarine->IsInhabited())
{
CASW_Lag_Compensation::RequestLagCompensation( pPlayer, pPlayer->GetCurrentUserCommand() );
}
#endif
FireBulletsInfo_t info;
info.m_vecSrc = pMarine->Weapon_ShootPosition( );
if ( pPlayer && pMarine->IsInhabited() )
{
info.m_vecDirShooting = pPlayer->GetAutoaimVectorForMarine(pMarine, GetAutoAimAmount(), GetVerticalAdjustOnlyAutoAimAmount()); // 45 degrees = 0.707106781187
}
else
{
#ifdef CLIENT_DLL
Msg("Error, clientside firing of a weapon that's being controlled by an AI marine\n");
#else
info.m_vecDirShooting = pMarine->GetActualShootTrajectory( info.m_vecSrc );
#endif
}
// To make the firing framerate independent, we may have to fire more than one bullet here on low-framerate systems,
// especially if the weapon we're firing has a really fast rate of fire.
info.m_iShots = 0;
float fireRate = GetFireRate();
while ( m_flNextPrimaryAttack <= gpGlobals->curtime )
{
m_flNextPrimaryAttack = m_flNextPrimaryAttack + fireRate;
info.m_iShots++;
if ( !fireRate )
break;
}
// Make sure we don't fire more than the amount in the clip
if ( UsesClipsForAmmo1() )
{
info.m_iShots = MIN( info.m_iShots, m_iClip1 );
m_iClip1 -= info.m_iShots;
#ifdef GAME_DLL
CASW_Marine *pMarine = GetMarine();
if (pMarine && m_iClip1 <= 0 && pMarine->GetAmmoCount(m_iPrimaryAmmoType) <= 0 )
{
// check he doesn't have ammo in an ammo bay
CASW_Weapon_Ammo_Bag* pAmmoBag = dynamic_cast<CASW_Weapon_Ammo_Bag*>(pMarine->GetASWWeapon(0));
if (!pAmmoBag)
pAmmoBag = dynamic_cast<CASW_Weapon_Ammo_Bag*>(pMarine->GetASWWeapon(1));
if (!pAmmoBag || !pAmmoBag->CanGiveAmmoToWeapon(this))
pMarine->OnWeaponOutOfAmmo(true);
}
#endif
}
else
{
info.m_iShots = MIN( info.m_iShots, pMarine->GetAmmoCount( m_iPrimaryAmmoType ) );
pMarine->RemoveAmmo( info.m_iShots, m_iPrimaryAmmoType );
}
info.m_flDistance = asw_weapon_max_shooting_distance.GetFloat();
info.m_iAmmoType = m_iPrimaryAmmoType;
info.m_iTracerFreq = 1; // asw tracer test everytime
info.m_flDamageForceScale = asw_weapon_force_scale.GetFloat();
info.m_vecSpread = pMarine->GetActiveWeapon()->GetBulletSpread();
info.m_flDamage = GetWeaponDamage();
#ifndef CLIENT_DLL
if (asw_debug_marine_damage.GetBool())
//.........这里部分代码省略.........
示例4: PrimaryAttack
void CASW_Weapon_Pistol::PrimaryAttack( void )
{
// If my clip is empty (and I use clips) start reload
if ( UsesClipsForAmmo1() && !m_iClip1 )
{
Reload();
return;
}
CASW_Player *pPlayer = GetCommander();
CASW_Marine *pMarine = GetMarine();
if (pMarine) // firing from a marine
{
// MUST call sound before removing a round from the clip of a CMachineGun
WeaponSound(SINGLE);
if (m_iClip1 <= AmmoClickPoint())
BaseClass::WeaponSound( EMPTY );
m_bIsFiring = true;
// tell the marine to tell its weapon to draw the muzzle flash
pMarine->DoMuzzleFlash();
// sets the animation on the weapon model iteself
SendWeaponAnim( GetPrimaryAttackActivity() );
// sets the animation on the marine holding this weapon
//pMarine->SetAnimation( PLAYER_ATTACK1 );
#ifdef GAME_DLL // check for turning on lag compensation
if (pPlayer && pMarine->IsInhabited())
{
CASW_Lag_Compensation::RequestLagCompensation( pPlayer, pPlayer->GetCurrentUserCommand() );
}
#endif
// if (asw_pistol_hitscan.GetBool())
if (true)
{
FireBulletsInfo_t info;
info.m_vecSrc = pMarine->Weapon_ShootPosition( );
if ( pPlayer && pMarine->IsInhabited() )
{
info.m_vecDirShooting = pPlayer->GetAutoaimVectorForMarine(pMarine, GetAutoAimAmount(), GetVerticalAdjustOnlyAutoAimAmount()); // 45 degrees = 0.707106781187
}
else
{
#ifdef CLIENT_DLL
Msg("Error, clientside firing of a weapon that's being controlled by an AI marine\n");
#else
info.m_vecDirShooting = pMarine->GetActualShootTrajectory( info.m_vecSrc );
#endif
}
info.m_iShots = 1;
// Make sure we don't fire more than the amount in the clip
if ( UsesClipsForAmmo1() )
{
info.m_iShots = MIN( info.m_iShots, m_iClip1 );
m_iClip1 -= info.m_iShots;
#ifdef GAME_DLL
CASW_Marine *pMarine = GetMarine();
if (pMarine && m_iClip1 <= 0 && pMarine->GetAmmoCount(m_iPrimaryAmmoType) <= 0 )
{
pMarine->OnWeaponOutOfAmmo(true);
}
#endif
}
else
{
info.m_iShots = MIN( info.m_iShots, pMarine->GetAmmoCount( m_iPrimaryAmmoType ) );
pMarine->RemoveAmmo( info.m_iShots, m_iPrimaryAmmoType );
}
info.m_flDistance = asw_weapon_max_shooting_distance.GetFloat();
info.m_iAmmoType = m_iPrimaryAmmoType;
info.m_iTracerFreq = 1;
info.m_flDamageForceScale = asw_weapon_force_scale.GetFloat();
info.m_vecSpread = GetBulletSpread();
info.m_flDamage = GetWeaponDamage();
#ifndef CLIENT_DLL
if (asw_debug_marine_damage.GetBool())
Msg("Weapon dmg = %f\n", info.m_flDamage);
info.m_flDamage *= pMarine->OnFired_GetDamageScale();
#endif
pMarine->FireBullets( info );
//FireBulletsInfo_t info( 1, vecSrc, vecAiming, GetBulletSpread(), MAX_TRACE_LENGTH, m_iPrimaryAmmoType );
//info.m_pAttacker = pMarine;
// Fire the bullets, and force the first shot to be perfectly accuracy
//pMarine->FireBullets( info );
}
else // projectile pistol
{
//.........这里部分代码省略.........
示例5: SecondaryAttack
void CASW_Weapon_Assault_Shotgun::SecondaryAttack()
{
// Only the player fires this way so we can cast
CASW_Player *pPlayer = GetCommander();
if (!pPlayer)
return;
CASW_Marine *pMarine = GetMarine();
if (!pMarine)
return;
//Must have ammo
bool bUsesSecondary = UsesSecondaryAmmo();
bool bUsesClips = UsesClipsForAmmo2();
int iAmmoCount = pMarine->GetAmmoCount(m_iSecondaryAmmoType);
bool bInWater = ( pMarine->GetWaterLevel() == 3 );
if ( (bUsesSecondary &&
( ( bUsesClips && m_iClip2 <= 0) ||
( !bUsesClips && iAmmoCount<=0 )
) )
|| bInWater || m_bInReload )
{
SendWeaponAnim( ACT_VM_DRYFIRE );
BaseClass::WeaponSound( EMPTY );
m_flNextSecondaryAttack = gpGlobals->curtime + 0.5f;
return;
}
BaseClass::WeaponSound( SPECIAL1 );
#ifndef CLIENT_DLL
pMarine->GetMarineSpeech()->Chatter(CHATTER_GRENADE);
Vector vecSrc = pMarine->Weapon_ShootPosition();
Vector vecThrow;
// check for turning on lag compensation
if (pPlayer && pMarine->IsInhabited())
{
CASW_Lag_Compensation::RequestLagCompensation( pPlayer, pPlayer->GetCurrentUserCommand() );
}
vecThrow = UTIL_LaunchVector(vecSrc, pPlayer->GetCrosshairTracePos(), asw_vindicator_grenade_gravity.GetFloat()) * 8.0f * asw_vindicator_grenade_velocity.GetFloat();
QAngle angAiming = pPlayer->EyeAnglesWithCursorRoll();
float fGrenadeDamage = MarineSkills()->GetSkillBasedValueByMarine(pMarine, ASW_MARINE_SKILL_GRENADES, ASW_MARINE_SUBSKILL_GRENADE_INCENDIARY_DMG);
float fGrenadeRadius = MarineSkills()->GetSkillBasedValueByMarine(pMarine, ASW_MARINE_SKILL_GRENADES, ASW_MARINE_SUBSKILL_GRENADE_RADIUS);
if (asw_debug_marine_damage.GetBool())
{
Msg("Grenade damage = %f radius = %f\n", fGrenadeDamage, fGrenadeRadius);
}
// check the grenade fits where we want to spawn it
Ray_t ray;
trace_t pm;
ray.Init( pMarine->WorldSpaceCenter(), vecSrc, -Vector(4,4,4), Vector(4,4,4) );
UTIL_TraceRay( ray, MASK_SOLID, pMarine, COLLISION_GROUP_PROJECTILE, &pm );
if (pm.fraction < 1.0f)
vecSrc = pm.endpos;
CASW_Grenade_Vindicator::Vindicator_Grenade_Create(
fGrenadeDamage,
fGrenadeRadius,
vecSrc, angAiming, vecThrow, AngularImpulse(0,0,0), pMarine, this );
pMarine->OnWeaponFired( this, 1, true );
#endif
SendWeaponAnim( GetPrimaryAttackActivity() );
pMarine->DoAnimationEvent( PLAYERANIMEVENT_FIRE_GUN_PRIMARY );
// Decrease ammo
if ( bUsesClips )
{
m_iClip2 -= 1;
}
else
{
pMarine->RemoveAmmo( 1, m_iSecondaryAmmoType );
}
#ifndef CLIENT_DLL
ASWFailAdvice()->OnMarineUsedSecondary();
CEffectData data;
data.m_vOrigin = GetAbsOrigin();
//data.m_vNormal = dir;
//data.m_flScale = (float)amount;
CPASFilter filter( data.m_vOrigin );
filter.SetIgnorePredictionCull(true);
DispatchParticleEffect( "muzzleflash_grenadelauncher_main", PATTACH_POINT_FOLLOW, this, "muzzle", false, -1, &filter );
#endif
// Can shoot again immediately
m_flNextPrimaryAttack = gpGlobals->curtime + 0.5f;
// Can blow up after a short delay (so have time to release mouse button)
m_flNextSecondaryAttack = gpGlobals->curtime + 1.0f;
}
示例6: PrimaryAttack
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CASW_Weapon_Chainsaw::PrimaryAttack( void )
{
// If my clip is empty (and I use clips) start reload
//if ( UsesClipsForAmmo1() && !m_iClip1 )
//{
//Reload();
//return;
//}
CASW_Player *pPlayer = GetCommander();
CASW_Marine *pMarine = GetMarine();
if ( !pMarine || !pMarine->IsAlive())
{
EndAttack();
return;
}
// don't fire underwater
if ( pMarine->GetWaterLevel() == 3 )
{
if ( m_fireState != FIRE_OFF || m_hBeam )
{
EndAttack();
}
else
{
WeaponSound( EMPTY );
}
m_flNextPrimaryAttack = gpGlobals->curtime + GetWeaponInfo()->m_flFireRate;
m_flNextSecondaryAttack = gpGlobals->curtime + GetWeaponInfo()->m_flFireRate;
return;
}
#ifdef GAME_DLL // check for turning on lag compensation
if (pPlayer && pMarine->IsInhabited())
{
CASW_Lag_Compensation::RequestLagCompensation( pPlayer, pPlayer->GetCurrentUserCommand() );
}
#endif
Vector vecSrc = pMarine->Weapon_ShootPosition( );
Vector vecAiming = vec3_origin;
if ( pPlayer && pMarine->IsInhabited() )
{
vecAiming = pPlayer->GetAutoaimVectorForMarine(pMarine, GetAutoAimAmount(), GetVerticalAdjustOnlyAutoAimAmount()); // 45 degrees = 0.707106781187
}
else
{
#ifndef CLIENT_DLL
vecAiming = pMarine->GetActualShootTrajectory( vecSrc );
#endif
}
// make vecaiming go down at 45 degrees
vecAiming.z = 0;
VectorNormalize(vecAiming);
vecAiming.z = -1.0f;
VectorNormalize(vecAiming);
switch( m_fireState )
{
case FIRE_OFF:
{
//if ( !HasAmmo() )
//{
//m_flNextPrimaryAttack = gpGlobals->curtime + 0.25;
//m_flNextSecondaryAttack = gpGlobals->curtime + 0.25;
//WeaponSound( EMPTY );
//return;
//}
m_flAmmoUseTime = gpGlobals->curtime;// start using ammo ASAP.
SendWeaponAnim( ACT_VM_PRIMARYATTACK );
m_flShakeTime = 0;
m_flStartFireTime = gpGlobals->curtime;
SetWeaponIdleTime( gpGlobals->curtime + 0.1 );
m_flDmgTime = gpGlobals->curtime + ASW_CHAINSAW_PULSE_INTERVAL;
SetFiringState(FIRE_STARTUP);
}
break;
case FIRE_STARTUP:
{
Fire( vecSrc, vecAiming );
#ifndef CLIENT_DLL
pMarine->OnWeaponFired( this, 1 );
#endif
if ( gpGlobals->curtime >= ( m_flStartFireTime + ASW_CHAINSAW_CHARGE_UP_TIME ) )
{
//EmitSound( "ASW_Chainsaw.AttackLoop" );
//.........这里部分代码省略.........