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

119 lines
2.6 KiB
Lua

-- Each ore tile has 1% chance to mutate into another ore (every patch becomes a mixed ore patch)
-- Complete
local Global = require 'utils.global'
local table = require 'utils.table'
local BASE_PERCENT = 0.01
local MAX_RAND = 100
local _global = {
level = 0, --1 to enabled by defualt
max_level = 10,
}
Global.register(_global, function(tbl) _global = tbl end)
local ORES = {
{'iron-ore', 10},
{'copper-ore', 7},
{'stone', 5},
{'coal', 3},
{'uranium-ore', 1},
}
local ALLOWED_DRILLS = {
['burner-mining-drill'] = true,
['electric-mining-drill'] = true,
}
-- ============================================================================
local function on_built_miner(event)
local entity = event.created_entity
if not (entity and entity.valid and entity.name and ALLOWED_DRILLS[entity.name]) then
-- Invalid entity
return
end
if not (_global and _global.level > 0) then
-- Level not enabled
return
end
local surface = entity.surface
local position = entity.position
local radius = entity.prototype.mining_drill_radius
if not (surface and surface.valid) then
-- Invalid surface
return
end
local ore_tiles = surface.find_entities_filtered{
position = position,
radius = radius or 1.5,
type = 'resource',
}
for _, ore in pairs(ore_tiles) do
if (ore and ore.valid) then
local extra_percent = _global.level * BASE_PERCENT
local rand = math.random(0, MAX_RAND)
if rand >= MAX_RAND*(1 - extra_percent) then
local rand_ore = table.get_random_weighted(ORES)
if (rand_ore ~= ore.name) and surface.get_tile(ore.position.x, ore.position.y).collides_with('ground-tile') then
local amount = ore.amount
local ore_position = ore.position
ore.destroy()
surface.create_entity{
name = rand_ore,
amount = amount,
position = ore_position,
}
end
end
end
end
end
-- ============================================================================
local Public = {}
Public.name = 'Magic drills'
Public.events = {
[defines.events.on_robot_built_entity] = on_built_miner,
[defines.events.on_built_entity] = on_built_miner,
}
Public.level_increase = function()
_global.level = math.min(_global.level + 1, _global.max_level)
end
Public.level_decrease = function()
_global.level = math.max(_global.level - 1, 0)
end
Public.level_reset = function()
_global.level = 0
end
Public.level_set = function(val)
_global.level = val
end
Public.level_get = function()
return _global.level
end
Public.max_get = function()
return _global.max_level
end
return Public