From 456d205161eb99bba331d0b57da997571386ffb5 Mon Sep 17 00:00:00 2001 From: the-real-herowl Date: Wed, 24 Jan 2024 00:28:24 +0100 Subject: [PATCH] Added strength and weakness effects * also highest effect level displayed in HUD set to 3000 * also improved indicating effects with strange factors in HUD --- mods/ENTITIES/mcl_mobs/combat.lua | 7 ++++++ mods/ITEMS/mcl_potions/functions.lua | 34 +++++++++++++++++++++++----- 2 files changed, 35 insertions(+), 6 deletions(-) diff --git a/mods/ENTITIES/mcl_mobs/combat.lua b/mods/ENTITIES/mcl_mobs/combat.lua index 4bbfcd119..f6ee2f429 100644 --- a/mods/ENTITIES/mcl_mobs/combat.lua +++ b/mods/ENTITIES/mcl_mobs/combat.lua @@ -605,6 +605,13 @@ function mob_class:on_punch(hitter, tflp, tool_capabilities, dir) * tmp * ((armor[group] or 0) / 100.0) end + -- strength and weakness effects + local strength = mcl_potions.get_effect(hitter, "strength") + local weakness = mcl_potions.get_effect(hitter, "weakness") + local str_fac = strength and strength.factor or 1 + local weak_fac = weakness and weakness.factor or 1 + damage = damage * str_fac * weak_fac + if weapon then local fire_aspect_level = mcl_enchanting.get_enchantment(weapon, "fire_aspect") if fire_aspect_level > 0 then diff --git a/mods/ITEMS/mcl_potions/functions.lua b/mods/ITEMS/mcl_potions/functions.lua index 796e82ebe..72252c910 100644 --- a/mods/ITEMS/mcl_potions/functions.lua +++ b/mods/ITEMS/mcl_potions/functions.lua @@ -54,7 +54,7 @@ local function generate_rational_fac_to_lvl(l1, l2) local a = (l1 - l2) * 2 local b = 2*l2 - l1 return function(factor) - if factor == 0 then return math.huge end + if (factor - b) == 0 then return math.huge end return math.round(a/(factor - b)) end end @@ -247,21 +247,41 @@ mcl_potions.register_effect({ mcl_potions.register_effect({ name = "strength", description = S("Strength"), - res_condition = function(object) - return (not object:is_player()) + get_tt = function(factor) + return S("+@1% melee damage", factor-1) end, particle_color = "#932423", + uses_factor = true, + lvl1_factor = 1.3, + lvl2_factor = 1.6, }) mcl_potions.register_effect({ name = "weakness", description = S("Weakness"), - res_condition = function(object) - return (not object:is_player()) + get_tt = function(factor) + return S("-@1% melee damage", 1-factor) end, particle_color = "#485D48", + uses_factor = true, + lvl1_factor = 0.8, + lvl2_factor = 0.6, }) +-- implementation of strength and weakness effects +-- mobs have this implemented in mcl_mobs/combat.lua in mob_class:on_punch() +mcl_damage.register_modifier(function(object, damage, reason) + if reason.direct and reason.direct == reason.source then + local hitter = reason.direct + local strength = EF.strength[hitter] + local weakness = EF.weakness[hitter] + if not strength and not weakness then return end + local str_fac = strength and strength.factor or 1 + local weak_fac = weakness and weakness.factor or 1 + return damage * str_fac * weak_fac + end +end, 0) + mcl_potions.register_effect({ name = "water_breathing", description = S("Water Breathing"), @@ -944,7 +964,9 @@ local function potions_set_icons(player) player:hud_change(icon, "text", def.icon .. "^[resize:128x128") if def.uses_factor then local level = def.factor_to_level(vals.factor) - if level == math.huge then level = "∞" + if level > 3000 or level == math.huge then level = "∞" + elseif level < 0 then level = "???" + elseif level == 0 then level = "0" else level = mcl_util.to_roman(level) end player:hud_change(label, "text", level) else