//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CWeaponPlasmaRifle::FireBullets( CBaseTFCombatWeapon *pWeapon, int cShots, const Vector &vecSrc, const Vector &vecDirShooting, const Vector &vecSpread, float flDistance, int iBulletType, int iTracerFreq ) { CBaseTFPlayer *pPlayer = static_cast< CBaseTFPlayer * >( GetOwner() ); if ( !pPlayer ) return; Vector vecForward; pPlayer->EyeVectors( &vecForward ); Vector vecOrigin = pPlayer->EyePosition(); trace_t tr; Vector vecTracerSrc = pWeapon->GetTracerSrc( (Vector&)vecSrc, (Vector&)vecDirShooting ); // Fire the emp projectile CBasePlasmaProjectile *pPlasma = CBasePlasmaProjectile::Create( vecTracerSrc, vecDirShooting, DMG_ENERGYBEAM, pPlayer ); pPlasma->SetDamage( weapon_plasmarifle_damage.GetFloat() ); pPlasma->m_hOwner = pPlayer; }
//----------------------------------------------------------------------------- // Purpose: Plasma sentrygun's fire //----------------------------------------------------------------------------- void CObjectMannedPlasmagun::Fire( ) { if (m_flNextAttack > gpGlobals->curtime) return; // Because the plasma sentrygun always thinks it has ammo (see below) // we might not have ammo here, in which case we should just abort. if ( !m_nAmmoCount ) return; // Make sure we think soon enough in case of firing... float flNextRecharge = gpGlobals->curtime + (HasPowerup(POWERUP_EMP) ? MANNED_PLASMAGUN_RECHARGE_TIME * 1.5 : MANNED_PLASMAGUN_RECHARGE_TIME); SetNextThink( gpGlobals->curtime + flNextRecharge ); // We have to flush the bone cache because it's possible that only the bone controllers // have changed since the bonecache was generated, and bone controllers aren't checked. InvalidateBoneCache(); QAngle vecAng; Vector vecSrc, vecAim; // Alternate barrels when firing if ( m_bFiringLeft ) { // Aliens permanently fire left barrel because they have no right if ( GetTeamNumber() == TEAM_HUMANS ) { m_bFiringLeft = false; } GetAttachment( m_nBarrelAttachment, vecSrc, vecAng ); SetActivity( ACT_VM_PRIMARYATTACK ); } else { m_bFiringLeft = true; GetAttachment( m_nRightBarrelAttachment, vecSrc, vecAng ); SetActivity( ACT_VM_SECONDARYATTACK ); } // Get the distance to the target AngleVectors( vecAng, &vecAim, 0, 0 ); int damageType = GetAmmoDef()->DamageType( m_nAmmoType ); CBasePlasmaProjectile *pPlasma = CBasePlasmaProjectile::CreatePredicted( vecSrc, vecAim, Vector( 0, 0, 0 ), damageType, GetDriverPlayer() ); if ( pPlasma ) { pPlasma->SetDamage( obj_manned_plasmagun_damage.GetFloat() ); pPlasma->m_hOwner = GetDriverPlayer(); //pPlasma->SetOwnerEntity( this ); pPlasma->SetMaxRange( m_flMaxRange ); if ( obj_manned_plasmagun_radius.GetFloat() ) { pPlasma->SetExplosive( obj_manned_plasmagun_radius.GetFloat() ); } } CSoundParameters params; if ( GetParametersForSound( "ObjectMannedPlasmagun.Fire", params, NULL ) ) { CPASAttenuationFilter filter( this, params.soundlevel ); if ( IsPredicted() ) { filter.UsePredictionRules(); } EmitSound( filter, entindex(), "ObjectMannedPlasmagun.Fire" ); } // SetSentryAnim( TFTURRET_ANIM_FIRE ); DoMuzzleFlash(); --m_nAmmoCount; m_flNextIdleTime = gpGlobals->curtime + MANNED_PLASMAGUN_IDLE_TIME; // If I'm EMPed, slow the firing rate down m_flNextAttack = gpGlobals->curtime + ( HasPowerup(POWERUP_EMP) ? 0.3f : 0.1f ); }