Bane of Arthropods; Smite; Lure

This commit is contained in:
Lizzy Fleckenstein 2020-11-09 18:59:08 +01:00
parent 479dfd6c0d
commit 3d7bb69e81
17 changed files with 60 additions and 45 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -2,3 +2,4 @@ mcl_core
mcl_sounds
mcl_loot
mcl_mobs
mcl_enchanting

View File

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