//----------------------------------------------------------------------------- // Purpose: // Input : *pSwitchingTo - // Output : Returns true on success, false on failure. //----------------------------------------------------------------------------- bool CWeaponGaussGun::Holster( CBaseCombatWeapon *pSwitchingTo ) { StopChargeSound(); m_bCharging = false; m_bChargeIndicated = false; return BaseClass::Holster(pSwitchingTo); }
//----------------------------------------------------------------------------- // Purpose: // Input : *pSwitchingTo - // Output : Returns true on success, false on failure. //----------------------------------------------------------------------------- bool CWeaponGauss::Holster( CBaseCombatWeapon *pSwitchingTo ) { StopChargeSound(); if (m_bCharging == true ){ ChargedFire(); ChargedFireFirstBeam(); } m_bCharging = false; m_bChargeIndicated = false; if ( m_sndCharge != NULL ) { (CSoundEnvelopeController::GetController()).SoundFadeOut( m_sndCharge, 0.1f ); } m_sndCharge = NULL; StopChargeSound(); return BaseClass::Holster( pSwitchingTo ); }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CASW_PropJeep::ExitVehicle( int iRole ) { HeadlightTurnOff(); BaseClass::ExitVehicle(iRole); //If the player has exited, stop charging StopChargeSound(); m_bCannonCharging = false; // Remember when we last saw the player m_flPlayerExitedTime = gpGlobals->curtime; m_flLastSawPlayerAt = gpGlobals->curtime; }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CWeaponGaussGun::ChargedFire() { if ( InGameRules()->IsMultiplayer() ) { } CBasePlayer *pOwner = ToBasePlayer( GetOwner() ); if ( !pOwner ) return; bool penetrated = false; //Play shock sounds WeaponSound( SINGLE ); WeaponSound( SPECIAL2 ); SendWeaponAnim( ACT_VM_SECONDARYATTACK ); StopChargeSound(); m_bCharging = false; m_bChargeIndicated = false; m_flNextPrimaryAttack = gpGlobals->curtime + 0.2f; m_flNextSecondaryAttack = gpGlobals->curtime + 0.5f; //Shoot a shot straight out Vector startPos= pOwner->Weapon_ShootPosition(); Vector aimDir = pOwner->GetAutoaimVector( AUTOAIM_5DEGREES ); Vector endPos = startPos + ( aimDir * MAX_TRACE_LENGTH ); trace_t tr; UTIL_TraceLine( startPos, endPos, MASK_SHOT, pOwner, COLLISION_GROUP_NONE, &tr ); #ifndef CLIENT_DLL ClearMultiDamage(); //Find how much damage to do float flChargeAmount = ( gpGlobals->curtime - m_flChargeStartTime ) / MAX_GAUSS_CHARGE_TIME; //Clamp this if ( flChargeAmount > 1.0f ) flChargeAmount = 1.0f; //Determine the damage amount float flDamage = sk_plr_dmg_gauss.GetFloat() + ( ( sk_plr_max_dmg_gauss.GetFloat() - sk_plr_dmg_gauss.GetFloat() ) * flChargeAmount ); #endif CBaseEntity *pHit = tr.m_pEnt; if ( tr.DidHitWorld() ) { //Try wall penetration UTIL_ImpactTrace( &tr, GetAmmoDef()->DamageType(m_iPrimaryAmmoType), "ImpactGauss" ); UTIL_DecalTrace( &tr, "RedGlowFade" ); CPVSFilter filter( tr.endpos ); te->GaussExplosion( filter, 0.0f, tr.endpos, tr.plane.normal, 0 ); Vector testPos = tr.endpos + ( aimDir * 48.0f ); UTIL_TraceLine( testPos, tr.endpos, MASK_SHOT, pOwner, COLLISION_GROUP_NONE, &tr ); if ( tr.allsolid == false ) { UTIL_DecalTrace( &tr, "RedGlowFade" ); penetrated = true; } } #ifndef CLIENT_DLL else if ( pHit != NULL ) { CTakeDamageInfo dmgInfo( this, pOwner, flDamage, DMG_SHOCK | DMG_DISSOLVE ); CalculateBulletDamageForce( &dmgInfo, m_iPrimaryAmmoType, aimDir, tr.endpos ); //Do direct damage to anything in our path pHit->DispatchTraceAttack( dmgInfo, aimDir, &tr ); } ApplyMultiDamage(); #endif UTIL_ImpactTrace( &tr, GetAmmoDef()->DamageType(m_iPrimaryAmmoType), "ImpactGauss" ); QAngle viewPunch; viewPunch.x = random->RandomFloat( -4.0f, -8.0f ); viewPunch.y = random->RandomFloat( -0.25f, 0.25f ); viewPunch.z = 0; pOwner->ViewPunch( viewPunch ); DrawBeam( startPos, tr.endpos, 25, true ); #ifndef CLIENT_DLL Vector recoilForce = pOwner->BodyDirection2D() * -( flDamage * 10.0f ); recoilForce[2] += 300.0f;//128 pOwner->ApplyAbsVelocityImpulse( recoilForce ); #endif CPVSFilter filter( tr.endpos ); te->GaussExplosion( filter, 0.0f, tr.endpos, tr.plane.normal, 0 ); #ifndef CLIENT_DLL if ( penetrated == true ) RadiusDamage( CTakeDamageInfo( this, this, flDamage, DMG_SHOCK ), tr.endpos, 200.0f, CLASS_NONE, NULL ); // Register a muzzleflash for the AI pOwner->SetMuzzleFlashTime( gpGlobals->curtime + 0.5 ); #endif }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CASW_PropJeep::FireChargedCannon( void ) { bool penetrated = false; m_bCannonCharging = false; m_flCannonTime = gpGlobals->curtime + 0.5f; StopChargeSound(); CPASAttenuationFilter sndFilter( this, "PropJeep.FireChargedCannon" ); EmitSound( sndFilter, entindex(), "PropJeep.FireChargedCannon" ); //Find the direction the gun is pointing in Vector aimDir; GetCannonAim( &aimDir ); Vector endPos = m_vecGunOrigin + ( aimDir * MAX_TRACE_LENGTH ); //Shoot a shot straight out trace_t tr; UTIL_TraceLine( m_vecGunOrigin, endPos, MASK_SHOT, this, COLLISION_GROUP_NONE, &tr ); ClearMultiDamage(); //Find how much damage to do float flChargeAmount = ( gpGlobals->curtime - m_flCannonChargeStartTime ) / MAX_GAUSS_CHARGE_TIME; //Clamp this if ( flChargeAmount > 1.0f ) { flChargeAmount = 1.0f; } //Determine the damage amount //FIXME: Use ConVars! float flDamage = 15 + ( ( 250 - 15 ) * flChargeAmount ); CBaseEntity *pHit = tr.m_pEnt; //Look for wall penetration if ( tr.DidHitWorld() && !(tr.surface.flags & SURF_SKY) ) { //Try wall penetration UTIL_ImpactTrace( &tr, m_nBulletType, "ImpactJeep" ); UTIL_DecalTrace( &tr, "RedGlowFade" ); CPVSFilter filter( tr.endpos ); te->GaussExplosion( filter, 0.0f, tr.endpos, tr.plane.normal, 0 ); Vector testPos = tr.endpos + ( aimDir * 48.0f ); UTIL_TraceLine( testPos, tr.endpos, MASK_SHOT, GetDriver(), COLLISION_GROUP_NONE, &tr ); if ( tr.allsolid == false ) { UTIL_DecalTrace( &tr, "RedGlowFade" ); penetrated = true; } } else if ( pHit != NULL ) { CTakeDamageInfo dmgInfo( this, GetDriver(), flDamage, DMG_SHOCK ); CalculateBulletDamageForce( &dmgInfo, GetAmmoDef()->Index("GaussEnergy"), aimDir, tr.endpos, 1.0f + flChargeAmount * 4.0f ); //Do direct damage to anything in our path pHit->DispatchTraceAttack( dmgInfo, aimDir, &tr ); } ApplyMultiDamage(); //Kick up an effect if ( !(tr.surface.flags & SURF_SKY) ) { UTIL_ImpactTrace( &tr, m_nBulletType, "ImpactJeep" ); //Do a gauss explosion CPVSFilter filter( tr.endpos ); te->GaussExplosion( filter, 0.0f, tr.endpos, tr.plane.normal, 0 ); } //Show the effect DrawBeam( m_vecGunOrigin, tr.endpos, 9.6 ); // Register a muzzleflash for the AI if ( m_hPlayer ) { m_hPlayer->SetMuzzleFlashTime( gpGlobals->curtime + 0.5f ); } //Rock the car IPhysicsObject *pObj = VPhysicsGetObject(); if ( pObj != NULL ) { Vector shoveDir = aimDir * -( flDamage * 500.0f ); pObj->ApplyForceOffset( shoveDir, m_vecGunOrigin ); } //Do radius damage if we didn't penetrate the wall if ( penetrated == true ) { RadiusDamage( CTakeDamageInfo( this, this, flDamage, DMG_SHOCK ), tr.endpos, 200.0f, CLASS_NONE, NULL ); } }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CWeaponGauss::ChargedFire( void ) { CBasePlayer *pOwner = ToBasePlayer( GetOwner() ); if(pOwner == NULL) return; bool penetrated = false; //Play shock sounds WeaponSound( SINGLE ); WeaponSound( SPECIAL2 ); SendWeaponAnim( ACT_VM_SECONDARYATTACK ); StopChargeSound(); m_bCharging = false; m_bChargeIndicated = false; m_flNextSecondaryAttack = gpGlobals->curtime + 1.0f; //Shoot a shot straight Vector startPos= pOwner->Weapon_ShootPosition(); Vector aimDir = pOwner->GetAutoaimVector( AUTOAIM_5DEGREES ); Vector endPos = startPos + ( aimDir * MAX_TRACE_LENGTH ); //Find Damage float flChargeAmount = ( gpGlobals->curtime - m_flChargeStartTime ) / MAX_GAUSS_CHARGE_TIME; //Clamp This if ( flChargeAmount > 1.0f ) { flChargeAmount = 1.0f; } #ifndef CLIENT_DLL // float flDamage = sk_plr_max_dmg_gauss.GetFloat() + ( ( sk_plr_max_dmg_gauss.GetFloat() - sk_plr_max_dmg_gauss.GetFloat() ) * flChargeAmount ); float flDamage = 3 + ( ( 37 - 15 ) * flChargeAmount ); #endif trace_t tr; UTIL_TraceLine( startPos, endPos, MASK_SHOT, pOwner, COLLISION_GROUP_NONE, &tr ); //Trace from gun to wall UTIL_ImpactTrace( &tr, GetAmmoDef()->DamageType(m_iPrimaryAmmoType), "ImpactGauss" ); UTIL_DecalTrace( &tr, "RedGlowFade" ); #ifndef CLIENT_DLL //RadiusDamage( CTakeDamageInfo( this, pOwner, sk_plr_max_dmg_gauss.GetFloat(), DMG_SHOCK ),tr.endpos, 90.0f, CLASS_PLAYER_ALLY, pOwner ); RadiusDamage( CTakeDamageInfo( this, pOwner, flDamage, DMG_SHOCK ), tr.endpos, 10.0f, CLASS_PLAYER_ALLY, pOwner ); #endif #ifndef CLIENT_DLL ClearMultiDamage(); #endif UTIL_ImpactTrace( &tr, GetAmmoDef()->DamageType(m_iPrimaryAmmoType), "ImpactGauss" ); UTIL_DecalTrace( &tr, "RedGlowFade" ); #ifndef CLIENT_DLL // RadiusDamage( CTakeDamageInfo( this, pOwner, sk_plr_max_dmg_gauss.GetFloat(), DMG_SHOCK ),tr.endpos, 90.0f, CLASS_PLAYER_ALLY, pOwner ); RadiusDamage( CTakeDamageInfo( this, pOwner, flDamage, DMG_SHOCK ), tr.endpos, 10.0f, CLASS_PLAYER_ALLY, pOwner ); #endif CBaseEntity *pHit = tr.m_pEnt; if ( tr.DidHitWorld() ){ UTIL_ImpactTrace( &tr, GetAmmoDef()->DamageType(m_iPrimaryAmmoType), "ImpactGauss" ); UTIL_DecalTrace( &tr, "RedGlowFade" ); CPVSFilter filter( tr.endpos ); te->GaussExplosion( filter, 0.0f, tr.endpos, tr.plane.normal, 0 ); Vector testPos = tr.endpos + ( aimDir * 128.0f ); UTIL_TraceLine( testPos, tr.endpos, MASK_SHOT, pOwner, COLLISION_GROUP_NONE, &tr ); //Trace to backside of first wall UTIL_ImpactTrace( &tr, GetAmmoDef()->DamageType(m_iPrimaryAmmoType), "ImpactGauss" ); UTIL_DecalTrace( &tr, "RedGlowFade" ); #ifndef CLIENT_DLL //RadiusDamage( CTakeDamageInfo( this, pOwner, sk_plr_max_dmg_gauss.GetFloat(), DMG_SHOCK ),tr.endpos, 90.0f, CLASS_PLAYER_ALLY, pOwner ); RadiusDamage( CTakeDamageInfo( this, pOwner, flDamage, DMG_SHOCK ), tr.endpos, 10.0f, CLASS_PLAYER_ALLY, pOwner ); #endif if ( tr.allsolid == false ){ UTIL_DecalTrace( &tr, "RedGlowFade" ); UTIL_ImpactTrace( &tr, GetAmmoDef()->DamageType(m_iPrimaryAmmoType), "ImpactGauss" ); #ifndef CLIENT_DLL //RadiusDamage( CTakeDamageInfo( this, pOwner, sk_plr_max_dmg_gauss.GetFloat(), DMG_SHOCK ),tr.endpos, 90.0f, CLASS_PLAYER_ALLY, pOwner ); RadiusDamage( CTakeDamageInfo( this, pOwner, flDamage, DMG_SHOCK ), tr.endpos, 10.0f, CLASS_PLAYER_ALLY, pOwner ); #endif penetrated = true; UTIL_ImpactTrace( &tr, GetAmmoDef()->DamageType(m_iPrimaryAmmoType), "ImpactGauss" ); UTIL_DecalTrace( &tr, "RedGlowFade" ); #ifndef CLIENT_DLL //RadiusDamage( CTakeDamageInfo( this, pOwner, sk_plr_max_dmg_gauss.GetFloat(), DMG_SHOCK ),tr.endpos, 90.0f, CLASS_PLAYER_ALLY, pOwner ); RadiusDamage( CTakeDamageInfo( this, pOwner, flDamage, DMG_SHOCK ), tr.endpos, 10.0f, CLASS_PLAYER_ALLY, pOwner ); #endif } } else if(pHit != NULL){ #ifndef CLIENT_DLL // CTakeDamageInfo dmgInfo( this, pOwner, sk_plr_max_dmg_gauss.GetFloat(), DMG_SHOCK ); // CalculateBulletDamageForce( &dmgInfo, m_iPrimaryAmmoType, aimDir, tr.endpos ); UTIL_ImpactTrace( &tr, GetAmmoDef()->DamageType(m_iPrimaryAmmoType), "ImpactGauss" ); UTIL_DecalTrace( &tr, "RedGlowFade" ); //Do Direct damage to anything in our path // pHit->DispatchTraceAttack( dmgInfo, aimDir, &tr ); #endif } #ifndef CLIENT_DLL ApplyMultiDamage(); #endif #ifndef CLIENT_DLL //RadiusDamage( CTakeDamageInfo( this, pOwner, sk_plr_max_dmg_gauss.GetFloat(), DMG_SHOCK ),tr.endpos, 90.0f, CLASS_PLAYER_ALLY, pOwner ); RadiusDamage( CTakeDamageInfo( this, pOwner, flDamage, DMG_SHOCK ), tr.endpos, 10.0f, CLASS_PLAYER_ALLY, pOwner ); #endif Vector newPos = tr.endpos + ( aimDir * MAX_TRACE_LENGTH); QAngle viewPunch; viewPunch.x = random->RandomFloat( -4.0f, -8.0f ); viewPunch.y = random->RandomFloat( -0.25f, 0.25f ); viewPunch.z = 0; pOwner->ViewPunch( viewPunch ); // DrawBeam( startPos, tr.endpos, 9.6, true ); //Draw beam from gun through first wall. #ifndef CLIENT_DLL Vector recoilForce = pOwner->BodyDirection3D() * -( flDamage * 15.0f ); recoilForce[2] += 128.0f; pOwner->ApplyAbsVelocityImpulse( recoilForce ); #endif CPVSFilter filter( tr.endpos ); te->GaussExplosion(filter, 0.0f, tr.endpos, tr.plane.normal, 0 ); #ifndef CLIENT_DLL //RadiusDamage( CTakeDamageInfo( this, pOwner, sk_plr_max_dmg_gauss.GetFloat(), DMG_SHOCK ),tr.endpos, 90.0f, CLASS_PLAYER_ALLY, pOwner ); RadiusDamage( CTakeDamageInfo( this, pOwner, flDamage, DMG_SHOCK ), tr.endpos, 10.0f, CLASS_PLAYER_ALLY, pOwner ); #endif if ( penetrated == true ){ trace_t beam_tr; Vector vecDest = tr.endpos + aimDir * MAX_TRACE_LENGTH; UTIL_TraceLine( tr.endpos, vecDest, MASK_SHOT, pOwner, COLLISION_GROUP_NONE, &beam_tr ); //Traces from back of first wall to second wall #ifndef CLIENT_DLL // float flDamage = sk_plr_max_dmg_gauss.GetFloat() + ( ( sk_plr_max_dmg_gauss.GetFloat() - sk_plr_max_dmg_gauss.GetFloat() ) * flChargeAmount ); float flDamage = 37 + ( ( 115 - 15 ) * flChargeAmount ); #endif for(int i = 0; i < 0; i++){ UTIL_TraceLine(beam_tr.endpos + aimDir * 128.0f, beam_tr.endpos, MASK_SHOT, pOwner, COLLISION_GROUP_NONE, &beam_tr ); //Traces To back of second wall UTIL_ImpactTrace( &beam_tr, GetAmmoDef()->DamageType(m_iPrimaryAmmoType), "ImpactGauss" ); UTIL_DecalTrace( &beam_tr, "RedGlowFade" ); #ifndef CLIENT_DLL //RadiusDamage( CTakeDamageInfo( this, pOwner, sk_plr_max_dmg_gauss.GetFloat(), DMG_SHOCK ), beam_tr.endpos, 90.0f, CLASS_PLAYER_ALLY, pOwner ); RadiusDamage( CTakeDamageInfo( this, pOwner, flDamage, DMG_SHOCK ), tr.endpos, 10.0f, CLASS_PLAYER_ALLY, pOwner ); #endif } DrawBeam( tr.endpos, beam_tr.endpos, 9.6, false ); DoWallBreak(tr.endpos,newPos,aimDir,&tr,pOwner,true); UTIL_ImpactTrace( &beam_tr, GetAmmoDef()->DamageType(m_iPrimaryAmmoType), "ImpactGauss" ); UTIL_DecalTrace( &beam_tr, "RedGlowFade" ); #ifndef CLIENT_DLL //RadiusDamage( CTakeDamageInfo( this, pOwner, sk_plr_max_dmg_gauss.GetFloat(), DMG_SHOCK ), beam_tr.endpos, 90.0f, CLASS_PLAYER_ALLY, pOwner ); RadiusDamage( CTakeDamageInfo( this, pOwner, flDamage, DMG_SHOCK ), tr.endpos, 10.0f, CLASS_PLAYER_ALLY, pOwner ); #endif return; } }