forked from VoxeLibre/VoxeLibre
Added strength and weakness effects
* also highest effect level displayed in HUD set to 3000 * also improved indicating effects with strange factors in HUD
This commit is contained in:
parent
c08750262c
commit
48b7b77b9d
|
@ -605,6 +605,13 @@ function mob_class:on_punch(hitter, tflp, tool_capabilities, dir)
|
||||||
* tmp * ((armor[group] or 0) / 100.0)
|
* tmp * ((armor[group] or 0) / 100.0)
|
||||||
end
|
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
|
if weapon then
|
||||||
local fire_aspect_level = mcl_enchanting.get_enchantment(weapon, "fire_aspect")
|
local fire_aspect_level = mcl_enchanting.get_enchantment(weapon, "fire_aspect")
|
||||||
if fire_aspect_level > 0 then
|
if fire_aspect_level > 0 then
|
||||||
|
|
|
@ -54,7 +54,7 @@ local function generate_rational_fac_to_lvl(l1, l2)
|
||||||
local a = (l1 - l2) * 2
|
local a = (l1 - l2) * 2
|
||||||
local b = 2*l2 - l1
|
local b = 2*l2 - l1
|
||||||
return function(factor)
|
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))
|
return math.round(a/(factor - b))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -247,21 +247,41 @@ mcl_potions.register_effect({
|
||||||
mcl_potions.register_effect({
|
mcl_potions.register_effect({
|
||||||
name = "strength",
|
name = "strength",
|
||||||
description = S("Strength"),
|
description = S("Strength"),
|
||||||
res_condition = function(object)
|
get_tt = function(factor)
|
||||||
return (not object:is_player())
|
return S("+@1% melee damage", factor-1)
|
||||||
end,
|
end,
|
||||||
particle_color = "#932423",
|
particle_color = "#932423",
|
||||||
|
uses_factor = true,
|
||||||
|
lvl1_factor = 1.3,
|
||||||
|
lvl2_factor = 1.6,
|
||||||
})
|
})
|
||||||
|
|
||||||
mcl_potions.register_effect({
|
mcl_potions.register_effect({
|
||||||
name = "weakness",
|
name = "weakness",
|
||||||
description = S("Weakness"),
|
description = S("Weakness"),
|
||||||
res_condition = function(object)
|
get_tt = function(factor)
|
||||||
return (not object:is_player())
|
return S("-@1% melee damage", 1-factor)
|
||||||
end,
|
end,
|
||||||
particle_color = "#485D48",
|
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({
|
mcl_potions.register_effect({
|
||||||
name = "water_breathing",
|
name = "water_breathing",
|
||||||
description = S("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")
|
player:hud_change(icon, "text", def.icon .. "^[resize:128x128")
|
||||||
if def.uses_factor then
|
if def.uses_factor then
|
||||||
local level = def.factor_to_level(vals.factor)
|
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
|
else level = mcl_util.to_roman(level) end
|
||||||
player:hud_change(label, "text", level)
|
player:hud_change(label, "text", level)
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in New Issue