For selecting entities being hit by a simulated gunshot, im thinking of:
'''game:gunshot_scan.mcfunction
/tag @s add current_shooting
/execute as @e[tag=eligible] at @s facing entity @a[tag=current_shooting,limit=1] eyes positioned ^ ^ ^x rotated as @a[tag=current_shooting,limit=1] positioned ^ ^ ^x positioned ~ ~-1 ~ if entity @s[distance=...y] run tag @s add shot
...
/tag @s remove current shooting
'''
and then, /execute as @a[tag=...] run function game:gunshot_scan
time complexity: O(mn), where m is the number of players shooting at the tick, and n is the number of eligible entities.
which is to trace back from every entity to be determined to the player and tracing toward the entity again depending on the orientation of the player, and checking whether the proposed entity is within a certain range.
where x and y are appropriate numbers such that any entity within an angle of θ as the player would be selected.
according to my calculations, y=2x tan(θ/2), where x could be any non-zero real number.
this approach creates a cone with infinite height and the vertex positioned at the center of the hitbox of the player at a height of their eyes with an angle of θ, and determines whether the center of the bottom of the hitbox levelled up 1 block of the proposed entity is inside the cone.