diff --git a/README.md b/README.md index cfba5c8f..18fa5fb2 100644 --- a/README.md +++ b/README.md @@ -60,7 +60,7 @@ The game includes the mods from the default [minetest_game](https://github.com/m * mobiles/aggressive/ * [mobs_goblins][] ([CC-BY-SA / CC-BY / CC0][lic.mobs_goblins]) -- version: [a346f85 Git][ver.mobs_goblins] *2015-09-12* ([patched][patch.mobs_goblins]) * [mobs_monster][] ([MIT][lic.mobs_monster]) -- version: [f6d0e01 Git][ver.mobs_monster] *2017-04-27* - * [sneeker][] ([WTFPL][lic.wtfpl] / [CC0][lic.cc0]) -- version: [9d7c566 Git][ver.sneeker] *2017-05-28* + * [sneeker][] ([WTFPL][lic.wtfpl] / [CC0][lic.cc0]) -- version: [b69cc98 Git][ver.sneeker] *2017-05-29* * [spidermob][] ([LGPL][lic.lgpl2.1] / [CC BY-SA][lic.ccbysa3.0] / [MIT][lic.mit] / [WTFPL][lic.spidermob] / [Unlicense][lic.unlicense]) -- version [c72d2ff Git][ver.spidermob] *2016-08-14* ([patched][patch.spidermob]) * mobiles/engine/ * mobiles/general/ @@ -342,7 +342,7 @@ The game includes the mods from the default [minetest_game](https://github.com/m [lic.mobf]: mods/modpacks/mobf_core/License.txt [lic.mobs_goblins]: mods/mobiles/aggressive/mobs_goblins/README.md [lic.mobs_monster]: mods/mobiles/aggressive/mobs_monster/license.txt -[lic.mobs_redo]: mods/mobiles/general/mobs_redo/license.txt +[lic.mobs_redo]: mods/mobiles/engine/mobs_redo/license.txt [lic.moreblocks]: mods/buildings/moreblocks/LICENSE.md [lic.moreores]: mods/materials/moreores/LICENSE.md [lic.mydoors]: mods/modpacks/mydoors/README.md @@ -459,7 +459,7 @@ The game includes the mods from the default [minetest_game](https://github.com/m [ver.rainbow_ore]: https://github.com/FsxShader2012/rainbow_ore/tree/6e77693 [ver.signs_lib]: https://github.com/minetest-mods/signs_lib/tree/2c36937 [ver.simple_protection]: https://github.com/SmallJoker/simple_protection/tree/23c024f -[ver.sneeker]: https://github.com/AntumDeluge/mtmod-sneeker/tree/9d7c566 +[ver.sneeker]: https://github.com/AntumDeluge/mtmod-sneeker/tree/b69cc98 [ver.snowdrift]: https://github.com/paramat/snowdrift/tree/fcb0537 [ver.spawneggs]: https://github.com/thefamilygrog66/spawneggs/tree/4650370 [ver.spectator_mode]: https://github.com/minetest-mods/spectator_mode/tree/7d68bec diff --git a/minetest.conf b/minetest.conf index 5ba72fa0..247d8d3c 100644 --- a/minetest.conf +++ b/minetest.conf @@ -1769,19 +1769,24 @@ sneeker.debug = true # Sets maximum number of spawns that can exist in world. # type: int -# default: 50 -#sneeker.spawn_cap = 50 +# default: 25 +#sneeker.spawn_cap = 25 # Sets possibility for sneeker mob spawn. # type: int -# default: 18000 -#sneeker.spawn_chance = 18000 +# default: 2 +#sneeker.spawn_chance = 2 # Sets frequency of sneeker mob spawn chance. Default 1200 is # equivalent to 40 minutes (60 * 40). # type: int # default: 2400 -#sneeker.spawn_interval = 2400 +#sneeker.spawn_interval = 120 + +# Sets the maximum light that a node can have for spawn to occur. +# type: int +# default: 7 +#sneeker.spawn_maxlight = 7 diff --git a/mods/mobiles/aggressive/sneeker/functions.lua b/mods/mobiles/aggressive/sneeker/functions.lua index a263c418..f9d55daf 100644 --- a/mods/mobiles/aggressive/sneeker/functions.lua +++ b/mods/mobiles/aggressive/sneeker/functions.lua @@ -1,14 +1,30 @@ -- Functions for sneeker mod +local log_mods = minetest.setting_getbool('log_mods') + + -- Displays a message in log output function sneeker.log(message) - minetest.log('action', '[' .. sneeker.modname .. '] ' .. message) + if log_mods then + minetest.log('action', '[' .. sneeker.modname .. '] ' .. message) + end end -- Displays a message in log output only if 'sneeker.debug' is set to 'true' function sneeker.log_debug(message) if sneeker.debug then - sneeker.log('[DEBUG] ' .. message) + sneeker.log('DEBUG: ' .. message) end end + +-- Spawns a sneeker entity +function sneeker.spawn(pos) + minetest.add_entity(pos, sneeker.mob_name) + sneeker.log_debug('Spawned entity "' .. sneeker.mob_name .. '" at ' .. tostring(pos.x) .. ',' .. tostring(pos.y)) +end + +-- Retrieves pos coordinates in string value +function sneeker.get_pos_string(pos) + return 'x=' .. tostring(pos.x) .. ', y=' .. tostring(pos.y) .. ', z=' .. tostring(pos.z) +end diff --git a/mods/mobiles/aggressive/sneeker/init.lua b/mods/mobiles/aggressive/sneeker/init.lua index cf7dfe4f..21840bef 100644 --- a/mods/mobiles/aggressive/sneeker/init.lua +++ b/mods/mobiles/aggressive/sneeker/init.lua @@ -5,18 +5,19 @@ sneeker = {} sneeker.modname = minetest.get_current_modname() sneeker.modpath = minetest.get_modpath(sneeker.modname) -local log_mods = minetest.setting_getbool('log_mods') - -if log_mods then +if minetest.setting_getbool('log_mods') then minetest.log('action', 'Loading mod "' .. sneeker.modname .. '" ...') end dofile(sneeker.modpath .. '/settings.lua') dofile(sneeker.modpath .. '/functions.lua') -if log_mods then - sneeker.log('Spawn cap: ' .. tostring(sneeker.spawn_cap)) -end +sneeker.log_debug('Debugging is on') + +sneeker.mob_name = sneeker.modname .. ':' .. sneeker.modname +sneeker.spawnegg_name = sneeker.modname .. ':spawnegg' + +sneeker.log('Spawn cap: ' .. tostring(sneeker.spawn_cap)) local scripts = { 'tnt_function', @@ -342,18 +343,18 @@ def.get_staticdata = function(self) }) end -minetest.register_entity('sneeker:sneeker',def) +minetest.register_entity(sneeker.mob_name, def) if minetest.get_modpath('spawneggs') and minetest.get_modpath('tnt') then - minetest.register_craftitem('sneeker:spawnegg',{ + minetest.register_craftitem(sneeker.spawnegg_name, { description = 'Sneeker Spawn Egg', inventory_image = 'sneeker_spawnegg.png', stack_max = 64, - on_place = function(itemstack,placer,pointed_thing) + on_place = function(itemstack, placer, pointed_thing) if pointed_thing.type == 'node' then local pos = pointed_thing.above pos.y = pos.y+1 - minetest.add_entity(pos,'sneeker:sneeker') + minetest.add_entity(pos, sneeker.mob_name) if not minetest.setting_getbool('creative_mode') then itemstack:take_item() end @@ -363,12 +364,12 @@ if minetest.get_modpath('spawneggs') and minetest.get_modpath('tnt') then }) minetest.register_craft({ - output = 'sneeker:spawnegg', + output = sneeker.spawnegg_name, type = 'shapeless', recipe = { 'spawneggs:egg', 'tnt:tnt', }, }) - minetest.register_alias('spawneggs:sneeker', 'sneeker:spawnegg') + minetest.register_alias('spawneggs:sneeker', sneeker.spawnegg_name) end diff --git a/mods/mobiles/aggressive/sneeker/settings.lua b/mods/mobiles/aggressive/sneeker/settings.lua index ec64b9c7..75e5d7e3 100644 --- a/mods/mobiles/aggressive/sneeker/settings.lua +++ b/mods/mobiles/aggressive/sneeker/settings.lua @@ -2,4 +2,9 @@ sneeker.debug = minetest.setting_get('sneeker.debug') or false -sneeker.spawn_cap = minetest.setting_get('sneeker.spawn_cap') or 50 + +-- Maximum number of spawns active at one time +sneeker.spawn_cap = minetest.setting_get('sneeker.spawn_cap') or 25 + +-- Maximum light of node for spawn +sneeker.spawn_maxlight = minetest.setting_get('sneeker.spawn_maxlight') or 7 diff --git a/mods/mobiles/aggressive/sneeker/settingtypes.txt b/mods/mobiles/aggressive/sneeker/settingtypes.txt index 607737ca..d7c8a1b1 100644 --- a/mods/mobiles/aggressive/sneeker/settingtypes.txt +++ b/mods/mobiles/aggressive/sneeker/settingtypes.txt @@ -2,11 +2,14 @@ sneeker.debug (Log debug output) bool false # Sets maximum number of spawns that can exist in world. -sneeker.spawn_cap (Maximum spawns) int 50 +sneeker.spawn_cap (Maximum spawns) int 25 # Sets possibility for spawn. -sneeker.spawn_chance (Spawn chance) int 18000 +sneeker.spawn_chance (Spawn chance) int 2 # Sets frequency of spawn chance. -# Default 1200 is equivalent to 20 minutes (60 * 40). -sneeker.spawn_interval (Spawn interval) int 2400 +# Default 120 is equivalent to 2 minutes (60 * 2). +sneeker.spawn_interval (Spawn interval) int 120 + +# Sets the maximum light that a node can have for spawn to occur. +sneeker.spawn_maxlight (Max light for spawn) int 7 diff --git a/mods/mobiles/aggressive/sneeker/spawn.lua b/mods/mobiles/aggressive/sneeker/spawn.lua index 3e3f153b..fd4e7d21 100644 --- a/mods/mobiles/aggressive/sneeker/spawn.lua +++ b/mods/mobiles/aggressive/sneeker/spawn.lua @@ -5,16 +5,16 @@ local time_min = 60 local time_hr = time_min * 60 local time_day = time_hr * 24 -local spawn_chance = minetest.setting_get('sneeker.spawn_chance') or 18000 -local spawn_interval = minetest.setting_get('sneeker.spawn_interval') or time_min * 40 -- Default interval is 40 minutes +local spawn_chance = minetest.setting_get('sneeker.spawn_chance') or 2 -- 50% chance of spawn +local spawn_interval = minetest.setting_get('sneeker.spawn_interval') or time_min * 2 -- Default interval is 2 minutes -if minetest.setting_getbool('log_mods') then - sneeker.log('Spawn chance: ' .. tostring(spawn_chance) .. ' (1/' .. tostring(spawn_chance) .. ')') - sneeker.log('Spawn interval: ' .. tostring(spawn_interval) .. ' (' .. tostring(spawn_interval/60) .. ' minutes)') -end +local spawn_chance_percent = tostring(math.floor(1 / spawn_chance * 100)) .. '%' + +sneeker.log('Spawn chance: ' .. spawn_chance_percent) +sneeker.log('Spawn interval: ' .. tostring(spawn_interval) .. ' (' .. tostring(spawn_interval/60) .. ' minute(s))') minetest.register_abm({ - nodenames = {'default:dirt_with_grass','default:stone'}, + nodenames = {'default:dirt_with_grass', 'default:stone'}, neighbors = {'air'}, interval = spawn_interval, chance = spawn_chance, @@ -22,19 +22,25 @@ minetest.register_abm({ if active_object_count_wider > 5 then return end + + -- Check light value of node pos.y = pos.y+1 - if not minetest.get_node_light(pos) then - return - end - if minetest.get_node_light(pos) > 5 then - return - end - if minetest.get_node_light(pos) < -1 then + local node_light = minetest.get_node_light(pos) + + -- Debugging spawning + sneeker.log_debug('Node light level at ' .. sneeker.get_pos_string(pos) .. ': ' .. tostring(node_light)) + + if not node_light or node_light > sneeker.spawn_maxlight or node_light < -1 then + sneeker.log_debug('Node not dark enough for spawn') return end + + -- Spawn range if pos.y > 31000 then return end + + -- Node must be touching air if minetest.get_node(pos).name ~= 'air' then return end @@ -42,6 +48,22 @@ minetest.register_abm({ if minetest.get_node(pos).name ~= 'air' then return end - minetest.add_entity(pos,'sneeker:sneeker') + + -- Get total count of sneekers in world + local count = 0 + for I in pairs(minetest.luaentities) do + if minetest.luaentities[I].name == sneeker.mob_name then + count = count + 1 + end + end + + sneeker.log_debug('Current active spawns: ' .. tostring(count) .. '/' .. tostring(sneeker.spawn_cap)) + + if count >= sneeker.spawn_cap then + sneeker.log_debug('Max spawns reached') + return + end + + sneeker.spawn(pos) end }) diff --git a/mods/mobiles/general/mobs_redo/api.lua b/mods/mobiles/engine/mobs_redo/api.lua similarity index 100% rename from mods/mobiles/general/mobs_redo/api.lua rename to mods/mobiles/engine/mobs_redo/api.lua diff --git a/mods/mobiles/general/mobs_redo/api.txt b/mods/mobiles/engine/mobs_redo/api.txt similarity index 100% rename from mods/mobiles/general/mobs_redo/api.txt rename to mods/mobiles/engine/mobs_redo/api.txt diff --git a/mods/mobiles/general/mobs_redo/crafts.lua b/mods/mobiles/engine/mobs_redo/crafts.lua similarity index 100% rename from mods/mobiles/general/mobs_redo/crafts.lua rename to mods/mobiles/engine/mobs_redo/crafts.lua diff --git a/mods/mobiles/general/mobs_redo/depends.txt b/mods/mobiles/engine/mobs_redo/depends.txt similarity index 100% rename from mods/mobiles/general/mobs_redo/depends.txt rename to mods/mobiles/engine/mobs_redo/depends.txt diff --git a/mods/mobiles/general/mobs_redo/description.txt b/mods/mobiles/engine/mobs_redo/description.txt similarity index 100% rename from mods/mobiles/general/mobs_redo/description.txt rename to mods/mobiles/engine/mobs_redo/description.txt diff --git a/mods/mobiles/general/mobs_redo/init.lua b/mods/mobiles/engine/mobs_redo/init.lua similarity index 100% rename from mods/mobiles/general/mobs_redo/init.lua rename to mods/mobiles/engine/mobs_redo/init.lua diff --git a/mods/mobiles/general/mobs_redo/license.txt b/mods/mobiles/engine/mobs_redo/license.txt similarity index 100% rename from mods/mobiles/general/mobs_redo/license.txt rename to mods/mobiles/engine/mobs_redo/license.txt diff --git a/mods/mobiles/general/mobs_redo/lucky_block.lua b/mods/mobiles/engine/mobs_redo/lucky_block.lua similarity index 100% rename from mods/mobiles/general/mobs_redo/lucky_block.lua rename to mods/mobiles/engine/mobs_redo/lucky_block.lua diff --git a/mods/mobiles/general/mobs_redo/mod.conf b/mods/mobiles/engine/mobs_redo/mod.conf similarity index 100% rename from mods/mobiles/general/mobs_redo/mod.conf rename to mods/mobiles/engine/mobs_redo/mod.conf diff --git a/mods/mobiles/general/mobs_redo/mount.lua b/mods/mobiles/engine/mobs_redo/mount.lua similarity index 100% rename from mods/mobiles/general/mobs_redo/mount.lua rename to mods/mobiles/engine/mobs_redo/mount.lua diff --git a/mods/mobiles/general/mobs_redo/readme.MD b/mods/mobiles/engine/mobs_redo/readme.MD similarity index 100% rename from mods/mobiles/general/mobs_redo/readme.MD rename to mods/mobiles/engine/mobs_redo/readme.MD diff --git a/mods/mobiles/general/mobs_redo/sounds/default_punch.ogg b/mods/mobiles/engine/mobs_redo/sounds/default_punch.ogg similarity index 100% rename from mods/mobiles/general/mobs_redo/sounds/default_punch.ogg rename to mods/mobiles/engine/mobs_redo/sounds/default_punch.ogg diff --git a/mods/mobiles/general/mobs_redo/spawner.lua b/mods/mobiles/engine/mobs_redo/spawner.lua similarity index 100% rename from mods/mobiles/general/mobs_redo/spawner.lua rename to mods/mobiles/engine/mobs_redo/spawner.lua diff --git a/mods/mobiles/general/mobs_redo/textures/mob_spawner.png b/mods/mobiles/engine/mobs_redo/textures/mob_spawner.png similarity index 100% rename from mods/mobiles/general/mobs_redo/textures/mob_spawner.png rename to mods/mobiles/engine/mobs_redo/textures/mob_spawner.png diff --git a/mods/mobiles/general/mobs_redo/textures/mobs_blood.png b/mods/mobiles/engine/mobs_redo/textures/mobs_blood.png similarity index 100% rename from mods/mobiles/general/mobs_redo/textures/mobs_blood.png rename to mods/mobiles/engine/mobs_redo/textures/mobs_blood.png diff --git a/mods/mobiles/general/mobs_redo/textures/mobs_blood_transparent.png b/mods/mobiles/engine/mobs_redo/textures/mobs_blood_transparent.png similarity index 100% rename from mods/mobiles/general/mobs_redo/textures/mobs_blood_transparent.png rename to mods/mobiles/engine/mobs_redo/textures/mobs_blood_transparent.png diff --git a/mods/mobiles/general/mobs_redo/textures/mobs_chicken_egg.png b/mods/mobiles/engine/mobs_redo/textures/mobs_chicken_egg.png similarity index 100% rename from mods/mobiles/general/mobs_redo/textures/mobs_chicken_egg.png rename to mods/mobiles/engine/mobs_redo/textures/mobs_chicken_egg.png diff --git a/mods/mobiles/general/mobs_redo/textures/mobs_chicken_egg_overlay.png b/mods/mobiles/engine/mobs_redo/textures/mobs_chicken_egg_overlay.png similarity index 100% rename from mods/mobiles/general/mobs_redo/textures/mobs_chicken_egg_overlay.png rename to mods/mobiles/engine/mobs_redo/textures/mobs_chicken_egg_overlay.png diff --git a/mods/mobiles/general/mobs_redo/textures/mobs_leather.png b/mods/mobiles/engine/mobs_redo/textures/mobs_leather.png similarity index 100% rename from mods/mobiles/general/mobs_redo/textures/mobs_leather.png rename to mods/mobiles/engine/mobs_redo/textures/mobs_leather.png diff --git a/mods/mobiles/general/mobs_redo/textures/mobs_magic_lasso.png b/mods/mobiles/engine/mobs_redo/textures/mobs_magic_lasso.png similarity index 100% rename from mods/mobiles/general/mobs_redo/textures/mobs_magic_lasso.png rename to mods/mobiles/engine/mobs_redo/textures/mobs_magic_lasso.png diff --git a/mods/mobiles/general/mobs_redo/textures/mobs_meat.png b/mods/mobiles/engine/mobs_redo/textures/mobs_meat.png similarity index 100% rename from mods/mobiles/general/mobs_redo/textures/mobs_meat.png rename to mods/mobiles/engine/mobs_redo/textures/mobs_meat.png diff --git a/mods/mobiles/general/mobs_redo/textures/mobs_meat_raw.png b/mods/mobiles/engine/mobs_redo/textures/mobs_meat_raw.png similarity index 100% rename from mods/mobiles/general/mobs_redo/textures/mobs_meat_raw.png rename to mods/mobiles/engine/mobs_redo/textures/mobs_meat_raw.png diff --git a/mods/mobiles/general/mobs_redo/textures/mobs_nametag.png b/mods/mobiles/engine/mobs_redo/textures/mobs_nametag.png similarity index 100% rename from mods/mobiles/general/mobs_redo/textures/mobs_nametag.png rename to mods/mobiles/engine/mobs_redo/textures/mobs_nametag.png diff --git a/mods/mobiles/general/mobs_redo/textures/mobs_net.png b/mods/mobiles/engine/mobs_redo/textures/mobs_net.png similarity index 100% rename from mods/mobiles/general/mobs_redo/textures/mobs_net.png rename to mods/mobiles/engine/mobs_redo/textures/mobs_net.png diff --git a/mods/mobiles/general/mobs_redo/textures/mobs_protector.png b/mods/mobiles/engine/mobs_redo/textures/mobs_protector.png similarity index 100% rename from mods/mobiles/general/mobs_redo/textures/mobs_protector.png rename to mods/mobiles/engine/mobs_redo/textures/mobs_protector.png diff --git a/mods/mobiles/general/mobs_redo/textures/mobs_saddle.png b/mods/mobiles/engine/mobs_redo/textures/mobs_saddle.png similarity index 100% rename from mods/mobiles/general/mobs_redo/textures/mobs_saddle.png rename to mods/mobiles/engine/mobs_redo/textures/mobs_saddle.png diff --git a/mods/mobiles/general/mobs_redo/textures/mobs_shears.png b/mods/mobiles/engine/mobs_redo/textures/mobs_shears.png similarity index 100% rename from mods/mobiles/general/mobs_redo/textures/mobs_shears.png rename to mods/mobiles/engine/mobs_redo/textures/mobs_shears.png diff --git a/mods/mobiles/general/mobs_redo/textures/tnt_smoke.png b/mods/mobiles/engine/mobs_redo/textures/tnt_smoke.png similarity index 100% rename from mods/mobiles/general/mobs_redo/textures/tnt_smoke.png rename to mods/mobiles/engine/mobs_redo/textures/tnt_smoke.png diff --git a/settingtypes.txt b/settingtypes.txt index b4b8c9c3..46b0563a 100644 --- a/settingtypes.txt +++ b/settingtypes.txt @@ -104,14 +104,17 @@ airtanks_wear_in_creative (Air tanks wear out in creative mode) bool true sneeker.debug (Log debug output) bool false # Sets maximum number of spawns that can exist in world. -sneeker.spawn_cap (Maximum spawns) int 50 +sneeker.spawn_cap (Maximum spawns) int 25 # Sets possibility for spawn. -sneeker.spawn_chance (Spawn chance) int 18000 +sneeker.spawn_chance (Spawn chance) int 2 # Sets frequency of spawn chance. -# Default 1200 is equivalent to 20 minutes (60 * 40). -sneeker.spawn_interval (Spawn interval) int 2400 +# Default 120 is equivalent to 2 minutes (60 * 2). +sneeker.spawn_interval (Spawn interval) int 120 + +# Sets the maximum light that a node can have for spawn to occur. +sneeker.spawn_maxlight (Max node light for spawn) int 7 [*Player Visuals]