1
0
mirror of https://github.com/ComfyFactory/ComfyFactorio.git synced 2025-03-17 20:58:13 +02:00

Journey update - vanilla

This commit is contained in:
hanakocz 2024-10-10 23:12:14 +02:00
parent cbcbcb1ce5
commit ddf04060ff
6 changed files with 114 additions and 127 deletions

View File

@ -1,6 +1,6 @@
local Public = {}
Public.mothership_teleporter_position = { x = 0, y = 12 }
Public.mothership_teleporter_position = { x = -3, y = 11 }
Public.teleporter_tile = 'lab-dark-2'
Public.mothership_radius = 48
@ -180,7 +180,6 @@ Public.starter_goods_pool = {
{ 'accumulator', 8, 16 },
{ 'electric-furnace', 4, 8 },
{ 'solar-panel', 8, 16 },
{ 'stack-inserter', 16, 32 },
{ 'bulk-inserter', 16, 32 },
{ 'steam-turbine', 4, 8 },
{ 'substation', 4, 8 },
@ -188,8 +187,6 @@ Public.starter_goods_pool = {
{ 'oil-refinery', 1, 2 },
},
['rare'] = {
{ 'green-wire', 256, 512 },
{ 'red-wire', 256, 512 },
{ 'heat-exchanger', 1, 2 },
{ 'heat-pipe', 10, 20 },
{ 'uranium-fuel-cell', 4, 8 },
@ -198,7 +195,7 @@ Public.starter_goods_pool = {
{ 'construction-robot', 16, 32 },
{ 'personal-roboport-equipment', 1, 1 },
{ 'solar-panel-equipment', 2, 4 },
{ 'effectivity-module', 5, 10 },
{ 'efficiency-module', 5, 10 },
},
}

View File

@ -1,17 +1,12 @@
--luacheck: ignore
local Map_functions = require 'utils.tools.map_functions'
local Server = require 'utils.server'
local Get_noise = require 'utils.math.get_noise'
local Autostash = require 'modules.autostash'
local Misc = require 'utils.commands.misc'
local BottomFrame = require 'utils.gui.bottom_frame'
local Constants = require 'maps.journey.constants'
local Unique_modifiers = require 'maps.journey.unique_modifiers'
local Vacants = require 'modules.clear_vacant_players'
local math_sqrt = math.sqrt
local math_random = math.random
local math_floor = math.floor
local math_abs = math.abs
local Math = require 'utils.math.math'
local Public = {}
local mixed_ores = { 'copper-ore', 'iron-ore', 'stone', 'coal' }
@ -19,13 +14,13 @@ local mixed_ores = { 'copper-ore', 'iron-ore', 'stone', 'coal' }
local function clear_selectors(journey)
for k, world_selector in pairs(journey.world_selectors) do
for _, ID in pairs(world_selector.texts) do
rendering.destroy(ID)
ID.destroy()
end
journey.world_selectors[k].texts = {}
journey.world_selectors[k].activation_level = 0
end
for _, ID in pairs(journey.reroll_selector.texts) do
rendering.destroy(ID)
ID.destroy()
end
journey.reroll_selector.texts = {}
journey.reroll_selector.activation_level = 0
@ -38,42 +33,45 @@ local function protect(entity, operable)
end
function Public.place_mixed_ore(event, journey)
if math_random(1, 192) ~= 1 then
if Math.random(1, 192) ~= 1 then
return
end
local surface = event.surface
local x = event.area.left_top.x + math_random(0, 31)
local y = event.area.left_top.y + math_random(0, 31)
local base_amount = 1000 + math_sqrt(x ^ 2 + y ^ 2) * 5
local x = event.area.left_top.x + Math.random(0, 31)
local y = event.area.left_top.y + Math.random(0, 31)
local base_amount = 1000 + Math.sqrt(x ^ 2 + y ^ 2) * 5
local richness = journey.mixed_ore_richness
Map_functions.draw_rainbow_patch({ x = x, y = y }, surface, math_random(17, 22), base_amount * richness + 100)
Map_functions.draw_rainbow_patch({ x = x, y = y }, surface, Math.random(17, 22), base_amount * richness + 100)
end
local function place_teleporter(journey, surface, position, build_beacon)
local tiles = {}
for x = -2, 2, 1 do
for y = -2, 2, 1 do
for x = -2, 7, 1 do
for y = -2, 7, 1 do
local pos = { x = position.x + x, y = position.y + y }
table.insert(tiles, { name = Constants.teleporter_tile, position = pos })
end
end
surface.set_tiles(tiles, false)
surface.create_entity({ name = 'electric-beam-no-sound', position = position, source = { x = position.x - 1.5, y = position.y - 1.5 }, target = { x = position.x + 2.5, y = position.y - 1.0 } })
surface.create_entity({ name = 'electric-beam-no-sound', position = position, source = { x = position.x + 2.5, y = position.y - 1.5 }, target = { x = position.x + 2.5, y = position.y + 3.0 } })
surface.create_entity({ name = 'electric-beam-no-sound', position = position, source = { x = position.x + 2.5, y = position.y + 2.5 }, target = { x = position.x - 1.5, y = position.y + 3.0 } })
surface.create_entity({ name = 'electric-beam-no-sound', position = position, source = { x = position.x - 1.5, y = position.y + 2.5 }, target = { x = position.x - 1.5, y = position.y - 1.0 } })
surface.destroy_decoratives({ area = { { position.x - 3, position.y - 3 }, { position.x + 3, position.y + 3 } } })
surface.create_entity({ name = 'electric-beam-no-sound', position = position, source = { x = position.x - 1.5, y = position.y - 1.5 }, target = { x = position.x + 7.5, y = position.y - 1.0 } })
surface.create_entity({ name = 'electric-beam-no-sound', position = position, source = { x = position.x + 7.5, y = position.y - 1.5 }, target = { x = position.x + 7.5, y = position.y + 8.0 } })
surface.create_entity({ name = 'electric-beam-no-sound', position = position, source = { x = position.x + 7.5, y = position.y + 7.5 }, target = { x = position.x - 1.5, y = position.y + 8.0 } })
surface.create_entity({ name = 'electric-beam-no-sound', position = position, source = { x = position.x - 1.5, y = position.y + 7.5 }, target = { x = position.x - 1.5, y = position.y - 1.0 } })
surface.destroy_decoratives({ area = { { position.x - 5, position.y - 5 }, { position.x + 5, position.y + 5 } } })
if build_beacon then
local beacon = surface.create_entity({ name = 'beacon', position = { x = position.x, y = position.y }, force = 'player' })
local beacon = surface.create_entity({ name = 'cargo-landing-pad', position = { x = position.x + 3 , y = position.y + 2}, force = 'player' })
journey.beacon_objective_health = 10000
beacon.operable = false
beacon.operable = true
beacon.minable = false
beacon.active = false
beacon.active = true
rendering.draw_text {
text = { 'journey.teleporter' },
surface = surface,
target = beacon,
target_offset = { 0, -1.5 },
target = {
entity = beacon,
offset = {0, -1.5},
position = beacon.position
},
color = { 0, 1, 0 },
scale = 0.90,
font = 'default-game',
@ -84,8 +82,11 @@ local function place_teleporter(journey, surface, position, build_beacon)
rendering.draw_text {
text = { 'journey.beacon_hp', journey.beacon_objective_health },
surface = surface,
target = beacon,
target_offset = { 0, -1.0 },
target = {
entity = beacon,
offset = {0, -1.0},
position = beacon.position
},
color = { 0, 1, 0 },
scale = 0.90,
font = 'default-game',
@ -99,14 +100,14 @@ end
local function destroy_teleporter(journey, surface, position)
local tiles = {}
for x = -2, 2, 1 do
for y = -2, 2, 1 do
for x = -2, 7, 1 do
for y = -2, 7, 1 do
local pos = { x = position.x + x, y = position.y + y }
table.insert(tiles, { name = 'lab-dark-1', position = pos })
end
end
surface.set_tiles(tiles, true)
for _, e in pairs(surface.find_entities_filtered({ name = 'electric-beam-no-sound', area = { { position.x - 3, position.y - 3 }, { position.x + 3, position.y + 3 } } })) do
for _, e in pairs(surface.find_entities_filtered({ name = 'electric-beam-no-sound', area = { { position.x - 5, position.y - 5 }, { position.x + 8, position.y + 8 } } })) do
e.destroy()
end
end
@ -137,7 +138,7 @@ local function drop_player_items(journey, player)
for i = 1, #inventory, 1 do
local slot = inventory[i]
if slot.valid and slot.valid_for_read then
surface.spill_item_stack(player.position, slot, true, nil, false)
surface.spill_item_stack({position = player.position, stack = slot, enable_looted = true, allow_belts = false})
end
end
inventory.clear()
@ -307,7 +308,7 @@ function Public.register_built_silo(event, journey)
if entity.type ~= 'rocket-silo' then
return
end
entity.auto_launch = false
--entity.auto_launch = false
table.insert(journey.rocket_silos, entity)
end
@ -421,10 +422,10 @@ function Public.draw_gui(journey)
end
local function is_mothership(position)
if math.abs(position.x) > Constants.mothership_radius then
if Math.abs(position.x) > Constants.mothership_radius then
return false
end
if math.abs(position.y) > Constants.mothership_radius then
if Math.abs(position.y) > Constants.mothership_radius then
return false
end
local p = { x = position.x, y = position.y }
@ -434,7 +435,7 @@ local function is_mothership(position)
if p.y > 0 then
p.y = p.y + 1
end
local d = math.sqrt(p.x ^ 2 + p.y ^ 2)
local d = Math.sqrt(p.x ^ 2 + p.y ^ 2)
if d < Constants.mothership_radius then
return true
end
@ -551,14 +552,14 @@ function Public.hard_reset(journey)
local surface = game.surfaces[1]
surface.clear(true)
surface.daytime = math.random(1, 100) * 0.01
surface.daytime = Math.random(1, 100) * 0.01
if journey.world_selectors and journey.world_selectors[1].border then
for k, world_selector in pairs(journey.world_selectors) do
for _, ID in pairs(world_selector.rectangles) do
rendering.destroy(ID)
ID.destroy()
end
rendering.destroy(world_selector.border)
world_selector.border.destroy()
end
end
@ -582,6 +583,7 @@ function Public.hard_reset(journey)
['nuclear-reactor'] = 60
}
journey.bonus_goods = {}
journey.bonus_goods['loader'] = 3
journey.tooltip_capsules = ''
journey.tooltip_modifiers = ''
journey.nauvis_chunk_positions = nil
@ -696,11 +698,12 @@ function Public.draw_mothership(journey)
for k, item_name in pairs({ 'arithmetic-combinator', 'constant-combinator', 'decider-combinator', 'programmable-speaker', 'red-wire', 'green-wire', 'small-lamp', 'substation', 'pipe', 'gate', 'stone-wall', 'transport-belt' }) do
local chest = surface.create_entity({ name = 'infinity-chest', position = { -7 + k, Constants.mothership_radius - 3 }, force = 'player' })
chest.set_infinity_container_filter(1, { name = item_name, count = prototypes.item[item_name].stack_size })
if not chest or not chest.valid then break end
chest.set_infinity_container_filter(1, { name = item_name, count = prototypes.item[item_name].stack_size, index = 1 })
protect(chest, false)
local loader = surface.create_entity({ name = 'express-loader', position = { -7 + k, Constants.mothership_radius - 4 }, force = 'player' })
protect(loader, true)
loader.direction = 4
loader.direction = defines.direction.north
end
for m = -1, 1, 2 do
@ -717,15 +720,16 @@ function Public.draw_mothership(journey)
end
local y = Constants.mothership_radius * 0.5 - 7
local turret = surface.create_entity({ name = 'artillery-turret', position = { x * m, y }, force = 'player' })
turret.direction = 4
turret.direction = defines.direction.north
protect(turret, false)
local ins = surface.create_entity({ name = 'burner-inserter', position = { (x - 1) * m, y }, force = 'player' })
ins.direction = 4 + m * 2
ins.direction = m > 0 and defines.direction.west or defines.direction.east
ins.rotatable = false
protect(ins, false)
local chest = surface.create_entity({ name = 'infinity-chest', position = { (x - 2) * m, y }, force = 'player' })
chest.set_infinity_container_filter(1, { name = 'solid-fuel', count = 50 })
chest.set_infinity_container_filter(2, { name = 'artillery-shell', count = 1 })
if not chest or not chest.valid then break end
chest.set_infinity_container_filter(1, { name = 'solid-fuel', count = 50, index = 1 })
chest.set_infinity_container_filter(2, { name = 'artillery-shell', count = 1 , index = 2})
protect(chest, false)
end
@ -745,7 +749,7 @@ function Public.teleport_players_to_mothership(journey)
for _, player in pairs(game.connected_players) do
if player.surface.name ~= 'mothership' then
Public.clear_player(player)
player.teleport(surface.find_non_colliding_position('character', { 0, 0 }, 32, 0.5), surface)
player.teleport(surface.find_non_colliding_position('character', { 0, 0 }, 32, 0.5) or {0,0}, surface)
journey.characters_in_mothership = journey.characters_in_mothership + 1
table.insert(journey.mothership_messages, 'Welcome home ' .. player.name .. '!')
return
@ -792,7 +796,7 @@ local function animate_selectors(journey)
end
for _, rectangle in pairs(world_selector.rectangles) do
local color = Constants.world_selector_colors[k]
rendering.set_color(rectangle, { r = color.r * activation_level, g = color.g * activation_level, b = color.b * activation_level, a = 255 })
rectangle.color = { r = color.r * activation_level, g = color.g * activation_level, b = color.b * activation_level, a = 255 }
end
end
local activation_level = journey.reroll_selector.activation_level
@ -803,7 +807,7 @@ local function animate_selectors(journey)
activation_level = 1
end
local color = Constants.reroll_selector_area_color
rendering.set_color(journey.reroll_selector.rectangle, { r = color.r * activation_level, g = color.g * activation_level, b = color.b * activation_level, a = 255 })
journey.reroll_selector.rectangle.color = { r = color.r * activation_level, g = color.g * activation_level, b = color.b * activation_level, a = 255 }
end
local function draw_background(journey, surface)
@ -812,32 +816,32 @@ local function draw_background(journey, surface)
end
local speed = journey.mothership_speed
for c = 1, 16 * speed, 1 do
local position = Constants.particle_spawn_vectors[math.random(1, Constants.size_of_particle_spawn_vectors)]
local position = Constants.particle_spawn_vectors[Math.random(1, Constants.size_of_particle_spawn_vectors)]
surface.create_entity({ name = 'shotgun-pellet', position = position, target = { position[1], position[2] + Constants.mothership_radius * 2 }, speed = speed })
end
for c = 1, 16 * speed, 1 do
local position = Constants.particle_spawn_vectors[math.random(1, Constants.size_of_particle_spawn_vectors)]
local position = Constants.particle_spawn_vectors[Math.random(1, Constants.size_of_particle_spawn_vectors)]
surface.create_entity({ name = 'piercing-shotgun-pellet', position = position, target = { position[1], position[2] + Constants.mothership_radius * 2 }, speed = speed })
end
for c = 1, 2 * speed, 1 do
local position = Constants.particle_spawn_vectors[math.random(1, Constants.size_of_particle_spawn_vectors)]
local position = Constants.particle_spawn_vectors[Math.random(1, Constants.size_of_particle_spawn_vectors)]
surface.create_entity({ name = 'cannon-projectile', position = position, target = { position[1], position[2] + Constants.mothership_radius * 2 }, speed = speed })
end
for c = 1, 1 * speed, 1 do
local position = Constants.particle_spawn_vectors[math.random(1, Constants.size_of_particle_spawn_vectors)]
local position = Constants.particle_spawn_vectors[Math.random(1, Constants.size_of_particle_spawn_vectors)]
surface.create_entity({ name = 'uranium-cannon-projectile', position = position, target = { position[1], position[2] + Constants.mothership_radius * 2 }, speed = speed })
end
if math.random(1, 32) == 1 then
local position = Constants.particle_spawn_vectors[math.random(1, Constants.size_of_particle_spawn_vectors)]
if Math.random(1, 32) == 1 then
local position = Constants.particle_spawn_vectors[Math.random(1, Constants.size_of_particle_spawn_vectors)]
surface.create_entity({ name = 'explosive-uranium-cannon-projectile', position = position, target = { position[1], position[2] + Constants.mothership_radius * 3 }, speed = speed })
end
if math.random(1, 90) == 1 then
local position_x = math.random(64, 160)
local position_y = math.random(64, 160)
if math.random(1, 2) == 1 then
if Math.random(1, 90) == 1 then
local position_x = Math.random(64, 160)
local position_y = Math.random(64, 160)
if Math.random(1, 2) == 1 then
position_x = position_x * -1
end
if math.random(1, 2) == 1 then
if Math.random(1, 2) == 1 then
position_y = position_y * -1
end
surface.create_entity({ name = 'big-worm-turret', position = { position_x, position_y }, force = 'enemy' })
@ -850,9 +854,9 @@ local function roll_bonus_goods(journey, trait, amount)
while #bonus_goods < (amount or 3) do
for key, numbers in pairs(loot) do
local loot_table = Constants.starter_goods_pool[key]
if #bonus_goods < (amount or 3) and math.random(numbers[1], numbers[2]) >= 1 then
local item = loot_table[math.random(1, #loot_table)]
bonus_goods[#bonus_goods + 1] = { item[1], math.random(item[2], item[3]) }
if #bonus_goods < (amount or 3) and Math.random(numbers[1], numbers[2]) >= 1 then
local item = loot_table[Math.random(1, #loot_table)]
bonus_goods[#bonus_goods + 1] = { item[1], Math.random(item[2], item[3]) }
end
end
end
@ -901,7 +905,7 @@ function Public.set_world_selectors(journey)
world_selector.modifiers = {}
world_selector.bonus_goods = {}
world_selector.world_trait = unique_world_traits[k]
world_selector.fuel_requirement = math.random(25, 50)
world_selector.fuel_requirement = Math.random(25, 50)
end
local position = Constants.world_selector_areas[k].left_top
local texts = world_selector.texts
@ -920,35 +924,35 @@ function Public.set_world_selectors(journey)
if journey.world_modifiers[modifier] >= data.max then
if data.dmin > 0 and counts[2] < limits[2] then
--at max, so we lower it as a positive modifier
v = math.floor(math.random(data.dmin, data.dmax) * -0.5)
v = Math.floor(Math.random(data.dmin, data.dmax) * -0.5)
counts[2] = counts[2] + 1
modifiers[i] = { name = modifier, value = v, neg = false }
elseif data.dmin < 0 and counts[1] < limits[1] then
--at max, but it is good modifier, so lower it as negative modifier
v = math.floor(math.random(data.dmin, data.dmax))
v = Math.floor(Math.random(data.dmin, data.dmax))
counts[1] = counts[1] + 1
modifiers[i] = { name = modifier, value = v, neg = true }
end
elseif journey.world_modifiers[modifier] <= data.min then
if data.dmin < 0 and counts[1] < limits[1] then
--at min, but good to have it min, so we grow it as negative modifier
v = math.floor(math.random(data.dmin, data.dmax))
v = Math.floor(Math.random(data.dmin, data.dmax))
counts[1] = counts[1] + 1
modifiers[i] = { name = modifier, value = v, neg = true }
elseif data.dmin > 0 and counts[2] < limits[2] then
--at min, but min is bad, so we grow it as positive modifier
v = math.floor(math.random(data.dmin, data.dmax) * -0.5)
v = Math.floor(Math.random(data.dmin, data.dmax) * -0.5)
counts[2] = counts[2] + 1
modifiers[i] = { name = modifier, value = v, neg = false }
end
else
--somewhere in middle, we first try to fill the positives then negatives. table is shuffled so it should be fine
if counts[2] < limits[2] then
v = math.floor(math.random(data.dmin, data.dmax) * -0.5)
v = Math.floor(Math.random(data.dmin, data.dmax) * -0.5)
counts[2] = counts[2] + 1
modifiers[i] = { name = modifier, value = v, neg = false }
elseif counts[1] < limits[1] then
v = math.floor(math.random(data.dmin, data.dmax))
v = Math.floor(Math.random(data.dmin, data.dmax))
counts[1] = counts[1] + 1
modifiers[i] = { name = modifier, value = v, neg = true }
end
@ -1151,7 +1155,7 @@ function Public.mothership_world_selection(journey)
if journey.emergency_triggered then
if not journey.emergency_selected then
journey.selected_world = math.random(1, 3)
journey.selected_world = Math.random(1, 3)
table.insert(journey.mothership_messages, 'Emergency destination selected..')
journey.emergency_selected = true
end
@ -1174,9 +1178,9 @@ function Public.mothership_world_selection(journey)
if journey.selected_world then
if not journey.mothership_advancing_to_world then
table.insert(journey.mothership_messages, 'Advancing to selected world.')
journey.mothership_advancing_to_world = game.tick + math.random(60 * 45, 60 * 75)
journey.mothership_advancing_to_world = game.tick + Math.random(60 * 45, 60 * 75)
else
local seconds_left = math.floor((journey.mothership_advancing_to_world - game.tick) / 60)
local seconds_left = Math.floor((journey.mothership_advancing_to_world - game.tick) / 60)
if seconds_left <= 0 then
journey.mothership_advancing_to_world = false
table.insert(journey.mothership_messages, 'Arriving at targeted destination!')
@ -1265,8 +1269,8 @@ end
function Public.create_the_world(journey)
local surface = game.surfaces.nauvis
local mgs = surface.map_gen_settings
mgs.seed = math.random(1, 4294967295)
mgs.terrain_segmentation = math.random(10, 20) * 0.1
mgs.seed = Math.random(1, 4294967295)
mgs.terrain_segmentation = Math.random(10, 20) * 0.1
mgs.peaceful_mode = false
local modifiers = journey.world_selectors[journey.selected_world].modifiers
@ -1291,7 +1295,7 @@ function Public.create_the_world(journey)
journey.rocket_silos = {}
journey.mothership_cargo['uranium-fuel-cell'] = 0
journey.world_number = journey.world_number + 1
local max_satellites = math_floor(journey.world_number * 0.334) + 1
local max_satellites = Math.floor(journey.world_number * 0.334) + 1
if max_satellites > Constants.max_satellites then
max_satellites = Constants.max_satellites
end
@ -1441,7 +1445,7 @@ function Public.dispatch_goods(journey)
if journey.dispatch_beacon_position then
local good = goods_to_dispatch[journey.dispatch_key]
surface.spill_item_stack(journey.dispatch_beacon_position, { name = good[1], count = good[2] }, true, nil, false)
surface.spill_item_stack({position = journey.dispatch_beacon_position, stack = { name = good[1], count = good[2] }, enable_looted = true, allow_belts = false})
table.remove(journey.goods_to_dispatch, journey.dispatch_key)
journey.dispatch_beacon = nil
journey.dispatch_beacon_position = nil
@ -1450,12 +1454,12 @@ function Public.dispatch_goods(journey)
end
local chunk = surface.get_random_chunk()
if math.abs(chunk.x) > 4 or math.abs(chunk.y) > 4 then
if Math.abs(chunk.x) > 4 or Math.abs(chunk.y) > 4 then
return
end
local position = { x = chunk.x * 32 + math.random(0, 31), y = chunk.y * 32 + math.random(0, 31) }
position = surface.find_non_colliding_position('rocket-silo', position, 32, 1)
local basic_position = { x = chunk.x * 32 + Math.random(0, 31), y = chunk.y * 32 + Math.random(0, 31) }
local position = surface.find_non_colliding_position('rocket-silo', basic_position, 32, 1)
if not position then
return
end
@ -1463,7 +1467,7 @@ function Public.dispatch_goods(journey)
journey.dispatch_beacon = surface.create_entity({ name = 'stone-wall', position = position, force = 'neutral' })
journey.dispatch_beacon.minable = false
journey.dispatch_beacon_position = { x = position.x, y = position.y }
journey.dispatch_key = math.random(1, size_of_goods_to_dispatch)
journey.dispatch_key = Math.random(1, size_of_goods_to_dispatch)
local good = goods_to_dispatch[journey.dispatch_key]
table.insert(journey.mothership_messages, 'Capsule containing ' .. good[2] .. 'x [img=item/' .. good[1] .. '] dispatched. [gps=' .. position.x .. ',' .. position.y .. ',nauvis]')
@ -1471,7 +1475,7 @@ function Public.dispatch_goods(journey)
Server.to_discord_embed('A capsule containing ' .. good[2] .. 'x ' .. good[1] .. ' was spotted at: x=' .. position.x .. ', y=' .. position.y .. '!')
end
surface.create_entity({ name = 'artillery-projectile', position = { x = position.x - 256 + math.random(0, 512), y = position.y - 256 }, target = position, speed = 0.2 })
surface.create_entity({ name = 'artillery-projectile', position = { x = position.x - 256 + Math.random(0, 512), y = position.y - 256 }, target = position, speed = 0.2 })
end
function Public.world(journey)
@ -1535,7 +1539,7 @@ function Public.world(journey)
local name = slot.name
local count = slot.count
local needs = (journey.mothership_cargo_space[name] or 0) - (journey.mothership_cargo[name] or 0)
if needs > 0 and count >= math.min(prototypes.item[name].stack_size, needs) then
if needs > 0 and count >= math.min(prototypes.item[name].stack_size, 1000000 / prototypes.item[name].weight, needs) then
if silo.launch_rocket() then
table.insert(journey.mothership_messages, { 'journey.message_rocket_launched', count, name, silo.position.x, silo.position.y })
end
@ -1551,13 +1555,13 @@ function Public.mothership_waiting_for_players(journey)
return
end
if math.random(1, 2) == 1 then
if Math.random(1, 2) == 1 then
return
end
local tick = game.tick % 3600
if tick == 0 then
local messages = Constants.mothership_messages.waiting
table.insert(journey.mothership_messages, messages[math.random(1, #messages)])
table.insert(journey.mothership_messages, messages[Math.random(1, #messages)])
end
end
@ -1604,8 +1608,8 @@ function Public.deal_damage_to_beacon(journey, incoming_damage)
return
end
local resistance = journey.beacon_objective_resistance
journey.beacon_objective_health = math.floor(journey.beacon_objective_health - (incoming_damage * (1 - resistance)))
rendering.set_text(journey.beacon_objective_hp_label, { 'journey.beacon_hp', journey.beacon_objective_health })
journey.beacon_objective_health = Math.floor(journey.beacon_objective_health - (incoming_damage * (1 - resistance)))
journey.beacon_objective_hp_label.text = { 'journey.beacon_hp', journey.beacon_objective_health }
if journey.beacon_objective_health < 5000 and game.tick > journey.mothership_messages_last_damage + 900 then --under 50%, once every 15 seconds max
table.insert(journey.mothership_messages, 'The personal teleporter is being damaged, preparing for emergency departure.')
journey.mothership_messages_last_damage = game.tick
@ -1638,7 +1642,7 @@ function Public.lure_biters(journey, position)
local biters = surface.find_entities_filtered { position = position or beacon.position, radius = 80, force = 'enemy', type = 'unit' }
if #biters > 0 then
for _, biter in pairs(biters) do
biter.set_command({ type = defines.command.attack_area, destination = beacon.position, radius = 10, distraction = defines.distraction.by_anything })
biter.commandable.set_command({ type = defines.command.attack_area, destination = beacon.position, radius = 10, distraction = defines.distraction.by_anything })
end
end
--return (#biters or 0)

View File

@ -2,8 +2,6 @@
Journey, launch a rocket in increasingly harder getting worlds. - MewMew
]]--
require 'modules.rocket_launch_always_yields_science'
local Server = require 'utils.server'
local Constants = require 'maps.journey.constants'
local Functions = require 'maps.journey.functions'
@ -157,7 +155,7 @@ local function on_entity_damaged(event)
if event.force and event.force.name == 'enemy' then
Functions.deal_damage_to_beacon(journey, event.final_damage_amount)
end
entity.health = 200
entity.health = 1000
end
local function on_entity_died(event)
@ -166,7 +164,7 @@ local function on_entity_died(event)
end
local function on_rocket_launched(event)
local rocket_inventory = event.rocket.get_inventory(defines.inventory.rocket)
local rocket_inventory = event.rocket.cargo_pod.get_inventory(defines.inventory.cargo_unit)
local slot = rocket_inventory[1]
if slot and slot.valid and slot.valid_for_read then
if journey.mothership_cargo[slot.name] then
@ -185,6 +183,8 @@ local function on_rocket_launched(event)
end
end
end
rocket_inventory.clear()
rocket_inventory.insert({name = 'space-science-pack', count = 200})
Functions.draw_gui(journey)
end
@ -242,7 +242,7 @@ local function on_init()
T.main_caption_color = {r = 100, g = 20, b = 255}
T.sub_caption_color = {r = 100, g = 100, b = 100}
game.permissions.get_group('Default').set_allows_action(defines.input_action.set_auto_launch_rocket, false)
game.permissions.get_group('Default').set_allows_action(defines.input_action.set_rocket_silo_send_to_orbit_automated_mode, false)
Vacants.init(1, true)
Functions.hard_reset(journey)
end
@ -269,7 +269,7 @@ commands.add_command(
local s, player = cmd_handler()
if s then
Functions.hard_reset(journey)
game.print(player.name .. ' has reset the map.')
game.print(player and player.name or 'Server' .. ' has reset the map.')
end
end
)
@ -341,7 +341,7 @@ Event.add(defines.events.on_chunk_generated, on_chunk_generated)
Event.add(defines.events.on_player_joined_game, on_player_joined_game)
Event.add(defines.events.on_player_left_game, on_player_left_game)
Event.add(defines.events.on_player_changed_position, on_player_changed_position)
Event.add(defines.events.on_rocket_launched, on_rocket_launched)
Event.add(defines.events.on_rocket_launch_ordered, on_rocket_launched)
Event.add(defines.events.on_robot_built_entity, on_robot_built_entity)
Event.add(defines.events.on_built_entity, on_built_entity)
Event.add(defines.events.on_robot_mined_entity, on_robot_mined_entity)

View File

@ -180,8 +180,8 @@ Public.mountainous = {
local count = math_floor(math_sqrt(entity.position.x ^ 2 + entity.position.y ^ 2) * 0.05) + math_random(25, 75)
local ore_amount = math_floor(count * 0.85)
local stone_amount = math_floor(count * 0.15)
surface.spill_item_stack(entity.position, { name = ore, count = ore_amount }, true)
surface.spill_item_stack(entity.position, { name = 'stone', count = stone_amount }, true)
surface.spill_item_stack({position = entity.position, stack = { name = ore, count = ore_amount }, enable_looted = true})
surface.spill_item_stack({position = entity.position, stack = { name = 'stone', count = stone_amount }, enable_looted = true})
end,
on_chunk_generated = function (event, journey)
local surface = event.surface
@ -263,14 +263,14 @@ Public.tarball = {
target = event.area.left_top,
surface = event.surface,
tint = { r = 0.0, g = 0.0, b = 0.0, a = 0.45 },
render_layer = 'ground'
render_layer = 'ground-layer-1'
}
)
)
end,
clear = function (journey)
for _, id in pairs(journey.world_color_filters) do
rendering.destroy(id)
for _, color_filter in pairs(journey.world_color_filters) do
color_filter.destroy()
end
journey.world_color_filters = {}
end
@ -334,7 +334,7 @@ Public.wasteland = {
if math_random(1, 4) == 1 then
local slots = prototypes.entity[e.name].get_inventory_size(defines.inventory.chest)
local blacklist = LootRaffle.get_tech_blacklist(0.2)
local item_stacks = LootRaffle.roll(math_random(16, 64), slots, blacklist)
local item_stacks = LootRaffle.roll(math_random(16, 64), slots, blacklist) or {}
for _, item_stack in pairs(item_stacks) do
e.insert(item_stack)
end
@ -411,7 +411,7 @@ Public.volcanic = {
target = event.area.left_top,
surface = event.surface,
tint = { r = 0.55, g = 0.0, b = 0.0, a = 0.25 },
render_layer = 'ground'
render_layer = 'ground-layer-1'
}
)
)
@ -425,7 +425,7 @@ Public.volcanic = {
if surface.index ~= 1 then
return
end
if solid_tiles[surface.get_tile(player.position).name] then
if solid_tiles[surface.get_tile(player.position.x, player.position.y).name] then
return
end
surface.create_entity({ name = 'fire-flame', position = player.position })
@ -434,7 +434,7 @@ Public.volcanic = {
local surface = game.surfaces.nauvis
surface.request_to_generate_chunks({ x = 0, y = 0 }, 3)
surface.force_generate_chunk_requests()
surface.spill_item_stack({ 0, 0 }, { name = 'stone-brick', count = 4096 }, true)
surface.spill_item_stack({position = { 0, 0 }, stack = { name = 'stone-brick', count = 4096 }, enable_looted = true})
for x = -24, 24, 1 do
for y = -24, 24, 1 do
if math.sqrt(x ^ 2 + y ^ 2) < 24 then
@ -444,8 +444,8 @@ Public.volcanic = {
end
end,
clear = function (journey)
for _, id in pairs(journey.world_color_filters) do
rendering.destroy(id)
for _, color_filter in pairs(journey.world_color_filters) do
color_filter.destroy()
end
journey.world_color_filters = {}
end
@ -473,7 +473,7 @@ Public.infested = {
target = event.area.left_top,
surface = event.surface,
tint = { r = 0.8, g = 0.0, b = 0.8, a = 0.25 },
render_layer = 'ground'
render_layer = 'ground-layer-1'
}
)
)
@ -484,8 +484,8 @@ Public.infested = {
journey.world_specials['trees_frequency'] = 2
end,
clear = function (journey)
for _, id in pairs(journey.world_color_filters) do
rendering.destroy(id)
for _, color_filter in pairs(journey.world_color_filters) do
color_filter.destroy()
end
journey.world_color_filters = {}
end,

View File

@ -1,14 +0,0 @@
-- rocket launch always yields space science -- by mewmew
local Event = require 'utils.event'
local function on_rocket_launched(event)
local rocket_inventory = event.rocket.get_inventory(defines.inventory.rocket)
if rocket_inventory.get_item_count('satellite') > 0 then
return
end
local rocket_silo_inventory = event.rocket_silo.get_inventory(defines.inventory.rocket_silo_result)
rocket_silo_inventory.insert({name = 'space-science-pack', count = 1000})
end
Event.add(defines.events.on_rocket_launched, on_rocket_launched)

View File

@ -183,7 +183,7 @@ local item_worths = {
['power-armor'] = 2048,
['power-armor-mk2'] = 32768,
['solar-panel-equipment'] = 256,
['fusion-reactor-equipment'] = 15000,
['fission-reactor-equipment'] = 15000,
['energy-shield-equipment'] = 128,
['energy-shield-mk2-equipment'] = 2048,
['battery-equipment'] = 96,