//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
Vector GetTracerOrigin( const CEffectData &data )
{
	Vector vecStart = data.m_vStart;
	QAngle vecAngles;

	int iEntIndex = data.m_nEntIndex;

	// Attachment?
	if ( data.m_fFlags & TRACER_FLAG_USEATTACHMENT )
	{
		int iAttachment = data.m_vStart[0];
		C_BaseViewModel *pViewModel = NULL;

		// If the entity specified is a weapon being carried by this player, use the viewmodel instead
		C_BaseEntity *pEnt = ClientEntityList().GetEnt( iEntIndex );
		if ( !pEnt )
			return vecStart;

		C_BaseCombatWeapon *pWpn = dynamic_cast<C_BaseCombatWeapon *>(pEnt);
		if ( pWpn && pWpn->IsCarriedByLocalPlayer() )
		{
			C_BasePlayer *player = ToBasePlayer( pWpn->GetOwner() );

			pViewModel = player ? player->GetViewModel( 0 ) : NULL;
			if ( pViewModel )
			{
				// Get the viewmodel and use it instead
				pEnt = pViewModel;
			}
		}

		// Get the attachment origin
		if ( !pEnt->GetAttachment( iAttachment, vecStart, vecAngles ) )
		{
			Msg( "GetTracerOrigin: Couldn't find attachment %d on model %s\n", iAttachment, pEnt->GetModelName() );
		}
	}

	return vecStart;
}