mirror of
https://github.com/ComfyFactory/ComfyFactorio.git
synced 2025-02-03 13:12:11 +02:00
updates
This commit is contained in:
parent
e0cf887347
commit
2543abbc72
@ -187,6 +187,7 @@ Public.send_near_biters_to_objective = function()
|
||||
if not global.locomotive_cargo3 then return end
|
||||
local targets = {global.locomotive, global.locomotive, global.locomotive_cargo, global.locomotive_cargo2, global.locomotive_cargo3}
|
||||
local random_target = targets[math_random(1, #targets)]
|
||||
if random_target.valid then return end
|
||||
local surface = random_target.surface
|
||||
local pollution = surface.get_pollution(random_target.position)
|
||||
local success = false
|
||||
|
@ -17,7 +17,7 @@ local variants = {
|
||||
[12] = {id = 12, name = "choppy planet", iron = 0, copper = 0, coal = 0, stone = 0, uranium = 0, oil = 1, biters = 6, moisture = 0.4, chance = 2, cumul_chance = 21},
|
||||
[13] = {id = 13, name = "river planet", iron = 1, copper = 1, coal = 3, stone = 1, uranium = 0, oil = 0, biters = 8, moisture = 0.5, chance = 2, cumul_chance = 23},
|
||||
[14] = {id = 14, name = "lava planet", iron = 1, copper = 1, coal = 1, stone = 1, uranium = 0, oil = 0, biters = 6, moisture = -0.5, chance = 1, cumul_chance = 24},
|
||||
[15] = {id = 15, name = "start planet", iron = 3, copper = 3, coal = 3, stone = 3, uranium = 0, oil = 0, biters = 1, moisture = -0.3, chance = 0, cumul_chance = 24},
|
||||
[15] = {id = 15, name = "start planet", iron = 3, copper = 3, coal = 3, stone = 3, uranium = 0, oil = 0, biters = 1, moisture = -0.3, chance = 0, cumul_chance = 24}
|
||||
|
||||
}
|
||||
|
||||
@ -58,24 +58,28 @@ end
|
||||
function Public.determine_planet(choice)
|
||||
local weight = variants[#variants].cumul_chance
|
||||
local planet_choice = nil
|
||||
local ores = math_random(1, #richness)
|
||||
if global.objective.game_lost then
|
||||
choice = 15
|
||||
ores = 2
|
||||
end
|
||||
if not choice then
|
||||
planet_choice = roll(weight)
|
||||
else
|
||||
planet_choice = variants[choice]
|
||||
if variants[choice] then
|
||||
planet_choice = variants[choice]
|
||||
else
|
||||
planet_choice = roll(weight)
|
||||
end
|
||||
end
|
||||
local planet = {
|
||||
[1] = {
|
||||
name = planet_choice,
|
||||
day_speed = time_speed_variants[math_random(1, #time_speed_variants)],
|
||||
time = math_random(1,100) / 100,
|
||||
ore_richness = richness[math_random(1, #richness)],
|
||||
ore_richness = richness[ores],
|
||||
}
|
||||
}
|
||||
if global.objective.game_lost then
|
||||
planet[1].name = variants[15]
|
||||
planet[1].ore_richness = richness[2]
|
||||
end
|
||||
return planet
|
||||
global.objective.planet = planet
|
||||
end
|
||||
|
||||
return Public
|
||||
|
@ -123,9 +123,9 @@ local function update_gui(player)
|
||||
[5] = {c = "--\n"}
|
||||
}
|
||||
local upgt = {
|
||||
[1] = {t = "[1]: + 5000 Train Max HP. Current: " .. objective.max_health .. "\n Cost : " .. math_floor(2500 * (1 + objective.hpupgradetier /4)) .. " coins + 3000 copper plates\n"},
|
||||
[1] = {t = "[1]: + 5000 Train Max HP. Current: " .. objective.max_health .. "\n Cost : " .. math_floor(2000 * (1 + objective.hpupgradetier /4)) .. " coins + 3000 copper plates\n"},
|
||||
[2] = {t = "[2]: Pollution Filter. Actual value of pollution made: " .. math_floor(300/(objective.filterupgradetier/3+1)) .. "%\n Buyable once per 3 jumps.\n Cost: 5000 coins + 2000 green circuits\n"},
|
||||
[3] = {t = "[3]: Add additional row of Acumulators.\n Cost: 2500 coins + 200 batteries\n"},
|
||||
[3] = {t = "[3]: Add additional row of Acumulators.\n Cost : " .. math_floor(2000 * (1 + objective.acuupgradetier /4)) .. " coins + 200 batteries\n"},
|
||||
[4] = {t = "[4]: Add item pickup distance to players.Current: +" .. objective.pickupupgradetier .. ",\n Cost: " .. 1000 * (1 + objective.pickupupgradetier) .. " coins + 400 red inserters\n"},
|
||||
[5] = {t = "[5]: Add +5 inventory slots. Buyable once per 5 jumps.\n Cost: " .. 2000 * (1 + objective.invupgradetier) .." coins + " .. chests[objective.invupgradetier + 1].c},
|
||||
[6] = {t = "[6]: Use up more repair tools on train at once. Current: +" .. objective.toolsupgradetier .. "\n Cost: " .. 1000 * (1 + objective.toolsupgradetier) .. " coins + " .. 200 * (1 + objective.toolsupgradetier) .. " repair tools\n"},
|
||||
|
@ -1,4 +1,3 @@
|
||||
require "maps.chronosphere.comfylatron"
|
||||
local Public = {}
|
||||
local math_floor = math.floor
|
||||
local math_random = math.random
|
||||
@ -101,38 +100,6 @@ function Public.fish_tag()
|
||||
text = " "
|
||||
})
|
||||
end
|
||||
--[[
|
||||
local function accelerate()
|
||||
if not global.locomotive then return end
|
||||
if not global.locomotive.valid then return end
|
||||
if global.locomotive.get_driver() then return end
|
||||
global.locomotive_driver = global.locomotive.surface.create_entity({name = "character", position = global.locomotive.position, force = "player"})
|
||||
global.locomotive_driver.driving = true
|
||||
global.locomotive_driver.riding_state = {acceleration = defines.riding.acceleration.accelerating, direction = defines.riding.direction.straight}
|
||||
end
|
||||
|
||||
local function remove_acceleration()
|
||||
if not global.locomotive then return end
|
||||
if not global.locomotive.valid then return end
|
||||
if global.locomotive_driver then global.locomotive_driver.destroy() end
|
||||
global.locomotive_driver = nil
|
||||
end
|
||||
]]
|
||||
function spawn_acumulators()
|
||||
local x = -28
|
||||
local y = -252
|
||||
local yy = global.objective.acuupgradetier * 2
|
||||
local surface = game.surfaces["cargo_wagon"]
|
||||
if yy > 8 then yy = yy + 2 end
|
||||
if yy > 26 then yy = yy + 2 end
|
||||
if yy > 44 then yy = yy + 2 end
|
||||
for i = 1, 27, 1 do
|
||||
local acumulator = surface.create_entity({name = "accumulator", position = {x + 2 * i, y + yy}, force="player", create_build_effect_smoke = false})
|
||||
acumulator.minable = false
|
||||
acumulator.destructible = false
|
||||
table.insert(global.acumulators, acumulator)
|
||||
end
|
||||
end
|
||||
|
||||
local market_offers = {
|
||||
{price = {{'coin', 10}}, offer = {type = 'give-item', item = "raw-fish"}},
|
||||
@ -433,21 +400,21 @@ local function create_wagon_room()
|
||||
for _, offer in pairs(market_offers) do market.add_market_item(offer) end
|
||||
|
||||
--generate cars--
|
||||
for _, x in pairs({width * -0.5 -0.5, width * 0.5 + 0.5}) do
|
||||
for _, x in pairs({width * -0.5 -1.4, width * 0.5 + 1.4}) do
|
||||
local e = surface.create_entity({name = "car", position = {x, 0}, force = "player", create_build_effect_smoke = false})
|
||||
e.get_inventory(defines.inventory.fuel).insert({name = "wood", count = 16})
|
||||
e.destructible = false
|
||||
e.minable = false
|
||||
e.operable = false
|
||||
end
|
||||
for _, x in pairs({width * -0.5 - 0.5, width * 0.5 + 0.5}) do
|
||||
for _, x in pairs({width * -0.5 - 1.4, width * 0.5 + 1.4}) do
|
||||
local e = surface.create_entity({name = "car", position = {x, -128}, force = "player", create_build_effect_smoke = false})
|
||||
e.get_inventory(defines.inventory.fuel).insert({name = "wood", count = 16})
|
||||
e.destructible = false
|
||||
e.minable = false
|
||||
e.operable = false
|
||||
end
|
||||
for _, x in pairs({width * -0.5 - 0.5, width * 0.5 + 0.5}) do
|
||||
for _, x in pairs({width * -0.5 - 1.4, width * 0.5 + 1.4}) do
|
||||
local e = surface.create_entity({name = "car", position = {x, 128}, force = "player", create_build_effect_smoke = false})
|
||||
e.get_inventory(defines.inventory.fuel).insert({name = "wood", count = 16})
|
||||
e.destructible = false
|
||||
@ -587,47 +554,10 @@ function Public.enter_cargo_wagon(player, vehicle)
|
||||
local x_vector = (vehicle.position.x / math.abs(vehicle.position.x)) * 2
|
||||
local y_vector = vehicle.position.y / 16
|
||||
local position = {global.locomotive_cargo2.position.x + x_vector, global.locomotive_cargo2.position.y + y_vector}
|
||||
local position = surface.find_non_colliding_position("character", position, 128, 0.5)
|
||||
if not position then return end
|
||||
player.teleport(position, surface)
|
||||
local position2 = surface.find_non_colliding_position("character", position, 128, 0.5)
|
||||
if not position2 then return end
|
||||
player.teleport(position2, surface)
|
||||
end
|
||||
end
|
||||
|
||||
-- local function clear_offers(market)
|
||||
-- for i = 1, 256, 1 do
|
||||
-- local a = market.remove_market_item(1)
|
||||
-- if a == false then return end
|
||||
-- end
|
||||
-- end
|
||||
|
||||
-- function Public.refresh_offers(event)
|
||||
--
|
||||
-- local market = event.entity or event.market
|
||||
-- if not market then return end
|
||||
-- if not market.valid then return end
|
||||
-- if market.name ~= "market" then return end
|
||||
-- if market ~= global.upgrademarket then return end
|
||||
-- clear_offers(market)
|
||||
-- setup_upgrade_shop(market)
|
||||
-- end
|
||||
|
||||
-- function Public.offer_purchased(event)
|
||||
-- local offer_index = event.offer_index
|
||||
-- if not market_offers2[offer_index] then return end
|
||||
-- local market = event.market
|
||||
-- if not market.name == "market" then return end
|
||||
--
|
||||
-- market_offers2[offer_index]()
|
||||
--
|
||||
-- count = event.count
|
||||
-- if count > 1 then
|
||||
-- local offers = market.get_market_items()
|
||||
-- local price = offers[offer_index].price[1].amount
|
||||
-- game.players[event.player_index].insert({name = "coin", count = price * (count - 1)})
|
||||
-- end
|
||||
-- Public.refresh_offers(event)
|
||||
-- end
|
||||
|
||||
|
||||
|
||||
return Public
|
||||
|
@ -10,8 +10,7 @@ require "modules.no_deconstruction_of_neutral_entities"
|
||||
require "modules.shotgun_buff"
|
||||
require "modules.mineable_wreckage_yields_scrap"
|
||||
require "maps.chronosphere.comfylatron"
|
||||
require "maps.chronosphere.chronobubles"
|
||||
require "maps.chronosphere.ores"
|
||||
require "maps.chronosphere.terrain"
|
||||
require "on_tick_schedule"
|
||||
require "modules.biter_noms_you"
|
||||
local Server = require 'utils.server'
|
||||
@ -19,10 +18,11 @@ local Ai = require "maps.chronosphere.ai"
|
||||
local unearthing_worm = require "functions.unearthing_worm"
|
||||
local unearthing_biters = require "functions.unearthing_biters"
|
||||
local tick_tack_trap = require "functions.tick_tack_trap"
|
||||
local chronobuble = require "maps.chronosphere.chronobubles"
|
||||
local level_depth = require "maps.chronosphere.terrain"
|
||||
local Planets = require "maps.chronosphere.chronobubles"
|
||||
local Ores =require "maps.chronosphere.ores"
|
||||
local Reset = require "functions.soft_reset"
|
||||
local Map = require "modules.map_info"
|
||||
local Upgrades = require "maps.chronosphere.upgrades"
|
||||
local Locomotive = require "maps.chronosphere.locomotive"
|
||||
local Modifier = require "player_modifiers"
|
||||
local update_gui = require "maps.chronosphere.gui"
|
||||
@ -30,10 +30,10 @@ local math_random = math.random
|
||||
local math_floor = math.floor
|
||||
local math_sqrt = math.sqrt
|
||||
local chests = {}
|
||||
local Public = {}
|
||||
--local acus = {}
|
||||
global.objective = {}
|
||||
global.flame_boots = {}
|
||||
global.comfylatron = nil
|
||||
|
||||
local choppy_entity_yield = {
|
||||
["tree-01"] = {"iron-ore"},
|
||||
@ -42,21 +42,15 @@ local choppy_entity_yield = {
|
||||
["tree-08-brown"] = {"stone"}
|
||||
}
|
||||
|
||||
|
||||
local starting_items = {['pistol'] = 1, ['firearm-magazine'] = 16, ['grenade'] = 1, ['raw-fish'] = 4, ['rail'] = 16, ['wood'] = 16}
|
||||
local starting_items = {['pistol'] = 1, ['firearm-magazine'] = 32, ['grenade'] = 4, ['raw-fish'] = 4, ['rail'] = 16, ['wood'] = 16}
|
||||
local starting_cargo = {['firearm-magazine'] = 16, ['iron-plate'] = 16, ['wood'] = 16, ['burner-mining-drill'] = 8}
|
||||
|
||||
function generate_overworld(surface, optplanet)
|
||||
local planet = nil
|
||||
if not optplanet then
|
||||
planet = chronobuble.determine_planet(nil)
|
||||
local message = "Planet info: " .. planet[1].name.name .. ", Ore richness: " .. planet[1].ore_richness.name .. ", Speed of day: " .. planet[1].day_speed.name
|
||||
game.print(message, {r=0.98, g=0.66, b=0.22})
|
||||
Server.to_discord_embed(message)
|
||||
global.objective.planet = planet
|
||||
else
|
||||
planet = optplanet
|
||||
end
|
||||
local function generate_overworld(surface, optplanet)
|
||||
Planets.determine_planet(optplanet)
|
||||
local planet = global.objective.planet
|
||||
local message = "Planet info: " .. planet[1].name.name .. ", Ore richness: " .. planet[1].ore_richness.name .. ", Speed of day: " .. planet[1].day_speed.name
|
||||
game.print(message, {r=0.98, g=0.66, b=0.22})
|
||||
Server.to_discord_embed(message)
|
||||
if planet[1].name.name == "choppy planet" then
|
||||
game.print("Comfylatron: OwO what are those strange trees?!? They have ore fruits! WTF!", {r=0.98, g=0.66, b=0.22})
|
||||
elseif planet[1].name.name == "lava planet" then
|
||||
@ -116,8 +110,8 @@ end
|
||||
local function get_map_gen_settings()
|
||||
local map_gen_settings = {
|
||||
["seed"] = math_random(1, 1000000),
|
||||
["width"] = level_depth,
|
||||
["height"] = level_depth,
|
||||
["width"] = 960,
|
||||
["height"] = 960,
|
||||
["water"] = 0.1,
|
||||
["starting_area"] = 1,
|
||||
["cliff_settings"] = {cliff_elevation_interval = 0, cliff_elevation_0 = 0},
|
||||
@ -159,22 +153,19 @@ local function render_train_hp()
|
||||
end
|
||||
|
||||
|
||||
function Public.reset_map()
|
||||
local function reset_map()
|
||||
global.chunk_queue = {}
|
||||
if game.surfaces["chronosphere"] then game.delete_surface(game.surfaces["chronosphere"]) end
|
||||
if game.surfaces["cargo_wagon"] then game.delete_surface(game.surfaces["cargo_wagon"]) end
|
||||
chests = {}
|
||||
local map_gen_settings = get_map_gen_settings()
|
||||
local planet = nil
|
||||
Planets.determine_planet(nil)
|
||||
local planet = global.objective.planet
|
||||
if not global.active_surface_index then
|
||||
global.active_surface_index = game.create_surface("chronosphere", map_gen_settings).index
|
||||
else
|
||||
planet = chronobuble.determine_planet(nil)
|
||||
|
||||
global.objective.planet = planet
|
||||
game.forces.player.set_spawn_position({12, 10}, game.surfaces[global.active_surface_index])
|
||||
global.active_surface_index = Reset.soft_reset_map(game.surfaces[global.active_surface_index], map_gen_settings, starting_items).index
|
||||
game.print("Planet info: " .. planet[1].name.name .. ", Ore richness: " .. planet[1].ore_richness.name .. ", Speed of day: " .. planet[1].day_speed.name, {r=0.98, g=0.66, b=0.22})
|
||||
end
|
||||
|
||||
local surface = game.surfaces[global.active_surface_index]
|
||||
@ -204,9 +195,9 @@ function Public.reset_map()
|
||||
|
||||
|
||||
game.difficulty_settings.technology_price_multiplier = 0.6
|
||||
game.map_settings.enemy_evolution.destroy_factor = 0.006
|
||||
game.map_settings.enemy_evolution.destroy_factor = 0.005
|
||||
game.map_settings.enemy_evolution.pollution_factor = 0
|
||||
game.map_settings.enemy_evolution.time_factor = 8e-05
|
||||
game.map_settings.enemy_evolution.time_factor = 7e-05
|
||||
game.map_settings.enemy_expansion.enabled = true
|
||||
game.map_settings.enemy_expansion.max_expansion_cooldown = 3600
|
||||
game.map_settings.enemy_expansion.min_expansion_cooldown = 3600
|
||||
@ -218,9 +209,9 @@ function Public.reset_map()
|
||||
game.map_settings.pollution.max_pollution_to_restore_trees = 0
|
||||
game.map_settings.pollution.pollution_with_max_forest_damage = 10
|
||||
game.map_settings.pollution.pollution_per_tree_damage = 0.5
|
||||
game.map_settings.pollution.ageing = 0
|
||||
game.map_settings.pollution.ageing = 0.1
|
||||
game.map_settings.pollution.diffusion_ratio = 0.1
|
||||
game.map_settings.pollution.enemy_attack_pollution_consumption_modifier = 0.5
|
||||
game.map_settings.pollution.enemy_attack_pollution_consumption_modifier = 0.75
|
||||
|
||||
game.forces.player.technologies["land-mine"].enabled = false
|
||||
game.forces.player.technologies["landfill"].enabled = false
|
||||
@ -243,8 +234,6 @@ local function on_player_joined_game(event)
|
||||
local player = game.players[event.player_index]
|
||||
global.flame_boots[event.player_index] = {fuel = 1}
|
||||
if not global.flame_boots[event.player_index].steps then global.flame_boots[event.player_index].steps = {} end
|
||||
--log(chronobuble.determine_planet())
|
||||
|
||||
--set_difficulty()
|
||||
|
||||
local surface = game.surfaces[global.active_surface_index]
|
||||
@ -302,289 +291,6 @@ local function repair_train()
|
||||
end
|
||||
end
|
||||
|
||||
local function check_upgrades()
|
||||
local objective = global.objective
|
||||
if not game.surfaces["cargo_wagon"] then return end
|
||||
if objective.game_lost == true then return end
|
||||
if global.hpchest and global.hpchest.valid then
|
||||
local inv = global.hpchest.get_inventory(defines.inventory.chest)
|
||||
local countcoins = inv.get_item_count("coin")
|
||||
local count2 = inv.get_item_count("copper-plate")
|
||||
local coincost = math_floor(2500 * (1 + objective.hpupgradetier /4))
|
||||
if countcoins >= coincost and count2 >= 3000 and objective.hpupgradetier < 18 then
|
||||
inv.remove({name = "coin", count = coincost})
|
||||
inv.remove({name = "copper-plate", count = 3000})
|
||||
game.print("Comfylatron: Train's max HP was upgraded.", {r=0.98, g=0.66, b=0.22})
|
||||
objective.hpupgradetier = objective.hpupgradetier + 1
|
||||
objective.max_health = 10000 + 5000 * objective.hpupgradetier
|
||||
rendering.set_text(global.objective.health_text, "HP: " .. global.objective.health .. " / " .. global.objective.max_health)
|
||||
end
|
||||
end
|
||||
if global.filterchest and global.filterchest.valid then
|
||||
local inv = global.filterchest.get_inventory(defines.inventory.chest)
|
||||
local countcoins = inv.get_item_count("coin")
|
||||
local count2 = inv.get_item_count("electronic-circuit")
|
||||
if countcoins >= 5000 and count2 >= 2000 and objective.filterupgradetier < 9 and objective.chronojumps >= (objective.filterupgradetier + 1) * 3 then
|
||||
inv.remove({name = "coin", count = 5000})
|
||||
inv.remove({name = "electronic-circuit", count = 2000})
|
||||
game.print("Comfylatron: Train's pollution filter was upgraded.", {r=0.98, g=0.66, b=0.22})
|
||||
objective.filterupgradetier = objective.filterupgradetier + 1
|
||||
end
|
||||
end
|
||||
if global.acuchest and global.acuchest.valid then
|
||||
local inv = global.acuchest.get_inventory(defines.inventory.chest)
|
||||
local countcoins = inv.get_item_count("coin")
|
||||
local count2 = inv.get_item_count("battery")
|
||||
if countcoins >= 2500 and count2 >= 200 and objective.acuupgradetier < 24 then
|
||||
inv.remove({name = "coin", count = 2500})
|
||||
inv.remove({name = "battery", count = 200})
|
||||
game.print("Comfylatron: Train's acumulator capacity was upgraded.", {r=0.98, g=0.66, b=0.22})
|
||||
objective.acuupgradetier = objective.acuupgradetier + 1
|
||||
spawn_acumulators()
|
||||
end
|
||||
end
|
||||
if global.playerchest and global.playerchest.valid then
|
||||
local inv = global.playerchest.get_inventory(defines.inventory.chest)
|
||||
local countcoins = inv.get_item_count("coin")
|
||||
local count2 = inv.get_item_count("long-handed-inserter")
|
||||
local coincost = 1000 * (1 + objective.pickupupgradetier)
|
||||
if countcoins >= coincost and count2 >= 400 and objective.pickupupgradetier < 4 then
|
||||
inv.remove({name = "coin", count = coincost})
|
||||
inv.remove({name = "long-handed-inserter", count = 400})
|
||||
game.print("Comfylatron: Players now have additional red inserter installed on shoulders, increasing their item pickup range.", {r=0.98, g=0.66, b=0.22})
|
||||
objective.pickupupgradetier = objective.pickupupgradetier + 1
|
||||
game.forces.player.character_loot_pickup_distance_bonus = game.forces.player.character_loot_pickup_distance_bonus + 1
|
||||
end
|
||||
end
|
||||
if global.invchest and global.invchest.valid then
|
||||
local inv = global.invchest.get_inventory(defines.inventory.chest)
|
||||
local countcoins = inv.get_item_count("coin")
|
||||
local item = "computer"
|
||||
if objective.invupgradetier == 0 then
|
||||
item = "wooden-chest"
|
||||
elseif objective.invupgradetier == 1 then
|
||||
item = "iron-chest"
|
||||
elseif objective.invupgradetier == 2 then
|
||||
item = "steel-chest"
|
||||
elseif objective.invupgradetier == 3 then
|
||||
item = "logistic-chest-storage"
|
||||
end
|
||||
local count2 = inv.get_item_count(item)
|
||||
local coincost = 2000 * (1 + objective.invupgradetier)
|
||||
if countcoins >= coincost and count2 >= 250 and objective.invupgradetier < 4 and objective.chronojumps >= (objective.invupgradetier + 1) * 5 then
|
||||
inv.remove({name = "coin", count = coincost})
|
||||
inv.remove({name = item, count = 250})
|
||||
game.print("Comfylatron: Players now can carry more trash in their unsorted inventories.", {r=0.98, g=0.66, b=0.22})
|
||||
objective.invupgradetier = objective.invupgradetier + 1
|
||||
game.forces.player.character_inventory_slots_bonus = game.forces.player.character_inventory_slots_bonus + 10
|
||||
end
|
||||
end
|
||||
|
||||
if global.toolschest and global.toolschest.valid then
|
||||
local inv = global.toolschest.get_inventory(defines.inventory.chest)
|
||||
local countcoins = inv.get_item_count("coin")
|
||||
local count2 = inv.get_item_count("repair-pack")
|
||||
local coincost = 1000 * (1 + objective.toolsupgradetier)
|
||||
local toolscost = 200 * (1 + objective.toolsupgradetier)
|
||||
if countcoins >= coincost and count2 >= toolscost and objective.toolsupgradetier < 4 then
|
||||
inv.remove({name = "coin", count = coincost})
|
||||
inv.remove({name = "repair-pack", count = toolscost})
|
||||
game.print("Comfylatron: Train now gets repaired with additional repair kit at once.", {r=0.98, g=0.66, b=0.22})
|
||||
objective.toolsupgradetier = objective.toolsupgradetier + 1
|
||||
end
|
||||
end
|
||||
if global.waterchest and global.waterchest.valid and game.surfaces["cargo_wagon"].valid then
|
||||
local inv = global.waterchest.get_inventory(defines.inventory.chest)
|
||||
local countcoins = inv.get_item_count("coin")
|
||||
local count2 = inv.get_item_count("pipe")
|
||||
if countcoins >= 2000 and count2 >= 500 and objective.waterupgradetier < 1 then
|
||||
inv.remove({name = "coin", count = 2000})
|
||||
inv.remove({name = "pipe", count = 500})
|
||||
game.print("Comfylatron: Train now has piping system for additional water sources.", {r=0.98, g=0.66, b=0.22})
|
||||
objective.waterupgradetier = objective.waterupgradetier + 1
|
||||
local e1 = game.surfaces["cargo_wagon"].create_entity({name = "offshore-pump", position = {28,66}, force="player"})
|
||||
local e2 = game.surfaces["cargo_wagon"].create_entity({name = "offshore-pump", position = {28,-62}, force = "player"})
|
||||
local e3 = game.surfaces["cargo_wagon"].create_entity({name = "offshore-pump", position = {-29,66}, force = "player"})
|
||||
local e4 = game.surfaces["cargo_wagon"].create_entity({name = "offshore-pump", position = {-29,-62}, force = "player"})
|
||||
e1.destructible = false
|
||||
e1.minable = false
|
||||
e2.destructible = false
|
||||
e2.minable = false
|
||||
e3.destructible = false
|
||||
e3.minable = false
|
||||
e4.destructible = false
|
||||
e4.minable = false
|
||||
end
|
||||
end
|
||||
if global.outchest and global.outchest.valid and game.surfaces["cargo_wagon"].valid then
|
||||
local inv = global.outchest.get_inventory(defines.inventory.chest)
|
||||
local countcoins = inv.get_item_count("coin")
|
||||
local count2 = inv.get_item_count("fast-inserter")
|
||||
if countcoins >= 2000 and count2 >= 100 and objective.outupgradetier < 1 then
|
||||
inv.remove({name = "coin", count = 2000})
|
||||
inv.remove({name = "fast-inserter", count = 100})
|
||||
game.print("Comfylatron: Train now has output chests.", {r=0.98, g=0.66, b=0.22})
|
||||
objective.outupgradetier = objective.outupgradetier + 1
|
||||
local e = {}
|
||||
e[1] = game.surfaces["cargo_wagon"].create_entity({name="compilatron-chest", position= {-16,-62}, force = "player"})
|
||||
e[2] = game.surfaces["cargo_wagon"].create_entity({name="compilatron-chest", position= {15,-62}, force = "player"})
|
||||
e[3] = game.surfaces["cargo_wagon"].create_entity({name="compilatron-chest", position= {-16,66}, force = "player"})
|
||||
e[4] = game.surfaces["cargo_wagon"].create_entity({name="compilatron-chest", position= {15,66}, force = "player"})
|
||||
|
||||
local out = {}
|
||||
for i = 1, 4, 1 do
|
||||
e[i].destructible = false
|
||||
e[i].minable = false
|
||||
global.outchests[i] = e[i]
|
||||
out[i] = rendering.draw_text{
|
||||
text = "Output",
|
||||
surface = e[i].surface,
|
||||
target = e[i],
|
||||
target_offset = {0, -1.5},
|
||||
color = global.locomotive.color,
|
||||
scale = 0.80,
|
||||
font = "default-game",
|
||||
alignment = "center",
|
||||
scale_with_zoom = false
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
||||
if global.boxchest and global.boxchest.valid and game.surfaces["cargo_wagon"].valid then
|
||||
local inv = global.boxchest.get_inventory(defines.inventory.chest)
|
||||
local countcoins = inv.get_item_count("coin")
|
||||
local item = "computer"
|
||||
if objective.boxupgradetier == 0 then
|
||||
item = "wooden-chest"
|
||||
elseif objective.boxupgradetier == 1 then
|
||||
item = "iron-chest"
|
||||
elseif objective.boxupgradetier == 2 then
|
||||
item = "steel-chest"
|
||||
elseif objective.boxupgradetier == 3 then
|
||||
item = "logistic-chest-storage"
|
||||
end
|
||||
local count2 = inv.get_item_count(item)
|
||||
if countcoins >= 5000 and count2 >= 250 and objective.boxupgradetier < 4 and objective.chronojumps >= (objective.boxupgradetier + 1) * 5 then
|
||||
inv.remove({name = "coin", count = 5000})
|
||||
inv.remove({name = item, count = 250})
|
||||
game.print("Comfylatron: Cargo wagons now have enlargened storage.", {r=0.98, g=0.66, b=0.22})
|
||||
objective.boxupgradetier = objective.boxupgradetier + 1
|
||||
local chests = {}
|
||||
for i = 1, 58, 1 do
|
||||
if objective.boxupgradetier == 1 then
|
||||
chests[#chests + 1] = {name="wooden-chest", position= {-33 ,-189 + i}, force = "player"}
|
||||
chests[#chests + 1] = {name="wooden-chest", position= {32 ,-189 + i}, force = "player"}
|
||||
elseif objective.boxupgradetier == 2 then
|
||||
chests[#chests + 1] = {name="iron-chest", position= {-33 ,-189 + i}, force = "player", fast_replace = true}
|
||||
chests[#chests + 1] = {name="iron-chest", position= {32 ,-189 + i}, force = "player", fast_replace = true}
|
||||
elseif objective.boxupgradetier == 3 then
|
||||
chests[#chests + 1] = {name="steel-chest", position= {-33 ,-189 + i}, force = "player", fast_replace = true}
|
||||
chests[#chests + 1] = {name="steel-chest", position= {32 ,-189 + i}, force = "player", fast_replace = true}
|
||||
elseif objective.boxupgradetier == 4 then
|
||||
chests[#chests + 1] = {name="logistic-chest-storage", position= {-33 ,-189 + i}, force = "player", fast_replace = true}
|
||||
chests[#chests + 1] = {name="logistic-chest-storage", position= {32 ,-189 + i}, force = "player", fast_replace = true}
|
||||
end
|
||||
end
|
||||
for i = 1, 58, 1 do
|
||||
if objective.boxupgradetier == 1 then
|
||||
chests[#chests + 1] = {name="wooden-chest", position= {-33 ,-127 + i}, force = "player"}
|
||||
chests[#chests + 1] = {name="wooden-chest", position= {32 ,-127 + i}, force = "player"}
|
||||
elseif objective.boxupgradetier == 2 then
|
||||
chests[#chests + 1] = {name="iron-chest", position= {-33 ,-127 + i}, force = "player", fast_replace = true}
|
||||
chests[#chests + 1] = {name="iron-chest", position= {32 ,-127 + i}, force = "player", fast_replace = true}
|
||||
elseif objective.boxupgradetier == 3 then
|
||||
chests[#chests + 1] = {name="steel-chest", position= {-33 ,-127 + i}, force = "player", fast_replace = true}
|
||||
chests[#chests + 1] = {name="steel-chest", position= {32 ,-127 + i}, force = "player", fast_replace = true}
|
||||
elseif objective.boxupgradetier == 4 then
|
||||
chests[#chests + 1] ={name="logistic-chest-storage", position= {-33 ,-127 + i}, force = "player", fast_replace = true}
|
||||
chests[#chests + 1] ={name="logistic-chest-storage", position= {32 ,-127 + i}, force = "player", fast_replace = true}
|
||||
end
|
||||
end
|
||||
for i = 1, 58, 1 do
|
||||
if objective.boxupgradetier == 1 then
|
||||
chests[#chests + 1] = {name="wooden-chest", position= {-33 ,-61 + i}, force = "player"}
|
||||
chests[#chests + 1] = {name="wooden-chest", position= {32 ,-61 + i}, force = "player"}
|
||||
elseif objective.boxupgradetier == 2 then
|
||||
chests[#chests + 1] = {name="iron-chest", position= {-33 ,-61 + i}, force = "player", fast_replace = true}
|
||||
chests[#chests + 1] = {name="iron-chest", position= {32 ,-61 + i}, force = "player", fast_replace = true}
|
||||
elseif objective.boxupgradetier == 3 then
|
||||
chests[#chests + 1] = {name="steel-chest", position= {-33 ,-61 + i}, force = "player", fast_replace = true}
|
||||
chests[#chests + 1] = {name="steel-chest", position= {32 ,-61 + i}, force = "player", fast_replace = true}
|
||||
elseif objective.boxupgradetier == 4 then
|
||||
chests[#chests + 1] = {name="logistic-chest-storage", position= {-33 ,-61 + i}, force = "player", fast_replace = true}
|
||||
chests[#chests + 1] = {name="logistic-chest-storage", position= {32 ,-61 + i}, force = "player", fast_replace = true}
|
||||
end
|
||||
end
|
||||
for i = 1, 58, 1 do
|
||||
if objective.boxupgradetier == 1 then
|
||||
chests[#chests + 1] = {name="wooden-chest", position= {-33 ,1 + i}, force = "player"}
|
||||
chests[#chests + 1] = {name="wooden-chest", position= {32 ,1 + i}, force = "player"}
|
||||
elseif objective.boxupgradetier == 2 then
|
||||
chests[#chests + 1] = {name="iron-chest", position= {-33 ,1 + i}, force = "player", fast_replace = true}
|
||||
chests[#chests + 1] = {name="iron-chest", position= {32 ,1 + i}, force = "player", fast_replace = true}
|
||||
elseif objective.boxupgradetier == 3 then
|
||||
chests[#chests + 1] = {name="steel-chest", position= {-33 ,1 + i}, force = "player", fast_replace = true}
|
||||
chests[#chests + 1] = {name="steel-chest", position= {32 ,1 + i}, force = "player", fast_replace = true}
|
||||
elseif objective.boxupgradetier == 4 then
|
||||
chests[#chests + 1] = {name="logistic-chest-storage", position= {-33 ,1 + i}, force = "player", fast_replace = true}
|
||||
chests[#chests + 1] = {name="logistic-chest-storage", position= {32 ,1 + i}, force = "player", fast_replace = true}
|
||||
end
|
||||
end
|
||||
for i = 1, 58, 1 do
|
||||
if objective.boxupgradetier == 1 then
|
||||
chests[#chests + 1] = {name="wooden-chest", position= {-33 ,67 + i}, force = "player"}
|
||||
chests[#chests + 1] = {name="wooden-chest", position= {32 ,67 + i}, force = "player"}
|
||||
elseif objective.boxupgradetier == 2 then
|
||||
chests[#chests + 1] = {name="iron-chest", position= {-33 ,67 + i}, force = "player", fast_replace = true}
|
||||
chests[#chests + 1] = {name="iron-chest", position= {32 ,67 + i}, force = "player", fast_replace = true}
|
||||
elseif objective.boxupgradetier == 3 then
|
||||
chests[#chests + 1] = {name="steel-chest", position= {-33 ,67 + i}, force = "player", fast_replace = true}
|
||||
chests[#chests + 1] = {name="steel-chest", position= {32 ,67 + i}, force = "player", fast_replace = true}
|
||||
elseif objective.boxupgradetier == 4 then
|
||||
chests[#chests + 1] = {name="logistic-chest-storage", position= {-33 ,67 + i}, force = "player", fast_replace = true}
|
||||
chests[#chests + 1] = {name="logistic-chest-storage", position= {32 ,67 + i}, force = "player", fast_replace = true}
|
||||
end
|
||||
end
|
||||
for i = 1, 58, 1 do
|
||||
if objective.boxupgradetier == 1 then
|
||||
chests[#chests + 1] = {name="wooden-chest", position= {-33 ,129 + i}, force = "player"}
|
||||
chests[#chests + 1] = {name="wooden-chest", position= {32 ,129 + i}, force = "player"}
|
||||
elseif objective.boxupgradetier == 2 then
|
||||
chests[#chests + 1] = {name="iron-chest", position= {-33 ,129 + i}, force = "player", fast_replace = true}
|
||||
chests[#chests + 1] = {name="iron-chest", position= {32 ,129 + i}, force = "player", fast_replace = true}
|
||||
elseif objective.boxupgradetier == 3 then
|
||||
chests[#chests + 1] = {name="steel-chest", position= {-33 ,129 + i}, force = "player", fast_replace = true}
|
||||
chests[#chests + 1] = {name="steel-chest", position= {32 ,129 + i}, force = "player", fast_replace = true}
|
||||
elseif objective.boxupgradetier == 4 then
|
||||
chests[#chests + 1] = {name="logistic-chest-storage", position= {-33 ,129 + i}, force = "player", fast_replace = true}
|
||||
chests[#chests + 1] = {name="logistic-chest-storage", position= {32 ,129 + i}, force = "player", fast_replace = true}
|
||||
end
|
||||
end
|
||||
local surface = game.surfaces["cargo_wagon"]
|
||||
for i = 1, #chests, 1 do
|
||||
surface.set_tiles({{name = "tutorial-grid", position = chests[i].position}})
|
||||
local e = surface.create_entity(chests[i])
|
||||
local old = nil
|
||||
if e.name == "iron-chest" then old = surface.find_entity("wooden-chest", e.position)
|
||||
elseif e.name == "steel-chest" then old = surface.find_entity("iron-chest", e.position)
|
||||
elseif e.name == "logistic-chest-storage" then old = surface.find_entity("steel-chest", e.position)
|
||||
end
|
||||
if old then
|
||||
local items = old.get_inventory(defines.inventory.chest).get_contents()
|
||||
for item, count in pairs(items) do
|
||||
e.insert({name = item, count = count})
|
||||
end
|
||||
old.destroy()
|
||||
end
|
||||
e.destructible = false
|
||||
e.minable = false
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
local function move_items()
|
||||
if not global.comfychests then return end
|
||||
if not global.comfychests2 then return end
|
||||
@ -640,13 +346,15 @@ local function output_items()
|
||||
end
|
||||
end
|
||||
|
||||
function chronojump(choice)
|
||||
local function chronojump(choice)
|
||||
local objective = global.objective
|
||||
if objective.game_lost then return end
|
||||
objective.chronojumps = objective.chronojumps + 1
|
||||
objective.chrononeeds = 2000 + 800 * objective.chronojumps
|
||||
objective.chronotimer = 0
|
||||
game.print("Comfylatron: Wheeee! Time Jump Active! This is Jump number " .. global.objective.chronojumps, {r=0.98, g=0.66, b=0.22})
|
||||
local message = "Comfylatron: Wheeee! Time Jump Active! This is Jump number " .. global.objective.chronojumps
|
||||
game.print(message, {r=0.98, g=0.66, b=0.22})
|
||||
Server.to_discord_embed(message)
|
||||
local oldsurface = game.surfaces[global.active_surface_index]
|
||||
|
||||
for _,player in pairs(game.players) do
|
||||
@ -661,11 +369,8 @@ function chronojump(choice)
|
||||
local surface = game.surfaces[global.active_surface_index]
|
||||
local planet = nil
|
||||
if choice then
|
||||
planet = chronobuble.determine_planet(choice)
|
||||
local message = "Planet info: " .. planet[1].name.name .. ", Ore richness: " .. planet[1].ore_richness.name .. ", Speed of day: " .. planet[1].day_speed.name
|
||||
game.print(message, {r=0.98, g=0.66, b=0.22})
|
||||
global.objective.planet = planet
|
||||
Server.to_discord_embed(message)
|
||||
Planets.determine_planet(choice)
|
||||
planet = global.objective.planet
|
||||
end
|
||||
generate_overworld(surface, planet)
|
||||
game.forces.player.set_spawn_position({12, 10}, surface)
|
||||
@ -679,7 +384,7 @@ function chronojump(choice)
|
||||
else
|
||||
game.forces["enemy"].evolution_factor = 1
|
||||
end
|
||||
game.map_settings.enemy_evolution.time_factor = 8e-05 + 4e-06 * objective.chronojumps
|
||||
game.map_settings.enemy_evolution.time_factor = 7e-05 + 3e-06 * objective.chronojumps
|
||||
surface.pollute(global.locomotive.position, 200 * (4 / (objective.filterupgradetier / 2 + 1)) * (1 + global.objective.chronojumps))
|
||||
game.forces.scrapyard.set_ammo_damage_modifier("bullet", objective.chronojumps / 20)
|
||||
game.forces.scrapyard.set_turret_attack_modifier("gun-turret", objective.chronojumps / 20)
|
||||
@ -688,7 +393,9 @@ end
|
||||
local function check_chronoprogress()
|
||||
local objective = global.objective
|
||||
--game.print(objective.chronotimer)
|
||||
if objective.chronotimer >= objective.chrononeeds - 60 and objective.chronotimer < objective.chrononeeds - 59 then
|
||||
if objective.chronotimer >= objective.chrononeeds - 180 and objective.chronotimer < objective.chrononeeds - 59 then
|
||||
game.print("Comfylatron: Acumulator charging disabled, 180 seconds countdown to jump!", {r=0.98, g=0.66, b=0.22})
|
||||
elseif objective.chronotimer >= objective.chrononeeds - 60 and objective.chronotimer < objective.chrononeeds - 59 then
|
||||
game.print("Comfylatron: ChronoTrain nearly charged! Grab what you can, we leaving in 60 seconds!", {r=0.98, g=0.66, b=0.22})
|
||||
elseif objective.chronotimer == objective.chrononeeds - 30 then
|
||||
game.print("Comfylatron: You better hurry up! 30 seconds remaining!", {r=0.98, g=0.66, b=0.22})
|
||||
@ -714,7 +421,7 @@ local function charge_chronosphere()
|
||||
if energy > 3000000 and objective.chronotimer < objective.chrononeeds - 182 and objective.chronotimer > 130 then
|
||||
acus[i].energy = acus[i].energy - 3000000
|
||||
objective.chronotimer = objective.chronotimer + 1
|
||||
game.surfaces[global.active_surface_index].pollute(global.locomotive.position, 200 * (4 / (objective.filterupgradetier / 2 + 1)))
|
||||
game.surfaces[global.active_surface_index].pollute(global.locomotive.position, (10 + 5 * objective.chronojumps) * (4 / (objective.filterupgradetier / 2 + 1)))
|
||||
--log("energy charged from acu")
|
||||
end
|
||||
end
|
||||
@ -759,7 +466,7 @@ local function tick()
|
||||
if tick % 1800 == 0 then
|
||||
Locomotive.set_player_spawn_and_refill_fish()
|
||||
repair_train()
|
||||
check_upgrades()
|
||||
Upgrades.check_upgrades()
|
||||
end
|
||||
local key = tick % 3600
|
||||
if tick_minute_functions[key] then tick_minute_functions[key]() end
|
||||
@ -774,7 +481,7 @@ local function tick()
|
||||
if global.game_reset_tick then
|
||||
if global.game_reset_tick < tick then
|
||||
global.game_reset_tick = nil
|
||||
require "maps.chronosphere.main".reset_map()
|
||||
reset_map()
|
||||
end
|
||||
return
|
||||
end
|
||||
@ -798,7 +505,7 @@ local function on_init()
|
||||
--global.rocks_yield_ore_base_amount = 50
|
||||
--global.rocks_yield_ore_distance_modifier = 0.025
|
||||
--if game.surfaces["nauvis"] then game.delete_surface(game.surfaces["nauvis"]) end
|
||||
Public.reset_map()
|
||||
reset_map()
|
||||
end
|
||||
|
||||
function set_objective_health(final_damage_amount)
|
||||
@ -855,9 +562,13 @@ local function protect_entity(event)
|
||||
if event.entity.force.index ~= 1 then return end --Player Force
|
||||
if isprotected(event.entity) then
|
||||
if event.cause then
|
||||
if event.cause.force.index == 2 then
|
||||
set_objective_health(event.final_damage_amount)
|
||||
if event.cause == global.comfylatron or event.entity == global.comfylatron then
|
||||
return
|
||||
end
|
||||
if event.cause.force.index == 2 then
|
||||
set_objective_health(event.final_damage_amount)
|
||||
end
|
||||
|
||||
end
|
||||
if not event.entity.valid then return end
|
||||
event.entity.health = event.entity.health + event.final_damage_amount
|
||||
@ -898,11 +609,11 @@ local function trap(entity)
|
||||
if math_random(1,64) == 1 then unearthing_biters(entity.surface, entity.position, math_random(4,8)) end
|
||||
end
|
||||
|
||||
local function get_choppy_amount(entity)
|
||||
local distance_to_center = 20 * global.objective.chronojumps
|
||||
local amount = (40 + distance_to_center ) * (1 + game.forces.player.mining_drill_productivity_bonus)
|
||||
if amount > 1000 then amount = 1000 end
|
||||
amount = math_random(math_floor(amount * 0.5), math_floor(amount * 1.5))
|
||||
local function get_ore_amount()
|
||||
local scaling = 10 * global.objective.chronojumps
|
||||
local amount = (40 + scaling ) * (1 + game.forces.player.mining_drill_productivity_bonus) * global.objective.planet[1].ore_richness.factor
|
||||
if amount > 800 then amount = 800 end
|
||||
amount = math_random(math_floor(amount * 0.7), math_floor(amount * 1.3))
|
||||
return amount
|
||||
end
|
||||
|
||||
@ -913,28 +624,22 @@ local function pre_player_mined_item(event)
|
||||
if objective.planet[1].name.name == "rocky planet" then
|
||||
if event.entity.name == "rock-huge" or event.entity.name == "rock-big" or event.entity.name == "sand-rock-big" then
|
||||
trap(event.entity)
|
||||
local rock_position = {x = event.entity.position.x, y = event.entity.position.y}
|
||||
event.entity.destroy()
|
||||
local tile_distance_to_center = 40 + 40 * objective.chronojumps * (1 + game.forces.player.mining_drill_productivity_bonus)
|
||||
if tile_distance_to_center > 1450 then tile_distance_to_center = 1450 end
|
||||
surface.spill_item_stack(player.position,{name = "raw-fish", count = math_random(1,3)},true)
|
||||
local bonus_amount = math_floor((tile_distance_to_center) + 1)
|
||||
if bonus_amount < 0 then bonus_amount = 0 end
|
||||
local amount = math_random(25,45) + bonus_amount
|
||||
if amount > 500 then amount = 500 end
|
||||
amount = math_floor(amount * (1+game.forces.player.mining_drill_productivity_bonus))
|
||||
local amount = get_ore_amount()
|
||||
local rock_mining = {"iron-ore", "iron-ore", "iron-ore", "iron-ore", "copper-ore", "copper-ore", "copper-ore", "stone", "stone", "coal", "coal"}
|
||||
local mined_loot = rock_mining[math_random(1,#rock_mining)]
|
||||
surface.create_entity({
|
||||
name = "flying-text",
|
||||
position = rock_position,
|
||||
position = {player.position.x, player.position.y - 0.5},
|
||||
text = "+" .. amount .. " [img=item/" .. mined_loot .. "]",
|
||||
color = {r=0.98, g=0.66, b=0.22}
|
||||
})
|
||||
local i = player.insert {name = mined_loot, count = amount}
|
||||
amount = amount - i
|
||||
if amount > 0 then
|
||||
surface.spill_item_stack(rock_position,{name = mined_loot, count = amount},true)
|
||||
surface.spill_item_stack(player.position, {name = mined_loot, count = amount},true)
|
||||
--surface.create_entity{name="item-on-ground", position=game.player.position, stack={name=mined_loot, count=50}}
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -948,7 +653,7 @@ local function on_player_mined_entity(event)
|
||||
if choppy_entity_yield[entity.name] then
|
||||
if event.buffer then event.buffer.clear() end
|
||||
if not event.player_index then return end
|
||||
local amount = get_choppy_amount(entity)
|
||||
local amount = get_ore_amount()
|
||||
local second_item_amount = math_random(2,5)
|
||||
local second_item = "wood"
|
||||
local main_item = choppy_entity_yield[entity.name][math_random(1,#choppy_entity_yield[entity.name])]
|
||||
@ -965,7 +670,7 @@ local function on_player_mined_entity(event)
|
||||
local inserted_count = player.insert({name = main_item, count = amount})
|
||||
amount = amount - inserted_count
|
||||
if amount > 0 then
|
||||
entity.surface.spill_item_stack(entity.position,{name = main_item, count = amount}, true)
|
||||
entity.surface.spill_item_stack(player.position,{name = main_item, count = amount}, true)
|
||||
end
|
||||
|
||||
local inserted_count = player.insert({name = second_item, count = second_item_amount})
|
||||
@ -977,7 +682,7 @@ local function on_player_mined_entity(event)
|
||||
end
|
||||
if entity.name == "rock-huge" or entity.name == "rock-big" or entity.name == "sand-rock-big" then
|
||||
if global.objective.planet[1].name.name ~= "rocky planet" then
|
||||
prospect_ores(entity)
|
||||
Ores.prospect_ores(entity)
|
||||
elseif
|
||||
global.objective.planet[1].name.name == "rocky planet" then event.buffer.clear()
|
||||
end
|
||||
@ -1118,4 +823,32 @@ event.add(defines.events.on_research_finished, on_research_finished)
|
||||
event.add(defines.events.on_player_driving_changed_state, on_player_driving_changed_state)
|
||||
event.add(defines.events.on_player_changed_position, on_player_changed_position)
|
||||
|
||||
return Public
|
||||
if _DEBUG then
|
||||
local Session = require 'utils.session_data'
|
||||
local Color = require 'utils.color_presets'
|
||||
|
||||
commands.add_command(
|
||||
'chronojump',
|
||||
'Weeeeee!',
|
||||
function(cmd)
|
||||
local player = game.player
|
||||
local trusted = Session.get_trusted_table()
|
||||
local param = tostring(cmd.parameter)
|
||||
local p
|
||||
|
||||
if player then
|
||||
if player ~= nil then
|
||||
p = player.print
|
||||
if not trusted[player.name] then
|
||||
if not player.admin then
|
||||
p("[ERROR] Only admins and trusted weebs are allowed to run this command!", Color.fail)
|
||||
return
|
||||
end
|
||||
end
|
||||
else
|
||||
p = log
|
||||
end
|
||||
end
|
||||
chronojump(param)
|
||||
end)
|
||||
end
|
||||
|
@ -1,3 +1,4 @@
|
||||
local Public_ores = {}
|
||||
local simplex_noise = require 'utils.simplex_noise'.d2
|
||||
local math_random = math.random
|
||||
local math_abs = math.abs
|
||||
@ -5,10 +6,6 @@ local math_floor = math.floor
|
||||
local math_sqrt = math.sqrt
|
||||
local ores = {"copper-ore", "iron-ore", "stone", "coal"}
|
||||
|
||||
local function pos_to_key(position)
|
||||
return tostring(position.x .. "_" .. position.y)
|
||||
end
|
||||
|
||||
local function draw_noise_ore_patch(position, name, surface, radius, richness, mixed)
|
||||
if not position then return end
|
||||
if not name then return end
|
||||
@ -41,36 +38,11 @@ local function draw_noise_ore_patch(position, name, surface, radius, richness, m
|
||||
if surface.can_place_entity(entity) then
|
||||
surface.create_entity(entity)
|
||||
end
|
||||
--if not global.ores_queue[pos.x] then global.ores_queue[pos.x] = {} end
|
||||
|
||||
--global.ores_queue[pos_to_key(pos)] = {name = name, position = pos, amount = a}
|
||||
--end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- function ores_are_mixed(surface)
|
||||
-- local ore_raffle = {
|
||||
-- "iron-ore", "iron-ore", "iron-ore", "copper-ore", "copper-ore", "coal", "stone"
|
||||
-- }
|
||||
-- local r = 480
|
||||
-- local area = {{r * -1, r * -1}, {r, r}}
|
||||
-- local ores = surface.find_entities_filtered({area = area, name = {"iron-ore", "copper-ore", "coal", "stone"}})
|
||||
-- if #ores == 0 then return end
|
||||
-- local seed = surface.map_gen_settings.seed
|
||||
--
|
||||
-- for _, ore in pairs(ores) do
|
||||
-- local pos = ore.position
|
||||
-- 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
|
||||
-- --if not global.ores_queue[pos.x] then global.ores_queue[pos.x] = {} end
|
||||
-- --global.ores_queue[pos_to_key(pos)] = {name = ore_raffle[i], position = ore.position, amount = ore.amount}
|
||||
-- ore.destroy()
|
||||
-- end
|
||||
-- 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
|
||||
@ -94,7 +66,7 @@ end
|
||||
|
||||
local function get_oil_amount(pos, oil_w)
|
||||
local hundred_percent = 300000
|
||||
return (hundred_percent / 20) * (1+global.objective.chronojumps) * oil_w
|
||||
return (hundred_percent / 40) * (1+global.objective.chronojumps) * oil_w
|
||||
end
|
||||
|
||||
function spawn_ore_vein(surface, pos, planet)
|
||||
@ -135,12 +107,13 @@ function spawn_ore_vein(surface, pos, planet)
|
||||
--end
|
||||
end
|
||||
|
||||
function prospect_ores(entity)
|
||||
function Public_ores.prospect_ores(entity)
|
||||
local planet = global.objective.planet
|
||||
local chance = 10
|
||||
if entity.name == "rock-huge" then chance = 40 end
|
||||
if math_random(chance + math_floor(10 * planet[1].ore_richness.factor) ,100 + chance) >= 100 then
|
||||
spawn_ore_vein(entity.surface, entity.position, planet)
|
||||
--if planet[1].name.name == "mixed planet" then
|
||||
end
|
||||
end
|
||||
|
||||
return Public_ores
|
||||
|
@ -584,5 +584,3 @@ end
|
||||
local event = require 'utils.event'
|
||||
--event.on_nth_tick(4, process_chunk_queue)
|
||||
event.add(defines.events.on_chunk_generated, on_chunk_generated)
|
||||
|
||||
return level_depth
|
||||
|
287
maps/chronosphere/upgrades.lua
Normal file
287
maps/chronosphere/upgrades.lua
Normal file
@ -0,0 +1,287 @@
|
||||
|
||||
local Public = {}
|
||||
local math_floor = math.floor
|
||||
|
||||
local function spawn_acumulators()
|
||||
local x = -28
|
||||
local y = -252
|
||||
local yy = global.objective.acuupgradetier * 2
|
||||
local surface = game.surfaces["cargo_wagon"]
|
||||
if yy > 8 then yy = yy + 2 end
|
||||
if yy > 26 then yy = yy + 2 end
|
||||
if yy > 44 then yy = yy + 2 end
|
||||
for i = 1, 27, 1 do
|
||||
local acumulator = surface.create_entity({name = "accumulator", position = {x + 2 * i, y + yy}, force="player", create_build_effect_smoke = false})
|
||||
acumulator.minable = false
|
||||
acumulator.destructible = false
|
||||
table.insert(global.acumulators, acumulator)
|
||||
end
|
||||
end
|
||||
|
||||
local function check_upgrade_hp()
|
||||
local objective = global.objective
|
||||
if not game.surfaces["cargo_wagon"] then return end
|
||||
if objective.game_lost == true then return end
|
||||
if global.hpchest and global.hpchest.valid then
|
||||
local inv = global.hpchest.get_inventory(defines.inventory.chest)
|
||||
local countcoins = inv.get_item_count("coin")
|
||||
local count2 = inv.get_item_count("copper-plate")
|
||||
local coincost = math_floor(2000 * (1 + objective.hpupgradetier /4))
|
||||
if countcoins >= coincost and count2 >= 3000 and objective.hpupgradetier < 18 then
|
||||
inv.remove({name = "coin", count = coincost})
|
||||
inv.remove({name = "copper-plate", count = 3000})
|
||||
game.print("Comfylatron: Train's max HP was upgraded.", {r=0.98, g=0.66, b=0.22})
|
||||
objective.hpupgradetier = objective.hpupgradetier + 1
|
||||
objective.max_health = 10000 + 5000 * objective.hpupgradetier
|
||||
rendering.set_text(global.objective.health_text, "HP: " .. global.objective.health .. " / " .. global.objective.max_health)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function check_upgrade_filter()
|
||||
local objective = global.objective
|
||||
if global.filterchest and global.filterchest.valid then
|
||||
local inv = global.filterchest.get_inventory(defines.inventory.chest)
|
||||
local countcoins = inv.get_item_count("coin")
|
||||
local count2 = inv.get_item_count("electronic-circuit")
|
||||
if countcoins >= 5000 and count2 >= 2000 and objective.filterupgradetier < 9 and objective.chronojumps >= (objective.filterupgradetier + 1) * 3 then
|
||||
inv.remove({name = "coin", count = 5000})
|
||||
inv.remove({name = "electronic-circuit", count = 2000})
|
||||
game.print("Comfylatron: Train's pollution filter was upgraded.", {r=0.98, g=0.66, b=0.22})
|
||||
objective.filterupgradetier = objective.filterupgradetier + 1
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function check_upgrade_acu()
|
||||
local objective = global.objective
|
||||
if global.acuchest and global.acuchest.valid then
|
||||
local inv = global.acuchest.get_inventory(defines.inventory.chest)
|
||||
local countcoins = inv.get_item_count("coin")
|
||||
local count2 = inv.get_item_count("battery")
|
||||
local coincost = math_floor(2000 * (1 + objective.acuupgradetier /4))
|
||||
if countcoins >= coincost and count2 >= 200 and objective.acuupgradetier < 24 then
|
||||
inv.remove({name = "coin", count = coincost})
|
||||
inv.remove({name = "battery", count = 200})
|
||||
game.print("Comfylatron: Train's acumulator capacity was upgraded.", {r=0.98, g=0.66, b=0.22})
|
||||
objective.acuupgradetier = objective.acuupgradetier + 1
|
||||
spawn_acumulators()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function check_upgrade_pickup()
|
||||
local objective = global.objective
|
||||
if global.playerchest and global.playerchest.valid then
|
||||
local inv = global.playerchest.get_inventory(defines.inventory.chest)
|
||||
local countcoins = inv.get_item_count("coin")
|
||||
local count2 = inv.get_item_count("long-handed-inserter")
|
||||
local coincost = 1000 * (1 + objective.pickupupgradetier)
|
||||
if countcoins >= coincost and count2 >= 400 and objective.pickupupgradetier < 4 then
|
||||
inv.remove({name = "coin", count = coincost})
|
||||
inv.remove({name = "long-handed-inserter", count = 400})
|
||||
game.print("Comfylatron: Players now have additional red inserter installed on shoulders, increasing their item pickup range.", {r=0.98, g=0.66, b=0.22})
|
||||
objective.pickupupgradetier = objective.pickupupgradetier + 1
|
||||
game.forces.player.character_loot_pickup_distance_bonus = game.forces.player.character_loot_pickup_distance_bonus + 1
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function check_upgrade_inv()
|
||||
local objective = global.objective
|
||||
if global.invchest and global.invchest.valid then
|
||||
local inv = global.invchest.get_inventory(defines.inventory.chest)
|
||||
local countcoins = inv.get_item_count("coin")
|
||||
local item = "computer"
|
||||
if objective.invupgradetier == 0 then
|
||||
item = "wooden-chest"
|
||||
elseif objective.invupgradetier == 1 then
|
||||
item = "iron-chest"
|
||||
elseif objective.invupgradetier == 2 then
|
||||
item = "steel-chest"
|
||||
elseif objective.invupgradetier == 3 then
|
||||
item = "logistic-chest-storage"
|
||||
end
|
||||
local count2 = inv.get_item_count(item)
|
||||
local coincost = 2000 * (1 + objective.invupgradetier)
|
||||
if countcoins >= coincost and count2 >= 250 and objective.invupgradetier < 4 and objective.chronojumps >= (objective.invupgradetier + 1) * 5 then
|
||||
inv.remove({name = "coin", count = coincost})
|
||||
inv.remove({name = item, count = 250})
|
||||
game.print("Comfylatron: Players now can carry more trash in their unsorted inventories.", {r=0.98, g=0.66, b=0.22})
|
||||
objective.invupgradetier = objective.invupgradetier + 1
|
||||
game.forces.player.character_inventory_slots_bonus = game.forces.player.character_inventory_slots_bonus + 10
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function check_upgrade_tools()
|
||||
local objective = global.objective
|
||||
if global.toolschest and global.toolschest.valid then
|
||||
local inv = global.toolschest.get_inventory(defines.inventory.chest)
|
||||
local countcoins = inv.get_item_count("coin")
|
||||
local count2 = inv.get_item_count("repair-pack")
|
||||
local coincost = 1000 * (1 + objective.toolsupgradetier)
|
||||
local toolscost = 200 * (1 + objective.toolsupgradetier)
|
||||
if countcoins >= coincost and count2 >= toolscost and objective.toolsupgradetier < 4 then
|
||||
inv.remove({name = "coin", count = coincost})
|
||||
inv.remove({name = "repair-pack", count = toolscost})
|
||||
game.print("Comfylatron: Train now gets repaired with additional repair kit at once.", {r=0.98, g=0.66, b=0.22})
|
||||
objective.toolsupgradetier = objective.toolsupgradetier + 1
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function check_upgrade_water()
|
||||
local objective = global.objective
|
||||
if global.waterchest and global.waterchest.valid and game.surfaces["cargo_wagon"].valid then
|
||||
local inv = global.waterchest.get_inventory(defines.inventory.chest)
|
||||
local countcoins = inv.get_item_count("coin")
|
||||
local count2 = inv.get_item_count("pipe")
|
||||
if countcoins >= 2000 and count2 >= 500 and objective.waterupgradetier < 1 then
|
||||
inv.remove({name = "coin", count = 2000})
|
||||
inv.remove({name = "pipe", count = 500})
|
||||
game.print("Comfylatron: Train now has piping system for additional water sources.", {r=0.98, g=0.66, b=0.22})
|
||||
objective.waterupgradetier = objective.waterupgradetier + 1
|
||||
local positions = {{28,66},{28,-62},{-29,66},{-29,-62}}
|
||||
for i = 1, 4, 1 do
|
||||
local e = game.surfaces["cargo_wagon"].create_entity({name = "offshore-pump", position = positions[i], force="player"})
|
||||
e.destructible = false
|
||||
e.minable = false
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function check_upgrade_out()
|
||||
local objective = global.objective
|
||||
if global.outchest and global.outchest.valid and game.surfaces["cargo_wagon"].valid then
|
||||
local inv = global.outchest.get_inventory(defines.inventory.chest)
|
||||
local countcoins = inv.get_item_count("coin")
|
||||
local count2 = inv.get_item_count("fast-inserter")
|
||||
if countcoins >= 2000 and count2 >= 100 and objective.outupgradetier < 1 then
|
||||
inv.remove({name = "coin", count = 2000})
|
||||
inv.remove({name = "fast-inserter", count = 100})
|
||||
game.print("Comfylatron: Train now has output chests.", {r=0.98, g=0.66, b=0.22})
|
||||
objective.outupgradetier = objective.outupgradetier + 1
|
||||
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 = "compilatron-chest", position = positions[i], force = "player"})
|
||||
e.destructible = false
|
||||
e.minable = false
|
||||
global.outchests[i] = e
|
||||
out[i] = rendering.draw_text{
|
||||
text = "Output",
|
||||
surface = e.surface,
|
||||
target = e,
|
||||
target_offset = {0, -1.5},
|
||||
color = global.locomotive.color,
|
||||
scale = 0.80,
|
||||
font = "default-game",
|
||||
alignment = "center",
|
||||
scale_with_zoom = false
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function check_upgrade_box()
|
||||
local objective = global.objective
|
||||
if global.boxchest and global.boxchest.valid and game.surfaces["cargo_wagon"].valid then
|
||||
local inv = global.boxchest.get_inventory(defines.inventory.chest)
|
||||
local countcoins = inv.get_item_count("coin")
|
||||
local item = "computer"
|
||||
if objective.boxupgradetier == 0 then
|
||||
item = "wooden-chest"
|
||||
elseif objective.boxupgradetier == 1 then
|
||||
item = "iron-chest"
|
||||
elseif objective.boxupgradetier == 2 then
|
||||
item = "steel-chest"
|
||||
elseif objective.boxupgradetier == 3 then
|
||||
item = "logistic-chest-storage"
|
||||
end
|
||||
local count2 = inv.get_item_count(item)
|
||||
if countcoins >= 5000 and count2 >= 250 and objective.boxupgradetier < 4 and objective.chronojumps >= (objective.boxupgradetier + 1) * 5 then
|
||||
inv.remove({name = "coin", count = 5000})
|
||||
inv.remove({name = item, count = 250})
|
||||
game.print("Comfylatron: Cargo wagons now have enlargened storage.", {r=0.98, g=0.66, b=0.22})
|
||||
objective.boxupgradetier = objective.boxupgradetier + 1
|
||||
local chests = {}
|
||||
local positions = {
|
||||
[1] = {x = {-33, 32}, y = {-189, -127, -61, 1, 67, 129}}
|
||||
}
|
||||
for i = 1, 58, 1 do
|
||||
for ii = 1, 6, 1 do
|
||||
if objective.boxupgradetier == 1 then
|
||||
chests[#chests + 1] = {name = "wooden-chest", position = {x = positions[1].x[1] ,y = positions[1].y[ii] + i}, force = "player"}
|
||||
chests[#chests + 1] = {name = "wooden-chest", position = {x = positions[1].x[2] ,y = positions[1].y[ii] + i}, force = "player"}
|
||||
elseif objective.boxupgradetier == 2 then
|
||||
chests[#chests + 1] = {name = "iron-chest", position = {x = positions[1].x[1] ,y = positions[1].y[ii] + i}, force = "player"}
|
||||
chests[#chests + 1] = {name = "iron-chest", position = {x = positions[1].x[2] ,y = positions[1].y[ii] + i}, force = "player"}
|
||||
elseif objective.boxupgradetier == 3 then
|
||||
chests[#chests + 1] = {name = "steel-chest", position = {x = positions[1].x[1] ,y = positions[1].y[ii] + i}, force = "player"}
|
||||
chests[#chests + 1] = {name = "steel-chest", position = {x = positions[1].x[2] ,y = positions[1].y[ii] + i}, force = "player"}
|
||||
elseif objective.boxupgradetier == 4 then
|
||||
chests[#chests + 1] = {name = "logistic-chest-storage", position = {x = positions[1].x[1] ,y = positions[1].y[ii] + i}, force = "player"}
|
||||
chests[#chests + 1] = {name = "logistic-chest-storage", position = {x = positions[1].x[2] ,y = positions[1].y[ii] + i}, force = "player"}
|
||||
end
|
||||
end
|
||||
end
|
||||
local surface = game.surfaces["cargo_wagon"]
|
||||
for i = 1, #chests, 1 do
|
||||
if objective.boxupgradetier == 1 then
|
||||
surface.set_tiles({{name = "tutorial-grid", position = chests[i].position}})
|
||||
end
|
||||
local e = surface.create_entity(chests[i])
|
||||
local old = nil
|
||||
if e.name == "iron-chest" then old = surface.find_entity("wooden-chest", e.position)
|
||||
elseif e.name == "steel-chest" then old = surface.find_entity("iron-chest", e.position)
|
||||
elseif e.name == "logistic-chest-storage" then old = surface.find_entity("steel-chest", e.position)
|
||||
end
|
||||
if old then
|
||||
local items = old.get_inventory(defines.inventory.chest).get_contents()
|
||||
for item, count in pairs(items) do
|
||||
e.insert({name = item, count = count})
|
||||
end
|
||||
old.destroy()
|
||||
end
|
||||
e.destructible = false
|
||||
e.minable = false
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function Public.check_upgrades()
|
||||
local objective = global.objective
|
||||
if objective.hpupgradetier < 18 then
|
||||
check_upgrade_hp()
|
||||
end
|
||||
if objective.filterupgradetier < 9 then
|
||||
check_upgrade_filter()
|
||||
end
|
||||
if objective.acuupgradetier < 24 then
|
||||
check_upgrade_acu(Locomotive)
|
||||
end
|
||||
if objective.pickupupgradetier < 4 then
|
||||
check_upgrade_pickup()
|
||||
end
|
||||
if objective.invupgradetier < 4 then
|
||||
check_upgrade_inv()
|
||||
end
|
||||
if objective.toolsupgradetier < 4 then
|
||||
check_upgrade_tools()
|
||||
end
|
||||
if objective.waterupgradetier < 1 then
|
||||
check_upgrade_water()
|
||||
end
|
||||
if objective.outupgradetier < 1 then
|
||||
check_upgrade_out()
|
||||
end
|
||||
if objective.boxupgradetier < 4 and objective.chronojumps >= (objective.boxupgradetier + 1) * 5 then
|
||||
check_upgrade_box()
|
||||
end
|
||||
end
|
||||
|
||||
return Public
|
Loading…
x
Reference in New Issue
Block a user