Here is my health code, a C++ Class. Tbh I can't explain it very well because its been a while since I did any programming.
What might help you is to copy this code and paste it into Chat GPT, it should do a good job of explaining it. I will post the code in text in my next comment instead of an image.