//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CTFMinigun::StartMuzzleEffect() { C_BaseEntity *pEffectOwner = GetWeaponForEffect(); if ( !pEffectOwner ) return; // Try and setup the attachment point if it doesn't already exist. // This caching will mess up if we go third person from first - we only do this in taunts and don't fire so we should // be okay for now. if ( m_iMuzzleAttachment == -1 ) { m_iMuzzleAttachment = pEffectOwner->LookupAttachment( "muzzle" ); } // Start the muzzle flash, if a system hasn't already been started. if ( m_iMuzzleAttachment != -1 && m_pMuzzleEffect == NULL ) { m_pMuzzleEffect = pEffectOwner->ParticleProp()->Create( "muzzle_minigun_constant", PATTACH_POINT_FOLLOW, m_iMuzzleAttachment ); } }
void C_NEOPlayer::CalcView( Vector &eyeOrigin, QAngle &eyeAngles, float &zNear, float &zFar, float &fov ) { C_BaseEntity* ragdoll = m_hRagdoll.Get(); if ( m_lifeState != LIFE_ALIVE && ragdoll && m_bIsOnDeathScreen ) { int attachment = ragdoll->LookupAttachment( "eyes" ); if ( !attachment ) return; Vector origin; QAngle angles; if ( !ragdoll->GetAttachment( attachment, origin, angles ) ) return; Vector forward; AngleVectors( angles, &forward ); Vector start; start = forward; start.z += 64.f; trace_t trace; UTIL_TraceHull( start, forward, -Vector( 12, 12, 12 ), Vector( 12, 12, 12 ), CONTENTS_MOVEABLE | CONTENTS_GRATE | CONTENTS_AUX | CONTENTS_WINDOW | CONTENTS_SOLID, this, 0, &trace ); if ( trace.fraction < 1.f ) forward = trace.endpos; if ( gpGlobals->curtime >= (m_fRagdollCreationTime + 10.f) ) m_bIsOnDeathScreen = false; } // The original game has a check for mobile armor in here else BaseClass::CalcView( eyeOrigin, eyeAngles, zNear, zFar, fov ); }
//----------------------------------------------------------------------------- // Purpose: Return the origin & angles for a projectile fired from the player's gun //----------------------------------------------------------------------------- void CTFWeaponBaseGun::GetProjectileFireSetup( CTFPlayer *pPlayer, Vector vecOffset, Vector *vecSrc, QAngle *angForward, bool bHitTeammates /* = true */ ) { Vector vecForward, vecRight, vecUp; AngleVectors( pPlayer->EyeAngles(), &vecForward, &vecRight, &vecUp ); Vector vecShootPos = pPlayer->Weapon_ShootPosition(); // Estimate end point Vector endPos = vecShootPos + vecForward * 2000; // Trace forward and find what's in front of us, and aim at that trace_t tr; if ( bHitTeammates ) { CTraceFilterSimple filter( pPlayer, COLLISION_GROUP_NONE ); UTIL_TraceLine( vecShootPos, endPos, MASK_SOLID, &filter, &tr ); } else { CTraceFilterIgnoreTeammates filter( pPlayer, COLLISION_GROUP_NONE, pPlayer->GetTeamNumber() ); UTIL_TraceLine( vecShootPos, endPos, MASK_SOLID, &filter, &tr ); } #ifndef CLIENT_DLL // Offset actual start point *vecSrc = vecShootPos + (vecForward * vecOffset.x) + (vecRight * vecOffset.y) + (vecUp * vecOffset.z); #else // If we're seeing another player shooting the projectile, move their start point to the weapon origin if ( pPlayer ) { C_TFPlayer *pLocalPlayer = C_TFPlayer::GetLocalTFPlayer(); if ( pLocalPlayer != pPlayer || ::input->CAM_IsThirdPerson() ) { if ( pPlayer->GetActiveWeapon() ) { pPlayer->GetActiveWeapon()->GetAttachment( "muzzle", *vecSrc ); } } else { C_BaseEntity *pViewModel = pLocalPlayer->GetViewModel(); if ( pViewModel ) { QAngle vecAngles; int iMuzzleFlashAttachment = pViewModel->LookupAttachment( "muzzle" ); pViewModel->GetAttachment( iMuzzleFlashAttachment, *vecSrc, vecAngles ); Vector vForward; AngleVectors( vecAngles, &vForward ); trace_t trace; UTIL_TraceLine( *vecSrc + vForward * -50, *vecSrc, MASK_SOLID, pPlayer, COLLISION_GROUP_NONE, &trace ); *vecSrc = trace.endpos; } } } #endif // Find angles that will get us to our desired end point // Only use the trace end if it wasn't too close, which results // in visually bizarre forward angles if ( tr.fraction > 0.1 ) { VectorAngles( tr.endpos - *vecSrc, *angForward ); } else { VectorAngles( endPos - *vecSrc, *angForward ); } }