1
0
mirror of https://github.com/ComfyFactory/ComfyFactorio.git synced 2025-01-04 00:15:45 +02:00

removed shadowing of local keys

This commit is contained in:
Gerkiz 2020-04-26 15:43:59 +02:00
parent eeb2b7790a
commit 40216c617c
16 changed files with 159 additions and 155 deletions

View File

@ -28,7 +28,7 @@ local size_of_vectors = #attack_vectors
local function get_active_biter_count()
local objective = Chrono_table.get_table()
local count = 0
for _, biter in pairs(objective.active_biters) do
for k, _ in pairs(objective.active_biters) do
count = count + 1
end
return count
@ -51,7 +51,7 @@ local function set_biter_raffle_table(surface)
end
end
local function is_biter_inactive(biter, unit_number)
local function is_biter_inactive(biter)
if not biter.entity then
--print("AI: active unit " .. unit_number .. " removed, possibly died.")
return true
@ -113,7 +113,7 @@ local function colonize(unit_group)
if biters[i].unit_group == unit_group then goodbiters[#goodbiters + 1] = biters[i] end
end
end
local eligible_spawns = 0
local eligible_spawns
if #goodbiters < 10 then
--game.print("no biters to colonize")
if #unit_group.members < 10 then
@ -141,11 +141,10 @@ local function colonize(unit_group)
end
if pos then
success = true
local e = nil
if math_random(1,5) == 1 then
e = surface.create_entity({name = worm_raffle[1 + math_floor((game.forces["enemy"].evolution_factor - 0.000001) * 4)], position = pos, force = unit_group.force})
surface.create_entity({name = worm_raffle[1 + math_floor((game.forces["enemy"].evolution_factor - 0.000001) * 4)], position = pos, force = unit_group.force})
else
e = surface.create_entity({name = spawner_raffle[math_random(1, #spawner_raffle)], position = pos, force = unit_group.force})
surface.create_entity({name = spawner_raffle[math_random(1, #spawner_raffle)], position = pos, force = unit_group.force})
end
--game.print("[gps=" .. e.position.x .. "," .. e.position.y .. "]")
else
@ -157,7 +156,7 @@ local function colonize(unit_group)
type = defines.command.attack,
target = obstacles[i],
distraction = defines.distraction.by_enemy
}
}
end
end
end
@ -197,7 +196,7 @@ Public.send_near_biters_to_objective = function()
if pollution > 200 * (1 / global.difficulty_vote_value) or objective.planet[1].name.id == 17 then
surface.pollute(random_target.position, -50 * (1 / global.difficulty_vote_value))
--game.print("sending objective wave")
success = true
success = true
else
if objective.chronojumps < 50 then
if math_random(1, 50 - objective.chronojumps) == 1 then success = true end
@ -256,7 +255,7 @@ local function select_units_around_spawner(spawner)
--Manual spawning of additional units
local size_of_biter_raffle = #objective.biter_raffle
if size_of_biter_raffle > 0 then
for c = 1, max_unit_count - unit_count, 1 do
for _ = 1, max_unit_count - unit_count, 1 do
local biter_name = objective.biter_raffle[math_random(1, size_of_biter_raffle)]
local position = spawner.surface.find_non_colliding_position(biter_name, spawner.position, 128, 2)
if not position then break end
@ -286,33 +285,33 @@ local function send_group(unit_group, nearest_player_unit)
local vector = attack_vectors[math_random(1, size_of_vectors)]
local position = {target.position.x + vector[1], target.position.y + vector[2]}
position = unit_group.surface.find_non_colliding_position("stone-furnace", position, 96, 1)
if position then
commands[#commands + 1] = {
type = defines.command.attack_area,
destination = position,
radius = 24,
distraction = defines.distraction.by_enemy
}
end
if position then
commands[#commands + 1] = {
type = defines.command.attack_area,
destination = position,
radius = 24,
distraction = defines.distraction.by_enemy
}
end
commands[#commands + 1] = {
type = defines.command.attack_area,
destination = target.position,
radius = 32,
distraction = defines.distraction.by_enemy
}
commands[#commands + 1] = {
type = defines.command.attack_area,
destination = target.position,
radius = 32,
distraction = defines.distraction.by_enemy
}
commands[#commands + 1] = {
type = defines.command.attack,
target = target,
distraction = defines.distraction.by_enemy
}
commands[#commands + 1] = {
type = defines.command.attack,
target = target,
distraction = defines.distraction.by_enemy
}
unit_group.set_command({
type = defines.command.compound,
structure_type = defines.compound_command.return_last,
commands = commands
})
unit_group.set_command({
type = defines.command.compound,
structure_type = defines.compound_command.return_last,
commands = commands
})
else
--game.print("not enough pollution for unit attack")
colonize(unit_group)
@ -422,7 +421,7 @@ Public.wake_up_sleepy_groups = function()
if objective.chronotimer < 100 then return end
local entity
local unit_group
for unit_number, biter in pairs(objective.active_biters) do
for _, biter in pairs(objective.active_biters) do
entity = biter.entity
if entity then
if entity.valid then

View File

@ -25,7 +25,7 @@ function Public_chrono.get_map_gen_settings()
end
function Public_chrono.restart_settings()
local objective = Chrono_table.get_table()
local objective = Chrono_table.get_table()
objective.max_health = 10000
objective.health = 10000
objective.poisontimeout = 0
@ -41,7 +41,7 @@ function Public_chrono.restart_settings()
objective.dangers = {}
objective.looted_nukes = 0
objective.offline_players = {}
objective.nextsurface = nil
objective.nextsurface = nil
for i = 1, 16, 1 do
objective.upgrades[i] = 0
end
@ -60,8 +60,8 @@ function Public_chrono.restart_settings()
global.landfill_history = {}
global.mining_history = {}
global.score = {}
global.difficulty_poll_closing_timeout = game.tick + 90000
global.difficulty_player_votes = {}
global.difficulty_poll_closing_timeout = game.tick + 90000
global.difficulty_player_votes = {}
game.difficulty_settings.technology_price_multiplier = 0.6
game.map_settings.enemy_evolution.destroy_factor = 0.005
@ -146,9 +146,9 @@ local function check_nuke_silos()
end
end
function Public_chrono.process_jump(choice)
function Public_chrono.process_jump()
local objective = Chrono_table.get_table()
local overstayed = overstayed()
local _overstayed = overstayed()
objective.chronojumps = objective.chronojumps + 1
objective.chrononeeds = 2000 + 300 * objective.chronojumps
objective.active_biters = {}
@ -156,7 +156,7 @@ function Public_chrono.process_jump(choice)
objective.biter_raffle = {}
objective.passivetimer = 0
objective.chronotimer = 0
objective.dangertimer = 1200
objective.dangertimer = 1200
local message = "Comfylatron: Wheeee! Time Jump Active! This is Jump number " .. objective.chronojumps
game.print(message, {r=0.98, g=0.66, b=0.22})
Server.to_discord_embed(message)
@ -173,7 +173,7 @@ function Public_chrono.process_jump(choice)
game.print({"chronosphere.message_quest5"}, {r=0.98, g=0.36, b=0.22})
objective.computermessage = 5
end
if overstayed then
if _overstayed then
game.print({"chronosphere.message_overstay"}, {r=0.98, g=0.36, b=0.22})
end
if objective.planet[1].name.id == 19 then

View File

@ -64,10 +64,10 @@ end
function Public.determine_planet(choice)
local objective = Chrono_table.get_table()
local weight = variants[#variants].cumul_chance
local planet_choice = nil
local ores = math_random(1, 9)
local dayspeed = time_speed_variants[math_random(1, #time_speed_variants)]
local daytime = math_random(1,100) / 100
local planet_choice
if objective.game_lost then
choice = 15
ores = 2
@ -77,7 +77,7 @@ function Public.determine_planet(choice)
ores = 10
end
if objective.config.jumpfailure == true and objective.game_lost == false then
if objective.chronojumps == 21 or objective.chronojumps == 29 or chronojumps == 36 or chronojumps == 42 then
if objective.chronojumps == 21 or objective.chronojumps == 29 or objective.chronojumps == 36 or objective.chronojumps == 42 then
choice = 19
ores = 10
dayspeed = time_speed_variants[1]

View File

@ -1,5 +1,5 @@
local Chrono_table = require 'maps.chronosphere.table'
local event = require 'utils.event'
local Event = require 'utils.event'
local math_random = math.random
@ -87,7 +87,7 @@ local texts = {
"They just wanted to deliver some fish so I pressed that button and then this happened",
"Maybe it was just a cat walking on my keyboard who caused this time travel fiasco",
"3...2...1...jump time! errr...I mean...desync time!",
"Just let me deliver the fish. They start to smell a bit. Luckily I don't have a nose"
"Just let me deliver the fish. They start to smell a bit. Luckily I don't have a nose"
},
["alone"] = {
"comfy ^.^",
@ -393,7 +393,7 @@ local function spawn_comfylatron(surface_index, x, y)
end
objective.comfylatron = surface.create_entity({
name = "compilatron",
position = {x,y + math_random(0,256)},
position = {x,y + math_random(0,256)},
force = "player",
create_build_effect_smoke = false
})
@ -429,5 +429,5 @@ local function on_tick()
end
end
event.add(defines.events.on_entity_damaged, on_entity_damaged)
event.add(defines.events.on_tick, on_tick)
Event.add(defines.events.on_entity_damaged, on_entity_damaged)
Event.add(defines.events.on_tick, on_tick)

View File

@ -1,17 +1,16 @@
-- config tab for chronotrain--
local Tabs = require 'comfy_panel.main'
local Chrono_table = require 'maps.chronosphere.table'
local functions = {
["comfy_panel_offline_accidents"] = function(event)
local objective = Chrono_table.get_table()
["comfy_panel_offline_accidents"] = function(event)
local objective = Chrono_table.get_table()
if game.players[event.player_index].admin then
if event.element.switch_state == "left" then
objective.config.offline_loot = true
else
objective.config.offline_loot = false
end
if event.element.switch_state == "left" then
objective.config.offline_loot = true
else
objective.config.offline_loot = false
end
else
game.players[event.player_index].print("You are not admin!")
end
@ -21,10 +20,10 @@ local functions = {
local objective = Chrono_table.get_table()
if game.players[event.player_index].admin then
if event.element.switch_state == "left" then
objective.config.jumpfailure = true
else
objective.config.jumpfailure = false
end
objective.config.jumpfailure = true
else
objective.config.jumpfailure = false
end
else
game.players[event.player_index].print("You are not admin!")
end
@ -33,7 +32,8 @@ local functions = {
local function add_switch(element, switch_state, name, description_main, description)
local t = element.add({type = "table", column_count = 5})
local label = t.add({type = "label", caption = "ON"})
local label
label = t.add({type = "label", caption = "ON"})
label.style.padding = 0
label.style.left_padding= 10
label.style.font_color = {0.77, 0.77, 0.77}
@ -41,18 +41,18 @@ local function add_switch(element, switch_state, name, description_main, descrip
switch.switch_state = switch_state
switch.style.padding = 0
switch.style.margin = 0
local label = t.add({type = "label", caption = "OFF"})
label = t.add({type = "label", caption = "OFF"})
label.style.padding = 0
label.style.font_color = {0.70, 0.70, 0.70}
local label = t.add({type = "label", caption = description_main})
label = t.add({type = "label", caption = description_main})
label.style.padding = 2
label.style.left_padding= 10
label.style.minimal_width = 120
label.style.font = "heading-2"
label.style.font_color = {0.88, 0.88, 0.99}
local label = t.add({type = "label", caption = description})
label = t.add({type = "label", caption = description})
label.style.padding = 2
label.style.left_padding= 10
label.style.single_line = false
@ -60,24 +60,23 @@ local function add_switch(element, switch_state, name, description_main, descrip
label.style.font_color = {0.85, 0.85, 0.85}
end
local build_config_gui = (function (player, frame)
local build_config_gui = (function (frame)
local objective = Chrono_table.get_table()
local switch_state
frame.clear()
local line_elements = {}
local switch_label_elements = {}
local label_elements = {}
line_elements[#line_elements + 1] = frame.add({type = "line"})
local switch_state = "right"
switch_state = "right"
if objective.config.offline_loot then switch_state = "left" end
add_switch(frame, switch_state, "comfy_panel_offline_accidents", "Offline Accidents", "Disablesr enables dropping of inventory when player goes offline.\nTimer is 15 minutes.")
line_elements[#line_elements + 1] = frame.add({type = "line"})
if objective.auto_hotbar_enabled then
local switch_state = "right"
switch_state = "right"
if objective.config.jumpfailure then switch_state = "left" end
add_switch(frame, switch_state, "comfy_panel_danger_events", "Dangerous Events", "Disables or enables dangerous event maps\n(they require at least 2-4 capable players to survive)")
line_elements[#line_elements + 1] = frame.add({type = "line"})

View File

@ -2,7 +2,6 @@ local Chrono_table = require 'maps.chronosphere.table'
local Public_gui = {}
local math_floor = math.floor
local math_ceil = math.ceil
local math_abs = math.abs
local math_max = math.max
local math_min = math.min
@ -11,24 +10,26 @@ local Upgrades = require "maps.chronosphere.upgrade_list"
local function create_gui(player)
local frame = player.gui.top.add({ type = "frame", name = "chronosphere"})
frame.style.maximal_height = 38
local label
local button
local label = frame.add({ type = "label", caption = " ", name = "label"})
label = frame.add({ type = "label", caption = " ", name = "label"})
label.style.font_color = {r=0.88, g=0.88, b=0.88}
label.style.font = "default-bold"
label.style.font_color = {r=0.33, g=0.66, b=0.9}
local label = frame.add({ type = "label", caption = " ", name = "jump_number"})
label = frame.add({ type = "label", caption = " ", name = "jump_number"})
label.style.font_color = {r=0.88, g=0.88, b=0.88}
label.style.font = "default-bold"
label.style.right_padding = 4
label.style.font_color = {r=0.33, g=0.66, b=0.9}
local label = frame.add({ type = "label", caption = " ", name = "charger"})
label = frame.add({ type = "label", caption = " ", name = "charger"})
label.style.font = "default-bold"
label.style.left_padding = 4
label.style.font_color = {r = 255, g = 200, b = 200} --255 200 200 --150 0 255
local label = frame.add({ type = "label", caption = " ", name = "charger_value"})
label = frame.add({ type = "label", caption = " ", name = "charger_value"})
label.style.font = "default-bold"
label.style.right_padding = 1
label.style.minimal_width = 10
@ -39,25 +40,25 @@ local function create_gui(player)
progressbar.style.maximal_width = 96
progressbar.style.top_padding = 10
local label = frame.add({ type = "label", caption = " ", name = "timer"})
label = frame.add({ type = "label", caption = " ", name = "timer"})
label.style.font = "default-bold"
label.style.right_padding = 1
label.style.minimal_width = 10
label.style.font_color = {r = 255, g = 200, b = 200}
local label = frame.add({ type = "label", caption = " ", name = "timer_value", tooltip = " "})
label = frame.add({ type = "label", caption = " ", name = "timer_value", tooltip = " "})
label.style.font = "default-bold"
label.style.right_padding = 1
label.style.minimal_width = 10
label.style.font_color = {r = 255, g = 200, b = 200}
local label = frame.add({ type = "label", caption = " ", name = "timer2"})
label = frame.add({ type = "label", caption = " ", name = "timer2"})
label.style.font = "default-bold"
label.style.right_padding = 1
label.style.minimal_width = 10
label.style.font_color = {r = 0, g = 200, b = 0}
local label = frame.add({ type = "label", caption = " ", name = "timer_value2"})
label = frame.add({ type = "label", caption = " ", name = "timer_value2"})
label.style.font = "default-bold"
label.style.right_padding = 1
label.style.minimal_width = 10
@ -67,12 +68,12 @@ local function create_gui(player)
-- line.style.left_padding = 4
-- line.style.right_padding = 8
local button = frame.add({type = "button", caption = " ", name = "planet_button"})
button = frame.add({type = "button", caption = " ", name = "planet_button"})
button.style.font = "default-bold"
button.style.font_color = { r=0.99, g=0.99, b=0.99}
button.style.minimal_width = 75
local button = frame.add({type = "button", caption = " ", name = "upgrades_button"})
button = frame.add({type = "button", caption = " ", name = "upgrades_button"})
button.style.font = "default-bold"
button.style.font_color = { r=0.99, g=0.99, b=0.99}
button.style.minimal_width = 75
@ -193,6 +194,7 @@ end
local function upgrades_gui(player)
if player.gui.screen["gui_upgrades"] then player.gui.screen["gui_upgrades"].destroy() return end
local objective = Chrono_table.get_table()
local costs = {}
local upgrades = Upgrades.upgrades()
local frame = player.gui.screen.add{type = "frame", name = "gui_upgrades", caption = "ChronoTrain Upgrades", direction = "vertical"}
frame.location = {x = 350, y = 45}
@ -211,7 +213,7 @@ local function upgrades_gui(player)
local maxed = upg_table.add({type = "sprite-button", name = "maxed" .. i, enabled = false, sprite = "virtual-signal/signal-check", tooltip = "Upgrade maxed!", visible = false})
local jumps = upg_table.add({type = "sprite-button", name = "jump_req" .. i, enabled = false, sprite = "virtual-signal/signal-J", number = upgrades[i].jump_limit, tooltip = "Required jump number", visible = true})
local costs = {}
for index,item in pairs(upgrades[i].cost) do
costs[index] = upg_table.add({type = "sprite-button", name = index .. "-" .. i, number = item.count, sprite = item.sprite, enabled = false, tooltip = {item.tt .. "." .. item.name}, visible = true})
end
@ -230,6 +232,7 @@ local function upgrades_gui(player)
end
end
frame.add({type = "button", name = "close_upgrades", caption = "Close"})
return costs
end
local function planet_gui(player)
@ -245,7 +248,7 @@ local function planet_gui(player)
frame.style.maximal_width = 400
local l = {}
l[1] = frame.add({type = "label", name = "planet_name", caption = {"chronosphere.gui_planet_0", planet.name.name}})
l[2] = frame.add({type = "label", caption = {"chronosphere.gui_planet_1"}})
l[2] = frame.add({type = "label", caption = {"chronosphere.gui_planet_1"}})
local table0 = frame.add({type = "table", name = "planet_ores", column_count = 3})
table0.add({type = "sprite-button", name = "iron-ore", sprite = "item/iron-ore", enabled = false, number = planet.name.iron})
table0.add({type = "sprite-button", name = "copper-ore", sprite = "item/copper-ore", enabled = false, number = planet.name.copper})
@ -266,6 +269,7 @@ local function planet_gui(player)
-- for i = 1, 3, 1 do
-- l[i].style.font = "default-game"
-- end
return l
end
function Public_gui.on_gui_click(event)

View File

@ -8,6 +8,8 @@ local function math_sgn(x)
end
function Public.locomotive_spawn(surface, position, wagons)
surface.request_to_generate_chunks({0,0}, 0.5)
surface.force_generate_chunk_requests()
local objective = Chrono_table.get_table()
if objective.planet[1].name.id == 17 then --fish market
position.x = position.x - 960

View File

@ -28,6 +28,8 @@ local math_floor = math.floor
local math_sqrt = math.sqrt
require "maps.chronosphere.config_tab"
local Public = {}
local starting_items = {['pistol'] = 1, ['firearm-magazine'] = 32, ['grenade'] = 4, ['raw-fish'] = 4, ['rail'] = 16, ['wood'] = 16}
local function generate_overworld(surface, optplanet)
@ -79,12 +81,6 @@ local function generate_overworld(surface, optplanet)
local mgs = surface.map_gen_settings
mgs.width = 2176
surface.map_gen_settings = mgs
surface.request_to_generate_chunks({-960,-64}, 3)
--surface.request_to_generate_chunks({0,0}, 3)
surface.force_generate_chunk_requests()
else
surface.request_to_generate_chunks({0,0}, 3)
surface.force_generate_chunk_requests()
end
end
@ -216,9 +212,9 @@ local function set_objective_health(final_damage_amount)
rendering.set_text(objective.health_text, "HP: " .. objective.health .. " / " .. objective.max_health)
end
local function chronojump(choice)
function Public.chronojump(choice)
local objective = Chrono_table.get_table()
if objective.game_lost then return end
if objective.game_lost then goto continue end
Chrono.process_jump()
local oldsurface = game.surfaces[objective.active_surface_index]
@ -227,28 +223,29 @@ local function chronojump(choice)
if player.surface == oldsurface then
if player.controller_type == defines.controllers.editor then player.toggle_map_editor() end
local wagons = {objective.locomotive_cargo[1], objective.locomotive_cargo[2], objective.locomotive_cargo[3]}
Locomotive.enter_cargo_wagon(player, wagons[math_random(1,3)])
Locomotive.enter_cargo_wagon(player, wagons[math.random(1,3)])
end
end
objective.lab_cells = {}
objective.active_surface_index = game.create_surface("chronosphere" .. objective.chronojumps, Chrono.get_map_gen_settings()).index
local surface = game.surfaces[objective.active_surface_index]
log("seed of new surface: " .. surface.map_gen_settings.seed)
local planet = nil
local planet = objective.planet
if choice then
Planets.determine_planet(choice)
planet = objective.planet
end
generate_overworld(surface, planet)
game.forces.player.set_spawn_position({12, 10}, surface)
Locomotive.locomotive_spawn(surface, {x = 16, y = 10}, Chrono.get_wagons(false))
--if objective.locomotive == nil then Locomotive.locomotive_spawn(surface, {x = 16, y = 10}, Chrono.get_wagons(false)) end
render_train_hp()
game.delete_surface(oldsurface)
Chrono.post_jump()
Event_functions.flamer_nerfs()
surface.pollute(objective.locomotive.position, 150 * (4 / (objective.upgrades[2] / 2 + 1)) * (1 + objective.chronojumps) * global.difficulty_vote_value)
::continue::
end
local tick_minute_functions = {
@ -305,12 +302,24 @@ local function tick()
objective.chronotimer = objective.chronotimer + 1
objective.passivetimer = objective.passivetimer + 1
if objective.chronojumps > 0 then
game.surfaces[objective.active_surface_index].pollute(objective.locomotive.position, (0.5 * objective.chronojumps) * (4 / (objective.upgrades[2] / 2 + 1)) * global.difficulty_vote_value)
if objective.locomotive ~= nil then
local surface = game.surfaces[objective.active_surface_index]
local pos = objective.locomotive.position or {x=0,y=0}
if surface and surface.valid then
game.surfaces[objective.active_surface_index].pollute(
pos,
(0.5 * objective.chronojumps) *
(4 / (objective.upgrades[2] / 2 + 1)) *
global.difficulty_vote_value)
end
end
end
if objective.planet[1].name.id == 19 then
Tick_functions.dangertimer()
end
if Tick_functions.check_chronoprogress() then chronojump(nil) end
if Tick_functions.check_chronoprogress() then
Public.chronojump(nil)
end
end
if tick % 120 == 0 then
Tick_functions.move_items()
@ -568,7 +577,7 @@ if _DEBUG then
p = log
end
end
chronojump(param)
Public.chronojump(param)
end)
end
--Time for the debug code. If any (not global.) globals are written to at this point, an error will be thrown.
@ -583,3 +592,5 @@ end
-- return global[n];
-- end
--})
return Public

View File

@ -2,10 +2,7 @@ local Chrono_table = require 'maps.chronosphere.table'
local Public_ores = {}
local simplex_noise = require 'utils.simplex_noise'.d2
local math_random = math.random
local math_abs = math.abs
local math_floor = math.floor
local math_sqrt = math.sqrt
local ores = {"copper-ore", "iron-ore", "stone", "coal"}
local function draw_noise_ore_patch(position, name, surface, radius, richness, mixed)
if not position then return end
@ -13,26 +10,26 @@ local function draw_noise_ore_patch(position, name, surface, radius, richness, m
if not surface then return end
if not radius then return end
if not richness then return end
local noise
local ore_raffle = {
"iron-ore", "iron-ore", "iron-ore", "copper-ore", "copper-ore", "coal", "stone"
}
local seed = surface.map_gen_settings.seed
local noise_seed_add = 25000
local richness_part = richness / radius
for y = radius * -3, radius * 3, 1 do
for x = radius * -3, radius * 3, 1 do
local pos = {x = x + position.x + 0.5, y = y + position.y + 0.5}
local noise_1 = simplex_noise(pos.x * 0.0125, pos.y * 0.0125, seed)
local noise_2 = simplex_noise(pos.x * 0.1, pos.y * 0.1, seed + 25000)
local noise = noise_1 + noise_2 * 0.12
noise = noise_1 + noise_2 * 0.12
local distance_to_center = math.sqrt(x^2 + y^2)
local a = richness - richness_part * distance_to_center
if distance_to_center < radius - math.abs(noise * radius * 0.85) and a > 1 then
pos = surface.find_non_colliding_position(name, pos, 64, 1, true)
if not pos then return end
if mixed then
local noise = simplex_noise(pos.x * 0.005, pos.y * 0.005, seed) + simplex_noise(pos.x * 0.01, pos.y * 0.01, seed) * 0.3 + simplex_noise(pos.x * 0.05, pos.y * 0.05, seed) * 0.2
local i = (math_floor(noise * 100) % 7) + 1
noise = simplex_noise(pos.x * 0.005, pos.y * 0.005, seed) + simplex_noise(pos.x * 0.01, pos.y * 0.01, seed) * 0.3 + simplex_noise(pos.x * 0.05, pos.y * 0.05, seed) * 0.2
local i = (math_floor(noise * 100) % 7) + 1
name = ore_raffle[i]
end
local entity = {name = name, position = pos, amount = a}
@ -46,7 +43,7 @@ end
local function get_size_of_ore(ore, planet)
local base_size = math_random(5, 10) + math_floor(planet[1].ore_richness.factor * 3)
local final_size = 1
local final_size
if planet[1].name.id == 1 and ore == "iron-ore" then --iron planet
final_size = math_floor(base_size * 1.5)
elseif planet[1].name.id == 2 and ore == "copper-ore" then --copper planet
@ -84,7 +81,6 @@ local function spawn_ore_vein(surface, pos, planet)
local uranium = {w = planet[1].name.uranium, t = coal.t + planet[1].name.uranium}
local oil = {w = planet[1].name.oil, t = uranium.t + planet[1].name.oil}
local total = iron.w + copper.w + stone.w + coal.w + uranium.w + oil.w
local roll = math_random (0, oil.t)
if roll == 0 then return end
local choice = nil

View File

@ -13,8 +13,8 @@ Global.register(
)
function Public.reset_table()
for k, v in pairs(chronosphere) do
chronosphere[k] = nil
for k, _ in pairs(chronosphere) do
chronosphere[k] = nil
end
chronosphere.computermessage = 0
chronosphere.config = {}
@ -38,7 +38,7 @@ function Public.reset_table()
chronosphere.dangers = {}
chronosphere.looted_nukes = 0
chronosphere.offline_players = {}
chronosphere.nextsurface = nil
chronosphere.nextsurface = nil
chronosphere.upgrades = {}
chronosphere.outchests = {}
chronosphere.upgradechest = {}

View File

@ -59,10 +59,6 @@ local modifiers_diagonal = {
{diagonal = {x = -1, y = -1}, connection_1 = {x = -1, y = 0}, connection_2 = {x = 0, y = -1}}
}
local function pos_to_key(position)
return tostring(position.x .. "_" .. position.y)
end
local function get_noise(name, pos, seed)
local noise = 0
local d = 0
@ -77,7 +73,7 @@ end
local function get_size_of_ore(ore, planet)
local base_size = 0.04 + 0.04 * planet[1].ore_richness.factor
local final_size = 1
local final_size
if planet[1].name.id == 1 and ore == "iron-ore" then --iron planet
final_size = base_size * 5
elseif planet[1].name.id == 2 and ore == "copper-ore" then --copper planet
@ -136,7 +132,7 @@ local function process_labyrinth_cell(pos, seed)
return true
end
local function process_dangerevent_position(p, seed, tiles, entities, treasure, planet)
local function process_dangerevent_position(p, seed, tiles, entities)
local scrapyard = get_noise("scrapyard", p, seed)
--Chasms
local noise_cave_ponds = get_noise("cave_ponds", p, seed)
@ -316,9 +312,8 @@ local function process_rocky_position(p, seed, tiles, entities, treasure, planet
elseif roll > 820 and math_sqrt(p.x * p.x + p.y * p.y) > 150 then
entities[#entities + 1] = {name = worm_raffle[math_random(1 + math_floor(game.forces["enemy"].evolution_factor * 8), math_floor(1 + game.forces["enemy"].evolution_factor * 16))], position = p}
else
end
if math_random(1, 1024) == 1 then treasure[#treasure + 1] = p end
if math_random(1, 1024) == 1 then treasure[#treasure + 1] = p end
return
end
@ -425,7 +420,6 @@ local function process_river_position(p, seed, tiles, entities, treasure, planet
if math_random(1,2048) == 1 then treasure[#treasure + 1] = p end
end
if noise_forest_location > 0.9 then
local tree = tree_raffle[math_random(1, s_tree_raffle)]
if math_random(1,100) > 42 then entities[#entities + 1] = {name = tree_raffle[math_random(1, s_tree_raffle)], position = p} end
return
end
@ -439,7 +433,6 @@ end
local function process_biter_position(p, seed, tiles, entities, treasure, planet)
local objective = Chrono_table.get_table()
local scrapyard = get_noise("scrapyard", p, seed)
local noise_forest_location = get_noise("forest_location", p, seed)
local large_caves = get_noise("large_caves", p, seed)
local biters = planet[1].name.biters
local ore_size = planet[1].ore_richness.factor
@ -471,7 +464,7 @@ local function process_biter_position(p, seed, tiles, entities, treasure, planet
if objective.chronojumps > 20 then jumps = 100 end
local roll = math_random(1,200 - jumps - biters)
if math_sqrt(p.x * p.x + p.y * p.y) > 200 + handicap then
if roll == 1 then
if roll == 1 then
entities[#entities + 1] = {name = spawner_raffle[math_random(1, 4)], position = p}
elseif roll == 2 then
entities[#entities + 1] = {name = worm_raffle[math_random(1 + math_floor(game.forces["enemy"].evolution_factor * 8), math_floor(1 + game.forces["enemy"].evolution_factor * 16))], position = p}
@ -487,7 +480,7 @@ end
local function process_scrapyard_position(p, seed, tiles, entities, treasure, planet)
local objective = Chrono_table.get_table()
local scrapyard = get_noise("scrapyard", p, seed)
local biters = planet[1].name.biters
--local biters = planet[1].name.biters
--Chasms
local noise_cave_ponds = get_noise("cave_ponds", p, seed)
local small_caves = get_noise("small_caves", p, seed)
@ -508,8 +501,8 @@ local function process_scrapyard_position(p, seed, tiles, entities, treasure, pl
end
tiles[#tiles + 1] = {name = "dirt-7", position = p}
if scrapyard < -0.55 or scrapyard > 0.55 then
if math_random(1,40) == 1 and math_sqrt(p.x * p.x + p.y * p.y) > 150 then entities[#entities + 1] = {name = spawner_raffle[math_random(1, 4)], position = p} end
return
if math_random(1,40) == 1 and math_sqrt(p.x * p.x + p.y * p.y) > 150 then entities[#entities + 1] = {name = spawner_raffle[math_random(1, 4)], position = p} end
return
end
if scrapyard + 0.5 > -0.05 - 0.1 * planet[1].name.moisture and scrapyard + 0.5 < 0.05 + 0.1 * planet[1].name.moisture then
if math_random(1,100) > 42 then entities[#entities + 1] = {name = tree_raffle[math_random(1, s_tree_raffle)], position = p} end
@ -545,7 +538,7 @@ end
local function process_swamp_position(p, seed, tiles, entities, treasure, planet)
local scrapyard = get_noise("scrapyard", p, seed)
local biters = planet[1].name.biters
--local biters = planet[1].name.biters
if scrapyard < -0.70 or scrapyard > 0.70 then
tiles[#tiles + 1] = {name = "grass-3", position = p}
@ -590,18 +583,18 @@ local function process_fish_position(p, seed, tiles, entities, treasure, planet)
local body_circle_center_1 = {x = body_center_position.x, y = body_center_position.y - body_spacing}
local body_circle_center_2 = {x = body_center_position.x, y = body_center_position.y + body_spacing}
local fin_radius = 200
local square_fin_radius = fin_radius ^ 2
local fin_circle_center_1 = {x = -600, y = 0}
local fin_circle_center_2 = {x = -600 - 120, y = 0}
--local fin_radius = 200
--local square_fin_radius = fin_radius ^ 2
--local fin_circle_center_1 = {x = -600, y = 0}
--local fin_circle_center_2 = {x = -600 - 120, y = 0}
--if math_abs(p.y) > 480 and p.x <= 160 and p.x > body_center_position.x then return true end
--Main Fish Body
local distance_to_center_1 = ((p.x - body_circle_center_1.x)^2 + (p.y - body_circle_center_1.y)^2)
local distance_to_center_2 = ((p.x - body_circle_center_2.x)^2 + (p.y - body_circle_center_2.y)^2)
local distance_to_fin_1 = ((p.x - fin_circle_center_1.x)^2 + (p.y - fin_circle_center_1.y)^2)
local distance_to_fin_2 = ((p.x - fin_circle_center_2.x)^2 + (p.y - fin_circle_center_2.y)^2)
--local distance_to_fin_1 = ((p.x - fin_circle_center_1.x)^2 + (p.y - fin_circle_center_1.y)^2)
--local distance_to_fin_2 = ((p.x - fin_circle_center_2.x)^2 + (p.y - fin_circle_center_2.y)^2)
local eye_center = {x = -500, y = -150}
@ -660,7 +653,7 @@ local function process_fish_position(p, seed, tiles, entities, treasure, planet)
end
local levels = {
process_level_1_position,
--process_level_1_position,
process_dangerevent_position,
process_hedgemaze_position,
process_rocky_position,
@ -683,7 +676,7 @@ local entity_functions = {
Treasure(surface, entity.position, entity.name)
end,
["lab"] = function(surface, entity)
local objective = Chrono_table.get_table()
local objective = Chrono_table.get_table()
local e = surface.create_entity(entity)
local evo = 1 + math_min(math_floor(objective.chronojumps / 4), 4)
local research = {
@ -861,7 +854,7 @@ local function fish_chunk(surface, left_top, level, planet)
entity_functions[game.entity_prototypes[entity.name].type](surface, entity)
else
if surface.can_place_entity(entity) then
local e = surface.create_entity(entity)
surface.create_entity(entity)
end
end
end
@ -903,18 +896,18 @@ local function normal_chunk(surface, left_top, level, planet)
end
end
for y = 0, 31, 1 do
for x = 0, 31, 1 do
local p = {x = left_top.x + x, y = left_top.y + y}
process_level(p, seed, tiles, entities, treasure, planet, cell, things)
end
end
for x = 0, 31, 1 do
local p = {x = left_top.x + x, y = left_top.y + y}
process_level(p, seed, tiles, entities, treasure, planet, cell, things)
end
end
else
for y = 0, 31, 1 do
for x = 0, 31, 1 do
local p = {x = left_top.x + x, y = left_top.y + y}
process_level(p, seed, tiles, entities, treasure, planet)
end
end
for x = 0, 31, 1 do
local p = {x = left_top.x + x, y = left_top.y + y}
process_level(p, seed, tiles, entities, treasure, planet)
end
end
end
surface.set_tiles(tiles, true)

View File

@ -64,7 +64,7 @@ function Public_terrain.fish_market(surface, left_top)
market.destructible = false
market.operable = false
market.minable = false
local repair_text = rendering.draw_text{
rendering.draw_text{
text = "Fish Market",
surface = surface,
target = market,
@ -80,7 +80,7 @@ function Public_terrain.fish_market(surface, left_top)
fishchest.minable = false
fishchest.operable = false
objective.fishchest = fishchest
local repair_text = rendering.draw_text{
rendering.draw_text{
text = "Deposit fish here",
surface = surface,
target = fishchest,

View File

@ -195,7 +195,7 @@ end
function Public_tick.offline_players()
local objective = Chrono_table.get_table()
if objective.chronotimer > objective.chrononeeds - 182 or objective.passivetimer < 30 then return end
local current_tick = game.tick
--local current_tick = game.tick
local players = objective.offline_players
local surface = game.surfaces[objective.active_surface_index]
if #players > 0 then
@ -229,7 +229,7 @@ function Public_tick.offline_players()
if #items > 0 then
for item = 1, #items, 1 do
if items[item].valid then
inv.insert(items[item])
inv.insert(items[item])
end
end
game.print({"chronosphere.message_accident"}, {r=0.98, g=0.66, b=0.22})

View File

@ -1,6 +1,5 @@
local Chrono_table = require 'maps.chronosphere.table'
local math_random = math.random
local math_sqrt = math.sqrt
local Public = {}
@ -171,7 +170,7 @@ function Public.treasure_chest(surface, position, container_name)
if distance_to_center > 1 then distance_to_center = 1 end
for _, t in pairs (chest_loot) do
for x = 1, t.weight, 1 do
for _ = 1, t.weight, 1 do
--if math_random(1,50) == 1 then log(distance_to_center) end
if t.d_min <= distance_to_center and t.d_max >= distance_to_center then
table.insert(chest_raffle, t[1])
@ -182,7 +181,7 @@ function Public.treasure_chest(surface, position, container_name)
local e = surface.create_entity({name = container_name, position=position, force="neutral", create_build_effect_smoke = false})
e.minable = false
local i = e.get_inventory(defines.inventory.chest)
for x = 1, math_random(2,6), 1 do
for _ = 1, math_random(2,6), 1 do
local loot = chest_raffle[math_random(1,#chest_raffle)]
i.insert(loot)
end

View File

@ -25,7 +25,7 @@ function Public.upgrades()
--First additional parameter for tooltip should match the max_level
--still need to map upgrade effects in upgrades.lua / process_upgrade() if it should do more than increase level of upgrade
local upgrades = {
[1] = {
[1] = {
name = {"chronosphere.upgrade_train_armor"},
sprite = "recipe/locomotive",
max_level = 36,

View File

@ -1,6 +1,5 @@
local Chrono_table = require 'maps.chronosphere.table'
local Public = {}
local math_floor = math.floor
local Server = require 'utils.server'
local Upgrades = require "maps.chronosphere.upgrade_list"
@ -23,8 +22,8 @@ local function check_win()
objective.game_lost = true
objective.chronotimer = 200000000 - 300
for _, player in pairs(game.connected_players) do
player.play_sound{path="utility/game_won", volume_modifier=0.85}
end
player.play_sound{path="utility/game_won", volume_modifier=0.85}
end
local message = {"chronosphere.message_game_won1"}
local message2 = "Number of delivered fish: " .. objective.mainscore
game.print(message, {r=0.98, g=0.66, b=0.22})
@ -82,7 +81,7 @@ end
local function upgrade_out()
local objective = Chrono_table.get_table()
if not game.surfaces["cargo_wagon"] then return end
local positions = {{-16,-62},{15,-62},{-16,66},{15,66}}
local positions = {{-16,-62},{15,-62},{-16,66},{15,66}}
local out = {}
for i = 1, 4, 1 do
local e = game.surfaces["cargo_wagon"].create_entity({name = "steel-chest", position = positions[i], force = "player"})
@ -101,6 +100,7 @@ local function upgrade_out()
scale_with_zoom = false
}
end
return out
end
local function upgrade_storage()
@ -157,6 +157,7 @@ end
local function mk2_buy()
local objective = Chrono_table.get_table()
if objective.upgradechest[13] and objective.upgradechest[13].valid then
local inv = objective.upgradechest[14].get_inventory(defines.inventory.chest)
inv.insert({name = "power-armor-mk2", count = 1})
end
end