//----------------------------------------------------------------------------- // Purpose: Draw the first Carged Beam //----------------------------------------------------------------------------- void CWeaponGauss::ChargedFireFirstBeam( void ) { CBasePlayer *pOwner = ToBasePlayer( GetOwner() ); if ( pOwner == NULL ) return; Vector startPos= pOwner->Weapon_ShootPosition(); Vector aimDir = pOwner->GetAutoaimVector( AUTOAIM_5DEGREES ); Vector endPos = startPos + ( aimDir * MAX_TRACE_LENGTH ); //Shoot a shot straight out trace_t tr; UTIL_TraceLine( startPos, endPos, MASK_SHOT, pOwner, COLLISION_GROUP_NONE, &tr ); startPos = tr.endpos; //Draw beam DrawBeam( tr.startpos, tr.endpos, 9.6, true ); CPVSFilter filter( tr.endpos ); te->GaussExplosion( filter, 0.0f, tr.endpos, tr.plane.normal, 0 ); UTIL_ImpactTrace( &tr, GetAmmoDef()->DamageType(m_iPrimaryAmmoType), "ImpactGauss" ); return; }
void CWeaponMomentumGun::DoImpactEffect(trace_t &tr, int nDamageType) { //Draw our beam DrawBeam(tr.startpos, tr.endpos, 15.5); if ((tr.surface.flags & SURF_SKY) == false) { CPVSFilter filter(tr.endpos); te->GaussExplosion(filter, 0.0f, tr.endpos, tr.plane.normal, 0); //m_nBulletType = GetAmmoDef()->Index("GaussEnergy"); //UTIL_ImpactTrace(&tr, m_nBulletType); } }
//----------------------------------------------------------------------------- // Purpose: // Input : &tr - // nDamageType - //----------------------------------------------------------------------------- void CASW_PropJeep::DoImpactEffect( trace_t &tr, int nDamageType ) { //Draw our beam DrawBeam( tr.startpos, tr.endpos, 2.4 ); if ( (tr.surface.flags & SURF_SKY) == false ) { CPVSFilter filter( tr.endpos ); te->GaussExplosion( filter, 0.0f, tr.endpos, tr.plane.normal, 0 ); UTIL_ImpactTrace( &tr, m_nBulletType ); } }
void CBeamEffectCreator::PaintHit (CG16bitImage &Dest, int x, int y, const CVector &vHitPos, SViewportPaintCtx &Ctx) // PaintHit // // Paint the effect when hit { SLineDesc Line; Metric rLength = LIGHT_SPEED * g_SecondsPerUpdate / g_KlicksPerPixel; CVector vFrom = PolarToVector(Ctx.iRotation, -rLength); Line.xFrom = x + (int)(vFrom.GetX() + 0.5); Line.yFrom = y - (int)(vFrom.GetY() + 0.5); Ctx.XForm.Transform(vHitPos, &Line.xTo, &Line.yTo); DrawBeam(Dest, Line, Ctx); }
void CBeamEffectCreator::Paint (CG16bitImage &Dest, int x, int y, SViewportPaintCtx &Ctx) // Paint // // Paint the effect { SLineDesc Line; // NOTE: We add 1.0 to make the ends of multiple beam objects overlap. // (Because round-off tends to lose a pixel.) Metric rLength = 1.0 + (LIGHT_SPEED * g_SecondsPerUpdate / g_KlicksPerPixel); CVector vFrom = PolarToVector(Ctx.iRotation, -rLength); Line.xFrom = x + (int)(vFrom.GetX() + 0.5); Line.yFrom = y - (int)(vFrom.GetY() + 0.5); Line.xTo = x; Line.yTo = y; DrawBeam(Dest, Line, Ctx); }
//----------------------------------------------------------------------------- // 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 }
//========================================================= // Disparo //========================================================= void CWeaponGaussGun::Fire() { CBasePlayer *pOwner = ToBasePlayer(GetOwner()); // ¿El jugador no ha sido creado? if ( !pOwner ) return; m_bCharging = false; if ( m_hViewModel == NULL ) { CBaseViewModel *vm = pOwner->GetViewModel(); if ( vm ) m_hViewModel.Set(vm); } Vector startPos = pOwner->Weapon_ShootPosition(); Vector aimDir = pOwner->GetAutoaimVector(AUTOAIM_5DEGREES); Vector vecUp, vecRight; VectorVectors(aimDir, vecRight, vecUp); float x, y, z; //Gassian spread do { x = random->RandomFloat(-0.5,0.5) + random->RandomFloat(-0.5,0.5); y = random->RandomFloat(-0.5,0.5) + random->RandomFloat(-0.5,0.5); z = x*x+y*y; } while (z > 1); aimDir = aimDir + x * GetBulletSpread().x * vecRight + y * GetBulletSpread().y * vecUp; Vector endPos = startPos + (aimDir * MAX_TRACE_LENGTH); // Shoot a shot straight out trace_t tr; UTIL_TraceLine(startPos, endPos, MASK_SHOT, pOwner, COLLISION_GROUP_NONE, &tr); #ifndef CLIENT_DLL ClearMultiDamage(); CBaseEntity *pHit = tr.m_pEnt; CTakeDamageInfo dmgInfo(this, pOwner, sk_plr_dmg_gauss.GetFloat(), DMG_SHOCK | DMG_DISSOLVE); if ( pHit != NULL ) { CalculateBulletDamageForce(&dmgInfo, m_iPrimaryAmmoType, aimDir, tr.endpos); pHit->DispatchTraceAttack(dmgInfo, aimDir, &tr); } if ( tr.DidHitWorld() ) { float hitAngle = -DotProduct( tr.plane.normal, aimDir ); if ( hitAngle < 0.5f ) { Vector vReflection; vReflection = 2.0 * tr.plane.normal * hitAngle + aimDir; startPos = tr.endpos; endPos = startPos + (vReflection * MAX_TRACE_LENGTH); // Draw beam to reflection point DrawBeam(tr.startpos, tr.endpos, 15, true); CPVSFilter filter(tr.endpos); te->GaussExplosion(filter, 0.0f, tr.endpos, tr.plane.normal, 0); UTIL_ImpactTrace(&tr, GetAmmoDef()->DamageType(m_iPrimaryAmmoType), "ImpactGauss"); //Find new reflection end position UTIL_TraceLine(startPos, endPos, MASK_SHOT, pOwner, COLLISION_GROUP_NONE, &tr); if ( tr.m_pEnt != NULL ) { dmgInfo.SetDamageForce(GetAmmoDef()->DamageForce(m_iPrimaryAmmoType) * vReflection); dmgInfo.SetDamagePosition(tr.endpos); tr.m_pEnt->DispatchTraceAttack(dmgInfo, vReflection, &tr); } // Connect reflection point to end DrawBeam(tr.startpos, tr.endpos, 10); } else DrawBeam(tr.startpos, tr.endpos, 15, true); } else DrawBeam(tr.startpos, tr.endpos, 15, true); ApplyMultiDamage(); #endif UTIL_ImpactTrace(&tr, GetAmmoDef()->DamageType(m_iPrimaryAmmoType), "ImpactGauss"); CPVSFilter filter(tr.endpos); te->GaussExplosion(filter, 0.0f, tr.endpos, tr.plane.normal, 0); m_flNextSecondaryAttack = gpGlobals->curtime + 0.5f; AddViewKick(); // Register a muzzleflash for the AI #ifndef CLIENT_DLL 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 CWeaponGrapple::PrimaryAttack( void ) { // Can't have an active hook out if ( m_hHook != NULL ) return; #ifndef CLIENT_DLL CBasePlayer *pPlayer = ToBasePlayer( GetOwner() ); if ( !pPlayer ) { return; } if ( m_iClip1 <= 0 ) { if ( !m_bFireOnEmpty ) { Reload(); } else { WeaponSound( EMPTY ); m_flNextPrimaryAttack = 0.15; } return; } m_iPrimaryAttacks++; gamestats->Event_WeaponFired( pPlayer, true, GetClassname() ); WeaponSound( SINGLE ); pPlayer->DoMuzzleFlash(); SendWeaponAnim( ACT_VM_PRIMARYATTACK ); pPlayer->SetAnimation( PLAYER_ATTACK1 ); m_flNextPrimaryAttack = gpGlobals->curtime + 0.75; m_flNextSecondaryAttack = gpGlobals->curtime + 0.75; //Disabled so we can shoot all the time that we want //m_iClip1--; Vector vecSrc = pPlayer->Weapon_ShootPosition(); Vector vecAiming = pPlayer->GetAutoaimVector( AUTOAIM_SCALE_DEFAULT ); //We will not shoot bullets anymore //pPlayer->FireBullets( 1, vecSrc, vecAiming, vec3_origin, MAX_TRACE_LENGTH, m_iPrimaryAmmoType, 0 ); pPlayer->SetMuzzleFlashTime( gpGlobals->curtime + 0.5 ); CSoundEnt::InsertSound( SOUND_COMBAT, GetAbsOrigin(), 600, 0.2, GetOwner() ); if ( !m_iClip1 && pPlayer->GetAmmoCount( m_iPrimaryAmmoType ) <= 0 ) { // HEV suit - indicate out of ammo condition pPlayer->SetSuitUpdate( "!HEV_AMO0", FALSE, 0 ); } trace_t tr; Vector vecShootOrigin, vecShootDir, vecDir, vecEnd; //Gets the direction where the player is aiming AngleVectors (pPlayer->EyeAngles(), &vecDir); //Gets the position of the player vecShootOrigin = pPlayer->Weapon_ShootPosition(); //Gets the position where the hook will hit vecEnd = vecShootOrigin + (vecDir * MAX_TRACE_LENGTH); //Traces a line between the two vectors UTIL_TraceLine( vecShootOrigin, vecEnd, MASK_SHOT, pPlayer, COLLISION_GROUP_NONE, &tr); //Draws the beam DrawBeam( vecShootOrigin, tr.endpos, 15.5 ); //Creates an energy impact effect if we don't hit the sky or other places if ( (tr.surface.flags & SURF_SKY) == false ) { CPVSFilter filter( tr.endpos ); te->GaussExplosion( filter, 0.0f, tr.endpos, tr.plane.normal, 0 ); m_nBulletType = GetAmmoDef()->Index("GaussEnergy"); UTIL_ImpactTrace( &tr, m_nBulletType ); //Makes a sprite at the end of the beam m_pLightGlow = CSprite::SpriteCreate( "sprites/physcannon_bluecore2b.vmt", GetAbsOrigin(), TRUE); //Sets FX render and color m_pLightGlow->SetTransparency( 9, 255, 255, 255, 200, kRenderFxNoDissipation ); //Sets the position m_pLightGlow->SetAbsOrigin(tr.endpos); //Bright m_pLightGlow->SetBrightness( 255 ); //Scale m_pLightGlow->SetScale( 0.65 ); } #endif FireHook(); SetWeaponIdleTime( gpGlobals->curtime + SequenceDuration( ACT_VM_PRIMARYATTACK ) ); }
//----------------------------------------------------------------------------- // 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; } }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CWeaponGauss::Fire( void ) { CBasePlayer *pOwner = ToBasePlayer( GetOwner() ); if ( pOwner == NULL ) return; m_bCharging = false; Vector startPos= pOwner->Weapon_ShootPosition(); Vector aimDir = pOwner->GetAutoaimVector( AUTOAIM_5DEGREES ); Vector vecUp, vecRight; VectorVectors( aimDir, vecRight, vecUp ); float x, y, z; //Gassian spread do { x = random->RandomFloat(-0.5,0.5) + random->RandomFloat(-0.5,0.5); y = random->RandomFloat(-0.5,0.5) + random->RandomFloat(-0.5,0.5); z = x*x+y*y; } while (z > 1); Vector endPos = startPos + ( aimDir * MAX_TRACE_LENGTH ); //Shoot a shot straight out trace_t tr; UTIL_TraceLine( startPos, endPos, MASK_SHOT, pOwner, COLLISION_GROUP_NONE, &tr ); #ifndef CLIENT_DLL ClearMultiDamage(); #endif CBaseEntity *pHit = tr.m_pEnt; #ifndef CLIENT_DLL CTakeDamageInfo dmgInfo( this, pOwner, sk_dmg_gauss.GetFloat(), DMG_SHOCK | DMG_BULLET ); #endif if ( pHit != NULL ) { #ifndef CLIENT_DLL CalculateBulletDamageForce( &dmgInfo, m_iPrimaryAmmoType, aimDir, tr.endpos, 7.0f * 5.0f ); pHit->DispatchTraceAttack( dmgInfo, aimDir, &tr ); #endif } if ( tr.DidHitWorld() ) { float hitAngle = -DotProduct( tr.plane.normal, aimDir ); if ( hitAngle < 0.5f ) { Vector vReflection; vReflection = 2.0 * tr.plane.normal * hitAngle + aimDir; startPos = tr.endpos; endPos = startPos + ( vReflection * MAX_TRACE_LENGTH ); //Draw beam to reflection point DrawBeam( tr.startpos, tr.endpos, 1.6, true ); CPVSFilter filter( tr.endpos ); te->GaussExplosion( filter, 0.0f, tr.endpos, tr.plane.normal, 0 ); UTIL_ImpactTrace( &tr, GetAmmoDef()->DamageType(m_iPrimaryAmmoType), "ImpactGauss" ); //Find new reflection end position UTIL_TraceLine( startPos, endPos, MASK_SHOT, pOwner, COLLISION_GROUP_NONE, &tr ); if ( tr.m_pEnt != NULL ) { #ifndef CLIENT_DLL dmgInfo.SetDamageForce( GetAmmoDef()->DamageForce(m_iPrimaryAmmoType) * vReflection ); dmgInfo.SetDamagePosition( tr.endpos ); tr.m_pEnt->DispatchTraceAttack( dmgInfo, vReflection, &tr ); #endif } //Connect reflection point to end DrawBeam( tr.startpos, tr.endpos, 0.4 ); } else { DrawBeam( tr.startpos, tr.endpos, 1.6, true ); } } else { DrawBeam( tr.startpos, tr.endpos, 1.6, true ); } #ifndef CLIENT_DLL ApplyMultiDamage(); #endif UTIL_ImpactTrace( &tr, GetAmmoDef()->DamageType(m_iPrimaryAmmoType), "ImpactGauss" ); CPVSFilter filter( tr.endpos ); te->GaussExplosion( filter, 0.0f, tr.endpos, tr.plane.normal, 0 ); m_flNextSecondaryAttack = gpGlobals->curtime + 1.0f; AddViewKick(); return; }