From 3d7bb69e81aab3791f2a190cbcbd68a717cd4c56 Mon Sep 17 00:00:00 2001 From: Elias Fleckenstein Date: Mon, 9 Nov 2020 18:59:08 +0100 Subject: [PATCH] Bane of Arthropods; Smite; Lure --- mods/CORE/_mcl_autogroup/init.lua | 5 ++-- mods/CORE/mcl_enchanting/enchantments.lua | 36 +++++++++++------------ mods/CORE/mcl_enchanting/engine.lua | 7 ++++- mods/CORE/mcl_enchanting/init.lua | 2 ++ mods/ENTITIES/mobs_mc/endermite.lua | 2 +- mods/ENTITIES/mobs_mc/horse.lua | 2 ++ mods/ENTITIES/mobs_mc/silverfish.lua | 1 + mods/ENTITIES/mobs_mc/skeleton+stray.lua | 1 + mods/ENTITIES/mobs_mc/skeleton_wither.lua | 1 + mods/ENTITIES/mobs_mc/spider.lua | 1 + mods/ENTITIES/mobs_mc/villager_zombie.lua | 2 +- mods/ENTITIES/mobs_mc/wither.lua | 2 +- mods/ENTITIES/mobs_mc/zombie.lua | 2 +- mods/ENTITIES/mobs_mc/zombiepig.lua | 2 +- mods/HELP/mcl_tt/snippets_base.lua | 2 +- mods/ITEMS/mcl_fishing/depends.txt | 1 + mods/ITEMS/mcl_fishing/init.lua | 36 +++++++++++------------ 17 files changed, 60 insertions(+), 45 deletions(-) diff --git a/mods/CORE/_mcl_autogroup/init.lua b/mods/CORE/_mcl_autogroup/init.lua index 50954235..aabfa590 100644 --- a/mods/CORE/_mcl_autogroup/init.lua +++ b/mods/CORE/_mcl_autogroup/init.lua @@ -56,7 +56,6 @@ for m=1, #materials do mcl_autogroup.creativetimes[basegroups[g].."_dig_"..materials[m]] = {} for e=1, max_efficiency_level do mcl_autogroup.digtimes[basegroups[g].."_dig_"..materials[m].."_efficiency_"..e] = {} - mcl_autogroup.creativetimes[basegroups[g].."_dig_"..materials[m].."_efficiency_"..e] = {} end end end @@ -109,7 +108,9 @@ local overwrite = function() time = math.ceil(time * 20) / 20 end table.insert(mcl_autogroup.digtimes[diggroup], time) - table.insert(mcl_autogroup.creativetimes[diggroup], 0) + if not efficiency then + table.insert(mcl_autogroup.creativetimes[diggroup], 0) + end newgroups[diggroup] = #mcl_autogroup.digtimes[diggroup] return newgroups end diff --git a/mods/CORE/mcl_enchanting/enchantments.lua b/mods/CORE/mcl_enchanting/enchantments.lua index 7ef5f7fe..4301c564 100644 --- a/mods/CORE/mcl_enchanting/enchantments.lua +++ b/mods/CORE/mcl_enchanting/enchantments.lua @@ -15,9 +15,17 @@ requires_tool = false, }]]-- --- unimplemented -mcl_enchanting.enchantments.bane_of_anthropods = { - name = "Bane of Anthropods", +local function increase_damage(damage_group, factor) + return function(itemstack, level) + local tool_capabilities = itemstack:get_tool_capabilities() + tool_capabilities.damage_groups[damage_group] = (tool_capabilities.damage_groups[damage_group] or 0) + level * factor + itemstack:get_meta():set_tool_capabilities(tool_capabilities) + end +end + +-- implemented via on_enchant and additions in mobs_mc; Slowness IV part unimplemented +mcl_enchanting.enchantments.bane_of_arthropods = { + name = "Bane of Arthropods", max_level = 5, primary = {sword = true}, secondary = {axe = true}, @@ -26,7 +34,7 @@ mcl_enchanting.enchantments.bane_of_anthropods = { weight = 5, description = "Increases damage and applies Slowness IV to arthropod mobs (spiders, cave spiders, silverfish and endermites).", curse = false, - on_enchant = function() end, + on_enchant = increase_damage("anthropod", 2.5), requires_tool = false, } @@ -297,7 +305,7 @@ mcl_enchanting.enchantments.luck_of_the_sea = { requires_tool = false, } --- unimplemented +-- implemented in mcl_fishing mcl_enchanting.enchantments.lure = { name = "Lure", max_level = 3, @@ -409,19 +417,11 @@ mcl_enchanting.enchantments.sharpness = { primary = {sword = true}, secondary = {axe = true}, disallow = {}, - incompatible = {bane_of_anthropods = true, smite = true}, + incompatible = {bane_of_arthropods = true, smite = true}, weight = 5, description = "Increases damage.", curse = false, - on_enchant = function(itemstack, level) - local tool_capabilities = itemstack:get_tool_capabilities() - local damage_groups = {} - for group, damage in pairs(tool_capabilities.damage_groups) do - damage_groups[group] = damage + level * 0.5 - end - tool_capabilities.damage_groups = damage_groups - itemstack:get_meta():set_tool_capabilities(tool_capabilities) - end, + on_enchant = increase_damage("fleshy", 0.5), requires_tool = false, } @@ -440,18 +440,18 @@ mcl_enchanting.enchantments.silk_touch = { requires_tool = false, } --- unimplemented +-- implemented via on_enchant and additions in mobs_mc mcl_enchanting.enchantments.smite = { name = "Smite", max_level = 5, primary = {sword = true}, secondary = {axe = true}, disallow = {}, - incompatible = {bane_of_anthropods = true, sharpness = true}, + incompatible = {bane_of_arthropods = true, sharpness = true}, weight = 5, description = "Increases damage to undead mobs.", curse = false, - on_enchant = function() end, + on_enchant = increase_damage("undead", 2.5), requires_tool = false, } diff --git a/mods/CORE/mcl_enchanting/engine.lua b/mods/CORE/mcl_enchanting/engine.lua index 40c600db..fa809cfa 100644 --- a/mods/CORE/mcl_enchanting/engine.lua +++ b/mods/CORE/mcl_enchanting/engine.lua @@ -175,7 +175,11 @@ end function mcl_enchanting.initialize() local all_groups = {} + local weighted = {} + local accum_weight = 0 for enchantment, enchantment_def in pairs(mcl_enchanting.enchantments) do + accum_weight = accum_weight + enchantment_def.weight + weighted[#weighted + 1] = {enchantment = enchantment, weight = accum_weight} for primary in pairs(enchantment_def.primary) do all_groups[primary] = true end @@ -183,6 +187,8 @@ function mcl_enchanting.initialize() all_groups[secondary] = true end end + mcl_enchanting.accumulated_weight = accum_weight + mcl_enchanting.accumulated_weight = weighted local register_tool_list = {} local register_item_list = {} for itemname, itemdef in pairs(minetest.registered_items) do @@ -238,4 +244,3 @@ function mcl_enchanting.initialize() minetest.register_tool(new_name, new_def) end end - diff --git a/mods/CORE/mcl_enchanting/init.lua b/mods/CORE/mcl_enchanting/init.lua index 1d4a9f7c..f0f7a951 100644 --- a/mods/CORE/mcl_enchanting/init.lua +++ b/mods/CORE/mcl_enchanting/init.lua @@ -4,6 +4,8 @@ mcl_enchanting = { book_offset = vector.new(0, 0.75, 0), roman_numerals = dofile(modpath .. "/roman_numerals.lua"), -- https://exercism.io/tracks/lua/exercises/roman-numerals/solutions/73c2fb7521e347209312d115f872fa49 enchantments = {}, + weighted_enchantments = {}, + accumulated_weight = 0, debug = false, } diff --git a/mods/ENTITIES/mobs_mc/endermite.lua b/mods/ENTITIES/mobs_mc/endermite.lua index 3fb0c1eb..256ad496 100644 --- a/mods/ENTITIES/mobs_mc/endermite.lua +++ b/mods/ENTITIES/mobs_mc/endermite.lua @@ -10,7 +10,7 @@ mobs:register_mob("mobs_mc:endermite", { passive = false, hp_min = 8, hp_max = 8, - armor = 100, + armor = {fleshy = 100, arthropod = 100}, group_attack = true, collisionbox = {-0.2, -0.01, -0.2, 0.2, 0.29, 0.2}, visual = "mesh", diff --git a/mods/ENTITIES/mobs_mc/horse.lua b/mods/ENTITIES/mobs_mc/horse.lua index fd4926d2..95cba7ac 100644 --- a/mods/ENTITIES/mobs_mc/horse.lua +++ b/mods/ENTITIES/mobs_mc/horse.lua @@ -352,6 +352,7 @@ mobs:register_mob("mobs_mc:horse", horse) -- Skeleton horse local skeleton_horse = table.copy(horse) skeleton_horse.breath_max = -1 +skeleton_horse.armor = {undead = 100, fleshy = 100} skeleton_horse.textures = {{"blank.png", "mobs_mc_horse_skeleton.png", "blank.png"}} skeleton_horse.drops = { {name = mobs_mc.items.bone, @@ -371,6 +372,7 @@ mobs:register_mob("mobs_mc:skeleton_horse", skeleton_horse) -- Zombie horse local zombie_horse = table.copy(horse) zombie_horse.breath_max = -1 +zombie_horse.armor = {undead = 100, fleshy = 100} zombie_horse.textures = {{"blank.png", "mobs_mc_horse_zombie.png", "blank.png"}} zombie_horse.drops = { {name = mobs_mc.items.rotten_flesh, diff --git a/mods/ENTITIES/mobs_mc/silverfish.lua b/mods/ENTITIES/mobs_mc/silverfish.lua index ca457344..d4ae7ca3 100644 --- a/mods/ENTITIES/mobs_mc/silverfish.lua +++ b/mods/ENTITIES/mobs_mc/silverfish.lua @@ -12,6 +12,7 @@ mobs:register_mob("mobs_mc:silverfish", { reach = 1, hp_min = 8, hp_max = 8, + armor = {fleshy = 100, arthropod = 100}, collisionbox = {-0.4, -0.01, -0.4, 0.4, 0.44, 0.4}, visual = "mesh", mesh = "mobs_mc_silverfish.b3d", diff --git a/mods/ENTITIES/mobs_mc/skeleton+stray.lua b/mods/ENTITIES/mobs_mc/skeleton+stray.lua index 3192a6c0..104ee4f5 100644 --- a/mods/ENTITIES/mobs_mc/skeleton+stray.lua +++ b/mods/ENTITIES/mobs_mc/skeleton+stray.lua @@ -18,6 +18,7 @@ local skeleton = { hp_min = 20, hp_max = 20, breath_max = -1, + armor = {undead = 100, fleshy = 100}, collisionbox = {-0.3, -0.01, -0.3, 0.3, 1.98, 0.3}, pathfinding = 1, group_attack = true, diff --git a/mods/ENTITIES/mobs_mc/skeleton_wither.lua b/mods/ENTITIES/mobs_mc/skeleton_wither.lua index f2bf2abb..c9e087db 100644 --- a/mods/ENTITIES/mobs_mc/skeleton_wither.lua +++ b/mods/ENTITIES/mobs_mc/skeleton_wither.lua @@ -15,6 +15,7 @@ mobs:register_mob("mobs_mc:witherskeleton", { hp_min = 20, hp_max = 20, breath_max = -1, + armor = {undead = 100, fleshy = 100}, pathfinding = 1, group_attack = true, collisionbox = {-0.35, -0.01, -0.35, 0.35, 2.39, 0.35}, diff --git a/mods/ENTITIES/mobs_mc/spider.lua b/mods/ENTITIES/mobs_mc/spider.lua index 5c92657a..f4206d2a 100644 --- a/mods/ENTITIES/mobs_mc/spider.lua +++ b/mods/ENTITIES/mobs_mc/spider.lua @@ -23,6 +23,7 @@ local spider = { reach = 2, hp_min = 16, hp_max = 16, + armor = {fleshy = 100, arthropod = 100}, collisionbox = {-0.7, -0.01, -0.7, 0.7, 0.89, 0.7}, visual = "mesh", mesh = "mobs_mc_spider.b3d", diff --git a/mods/ENTITIES/mobs_mc/villager_zombie.lua b/mods/ENTITIES/mobs_mc/villager_zombie.lua index 66af8f22..6f7e3e5a 100644 --- a/mods/ENTITIES/mobs_mc/villager_zombie.lua +++ b/mods/ENTITIES/mobs_mc/villager_zombie.lua @@ -18,7 +18,7 @@ mobs:register_mob("mobs_mc:villager_zombie", { hp_min = 20, hp_max = 20, breath_max = -1, - armor = 90, + armor = {undead = 90, fleshy = 90}, collisionbox = {-0.3, -0.01, -0.3, 0.3, 1.94, 0.3}, visual = "mesh", mesh = "mobs_mc_villager_zombie.b3d", diff --git a/mods/ENTITIES/mobs_mc/wither.lua b/mods/ENTITIES/mobs_mc/wither.lua index 6af50eff..e3604f94 100644 --- a/mods/ENTITIES/mobs_mc/wither.lua +++ b/mods/ENTITIES/mobs_mc/wither.lua @@ -14,7 +14,7 @@ mobs:register_mob("mobs_mc:wither", { spawn_class = "hostile", hp_max = 300, hp_min = 300, - armor = 80, + armor = {undead = 80, fleshy = 80}, -- This deviates from MC Wiki's size, which makes no sense collisionbox = {-0.9, 0.4, -0.9, 0.9, 2.45, 0.9}, visual = "mesh", diff --git a/mods/ENTITIES/mobs_mc/zombie.lua b/mods/ENTITIES/mobs_mc/zombie.lua index 416be8a3..94b441bf 100644 --- a/mods/ENTITIES/mobs_mc/zombie.lua +++ b/mods/ENTITIES/mobs_mc/zombie.lua @@ -44,7 +44,7 @@ local zombie = { hp_min = 20, hp_max = 20, breath_max = -1, - armor = 90, + armor = {undead = 90, fleshy = 90}, collisionbox = {-0.3, -0.01, -0.3, 0.3, 1.94, 0.3}, visual = "mesh", mesh = "mobs_mc_zombie.b3d", diff --git a/mods/ENTITIES/mobs_mc/zombiepig.lua b/mods/ENTITIES/mobs_mc/zombiepig.lua index 577a49af..3a336456 100644 --- a/mods/ENTITIES/mobs_mc/zombiepig.lua +++ b/mods/ENTITIES/mobs_mc/zombiepig.lua @@ -18,7 +18,7 @@ local pigman = { hp_min = 20, hp_max = 20, breath_max = -1, - armor = 90, + armor = {undead = 90, fleshy = 90}, attack_type = "dogfight", group_attack = { "mobs_mc:pigman", "mobs_mc:baby_pigman" }, damage = 9, diff --git a/mods/HELP/mcl_tt/snippets_base.lua b/mods/HELP/mcl_tt/snippets_base.lua index a3470b5c..8242f2c1 100644 --- a/mods/HELP/mcl_tt/snippets_base.lua +++ b/mods/HELP/mcl_tt/snippets_base.lua @@ -116,7 +116,7 @@ tt.register_snippet(function(itemstring, toolcaps) -- Weapon stats if toolcaps.damage_groups then for group, damage in pairs(toolcaps.damage_groups) do - local msg + local msg = "" if group == "fleshy" then if damage >= 0 then msg = S("Damage: @1", damage) diff --git a/mods/ITEMS/mcl_fishing/depends.txt b/mods/ITEMS/mcl_fishing/depends.txt index 93ef0bf5..bbc3c6ad 100644 --- a/mods/ITEMS/mcl_fishing/depends.txt +++ b/mods/ITEMS/mcl_fishing/depends.txt @@ -2,3 +2,4 @@ mcl_core mcl_sounds mcl_loot mcl_mobs +mcl_enchanting diff --git a/mods/ITEMS/mcl_fishing/init.lua b/mods/ITEMS/mcl_fishing/init.lua index b7e1ba73..ac64f07d 100644 --- a/mods/ITEMS/mcl_fishing/init.lua +++ b/mods/ITEMS/mcl_fishing/init.lua @@ -18,8 +18,8 @@ local bobber_ENTITY={ _lastpos={}, _dive = false, - _waittick = nil, - _tick = 0, + _waittime = nil, + _time = 0, player=nil, _oldy = nil, objtype="fishing", @@ -179,11 +179,10 @@ local bobber_on_step = function(self, dtime) self.object:remove() return end - + local wield = player:get_wielded_item() --Check if player is nearby - if self._tick % 5 == 0 and self.player ~= nil and player ~= nil then + if self.player ~= nil and player ~= nil then --Destroy bobber if item not wielded. - local wield = player:get_wielded_item() if ((not wield) or (minetest.get_item_group(wield:get_name(), "fishing_rod") <= 0)) then self.object:remove() return @@ -232,33 +231,34 @@ local bobber_on_step = function(self, dtime) pos = {x=epos["x"]+math.random(-1,1)*math.random()/2,y=epos["y"]+0.1,z=epos["z"]+math.random(-1,1)*math.random()/2}, velocity = {x=0, y=4, z=0}, acceleration = {x=0, y=-5, z=0}, - expirationtime = math.random(), - size = math.random()+0.5, + expirationtime = math.random() * 0.5, + size = math.random(), collisiondetection = true, vertical = false, texture = "mcl_particles_bubble.png", }) end - if self._tick ~= self._waittick then - self._tick = self._tick + 1 + if self._time < self._waittime then + self._time = self._time + dtime else - self._waittick = nil - self._tick = 0 + self._waittime = 0 + self._time = 0 self._dive = false end - else if self._waittick == nil then + else if not self._waittime or self._waittime <= 0 then -- wait for random number of ticks. - self._waittick = math.random(50,333) + local lure_enchantment = wield and mcl_enchanting.get_enchantment(wield, "lure") or 0 + self._waittime = math.random(5, 30) - lure_enchantment * 5 else - if self._tick ~= self._waittick then - self._tick = self._tick + 1 + if self._time < self._waittime then + self._time = self._time + dtime else - --wait time is over time to dive. + -- wait time is over time to dive. self._dive = true self.object:set_velocity({x=0,y=-2,z=0}) self.object:set_acceleration({x=0,y=5,z=0}) - self._waittick = 30 - self._tick = 0 + self._waittime = 0.8 + self._time = 0 end end end