#5383 mobs_redo now uses get_properties() for hp_max; adjusted update_tag

This commit is contained in:
Sokomine 2023-11-08 22:45:43 +01:00
parent 1416ab39d3
commit f60aaa8bd0

View File

@ -126,38 +126,47 @@ mobs.mob_class.update_tag = function(self)
return yl_speak_up.orig_mobs_update_tag(self) return yl_speak_up.orig_mobs_update_tag(self)
end end
local qua = 0
local floor = math.floor local floor = math.floor
local col = "#00FF00" 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 if(self.force_nametag_color) then
col = self.force_nametag_color col = self.force_nametag_color
elseif self.health <= floor(qua) then elseif self.health <= qua then
col = "#FF0000" col = "#FF0000"
elseif self.health <= floor(qua * 2) then elseif self.health <= (qua * 2) then
col = "#FF6600" col = "#FF7A00"
elseif self.health <= floor(qua * 3) then elseif self.health <= (qua * 3) then
col = "#FFB500"
elseif self.health <= (qua * 4) then
col = "#FFFF00" col = "#FFFF00"
elseif self.health <= (qua * 5) then
col = "#B4FF00"
elseif self.health > (qua * 5) then
col = "#00FF00"
end end
local text = "" local text = ""
if self.horny == true then if self.horny == true then
local HORNY_TIME = 30 local HORNY_TIME = 30
local HORNY_AGAIN_TIME = 60 * 5 -- 5 minutes local HORNY_AGAIN_TIME = 60 * 5 -- 5 minutes
text = "\nLoving: " .. (self.hornytimer - (HORNY_TIME + HORNY_AGAIN_TIME)) text = "\nLoving: " .. (self.hornytimer - (HORNY_TIME + HORNY_AGAIN_TIME))
elseif self.child == true then elseif self.child == true then
local CHILD_GROW_TIME = 60 * 20 -- 20 minutes local CHILD_GROW_TIME = 60 * 20 -- 20 minutes
text = "\nGrowing: " .. (self.hornytimer - CHILD_GROW_TIME) text = "\nGrowing: " .. (self.hornytimer - CHILD_GROW_TIME)
elseif self._breed_countdown then elseif self._breed_countdown then
text = "\nBreeding: " .. self._breed_countdown text = "\nBreeding: " .. self._breed_countdown
end end
if self.protected then 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) add_info = add_info..", "..tostring(self.yl_speak_up.npc_description)
end end
end end
self.infotext = "Health: " .. self.health .. " / " .. self.hp_max self.infotext = "Health: " .. self.health .. " / " .. hp_max
.. add_info .. add_info
.. (self.owner == "" and "" or "\nOwner: " .. self.owner) .. (self.owner == "" and "" or "\nOwner: " .. self.owner)
.. text .. text