From f60aaa8bd0b6b66ce2aeec82889507e8b6f50bad Mon Sep 17 00:00:00 2001 From: Sokomine Date: Wed, 8 Nov 2023 22:45:43 +0100 Subject: [PATCH] #5383 mobs_redo now uses get_properties() for hp_max; adjusted update_tag --- interface_mobs_api.lua | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/interface_mobs_api.lua b/interface_mobs_api.lua index 5b1dc3c..4b9ab2f 100644 --- a/interface_mobs_api.lua +++ b/interface_mobs_api.lua @@ -126,38 +126,47 @@ mobs.mob_class.update_tag = function(self) return yl_speak_up.orig_mobs_update_tag(self) end + local qua = 0 local floor = math.floor local col = "#00FF00" - local qua = self.hp_max / 4 + local prop = self.object:get_properties() + local hp_max = 0 + if(prop) then + hp_max = prop.hp_max + else + hp_max = self.hp_max + end + local qua = hp_max / 6 if(self.force_nametag_color) then col = self.force_nametag_color - elseif self.health <= floor(qua) then + elseif self.health <= qua then col = "#FF0000" - elseif self.health <= floor(qua * 2) then - col = "#FF6600" - elseif self.health <= floor(qua * 3) then + elseif self.health <= (qua * 2) then + col = "#FF7A00" + elseif self.health <= (qua * 3) then + col = "#FFB500" + elseif self.health <= (qua * 4) then col = "#FFFF00" + elseif self.health <= (qua * 5) then + col = "#B4FF00" + elseif self.health > (qua * 5) then + col = "#00FF00" end + local text = "" if self.horny == true then - local HORNY_TIME = 30 local HORNY_AGAIN_TIME = 60 * 5 -- 5 minutes text = "\nLoving: " .. (self.hornytimer - (HORNY_TIME + HORNY_AGAIN_TIME)) - elseif self.child == true then - local CHILD_GROW_TIME = 60 * 20 -- 20 minutes text = "\nGrowing: " .. (self.hornytimer - CHILD_GROW_TIME) - elseif self._breed_countdown then - text = "\nBreeding: " .. self._breed_countdown - end if self.protected then @@ -175,7 +184,7 @@ mobs.mob_class.update_tag = function(self) add_info = add_info..", "..tostring(self.yl_speak_up.npc_description) end end - self.infotext = "Health: " .. self.health .. " / " .. self.hp_max + self.infotext = "Health: " .. self.health .. " / " .. hp_max .. add_info .. (self.owner == "" and "" or "\nOwner: " .. self.owner) .. text