//----------------------------------------------------------------------------- // Purpose: // Input : &startPos - // &endPos - // width - // useMuzzle - //----------------------------------------------------------------------------- void CASW_PropJeep::DrawBeam( const Vector &startPos, const Vector &endPos, float width ) { //Tracer down the middle UTIL_Tracer( startPos, endPos, 0, TRACER_DONT_USE_ATTACHMENT, 6500, false, "GaussTracer" ); //Draw the main beam shaft CBeam *pBeam = CBeam::BeamCreate( GAUSS_BEAM_SPRITE, 0.5 ); pBeam->SetStartPos( startPos ); pBeam->PointEntInit( endPos, this ); pBeam->SetEndAttachment( LookupAttachment("Muzzle") ); pBeam->SetWidth( width ); pBeam->SetEndWidth( 0.05f ); pBeam->SetBrightness( 255 ); pBeam->SetColor( 255, 185+random->RandomInt( -16, 16 ), 40 ); pBeam->RelinkBeam(); pBeam->LiveForTime( 0.1f ); //Draw electric bolts along shaft pBeam = CBeam::BeamCreate( GAUSS_BEAM_SPRITE, 3.0f ); pBeam->SetStartPos( startPos ); pBeam->PointEntInit( endPos, this ); pBeam->SetEndAttachment( LookupAttachment("Muzzle") ); pBeam->SetBrightness( random->RandomInt( 64, 255 ) ); pBeam->SetColor( 255, 255, 150+random->RandomInt( 0, 64 ) ); pBeam->RelinkBeam(); pBeam->LiveForTime( 0.1f ); pBeam->SetNoise( 1.6f ); pBeam->SetEndWidth( 0.1f ); }
void CWeaponMomentumGun::DrawBeam(const Vector &startPos, const Vector &endPos, float width) { //Tracer down the middle UTIL_Tracer(startPos, endPos, 0, TRACER_DONT_USE_ATTACHMENT, 6500, false, "GaussTracer"); //Draw the main beam shaft CBeam *pBeam = CBeam::BeamCreate("sprites/orangelight1.vmt", 15.5); // It starts at startPos pBeam->SetStartPos(startPos); // This sets up some things that the beam uses to figure out where // it should start and end pBeam->PointEntInit(endPos, this); // This makes it so that the laser appears to come from the muzzle of the pistol pBeam->SetEndAttachment(LookupAttachment("Muzzle")); pBeam->SetWidth(width); // pBeam->SetEndWidth( 0.05f ); // Higher brightness means less transparent pBeam->SetBrightness(255); pBeam->SetColor(255, 185 + random->RandomInt(-16, 16), 40); pBeam->RelinkBeam(); // The beam should only exist for a very short time pBeam->LiveForTime(0.1f); }
void CEgon::UpdateEffect( const Vector &startPoint, const Vector &endPoint, float timeBlend ) { if ( !m_pBeam ) { CreateEffect(); } m_pBeam->SetStartPos( endPoint ); m_pBeam->SetBrightness( 255 - (timeBlend*180) ); m_pBeam->SetWidth( 40 - (timeBlend*20) ); if ( m_fireMode == FIRE_WIDE ) m_pBeam->SetColor( 30 + (25*timeBlend), 30 + (30*timeBlend), 64 + 80*fabs(sin(gpGlobals->time*10)) ); else m_pBeam->SetColor( 60 + (25*timeBlend), 120 + (30*timeBlend), 64 + 80*fabs(sin(gpGlobals->time*10)) ); UTIL_SetOrigin( m_pSprite->pev, endPoint ); m_pSprite->pev->frame += 8 * gpGlobals->frametime; if ( m_pSprite->pev->frame > m_pSprite->Frames() ) m_pSprite->pev->frame = 0; m_pNoise->SetStartPos( endPoint ); }
//----------------------------------------------------------------------------- //----------------------------------------------------------------------------- void CNPC_GroundTurret::ProjectBeam( const Vector &vecStart, const Vector &vecDir, int width, int brightness, float duration ) { CBeam *pBeam; pBeam = CBeam::BeamCreate( GROUNDTURRET_BEAM_SPRITE, width ); if ( !pBeam ) return; trace_t tr; AI_TraceLine( vecStart, vecStart + vecDir * m_flSensingDist, MASK_SHOT, this, COLLISION_GROUP_NONE, &tr ); pBeam->SetStartPos( tr.endpos ); pBeam->SetEndPos( tr.startpos ); pBeam->SetWidth( width ); pBeam->SetEndWidth( 0.1 ); pBeam->SetFadeLength( 16 ); pBeam->SetBrightness( brightness ); pBeam->SetColor( 0, 145+random->RandomInt( -16, 16 ), 255 ); pBeam->RelinkBeam(); pBeam->LiveForTime( duration ); }
//--------------------------------------------------------- //--------------------------------------------------------- void CNPC_GroundTurret::MakeTracer( const Vector &vecTracerSrc, const trace_t &tr, int iTracerType ) { #if 1 //BaseClass::MakeTracer( vecTracerSrc, tr, iTracerType ); UTIL_Tracer( vecTracerSrc, tr.endpos, 0, TRACER_DONT_USE_ATTACHMENT, 5000, true, "AR2Tracer" ); #else CBeam *pBeam; int width = 2; pBeam = CBeam::BeamCreate( GROUNDTURRET_BEAM_SPRITE, width ); if ( !pBeam ) return; pBeam->SetStartPos( vecTracerSrc ); pBeam->SetEndPos( tr.endpos ); pBeam->SetWidth( width ); pBeam->SetEndWidth( width / 4.0f ); pBeam->SetBrightness( 100 ); pBeam->SetColor( 0, 145+random->RandomInt( -16, 16 ), 255 ); pBeam->RelinkBeam(); pBeam->LiveForTime( random->RandomFloat( 0.2f, 0.5f ) ); #endif }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CWeaponGaussGun::DrawBeam( const Vector &startPos, const Vector &endPos, float width, bool useMuzzle ) { CBasePlayer *pOwner = ToBasePlayer(GetOwner()); if (!pOwner) return; //Check to store off our view model index if (m_hViewModel == NULL) { CBaseViewModel *vm = pOwner->GetViewModel(); if (vm) m_hViewModel.Set(vm); } //Draw the main beam shaft CBeam *pBeam = CBeam::BeamCreate( GAUSS_BEAM_SPRITE, width ); if ( useMuzzle ) { pBeam->PointEntInit( endPos, m_hViewModel ); pBeam->SetEndAttachment( 1 ); pBeam->SetWidth( width / 4.0f ); pBeam->SetEndWidth( width ); } else { pBeam->SetStartPos( startPos ); pBeam->SetEndPos( endPos ); pBeam->SetWidth( width ); pBeam->SetEndWidth( width / 4.0f ); } pBeam->SetBrightness( 255 ); pBeam->SetColor( 255, 145+random->RandomInt( -16, 16 ), 0 ); pBeam->RelinkBeam(); pBeam->LiveForTime( 0.1f ); //Draw electric bolts along shaft for ( int i = 0; i < 3; i++ ) { pBeam = CBeam::BeamCreate( GAUSS_BEAM_SPRITE, (width/2.0f) + i ); if ( useMuzzle ) { pBeam->PointEntInit( endPos, m_hViewModel ); pBeam->SetEndAttachment( 1 ); } else { pBeam->SetStartPos( startPos ); pBeam->SetEndPos( endPos ); } pBeam->SetBrightness( random->RandomInt( 64, 255 ) ); pBeam->SetColor( 255, 255, 150+random->RandomInt( 0, 64 ) ); pBeam->RelinkBeam(); pBeam->LiveForTime( 0.1f ); pBeam->SetNoise( 1.6f * i ); pBeam->SetEndWidth( 0.1f ); } }
BOOL CApache :: FireGun( ) { UTIL_MakeAimVectors( pev->angles ); Vector posGun, angGun; GetAttachment( 1, posGun, angGun ); Vector vecTarget = (m_posTarget - posGun).Normalize( ); Vector vecOut; vecOut.x = DotProduct( gpGlobals->v_forward, vecTarget ); vecOut.y = -DotProduct( gpGlobals->v_right, vecTarget ); vecOut.z = DotProduct( gpGlobals->v_up, vecTarget ); Vector angles = UTIL_VecToAngles (vecOut); angles.x = -angles.x; if (angles.y > 180) angles.y = angles.y - 360; if (angles.y < -180) angles.y = angles.y + 360; if (angles.x > 180) angles.x = angles.x - 360; if (angles.x < -180) angles.x = angles.x + 360; if (angles.x > m_angGun.x) m_angGun.x = min( angles.x, m_angGun.x + 12 ); if (angles.x < m_angGun.x) m_angGun.x = max( angles.x, m_angGun.x - 12 ); if (angles.y > m_angGun.y) m_angGun.y = min( angles.y, m_angGun.y + 12 ); if (angles.y < m_angGun.y) m_angGun.y = max( angles.y, m_angGun.y - 12 ); m_angGun.y = SetBoneController( 0, m_angGun.y ); m_angGun.x = SetBoneController( 1, m_angGun.x ); Vector posBarrel, angBarrel; GetAttachment( 0, posBarrel, angBarrel ); Vector vecGun = (posBarrel - posGun).Normalize( ); if (DotProduct( vecGun, vecTarget ) > 0.98) { #if 1 FireBullets( 1, posGun, vecGun, VECTOR_CONE_4DEGREES, 8192, BULLET_MONSTER_12MM, 1 ); EMIT_SOUND(ENT(pev), CHAN_WEAPON, "turret/tu_fire1.wav", 1, 0.3); #else static float flNext; TraceResult tr; UTIL_TraceLine( posGun, posGun + vecGun * 8192, dont_ignore_monsters, ENT( pev ), &tr ); if (!m_pBeam) { m_pBeam = CBeam::BeamCreate( "sprites/lgtning.spr", 80 ); m_pBeam->PointEntInit( pev->origin, entindex( ) ); m_pBeam->SetEndAttachment( 1 ); m_pBeam->SetColor( 255, 180, 96 ); m_pBeam->SetBrightness( 192 ); } if (flNext < gpGlobals->time) { flNext = gpGlobals->time + 0.5; m_pBeam->SetStartPos( tr.vecEndPos ); } #endif return TRUE; } else { if (m_pBeam) { UTIL_Remove( m_pBeam ); m_pBeam = NULL; } } return FALSE; }