From 0b1cc6ad5745c91f58050363dd2661db7d802baf Mon Sep 17 00:00:00 2001 From: the-real-herowl Date: Mon, 8 Jan 2024 00:25:30 +0100 Subject: [PATCH] Fixed splash and lingering potions * descriptions * scaling --- mods/HELP/mcl_tt/snippets_mcl.lua | 10 ++++++++-- mods/ITEMS/mcl_potions/lingering.lua | 9 +++++---- mods/ITEMS/mcl_potions/splash.lua | 13 ++++++++++--- 3 files changed, 23 insertions(+), 9 deletions(-) diff --git a/mods/HELP/mcl_tt/snippets_mcl.lua b/mods/HELP/mcl_tt/snippets_mcl.lua index c1396790e..7b25f0750 100644 --- a/mods/HELP/mcl_tt/snippets_mcl.lua +++ b/mods/HELP/mcl_tt/snippets_mcl.lua @@ -133,7 +133,13 @@ tt.register_snippet(function(itemstring, _, itemstack) local meta = itemstack:get_meta() local potency = meta:get_int("mcl_potions:potion_potent") local plus = meta:get_int("mcl_potions:potion_plus") - if def._dynamic_tt then s = s.. def._dynamic_tt(potency+1).. "\n" end + local sl_factor = 1 + if def.groups.splash_potion == 1 then + sl_factor = mcl_potions.SPLASH_FACTOR + elseif def.groups.ling_potion == 1 then + sl_factor = mcl_potions.LINGERING_FACTOR + end + if def._dynamic_tt then s = s.. def._dynamic_tt((potency+1)*sl_factor).. "\n" end local effects = def._effect_list if effects then local effect @@ -146,7 +152,7 @@ tt.register_snippet(function(itemstring, _, itemstack) for name, details in pairs(effects) do effect = mcl_potions.registered_effects[name] if details.dur_variable then - dur = details.dur * math.pow(mcl_potions.PLUS_FACTOR, plus) + dur = details.dur * math.pow(mcl_potions.PLUS_FACTOR, plus) * sl_factor if potency > 0 and details.uses_level then dur = dur / math.pow(mcl_potions.POTENT_FACTOR, potency) end diff --git a/mods/ITEMS/mcl_potions/lingering.lua b/mods/ITEMS/mcl_potions/lingering.lua index 68da35146..646ff16ff 100644 --- a/mods/ITEMS/mcl_potions/lingering.lua +++ b/mods/ITEMS/mcl_potions/lingering.lua @@ -86,18 +86,19 @@ minetest.register_globalstep(function(dtime) if vals.potency>0 and details.uses_level then dur = dur / math.pow(mcl_potions.POTENT_FACTOR, vals.potency) end + dur = dur * mcl_potions.LINGERING_FACTOR else dur = details.dur end - dur = dur * mcl_potions.SPLASH_FACTOR if mcl_potions.give_effect_by_level(name, obj, ef_level, dur) then applied = true end end end - if vals.def.custom_effect and vals.def.custom_effect(obj, vals.potency+1) then - applied = true + if vals.def.custom_effect + and vals.def.custom_effect(obj, (vals.potency+1) * mcl_potions.LINGERING_FACTOR) then + applied = true end if applied then vals.timer = vals.timer - 3.25 end @@ -138,7 +139,7 @@ function mcl_potions.register_lingering(name, descr, color, def) _default_potent_level = def._default_potent_level, _default_extend_level = def._default_extend_level, inventory_image = lingering_image(color), - groups = {brewitem=1, bottle=1, _mcl_potion=1}, + groups = {brewitem=1, bottle=1, ling_potion=1, _mcl_potion=1}, on_use = function(item, placer, pointed_thing) local velocity = 10 local dir = placer:get_look_dir(); diff --git a/mods/ITEMS/mcl_potions/splash.lua b/mods/ITEMS/mcl_potions/splash.lua index 33515c161..e14bf2c1a 100644 --- a/mods/ITEMS/mcl_potions/splash.lua +++ b/mods/ITEMS/mcl_potions/splash.lua @@ -34,7 +34,7 @@ function mcl_potions.register_splash(name, descr, color, def) _default_potent_level = def._default_potent_level, _default_extend_level = def._default_extend_level, inventory_image = splash_image(color), - groups = {brewitem=1, bottle=1, _mcl_potion=1}, + groups = {brewitem=1, bottle=1, splash_potion=1, _mcl_potion=1}, on_use = function(item, placer, pointed_thing) local velocity = 10 local dir = placer:get_look_dir(); @@ -145,10 +145,10 @@ function mcl_potions.register_splash(name, descr, color, def) if potency>0 and details.uses_level then dur = dur / math.pow(mcl_potions.POTENT_FACTOR, potency) end + dur = dur * mcl_potions.SPLASH_FACTOR else dur = details.dur end - dur = dur * mcl_potions.SPLASH_FACTOR if rad > 0 then mcl_potions.give_effect_by_level(name, obj, ef_level, redux_map[rad]*dur) else @@ -157,7 +157,14 @@ function mcl_potions.register_splash(name, descr, color, def) end end - if def.custom_effect then def.custom_effect(obj, potency+1) end -- TODO use redux_map + if def.custom_effect then + local power = (potency+1) * mcl_potions.SPLASH_FACTOR + if rad > 0 then + def.custom_effect(obj, redux_map[rad] * power) + else + def.custom_effect(obj, power) + end + end end end self.object:remove()