1
0
mirror of https://github.com/Refactorio/RedMew.git synced 2025-02-09 13:37:05 +02:00
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

105 lines
2.5 KiB
Lua

-- rotten egg, produces pollution. Similar to golden goose
-- SPAWN_INTERVAL and CHANGE_EGGS_INTERVAL should be set to the number of ticks between the event triggering
local Global = require 'utils.global'
local BASE_EGGS = 1 -- how many eggs per level
local SPAWN_INTERVAL = 60 * 5 -- 5sec
local CHANGE_EGGS_INTERVAL = 60 * 101 -- 100sec
local DROP_AMOUNT = 1 -- 60/m ~ 6x mining drills
local _global = {
level = 0, -- 1 to enabled by defualt
max_level = 10,
rand_eggs = {},
}
Global.register(_global, function(tbl) _global = tbl end)
-- ============================================================================
local function clear_eggs()
for j=1, #_global.rand_eggs do
_global.rand_eggs[j] = nil
end
end
local function change_eggs()
if not (_global and _global.level > 0) then
-- Level not enabled
return
end
local num_eggs = _global.level * BASE_EGGS
for j=1, num_eggs do
_global.rand_eggs[j] = nil
end
if #game.connected_players > 0 then
for j=1, num_eggs do
local player_index = math.random(1, #game.connected_players)
_global.rand_eggs[j] = game.connected_players[player_index]
end
end
end
local function eggs_spawn_pollution()
if not (_global and _global.rand_eggs and (#_global.rand_eggs > 0)) then
-- No eggs
return
end
for _, player in pairs(_global.rand_eggs) do
if (player and player.valid) then
local surface = player.surface
local position = player.position
local amount = (_global.level or 1) * DROP_AMOUNT
-- must be extra cautious with surface & players as they may be teleported across temporary surfaces
if (surface and surface.valid and position) then
surface.pollute(position, amount)
end
end
end
end
-- ============================================================================
local Public = {}
Public.name = 'Rotten egg'
Public.on_nth_tick = {
[CHANGE_EGGS_INTERVAL] = change_eggs,
[SPAWN_INTERVAL] = eggs_spawn_pollution,
}
Public.level_increase = function()
_global.level = math.min(_global.level + 1, _global.max_level)
end
Public.level_decrease = function()
_global.rand_eggs[_global.level] = nil
_global.level = math.max(_global.level - 1, 0)
end
Public.level_reset = function()
clear_eggs()
_global.level = 0
end
Public.level_set = function(val)
clear_eggs()
_global.level = val
end
Public.level_get = function()
return _global.level
end
Public.max_get = function()
return _global.max_level
end
return Public