From e3b5825b49934f3e8cc91d244dba71a961cbfe63 Mon Sep 17 00:00:00 2001 From: Juraj Vajda Date: Mon, 24 Apr 2023 23:16:05 -0400 Subject: [PATCH] Refresh env spawners --- API.md | 40 +++ README.md | 5 +- spawners_env/api.lua | 258 +++++++++++++++++-- spawners_env/config.lua | 258 ------------------- spawners_env/init.lua | 23 +- spawners_env/mod.conf | 6 +- spawners_env/mod_support_animalia.lua | 148 +++++++++++ spawners_env/mod_support_mobs_animal.lua | 106 ++++++++ spawners_env/mod_support_mobs_monster.lua | 107 ++++++++ spawners_env/mod_support_mobs_redo.lua | 54 ++++ spawners_env/spawners_env.lua | 298 ---------------------- spawners_env/spawners_gen.lua | 17 +- spawners_mobs/api.lua | 25 +- spawners_mobs/config.lua | 89 ++++++- spawners_mobs/mob_balrog.lua | 9 +- spawners_mobs/mod.conf | 2 +- spawners_mobs/spawners_mobs.lua | 2 + 17 files changed, 828 insertions(+), 619 deletions(-) create mode 100644 API.md delete mode 100644 spawners_env/config.lua create mode 100644 spawners_env/mod_support_animalia.lua create mode 100644 spawners_env/mod_support_mobs_animal.lua create mode 100644 spawners_env/mod_support_mobs_monster.lua create mode 100644 spawners_env/mod_support_mobs_redo.lua delete mode 100644 spawners_env/spawners_env.lua diff --git a/API.md b/API.md new file mode 100644 index 0000000..cf45c56 --- /dev/null +++ b/API.md @@ -0,0 +1,40 @@ +# Spawners API + +## Class + +`spawners_env` +`spawners_mobs` + +## Methods + +`register_spawner(name, def)` + +`name` - mob technical name + +`def`: + +`egg_name_custom` string +For `spawners_mobs` only. Deifnes material for recipes. + +`dummy_size` string +Entity size inside the spawner. + +`dummy_offset` string +Entity y offset inside the spawner. + +`dummy_mesh` string +Entity mesh model inside the spawner. + +`dummy_texture` string +Entity mesh texture inside the spawner. + +`night_only` string +true - night only +false - day only +'disable' - day and night + +`sound_custom` string +Sound used when entity spawns. When not defined one will be attempted to generate. + +`boss` string +Boss flag will spawn mob without player near by. Only one mob at the time with ~1 hour intervals. diff --git a/README.md b/README.md index 3436d9c..d3629ab 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,8 @@ # Spawners Modpack # -Adds multiple spawner blocks. There ara no ABM's used and this modpack is developed with focus on the best multiplayer online server performace. -Easy to implement new mob mods just look in to config.lua. +Adds multiple spawner blocks. There ara no ABM's used and this modpack is developed with focus on the best multiplayer online server performance. -Currently it works with [Mobs Redo](https://forum.minetest.net/viewtopic.php?f=11&t=9917) and [Creatures](https://forum.minetest.net/viewtopic.php?f=11&t=8638) but other mob mods can be easily added to config.lua +Currently it works with Animalia, Mobs Animal and Mobs Monster, but other mob mods can be easily added via API. ## Spawners Ores ## diff --git a/spawners_env/api.lua b/spawners_env/api.lua index b17d5e6..3817b1e 100644 --- a/spawners_env/api.lua +++ b/spawners_env/api.lua @@ -1,5 +1,5 @@ --[[ - Adds environmental spawners to the map. When enabled, the spawners will be added to newly generated Dungeons (Uruk Hai) and Temples (Spider). They are dropping a real mob spawner by change (very small chance). + Adds environmental spawners to the map. When enabled, the spawners will be added to newly generated Dungeons and Temples. They are dropping a real mob spawner by change (small chance). Copyright (C) 2016 - 2023 SaKeL This library is free software; you can redistribute it and/or @@ -18,36 +18,240 @@ -- main tables spawners_env = { - ENABLED_MODS = {}, - MOBS_PROPS = {} + registered_spawners_names = {} } -spawners_env.mob_tables = {} +function spawners_env.register_spawner(name, def) + local mod_prefix = name:split(':')[1] + local mob_name = name:split(':')[2] -function spawners_env.register_spawners() - -- check if mods exists and build tables - for k, mob_mod in ipairs(spawners_env.ENABLED_MODS) do - local modpath = minetest.get_modpath(mob_mod) - -- list of mobs and their info - if (modpath) then - for j, mob in ipairs(spawners_env.MOBS_PROPS[mob_mod]) do - -- local mob_egg = nil + -- Entity inside the spawner + local ent_def = { + hp_max = 1, + physical = true, + collisionbox = { 0, 0, 0, 0, 0, 0 }, + visual = def.dummy_visual or 'mesh', + visual_size = def.dummy_size, + mesh = def.dummy_mesh, + textures = def.dummy_texture, + makes_footstep_sound = false, + timer = 0, + automatic_rotate = math.pi * -3, + m_name = 'dummy' + } + local ent_name = 'spawners_env:dummy_' .. mod_prefix .. '_' .. mob_name - -- create only environmental spawners - if mob.env then - table.insert(spawners_env.mob_tables, { name = mob.name, mod_prefix = mob_mod, egg_name_custom = mob.egg_name_custom, dummy_size = mob.dummy_size, dummy_offset = mob.dummy_offset, dummy_mesh = mob.dummy_mesh, dummy_texture = mob.dummy_texture, night_only = mob.night_only, sound_custom = mob.sound_custom, env = mob.env, boss = mob.boss }) + ent_def.on_activate = function(self) + self.object:set_velocity({ x = 0, y = 0, z = 0 }) + self.object:set_acceleration({ x = 0, y = 0, z = 0 }) + self.object:set_armor_groups({ immortal = 1 }) + end - -- use custom egg or create a default egg - -- if mob.egg_name_custom ~= '' then - -- mob_egg = mob.egg_name_custom - -- else - -- mob_egg = mob_mod .. ':' .. mob.name - -- end - end + -- remove dummy after dig the spawner + ent_def.on_step = function(self, dtime) + self.timer = self.timer + dtime + if self.timer > 2 then + local n = minetest.get_node_or_nil(self.object:get_pos()) + if n and n.name ~= 'spawners_env:' .. mod_prefix .. '_' .. mob_name .. '_spawner_active' + then + self.object:remove() end end end + + minetest.register_entity('spawners_env:dummy_' .. mod_prefix .. '_' .. mob_name, ent_def) + + -- Default spawner (inactive) + local node_def = {} + local node_name = 'spawners_env:' .. mod_prefix .. '_' .. mob_name .. '_spawner' + node_def.description = mod_prefix .. '_' .. mob_name .. ' spawner env' + node_def.paramtype = 'light' + node_def.paramtype2 = 'glasslikeliquidlevel' + node_def.drawtype = 'glasslike_framed_optional' + node_def.walkable = true + node_def.sounds = default.node_sound_metal_defaults() + node_def.sunlight_propagates = true + node_def.tiles = { 'spawners_env_spawner_16.png' } + node_def.is_ground_content = true + node_def.groups = { + -- MTG + cracky = 1, + level = 2 + } + node_def.stack_max = 1 + node_def.drop = '' + node_def.on_construct = function(pos) + spawners_env.check_for_spawning_timer(pos, mob_name, def.night_only, mod_prefix, def.sound_custom, def.boss) + end + + local drop_item_name = 'spawners_mobs:' .. mod_prefix .. '_' .. mob_name .. '_spawner' + + if minetest.get_modpath('spawners_mobs') and minetest.registered_nodes[drop_item_name] then + node_def.drop = { + max_items = 1, + items = { + { items = { 'spawners_mobs:' .. mod_prefix .. '_' .. mob_name .. '_spawner' }, rarity = 5 } + } + } + end + + minetest.register_node(node_name, node_def) + + table.insert(spawners_env.registered_spawners_names, node_name) + + -- Waiting spawner + local node_def_waiting = table.copy(node_def) + node_name = 'spawners_env:' .. mod_prefix .. '_' .. mob_name .. '_spawner_waiting' + node_def_waiting.description = mod_prefix .. '_' .. mob_name .. ' spawner waiting env' + node_def_waiting.light_source = 2 + node_def_waiting.tiles = { + { + name = 'spawners_env_spawner_waiting_animated_16.png', + animation = { + type = 'vertical_frames', + aspect_w = 16, + aspect_h = 16, + length = 2.0 + }, + } + } + node_def_waiting.groups = { + -- MTG + cracky = 1, + level = 2, + not_in_creative_inventory = 1 + } + node_def_waiting.on_timer = function(pos, elapsed) + spawners_env.check_for_spawning_timer(pos, mob_name, def.night_only, mod_prefix, def.sound_custom, def.boss) + return false + end + node_def_waiting.on_construct = nil + + minetest.register_node(node_name, node_def_waiting) + + -- Active spawner + local node_def_active = table.copy(node_def) + node_name = 'spawners_env:' .. mod_prefix .. '_' .. mob_name .. '_spawner_active' + node_def_active.description = mod_prefix .. '_' .. mob_name .. ' spawner active env' + node_def_active.light_source = 4 + node_def_active.damage_per_second = 4 + node_def_active.tiles = { + { + name = 'spawners_env_spawner_animated_16.png', + animation = { + type = 'vertical_frames', + aspect_w = 16, + aspect_h = 16, + length = 2.0 + }, + } + } + node_def_active.groups = { + -- MTG + cracky = 1, + level = 2, + igniter = 1, + not_in_creative_inventory = 1 + } + node_def_active.on_timer = function(pos, elapsed) + spawners_env.check_for_spawning_timer(pos, mob_name, def.night_only, mod_prefix, def.sound_custom, def.boss) + return false + end + node_def_active.on_construct = function(pos) + pos.y = pos.y + def.dummy_offset + minetest.add_entity(pos, ent_name) + end + + minetest.register_node(node_name, node_def_active) + + -- + -- * LBM * + -- + + minetest.register_lbm({ + name = 'spawners_env:check_for_spawning_timer_' .. mob_name, + nodenames = { + 'spawners_env:' .. mod_prefix .. '_' .. mob_name .. '_spawner', + 'spawners_env:' .. mod_prefix .. '_' .. mob_name .. '_spawner_active', + 'spawners_env:' .. mod_prefix .. '_' .. mob_name .. '_spawner_waiting' + }, + action = function(pos) + spawners_env.check_for_spawning_timer(pos, mob_name, def.night_only, mod_prefix, def.sound_custom, def.boss) + end + }) +end + +-- +-- Check for spawning +-- +function spawners_env.check_for_spawning_timer(pos, mob_name, night_only, mod_prefix, sound_custom, boss) + local random_pos = spawners_env.check_node_status(pos, mob_name, night_only, boss) + local node = minetest.get_node_or_nil(pos) + + -- minetest.log('action', '[Mod][Spawners] checking for: ' .. mob_name .. ' at ' .. minetest.pos_to_string(pos)) + + if random_pos and node then + -- print('try to spawn another mob at: ' .. minetest.pos_to_string(random_pos)) + local mobs_counter_table = {} + local mobs_check_radius = 10 + local mobs_max = 3 + mobs_counter_table[mob_name] = 0 + + if boss then + mobs_max = 1 + mobs_check_radius = 35 + end + + -- collect all spawned mobs around area + for _, obj in ipairs(minetest.get_objects_inside_radius(pos, mobs_check_radius)) do + if obj:get_luaentity() then + -- get entity name + local name_split = string.split(obj:get_luaentity().name, ':') + + if name_split[2] == mob_name then + mobs_counter_table[mob_name] = mobs_counter_table[mob_name] + 1 + end + end + end + + -- print(mob_name .. ' : ' .. mobs_counter_table[mob_name]) + + -- enough place to spawn more mobs + if mobs_counter_table[mob_name] < mobs_max then + -- make sure the right node status is shown + if node.name ~= 'spawners_env:' .. mod_prefix .. '_' .. mob_name .. '_spawner_active' then + minetest.set_node(pos, { name = 'spawners_env:' .. mod_prefix .. '_' .. mob_name .. '_spawner_active' }) + end + + if boss then + minetest.chat_send_all(minetest.colorize('#FF5722', 'Boss ' .. mob_name .. ' has spawned to this World!')) + end + + spawners_env.start_spawning(random_pos, 1, 'spawners_env:' .. mob_name, mod_prefix, sound_custom) + else + -- print('too many mobs: waiting') + -- waiting status + if node.name ~= 'spawners_env:' .. mod_prefix .. '_' .. mob_name .. '_spawner_waiting' then + minetest.set_node(pos, { name = 'spawners_env:' .. mod_prefix .. '_' .. mob_name .. '_spawner_waiting' }) + end + end + + elseif node then + -- print('no random_pos found: waiting') + -- waiting status + if node.name ~= 'spawners_env:' .. mod_prefix .. '_' .. mob_name .. '_spawner_waiting' then + minetest.set_node(pos, { name = 'spawners_env:' .. mod_prefix .. '_' .. mob_name .. '_spawner_waiting' }) + end + end + -- 6 hours = 21600 seconds + -- 4 hours = 14400 seconds + -- 1 hour = 3600 seconds + if boss then + minetest.get_node_timer(pos):start(3600) + else + minetest.get_node_timer(pos):start(math.random(5, 15)) + end end -- start spawning mobs @@ -60,14 +264,15 @@ function spawners_env.start_spawning(pos, how_many, mob_name, mod_prefix, sound_ -- remove 'spawners_env:' from the string local _mob_name = string.sub(mob_name, 14) local sound_name + -- use custom sounds - if sound_custom ~= '' then + if sound_custom and sound_custom ~= '' then sound_name = sound_custom else sound_name = mod_prefix .. '_' .. _mob_name end - if how_many == nil then + if not how_many then how_many = math.random(1, 2) end @@ -79,7 +284,7 @@ function spawners_env.start_spawning(pos, how_many, mob_name, mod_prefix, sound_ if sound_name then minetest.sound_play(sound_name, { pos = pos, - max_hear_distance = 100, + max_hear_distance = 16, gain = 5, }) end @@ -91,9 +296,10 @@ function spawners_env.check_around_radius(pos) local player_near = false local radius = 21 - for _,obj in ipairs(minetest.get_objects_inside_radius(pos, radius)) do + for _, obj in ipairs(minetest.get_objects_inside_radius(pos, radius)) do if obj:is_player() then player_near = true + break end end diff --git a/spawners_env/config.lua b/spawners_env/config.lua deleted file mode 100644 index d103642..0000000 --- a/spawners_env/config.lua +++ /dev/null @@ -1,258 +0,0 @@ ---[[ - Adds environmental spawners to the map. When enabled, the spawners will be added to newly generated Dungeons (Uruk Hai) and Temples (Spider). They are dropping a real mob spawner by change (very small chance). - Copyright (C) 2016 - 2023 SaKeL - - This library is free software; you can redistribute it and/or - modify it pos the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to juraj.vajda@gmail.com ---]] - --- * [name : string] - Name of the mob used in the mod. - --- [egg_name_custom : string] - Custom name for the egg item. If empty default name will be used i.e. 'mobs:chicken'. - --- * [dummy_size : table] - Size of the rotating dummy inside the node. - --- * [dummy_offset : integer] - Offset on Y axis of the dummy inside the node. - --- * [dummy_mesh : string] - Filename of the model used fot he mob. - --- * [dummy_texture : table] - Textures used for the mob. - --- * [night_only : boolean : string] - If true mobs will spawn 'only' during the night or in dark areas, default:true. Writing 'disable' will disable light check and it will spawn in both states (night and day) - --- [sound_custom : string] - Custom name for the sound file name if differ from default: i.e 'mobs_cow'. - --- [*] -> MANDATORY - has to be filled in! - --- mods what should be enabled and loded, remove/add the one you want to load -spawners_env.ENABLED_MODS = { 'mobs', 'creatures' } - --- mobs properties - setup all you mobs here -spawners_env.MOBS_PROPS = { - - ['mobs'] = { -- MOBS REDO CONFIG - { - name = 'sheep_white', - egg_name_custom = '', - dummy_size = { x = 0.52, y = 0.52 }, - dummy_offset = 0.2, - dummy_mesh = 'mobs_sheep.b3d', - dummy_texture = { 'mobs_sheep_wool.png^mobs_sheep_base.png' }, - night_only = false, - sound_custom = 'mobs_sheep' - }, - { - name = 'cow', - egg_name_custom = '', - dummy_size = { x = 0.3, y = 0.3 }, - dummy_offset = -0.3, - dummy_mesh = 'mobs_cow.x', - dummy_texture = { 'mobs_cow.png' }, - night_only = false, - sound_custom = '' - }, - { - name = 'chicken', - egg_name_custom = '', - dummy_size = { x = 0.9, y = 0.9 }, - dummy_offset = 0.2, - dummy_mesh = 'mobs_chicken.x', - dummy_texture = { 'mobs_chicken.png', 'mobs_chicken.png', 'mobs_chicken.png', 'mobs_chicken.png', 'mobs_chicken.png', 'mobs_chicken.png', 'mobs_chicken.png', 'mobs_chicken.png', 'mobs_chicken.png' }, - night_only = false, - sound_custom = '' - }, - { - name = 'pumba', - egg_name_custom = '', - dummy_size = { x = 0.62, y = 0.62 }, - dummy_offset = -0.3, - dummy_mesh = 'mobs_pumba.x', - dummy_texture = { 'mobs_pumba.png' }, - night_only = false, - sound_custom = 'mobs_pig' - }, - -- { - -- name = 'bunny', - -- egg_name_custom = '', - -- dummy_size = { x = 1, y = 1}, - -- dummy_offset = 0.2, - -- dummy_mesh = 'mobs_bunny.b3d', - -- dummy_texture = { 'mobs_bunny_brown.png' }, - -- night_only = false, - -- sound_custom = 'spawners_mobs_bunny' - -- }, - -- { - -- name = 'kitten', - -- egg_name_custom = '', - -- dummy_size = { x = 0.32, y = 0.32}, - -- dummy_offset = 0, - -- dummy_mesh = 'mobs_kitten.b3d', - -- dummy_texture = { 'mobs_kitten_ginger.png' }, - -- night_only = false, - -- sound_custom = '' - -- }, - { - name = 'spider', - egg_name_custom = '', - dummy_size = { x = 2, y = 2 }, - dummy_offset = -0.2, - dummy_mesh = 'mobs_spider.x', - dummy_texture = { 'mobs_spider.png' }, - night_only = true, - env = true, - sound_custom = 'mobs_spider_neutral' - }, - { - name = 'stone_monster', - egg_name_custom = '', - dummy_size = { x = 0.5, y = 0.5 }, - dummy_offset = 0.05, - dummy_mesh = 'mobs_stone_monster.b3d', - dummy_texture = { 'mobs_stone_monster.png' }, - night_only = true, - sound_custom = 'mobs_stonemonster_neutral' - }, - { - name = 'oerkki', - egg_name_custom = '', - dummy_size = { x = 0.5, y = 0.5 }, - dummy_offset = 0.05, - dummy_mesh = 'mobs_oerkki.b3d', - dummy_texture = { 'mobs_oerkki.png' }, - night_only = true, - sound_custom = '' - }, - { - name = 'tree_monster', - egg_name_custom = '', - dummy_size = { x = 0.4, y = 0.4 }, - dummy_offset = 0.05, - dummy_mesh = 'mobs_tree_monster.b3d', - dummy_texture = { 'mobs_tree_monster.png' }, - night_only = true, - sound_custom = 'mobs_treemonster_neutral' - } - }, - - ['creatures'] = { -- CREATURES MOD CONFIG - { - name = 'chicken', - egg_name_custom = 'creatures:chicken_spawn_egg', - dummy_size = { x = 0.9, y = 0.9 }, - dummy_offset = -0.3, - dummy_mesh = 'creatures_chicken.b3d', - dummy_texture = { 'creatures_chicken.png' }, - night_only = false, - sound_custom = '' - }, - { - name = 'ghost', - egg_name_custom = 'creatures:ghost_spawn_egg', - dummy_size = { x = 0.7, y = 0.7 }, - dummy_offset = -0.5, - dummy_mesh = 'creatures_ghost.b3d', - dummy_texture = { 'creatures_ghost.png' }, - night_only = true, - sound_custom = '' - }, - { - name = 'sheep', - egg_name_custom = 'creatures:sheep_spawn_egg', - dummy_size = { x = 0.6, y = 0.6 }, - dummy_offset = -0.3, - dummy_mesh = 'creatures_sheep.b3d', - dummy_texture = { 'creatures_sheep.png^creatures_sheep_white.png' }, - night_only = false, - sound_custom = '' - }, - { - name = 'zombie', - egg_name_custom = 'creatures:zombie_spawn_egg', - dummy_size = { x = 0.5, y = 0.5 }, - dummy_offset = -0.5, - dummy_mesh = 'creatures_zombie.b3d', - dummy_texture = { 'creatures_zombie.png' }, - night_only = false, - sound_custom = '' - }, - { - name = 'oerrki', - egg_name_custom = 'creatures:oerrki_spawn_egg', - dummy_size = { x = 0.4, y = 0.4 }, - dummy_offset = -0.5, - dummy_mesh = 'creatures_oerrki.b3d', - dummy_texture = { 'creatures_oerrki.png' }, - night_only = false, - sound_custom = 'creatures_oerrki_idle' - } - } -} - --- --- check for 3rd party dependencies --- - --- include mummy mobs redo addon (spawner) -if minetest.get_modpath('mobs') ~= nil then - -- enable spawner - table.insert(spawners_env.ENABLED_MODS, 'spawners_mobs') - - -- configure spawner - spawners_env.MOBS_PROPS['spawners_mobs'] = { - { - name = 'mummy', - egg_name_custom = '', - dummy_size = { x = 0.4, y = 0.4 }, - dummy_offset = 0, - dummy_mesh = 'spawners_mobs_mummy.b3d', - dummy_texture = { 'spawners_mobs_mummy.png' }, - night_only = true, - sound_custom = 'spawners_mobs_mummy_neutral' - }, - { - name = 'bunny_evil', - egg_name_custom = '', - dummy_size = { x = 1, y = 1 }, - dummy_offset = 0.2, - dummy_mesh = 'spawners_mobs_evil_bunny.b3d', - dummy_texture = { 'spawners_mobs_evil_bunny.png' }, - night_only = true, - sound_custom = 'spawners_mobs_bunny' - }, - { - name = 'uruk_hai', - egg_name_custom = '', - dummy_size = { x = 0.5, y = 0.5 }, - dummy_offset = 0, - dummy_mesh = 'spawners_mobs_character.b3d', - dummy_texture = { 'spawners_mobs_uruk_hai.png', 'spawners_mobs_trans.png', 'spawners_mobs_galvornsword.png', 'spawners_mobs_trans.png' }, - night_only = true, - sound_custom = 'spawners_mobs_uruk_hai_neutral', - env = true - }, - { - name = 'balrog', - egg_name_custom = '', - dummy_size = { x = 0.2, y = 0.2 }, - dummy_offset = 0, - dummy_mesh = 'spawners_mobs_balrog.b3d', - dummy_texture = { 'spawners_mobs_balrog.png' }, - night_only = 'disable', - sound_custom = 'spawners_mobs_balrog_neutral', - env = true, - boss = true - } - } -end - -spawners_env.register_spawners() diff --git a/spawners_env/init.lua b/spawners_env/init.lua index 0d5b969..37011d2 100644 --- a/spawners_env/init.lua +++ b/spawners_env/init.lua @@ -1,5 +1,5 @@ --[[ - Adds environmental spawners to the map. When enabled, the spawners will be added to newly generated Dungeons (Uruk Hai) and Temples (Spider). They are dropping a real mob spawner by change (very small chance). + Adds environmental spawners to the map. When enabled, the spawners will be added to newly generated Dungeons and Temples. They are dropping a real mob spawner by change (small chance). Copyright (C) 2016 - 2023 SaKeL This library is free software; you can redistribute it and/or @@ -22,11 +22,24 @@ local path = minetest.get_modpath('spawners_env') -- API dofile(path .. '/api.lua') --- Spawners configurations -dofile(path .. '/config.lua') +-- Register spawners +if minetest.get_modpath('animalia') then + dofile(path .. '/mod_support_animalia.lua') +end --- Spawners for mobs -dofile(path .. '/spawners_env.lua') +if minetest.get_modpath('mobs') then + dofile(path .. '/mod_support_mobs_redo.lua') +end + +if minetest.get_modpath('mobs_animal') then + dofile(path .. '/mod_support_mobs_animal.lua') +end + +if minetest.get_modpath('mobs_monster') then + dofile(path .. '/mod_support_mobs_monster.lua') +end + +-- Generate spawners in the World dofile(path .. '/spawners_gen.lua') local mod_end_time = (minetest.get_us_time() - mod_start_time) / 1000000 diff --git a/spawners_env/mod.conf b/spawners_env/mod.conf index ff3dba6..2c7b202 100644 --- a/spawners_env/mod.conf +++ b/spawners_env/mod.conf @@ -1,6 +1,6 @@ name = spawners_env -description = Adds environmental spawners to the map. When enabled, the spawners will be added to newly generated Dungeons (Uruk Hai) and Temples (Spider). They are dropping a real mob spawner by change (very small chance). -depends = default, mobs -optional_depends = creatures +description = Adds environmental spawners to the map. When enabled, the spawners will be added to newly generated Dungeons and Temples. They are dropping a real mob spawner by change (small chance). +depends = default +optional_depends = mobs_animal, mobs_monster, animalia, spawners_mobs supported_games = min_minetest_version = 5.4 diff --git a/spawners_env/mod_support_animalia.lua b/spawners_env/mod_support_animalia.lua new file mode 100644 index 0000000..21cbc22 --- /dev/null +++ b/spawners_env/mod_support_animalia.lua @@ -0,0 +1,148 @@ +--[[ + Adds environmental spawners to the map. When enabled, the spawners will be added to newly generated Dungeons and Temples. They are dropping a real mob spawner by change (small chance). + Copyright (C) 2016 - 2023 SaKeL + + This library is free software; you can redistribute it and/or + modify it pos the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to juraj.vajda@gmail.com +--]] + +spawners_env.register_spawner('animalia:chicken', { + dummy_size = { x = 7, y = 7 }, + dummy_offset = -0.3, + dummy_mesh = 'animalia_chicken.b3d', + dummy_texture = { 'animalia_chicken_1.png' }, + night_only = false, + sound_custom = 'animalia_chicken' +}) + +spawners_env.register_spawner('animalia:cow', { + dummy_size = { x = 3, y = 3 }, + dummy_offset = -0.3, + dummy_mesh = 'animalia_cow.b3d', + dummy_texture = { 'animalia_cow_1.png' }, + night_only = false, + sound_custom = 'animalia_cow' +}) + +spawners_env.register_spawner('animalia:fox', { + dummy_size = { x = 7, y = 7 }, + dummy_offset = -0.3, + dummy_mesh = 'animalia_fox.b3d', + dummy_texture = { 'animalia_fox_1.png' }, + night_only = false, + sound_custom = 'animalia_fox' +}) + +spawners_env.register_spawner('animalia:horse', { + dummy_size = { x = 2.5, y = 2.5 }, + dummy_offset = -0.3, + dummy_mesh = 'animalia_horse.b3d', + dummy_texture = { 'animalia_horse_1.png' }, + night_only = false, + sound_custom = 'animalia_horse' +}) + +spawners_env.register_spawner('animalia:frog', { + dummy_size = { x = 7, y = 7 }, + dummy_offset = -0.3, + dummy_mesh = 'animalia_frog.b3d', + dummy_texture = { 'animalia_tree_frog.png' }, + night_only = false, + sound_custom = 'animalia_frog' +}) + +spawners_env.register_spawner('animalia:pig', { + dummy_size = { x = 6, y = 6 }, + dummy_offset = -0.3, + dummy_mesh = 'animalia_pig.b3d', + dummy_texture = { 'animalia_pig_1.png' }, + night_only = false, + sound_custom = 'animalia_pig' +}) + +spawners_env.register_spawner('animalia:sheep', { + dummy_size = { x = 4.5, y = 4.5 }, + dummy_offset = -0.3, + dummy_mesh = 'animalia_sheep.b3d', + dummy_texture = { 'animalia_sheep.png^animalia_sheep_wool.png' }, + night_only = false, + sound_custom = 'animalia_sheep' +}) + +spawners_env.register_spawner('animalia:bat', { + dummy_size = { x = 8, y = 8 }, + dummy_offset = -0.1, + dummy_mesh = 'animalia_bat.b3d', + dummy_texture = { 'animalia_bat_1.png' }, + night_only = true, + sound_custom = 'animalia_bat' +}) + +spawners_env.register_spawner('animalia:cat', { + dummy_size = { x = 5.5, y = 5.5 }, + dummy_offset = -0.2, + dummy_mesh = 'animalia_cat.b3d', + dummy_texture = { 'animalia_cat_1.png' }, + night_only = false, + sound_custom = 'animalia_cat' +}) + +spawners_env.register_spawner('animalia:owl', { + dummy_size = { x = 5, y = 5 }, + dummy_offset = -0.3, + dummy_mesh = 'animalia_owl.b3d', + dummy_texture = { 'animalia_owl.png' }, + night_only = true, +}) + +spawners_env.register_spawner('animalia:rat', { + dummy_size = { x = 8, y = 8 }, + dummy_offset = -0.1, + dummy_mesh = 'animalia_rat.b3d', + dummy_texture = { 'animalia_rat_1.png' }, + night_only = false, +}) + +spawners_env.register_spawner('animalia:reindeer', { + dummy_size = { x = 3, y = 3 }, + dummy_offset = -0.3, + dummy_mesh = 'animalia_reindeer.b3d', + dummy_texture = { 'animalia_reindeer.png' }, + night_only = false, +}) + +spawners_env.register_spawner('animalia:song_bird', { + dummy_size = { x = 8, y = 8 }, + dummy_offset = -0.3, + dummy_mesh = 'animalia_bird.b3d', + dummy_texture = { 'animalia_cardinal.png' }, + night_only = false, + sound_custom = 'animalia_cardinal' +}) + +spawners_env.register_spawner('animalia:turkey', { + dummy_size = { x = 4.5, y = 4.5 }, + dummy_offset = -0.3, + dummy_mesh = 'animalia_turkey.b3d', + dummy_texture = { 'animalia_turkey_tom.png' }, + night_only = false, + sound_custom = 'animalia_turkey' +}) + +spawners_env.register_spawner('animalia:wolf', { + dummy_size = { x = 4.5, y = 4.5 }, + dummy_offset = -0.3, + dummy_mesh = 'animalia_wolf.b3d', + dummy_texture = { 'animalia_wolf_1.png' }, + night_only = true, +}) diff --git a/spawners_env/mod_support_mobs_animal.lua b/spawners_env/mod_support_mobs_animal.lua new file mode 100644 index 0000000..7a49a80 --- /dev/null +++ b/spawners_env/mod_support_mobs_animal.lua @@ -0,0 +1,106 @@ +--[[ + Adds environmental spawners to the map. When enabled, the spawners will be added to newly generated Dungeons and Temples. They are dropping a real mob spawner by change (small chance). + Copyright (C) 2016 - 2023 SaKeL + + This library is free software; you can redistribute it and/or + modify it pos the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to juraj.vajda@gmail.com +--]] + +spawners_env.register_spawner('mobs_animal:sheep_white', { + dummy_size = { x = 0.52, y = 0.52 }, + dummy_offset = 0.2, + dummy_mesh = 'mobs_sheep.b3d', + dummy_texture = { 'mobs_sheep_wool.png^mobs_sheep_base.png' }, + night_only = false, + sound_custom = 'mobs_sheep' +}) + +spawners_env.register_spawner('mobs_animal:cow', { + dummy_size = { x = 0.25, y = 0.25 }, + dummy_offset = -0.3, + dummy_mesh = 'mobs_cow.b3d', + dummy_texture = { 'mobs_cow.png' }, + night_only = false, + sound_custom = '' +}) + +spawners_env.register_spawner('mobs_animal:chicken', { + dummy_size = { x = 0.9, y = 0.9 }, + dummy_offset = 0.2, + dummy_mesh = 'mobs_chicken.b3d', + dummy_texture = { 'mobs_chicken.png', 'mobs_chicken.png', 'mobs_chicken.png', 'mobs_chicken.png', 'mobs_chicken.png', 'mobs_chicken.png', 'mobs_chicken.png', 'mobs_chicken.png', 'mobs_chicken.png' }, + night_only = false, + sound_custom = '' +}) + +spawners_env.register_spawner('mobs_animal:pumba', { + dummy_size = { x = 0.62, y = 0.62 }, + dummy_offset = -0.3, + dummy_mesh = 'mobs_pumba.b3d', + dummy_texture = { 'mobs_pumba.png' }, + night_only = false, + sound_custom = 'mobs_pig' +}) + + +spawners_env.register_spawner('mobs_animal:bee', { + dummy_size = { x = 1.5, y = 1.5 }, + dummy_offset = -0.5, + dummy_mesh = 'mobs_bee.b3d', + dummy_texture = { 'mobs_bee.png' }, + night_only = false, + sound_custom = 'mobs_bee' +}) + +spawners_env.register_spawner('mobs_animal:bunny', { + dummy_size = { x = 1, y = 1 }, + dummy_offset = 0.2, + dummy_mesh = 'mobs_bunny.b3d', + dummy_texture = { 'mobs_bunny_white.png' }, + night_only = false, +}) + +spawners_env.register_spawner('mobs_animal:kitten', { + dummy_size = { x = 0.25, y = 0.25 }, + dummy_offset = 0, + dummy_mesh = 'mobs_kitten.b3d', + dummy_texture = { 'mobs_kitten_striped.png' }, + night_only = false, + sound_custom = 'mobs_kitten' +}) + +spawners_env.register_spawner('mobs_animal:panda', { + dummy_size = { x = 0.5, y = 0.5 }, + dummy_offset = 0, + dummy_mesh = 'mobs_panda.b3d', + dummy_texture = { 'mobs_panda.png' }, + night_only = false, + sound_custom = 'mobs_panda' +}) + +spawners_env.register_spawner('mobs_animal:penguin', { + dummy_size = { x = 0.2, y = 0.2 }, + dummy_offset = -0.15, + dummy_mesh = 'mobs_penguin.b3d', + dummy_texture = { 'mobs_penguin.png' }, + night_only = false, +}) + +spawners_env.register_spawner('mobs_animal:rat', { + dummy_size = { x = 0.9, y = 0.9 }, + dummy_offset = 0.8, + dummy_mesh = 'mobs_rat.b3d', + dummy_texture = { 'mobs_rat.png' }, + night_only = false, + sound_custom = 'mobs_rat' +}) diff --git a/spawners_env/mod_support_mobs_monster.lua b/spawners_env/mod_support_mobs_monster.lua new file mode 100644 index 0000000..8b81073 --- /dev/null +++ b/spawners_env/mod_support_mobs_monster.lua @@ -0,0 +1,107 @@ +--[[ + Adds environmental spawners to the map. When enabled, the spawners will be added to newly generated Dungeons and Temples. They are dropping a real mob spawner by change (small chance). + Copyright (C) 2016 - 2023 SaKeL + + This library is free software; you can redistribute it and/or + modify it pos the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to juraj.vajda@gmail.com +--]] + +spawners_env.register_spawner('mobs_monster:spider', { + dummy_size = { x = 0.4, y = 0.4 }, + dummy_offset = 0.1, + dummy_mesh = 'mobs_spider.b3d', + dummy_texture = { 'mobs_spider_orange.png' }, + night_only = true, + sound_custom = 'mobs_spider_neutral' +}) + +spawners_env.register_spawner('mobs_monster:stone_monster', { + dummy_size = { x = 0.5, y = 0.5 }, + dummy_offset = 0.05, + dummy_mesh = 'mobs_stone_monster.b3d', + dummy_texture = { 'mobs_stone_monster.png' }, + night_only = true, + sound_custom = 'mobs_stonemonster_neutral' +}) + +spawners_env.register_spawner('mobs_monster:oerkki', { + dummy_size = { x = 0.4, y = 0.4 }, + dummy_offset = 0.05, + dummy_mesh = 'mobs_oerkki.b3d', + dummy_texture = { 'mobs_oerkki.png' }, + night_only = true, + sound_custom = '' +}) + +spawners_env.register_spawner('mobs_monster:tree_monster', { + dummy_size = { x = 0.4, y = 0.4 }, + dummy_offset = 0.05, + dummy_mesh = 'mobs_tree_monster.b3d', + dummy_texture = { 'mobs_tree_monster.png' }, + night_only = true, + sound_custom = 'mobs_treemonster_neutral' +}) + +spawners_env.register_spawner('mobs_monster:dirt_monster', { + dummy_size = { x = 0.4, y = 0.4 }, + dummy_offset = 0.05, + dummy_mesh = 'mobs_stone_monster.b3d', + dummy_texture = { 'mobs_dirt_monster.png' }, + night_only = true, + sound_custom = 'mobs_dirtmonster' +}) + +spawners_env.register_spawner('mobs_monster:dungeon_master', { + dummy_size = { x = 0.3, y = 0.3 }, + dummy_offset = -0.1, + dummy_mesh = 'mobs_dungeon_master.b3d', + dummy_texture = { 'mobs_dungeon_master.png' }, + night_only = true, + sound_custom = 'mobs_dungeonmaster' +}) + +spawners_env.register_spawner('mobs_monster:land_guard', { + dummy_size = { x = 0.3, y = 0.3 }, + dummy_offset = -0.1, + dummy_mesh = 'mobs_dungeon_master.b3d', + dummy_texture = { 'mobs_land_guard.png' }, + night_only = true, + sound_custom = 'mobs_dungeonmaster' +}) + +spawners_env.register_spawner('mobs_monster:lava_flan', { + dummy_size = { x = 0.4, y = 0.4 }, + dummy_offset = -0.1, + dummy_mesh = 'zmobs_lava_flan.x', + dummy_texture = { 'zmobs_lava_flan.png' }, + night_only = true, + sound_custom = 'mobs_lavaflan' +}) + +spawners_env.register_spawner('mobs_monster:mese_monster', { + dummy_size = { x = 2.5, y = 2.5 }, + dummy_offset = -0.3, + dummy_mesh = 'mobs_mese_monster.b3d', + dummy_texture = { 'mobs_mese_monster_purple.png' }, + night_only = true, + sound_custom = 'mobs_mesemonster' +}) + +spawners_env.register_spawner('mobs_monster:sand_monster', { + dummy_size = { x = 0.4, y = 0.4 }, + dummy_offset = 0.05, + dummy_mesh = 'mobs_sand_monster.b3d', + dummy_texture = { 'mobs_sand_monster.png' }, + night_only = true, + sound_custom = 'mobs_sandmonster' +}) diff --git a/spawners_env/mod_support_mobs_redo.lua b/spawners_env/mod_support_mobs_redo.lua new file mode 100644 index 0000000..e7717d8 --- /dev/null +++ b/spawners_env/mod_support_mobs_redo.lua @@ -0,0 +1,54 @@ +--[[ + Adds environmental spawners to the map. When enabled, the spawners will be added to newly generated Dungeons and Temples. They are dropping a real mob spawner by change (small chance). + Copyright (C) 2016 - 2023 SaKeL + + This library is free software; you can redistribute it and/or + modify it pos the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to juraj.vajda@gmail.com +--]] + +spawners_env.register_spawner('spawners_mobs:mummy', { + dummy_size = { x = 0.4, y = 0.4 }, + dummy_offset = 0, + dummy_mesh = 'spawners_mobs_mummy.b3d', + dummy_texture = { 'spawners_mobs_mummy.png' }, + night_only = true, + sound_custom = 'spawners_mobs_mummy_neutral' +}) + +spawners_env.register_spawner('spawners_mobs:bunny_evil', { + dummy_size = { x = 1, y = 1 }, + dummy_offset = 0.2, + dummy_mesh = 'spawners_mobs_evil_bunny.b3d', + dummy_texture = { 'spawners_mobs_evil_bunny.png' }, + night_only = true, + sound_custom = 'spawners_mobs_bunny' +}) + +spawners_env.register_spawner('spawners_mobs:uruk_hai', { + dummy_size = { x = 0.5, y = 0.5 }, + dummy_offset = 0, + dummy_mesh = 'spawners_mobs_character.b3d', + dummy_texture = { 'spawners_mobs_uruk_hai.png', 'spawners_mobs_trans.png', 'spawners_mobs_galvornsword.png', 'spawners_mobs_trans.png' }, + night_only = true, + sound_custom = 'spawners_mobs_uruk_hai_neutral', +}) + +-- spawners_env.register_spawner('spawners_mobs:balrog', { +-- dummy_size = { x = 0.2, y = 0.2 }, +-- dummy_offset = 0, +-- dummy_mesh = 'spawners_mobs_balrog.b3d', +-- dummy_texture = { 'spawners_mobs_balrog.png' }, +-- night_only = 'disable', +-- sound_custom = 'spawners_mobs_balrog_neutral', +-- boss = true +-- }) diff --git a/spawners_env/spawners_env.lua b/spawners_env/spawners_env.lua deleted file mode 100644 index 893aaf3..0000000 --- a/spawners_env/spawners_env.lua +++ /dev/null @@ -1,298 +0,0 @@ ---[[ - Adds environmental spawners to the map. When enabled, the spawners will be added to newly generated Dungeons (Uruk Hai) and Temples (Spider). They are dropping a real mob spawner by change (very small chance). - Copyright (C) 2016 - 2023 SaKeL - - This library is free software; you can redistribute it and/or - modify it pos the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to juraj.vajda@gmail.com ---]] - --- --- * CREATE ALL SPAWNERS NODES * --- - -function spawners_env.create(mob_name, mod_prefix, size, offset, mesh, texture, night_only, sound_custom, env, boss) - - -- - -- DUMMY INSIDE THE SPAWNER - -- - - local dummy_definition = { - hp_max = 1, - physical = true, - collisionbox = { 0, 0, 0, 0, 0, 0 }, - visual = 'mesh', - visual_size = size, - mesh = mesh, - textures = texture, - makes_footstep_sound = false, - timer = 0, - automatic_rotate = math.pi * -3, - m_name = 'dummy' - } - - dummy_definition.on_activate = function(self) - self.object:set_velocity({ x = 0, y = 0, z = 0 }) - self.object:set_acceleration({ x = 0, y = 0, z = 0 }) - self.object:set_armor_groups({ immortal = 1 }) - end - - -- remove dummy after dug up the spawner - dummy_definition.on_step = function(self, dtime) - self.timer = self.timer + dtime - local n = minetest.get_node_or_nil(self.object:get_pos()) - if self.timer > 2 then - if n and n.name and n.name ~= 'spawners_env:' .. mod_prefix .. '_' .. mob_name .. '_spawner_active' then - self.object:remove() - end - end - end - - minetest.register_entity('spawners_env:dummy_' .. mod_prefix .. '_' .. mob_name, dummy_definition) - - -- - -- ACTIVE SPAWNER ENV - -- - - minetest.register_node('spawners_env:' .. mod_prefix .. '_' .. mob_name .. '_spawner_active', { - description = mod_prefix .. '_' .. mob_name .. ' spawner active env', - paramtype = 'light', - light_source = 4, - paramtype2 = 'glasslikeliquidlevel', - drawtype = 'glasslike_framed_optional', - walkable = true, - sounds = default.node_sound_metal_defaults(), - damage_per_second = 4, - sunlight_propagates = true, - tiles = { - { - name = 'spawners_env_spawner_animated_16.png', - animation = { - type = 'vertical_frames', - aspect_w = 16, - aspect_h = 16, - length = 2.0 - }, - } - }, - is_ground_content = true, - groups = { - -- MTG - cracky = 1, - level = 2, - igniter = 1, - not_in_creative_inventory = 1 - }, - on_timer = function(pos, elapsed) - spawners_env.check_for_spawning_timer(pos, mob_name, night_only, mod_prefix, sound_custom, env, boss) - return false - end, - drop = { - max_items = 1, - items = { - { items = { 'spawners_mobs:' .. mod_prefix .. '_' .. mob_name .. '_spawner' }, rarity = 20 } - } - }, - on_construct = function(pos) - pos.y = pos.y + offset - minetest.add_entity(pos, 'spawners_env:dummy_' .. mod_prefix .. '_' .. mob_name) - end, - }) - - -- - -- WAITING SPAWNER ENV - -- - - -- waiting for light - everything is ok but too much light or not enough light - minetest.register_node('spawners_env:' .. mod_prefix .. '_' .. mob_name .. '_spawner_waiting', { - description = mod_prefix .. '_' .. mob_name .. ' spawner waiting env', - paramtype = 'light', - light_source = 2, - paramtype2 = 'glasslikeliquidlevel', - drawtype = 'glasslike_framed_optional', - walkable = true, - sounds = default.node_sound_metal_defaults(), - sunlight_propagates = true, - tiles = { - { - name = 'spawners_env_spawner_waiting_animated_16.png', - animation = { - type = 'vertical_frames', - aspect_w = 16, - aspect_h = 16, - length = 2.0 - }, - } - }, - is_ground_content = true, - groups = { - -- MTG - cracky = 1, - level = 2, - not_in_creative_inventory = 1 - }, - on_timer = function(pos, elapsed) - spawners_env.check_for_spawning_timer(pos, mob_name, night_only, mod_prefix, sound_custom, env, boss) - return false - end, - drop = { - max_items = 1, - items = { - { items = { 'spawners_mobs:' .. mod_prefix .. '_' .. mob_name .. '_spawner' }, rarity = 20 } - } - }, - }) - - -- - -- INACTIVE SPAWNER (DEFAULT) ENV - -- - - minetest.register_node('spawners_env:' .. mod_prefix .. '_' .. mob_name .. '_spawner', { - description = mod_prefix .. '_' .. mob_name .. ' spawner env', - paramtype = 'light', - paramtype2 = 'glasslikeliquidlevel', - drawtype = 'glasslike_framed_optional', - walkable = true, - sounds = default.node_sound_metal_defaults(), - sunlight_propagates = true, - tiles = { 'spawners_env_spawner_16.png' }, - is_ground_content = true, - groups = { - -- MTG - cracky = 1, - level = 2, - not_in_creative_inventory = 0 - }, - stack_max = 1, - drop = { - max_items = 1, - items = { - { items = { 'spawners_mobs:' .. mod_prefix .. '_' .. mob_name .. '_spawner' }, rarity = 20 } - } - }, - on_construct = function(pos) - spawners_env.check_for_spawning_timer(pos, mob_name, night_only, mod_prefix, sound_custom, env, boss) - end, - }) - - -- - -- * LBM * - -- - - minetest.register_lbm({ - name = 'spawners_env:check_for_spawning_timer', - nodenames = { - 'spawners_env:' .. mod_prefix .. '_' .. mob_name .. '_spawner', - 'spawners_env:' .. mod_prefix .. '_' .. mob_name .. '_spawner_active', - 'spawners_env:' .. mod_prefix .. '_' .. mob_name .. '_spawner_waiting' - }, - action = function(pos) - spawners_env.check_for_spawning_timer(pos, mob_name, night_only, mod_prefix, sound_custom, env, boss) - end - }) -end - --- --- * check for spawning * --- -function spawners_env.check_for_spawning_timer(pos, mob_name, night_only, mod_prefix, sound_custom, env, boss) - - local random_pos = spawners_env.check_node_status(pos, mob_name, night_only, boss) - - local node = minetest.get_node_or_nil(pos) - - -- minetest.log('action', '[Mod][Spawners] checking for: ' .. mob_name .. ' at ' .. minetest.pos_to_string(pos)) - - if random_pos then - -- print('try to spawn another mob at: ' .. minetest.pos_to_string(random_pos)) - - local mobs_counter_table = {} - local mobs_check_radius - local mobs_max - mobs_counter_table[mob_name] = 0 - - if boss then - mobs_max = 1 - mobs_check_radius = 35 - else - mobs_max = 3 - mobs_check_radius = 10 - end - - -- collect all spawned mobs around area - for _, obj in ipairs(minetest.get_objects_inside_radius(pos, mobs_check_radius)) do - - if obj:get_luaentity() ~= nil then - - -- get entity name - local name_split = string.split(obj:get_luaentity().name, ':') - - if name_split[2] == mob_name then - - mobs_counter_table[mob_name] = mobs_counter_table[mob_name] + 1 - - end - - end - - end - - -- print(mob_name .. ' : ' .. mobs_counter_table[mob_name]) - - -- enough place to spawn more mobs - if mobs_counter_table[mob_name] < mobs_max then - -- make sure the right node status is shown - if node.name ~= 'spawners_env:' .. mod_prefix .. '_' .. mob_name .. '_spawner_active' then - minetest.set_node(pos, { name = 'spawners_env:' .. mod_prefix .. '_' .. mob_name .. '_spawner_active' }) - end - - if boss then - -- color: deep orange - minetest.chat_send_all(minetest.colorize('#FF5722', 'Balrog has spawned to this World!')) - end - - spawners_env.start_spawning(random_pos, 1, 'spawners_env:' .. mob_name, mod_prefix, sound_custom) - else - -- print('too many mobs: waiting') - -- waiting status - if node.name ~= 'spawners_env:' .. mod_prefix .. '_' .. mob_name .. '_spawner_waiting' then - minetest.set_node(pos, { name = 'spawners_env:' .. mod_prefix .. '_' .. mob_name .. '_spawner_waiting' }) - end - end - - else - -- print('no random_pos found: waiting') - -- waiting status - if node.name ~= 'spawners_env:' .. mod_prefix .. '_' .. mob_name .. '_spawner_waiting' then - minetest.set_node(pos, { name = 'spawners_env:' .. mod_prefix .. '_' .. mob_name .. '_spawner_waiting' }) - end - end - -- 6 hours = 21600 seconds - -- 4 hours = 14400 seconds - -- 1 hour = 3600 seconds - if boss then - minetest.get_node_timer(pos):start(3600) - else - minetest.get_node_timer(pos):start(math.random(5, 15)) - end -end - --- --- CALL 'CREATE' FOR ALL SPAWNERS --- - -for i, mob_table in ipairs(spawners_env.mob_tables) do - if mob_table then - - spawners_env.create(mob_table.name, mob_table.mod_prefix, mob_table.dummy_size, mob_table.dummy_offset, mob_table.dummy_mesh, mob_table.dummy_texture, mob_table.night_only, mob_table.sound_custom, mob_table.env, mob_table.boss) - end -end diff --git a/spawners_env/spawners_gen.lua b/spawners_env/spawners_gen.lua index d232e74..4f91f0f 100644 --- a/spawners_env/spawners_gen.lua +++ b/spawners_env/spawners_gen.lua @@ -1,5 +1,5 @@ --[[ - Adds environmental spawners to the map. When enabled, the spawners will be added to newly generated Dungeons (Uruk Hai) and Temples (Spider). They are dropping a real mob spawner by change (very small chance). + Adds environmental spawners to the map. When enabled, the spawners will be added to newly generated Dungeons and Temples. They are dropping a real mob spawner by change (small chance). Copyright (C) 2016 - 2023 SaKeL This library is free software; you can redistribute it and/or @@ -43,14 +43,15 @@ local function place_spawner(param) pos.y = pos.y + 1 end - if gen_obj == 'dungeon' then - minetest.set_node(pos, { name = 'spawners_env:spawners_mobs_uruk_hai_spawner' }) - minetest.log('action', '[Spawners] dungeon spawner placed at: ' .. minetest.pos_to_string(pos)) - else - minetest.set_node(pos, { name = 'spawners_env:spawners_mobs_uruk_hai_spawner' }) - minetest.log('action', '[Spawners] temple spawner placed at: ' .. minetest.pos_to_string(pos)) - end + local spawner_name = spawners_env.registered_spawners_names[math.random(1, #spawners_mobs.registered_spawners_names)] + if gen_obj == 'dungeon' then + minetest.set_node(pos, { name = spawner_name }) + minetest.log('action', '[Spawners] dungeon spawner ' .. spawner_name .. ' placed at: ' .. minetest.pos_to_string(pos)) + else + minetest.set_node(pos, { name = spawner_name }) + minetest.log('action', '[Spawners] temple spawner ' .. spawner_name .. ' placed at: ' .. minetest.pos_to_string(pos)) + end end end diff --git a/spawners_mobs/api.lua b/spawners_mobs/api.lua index 6296c64..42d44dc 100644 --- a/spawners_mobs/api.lua +++ b/spawners_mobs/api.lua @@ -19,7 +19,8 @@ -- main tables spawners_mobs = { ENABLED_MODS = {}, - MOBS_PROPS = {} + MOBS_PROPS = {}, + registered_spawners_names = {} } spawners_mobs.mob_tables = {} local max_obj_per_mapblock = tonumber(minetest.settings:get('max_objects_per_block')) @@ -256,6 +257,24 @@ function spawners_mobs.on_timer(pos, elapsed) local sound_custom = mob_table.sound_custom local night_only = mob_table.night_only local max_objects = max_obj_per_mapblock / 4 + local offset = mob_table.dummy_offset + local has_dummy = false + + local objects_inside_radius = minetest.get_objects_inside_radius(pos, 0.5) + + for _, obj in ipairs(objects_inside_radius) do + local lua_ent = obj:get_luaentity() + + if lua_ent then + if lua_ent.name == 'spawners_mobs:dummy_' .. mod_prefix .. '_' .. mob_name then + has_dummy = true + end + end + end + + if not has_dummy and meta:get_string('status') == 'active' then + minetest.add_entity({ x = pos.x, y = pos.y + offset, z = pos.z }, 'spawners_mobs:dummy_' .. mod_prefix .. '_' .. mob_name) + end -- check spawner light local node_light = minetest.get_node_light(pos) @@ -295,7 +314,7 @@ function spawners_mobs.on_timer(pos, elapsed) end -- spawn 2 mobs on 2 different positions by chance - local how_many = math.random(2) + local how_many = math.random(1, 2) local spawn_area_random_pos = {} -- get random spawn position from spawn area @@ -449,7 +468,7 @@ function spawners_mobs.set_status(pos, set_status) if meta_status ~= set_status then -- add dummy entity - minetest.add_entity({ x = pos.x, y = pos.y + offset, z = pos.z },'spawners_mobs:dummy_' .. mod_prefix .. '_' .. mob_name) + minetest.add_entity({ x = pos.x, y = pos.y + offset, z = pos.z }, 'spawners_mobs:dummy_' .. mod_prefix .. '_' .. mob_name) meta:set_string('status', 'active') diff --git a/spawners_mobs/config.lua b/spawners_mobs/config.lua index 04abab4..ffe0ee3 100644 --- a/spawners_mobs/config.lua +++ b/spawners_mobs/config.lua @@ -35,7 +35,7 @@ -- [*] -> MANDATORY - has to be filled in! -- mods what should be enabled and loded, remove/add the one you want to load -spawners_mobs.ENABLED_MODS = { 'mobs', 'creatures' } +spawners_mobs.ENABLED_MODS = { 'mobs', 'creatures', 'animalia' } -- mobs properties - setup all you mobs here spawners_mobs.MOBS_PROPS = { @@ -54,7 +54,7 @@ spawners_mobs.MOBS_PROPS = { { name = 'cow', egg_name_custom = '', - dummy_size = { x = 0.3, y = 0.3 }, + dummy_size = { x = 0.25, y = 0.25 }, dummy_offset = -0.3, dummy_mesh = 'mobs_cow.b3d', dummy_texture = { 'mobs_cow.png' }, @@ -104,10 +104,10 @@ spawners_mobs.MOBS_PROPS = { { name = 'spider', egg_name_custom = '', - dummy_size = { x = 2, y = 2 }, - dummy_offset = -0.2, - dummy_mesh = 'mobs_spider.x', - dummy_texture = { 'mobs_spider.png' }, + dummy_size = { x = 0.4, y = 0.4 }, + dummy_offset = 0.1, + dummy_mesh = 'mobs_spider.b3d', + dummy_texture = { 'mobs_spider_orange.png' }, night_only = true, env = true, sound_custom = 'mobs_spider_neutral' @@ -125,7 +125,7 @@ spawners_mobs.MOBS_PROPS = { { name = 'oerkki', egg_name_custom = '', - dummy_size = { x = 0.5, y = 0.5 }, + dummy_size = { x = 0.4, y = 0.4 }, dummy_offset = 0.05, dummy_mesh = 'mobs_oerkki.b3d', dummy_texture = { 'mobs_oerkki.png' }, @@ -195,6 +195,79 @@ spawners_mobs.MOBS_PROPS = { night_only = false, sound_custom = 'creatures_oerrki_idle' } + }, + + ['animalia'] = { -- MOBS REDO CONFIG + { + name = 'chicken', + egg_name_custom = '', + dummy_size = { x = 7, y = 7 }, + dummy_offset = -0.3, + dummy_mesh = 'animalia_chicken.b3d', + dummy_texture = { 'animalia_chicken_1.png' }, + night_only = false, + sound_custom = 'animalia_chicken' + }, + { + name = 'cow', + egg_name_custom = '', + dummy_size = { x = 3, y = 3 }, + dummy_offset = -0.3, + dummy_mesh = 'animalia_cow.b3d', + dummy_texture = { 'animalia_cow_1.png' }, + night_only = false, + sound_custom = 'animalia_cow' + }, + { + name = 'fox', + egg_name_custom = '', + dummy_size = { x = 7, y = 7 }, + dummy_offset = -0.3, + dummy_mesh = 'animalia_fox.b3d', + dummy_texture = { 'animalia_fox_1.png' }, + night_only = false, + sound_custom = 'animalia_fox' + }, + { + name = 'horse', + egg_name_custom = '', + dummy_size = { x = 2.5, y = 2.5 }, + dummy_offset = -0.3, + dummy_mesh = 'animalia_horse.b3d', + dummy_texture = { 'animalia_horse_1.png' }, + night_only = false, + sound_custom = 'animalia_horse' + }, + { + name = 'frog', + egg_name_custom = '', + dummy_size = { x = 7, y = 7 }, + dummy_offset = -0.3, + dummy_mesh = 'animalia_frog.b3d', + dummy_texture = { 'animalia_tree_frog.png' }, + night_only = false, + sound_custom = 'animalia_frog' + }, + { + name = 'pig', + egg_name_custom = '', + dummy_size = { x = 6, y = 6 }, + dummy_offset = -0.3, + dummy_mesh = 'animalia_pig.b3d', + dummy_texture = { 'animalia_pig_1.png' }, + night_only = false, + sound_custom = 'animalia_pig' + }, + { + name = 'sheep', + egg_name_custom = '', + dummy_size = { x = 4.5, y = 4.5 }, + dummy_offset = -0.3, + dummy_mesh = 'animalia_sheep.b3d', + dummy_texture = { 'animalia_sheep.png^animalia_sheep_wool.png' }, + night_only = false, + sound_custom = 'animalia_sheep' + }, } } @@ -203,7 +276,7 @@ spawners_mobs.MOBS_PROPS = { -- -- include mummy mobs redo addon (spawner) -if minetest.get_modpath('mobs') ~= nil then +if minetest.get_modpath('mobs') ~= nil then -- enable spawner table.insert(spawners_mobs.ENABLED_MODS, 'spawners_mobs') diff --git a/spawners_mobs/mob_balrog.lua b/spawners_mobs/mob_balrog.lua index be5a9b7..37764f0 100644 --- a/spawners_mobs/mob_balrog.lua +++ b/spawners_mobs/mob_balrog.lua @@ -22,10 +22,8 @@ local balrog_def = { type = 'monster', passive = false, rotate = 180, - hp_min = 10, - hp_max = 15, - -- hp_min = 1000, - -- hp_max = 1250, + hp_min = 1000, + hp_max = 1250, pathfinding = false, attack_type = 'dogshoot', shoot_interval = 0.6, @@ -34,8 +32,7 @@ local balrog_def = { shoot_offset = 1, arrow = 'spawners_mobs:balrog_firebolt', reach = 5, - damage = 1, - -- damage = 10, + damage = 10, armor = 100, collisionbox = { -0.8, -2.1, -0.8, 0.8, 2.6, 0.8 }, visual_size = { x = 2, y = 2 }, diff --git a/spawners_mobs/mod.conf b/spawners_mobs/mod.conf index 1227e45..aee47b0 100644 --- a/spawners_mobs/mod.conf +++ b/spawners_mobs/mod.conf @@ -1,6 +1,6 @@ name = spawners_mobs description = Let the player craft Mob Spawners. Mobs are spawning randomly in a short intervals, giving the option of creating mob farms and grinders. depends = default -optional_depends = mobs, creatures, xpanes, fire, bones +optional_depends = mobs_animal, mobs_monster, animalia, xpanes, fire, bones supported_games = min_minetest_version = 5.4 diff --git a/spawners_mobs/spawners_mobs.lua b/spawners_mobs/spawners_mobs.lua index 121013a..7c727e3 100644 --- a/spawners_mobs/spawners_mobs.lua +++ b/spawners_mobs/spawners_mobs.lua @@ -91,6 +91,8 @@ function spawners_mobs.create(mob_table, idx) end }) + table.insert(spawners_mobs.registered_spawners_names, 'spawners_mobs:' .. mod_prefix .. '_' .. mob_name .. '_spawner') + -- -- WAITING SPAWNER --