From 9a32bdc967290e74326015685dbf016257c2c9cc Mon Sep 17 00:00:00 2001 From: Brandon Date: Mon, 27 Jul 2020 19:17:04 -0400 Subject: [PATCH] Update HUD for poison/regen. --- mods/ITEMS/mcl_potions/functions.lua | 32 ++++++++++++++++-- .../textures/hbhunger_icon_regen_poison.png | Bin 0 -> 290 bytes .../textures/hudbars_icon_regenerate.png | Bin 0 -> 305 bytes 3 files changed, 30 insertions(+), 2 deletions(-) create mode 100644 mods/ITEMS/mcl_potions/textures/hbhunger_icon_regen_poison.png create mode 100644 mods/ITEMS/mcl_potions/textures/hudbars_icon_regenerate.png diff --git a/mods/ITEMS/mcl_potions/functions.lua b/mods/ITEMS/mcl_potions/functions.lua index afe87c367..0c199697a 100644 --- a/mods/ITEMS/mcl_potions/functions.lua +++ b/mods/ITEMS/mcl_potions/functions.lua @@ -55,7 +55,9 @@ minetest.register_globalstep(function(dtime) if is_poisoned[player].timer >= is_poisoned[player].dur then is_poisoned[player] = nil - if is_player then + if is_regenerating[player] then + hb.change_hudbar(player, "health", nil, nil, "hudbars_icon_regenerate.png", nil, "hudbars_bar_health.png") + else hb.change_hudbar(player, "health", nil, nil, "hudbars_icon_health.png", nil, "hudbars_bar_health.png") end end @@ -89,6 +91,13 @@ minetest.register_globalstep(function(dtime) if is_regenerating[player].timer >= is_regenerating[player].dur then is_regenerating[player] = nil + if is_player then + if is_poisoned[player] then + hb.change_hudbar(player, "health", nil, nil, "hbhunger_icon_health_poison.png", nil, "hudbars_bar_health.png") + else + hb.change_hudbar(player, "health", nil, nil, "hudbars_icon_health.png", nil, "hudbars_bar_health.png") + end + end end end @@ -284,6 +293,7 @@ function mcl_potions._reset_player_effects(player) end if is_poisoned[player] then + is_poisoned[player] = nil if player:is_player() then @@ -293,7 +303,13 @@ function mcl_potions._reset_player_effects(player) end if is_regenerating[player] then + is_regenerating[player] = nil + + if player:is_player() then + hb.change_hudbar(player, "health", nil, nil, "hudbars_icon_health.png", nil, "hudbars_bar_health.png") + end + end if is_strong[player] then @@ -556,7 +572,11 @@ function mcl_potions.poison_func(player, factor, duration) is_poisoned[player] = {step = factor, dur = duration, timer = 0} if player:is_player() then - hb.change_hudbar(player, "health", nil, nil, "hbhunger_icon_health_poison.png", nil, "hbhunger_bar_health_poison.png") + if is_regenerating[player] then + hb.change_hudbar(player, "health", nil, nil, "hbhunger_icon_regen_poison.png", nil, "hudbars_bar_health.png") + else + hb.change_hudbar(player, "health", nil, nil, "hbhunger_icon_health_poison.png", nil, "hbhunger_bar_health_poison.png") + end end else @@ -577,6 +597,14 @@ function mcl_potions.regeneration_func(player, factor, duration) is_regenerating[player] = {step = factor, dur = duration, timer = 0} + if player:is_player() then + if is_poisoned[player] then + hb.change_hudbar(player, "health", nil, nil, "hbhunger_icon_regen_poison.png", nil, "hudbars_bar_health.png") + else + hb.change_hudbar(player, "health", nil, nil, "hudbars_icon_regenerate.png", nil, "hudbars_bar_health.png") + end + end + else local victim = is_regenerating[player] diff --git a/mods/ITEMS/mcl_potions/textures/hbhunger_icon_regen_poison.png b/mods/ITEMS/mcl_potions/textures/hbhunger_icon_regen_poison.png new file mode 100644 index 0000000000000000000000000000000000000000..d4fe9b4e0783d7ddabcc749e79095e880c49af0d GIT binary patch literal 290 zcmeAS@N?(olHy`uVBq!ia0y~yVBiE{4mJh`h6fYb1Q-|?7>k44ofy`glX=O&z+jOY z;hE;^%b>-;z`()4*q+J20#d@jz#zo{0!#~-;3Aw0m=SD{Bv04w*$fN}Gdx`!LnI`V z6BL*Xny&n@|NqZE;%yxp+c71_WB)$}*ab`|T&SST?cw-Ci+_WZz{makC+c}0+VA{2 z@1ec(^?I=xYbJCs%-{@WcvSFdW7E+Y2UPeT{a$`QK~juuf%Uz8KbjWuMDjc;SYREa zce_E9%lkuvX`_$jF0bP0l+XkKB`;Xz literal 0 HcmV?d00001 diff --git a/mods/ITEMS/mcl_potions/textures/hudbars_icon_regenerate.png b/mods/ITEMS/mcl_potions/textures/hudbars_icon_regenerate.png new file mode 100644 index 0000000000000000000000000000000000000000..4ae2598971f5dd75a5dfc3bf94e1ddcc0303a57e GIT binary patch literal 305 zcmeAS@N?(olHy`uVBq!ia0y~yVBiE{4mJh`h6fYb1Q-|?7>k44ofy`glX=O&z+jOY z;hE;^%b>-;z`()4*q+J20#d@jz#zo{0!#~-;3Aw0m=SD{Bv04w*$fN}%ROBjLnI`V z6BL*Xny&n@|NqZE;%yxp+c71_WB)$}*ab`|T&SST?Q!rF5Bmlwfsgz7PsDRRoL~EY z;zN7q>-B0ga(?_{<}p%Q#ACp!P^efIw!tLk;>8OAGpa29zI&c;FuRrUMc?oH`wR{C zRPs(|F+7kIAlPxZ@!g9V`D|iAPaZL8Gt9hHs@>f7K5BF6*2UngGtuU@QOt literal 0 HcmV?d00001