1
0
mirror of https://github.com/Refactorio/RedMew.git synced 2024-12-12 10:04:40 +02:00

Technology and research restrictions added

This commit is contained in:
SimonFlapse 2019-02-17 23:10:41 +01:00
parent 937cdb5ec5
commit 6d0df6a0fa
4 changed files with 512 additions and 41 deletions

View File

@ -0,0 +1,243 @@
local recipes = {
default = {
recipe = {
['iron-axe'] = true,
['boiler'] = true,
['steam-engine'] = true,
['offshore-pump'] = true,
['stone-furnace'] = true,
['assembling-machine-1'] = true,
['wood'] = true,
['copper-cable'] = true,
['iron-stick'] = true,
['iron-plate'] = true,
['copper-plate'] = true,
['stone-brick'] = true,
['burner-mining-drill'] = true,
['burner-inserter'] = true,
['transport-belt'] = true,
['small-electric-pole'] = true,
['wooden-chest'] = true,
['empty-crude-oil-barrel'] = true,
['empty-heavy-oil-barrel'] = true,
['empty-light-oil-barrel'] = true,
['empty-lubricant-barrel'] = true,
['empty-petroleum-gas-barrel'] = true,
['empty-sulfuric-acid-barrel'] = true,
['empty-water-barrel'] = true,
['medium-electric-pole'] = true,
['pipe'] = true,
['pipe-to-ground'] = true,
['lamp'] = true,
['steel-axe'] = true,
['repair-pack'] = true,
['pistol'] = true,
['firearm-magazine'] = true,
['light-armor'] = true,
['stone-wall'] = true,
['gate'] = true,
['gun-turret'] = true,
['iron-gear-wheel'] = true
}
},
quadrant1 = {
recipe = {
['science-pack-1'] = true,
['military-science-pack'] = true,
['artillery-wagon'] = true,
['car'] = true,
['tank'] = true,
['lab'] = true,
['satellite'] = true,
['submachine-gun'] = true,
['shotgun'] = true,
['combat-shotgun'] = true,
['rocket-launcher'] = true,
['flamethrower'] = true,
['land-mine'] = true,
['piercing-rounds-magazine'] = true,
['uranium-rounds-magazine'] = true,
['shotgun-shells'] = true,
['piercing-shotgun-shells'] = true,
['cannon-shell'] = true,
['explosive-cannon-shell'] = true,
['uranium-cannon-shell'] = true,
['explosive-uranium-cannon-shell'] = true,
['artillery-shell'] = true,
['rocket'] = true,
['explosive-rocket'] = true,
['atomic-bomb'] = true,
['grenade'] = true,
['cluster-grenade'] = true,
['poison-capsule'] = true,
['slowdown-capsule'] = true,
['defender-capsule'] = true,
['distractor-capsule'] = true,
['destroyer-capsule'] = true,
['discharge-defense-remote'] = true,
['artillery-targeting-remote'] = true,
['heavy-armor'] = true,
['modular-armor'] = true,
['power-armor'] = true,
['power-armor-mk2'] = true,
['laser-turret'] = true,
['artillery-turret'] = true,
['radar'] = true,
['energy-shield-equipment'] = true,
['energy-shield-mk2-equipment'] = true,
['battery-equipment'] = true,
['battery-mk2-equipment'] = true,
['personal-laser-defense-equipment'] = true,
['discharge-defense-equipment'] = true,
['night-vision-equipment'] = true,
['railgun'] = true,
['railgun-dart'] = true
}
},
quadrant2 = {
recipe = {
['concrete'] = true,
['hazard-concrete'] = true,
['refined-concrete'] = true,
['refined-hazard-concrete'] = true,
['landfill'] = true,
['electric-mining-drill'] = true,
['solar-panel'] = true,
['accumulator'] = true,
['production-science-pack'] = true,
['low-density-structure'] = true,
['electronic-circuit'] = true,
['advanced-circuit'] = true,
['processing-unit'] = true,
['engine-unit'] = true,
['electric-engine-unit'] = true,
['steel-plate'] = true,
['solar-panel-equipment'] = true,
['science-pack-3'] = true
}
},
quadrant3 = {
recipe = {
['pump'] = true,
['fluid-wagon'] = true,
['red-wire'] = true,
['green-wire'] = true,
['arithmetic-combinator'] = true,
['decider-combinator'] = true,
['constant-combinator'] = true,
['power-switch'] = true,
['programmable-speaker'] = true,
['storage-tank'] = true,
['steam-turbine'] = true,
['nuclear-reactor'] = true,
['heat-exchanger'] = true,
['heat-pipe'] = true,
['pumpjack'] = true,
['electric-furnace'] = true,
['oil-refinery'] = true,
['chemical-plant'] = true,
['centrifuge'] = true,
['beacon'] = true,
['speed-module'] = true,
['speed-module-2'] = true,
['speed-module-3'] = true,
['effectivity-module'] = true,
['effectivity-module-2'] = true,
['effectivity-module-3'] = true,
['productivity-module'] = true,
['productivity-module-2'] = true,
['productivity-module-3'] = true,
['high-tech-science-pack'] = true,
['uranium-fuel-cell'] = true,
['nuclear-fuel-reprocessing'] = true,
['uranium-processing'] = true,
['kovarex-enrichment-process'] = true,
['rocket-control-unit'] = true,
['empty-barrel'] = true,
['fill-crude-oil-barrel'] = true,
['fill-heavy-oil-barrel'] = true,
['fill-light-oil-barrel'] = true,
['fill-lubricant-barrel'] = true,
['fill-petroleum-gas-barrel'] = true,
['fill-sulfuric-acid-barrel'] = true,
['fill-water-barrel'] = true,
['sulfuric-acid'] = true,
['basic-oil-processing'] = true,
['advanced-oil-processing'] = true,
['heavy-oil-cracking'] = true,
['light-oil-cracking'] = true,
['coal-liquefaction'] = true,
['solid-fuel-from-heavy-oil'] = true,
['solid-fuel-from-light-oil'] = true,
['solid-fuel-from-petroleum-gas'] = true,
['lubricant'] = true,
['sulfur'] = true,
['battery'] = true,
['explosives'] = true,
['plastic-bar'] = true,
['cliff-explosives'] = true,
['flamethrower-turret'] = true,
['flamethrower-ammo'] = true,
['flamethrower'] = true,
['fusion-reactor-equipment'] = true,
['rocket-silo'] = true,
['rocket-part'] = true
}
},
quadrant4 = {
recipe = {
['iron-chest'] = true,
['steel-chest'] = true,
['fast-transport-belt'] = true,
['express-transport-belt'] = true,
['fast-underground-belt'] = true,
['express-underground-belt'] = true,
['underground-belt'] = true,
['splitter'] = true,
['fast-splitter'] = true,
['express-splitter'] = true,
['loader'] = true,
['fast-loader'] = true,
['express-loader'] = true,
['inserter'] = true,
['long-handed-inserter'] = true,
['fast-inserter'] = true,
['filter-inserter'] = true,
['stack-inserter'] = true,
['stack-filter-inserter'] = true,
['big-electric-pole'] = true,
['substation'] = true,
['rail'] = true,
['train-stop'] = true,
['rail-signal'] = true,
['rail-chain-signal'] = true,
['locomotive'] = true,
['cargo-wagon'] = true,
['logistic-robot'] = true,
['construction-robot'] = true,
['flying-robot-frame'] = true,
['logistic-chest-active-provider'] = true,
['logistic-chest-passive-provider'] = true,
['logistic-chest-storage'] = true,
['logistic-chest-buffer'] = true,
['logistic-chest-requester'] = true,
['roboport'] = true,
['electric-mining-drill'] = true,
['steel-furnace'] = true,
['assembling-machine-2'] = true,
['assembling-machine-3'] = true,
['science-pack-2'] = true,
['rocket-fuel'] = true,
['nuclear-fuel'] = true,
['exoskeleton-equipment'] = true,
['personal-roboport-equipment'] = true,
['personal-roboport-mk2-equipment'] = true
}
},
}
return recipes

View File

@ -0,0 +1,62 @@
local Event = require 'utils.event'
local Game = require 'utils.game'
local abs = math.abs
local allowed_entities = {
['transport-belt'] = true,
['fast-transport-belt'] = true,
['express-transport-belt'] = true,
['underground-belt'] = true,
['fast-underground-belt'] = true,
['express-underground-belt'] = true,
['splitter'] = true,
['fast-splitter'] = true,
['express-splitter'] = true,
}
local function on_built_entity(event)
local entity = event.created_entity
if not entity or not entity.valid then
return
end
local s_box = entity.selection_box
local size_x = abs(s_box.left_top.x - s_box.right_bottom.x)
local size_y = abs(s_box.left_top.y - s_box.right_bottom.y)
local pos = {x = abs(entity.position.x) - (size_x/2), y = abs(entity.position.y) - (size_y/2)}
if not(pos.x <= 23 or pos.y <= 23) then
return
end
local name = entity.name
local ghost = false
if name == 'entity-ghost' then
name = entity.ghost_name
ghost = true
end
if name == 'tile-ghost' then
return
end
if allowed_entities[name] and not (pos.x < 2 or pos.y < 2) then
return
end
local p = Game.get_player_by_index(event.player_index)
if not p or not p.valid then
return
end
entity.destroy()
if not ghost then
p.insert(event.stack)
end
end
Event.add(defines.events.on_built_entity, on_built_entity)

View File

@ -1,16 +1,116 @@
require 'map_gen.maps.quadrants.switch_team'
require 'map_gen.maps.quadrants.restrict_placement'
local b = require('map_gen.shared.builders')
local Retailer = require('features.retailer')
local market_items = require 'resources.market_items'
local RS = require 'map_gen.shared.redmew_surface'
local Event = require 'utils.event'
local ScenarioInfo = require 'features.gui.info'
local Recipes = require 'map_gen.maps.quadrants.enabled_recipes'
local abs = math.abs
local round = math.round
local redmew_config = global.config
local forces = {}
require 'switch_team'
ScenarioInfo.set_map_name('[WIP] Quadrants')
ScenarioInfo.set_map_description('Teamwork based map')
ScenarioInfo.add_map_extra_info( [[
- Restricted research
- Restricted recipes
- Restricted teleport between quadrants
]]
)
redmew_config.paint.enabled = false
redmew_config.player_create.starting_items = {
{name = 'iron-plate', count = 7},
{name = 'iron-gear-wheel', count = 3}
}
redmew_config.player_create.join_messages = {
'Welcome to this map created by the RedMew team. You can join our discord at: redmew.com/discord',
'Click the question mark in the top left corner for server information and map details.',
'----',
'Quadrants is a different take on a teamwork based map. Be sure to read the map details!',
'--------'
}
local function spawn_market(surface, force, position)
position.y = round(position.y - 4)
position.x = round(position.x)
local pos = surface.find_non_colliding_position('market', position, 10, 1)
local market = surface.create_entity({ name = 'market', position = pos })
market.destructible = false
Retailer.add_market(pos.x .. 'fish_market' .. pos.y, market)
if table.size(Retailer.get_items(pos.x .. 'fish_market' .. pos.y)) == 0 then
for _, prototype in pairs(market_items) do
Retailer.set_item(pos.x .. 'fish_market' .. pos.y, prototype)
end
end
force.add_chart_tag(surface, { icon = { type = 'item', name = 'coin' }, position = pos, text = 'Market' })
end
local function reset_recipes()
for _, force in pairs(forces) do
for _, recipe in pairs(force.recipes) do
if not (Recipes[force.name].recipe[recipe.name] or Recipes.default.recipe[recipe.name]) then
recipe.enabled = false
end
end
end
end
local function on_init()
game.forces.player.set_spawn_position({64, -64}, game.surfaces[1])
local surface = RS.get_surface()
local q1 = game.create_force('quadrant1')
q1.set_spawn_position({ 64, -64 }, surface)
local q2 = game.create_force('quadrant2')
q2.set_spawn_position({ -64, -64 }, surface)
local q3 = game.create_force('quadrant3')
q3.set_spawn_position({ -64, 64 }, surface)
local q4 = game.create_force('quadrant4')
q4.set_spawn_position({ 64, 64 }, surface)
forces = { q1, q2, q3, q4 }
reset_recipes()
for _, force in pairs(forces) do
force.share_chart = true
if force.name ~= 'quadrant1' then
force.disable_research()
end
for _, friend_force in pairs(forces) do
if friend_force ~= force then
force.set_friend(friend_force, true)
end
end
end
end
local function on_research_finished(event)
if event.research.force ~= forces[1] then
return
end
for _, force in pairs(forces) do
if force.name ~= 'quadrant1' then
force.technologies[event.research.name].researched = true
end
end
reset_recipes()
end
Event.on_init(on_init)
Event.add(defines.events.on_research_finished, on_research_finished)
local function quadrants(x, y)
local abs_x = abs(x) - 0.5
@ -18,9 +118,9 @@ local function quadrants(x, y)
if (abs_x <= 200 and abs_y <= 200) then
if game.surfaces[2].get_tile(x, y).collides_with('water-tile') then
game.surfaces[2].set_tiles({{name="grass-1", position={x, y}}}, true)
game.surfaces[2].set_tiles({ { name = "grass-1", position = { x, y } } }, true)
end
local entities = game.surfaces[2].find_entities({{x-0.5, y-0.5}, {x+0.5, y+0.5}})
local entities = game.surfaces[2].find_entities({ { x - 0.5, y - 0.5 }, { x + 0.5, y + 0.5 } })
for _, entity in ipairs(entities) do
if entity.name ~= 'player' then
@ -29,37 +129,51 @@ local function quadrants(x, y)
end
end
if (abs_x >= 112 and abs_x <= 144 and abs_y >= 112 and abs_y <= 144 ) then
game.surfaces[2].set_tiles({{name="water", position={x, y}}}, true)
if (abs_x == 100) and (abs_y == 100) then
spawn_market(RS.get_surface(), game.forces.player, { x = x, y = y })
end
if (abs_x <= 23 or abs_y <= 23) then
if ((abs_y % 4 == 0) or (abs_x % 4 == 0)) then -- Between quadrants create land
game.surfaces[2].set_tiles({{name="tutorial-grid", position={x, y}}}, true)
local entities = game.surfaces[2].find_entities({{x-0.5, y-0.5}, {x+0.5, y+0.5}})
if (abs_x >= 112 and abs_x <= 144 and abs_y >= 112 and abs_y <= 144) then
game.surfaces[2].set_tiles({ { name = "water", position = { x, y } } }, true)
end
for _, entity in ipairs(entities) do
if entity.name ~= 'player' then
entity.destroy()
end
end
if (abs_x <= 2 and abs_y <= 2) then --Spawn
return true
elseif (abs_x <= 23 and abs_y <= 23) and not (abs_x <= 2 and abs_y <= 2) then -- Around spawn, in between the quadrants
return false
elseif ((abs_x <= 1 or abs_x == 8 or abs_x == 9 or abs_x == 16 or abs_x == 17) and abs_y % 4 == 0) or ((abs_y <= 1 or abs_y == 8 or abs_y == 9 or abs_y == 16 or abs_y == 17) and abs_x % 4 == 0) then -- connections
return true
if (abs_x <= 23 or abs_y <= 23) then
-- Between quadrants create land
game.surfaces[2].set_tiles({ { name = "tutorial-grid", position = { x, y } } }, true)
local entities = game.surfaces[2].find_entities({ { x - 0.5, y - 0.5 }, { x + 0.5, y + 0.5 } })
for _, entity in ipairs(entities) do
if entity.name ~= 'player' then
entity.destroy()
end
end
return false
if (abs_x <= 1 and abs_y <= 1) then
if abs_x == 1 and abs_y == 1 then
return false
end
return true
end
if (abs_x <= 23 and abs_y <= 23) then
-- Around spawn, in between the quadrants
return false
end
if (abs_x < 2 or abs_y < 2) then
return false
end
return true
end
return true
end
local rectangle = b.rectangle(32,32)
local rectangle = b.rectangle(32, 32)
local tree_rectangle = b.rectangle(64, 16)
local tree_rectangle_1 = b.throttle_xy(tree_rectangle,1, 3, 1, 3)
local tree_rectangle_2 = b.rotate(tree_rectangle_1, math.pi/2)
local tree_rectangle_1 = b.throttle_xy(tree_rectangle, 1, 3, 1, 3)
local tree_rectangle_2 = b.rotate(tree_rectangle_1, math.pi / 2)
local function constant(x)
return function()
@ -77,26 +191,24 @@ local start_coal = b.resource(rectangle, 'coal', constant(600))
local start_tree_1 = b.entity(tree_rectangle_1, 'tree-01')
local start_tree_2 = b.entity(tree_rectangle_2, 'tree-01')
start_iron = b.combine({b.translate(start_iron, base_x,base_y), b.translate(start_iron, -base_x,-base_y), b.translate(start_iron, base_x,-base_y), b.translate(start_iron, -base_x,base_y)})
start_iron = b.combine({ b.translate(start_iron, base_x, base_y), b.translate(start_iron, -base_x, -base_y), b.translate(start_iron, base_x, -base_y), b.translate(start_iron, -base_x, base_y) })
base_x = base_x + 32
start_copper = b.combine({b.translate(start_copper, base_x,base_y), b.translate(start_copper, -base_x,-base_y), b.translate(start_copper, base_x,-base_y), b.translate(start_copper, -base_x,base_y)})
start_copper = b.combine({ b.translate(start_copper, base_x, base_y), b.translate(start_copper, -base_x, -base_y), b.translate(start_copper, base_x, -base_y), b.translate(start_copper, -base_x, base_y) })
base_y = base_x
start_stone = b.combine({b.translate(start_stone, base_x,base_y), b.translate(start_stone, -base_x,-base_y), b.translate(start_stone, base_x,-base_y), b.translate(start_stone, -base_x,base_y)})
start_stone = b.combine({ b.translate(start_stone, base_x, base_y), b.translate(start_stone, -base_x, -base_y), b.translate(start_stone, base_x, -base_y), b.translate(start_stone, -base_x, base_y) })
base_x = base_x - 32
start_coal = b.combine({b.translate(start_coal, base_x,base_y), b.translate(start_coal, -base_x,-base_y), b.translate(start_coal, base_x,-base_y), b.translate(start_coal, -base_x,base_y)})
start_coal = b.combine({ b.translate(start_coal, base_x, base_y), b.translate(start_coal, -base_x, -base_y), b.translate(start_coal, base_x, -base_y), b.translate(start_coal, -base_x, base_y) })
base_x = 64
base_y = 128
start_tree_1 = b.combine({b.translate(start_tree_1, base_x,base_y), b.translate(start_tree_1, -base_x,-base_y), b.translate(start_tree_1, base_x,-base_y), b.translate(start_tree_1, -base_x,base_y)})
start_tree_1 = b.combine({ b.translate(start_tree_1, base_x, base_y), b.translate(start_tree_1, -base_x, -base_y), b.translate(start_tree_1, base_x, -base_y), b.translate(start_tree_1, -base_x, base_y) })
base_x = 128
base_y = 64
start_tree_2 = b.combine({b.translate(start_tree_2, base_x,base_y), b.translate(start_tree_2, -base_x,-base_y), b.translate(start_tree_2, base_x,-base_y), b.translate(start_tree_2, -base_x,base_y)})
start_tree_2 = b.combine({ b.translate(start_tree_2, base_x, base_y), b.translate(start_tree_2, -base_x, -base_y), b.translate(start_tree_2, base_x, -base_y), b.translate(start_tree_2, -base_x, base_y) })
local map = b.apply_entities(quadrants, {start_iron, start_copper, start_stone, start_coal, start_tree_1, start_tree_2})
local map = b.apply_entities(quadrants, { start_iron, start_copper, start_stone, start_coal, start_tree_1, start_tree_2 })
return map

View File

@ -3,6 +3,7 @@ local Gui = require 'utils.gui'
local Game = require 'utils.game'
local abs = math.abs
local Color = require 'resources.color_presets'
local Popup = require 'features.gui.popup'
local gui = {}
@ -13,11 +14,52 @@ local spawn_locations = {
quadrant_4 = {64, 64}
}
local quadrant_message = {
{
title = 'Research and command center',
msg = [[
Our main objective is to provide the region with new scientific discoveries
Secondary we are the central command hub
We provide the region with military equipment
]]
},
{
title = 'Intermediate production',
msg = [[
Our main objective is to provide the region with intermediate products
We primarily supply electronic circuits in various densities
We're also the area with the highest quality steel!
]]
},
{
title = 'Oil and high tech production',
msg = [[
Our main objective is to provide the region with oil based products
Secondary we are the regions technological leader
We provide the region with various high technology (and radioactive) products
]]
},
{
title = 'Logistical production',
msg = [[
Our main objective is to provide the region with logistical solutions
We primarily supply belt and bot based solutions
We're also specialized in high performance train networks!
]]
},
}
local function teleport(event, quadrant)
local player = event.player
if (abs(player.position.x) <= 4 and abs(player.position.y) <= 4) or (player.get_inventory(1).is_empty() and player.get_inventory(2).is_empty() and (player.get_inventory(8) or player.get_inventory(3).is_empty())) then
player.teleport(spawn_locations['quadrant_'..quadrant])
player.force = game.forces['quadrant'..quadrant]
Popup.player(player, quadrant_message[quadrant].msg, quadrant_message[quadrant].title, nil, 'Quadrants.quadrant_description')
else
local text = '## - You are too heavy for teleportation! Empty your inventory before switching quadrant!'
player.print(text, Color.red)
@ -42,7 +84,7 @@ local function toggle(event)
local label_flow = content_flow.add {type = 'flow'}
label_flow.style.horizontally_stretchable = true
local label = label_flow.add {type = 'label', caption = "Welcome to quadrants!"}
local label = label_flow.add {type = 'label', caption = "Welcome to Redmew - Quadrants!"}
label.style.single_line = false
label.style.font = 'default-large-bold'
@ -56,19 +98,31 @@ local function toggle(event)
label.style.single_line = false
label.style.font = 'default'
local left_flow = frame.add {type = 'flow', direction = 'horizontal'}
local content_flow = frame.add {type = 'flow', direction = 'horizontal'}
local left_flow = content_flow.add {type = 'flow', direction = 'horizontal'}
left_flow.style.align = 'left'
left_flow.style.horizontally_stretchable = true
left_flow.add({type = 'button', name = 'Quadrants.Button.1', caption = 'Join quadrant1'})
left_flow.add({type = 'button', name = 'Quadrants.Button.2', caption = 'Join quadrant2'})
local right_flow = content_flow.add {type = 'flow', direction = 'horizontal'}
right_flow.style.align = 'right'
right_flow.style.horizontally_stretchable = true
local left_flow = frame.add {type = 'flow', direction = 'horizontal'}
left_flow.add({type = 'button', name = 'Quadrants.Button.2', caption = 'Intermediate produce'})
right_flow.add({type = 'button', name = 'Quadrants.Button.1', caption = 'Science and Military'})
local content_flow = frame.add {type = 'flow', direction = 'horizontal'}
local left_flow = content_flow.add {type = 'flow', direction = 'horizontal'}
left_flow.style.align = 'left'
left_flow.style.horizontally_stretchable = true
left_flow.add({type = 'button', name = 'Quadrants.Button.3', caption = 'Join quadrant3'})
left_flow.add({type = 'button', name = 'Quadrants.Button.4', caption = 'Join quadrant4'})
local right_flow = content_flow.add {type = 'flow', direction = 'horizontal'}
right_flow.style.align = 'right'
right_flow.style.horizontally_stretchable = true
left_flow.add({type = 'button', name = 'Quadrants.Button.3', caption = 'Oil and High Tech'})
right_flow.add({type = 'button', name = 'Quadrants.Button.4', caption = 'Logistics and Transport'})
local data = {
frame = frame,