Added the 'infested' status effect and potions

This commit is contained in:
WillConker 2024-07-03 10:10:49 +01:00
parent 026ea5940c
commit f8abdea966
4 changed files with 47 additions and 1 deletions

View File

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

View File

@ -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)
-- ██╗░░░██╗██████╗░██████╗░░█████╗░████████╗███████╗
-- ██║░░░██║██╔══██╗██╔══██╗██╔══██╗╚══██╔══╝██╔════╝

View File

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

View File

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