mirror of
https://github.com/Refactorio/RedMew.git
synced 2024-12-14 10:13:13 +02:00
formatting
This commit is contained in:
parent
03de8ca472
commit
bdb524c6db
@ -125,72 +125,71 @@ local start_size = start_chunks_half_size * 64
|
||||
local value = b.euclidean_value
|
||||
|
||||
local quadrant_config = {
|
||||
['iron-ore'] = {
|
||||
['tiles'] = {
|
||||
[1] = 'grass-1',
|
||||
[2] = 'grass-2',
|
||||
[3] = 'grass-3',
|
||||
[4] = 'grass-4'
|
||||
['iron-ore'] = {
|
||||
['tiles'] = {
|
||||
[1] = 'grass-1',
|
||||
[2] = 'grass-2',
|
||||
[3] = 'grass-3',
|
||||
[4] = 'grass-4'
|
||||
},
|
||||
['ratios'] = {
|
||||
{resource = b.resource(b.full_shape, 'iron-ore', value(0, 0.5)), weight = 60},
|
||||
{resource = b.resource(b.full_shape, 'copper-ore', value(0, 0.5)), weight = 20},
|
||||
{resource = b.resource(b.full_shape, 'stone', value(0, 0.5)), weight = 2},
|
||||
{resource = b.resource(b.full_shape, 'coal', value(0, 0.5)), weight = 20}
|
||||
}
|
||||
},
|
||||
['ratios'] = {
|
||||
{resource = b.resource(b.full_shape, 'iron-ore', value(0, 0.5)), weight = 60},
|
||||
{resource = b.resource(b.full_shape, 'copper-ore', value(0, 0.5)), weight = 20},
|
||||
{resource = b.resource(b.full_shape, 'stone', value(0, 0.5)), weight = 2},
|
||||
{resource = b.resource(b.full_shape, 'coal', value(0, 0.5)), weight = 20}
|
||||
}
|
||||
},
|
||||
['copper-ore'] = {
|
||||
['tiles'] = {
|
||||
[1] = 'red-desert-0',
|
||||
[2] = 'red-desert-1',
|
||||
[3] = 'red-desert-2',
|
||||
[4] = 'red-desert-3'
|
||||
['copper-ore'] = {
|
||||
['tiles'] = {
|
||||
[1] = 'red-desert-0',
|
||||
[2] = 'red-desert-1',
|
||||
[3] = 'red-desert-2',
|
||||
[4] = 'red-desert-3'
|
||||
},
|
||||
['ratios'] = {
|
||||
{resource = b.resource(b.full_shape, 'iron-ore', value(0, 0.5)), weight = 20},
|
||||
{resource = b.resource(b.full_shape, 'copper-ore', value(0, 0.5)), weight = 60},
|
||||
{resource = b.resource(b.full_shape, 'stone', value(0, 0.5)), weight = 2},
|
||||
{resource = b.resource(b.full_shape, 'coal', value(0, 0.5)), weight = 20}
|
||||
}
|
||||
},
|
||||
['ratios'] = {
|
||||
{resource = b.resource(b.full_shape, 'iron-ore', value(0, 0.5)), weight = 20},
|
||||
{resource = b.resource(b.full_shape, 'copper-ore', value(0, 0.5)), weight = 60},
|
||||
{resource = b.resource(b.full_shape, 'stone', value(0, 0.5)), weight = 2},
|
||||
{resource = b.resource(b.full_shape, 'coal', value(0, 0.5)), weight = 20}
|
||||
}
|
||||
},
|
||||
['coal'] = {
|
||||
['tiles'] = {
|
||||
[1] = 'dirt-1',
|
||||
[2] = 'dirt-2',
|
||||
[3] = 'dirt-3',
|
||||
[4] = 'dirt-4',
|
||||
[5] = 'dirt-5',
|
||||
[6] = 'dirt-6',
|
||||
[7] = 'dirt-7'
|
||||
['coal'] = {
|
||||
['tiles'] = {
|
||||
[1] = 'dirt-1',
|
||||
[2] = 'dirt-2',
|
||||
[3] = 'dirt-3',
|
||||
[4] = 'dirt-4',
|
||||
[5] = 'dirt-5',
|
||||
[6] = 'dirt-6',
|
||||
[7] = 'dirt-7'
|
||||
},
|
||||
['ratios'] = {
|
||||
{resource = b.resource(b.full_shape, 'iron-ore', value(0, 0.5)), weight = 20},
|
||||
{resource = b.resource(b.full_shape, 'copper-ore', value(0, 0.5)), weight = 20},
|
||||
{resource = b.resource(b.full_shape, 'stone', value(0, 0.5)), weight = 2},
|
||||
{resource = b.resource(b.full_shape, 'coal', value(0, 0.5)), weight = 40}
|
||||
}
|
||||
},
|
||||
['ratios'] = {
|
||||
{resource = b.resource(b.full_shape, 'iron-ore', value(0, 0.5)), weight = 20},
|
||||
{resource = b.resource(b.full_shape, 'copper-ore', value(0, 0.5)), weight = 20},
|
||||
{resource = b.resource(b.full_shape, 'stone', value(0, 0.5)), weight = 2},
|
||||
{resource = b.resource(b.full_shape, 'coal', value(0, 0.5)), weight = 40}
|
||||
['stone'] = {
|
||||
['tiles'] = {
|
||||
[1] = 'sand-1',
|
||||
[2] = 'sand-2',
|
||||
[3] = 'sand-3'
|
||||
},
|
||||
['ratios'] = {
|
||||
{resource = b.resource(b.full_shape, 'iron-ore', value(0, 0.5)), weight = 20},
|
||||
{resource = b.resource(b.full_shape, 'copper-ore', value(0, 0.5)), weight = 20},
|
||||
{resource = b.resource(b.full_shape, 'stone', value(0, 0.5)), weight = 30},
|
||||
{resource = b.resource(b.full_shape, 'coal', value(0, 0.5)), weight = 20}
|
||||
}
|
||||
}
|
||||
},
|
||||
['stone'] = {
|
||||
['tiles'] = {
|
||||
[1] = 'sand-1',
|
||||
[2] = 'sand-2',
|
||||
[3] = 'sand-3'
|
||||
},
|
||||
['ratios'] = {
|
||||
{resource = b.resource(b.full_shape, 'iron-ore', value(0, 0.5)), weight = 20},
|
||||
{resource = b.resource(b.full_shape, 'copper-ore', value(0, 0.5)), weight = 20},
|
||||
{resource = b.resource(b.full_shape, 'stone', value(0, 0.5)), weight = 30},
|
||||
{resource = b.resource(b.full_shape, 'coal', value(0, 0.5)), weight = 20}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
local tile_quadrants = {
|
||||
[1] = 'stone',
|
||||
[2] = 'iron-ore',
|
||||
[3] = 'copper-ore',
|
||||
[4] = 'coal'
|
||||
[1] = 'stone',
|
||||
[2] = 'iron-ore',
|
||||
[3] = 'copper-ore',
|
||||
[4] = 'coal'
|
||||
}
|
||||
|
||||
local tiles_pos_x_pos_y
|
||||
@ -253,19 +252,19 @@ Global.register_init(
|
||||
|
||||
table.shuffle_table(tile_quadrants)
|
||||
|
||||
tiles_pos_x_pos_y = quadrant_config[ tile_quadrants[1] ]['tiles']
|
||||
tiles_pos_x_pos_y_count = #quadrant_config[ tile_quadrants[1] ]['tiles']
|
||||
tiles_pos_x_neg_y = quadrant_config[ tile_quadrants[2] ]['tiles']
|
||||
tiles_pos_x_neg_y_count = #quadrant_config[ tile_quadrants[2] ]['tiles']
|
||||
tiles_neg_x_pos_y = quadrant_config[ tile_quadrants[3] ]['tiles']
|
||||
tiles_neg_x_pos_y_count = #quadrant_config[ tile_quadrants[3] ]['tiles']
|
||||
tiles_neg_x_neg_y = quadrant_config[ tile_quadrants[4] ]['tiles']
|
||||
tiles_neg_x_neg_y_count = #quadrant_config[ tile_quadrants[4] ]['tiles']
|
||||
tiles_pos_x_pos_y = quadrant_config[tile_quadrants[1]]['tiles']
|
||||
tiles_pos_x_pos_y_count = #quadrant_config[tile_quadrants[1]]['tiles']
|
||||
tiles_pos_x_neg_y = quadrant_config[tile_quadrants[2]]['tiles']
|
||||
tiles_pos_x_neg_y_count = #quadrant_config[tile_quadrants[2]]['tiles']
|
||||
tiles_neg_x_pos_y = quadrant_config[tile_quadrants[3]]['tiles']
|
||||
tiles_neg_x_pos_y_count = #quadrant_config[tile_quadrants[3]]['tiles']
|
||||
tiles_neg_x_neg_y = quadrant_config[tile_quadrants[4]]['tiles']
|
||||
tiles_neg_x_neg_y_count = #quadrant_config[tile_quadrants[4]]['tiles']
|
||||
|
||||
ores_pos_x_pos_y = quadrant_config[ tile_quadrants[1] ]['ratios']
|
||||
ores_pos_x_neg_y = quadrant_config[ tile_quadrants[2] ]['ratios']
|
||||
ores_neg_x_pos_y = quadrant_config[ tile_quadrants[3] ]['ratios']
|
||||
ores_neg_x_neg_y = quadrant_config[ tile_quadrants[4] ]['ratios']
|
||||
ores_pos_x_pos_y = quadrant_config[tile_quadrants[1]]['ratios']
|
||||
ores_pos_x_neg_y = quadrant_config[tile_quadrants[2]]['ratios']
|
||||
ores_neg_x_pos_y = quadrant_config[tile_quadrants[3]]['ratios']
|
||||
ores_neg_x_neg_y = quadrant_config[tile_quadrants[4]]['ratios']
|
||||
|
||||
weighted_ores_pos_x_pos_y = b.prepare_weighted_array(ores_pos_x_pos_y)
|
||||
weighted_ores_pos_x_neg_y = b.prepare_weighted_array(ores_pos_x_neg_y)
|
||||
@ -278,14 +277,13 @@ Global.register_init(
|
||||
total_ores_neg_x_neg_y = weighted_ores_neg_x_neg_y.total
|
||||
|
||||
start_ores = {
|
||||
b.resource(ore_circle, tile_quadrants[2], value(125, 0)),
|
||||
b.resource(ore_circle, tile_quadrants[4], value(125, 0)),
|
||||
b.resource(ore_circle, tile_quadrants[3], value(125, 0)),
|
||||
b.resource(ore_circle, tile_quadrants[1], value(125, 0))
|
||||
}
|
||||
|
||||
start_segment = b.segment_pattern(start_ores)
|
||||
b.resource(ore_circle, tile_quadrants[2], value(125, 0)),
|
||||
b.resource(ore_circle, tile_quadrants[4], value(125, 0)),
|
||||
b.resource(ore_circle, tile_quadrants[3], value(125, 0)),
|
||||
b.resource(ore_circle, tile_quadrants[1], value(125, 0))
|
||||
}
|
||||
|
||||
start_segment = b.segment_pattern(start_ores)
|
||||
end
|
||||
)
|
||||
|
||||
@ -323,13 +321,13 @@ local function ore(x, y, world)
|
||||
local resource
|
||||
|
||||
if x > 0 and y > 0 then
|
||||
i = math.random() * total_ores_pos_x_pos_y
|
||||
index = table.binary_search(weighted_ores_pos_x_pos_y, i)
|
||||
if (index < 0) then
|
||||
index = bit32.bnot(index)
|
||||
end
|
||||
i = math.random() * total_ores_pos_x_pos_y
|
||||
index = table.binary_search(weighted_ores_pos_x_pos_y, i)
|
||||
if (index < 0) then
|
||||
index = bit32.bnot(index)
|
||||
end
|
||||
|
||||
resource = ores_pos_x_pos_y[index].resource
|
||||
resource = ores_pos_x_pos_y[index].resource
|
||||
elseif x > 0 and y < 0 then
|
||||
i = math.random() * total_ores_pos_x_neg_y
|
||||
index = table.binary_search(weighted_ores_pos_x_neg_y, i)
|
||||
@ -345,13 +343,13 @@ local function ore(x, y, world)
|
||||
end
|
||||
resource = ores_neg_x_pos_y[index].resource
|
||||
else
|
||||
i = math.random() * total_ores_neg_x_neg_y
|
||||
index = table.binary_search(weighted_ores_neg_x_neg_y, i)
|
||||
if (index < 0) then
|
||||
index = bit32.bnot(index)
|
||||
end
|
||||
i = math.random() * total_ores_neg_x_neg_y
|
||||
index = table.binary_search(weighted_ores_neg_x_neg_y, i)
|
||||
if (index < 0) then
|
||||
index = bit32.bnot(index)
|
||||
end
|
||||
|
||||
resource = ores_neg_x_neg_y[index].resource
|
||||
resource = ores_neg_x_neg_y[index].resource
|
||||
end
|
||||
|
||||
local entity = resource(x, y, world)
|
||||
@ -379,7 +377,7 @@ local win_condition_biters_disabled = false
|
||||
|
||||
local function enemy(x, y, world)
|
||||
if win_condition_biters_disabled == true then
|
||||
return nil
|
||||
return nil
|
||||
end
|
||||
|
||||
local d = math.sqrt(world.x * world.x + world.y * world.y)
|
||||
@ -439,71 +437,71 @@ local function water_shape(x, y)
|
||||
-- Control the tiles at X quadrant
|
||||
if x > 31 and y > 31 then
|
||||
-- southeast
|
||||
return tiles_pos_x_pos_y[ math.ceil(math.random(tiles_pos_x_pos_y_count)) ]
|
||||
return tiles_pos_x_pos_y[math.ceil(math.random(tiles_pos_x_pos_y_count))]
|
||||
elseif x > 0 and y < 31 and y > 0 then
|
||||
-- southeast to northeast
|
||||
if math.random(100) < 50 + y * 2 then
|
||||
return tiles_pos_x_pos_y[ math.ceil(math.random(tiles_pos_x_pos_y_count)) ]
|
||||
return tiles_pos_x_pos_y[math.ceil(math.random(tiles_pos_x_pos_y_count))]
|
||||
else
|
||||
return tiles_pos_x_neg_y[ math.ceil(math.random(tiles_pos_x_neg_y_count)) ]
|
||||
return tiles_pos_x_neg_y[math.ceil(math.random(tiles_pos_x_neg_y_count))]
|
||||
end
|
||||
elseif x > 0 and y >= 0 then
|
||||
-- southeast to southwest
|
||||
if math.random(100) < 50 + x * 2 then
|
||||
return tiles_pos_x_pos_y[ math.ceil(math.random(tiles_pos_x_pos_y_count)) ]
|
||||
return tiles_pos_x_pos_y[math.ceil(math.random(tiles_pos_x_pos_y_count))]
|
||||
else
|
||||
return tiles_neg_x_pos_y[ math.ceil(math.random(tiles_neg_x_pos_y_count)) ]
|
||||
return tiles_neg_x_pos_y[math.ceil(math.random(tiles_neg_x_pos_y_count))]
|
||||
end
|
||||
elseif x > 31 and y < -31 then
|
||||
-- northeast
|
||||
return tiles_pos_x_neg_y[ math.ceil(math.random(tiles_pos_x_neg_y_count)) ]
|
||||
return tiles_pos_x_neg_y[math.ceil(math.random(tiles_pos_x_neg_y_count))]
|
||||
elseif x > 0 and x < 31 and y <= 0 then
|
||||
-- northeast to northwest
|
||||
if math.random(100) < 50 + x * 2 then
|
||||
return tiles_pos_x_neg_y[ math.ceil(math.random(tiles_pos_x_neg_y_count)) ]
|
||||
return tiles_pos_x_neg_y[math.ceil(math.random(tiles_pos_x_neg_y_count))]
|
||||
else
|
||||
return tiles_neg_x_neg_y[ math.ceil(math.random(tiles_neg_x_neg_y_count)) ]
|
||||
return tiles_neg_x_neg_y[math.ceil(math.random(tiles_neg_x_neg_y_count))]
|
||||
end
|
||||
elseif x > 0 and y < 0 then
|
||||
-- northeast to southeast
|
||||
if math.random(100) < 50 - y * 2 then
|
||||
return tiles_pos_x_neg_y[ math.ceil(math.random(tiles_pos_x_neg_y_count)) ]
|
||||
return tiles_pos_x_neg_y[math.ceil(math.random(tiles_pos_x_neg_y_count))]
|
||||
else
|
||||
return tiles_pos_x_pos_y[ math.ceil(math.random(tiles_pos_x_pos_y_count)) ]
|
||||
return tiles_pos_x_pos_y[math.ceil(math.random(tiles_pos_x_pos_y_count))]
|
||||
end
|
||||
elseif x < -31 and y < -31 then
|
||||
-- northwest
|
||||
return tiles_neg_x_neg_y[ math.ceil(math.random(tiles_neg_x_neg_y_count)) ]
|
||||
return tiles_neg_x_neg_y[math.ceil(math.random(tiles_neg_x_neg_y_count))]
|
||||
elseif x > -31 and x < 0 and y <= 0 then
|
||||
-- northwest to northeast
|
||||
if math.random(100) < 50 - x * 2 then
|
||||
return tiles_neg_x_neg_y[ math.ceil(math.random(tiles_neg_x_neg_y_count)) ]
|
||||
return tiles_neg_x_neg_y[math.ceil(math.random(tiles_neg_x_neg_y_count))]
|
||||
else
|
||||
return tiles_pos_x_neg_y[ math.ceil(math.random(tiles_pos_x_neg_y_count)) ]
|
||||
return tiles_pos_x_neg_y[math.ceil(math.random(tiles_pos_x_neg_y_count))]
|
||||
end
|
||||
elseif x < 0 and y > -31 and y < 0 then
|
||||
-- northwest to southwest
|
||||
if math.random(100) < ( 50 - y * 2 ) then
|
||||
return tiles_neg_x_neg_y[ math.ceil(math.random(tiles_neg_x_neg_y_count)) ]
|
||||
if math.random(100) < (50 - y * 2) then
|
||||
return tiles_neg_x_neg_y[math.ceil(math.random(tiles_neg_x_neg_y_count))]
|
||||
else
|
||||
return tiles_neg_x_pos_y[ math.ceil(math.random(tiles_neg_x_pos_y_count)) ]
|
||||
return tiles_neg_x_pos_y[math.ceil(math.random(tiles_neg_x_pos_y_count))]
|
||||
end
|
||||
elseif x < -31 and y > 31 then
|
||||
-- southwest
|
||||
return tiles_neg_x_pos_y[ math.ceil(math.random(tiles_neg_x_pos_y_count)) ]
|
||||
return tiles_neg_x_pos_y[math.ceil(math.random(tiles_neg_x_pos_y_count))]
|
||||
elseif x < 0 and y > 0 and y < 32 then
|
||||
-- southwest to northwest
|
||||
if math.random(100) < ( 50 + y * 2 ) then
|
||||
return tiles_neg_x_pos_y[ math.ceil(math.random(tiles_neg_x_pos_y_count)) ]
|
||||
if math.random(100) < (50 + y * 2) then
|
||||
return tiles_neg_x_pos_y[math.ceil(math.random(tiles_neg_x_pos_y_count))]
|
||||
else
|
||||
return tiles_neg_x_neg_y[ math.ceil(math.random(tiles_neg_x_neg_y_count)) ]
|
||||
return tiles_neg_x_neg_y[math.ceil(math.random(tiles_neg_x_neg_y_count))]
|
||||
end
|
||||
elseif x < 0 and y > 0 then
|
||||
-- southwest to southeast
|
||||
if math.random(100) < 50 - x * 2 then
|
||||
return tiles_neg_x_pos_y[ math.ceil(math.random(tiles_neg_x_pos_y_count)) ]
|
||||
if math.random(100) < 50 - x * 2 then
|
||||
return tiles_neg_x_pos_y[math.ceil(math.random(tiles_neg_x_pos_y_count))]
|
||||
else
|
||||
return tiles_pos_x_pos_y[ math.ceil(math.random(tiles_pos_x_pos_y_count)) ]
|
||||
return tiles_pos_x_pos_y[math.ceil(math.random(tiles_pos_x_pos_y_count))]
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -555,57 +553,58 @@ map = b.fish(map, 0.025)
|
||||
local bounds = b.rectangle(start_size, start_size)
|
||||
|
||||
local function rocket_launched(event)
|
||||
local entity = event.rocket
|
||||
local entity = event.rocket
|
||||
|
||||
if not entity or not entity.valid or not entity.force == 'player' then
|
||||
return
|
||||
end
|
||||
|
||||
local inventory = entity.get_inventory(defines.inventory.rocket)
|
||||
if not inventory or not inventory.valid then
|
||||
return
|
||||
end
|
||||
|
||||
local satellite_count = game.forces.player.get_item_launched('satellite')
|
||||
if satellite_count == 0 then
|
||||
return
|
||||
end
|
||||
|
||||
-- Increase enemy_evolution
|
||||
local current_evolution = game.forces.enemy.evolution_factor
|
||||
local message
|
||||
|
||||
if win_condition_biters_disabled == false then
|
||||
if (satellite_count % 5) == 0 and win_condition_evolution_rocket_maxed == -1 then
|
||||
message = 'Continued launching of satellites has angered the local biter population, evolution increasing...'
|
||||
game.print(message)
|
||||
|
||||
current_evolution = current_evolution + 0.05
|
||||
if not entity or not entity.valid or not entity.force == 'player' then
|
||||
return
|
||||
end
|
||||
|
||||
if current_evolution >= 1 and win_condition_evolution_rocket_maxed == -1 then
|
||||
current_evolution = 1
|
||||
win_condition_evolution_rocket_maxed = satellite_count
|
||||
|
||||
message = 'Biters at maximum evolution! Protect the base for an additional 100 rockets to wipe them out forever.'
|
||||
game.print(message)
|
||||
local inventory = entity.get_inventory(defines.inventory.rocket)
|
||||
if not inventory or not inventory.valid then
|
||||
return
|
||||
end
|
||||
|
||||
game.forces.enemy.evolution_factor = current_evolution
|
||||
if win_condition_evolution_rocket_maxed > 0 and satellite_count >= (win_condition_evolution_rocket_maxed + 100) then
|
||||
message = 'Congratulations! Biters have been wiped from the map!'
|
||||
game.print(message)
|
||||
|
||||
win_condition_evolution_rocket_maxed = true
|
||||
|
||||
for key, entity in pairs(surface.find_entities_filtered({force="enemy"})) do
|
||||
entity.destroy()
|
||||
end
|
||||
local satellite_count = game.forces.player.get_item_launched('satellite')
|
||||
if satellite_count == 0 then
|
||||
return
|
||||
end
|
||||
|
||||
-- Increase enemy_evolution
|
||||
local current_evolution = game.forces.enemy.evolution_factor
|
||||
local message
|
||||
|
||||
if win_condition_biters_disabled == false then
|
||||
if (satellite_count % 5) == 0 and win_condition_evolution_rocket_maxed == -1 then
|
||||
message =
|
||||
'Continued launching of satellites has angered the local biter population, evolution increasing...'
|
||||
game.print(message)
|
||||
|
||||
current_evolution = current_evolution + 0.05
|
||||
end
|
||||
|
||||
if current_evolution >= 1 and win_condition_evolution_rocket_maxed == -1 then
|
||||
current_evolution = 1
|
||||
win_condition_evolution_rocket_maxed = satellite_count
|
||||
|
||||
message =
|
||||
'Biters at maximum evolution! Protect the base for an additional 100 rockets to wipe them out forever.'
|
||||
game.print(message)
|
||||
end
|
||||
|
||||
game.forces.enemy.evolution_factor = current_evolution
|
||||
if win_condition_evolution_rocket_maxed > 0 and satellite_count >= (win_condition_evolution_rocket_maxed + 100) then
|
||||
message = 'Congratulations! Biters have been wiped from the map!'
|
||||
game.print(message)
|
||||
|
||||
win_condition_evolution_rocket_maxed = true
|
||||
|
||||
for key, entity in pairs(surface.find_entities_filtered({force = 'enemy'})) do
|
||||
entity.destroy()
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
local function on_chunk(event)
|
||||
if surface ~= event.surface then
|
||||
return
|
||||
|
Loading…
Reference in New Issue
Block a user