forked from VoxeLibre/VoxeLibre
Added weaving effect
This commit is contained in:
parent
21e1fef166
commit
b95beca545
|
@ -465,6 +465,7 @@ function mob_class:check_for_death(cause, cmi_cause)
|
|||
self:mob_sound("death")
|
||||
|
||||
mcl_potions.check_oozing_on_death(self.object)
|
||||
mcl_potions.check_weaving_on_death(self.object)
|
||||
|
||||
local function death_handle(self)
|
||||
if cmi_cause and cmi_cause["type"] then
|
||||
|
|
|
@ -1130,10 +1130,12 @@ mcl_potions.register_effect({
|
|||
get_tt = function(factor)
|
||||
return S("Causes 1-2 silverfish to spawn with a 10% chance when damaged")
|
||||
end,
|
||||
-- TODO: Better particles (or change colour)
|
||||
particle_color = "#472331",
|
||||
uses_factor = false,
|
||||
})
|
||||
|
||||
-- Called for mobs in their physics.lua
|
||||
function mcl_potions.check_infested_on_damage(obj)
|
||||
-- check for infested status effect
|
||||
-- TODO: silverfish should fling out in direction entity faces
|
||||
|
@ -1164,10 +1166,12 @@ mcl_potions.register_effect({
|
|||
get_tt = function(factor)
|
||||
return S("Causes 2 medium slimes to spawn on death")
|
||||
end,
|
||||
-- TODO: Better particles (or change colour)
|
||||
particle_color = "#60AA30",
|
||||
uses_factor = false,
|
||||
})
|
||||
|
||||
-- Called for mobs in their physics.lua
|
||||
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?)
|
||||
|
@ -1175,13 +1179,13 @@ function mcl_potions.check_oozing_on_death(obj)
|
|||
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 in air above node
|
||||
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")
|
||||
|
@ -1193,6 +1197,52 @@ mcl_damage.register_on_death(function (obj, damage, reason)
|
|||
mcl_potions.check_oozing_on_death(obj)
|
||||
end)
|
||||
|
||||
-- TODO: Reduce cobweb movement resistance when
|
||||
mcl_potions.register_effect({
|
||||
name = "weaving",
|
||||
description = S("Weaving"),
|
||||
res_condition = function(obj)
|
||||
-- apply to players and mobs
|
||||
if obj:is_player() then return false end
|
||||
local entity = obj:get_luaentity()
|
||||
if entity and entity.is_mob then return false end
|
||||
return true
|
||||
end,
|
||||
get_tt = function(factor)
|
||||
return S("Causes 2-3 cobwebs to appear on death")
|
||||
end,
|
||||
-- TODO: Better particles (or change colour)
|
||||
particle_color = "#ACCCFF",
|
||||
uses_factor = false,
|
||||
})
|
||||
|
||||
-- Called for mobs in their physics.lua
|
||||
function mcl_potions.check_weaving_on_death(obj)
|
||||
-- check for weaving status effect
|
||||
if mcl_potions.get_effect(obj, "weaving") then
|
||||
local pos = vector.round(obj:get_pos())
|
||||
-- Use distance of 1 for 3x3x3 area as find_nodes_in_area is quite zealous with valid nodes
|
||||
-- TODO: Cobwebs should probably be able to replace replaceable nodes (e.g. grass)
|
||||
local nodes_under_air = minetest.find_nodes_in_area_under_air(vector.offset(pos, -1, -1, -1), vector.offset(pos, 1, 1, 1), "group:solid")
|
||||
minetest.debug(#nodes_under_air, dump(pos), dump(nodes))
|
||||
-- spawn 2-3 cobwebs
|
||||
local num_cobwebs = math.random(2, 3)
|
||||
for i=1,num_cobwebs do
|
||||
if #nodes_under_air == 0 then
|
||||
return
|
||||
end
|
||||
local pos_index = math.random(1, #nodes_under_air)
|
||||
-- Put cobweb in the air above node
|
||||
minetest.set_node(vector.offset(nodes_under_air[pos_index], 0, 1, 0), {name="mcl_core:cobweb"})
|
||||
table.remove(nodes_under_air, pos_index)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
mcl_damage.register_on_death(function (obj, damage, reason)
|
||||
mcl_potions.check_weaving_on_death(obj)
|
||||
end)
|
||||
|
||||
-- ██╗░░░██╗██████╗░██████╗░░█████╗░████████╗███████╗
|
||||
-- ██║░░░██║██╔══██╗██╔══██╗██╔══██╗╚══██╔══╝██╔════╝
|
||||
-- ██║░░░██║██████╔╝██║░░██║███████║░░░██║░░░█████╗░░
|
||||
|
|
|
@ -400,6 +400,7 @@ local awkward_table = {
|
|||
["mcl_mobitems:rabbit_foot"] = "mcl_potions:leaping",
|
||||
["mcl_core:stone"] = "mcl_potions:infestation",
|
||||
["mcl_core:slimeblock"] = "mcl_potions:oozing",
|
||||
["mcl_core:cobweb"] = "mcl_potions:weaving",
|
||||
|
||||
["mcl_flowers:fourleaf_clover"] = "mcl_potions:luck",
|
||||
["mcl_farming:potato_item_poison"] = "mcl_potions:nausea",
|
||||
|
|
|
@ -822,6 +822,18 @@ mcl_potions.register_potion({
|
|||
has_arrow = true,
|
||||
})
|
||||
|
||||
mcl_potions.register_potion({
|
||||
name = "weaving",
|
||||
desc_suffix = S("of Weaving"),
|
||||
_tt = nil,
|
||||
_longdesc = S("Causes 2-3 cobwebs to appear on death"),
|
||||
color = "#ACCCFF",
|
||||
_effect_list = {
|
||||
weaving = {},
|
||||
},
|
||||
has_arrow = true,
|
||||
})
|
||||
|
||||
|
||||
-- COMPAT CODE
|
||||
local function replace_legacy_potion(itemstack)
|
||||
|
|
Loading…
Reference in New Issue