1
0
mirror of https://codeberg.org/tenplus1/mobs_monster.git synced 2024-12-23 09:20:26 +01:00
mobs_monster/lava_flan.lua

351 lines
8.0 KiB
Lua
Raw Normal View History

2024-08-10 15:39:51 +02:00
2023-08-13 12:02:47 +02:00
local S = minetest.get_translator("mobs_monster")
2016-04-15 16:00:45 +02:00
-- Lava Flan by Zeg9 (additional textures by JurajVajda)
mobs:register_mob("mobs_monster:lava_flan", {
type = "monster",
passive = false,
attack_type = "dogfight",
reach = 2,
damage = 3,
hp_min = 10,
hp_max = 35,
armor = 80,
collisionbox = {-0.5, -0.5, -0.5, 0.5, 1.5, 0.5},
visual = "mesh",
mesh = "zmobs_lava_flan.x",
textures = {
{"zmobs_lava_flan.png"},
{"zmobs_lava_flan2.png"},
2022-08-11 08:39:25 +02:00
{"zmobs_lava_flan3.png"}
2016-04-15 16:00:45 +02:00
},
blood_texture = "fire_basic_flame.png",
makes_footstep_sound = false,
sounds = {
random = "mobs_lavaflan",
2022-08-11 08:39:25 +02:00
war_cry = "mobs_lavaflan"
2016-04-15 16:00:45 +02:00
},
walk_velocity = 0.5,
run_velocity = 2,
jump = true,
view_range = 10,
floats = 1,
drops = {
2022-08-11 08:39:25 +02:00
{name = "mobs:lava_orb", chance = 15, min = 1, max = 1}
2016-04-15 16:00:45 +02:00
},
water_damage = 8,
2021-06-14 10:38:32 +02:00
lava_damage = -1,
2021-04-05 09:51:13 +02:00
fire_damage = 0,
2016-04-15 16:00:45 +02:00
light_damage = 0,
immune_to = {
2022-08-11 08:39:25 +02:00
{"mobs:pick_lava", -2} -- lava pick heals 2 health
},
fly_in = {"default:lava_source", "default:lava_flowing"},
2016-04-15 16:00:45 +02:00
animation = {
speed_normal = 15,
speed_run = 15,
stand_start = 0,
stand_end = 8,
walk_start = 10,
walk_end = 18,
run_start = 20,
run_end = 28,
punch_start = 20,
2021-06-14 10:38:32 +02:00
punch_end = 28
2016-04-15 16:00:45 +02:00
},
2022-08-11 08:39:25 +02:00
-- custom death function
2020-06-19 21:26:21 +02:00
on_die = function(self, pos)
local cod = self.cause_of_death or {}
local def = cod.node and minetest.registered_nodes[cod.node]
if def and def.groups and def.groups.water then
pos.y = pos.y + 1
mobs:effect(pos, 40, "tnt_smoke.png", 3, 5, 2, 0.5, nil, false)
2020-06-19 21:26:21 +02:00
minetest.sound_play("fire_extinguish_flame",
2022-08-11 08:39:25 +02:00
{pos = pos, max_hear_distance = 12, gain = 1.5}, true)
2020-06-19 21:26:21 +02:00
2020-06-19 21:44:52 +02:00
self.object:remove()
2020-06-19 21:26:21 +02:00
if math.random(4) == 1 then
2022-08-11 08:39:25 +02:00
mobs:add_mob(pos, {name = "mobs_monster:obsidian_flan"})
2020-06-19 21:26:21 +02:00
end
else
mobs:effect(pos, 40, "fire_basic_flame.png", 2, 3, 2, 5, 10, nil)
local nods = minetest.find_nodes_in_area(
2024-08-10 15:39:51 +02:00
{x = pos.x, y = pos.y + 1, z = pos.z},
{x = pos.x, y = pos.y, z = pos.z}, "air")
2022-08-11 08:39:25 +02:00
-- place flame if position empty and flame exists
if nods and #nods > 0
2022-08-11 08:39:25 +02:00
and minetest.registered_nodes["fire:basic_flame"] then
pos = nods[math.random(#nods)]
2020-06-19 21:44:52 +02:00
minetest.set_node(pos, {name = "fire:basic_flame"})
end
self.object:remove()
2020-06-19 21:26:21 +02:00
end
end,
2022-08-11 08:39:25 +02:00
glow = 10
2016-04-15 16:00:45 +02:00
})
2024-08-10 15:39:51 +02:00
-- where to spawn
if not mobs.custom_spawn_monster then
2024-08-10 15:39:51 +02:00
mobs:spawn({
name = "mobs_monster:lava_flan",
nodes = {"default:lava_source"},
chance = 1500,
active_object_count = 1,
max_height = 0
})
end
2016-04-15 16:00:45 +02:00
2024-08-10 15:39:51 +02:00
-- spawn egg
2016-06-11 12:03:00 +02:00
mobs:register_egg("mobs_monster:lava_flan", S("Lava Flan"), "default_lava.png", 1)
2016-04-15 16:00:45 +02:00
2024-08-10 15:39:51 +02:00
-- compatibility for old mobs mod
2022-08-11 08:39:25 +02:00
mobs:alias_mob("mobs:lava_flan", "mobs_monster:lava_flan")
2016-04-15 16:00:45 +02:00
-- lava orb
2024-08-10 15:39:51 +02:00
2016-04-15 16:00:45 +02:00
minetest.register_craftitem(":mobs:lava_orb", {
2016-06-11 12:03:00 +02:00
description = S("Lava orb"),
2016-04-15 16:00:45 +02:00
inventory_image = "zmobs_lava_orb.png",
2022-08-11 08:39:25 +02:00
light_source = 14
2016-04-15 16:00:45 +02:00
})
minetest.register_alias("zmobs:lava_orb", "mobs:lava_orb")
minetest.register_craft({
type = "fuel",
recipe = "mobs:lava_orb",
2022-08-11 08:39:25 +02:00
burntime = 80
2016-04-15 16:00:45 +02:00
})
2024-08-10 15:39:51 +02:00
-- backup and replace old function
2016-04-15 16:00:45 +02:00
local old_handle_node_drops = minetest.handle_node_drops
function minetest.handle_node_drops(pos, drops, digger)
2024-06-28 12:31:26 +02:00
-- are we a player using the lava pick?
if digger and digger:get_wielded_item():get_name() == ("mobs:pick_lava") then
2016-04-15 16:00:45 +02:00
2024-06-28 12:31:26 +02:00
local hot_drops = {}
local is_cooked
2016-04-15 16:00:45 +02:00
2024-06-28 12:31:26 +02:00
for _, drop in ipairs(drops) do
2016-04-15 16:00:45 +02:00
2024-06-28 12:31:26 +02:00
local stack = ItemStack(drop)
2024-06-28 12:31:26 +02:00
while not stack:is_empty() do
2024-06-28 12:31:26 +02:00
local output, decremented_input = minetest.get_craft_result({
2024-08-10 15:39:51 +02:00
method = "cooking", width = 1, items = {stack}})
2024-06-28 12:31:26 +02:00
if output.item:is_empty() then
table.insert_all(hot_drops, decremented_input.items)
break
else
is_cooked = true
2024-06-28 12:31:26 +02:00
if not output.item:is_empty() then
table.insert(hot_drops, output.item)
end
2024-06-28 12:31:26 +02:00
table.insert_all(hot_drops, output.replacements)
2024-06-28 12:31:26 +02:00
stack = decremented_input.items[1] or ItemStack()
end
end
2016-04-15 16:00:45 +02:00
end
2024-06-28 12:31:26 +02:00
drops = hot_drops -- replace normal drops with cooked versions
if is_cooked then
mobs:effect(pos, 1, "tnt_smoke.png", 3, 5, 2, 0.5, nil, false)
minetest.sound_play("fire_extinguish_flame",
2024-09-23 09:27:01 +02:00
{pos = pos, max_hear_distance = 5, gain = 0.05}, true)
end
2016-04-15 16:00:45 +02:00
end
2024-06-28 12:31:26 +02:00
return old_handle_node_drops(pos, drops, digger)
2016-04-15 16:00:45 +02:00
end
2024-08-10 15:39:51 +02:00
-- lava pick, smelts nodes when you dig
2016-04-15 16:00:45 +02:00
minetest.register_tool(":mobs:pick_lava", {
2016-06-11 12:03:00 +02:00
description = S("Lava Pickaxe"),
2016-04-15 16:00:45 +02:00
inventory_image = "mobs_pick_lava.png",
tool_capabilities = {
full_punch_interval = 0.4,
2021-06-14 10:38:32 +02:00
max_drop_level = 3,
groupcaps = {
cracky = {
2024-08-10 15:39:51 +02:00
times = {[1] = 1.80, [2] = 0.80, [3] = 0.40}, uses = 40, maxlevel = 3
2021-06-14 10:38:32 +02:00
}
2016-04-15 16:00:45 +02:00
},
2019-06-03 11:02:26 +02:00
damage_groups = {fleshy = 6, fire = 1},
2016-04-15 16:00:45 +02:00
},
2021-01-28 15:38:57 +01:00
groups = {pickaxe = 1},
light_source = 14
2016-04-15 16:00:45 +02:00
})
2024-08-10 15:39:51 +02:00
-- recipe
2016-04-15 16:00:45 +02:00
minetest.register_craft({
output = "mobs:pick_lava",
recipe = {
{"mobs:lava_orb", "mobs:lava_orb", "mobs:lava_orb"},
{"", "default:obsidian_shard", ""},
2021-06-14 10:38:32 +02:00
{"", "default:obsidian_shard", ""}
2016-04-15 16:00:45 +02:00
}
})
2017-07-28 09:46:48 +02:00
2024-08-10 15:39:51 +02:00
-- Add [toolranks] mod support
2017-07-28 09:46:48 +02:00
if minetest.get_modpath("toolranks") then
2024-08-10 15:39:51 +02:00
minetest.override_item("mobs:pick_lava", {
original_description = S("Lava Pickaxe"),
2024-08-10 15:39:51 +02:00
description = toolranks.create_description("Lava Pickaxe", 0, 1),
after_use = toolranks.new_afteruse})
2017-07-28 09:46:48 +02:00
end
2020-06-19 21:26:21 +02:00
-- obsidian flan
mobs:register_mob("mobs_monster:obsidian_flan", {
type = "monster",
passive = false,
attack_type = "shoot",
shoot_interval = 0.5,
shoot_offset = 1.0,
arrow = "mobs_monster:obsidian_arrow",
reach = 2,
damage = 3,
hp_min = 10,
hp_max = 35,
2020-06-19 21:44:52 +02:00
armor = 30,
2020-06-19 21:26:21 +02:00
visual_size = {x = 0.6, y = 0.6},
collisionbox = {-0.3, -0.3, -0.3, 0.3, 0.8, 0.3},
visual = "mesh",
mesh = "zmobs_lava_flan.x",
2024-08-10 15:39:51 +02:00
textures = {{"mobs_obsidian_flan.png"}},
2020-06-19 21:26:21 +02:00
blood_texture = "default_obsidian.png",
makes_footstep_sound = true,
2024-08-10 15:39:51 +02:00
sounds = {random = "mobs_lavaflan"},
2020-06-19 21:26:21 +02:00
walk_velocity = 0.1,
run_velocity = 0.5,
jump = false,
view_range = 10,
floats = 0,
drops = {
{name = "default:obsidian_shard", chance = 1, min = 1, max = 5},
2022-08-11 08:39:25 +02:00
{name = "default:obsidian", chance = 3, min = 0, max = 2}
2020-06-19 21:26:21 +02:00
},
water_damage = 0,
lava_damage = 8,
2021-04-05 09:56:12 +02:00
fire_damage = 0,
2020-06-19 21:26:21 +02:00
light_damage = 0,
animation = {
2024-08-10 15:39:51 +02:00
speed_normal = 15, speed_run = 15,
stand_start = 0, stand_end = 8,
walk_start = 10, walk_end = 18,
run_start = 20, run_end = 28,
punch_start = 20, punch_end = 28
2020-06-19 21:26:21 +02:00
}
})
2024-08-10 15:39:51 +02:00
-- spawn egg
2024-09-15 09:38:31 +02:00
2020-06-19 21:26:21 +02:00
mobs:register_egg("mobs_monster:obsidian_flan", S("Obsidian Flan"),
"default_obsidian.png", 1)
2024-08-10 15:39:51 +02:00
-- obsidian arrow and grief setting check
2020-06-19 21:26:21 +02:00
local mobs_griefing = minetest.settings:get_bool("mobs_griefing") ~= false
mobs:register_arrow("mobs_monster:obsidian_arrow", {
visual = "sprite",
visual_size = {x = 0.5, y = 0.5},
textures = {"default_obsidian_shard.png"},
velocity = 6,
hit_player = function(self, player)
2024-08-10 15:39:51 +02:00
2020-06-19 21:26:21 +02:00
player:punch(self.object, 1.0, {
full_punch_interval = 1.0,
damage_groups = {fleshy = 8},
}, nil)
end,
hit_mob = function(self, player)
2024-08-10 15:39:51 +02:00
2020-06-19 21:26:21 +02:00
player:punch(self.object, 1.0, {
full_punch_interval = 1.0,
damage_groups = {fleshy = 8},
}, nil)
end,
hit_node = function(self, pos, node)
if mobs_griefing == false or minetest.is_protected(pos, "") then
return
end
local texture = "default_dirt.png" --fallback texture
local radius = 1
2023-12-04 08:49:50 +01:00
local def = node and minetest.registered_nodes[node.name]
2021-06-14 10:38:32 +02:00
2024-08-10 15:39:51 +02:00
if not def then return end
2021-06-14 10:38:32 +02:00
2020-06-19 21:26:21 +02:00
if def and def.tiles and def.tiles[1] then
texture = def.tiles[1]
end
2020-06-21 21:52:52 +02:00
-- do not break obsidian or diamond blocks or unbreakable nodes
if (def.groups and def.groups.level and def.groups.level > 1)
or def.groups.unbreakable then
2020-06-19 21:26:21 +02:00
return
end
minetest.add_particlespawner({
amount = 32,
time = 0.1,
minpos = vector.subtract(pos, radius / 2),
maxpos = vector.add(pos, radius / 2),
minvel = {x = -3, y = 0, z = -3},
maxvel = {x = 3, y = 5, z = 3},
minacc = {x = 0, y = -10, z = 0},
maxacc = {x = 0, y = -10, z = 0},
minexptime = 0.8,
maxexptime = 2.0,
minsize = radius * 0.33,
maxsize = radius,
texture = texture,
-- ^ only as fallback for clients without support for `node` parameter
node = node,
2021-06-14 10:38:32 +02:00
collisiondetection = true
2020-06-19 21:26:21 +02:00
})
minetest.set_node(pos, {name = "air"})
2020-06-19 21:44:52 +02:00
local snd = def.sounds and def.sounds.dug or "default_dig_crumbly"
2023-12-04 08:49:50 +01:00
minetest.sound_play(snd, {pos = pos, max_hear_distance = 8, gain = 1.0}, true)
2020-06-19 21:26:21 +02:00
end
})