diff --git a/mods/ENTITIES/mcl_mobs/physics.lua b/mods/ENTITIES/mcl_mobs/physics.lua index 73aefb509..c244bc24b 100644 --- a/mods/ENTITIES/mcl_mobs/physics.lua +++ b/mods/ENTITIES/mcl_mobs/physics.lua @@ -412,7 +412,6 @@ end -- check if mob is dead or only hurt function mob_class:check_for_death(cause, cmi_cause) - if self.state == "die" then return true end @@ -425,6 +424,8 @@ function mob_class:check_for_death(cause, cmi_cause) local damaged = self.health < self.old_health self.old_health = self.health + mcl_potions.check_infested_on_damage(self.object) + -- still got some health? if self.health > 0 then diff --git a/mods/ITEMS/mcl_potions/functions.lua b/mods/ITEMS/mcl_potions/functions.lua index a1c838814..aae4ca9ab 100644 --- a/mods/ITEMS/mcl_potions/functions.lua +++ b/mods/ITEMS/mcl_potions/functions.lua @@ -1117,6 +1117,39 @@ end) -- update when hitting mob implemented in mcl_mobs/combat.lua +mcl_potions.register_effect({ + name = "infested", + description = S("Infested"), + res_condition = function(obj) + -- apply to players and non-silverfish mobs + if obj:is_player() then return false end + local entity = obj:get_luaentity() + minetest.debug(entity, entity.is_mob, entity.name, entity and entity.is_mob and entity.name ~= "mobs_mc:silverfish") + if entity and entity.is_mob and entity.name ~= "mobs_mc:silverfish" then return false end + return true + end, + get_tt = function(factor) + return S("Causes 1-2 silverfish to spawn with a 10% chance when damaged") + end, + particle_color = "#472331", + uses_factor = false, +}) + +function mcl_potions.check_infested_on_damage(obj) + -- check for infested status effect + minetest.debug(mcl_potions.get_effect(obj, "infested")) + if mcl_potions.get_effect(obj, "infested") and math.random(1, 10) == 1 then + -- 50-50 for 1 or 2 silverfish + minetest.add_entity(obj:get_pos(), "mobs_mc:silverfish") + if math.random(1, 2) == 1 then + minetest.add_entity(obj:get_pos(), "mobs_mc:silverfish") + end + end +end + +mcl_damage.register_on_damage(function (obj, damage, reason) + mcl_potions.check_infested_on_damage(obj) +end) -- ██╗░░░██╗██████╗░██████╗░░█████╗░████████╗███████╗ -- ██║░░░██║██╔══██╗██╔══██╗██╔══██╗╚══██╔══╝██╔════╝ diff --git a/mods/ITEMS/mcl_potions/init.lua b/mods/ITEMS/mcl_potions/init.lua index 446f6ef16..788c464a8 100644 --- a/mods/ITEMS/mcl_potions/init.lua +++ b/mods/ITEMS/mcl_potions/init.lua @@ -398,6 +398,7 @@ local awkward_table = { ["mcl_mobitems:spider_eye"] = "mcl_potions:poison", ["mcl_flowers:wither_rose"] = "mcl_potions:withering", ["mcl_mobitems:rabbit_foot"] = "mcl_potions:leaping", + ["mcl_core:stone"] = "mcl_potions:infestation", ["mcl_flowers:fourleaf_clover"] = "mcl_potions:luck", ["mcl_farming:potato_item_poison"] = "mcl_potions:nausea", diff --git a/mods/ITEMS/mcl_potions/potions.lua b/mods/ITEMS/mcl_potions/potions.lua index af8a63e68..e62729483 100644 --- a/mods/ITEMS/mcl_potions/potions.lua +++ b/mods/ITEMS/mcl_potions/potions.lua @@ -798,6 +798,17 @@ mcl_potions.register_potion({ }) +mcl_potions.register_potion({ + name = "infestation", + desc_suffix = S("of Infestation"), + _tt = nil, + _longdesc = S("Causes 1-2 silverfish to spawn with a 10% chance when damaged"), + color = "#292929", + _effect_list = { + infested = {}, + }, + has_arrow = true, +}) -- COMPAT CODE