How to code a "damage reflection" with commands?

i was wondering how to do this

Continue to help post