Added oozing effect

This commit is contained in:
WillConker 2024-07-03 11:17:20 +01:00
parent f8abdea966
commit 21e1fef166
4 changed files with 60 additions and 3 deletions

View File

@ -464,6 +464,8 @@ function mob_class:check_for_death(cause, cmi_cause)
self:mob_sound("death")
mcl_potions.check_oozing_on_death(self.object)
local function death_handle(self)
if cmi_cause and cmi_cause["type"] then
--minetest.log("cmi_cause: " .. tostring(cmi_cause["type"]))

View File

@ -1124,7 +1124,6 @@ mcl_potions.register_effect({
-- 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,
@ -1137,7 +1136,7 @@ mcl_potions.register_effect({
function mcl_potions.check_infested_on_damage(obj)
-- check for infested status effect
minetest.debug(mcl_potions.get_effect(obj, "infested"))
-- TODO: silverfish should fling out in direction entity faces
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")
@ -1151,6 +1150,49 @@ mcl_damage.register_on_damage(function (obj, damage, reason)
mcl_potions.check_infested_on_damage(obj)
end)
mcl_potions.register_effect({
name = "oozing",
description = S("Oozing"),
res_condition = function(obj)
-- apply to players and non-slime mobs
if obj:is_player() then return false end
local entity = obj:get_luaentity()
if entity and entity.is_mob and not string.find(entity.name, "mobs_mc:slime") then return false end
return true
end,
get_tt = function(factor)
return S("Causes 2 medium slimes to spawn on death")
end,
particle_color = "#60AA30",
uses_factor = false,
})
function mcl_potions.check_oozing_on_death(obj)
-- check for oozing status effect
-- TODO: maybe slimes shouldn't spawn through walls (is this practical without line of sight check?)
if mcl_potions.get_effect(obj, "oozing") then
local pos = vector.round(obj:get_pos())
-- Use distance of 2 for 5x5x5 area as find_nodes_in_area is quite zealous with valid nodes
local nodes_under_air = minetest.find_nodes_in_area_under_air(vector.offset(pos, -2, -2, -2), vector.offset(pos, 2, 2, 2), "group:solid")
minetest.debug(#nodes_under_air, #nodes, dump(pos), dump(nodes))
-- always 2 medium ('small') slimes
for i=1,2 do
local spawn_pos
if #nodes_under_air == 0 then
spawn_pos = pos
else
spawn_pos = vector.offset(nodes_under_air[math.random(#nodes_under_air)], 0, 1, 0)
end
minetest.add_entity(spawn_pos, "mobs_mc:slime_small")
end
end
end
mcl_damage.register_on_death(function (obj, damage, reason)
mcl_potions.check_oozing_on_death(obj)
end)
-- ██╗░░░██╗██████╗░██████╗░░█████╗░████████╗███████╗
-- ██║░░░██║██╔══██╗██╔══██╗██╔══██╗╚══██╔══╝██╔════╝
-- ██║░░░██║██████╔╝██║░░██║███████║░░░██║░░░█████╗░░

View File

@ -399,6 +399,7 @@ local awkward_table = {
["mcl_flowers:wither_rose"] = "mcl_potions:withering",
["mcl_mobitems:rabbit_foot"] = "mcl_potions:leaping",
["mcl_core:stone"] = "mcl_potions:infestation",
["mcl_core:slimeblock"] = "mcl_potions:oozing",
["mcl_flowers:fourleaf_clover"] = "mcl_potions:luck",
["mcl_farming:potato_item_poison"] = "mcl_potions:nausea",

View File

@ -803,13 +803,25 @@ mcl_potions.register_potion({
desc_suffix = S("of Infestation"),
_tt = nil,
_longdesc = S("Causes 1-2 silverfish to spawn with a 10% chance when damaged"),
color = "#292929",
color = "#472331",
_effect_list = {
infested = {},
},
has_arrow = true,
})
mcl_potions.register_potion({
name = "oozing",
desc_suffix = S("of Oozing"),
_tt = nil,
_longdesc = S("Causes 2 medium slimes to spawn on death"),
color = "#60AA30",
_effect_list = {
oozing = {},
},
has_arrow = true,
})
-- COMPAT CODE
local function replace_legacy_potion(itemstack)