From bc75112bf7961e5259e26a9790305a0afa598e29 Mon Sep 17 00:00:00 2001 From: Juraj Vajda Date: Fri, 16 Dec 2016 00:09:41 +0100 Subject: [PATCH] boss env spawner --- spawners_env/api.lua | 6 +- spawners_env/spawners_env.lua | 46 ++++++++--- spawners_mobs/init.lua | 1 + spawners_mobs/mob_balrog.lua | 146 ++++++++++++++++++++++++++------- spawners_mobs/mob_uruk_hai.lua | 4 +- 5 files changed, 157 insertions(+), 46 deletions(-) diff --git a/spawners_env/api.lua b/spawners_env/api.lua index 4bdbfc3..541aeb3 100644 --- a/spawners_env/api.lua +++ b/spawners_env/api.lua @@ -11,7 +11,7 @@ for k, mob_mod in ipairs(ENABLED_MODS) do local mob_egg = nil -- 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}) + 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}) -- use custom egg or create a default egg if mob.egg_name_custom ~= "" then mob_egg = mob.egg_name_custom @@ -77,10 +77,10 @@ function spawners_env.check_around_radius(pos) return player_near end -function spawners_env.check_node_status(pos, mob, night_only) +function spawners_env.check_node_status(pos, mob, night_only, boss) local player_near = spawners_env.check_around_radius(pos) - if player_near then + if player_near or boss then local random_pos = false local min_node_light = 10 local tod = minetest.get_timeofday() * 24000 diff --git a/spawners_env/spawners_env.lua b/spawners_env/spawners_env.lua index 76e3482..d2c8511 100644 --- a/spawners_env/spawners_env.lua +++ b/spawners_env/spawners_env.lua @@ -2,7 +2,7 @@ -- * CREATE ALL SPAWNERS NODES * -- -function spawners_env.create(mob_name, mod_prefix, size, offset, mesh, texture, night_only, sound_custom) +function spawners_env.create(mob_name, mod_prefix, size, offset, mesh, texture, night_only, sound_custom, env, boss) -- -- DUMMY INSIDE THE SPAWNER @@ -68,7 +68,7 @@ function spawners_env.create(mob_name, mod_prefix, size, offset, mesh, texture, is_ground_content = true, groups = {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) + spawners_env.check_for_spawning_timer(pos, mob_name, night_only, mod_prefix, sound_custom, env, boss) return false end, drop = { @@ -110,7 +110,7 @@ function spawners_env.create(mob_name, mod_prefix, size, offset, mesh, texture, is_ground_content = true, groups = {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) + spawners_env.check_for_spawning_timer(pos, mob_name, night_only, mod_prefix, sound_custom, env, boss) return false end, drop = { @@ -143,7 +143,7 @@ function spawners_env.create(mob_name, mod_prefix, size, offset, mesh, texture, } }, on_construct = function(pos) - spawners_env.check_for_spawning_timer(pos, mob_name, night_only, mod_prefix, sound_custom) + spawners_env.check_for_spawning_timer(pos, mob_name, night_only, mod_prefix, sound_custom, env, boss) end, }) @@ -159,7 +159,7 @@ function spawners_env.create(mob_name, mod_prefix, size, offset, mesh, texture, "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) + spawners_env.check_for_spawning_timer(pos, mob_name, night_only, mod_prefix, sound_custom, env, boss) end }) end @@ -167,9 +167,9 @@ end -- -- * check for spawning * -- -function spawners_env.check_for_spawning_timer(pos, mob_name, night_only, mod_prefix, sound_custom) +function spawners_env.check_for_spawning_timer(pos, mob_name, night_only, mod_prefix, sound_custom, env, boss) - local random_pos, waiting = spawners_env.check_node_status(pos, mob_name, night_only) + local random_pos, waiting = spawners_env.check_node_status(pos, mob_name, night_only, boss) local node = minetest.get_node_or_nil(pos) @@ -179,10 +179,20 @@ function spawners_env.check_for_spawning_timer(pos, mob_name, night_only, mod_pr -- 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, 10)) do + for _,obj in ipairs(minetest.get_objects_inside_radius(pos, mobs_check_radius)) do if obj:get_luaentity() ~= nil then @@ -200,14 +210,18 @@ function spawners_env.check_for_spawning_timer(pos, mob_name, night_only, mod_pr end -- print(mob_name.." : "..mobs_counter_table[mob_name]) - + -- enough place to spawn more mobs - if mobs_counter_table[mob_name] < 3 then + 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('!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") @@ -224,8 +238,14 @@ function spawners_env.check_for_spawning_timer(pos, mob_name, night_only, mod_pr minetest.set_node(pos, {name="spawners_env:"..mod_prefix.."_"..mob_name.."_spawner_waiting"}) end end - - minetest.get_node_timer(pos):start(math.random(5, 15)) + -- 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 -- @@ -235,6 +255,6 @@ end 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) + 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 \ No newline at end of file diff --git a/spawners_mobs/init.lua b/spawners_mobs/init.lua index 18a31de..7d93dd4 100644 --- a/spawners_mobs/init.lua +++ b/spawners_mobs/init.lua @@ -14,6 +14,7 @@ if minetest.get_modpath("mobs") then dofile(minetest.get_modpath(MOD_NAME).."/mob_mummy.lua") dofile(minetest.get_modpath(MOD_NAME).."/mob_bunny_evil.lua") dofile(minetest.get_modpath(MOD_NAME).."/mob_uruk_hai.lua") + dofile(minetest.get_modpath(MOD_NAME).."/mob_balrog.lua") dofile(minetest.get_modpath(MOD_NAME).."/nodes_additional.lua") end diff --git a/spawners_mobs/mob_balrog.lua b/spawners_mobs/mob_balrog.lua index 83c3b39..8435f0c 100644 --- a/spawners_mobs/mob_balrog.lua +++ b/spawners_mobs/mob_balrog.lua @@ -1,18 +1,13 @@ -- modified Sand Monster by PilzAdam with Mummy by BlockMen -local mummy_def = { +local balrog_def = { type = "monster", passive = false, rotate = 180, - hp_min = 5, - hp_max = 10, - pathfinding = true, + hp_min = 1000, + hp_max = 1250, + pathfinding = false, attack_type = "dogfight", - shoot_interval = 2, - dogshoot_switch = 1, - dogshoot_count_max = 10, - arrow = "spawners_mobs:black_skull", - shoot_offset = 2, reach = 3, damage = 10, armor = 100, @@ -24,28 +19,123 @@ local mummy_def = { textures = { {"spawners_mobs_balrog.png"}, }, + blood_texture = "fire_basic_flame.png", makes_footstep_sound = true, sounds = { - war_cry = "spawners_mobs_howl", death = "spawners_mobs_howl", attack = "spawners_mobs_stone_death", }, walk_velocity = 1, run_velocity = 3, - view_range = 15, + view_range = 20, jump = true, floats = 1, drops = { - {name = "default:sandstone", chance = 5, min = 1, max = 2}, - {name = "default:sandstonebrick", chance = 5, min = 1, max = 2}, - {name = "spawners_mobs:deco_stone_eye", chance = 25, min = 1, max = 1}, - {name = "spawners_mobs:deco_stone_men", chance = 25, min = 1, max = 1}, - {name = "spawners_mobs:deco_stone_sun", chance = 25, min = 1, max = 1}, + {name = "default:diamondblock", chance = 2, min = 1, max = 4}, + {name = "default:diamondblock", chance = 2, min = 1, max = 4}, + {name = "default:diamondblock", chance = 2, min = 1, max = 4}, + {name = "default:diamondblock", chance = 2, min = 1, max = 4}, + {name = "default:diamondblock", chance = 2, min = 1, max = 4}, + {name = "default:diamondblock", chance = 2, min = 1, max = 4}, + {name = "default:diamondblock", chance = 2, min = 1, max = 4}, + {name = "default:diamondblock", chance = 2, min = 1, max = 4}, + {name = "default:diamondblock", chance = 2, min = 1, max = 4}, + {name = "default:diamondblock", chance = 2, min = 1, max = 4}, + {name = "default:diamond", chance = 2, min = 1, max = 4}, + {name = "default:diamond", chance = 2, min = 1, max = 4}, + {name = "default:diamond", chance = 2, min = 1, max = 4}, + {name = "default:diamond", chance = 2, min = 1, max = 4}, + {name = "default:diamond", chance = 2, min = 1, max = 4}, + {name = "default:diamond", chance = 2, min = 1, max = 4}, + {name = "default:diamond", chance = 2, min = 1, max = 4}, + {name = "default:diamond", chance = 2, min = 1, max = 4}, + {name = "default:diamond", chance = 2, min = 1, max = 4}, + {name = "default:diamond", chance = 2, min = 1, max = 4}, + {name = "default:mese", chance = 2, min = 1, max = 4}, + {name = "default:mese_crystal", chance = 2, min = 1, max = 4}, + {name = "default:mese", chance = 2, min = 1, max = 4}, + {name = "default:mese_crystal", chance = 2, min = 1, max = 4}, + {name = "default:mese", chance = 2, min = 1, max = 4}, + {name = "default:mese_crystal", chance = 2, min = 1, max = 4}, + {name = "default:mese", chance = 2, min = 1, max = 4}, + {name = "default:mese_crystal", chance = 2, min = 1, max = 4}, + {name = "default:mese", chance = 2, min = 1, max = 4}, + {name = "default:mese_crystal", chance = 2, min = 1, max = 4}, + {name = "default:mese", chance = 2, min = 1, max = 4}, + {name = "default:mese_crystal", chance = 2, min = 1, max = 4}, + {name = "default:mese", chance = 2, min = 1, max = 4}, + {name = "default:mese_crystal", chance = 2, min = 1, max = 4}, + {name = "default:mese", chance = 2, min = 1, max = 4}, + {name = "default:mese_crystal", chance = 2, min = 1, max = 4}, + {name = "default:mese", chance = 2, min = 1, max = 4}, + {name = "default:mese_crystal", chance = 2, min = 1, max = 4}, + {name = "default:mese", chance = 2, min = 1, max = 4}, + {name = "default:mese_crystal", chance = 2, min = 1, max = 4}, + {name = "3d_armor:boots_diamond", chance = 2, min = 1, max = 4}, + {name = "3d_armor:chestplate_diamond", chance = 2, min = 1, max = 1}, + {name = "3d_armor:helmet_diamond", chance = 2, min = 1, max = 1}, + {name = "3d_armor:leggings_diamond", chance = 2, min = 1, max = 1}, + {name = "3d_armor:chestplate_diamond", chance = 2, min = 1, max = 1}, + {name = "3d_armor:helmet_diamond", chance = 2, min = 1, max = 1}, + {name = "3d_armor:leggings_diamond", chance = 2, min = 1, max = 1}, + {name = "3d_armor:chestplate_diamond", chance = 2, min = 1, max = 1}, + {name = "3d_armor:helmet_diamond", chance = 2, min = 1, max = 1}, + {name = "3d_armor:leggings_diamond", chance = 2, min = 1, max = 1}, + {name = "3d_armor:chestplate_bronze", chance = 2, min = 1, max = 1}, + {name = "3d_armor:helmet_bronze", chance = 2, min = 1, max = 1}, + {name = "3d_armor:leggings_bronze", chance = 2, min = 1, max = 1}, + {name = "3d_armor:chestplate_bronze", chance = 2, min = 1, max = 1}, + {name = "3d_armor:helmet_bronze", chance = 2, min = 1, max = 1}, + {name = "3d_armor:leggings_bronze", chance = 2, min = 1, max = 1}, + {name = "3d_armor:chestplate_bronze", chance = 2, min = 1, max = 1}, + {name = "3d_armor:helmet_bronze", chance = 2, min = 1, max = 1}, + {name = "3d_armor:leggings_bronze", chance = 2, min = 1, max = 1}, + {name = "3d_armor:chestplate_gold", chance = 2, min = 1, max = 1}, + {name = "3d_armor:helmet_gold", chance = 2, min = 1, max = 1}, + {name = "3d_armor:leggings_gold", chance = 2, min = 1, max = 1}, + {name = "3d_armor:chestplate_gold", chance = 2, min = 1, max = 1}, + {name = "3d_armor:helmet_gold", chance = 2, min = 1, max = 1}, + {name = "3d_armor:leggings_gold", chance = 2, min = 1, max = 1}, + {name = "3d_armor:chestplate_gold", chance = 2, min = 1, max = 1}, + {name = "3d_armor:helmet_gold", chance = 2, min = 1, max = 1}, + {name = "3d_armor:leggings_gold", chance = 2, min = 1, max = 1}, + {name = "obsidianmese:pick", chance = 2, min = 1, max = 1}, + {name = "obsidianmese:sword", chance = 2, min = 1, max = 1}, + {name = "default:pick_diamond", chance = 2, min = 1, max = 1}, + {name = "default:sword_diamond", chance = 2, min = 1, max = 1}, + {name = "default:shovel_diamond", chance = 2, min = 1, max = 1}, + {name = "default:axe_diamond", chance = 2, min = 1, max = 1}, + {name = "default:hoe_diamond", chance = 2, min = 1, max = 1}, + {name = "default:pick_mese", chance = 2, min = 1, max = 1}, + {name = "default:sword_mese", chance = 2, min = 1, max = 1}, + {name = "default:shovel_mese", chance = 2, min = 1, max = 1}, + {name = "default:axe_mese", chance = 2, min = 1, max = 1}, + {name = "default:hoe_mese", chance = 2, min = 1, max = 1}, + {name = "default:pick_bronze", chance = 2, min = 1, max = 1}, + {name = "default:sword_bronze", chance = 2, min = 1, max = 1}, + {name = "default:shovel_bronze", chance = 2, min = 1, max = 1}, + {name = "default:axe_bronze", chance = 2, min = 1, max = 1}, + {name = "default:hoe_bronze", chance = 2, min = 1, max = 1}, + {name = "farming:bread", chance = 2, min = 1, max = 3}, + {name = "farming:bread", chance = 2, min = 1, max = 3}, + {name = "farming:bread", chance = 2, min = 1, max = 3}, + {name = "farming:bread", chance = 2, min = 1, max = 3}, + {name = "farming:bread", chance = 2, min = 1, max = 3}, + {name = "farming:bread", chance = 2, min = 1, max = 3}, + {name = "farming:bread", chance = 2, min = 1, max = 3}, + {name = "farming:bread", chance = 2, min = 1, max = 3}, + {name = "farming:bread", chance = 2, min = 1, max = 3}, + {name = "farming:bread", chance = 2, min = 1, max = 3}, + {name = "obsidianmese:mese_apple", chance = 2, min = 1, max = 3}, + {name = "obsidianmese:mese_apple", chance = 2, min = 1, max = 3}, + {name = "obsidianmese:mese_apple", chance = 2, min = 1, max = 3}, + {name = "obsidianmese:mese_apple", chance = 2, min = 1, max = 3}, + {name = "obsidianmese:mese_apple", chance = 2, min = 1, max = 3}, }, water_damage = 0, lava_damage = 0, light_damage = 0, - fear_height = 4, + fear_height = 3, animation = { stand_start = 0, stand_end = 240, @@ -58,16 +148,16 @@ local mummy_def = { }, } -mobs:register_mob("spawners_mobs:balrog", mummy_def) +mobs:register_mob("spawners_mobs:balrog", balrog_def) -mobs:spawn({ - name = "spawners_mobs:balrog", - nodes = {"default:desert_sand", "default:desert_stone", "default:sand", "default:sandstone", "default:silver_sand"}, - min_light = 0, - max_light = 20, - chance = 2000, - active_object_count = 2, - day_toggle = false, -}) +-- mobs:spawn({ +-- name = "spawners_mobs:balrog", +-- nodes = {"default:desert_sand", "default:desert_stone", "default:sand", "default:sandstone", "default:silver_sand"}, +-- min_light = 0, +-- max_light = 20, +-- chance = 2000, +-- active_object_count = 2, +-- day_toggle = false, +-- }) -mobs:register_egg("spawners_mobs:balrog", "balrog", "default_sandstone_brick.png", 1) +mobs:register_egg("spawners_mobs:balrog", "balrog", "default_coal_block.png", 1, true) diff --git a/spawners_mobs/mob_uruk_hai.lua b/spawners_mobs/mob_uruk_hai.lua index bab9436..dbbd85a 100644 --- a/spawners_mobs/mob_uruk_hai.lua +++ b/spawners_mobs/mob_uruk_hai.lua @@ -34,9 +34,9 @@ local uruk_hai_def = { jump = true, floats = 1, drops = { - {name = "default:apple", chance = 10, min = 1, max = 2}, + {name = "default:apple", chance = 5, min = 1, max = 2}, {name = "default:wood", chance = 15, min = 1, max = 2}, - {name = "default:stick", chance = 10, min = 1, max = 2}, + {name = "default:stick", chance = 5, min = 1, max = 2}, {name = "default:torch", chance = 10, min = 1, max = 2}, }, water_damage = 0,