I’ve seen research into how a person with a knife wins vs a person with a gun if the knife person is within 30 feet. Let’s make that a piece of DnD!
Just because you are not near by doesn’t mean you are an easy target. When a ranged attack is made against you and you are within 30 feet of the target, you may move up to the target and make a melee attack as a reaction. This movement provokes attacks as normal.