1
0
mirror of https://github.com/Refactorio/RedMew.git synced 2025-01-07 23:02:06 +02:00
RedMew/map_gen/maps/april_fools/modules/unorganized_recipes.lua
RedRafe acc257b8b6
April fools maps (#1404)
* Upload pinguin scenario

* Fix relative path

* Pinguin scenario modularization

* Update enemy_turrets.lua

Added energy interface controls to limit power available to enemy laser turrets, with laser_shots_per_level constant for balancing.

* Update floor_is_lava.lua

Now spawns fire under players when level is half of max.

* Explosion Scare Module

Added explosion_scare module. Chooses players to randomly explode (non-damaging) a number of times before switching to new targets. Explosion intensity increases as module increases.

* Update pinguin.lua

Removed comment block over modules.

* Added New Module: permanent_factory

Has a very small chance to make an entity unminable and undestructible when placed.

* MeteOres

Added new module: MeteOres.
Spawns a random meteor that damages entities, creates ore, and spawns biters.

* Update meteOres.lua

Added explosion to meteor

* Added Auto Build

Added auto_build module. Selects random players, and automatically builds the item in their cursor nearby for a while, before changing targets.

* New module: Unorganized Recipes

Added a new module to hide recipe groups and subgroups for random players. This leads to "unorganized" crafting menus.

* Update auto_build.lua

Fixed typo. I must have changed base targets to 0 instead of the global level when preparing this file for commit.

* Add Biter Ores Module

Add new module. Spawns ores on death of biters, worms, and spawners, based on difficulty of biter and level.

looks for ores on the tile the biter dies on to add to, otherwise looks nearby for an ore type and uses that, otherwise decides on a new ore type to spawn.

This should allow players to set up "farms" for their ores, creating reasonable ore patches.

Contains a RANDOM_ORES constant that will make the search radius small and ensure random ores are placed instead.

* Update biter_ores.lua

Found typo. radius should be .1 not 1 for tile directly beneath biter.

* Updated Existing Modules

Got luacheck setup in my IDE so we don't have to wait for RedMew to run it. Fixed white-space and other linting errors.

* Split AF scenarios

* Add alien biomes module

* Draft april-fools scenarios

* Fix draft issues

---------

Co-authored-by: R. Nukem <Reoisasa@gmail.com>
2024-03-28 23:27:27 +00:00

96 lines
2.6 KiB
Lua

-- hides recipe groups from random players. If a player is targeted again, it will revert back to normal
-- only works with vanilla item-groups.
-- in future possible change to on_init to populate item_groups with all detected item groups?
-- WIP
local Global = require 'utils.global'
local BASE_TARGETS = 1 -- how many targets per level
local CHANGE_TARGET_INTERVAL = _DEBUG and 60 * 10 or 60 * 180 -- 180sec
local _global = {
level = 0, -- 1 to enabled by defualt
max_level = 10,
rand_targets = {},
}
Global.register(_global, function(tbl) _global = tbl end)
-- ============================================================================
local function clear_targets()
for j=1, #_global.rand_targets do
_global.rand_targets[j] = nil
end
end
local function change_targets()
if not (_global and _global.level > 0) then
-- Level not enabled
return
end
local num_targets = math.min(#game.connected_players, _global.level * BASE_TARGETS)
if #game.connected_players > 0 then
for j=1, num_targets do
local player_index = math.random(1, #game.connected_players)
local duplicate = false
--check that randomly selected player is not in old list
for k=1, #_global.rand_targets do
if game.connected_players[player_index].name == _global.rand_targets[k].name then
duplicate = true -- target was previously targeted, so enable them and take them off the list
_global.rand_targets[k].enable_recipe_groups()
_global.rand_targets[k].enable_recipe_subgroups()
_global.rand_targets[k] = nil
end
end
if duplicate == false then -- this is a new target
_global.rand_targets[j] = game.connected_players[player_index]
_global.rand_targets[j].disable_recipe_groups()
_global.rand_targets[j].disable_recipe_subgroups()
end
end
end
end
-- ============================================================================
local Public = {}
Public.name = 'Unorganized Recipes'
Public.on_nth_tick = {
[CHANGE_TARGET_INTERVAL] = change_targets,
}
Public.level_increase = function()
_global.level = math.min(_global.level + 1, _global.max_level)
end
Public.level_decrease = function()
_global.rand_targets[_global.level] = nil
_global.level = math.max(_global.level - 1, 0)
end
Public.level_reset = function()
clear_targets()
_global.level = 0
end
Public.level_set = function(val)
clear_targets()
_global.level = val
end
Public.level_get = function()
return _global.level
end
Public.max_get = function()
return _global.max_level
end
return Public