First add an event inside of the main function. You need to add a function reference (to entityGotDamaged) and a “entity_damage_by_entity Event”. The function that you reference (entityGotDamaged) needs to have a parameter (in this case info), this will allow the code to retrieve information from the event.
Inside of this new function you will need three variables: one to get the entity that is being hurt, one to get the entity’s maximum health, and another to get the entity’s current health (hurtEntity, maxHP, and currentHP). You need to set hurtEntity to “info’s Entity”, maxHP to “hurtEntity’s MaxHealth”, and currentHP to “hurtEntity’s Health”.
To get the percentage first divide (currentHP / maxHP), then multiply that result by 100.
Now that you have the necessary information, you can simply send a message with the health percentage.
In this mod whenever you hurt an entity it will print out a message saying: “Health = ##%”. NOTE: (## will correspond to the result of the operation):
Link to similar badge: