Allow to customize the defense of the hero
Created by: christopho
The defense of the hero when being hurt should be customizable. Currently, this is hardcoded as dividing the damage from the enemy or from hero:start_hurt() by 1, 2 or 4 depending on the tunic.
Proposed new API:
The enemy damage parameter, as well as the damage parameter of hero:start_hurt(), should accept a number or a function.
- If damage is a number, it corresponds to some life points to remove. By default, the hero loses this number of life points divided by the tunic. If the user wants to override this behavior, for example to take into account the shield, he can define hero:on_hurt(base_life_points). If hero:on_hurt() is defined, no life points are removed: the script is responsible to do it.
- If damage is a function, this corresponds to custom damage. The magic_damage parameter can be removed: use a custom damage function instead.