Fixed splash and lingering potions

* descriptions
* scaling
This commit is contained in:
the-real-herowl 2024-01-08 00:25:30 +01:00
parent 93572d71f2
commit 0b1cc6ad57
3 changed files with 23 additions and 9 deletions

View File

@ -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

View File

@ -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();

View File

@ -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()