-
- if player:hud_get_flags().healthbar and
- core.is_yes(core.setting_get("enable_damage")) then
- if hud_ids[name].id_healthbar == nil then
- health_bar_definition.number = player:get_hp()
- hud_ids[name].id_healthbar = player:hud_add(health_bar_definition)
+ local hud = hud_ids[name]
+
+ if player:hud_get_flags().healthbar and enable_damage then
+ if hud.id_healthbar == nil then
+ local hp = player:get_hp()
+ local max_display_hp = math.max(core.PLAYER_MAX_HP_DEFAULT,
+ math.max(player:get_properties().hp_max, hp))
+ -- Limit width of health bar: Scale to the default maximal HP
+ health_bar_definition.number =
+ hp / max_display_hp * core.PLAYER_MAX_HP_DEFAULT
+ hud.id_healthbar = player:hud_add(health_bar_definition)