1
0
mirror of https://github.com/ComfyFactory/ComfyFactorio.git synced 2025-02-09 13:37:02 +02:00

chrono upgrades gui and system revamped

This commit is contained in:
hanakocz 2020-04-14 09:51:09 +02:00
parent b23f186cf8
commit 3adc32953d
11 changed files with 580 additions and 603 deletions

View File

@ -87,27 +87,14 @@ message_game_lost1=The chronotrain was destroyed!
message_game_lost2=Comfylatron is going to kill you for that...he has time machine after all!
message_evolve=Comfylatron: Biters start to evolve faster! We need to charge forward or they will be stronger! (hover over timer to see evolve timer)
message_quest1=Comfylatron: You know...I have big quest. Deliver fish to fish market. But this train is broken. Please help me fix the train computer!
message_quest2=Comfylatron: Thanks for fixing train navigation. I can now get us rid of very poor worlds. It will still need more work though.
message_quest3=Comfylatron: Ah, we need to give this machine more power and better navigation chipset. Please bring me some additional things.
message_quest4=Comfylatron: Perfect! Now we have train reactor and even better destination precision. I will get to you later what still needs to be done.
message_quest5=Comfylatron: Finally found the main issue. We will need to rebuild whole processor. Exactly what I feared of. Just a few more things...
message_quest6=Comfylatron: And this was last part of cpu brain done. Now we just need to synchronize our time correctly and we are done! Bring me satellite and rocket silo.
message_quest7=Comfylatron: Time synchronized. Calculating time and space destination. Success. Jump once more and let me deliver the fish finally. This trip is getting long.
message_game_won1=Comfylatron: Thank you with helping me on this delivery. It was tough one. I hope, that now, when all biters are dead, fish will be safe here forever...
message_overstay=Comfylatron: Looks like you stayed on previous planet for so long that enemies on other planets had additional time to evolve!
message_upgrade_hp=Comfylatron: Train's max HP was upgraded.
message_upgrade_filter=Comfylatron: Train's pollution filter was upgraded.
message_upgrade_acu=Comfylatron: Train's accumulator capacity was upgraded.
message_upgrade_pickup=Comfylatron: Players now have additional red inserter installed on shoulders, increasing their item pickup range.
message_upgrade_inventory=Comfylatron: Players now can carry more trash in their unsorted inventories.
message_upgrade_repair=Comfylatron: Train now gets repaired with additional repair kit at once.
message_upgrade_water=Comfylatron: Train now has piping system for additional water sources.
message_upgrade_out=Comfylatron: Train now has output chests.
message_upgrade_storage=Comfylatron: Cargo wagons now have enlarged storage.
message_upgrade_poison=Comfylatron: I don't believe in your defense skills. I equipped train with poison defense.
message_upgrade_mk2=Comfylatron: I upgraded one armor to mk2.
message_upgrade_fusion=Comfylatron: One personal fusion reactor ready.
message_poison_defense=Comfylatron: Triggering poison defense. Let's kill everything!
ore_richness_very_rich=Very Rich
ore_richness_rich=Rich
ore_richness_normal=Normal
@ -120,6 +107,56 @@ daynight_slow=Slow
daynight_superslow=Super Slow
daynight_fast=Fast
daynight_superfast=Super Fast
upgrade_train_armor=Train Armor
upgrade_train_armor_message=Comfylatron: Train's max HP was upgraded.
upgrade_train_armor_tooltip=+2500 Train Max HP. Max level: __1__ Current Max HP: __2__
upgrade_filter=Pollution Filter
upgrade_filter_message=Comfylatron: Train's pollution filter was upgraded.
upgrade_filter_tooltip=Train Pollution Filter. Decreases pollution from inside of train and from chrono engine.\nCurrent pollution made by train: __1__%
upgrade_accumulators=Accumulators
upgrade_accumulators_message=Comfylatron: Train's accumulator capacity was upgraded.
upgrade_accumulators_tooltip=Add additional row of Accumulators for train's charging system.\nEach accumulator adds 300kW possible power input.
upgrade_loot_pickup=Loot Pickup Range
upgrade_loot_pickup_message=Comfylatron: Players now have additional red inserter installed on shoulders, increasing their item pickup range.
upgrade_loot_pickup_tooltip=Add loot pickup distance to players. Current: +__1__ tiles range
upgrade_inventory_size=Character Inventory Size
upgrade_inventory_size_message=Comfylatron: Players now can carry more trash in their unsorted inventories.
upgrade_inventory_size_tooltip=Add +10 inventory slots to all players.
upgrade_repair=Train Repair Speed
upgrade_repair_message=Comfylatron: Train now gets repaired with additional repair kit at once.
upgrade_repair_tooltip=Train uses more repair tools at once from Repair chest. Current: +__1__
upgrade_water=Piping System
upgrade_water_message=Comfylatron: Train now has piping system for additional water sources.
upgrade_water_tooltip=Add piping through wagon sides to create water sources for each wagon.
upgrade_output=Output System
upgrade_output_message=Comfylatron: Train now has output chests.
upgrade_output_tooltip=Add comfylatron chests that output outside (into cargo wagon 2 and 3)
upgrade_storage=Train Storage
upgrade_storage_message=Comfylatron: Cargo wagons now have upgraded storage.
upgrade_storage_tooltip=Add and upgrade storage chests to the sides of wagons.
upgrade_poison=Poison Defense
upgrade_poison_message=Comfylatron: I don't believe in your defense skills. I equipped train with poison defense.
upgrade_poison_tooltip=Poison defense. Triggers automatically when train has low HP.\nRecharge timer for next use: __1__ min
upgrade_fusion=Fusion Reactor
upgrade_fusion_message=Comfylatron: One personal fusion reactor ready.
upgrade_fusion_tooltip=Creates one Fusion Reactor.
upgrade_mk2=Power Armor MK2
upgrade_mk2_message=Comfylatron: I upgraded one armor to mk2.
upgrade_mk2_tooltip=Creates one Power Armor MK2
upgrade_computer1=Comfylatron's Quest 1
upgrade_computer1_message=Comfylatron: Thanks for fixing train navigation. I can now get us rid of very poor worlds. It will still need more work though.
upgrade_computer1_tooltip=Progresses main quest.\nAll next worlds won't have "very poor" ore distribution.
upgrade_computer2=Comfylatron's Quest 2
upgrade_computer2_message=Comfylatron: Perfect! Now we have train reactor and even better destination precision. I will get to you later what still needs to be done.
upgrade_computer2_tooltip=Progresses main quest.\nAll next worlds won't have "poor" ore distribution.
upgrade_computer3=Comfylatron's Quest 3
upgrade_computer3_message=Comfylatron: That's __1__ / 10 processor parts done!
upgrade_computer3_tooltip=Progresses main quest.\nAfter completing 10th part, the final map can be unlocked.
upgrade_computer4=Comfylatron's Final Quest
upgrade_computer4_message=Comfylatron: Time synchronized. Calculating time and space destination. Success. Jump once more and let me deliver the fish finally. This trip is getting long.
upgrade_computer4_tooltip=Progresses main quest.\nBy unlocking this, the next destination is Fish Market map.\nBe sure to be ready, there is no way back!
gui_1=ChronoJumps:
gui_2=Charge:
gui_3=Timer:
@ -128,7 +165,8 @@ gui_3_2=Nuclear missiles launched in:
gui_4=Local Evolution:
gui_planet_button=Planet Info
gui_upgrades_button=Upgrades
gui_upgrades_1=Insert needed items into chest with given upgrade number.\nChests are at top inside train.\nUpgrading can take a minute.
gui_upgrades_1=Insert needed items into chest with given picture.
gui_upgrades_2=Chests are at top inside the train. Upgrading can take a minute.
gui_planet_0=Name: __1__
gui_planet_1=Detected ore distribution:
gui_planet_2=Ore Amounts: __1__

View File

@ -27,17 +27,6 @@ function Public_chrono.restart_settings()
local objective = global.objective
objective.max_health = 10000
objective.health = 10000
objective.hpupgradetier = 0
objective.acuupgradetier = 0
objective.filterupgradetier = 0
objective.pickupupgradetier = 0
objective.invupgradetier = 0
objective.toolsupgradetier = 0
objective.waterupgradetier = 0
objective.outupgradetier = 0
objective.boxupgradetier = 0
objective.pistolupgradetier = 0
objective.poisondefense = 2
objective.poisontimeout = 0
objective.chronotimer = 0
objective.passivetimer = 0
@ -52,6 +41,10 @@ function Public_chrono.restart_settings()
objective.looted_nukes = 0
objective.offline_players = {}
objective.nextsurface = nil
for i = 1, 16, 1 do
objective.upgrades[i] = 0
end
objective.upgrades[10] = 2 --poison
global.outchests = {}
global.upgradechest = {}
global.fishchest = {}

View File

@ -70,12 +70,12 @@ function Public.determine_planet(choice)
choice = 15
ores = 2
end
if objective.computerupgrade == 3 then
if objective.upgrades[16] == 1 then
choice = 17
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 then
if objective.chronojumps == 21 or objective.chronojumps == 29 or chronojumps == 36 or chronojumps == 42 then
choice = 19
ores = 10
dayspeed = time_speed_variants[1]
@ -92,8 +92,8 @@ function Public.determine_planet(choice)
end
end
if planet_choice.id == 10 then ores = 10 end
if objective.computerupgrade >= 1 and ores == 9 then ores = 8 end
if objective.computerupgrade >= 2 and ores > 6 and ores ~= 10 then ores = 6 end
if objective.upgrades[13] == 1 and ores == 9 then ores = 8 end
if objective.upgrades[14] == 1 and ores > 6 and ores ~= 10 then ores = 6 end
local planet = {
[1] = {
name = planet_choice,

View File

@ -317,22 +317,6 @@ function Public_event.mining_buffs(event)
end
end
function Public_event.pistol_buffs(event)
if global.objective.pistolupgradetier == 0 then return end
if not event.cause then return end
if event.cause.name ~= "player" then return end
if event.damage_type.name ~= "physical" then return end
local player = event.cause
if player.shooting_state.state == defines.shooting.not_shooting then return end
local weapon = event.cause.get_inventory(defines.inventory.character_guns)[event.cause.selected_gun_index].name
local ammo = event.cause.get_inventory(defines.inventory.character_ammo)[event.cause.selected_gun_index].name
game.print(ammo)
game.print(wapon)
if weapon ~= "pistol" then return end
if ammo ~= "firearm-magazine" and ammo ~= "piercing-rounds-magazine" and ammo ~= "uranium-rounds-magazine" then return end
event.entity.damage(event.final_damage_amount * 4, player.force, "physical", player)
end
function Public_event.on_technology_effects_reset(event)
if event.force.name == "player" then
game.forces.player.character_inventory_slots_bonus = game.forces.player.character_inventory_slots_bonus + global.objective.invupgradetier * 10

View File

@ -5,6 +5,7 @@ local math_ceil = math.ceil
local math_abs = math.abs
local math_max = math.max
local math_min = math.min
local Upgrades = require "maps.chronosphere.upgrade_list"
local function create_gui(player)
local frame = player.gui.top.add({ type = "frame", name = "chronosphere"})
@ -74,31 +75,35 @@ local function create_gui(player)
button.style.font = "default-bold"
button.style.font_color = { r=0.99, g=0.99, b=0.99}
button.style.minimal_width = 75
end
-- local label = frame.add({ type = "label", caption = " ", name = "evo"})
-- label.style.font = "default-bold"
-- label.style.right_padding = 1
-- label.style.minimal_width = 10
-- label.style.font_color = {r = 150, g = 0, b = 255}
local function update_upgrades_gui(player)
if not player.gui.screen["gui_upgrades"] then return end
local upgrades = Upgrades.upgrades()
local frame = player.gui.screen["gui_upgrades"]
-- local label = frame.add({ type = "label", caption = " ", name = "evo_value"})
-- label.style.font = "default-bold"
-- label.style.right_padding = 1
-- label.style.minimal_width = 10
-- label.style.font_color = {r = 150, g = 0, b = 255}
-- local label = frame.add({ type = "label", caption = " ", name = "planet"})
-- label.style.font = "default-bold"
-- label.style.right_padding = 1
-- label.style.minimal_width = 10
-- label.style.font_color = {r = 0, g = 100, b = 200}
-- local label = frame.add({ type = "label", caption = "[Upgrades]", name = "upgrades", tooltip = " "})
-- label.style.font = "default-bold"
-- label.style.right_padding = 1
-- label.style.minimal_width = 10
-- label.style.font_color = {r=0.33, g=0.66, b=0.9}
for i = 1, #upgrades, 1 do
local t = frame["upgrades_table" .. i]
t["upgrade" .. i].number = global.objective.upgrades[i]
t["upgrade" .. i].tooltip = upgrades[i].tooltip
t["upgrade_label" .. i].tooltip = upgrades[i].tooltip
if global.objective.upgrades[i] == upgrades[i].max_level then
t["maxed" .. i].visible = true
t["jump_req" .. i].visible = false
for index,_ in pairs(upgrades[i].cost) do
t[index .. "-" .. i].visible = false
end
else
t["maxed" .. i].visible = false
t["jump_req" .. i].visible = true
t["jump_req" .. i].number = upgrades[i].jump_limit
for index,item in pairs(upgrades[i].cost) do
t[index .. "-" .. i].visible = true
t[index .. "-" .. i].number = item.count
end
end
end
end
local function update_planet_gui(player)
@ -131,6 +136,7 @@ end
function Public_gui.update_gui(player)
local objective = global.objective
update_planet_gui(player)
update_upgrades_gui(player)
if not player.gui.top.chronosphere then create_gui(player) end
local gui = player.gui.top.chronosphere
@ -164,9 +170,8 @@ function Public_gui.update_gui(player)
gui.planet_button.caption = {"chronosphere.gui_planet_button"}
gui.upgrades_button.caption = {"chronosphere.gui_upgrades_button"}
--gui.planet.caption = "Planet: " .. objective.planet[1].name.name .. " | Ores: " .. objective.planet[1].ore_richness.name
local acus = 0
if global.acumulators then acus = #global.acumulators else acus = 0 end
if global.acumulators then acus = #global.acumulators end
local bestcase = math_floor((objective.chrononeeds - objective.chronotimer) / (1 + math_floor(acus/10)))
local nukecase = objective.dangertimer
if objective.planet[1].name.id == 19 and objective.passivetimer > 31 then
@ -180,106 +185,47 @@ function Public_gui.update_gui(player)
gui.timer2.style.font_color = {r = 0, g = 200, b = 0}
gui.timer_value2.style.font_color = {r = 0, g = 200, b = 0}
end
local evolution = game.forces["enemy"].evolution_factor
--gui.evo.caption = {"chronosphere.gui_4"}
--gui.evo_value.caption = math_floor(evolution * 100) .. "%"
local chests = {
[1] = {c = "250 wooden chests + Jump number 5\n"},
[2] = {c = "250 iron chests + Jump number 10\n"},
[3] = {c = "250 steel chests + Jump number 15\n"},
[4] = {c = "250 storage chests + Jump number 20\n"},
[5] = {c = "--\n"}
}
local upgt = {
[1] = {t = "[1]: + 2500 Train Max HP. Current: " .. objective.max_health .. "\n Cost : " .. math_floor(500 * (1 + objective.hpupgradetier /2)) .. " coins + 1500 copper plates\n"},
[2] = {t = "[2]: Pollution Filter. Actual value of pollution made: " .. math_floor(300/(objective.filterupgradetier/3+1) * global.difficulty_vote_value) .. "%\n Buyable once per 3 jumps.\n Cost: 5000 coins + 2000 green circuits + Jump number " .. (objective.filterupgradetier + 1) * 3 .. "\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 +10 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"},
[7] = {t = "[7]: Add piping through wagon sides to create water sources for each wagon.\n Cost: 2000 coins + 500 pipes\n"},
[8] = {t = "[8]: Add comfylatron chests that output outside (into cargo wagon 2 and 3)\n Cost: 2000 coins + 100 fast inserters\n"},
[9] = {t = "[9]: Add storage chests to the sides of wagons.\n Buyable once per 5 jumps.\n Cost: 5000 coins + " .. chests[objective.boxupgradetier + 1].c},
[10] = {t = "[P]: Poison defense. Triggers automatically when train has low HP.\n Actual charges: " .. objective.poisondefense .. " / 4\n Recharge timer for next use: " .. math_ceil(objective.poisontimeout /6) .. "min\n Cost: 1000 coins + 50 poison capsules\n"},
[11] = {t = "[A]: 1x mk1 armor + 300 railgun darts + 100 low density structures -> 1x mk2 armor\n"},
[12] = {t = "[R]: 16x personal solar + 200 railgun darts + 100 low density structures -> 1x fusion reactor\n"},
[13] = {t = "[C]: Train computer fixing for Comfylatron. Finish this to fullfill the main objective.\n Tier 1 costs: 5000 coins, 1000 advanced circuits, 2000 copper plates.\n Discards very poor planets.\n"},
[14] = {t = "[C]: Train power and navigation fixing for Comfylatron. Finish this to fullfill the main objective.\n Tier 2 costs: 10000 coins, 1000 processing units, 1 nuclear reactor.\n Discards poor planets.\n"},
[15] = {t = "[C]: Train time machine processor fixing for Comfylatron. Finish this to fullfill the main objective.\n Tier 3 costs per part: 2000 coins, 100 rocket control units, 100 low density structures, 50 uranium fuel cells.\n Parts finished: " .. objective.computerparts .. " / 10\n"},
[16] = {t = "[C]: Train is repaired. Synchronize the time to unlock final map to finish the main objective.\n Costs: 1 rocket silo, 1 satellite.\n Warning: after buying this, the next jump destination is locked to final map,\n that means 100% evolution and no resources.\n"}
}
local maxed = {
[1] = {t = "[1]: Train HP maxed.\n"},
[2] = {t = "[2]: Pollution Filter maxed. Pollution made: " .. math_floor(300/(objective.filterupgradetier/3+1)) .. "%\n"},
[3] = {t = "[3]: Acumulators maxed.\n"},
[4] = {t = "[4]: Pickup distance maxed.\n"},
[5] = {t = "[5]: Inventory maxed. Research Mining Productivity for more.\n"},
[6] = {t = "[6]: Repairing at top speed of 5 packs.\n"},
[7] = {t = "[7]: Piping created. Don't spill it!\n"},
[8] = {t = "[8]: Output chests created.\n"},
[9] = {t = "[9]: Storage chests fully upgraded.\n"},
[10] = {t = "[C]: Train's next destination is Fish Market.\n"}
}
local tooltip = "Insert needed items into chest with upgrade number.\nUpgrading can take a minute.\n\n"
if objective.hpupgradetier < 36 then tooltip = tooltip .. upgt[1].t else tooltip = tooltip .. maxed[1].t end
if objective.filterupgradetier < 9 then tooltip = tooltip .. upgt[2].t else tooltip = tooltip .. maxed[2].t end
if objective.acuupgradetier < 24 then tooltip = tooltip .. upgt[3].t else tooltip = tooltip .. maxed[3].t end
if objective.pickupupgradetier < 4 then tooltip = tooltip .. upgt[4].t else tooltip = tooltip .. maxed[4].t end
if objective.invupgradetier < 4 then tooltip = tooltip .. upgt[5].t else tooltip = tooltip .. maxed[5].t end
if objective.toolsupgradetier < 4 then tooltip = tooltip .. upgt[6].t else tooltip = tooltip .. maxed[6].t end
if objective.waterupgradetier < 1 then tooltip = tooltip .. upgt[7].t else tooltip = tooltip .. maxed[7].t end
if objective.outupgradetier < 1 then tooltip = tooltip .. upgt[8].t else tooltip = tooltip .. maxed[8].t end
if objective.boxupgradetier < 4 then tooltip = tooltip .. upgt[9].t else tooltip = tooltip .. maxed[9].t end
tooltip = tooltip .. upgt[10].t
if objective.chronojumps >= 24 then
tooltip = tooltip .. upgt[11].t .. upgt[12].t
else
tooltip = tooltip .. "Armor and reactor can be bought since jump 24 (for railgun darts).\n"
end
if objective.computerupgrade == 0 and objective.chronojumps >= 15 and objective.computermessage == 1 then
tooltip = tooltip .. upgt[13].t
elseif objective.computerupgrade == 1 and objective.chronojumps >= 20 and objective.computermessage == 3 then
tooltip = tooltip .. upgt[14].t
elseif objective.computerupgrade == 2 and objective.chronojumps >= 25 and objective.computermessage == 5 then
if objective.computerparts < 10 then
tooltip = tooltip .. upgt[15].t
elseif objective.computerparts == 10 then
tooltip = tooltip .. upgt[16].t
end
elseif objective.computerupgrade == 3 and objective.chronojumps >= 25 then
tooltip = tooltip .. maxed[10].t
end
--gui.upgrades.tooltip = tooltip
-- if evolution < 10 then
-- gui.evo.style.font_color = {r = 255, g = 255, b = 0}
-- elseif evolution >= 10 and evolution < 50 then
-- gui.evo.style.font_color = {r = 200, g = 0, b = 0}
-- elseif evolution >= 50 and evolution < 90 then
-- gui.evo.style.font_color = {r = 0, g = 140, b = 255}
-- else
-- gui.evo.style.font_color = {r = 0, g = 255, b = 0}
-- end
-- gui.evo.style.font_color = {
-- r = math_floor(255 * 1 * math_max(0, math_min(1, 1.2 - evolution * 2))),
-- g = math_floor(255 * 1 * math_max(math_abs(0.5 - evolution * 1.5), 1 - evolution * 4)),
-- b = math_floor(255 * 4 * math_max(0, 0.25 - math_abs(0.5 - evolution)))
-- }
-- gui.evo_value.style.font_color = gui.evo.style.font_color
end
local function upgrades_gui(player)
if player.gui.screen["gui_upgrades"] then player.gui.screen["gui_upgrades"].destroy() return end
local objective = global.objective
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}
frame.style.minimal_height = 300
frame.style.maximal_height = 300
frame.style.maximal_height = 900
frame.style.minimal_width = 330
frame.style.maximal_width = 630
frame.add({type = "label", caption = {"chronosphere.gui_upgrades_1"}})
frame.add({type = "label", caption = {"chronosphere.gui_upgrades_2"}})
for i = 1, #upgrades, 1 do
local upg_table = frame.add({type = "table", name = "upgrades_table" .. i, column_count = 10})
upg_table.add({type = "sprite-button", name = "upgrade" .. i, enabled = false, sprite = upgrades[i].sprite, number = global.objective.upgrades[i], tooltip = upgrades[i].tooltip})
local name = upg_table.add({type = "label", name ="upgrade_label" .. i, caption = upgrades[i].name, tooltip = upgrades[i].tooltip})
name.style.width = 200
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
if global.objective.upgrades[i] == upgrades[i].max_level then
maxed.visible = true
jumps.visible = false
for index,_ in pairs(upgrades[i].cost) do
costs[index].visible = false
end
else
maxed.visible = false
jumps.visible = true
for index,_ in pairs(upgrades[i].cost) do
costs[index].visible = true
end
end
end
frame.add({type = "button", name = "close_upgrades", caption = "Close"})
end
@ -287,8 +233,6 @@ local function planet_gui(player)
if player.gui.screen["gui_planet"] then player.gui.screen["gui_planet"].destroy() return end
local planet = global.objective.planet[1]
local evolution = game.forces["enemy"].evolution_factor
--gui.evo.caption = {"chronosphere.gui_4"}
--gui.evo_value.caption = math_floor(evolution * 100) .. "%"
local frame = player.gui.screen.add{type = "frame", name = "gui_planet", caption = "Planet Info", direction = "vertical"}
frame.location = {x = 650, y = 45}
frame.style.minimal_height = 300
@ -339,6 +283,4 @@ function Public_gui.on_gui_click(event)
if name == "close_planet" then planet_gui(player) return end
end
return Public_gui

View File

@ -1,4 +1,5 @@
local Public = {}
local Upgrades = require "maps.chronosphere.upgrade_list"
local math_floor = math.floor
local math_random = math.random
local function math_sgn(x)
@ -308,55 +309,39 @@ function Public.create_wagon_room()
powerpole.minable = false
powerpole.destructible = false
local market = surface.create_entity({name = "market", position = {-5, height * -0.5 + 13}, force="neutral", create_build_effect_smoke = false})
local market = surface.create_entity({name = "market", position = {-30, height * -0.5 + 4}, force="neutral", create_build_effect_smoke = false})
market.minable = false
market.destructible = false
local upgradechests = {
[1] = {name = "repairchest", entity = {name = "compilatron-chest", position = {0, height * -0.5 + 13}, force = "player"}, signal = nil},
[2] = {name = "hpchest", entity = {name = "compilatron-chest", position = {3, height * -0.5 + 12}, force = "player"}, signal = "virtual-signal/signal-1"},
[3] = {name = "filterchest", entity = {name = "compilatron-chest", position = {4, height * -0.5 + 12}, force = "player"}, signal = "virtual-signal/signal-2"},
[4] = {name = "acuchest", entity = {name = "compilatron-chest", position = {5, height * -0.5 + 12}, force = "player"}, signal = "virtual-signal/signal-3"},
[5] = {name = "reachchest", entity = {name = "compilatron-chest", position = {3, height * -0.5 + 13}, force = "player"}, signal = "virtual-signal/signal-4"},
[6] = {name = "invchest", entity = {name = "compilatron-chest", position = {4, height * -0.5 + 13}, force = "player"}, signal = "virtual-signal/signal-5"},
[7] = {name = "toolschest", entity = {name = "compilatron-chest", position = {5, height * -0.5 + 13}, force = "player"}, signal = "virtual-signal/signal-6"},
[8] = {name = "waterchest", entity = {name = "compilatron-chest", position = {3, height * -0.5 + 14}, force = "player"}, signal = "virtual-signal/signal-7"},
[9] = {name = "outchest", entity = {name = "compilatron-chest", position = {4, height * -0.5 + 14}, force = "player"}, signal = "virtual-signal/signal-8"},
[10] = {name = "boxchest", entity = {name = "compilatron-chest", position = {5, height * -0.5 + 14}, force = "player"}, signal = "virtual-signal/signal-9"},
[11] = {name = "poisonchest", entity = {name = "compilatron-chest", position = {6, height * -0.5 + 12}, force = "player"}, signal = "virtual-signal/signal-P"},
[12] = {name = "computerchest", entity = {name = "compilatron-chest", position = {6, height * -0.5 + 13}, force = "player"}, signal = "virtual-signal/signal-C"},
[13] = {name = "armorchest", entity = {name = "compilatron-chest", position = {7, height * -0.5 + 12}, force = "player"}, signal = "virtual-signal/signal-A"},
[14] = {name = "reactorchest", entity = {name = "compilatron-chest", position = {7, height * -0.5 + 13}, force = "player"}, signal = "virtual-signal/signal-R"}
}
for i = 1, #upgradechests, 1 do
local e = surface.create_entity(upgradechests[i].entity)
e.minable = false
e.destructible = false
global.upgradechest[i] = e
if i == 1 then
local repair_text = rendering.draw_text{
text = "Repair chest",
surface = surface,
target = e,
target_offset = {0, -2.5},
color = global.locomotive.color,
scale = 1.00,
font = "default-game",
alignment = "center",
scale_with_zoom = false
}
else
local upgrade_text = rendering.draw_sprite{
sprite = upgradechests[i].signal,
surface = surface,
target = e,
target_offset = {0, -0.1},
font = "default-game",
visible = true
}
end
end
local repairchest = surface.create_entity({name = "compilatron-chest", position = {-24, height * -0.5 + 3}, force = "player"})
repairchest.minable = false
repairchest.destructible = false
global.upgradechest[0] = repairchest
rendering.draw_text{
text = "Repair chest",
surface = surface,
target = repairchest,
target_offset = {0, -2.5},
color = global.locomotive.color,
scale = 1.00,
font = "default-game",
alignment = "center",
scale_with_zoom = false
}
local upgrades = Upgrades.upgrades()
for i = 1, #upgrades, 1 do
local e = surface.create_entity({name = "compilatron-chest", position = {-21 + i, height * -0.5 + 3}, force = "player"})
e.minable = false
e.destructible = false
global.upgradechest[i] = e
rendering.draw_sprite{
sprite = upgrades[i].sprite,
surface = surface,
target = e,
target_offset = {0, -1.3},
font = "default-game",
visible = true
}
end
local market1_text = rendering.draw_text{
text = "Resources",
@ -372,7 +357,7 @@ function Public.create_wagon_room()
local upgrade_text = rendering.draw_text{
text = "Upgrades",
surface = surface,
target = global.upgradechest[3],
target = global.upgradechest[8],
target_offset = {0, -3.5},
color = global.locomotive.color,
scale = 1.00,
@ -383,7 +368,7 @@ function Public.create_wagon_room()
local upgrade_sub_text = rendering.draw_text{
text = "Click [Upgrades] on top of screen",
surface = surface,
target = global.upgradechest[3],
target = global.upgradechest[8],
target_offset = {0, -2.5},
color = global.locomotive.color,
scale = 0.80,

View File

@ -1,5 +1,6 @@
-- chronosphere --
global.objective = {}
require "modules.difficulty_vote"
require "modules.biters_yield_coins"
require "modules.no_deconstruction_of_neutral_entities"
@ -25,7 +26,6 @@ local Gui = require "maps.chronosphere.gui"
local math_random = math.random
local math_floor = math.floor
local math_sqrt = math.sqrt
global.objective = {}
global.objective.config = {}
global.flame_boots = {}
global.comfylatron = nil
@ -124,10 +124,10 @@ local function reset_map()
end
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 objective = global.objective
objective.computerupgrade = 0
objective.computerparts = 0
for i = 13, 16, 1 do
objective.upgrades[i] = 0
end
objective.computermessage = 0
objective.chronojumps = 0
Planets.determine_planet(nil)
@ -245,7 +245,7 @@ local function chronojump(choice)
game.delete_surface(oldsurface)
Chrono.post_jump()
Event_functions.flamer_nerfs()
surface.pollute(global.locomotive.position, 150 * (4 / (objective.filterupgradetier / 2 + 1)) * (1 + global.objective.chronojumps) * global.difficulty_vote_value)
surface.pollute(global.locomotive.position, 150 * (4 / (objective.upgrades[2] / 2 + 1)) * (1 + global.objective.chronojumps) * global.difficulty_vote_value)
end
local tick_minute_functions = {
@ -302,7 +302,7 @@ local function tick()
objective.chronotimer = objective.chronotimer + 1
objective.passivetimer = objective.passivetimer + 1
if objective.chronojumps > 0 then
game.surfaces[global.active_surface_index].pollute(global.locomotive.position, (0.5 * objective.chronojumps) * (4 / (objective.filterupgradetier / 2 + 1)) * global.difficulty_vote_value)
game.surfaces[global.active_surface_index].pollute(global.locomotive.position, (0.5 * objective.chronojumps) * (4 / (objective.upgrades[2] / 2 + 1)) * global.difficulty_vote_value)
end
if objective.planet[1].name.id == 19 then
Tick_functions.dangertimer()
@ -378,7 +378,6 @@ local function on_entity_damaged(event)
Event_functions.biters_chew_rocks_faster(event)
if event.entity.force.name == "enemy" then
Event_functions.biter_immunities(event)
Event_functions.pistol_buffs(event)
end
end

View File

@ -46,7 +46,7 @@ function Public_tick.charge_chronosphere()
if energy > 3010000 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, (10 + 2 * objective.chronojumps) * (4 / (objective.filterupgradetier / 2 + 1)) * global.difficulty_vote_value)
game.surfaces[global.active_surface_index].pollute(global.locomotive.position, (10 + 2 * objective.chronojumps) * (4 / (objective.upgrades[2] / 2 + 1)) * global.difficulty_vote_value)
end
end
end
@ -54,7 +54,7 @@ end
function Public_tick.transfer_pollution()
local surface = game.surfaces["cargo_wagon"]
if not surface then return end
local pollution = surface.get_total_pollution() * (3 / (global.objective.filterupgradetier / 3 + 1)) * global.difficulty_vote_value
local pollution = surface.get_total_pollution() * (3 / (global.objective.upgrades[2] / 3 + 1)) * global.difficulty_vote_value
game.surfaces[global.active_surface_index].pollute(global.locomotive.position, pollution)
surface.clear_pollution()
end
@ -97,7 +97,7 @@ function Public_tick.output_items()
if not global.outchests then return end
if not global.locomotive_cargo[2] then return end
if not global.locomotive_cargo[3] then return end
if global.objective.outupgradetier ~= 1 then return end
if global.objective.upgrades[8] ~= 1 then return end
local wagon = {
[1] = global.locomotive_cargo[2].get_inventory(defines.inventory.cargo_wagon),
[2] = global.locomotive_cargo[3].get_inventory(defines.inventory.cargo_wagon)
@ -120,10 +120,10 @@ function Public_tick.repair_train()
if not game.surfaces["cargo_wagon"] then return 0 end
if objective.game_lost == true then return 0 end
local count = 0
local inv = global.upgradechest[1].get_inventory(defines.inventory.chest)
local inv = global.upgradechest[0].get_inventory(defines.inventory.chest)
if objective.health < objective.max_health then
count = inv.get_item_count("repair-pack")
count = math_min(count, objective.toolsupgradetier + 1, math_ceil((objective.max_health - objective.health) / 150))
count = math_min(count, objective.upgrades[6] + 1, math_ceil((objective.max_health - objective.health) / 150))
if count > 0 then inv.remove({name = "repair-pack", count = count}) end
end
return count * -150

View File

@ -0,0 +1,239 @@
local Public = {}
local math_floor = math.floor
local math_min = math.min
local math_max = math.max
local math_abs = math.abs
local math_ceil = math.ceil
function Public.upgrades()
if not global.objective then global.objective = {} end
if not global.objective.upgrades then
global.objective.upgrades = {}
for i = 1, 16, 1 do
global.objective.upgrades[i] = 0
end
end
if not global.difficulty_vote_value then global.difficulty_vote_value = 1 end
--Each upgrade is automatically added into gui.
--name : visible name in gui (best if localized)
--sprite: visible icon
--cost/item/tt = the first part of localized string, for example coin is in item-name.coin. Can be even scenario's key.
--Second part of localized string is taken from item's name.
--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] = {
name = {"chronosphere.upgrade_train_armor"},
sprite = "recipe/locomotive",
max_level = 36,
message = {"chronosphere.upgrade_train_armor_message"},
tooltip = {"chronosphere.upgrade_train_armor_tooltip", 36, global.objective.max_health},
jump_limit = global.objective.upgrades[1],
cost = {
item1 = {name = "coin", tt = "item-name", sprite = "item/coin", count = 500 * (1 + global.objective.upgrades[1])},
item2 = {name = "copper-plate", tt = "item-name", sprite = "item/copper-plate", count = 1500},
}
},
[2] = {
name = {"chronosphere.upgrade_filter"},
sprite = "recipe/effectivity-module",
max_level = 9,
message = {"chronosphere.upgrade_filter_message"},
tooltip = {"chronosphere.upgrade_filter_tooltip", math_floor(300/(global.objective.upgrades[2]/3+1) * global.difficulty_vote_value)},
jump_limit = (1 + global.objective.upgrades[2]) * 3 or 0,
cost = {
item1 = {name = "coin", tt = "item-name", sprite = "item/coin", count = 5000},
item2 = {name = "electronic-circuit", tt = "item-name", sprite = "item/electronic-circuit", count = math_min(1 + global.objective.upgrades[2], 3) * 500 + 500},
item3 = {name = "advanced-circuit", tt = "item-name", sprite = "item/advanced-circuit", count = math_max(math_min(1 + global.objective.upgrades[2], 6) - 3, 0) * 500},
item4 = {name = "processing-unit", tt = "item-name", sprite = "item/processing-unit", count = math_max(math_min(1 + global.objective.upgrades[2], 9) - 6, 0) * 500}
}
},
[3] = {
name = {"chronosphere.upgrade_accumulators"},
sprite = "recipe/accumulator",
max_level = 24,
message = {"chronosphere.upgrade_accumulators_message"},
tooltip = {"chronosphere.upgrade_accumulators_tooltip"},
jump_limit = global.objective.upgrades[3],
cost = {
item1 = {name = "coin", tt = "item-name", sprite = "item/coin", count = 2000 * (1 + global.objective.upgrades[3] / 4)},
item2 = {name = "battery", tt = "item-name", sprite = "item/battery", count = 100 * (1 + global.objective.upgrades[3])}
}
},
[4] = {
name = {"chronosphere.upgrade_loot_pickup"},
sprite = "recipe/long-handed-inserter",
max_level = 4,
message = {"chronosphere.upgrade_loot_pickup_message"},
tooltip = {"chronosphere.upgrade_loot_pickup_tooltip", global.objective.upgrades[4]},
jump_limit = 0,
cost = {
item1 = {name = "coin", tt = "item-name", sprite = "item/coin", count = 1000 * (1 + global.objective.upgrades[4])},
item2 = {name = "long-handed-inserter", tt = "entity-name", sprite = "recipe/long-handed-inserter", count = 400}
}
},
[5] = {
name = {"chronosphere.upgrade_inventory_size"},
sprite = "entity/character",
max_level = 4,
message = {"chronosphere.upgrade_inventory_size_message"},
tooltip = {"chronosphere.upgrade_inventory_size_tooltip"},
jump_limit = (1 + global.objective.upgrades[5]) * 5,
cost = {
item1 = {name = "coin", tt = "item-name", sprite = "item/coin", count = 2500 * (1 + global.objective.upgrades[5])},
item2 = {name = "wooden-chest", tt = "entity-name", sprite = "item/wooden-chest", count = math_max(0, 250 - math_abs(global.objective.upgrades[5]) * 250)},
item3 = {name = "iron-chest", tt = "entity-name", sprite = "item/iron-chest", count = math_max(0, 250 - math_abs(global.objective.upgrades[5] - 1) * 250)},
item4 = {name = "steel-chest", tt = "entity-name", sprite = "item/steel-chest", count = math_max(0, 250 - math_abs(global.objective.upgrades[5] - 2) * 250)},
item5 = {name = "logistic-chest-storage", tt = "entity-name", sprite = "item/logistic-chest-storage", count = math_max(0, 250 - math_abs(global.objective.upgrades[5] - 3) * 250)}
}
},
[6] = {
name = {"chronosphere.upgrade_repair"},
sprite = "recipe/repair-pack",
max_level = 4,
message = {"chronosphere.upgrade_repair_message"},
tooltip = {"chronosphere.upgrade_repair_tooltip", global.objective.upgrades[6]},
jump_limit = 0,
cost = {
item1 = {name = "coin", tt = "item-name", sprite = "item/coin", count = 1000 * (1 + global.objective.upgrades[6])},
item2 = {name = "repair-pack", tt = "item-name", sprite = "recipe/repair-pack", count = 200 * (1 + global.objective.upgrades[6])}
}
},
[7] = {
name = {"chronosphere.upgrade_water"},
sprite = "fluid/water",
max_level = 1,
message = {"chronosphere.upgrade_water_message"},
tooltip = {"chronosphere.upgrade_water_tooltip"},
jump_limit = 0,
cost = {
item1 = {name = "coin", tt = "item-name", sprite = "item/coin", count = 2000},
item2 = {name = "pipe", tt = "entity-name", sprite = "item/pipe", count = 500},
item3 = {name = "pump", tt = "entity-name", sprite = "item/pump", count = 10}
}
},
[8] = {
name = {"chronosphere.upgrade_output"},
sprite = "recipe/cargo-wagon",
max_level = 1,
message = {"chronosphere.upgrade_output_message"},
tooltip = {"chronosphere.upgrade_output_tooltip"},
jump_limit = 0,
cost = {
item1 = {name = "coin", tt = "item-name", sprite = "item/coin", count = 2000},
item2 = {name = "fast-inserter", tt = "entity-name", sprite = "recipe/fast-inserter", count = 200}
}
},
[9] = {
name = {"chronosphere.upgrade_storage"},
sprite = "item/logistic-chest-storage",
max_level = 4,
message = {"chronosphere.upgrade_storage_message"},
tooltip = {"chronosphere.upgrade_storage_tooltip"},
jump_limit = (1 + global.objective.upgrades[9]) * 5,
cost = {
item1 = {name = "coin", tt = "item-name", sprite = "item/coin", count = 2500 * (1 + global.objective.upgrades[9])},
item2 = {name = "wooden-chest", tt = "entity-name", sprite = "item/wooden-chest", count = math_max(0, 250 - math_abs(global.objective.upgrades[9]) * 250)},
item3 = {name = "iron-chest", tt = "entity-name", sprite = "item/iron-chest", count = math_max(0, 250 - math_abs(global.objective.upgrades[9] - 1) * 250)},
item4 = {name = "steel-chest", tt = "entity-name", sprite = "item/steel-chest", count = math_max(0, 250 - math_abs(global.objective.upgrades[9] - 2) * 250)},
item5 = {name = "logistic-chest-storage", tt = "entity-name", sprite = "item/logistic-chest-storage", count = math_max(0, 250 - math_abs(global.objective.upgrades[9] - 3) * 250)}
}
},
[10] = {
name = {"chronosphere.upgrade_poison"},
sprite = "recipe/poison-capsule",
max_level = 4,
message = {"chronosphere.upgrade_poison_message"},
tooltip = {"chronosphere.upgrade_poison_tooltip", math_ceil(global.objective.poisontimeout /6)},
jump_limit = 0,
cost = {
item1 = {name = "coin", tt = "item-name", sprite = "item/coin", count = 1000},
item2 = {name = "poison-capsule", tt = "item-name", sprite = "recipe/poison-capsule", count = 50}
}
},
[11] = {
name = {"chronosphere.upgrade_fusion"},
sprite = "recipe/fusion-reactor-equipment",
max_level = 999,
message = {"chronosphere.upgrade_fusion_message"},
tooltip = {"chronosphere.upgrade_fusion_tooltip"},
jump_limit = 24,
cost = {
item1 = {name = "low-density-structure", tt = "item-name", sprite = "item/low-density-structure", count = 100},
item2 = {name = "railgun-dart", tt = "item-name", sprite = "item/railgun-dart", count = 200},
item3 = {name = "solar-panel-equipment", tt = "equipment-name", sprite = "item/solar-panel-equipment", count = 16}
}
},
[12] = {
name = {"chronosphere.upgrade_mk2"},
sprite = "recipe/power-armor-mk2",
max_level = 999,
message = {"chronosphere.upgrade_mk2_message"},
tooltip = {"chronosphere.upgrade_mk2_tooltip"},
jump_limit = 24,
cost = {
item1 = {name = "low-density-structure", tt = "item-name", sprite = "item/low-density-structure", count = 100},
item2 = {name = "railgun-dart", tt = "item-name", sprite = "item/railgun-dart", count = 300},
item3 = {name = "power-armor", tt = "item-name", sprite = "item/power-armor", count = 1}
}
},
[13] = {
name = {"chronosphere.upgrade_computer1"},
sprite = "item/advanced-circuit",
max_level = 1,
message = {"chronosphere.upgrade_computer1_message"},
tooltip = {"chronosphere.upgrade_computer1_tooltip"},
jump_limit = 15,
cost = {
item1 = {name = "coin", tt = "item-name", sprite = "item/coin", count = 5000},
item2 = {name = "advanced-circuit", tt = "item-name", sprite = "item/advanced-circuit", count = 1000},
item3 = {name = "copper-plate", tt = "item-name", sprite = "item/copper-plate", count = 2000}
}
},
[14] = {
name = {"chronosphere.upgrade_computer2"},
sprite = "item/processing-unit",
max_level = 1,
message = {"chronosphere.upgrade_computer2_message"},
tooltip = {"chronosphere.upgrade_computer2_tooltip"},
jump_limit = 20,
cost = {
item1 = {name = "coin", tt = "item-name", sprite = "item/coin", count = 10000},
item2 = {name = "processing-unit", tt = "item-name", sprite = "item/processing-unit", count = 1000},
item3 = {name = "nuclear-reactor", tt = "entity-name", sprite = "item/nuclear-reactor", count = 1}
}
},
[15] = {
name = {"chronosphere.upgrade_computer3"},
sprite = "item/rocket-control-unit",
max_level = 10,
message = {"chronosphere.upgrade_computer3_message", global.objective.upgrades[15]},
tooltip = {"chronosphere.upgrade_computer3_tooltip"},
jump_limit = 25,
cost = {
item1 = {name = "coin", tt = "item-name", sprite = "item/coin", count = 2000},
item2 = {name = "low-density-structure", tt = "item-name", sprite = "item/low-density-structure", count = 100},
item3 = {name = "rocket-control-unit", tt = "item-name", sprite = "item/rocket-control-unit", count = 100},
item4 = {name = "uranium-fuel-cell", tt = "item-name", sprite = "item/uranium-fuel-cell", count = 50}
}
},
[16] = {
name = {"chronosphere.upgrade_computer4"},
sprite = "item/satellite",
max_level = 1,
message = {"chronosphere.upgrade_computer4_message"},
tooltip = {"chronosphere.upgrade_computer4_tooltip"},
jump_limit = 25,
cost = {
item1 = {name = "rocket-silo", tt = "entity-name", sprite = "item/rocket-silo", count = 1},
item2 = {name = "satellite", tt = "item-name", sprite = "item/satellite", count = 1}
}
}
}
return upgrades
end
return Public

View File

@ -2,320 +2,7 @@
local Public = {}
local math_floor = math.floor
local Server = require 'utils.server'
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.upgradechest[2] and global.upgradechest[2].valid then
local inv = global.upgradechest[2].get_inventory(defines.inventory.chest)
local countcoins = inv.get_item_count("coin")
local count2 = inv.get_item_count("copper-plate")
local coincost = math_floor(500 * (1 + objective.hpupgradetier /2))
if countcoins >= coincost and count2 >= 1500 and objective.hpupgradetier < 36 then
inv.remove({name = "coin", count = coincost})
inv.remove({name = "copper-plate", count = 1500})
game.print({"chronosphere.message_upgrade_hp"}, {r=0.98, g=0.66, b=0.22})
objective.hpupgradetier = objective.hpupgradetier + 1
objective.max_health = 10000 + 2500 * 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.upgradechest[3] and global.upgradechest[3].valid then
local inv = global.upgradechest[3].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({"chronosphere.message_upgrade_filter"}, {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.upgradechest[4] and global.upgradechest[4].valid then
local inv = global.upgradechest[4].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({"chronosphere.message_upgrade_acu"}, {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.upgradechest[5] and global.upgradechest[5].valid then
local inv = global.upgradechest[5].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({"chronosphere.message_upgrade_pickup"}, {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.upgradechest[6] and global.upgradechest[6].valid then
local inv = global.upgradechest[6].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({"chronosphere.message_upgrade_inventory"}, {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.upgradechest[7] and global.upgradechest[7].valid then
local inv = global.upgradechest[7].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({"chronosphere.message_upgrade_repair"}, {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.upgradechest[8] and global.upgradechest[8].valid and game.surfaces["cargo_wagon"].valid then
local inv = global.upgradechest[8].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({"chronosphere.message_upgrade_water"}, {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.upgradechest[9] and global.upgradechest[9].valid and game.surfaces["cargo_wagon"].valid then
local inv = global.upgradechest[9].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({"chronosphere.message_upgrade_out"}, {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.upgradechest[10] and global.upgradechest[10].valid and game.surfaces["cargo_wagon"].valid then
local inv = global.upgradechest[10].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({"chronosphere.message_upgrade_storage"}, {r=0.98, g=0.66, b=0.22})
objective.boxupgradetier = objective.boxupgradetier + 1
local chests = {}
local positions = {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] = {entity = {name = "wooden-chest", position = {x = positions.x[1] ,y = positions.y[ii] + i}, force = "player"}, old = "none"}
chests[#chests + 1] = {entity = {name = "wooden-chest", position = {x = positions.x[2] ,y = positions.y[ii] + i}, force = "player"}, old = "none"}
elseif objective.boxupgradetier == 2 then
chests[#chests + 1] = {entity = {name = "iron-chest", position = {x = positions.x[1] ,y = positions.y[ii] + i}, force = "player", fast_replace = true, spill = false}, old = "wood"}
chests[#chests + 1] = {entity = {name = "iron-chest", position = {x = positions.x[2] ,y = positions.y[ii] + i}, force = "player", fast_replace = true, spill = false}, old = "wood"}
elseif objective.boxupgradetier == 3 then
chests[#chests + 1] = {entity = {name = "steel-chest", position = {x = positions.x[1] ,y = positions.y[ii] + i}, force = "player", fast_replace = true, spill = false}, old = "iron"}
chests[#chests + 1] = {entity = {name = "steel-chest", position = {x = positions.x[2] ,y = positions.y[ii] + i}, force = "player", fast_replace = true, spill = false}, old = "iron"}
elseif objective.boxupgradetier == 4 then
chests[#chests + 1] = {entity = {name = "logistic-chest-storage", position = {x = positions.x[1] ,y = positions.y[ii] + i}, force = "player", fast_replace = true, spill = false}, old = "steel"}
chests[#chests + 1] = {entity = {name = "logistic-chest-storage", position = {x = positions.x[2] ,y = positions.y[ii] + i}, force = "player", fast_replace = true, spill = false}, old = "steel"}
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].entity.position}})
end
local old = nil
local oldpos = {x = chests[i].entity.position.x + 0.5, y = chests[i].entity.position.y + 0.5}
if chests[i].old == "wood" then old = surface.find_entity("wooden-chest", oldpos)
elseif chests[i].old == "iron" then old = surface.find_entity("iron-chest", oldpos)
elseif chests[i].old == "steel" then old = surface.find_entity("steel-chest", oldpos)
end
if old then
old.minable = true
old.destructible = true
end
local e = surface.create_entity(chests[i].entity)
e.destructible = false
e.minable = false
end
end
end
end
local function check_poisondefense()
local objective = global.objective
if global.upgradechest[11] and global.upgradechest[11].valid then
local inv = global.upgradechest[11].get_inventory(defines.inventory.chest)
local countcoins = inv.get_item_count("coin")
local count2 = inv.get_item_count("poison-capsule")
if countcoins >= 1000 and count2 >= 50 and objective.poisondefense < 4 then
inv.remove({name = "coin", count = 1000})
inv.remove({name = "poison-capsule", count = 50})
game.print({"chronosphere.message_upgrade_poison"}, {r=0.98, g=0.66, b=0.22})
objective.poisondefense = objective.poisondefense + 1
end
end
end
local function check_upgrade_computer()
local objective = global.objective
if global.upgradechest[12] and global.upgradechest[12].valid then
local inv = global.upgradechest[12].get_inventory(defines.inventory.chest)
local countcoins = inv.get_item_count("coin")
local count2 = inv.get_item_count("advanced-circuit")
local count3 = inv.get_item_count("processing-unit")
local count4 = inv.get_item_count("low-density-structure")
local count5 = inv.get_item_count("rocket-control-unit")
local count6 = inv.get_item_count("uranium-fuel-cell")
local count7 = inv.get_item_count("nuclear-reactor")
local count8 = inv.get_item_count("copper-plate")
local count9 = inv.get_item_count("rocket-silo")
local count10 = inv.get_item_count("satellite")
if countcoins >= 5000 and count2 >= 1000 and count8 >= 2000 and objective.computerupgrade == 0 and objective.chronojumps >= 15 and objective.computermessage == 1 then
inv.remove({name = "coin", count = 5000})
inv.remove({name = "advanced-circuit", count = 1000})
inv.remove({name = "copper-plate", count = 2000})
game.print({"chronosphere.message_quest2"}, {r=0.98, g=0.66, b=0.22})
objective.computermessage = 2
objective.computerupgrade = objective.computerupgrade + 1
elseif countcoins >= 10000 and count3 >= 1000 and count7 >= 1 and objective.computerupgrade == 1 and objective.chronojumps >= 20 and objective.computermessage == 3 then
inv.remove({name = "coin", count = 10000})
inv.remove({name = "processing-unit", count = 1000})
inv.remove({name = "nuclear-reactor", count = 1})
objective.computermessage = 4
objective.computerupgrade = objective.computerupgrade + 1
game.print({"chronosphere.message_quest4"}, {r=0.98, g=0.66, b=0.22})
elseif objective.computerupgrade == 2 and objective.chronojumps >= 25 and objective.computermessage == 5 then
if countcoins >= 2000 and count4 >= 100 and count5 >= 100 and count6 >= 50 and objective.computerparts < 10 then
inv.remove({name = "coin", count = 2000})
inv.remove({name = "low-density-structure", count = 100})
inv.remove({name = "rocket-control-unit", count = 100})
inv.remove({name = "uranium-fuel-cell", count = 50 })
objective.computerparts = objective.computerparts + 1
if objective.computerparts < 10 then
game.print("Comfylatron: That's another processor part done! I still need " .. 10 - objective.computerparts .. " more of those parts.", {r=0.98, g=0.66, b=0.22})
else
game.print({"chronosphere.message_quest6"}, {r=0.98, g=0.66, b=0.22})
end
elseif objective.computerparts == 10 and count9 >= 1 and count10 >= 1 then
inv.remove({name = "satellite", count = 1 })
inv.remove({name = "rocket-silo", count = 1 })
game.print({"chronosphere.message_quest7"}, {r=0.98, g=0.66, b=0.22})
objective.computermessage = 6
objective.computerupgrade = objective.computerupgrade + 1
end
end
end
end
local Upgrades = require "maps.chronosphere.upgrade_list"
local function check_win()
local objective = global.objective
@ -351,80 +38,190 @@ local function check_win()
end
end
local function check_mk2_buy()
local objective = global.objective
if global.upgradechest[13] and global.upgradechest[13].valid then
local inv = global.upgradechest[13].get_inventory(defines.inventory.chest)
local count = inv.get_item_count("low-density-structure")
local count2 = inv.get_item_count("railgun-dart")
local count3 = inv.get_item_count("power-armor")
if count >= 100 and count2 >= 300 and count3 >= 1 and objective.chronojumps >= 24 then
inv.remove({name = "low-density-structure", count = 100})
inv.remove({name = "railgun-dart", count = 300})
inv.remove({name = "power-armor", count = 1})
inv.insert({name = "power-armor-mk2", count = 1})
game.print({"chronosphere.message_upgrade_mk2"}, {r=0.98, g=0.66, b=0.22})
end
local function upgrade_hp()
global.objective.max_health = 10000 + 2500 * global.objective.upgrades[1]
rendering.set_text(global.objective.health_text, "HP: " .. global.objective.health .. " / " .. global.objective.max_health)
end
local function spawn_acumulators()
local x = -28
local y = -252
local yy = global.objective.upgrades[3] * 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 upgrade_pickup()
game.forces.player.character_loot_pickup_distance_bonus = game.forces.player.character_loot_pickup_distance_bonus + 1
end
local function upgrade_inv()
game.forces.player.character_inventory_slots_bonus = game.forces.player.character_inventory_slots_bonus + 10
end
local function upgrade_water()
if not game.surfaces["cargo_wagon"] then return end
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
local function check_fusion_buy()
local function upgrade_out()
if not game.surfaces["cargo_wagon"] then return end
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
local function upgrade_storage()
local objective = global.objective
if global.upgradechest[14] and global.upgradechest[14].valid then
local inv = global.upgradechest[14].get_inventory(defines.inventory.chest)
local count = inv.get_item_count("low-density-structure")
local count2 = inv.get_item_count("railgun-dart")
local count3 = inv.get_item_count("solar-panel-equipment")
if count >= 100 and count2 >= 200 and count3 >= 16 and objective.chronojumps >= 24 then
inv.remove({name = "low-density-structure", count = 100})
inv.remove({name = "railgun-dart", count = 200})
inv.remove({name = "solar-panel-equipment", count = 16})
inv.insert({name = "fusion-reactor-equipment", count = 1})
game.print({"chronosphere.message_upgrade_fusion"}, {r=0.98, g=0.66, b=0.22})
if not game.surfaces["cargo_wagon"] then return end
local chests = {}
local positions = {x = {-33, 32}, y = {-189, -127, -61, 1, 67, 129}}
for i = 1, 58, 1 do
for ii = 1, 6, 1 do
if objective.upgrades[9] == 1 then
chests[#chests + 1] = {entity = {name = "wooden-chest", position = {x = positions.x[1] ,y = positions.y[ii] + i}, force = "player"}, old = "none"}
chests[#chests + 1] = {entity = {name = "wooden-chest", position = {x = positions.x[2] ,y = positions.y[ii] + i}, force = "player"}, old = "none"}
elseif objective.upgrades[9] == 2 then
chests[#chests + 1] = {entity = {name = "iron-chest", position = {x = positions.x[1] ,y = positions.y[ii] + i}, force = "player", fast_replace = true, spill = false}, old = "wood"}
chests[#chests + 1] = {entity = {name = "iron-chest", position = {x = positions.x[2] ,y = positions.y[ii] + i}, force = "player", fast_replace = true, spill = false}, old = "wood"}
elseif objective.upgrades[9] == 3 then
chests[#chests + 1] = {entity = {name = "steel-chest", position = {x = positions.x[1] ,y = positions.y[ii] + i}, force = "player", fast_replace = true, spill = false}, old = "iron"}
chests[#chests + 1] = {entity = {name = "steel-chest", position = {x = positions.x[2] ,y = positions.y[ii] + i}, force = "player", fast_replace = true, spill = false}, old = "iron"}
elseif objective.upgrades[9] == 4 then
chests[#chests + 1] = {entity = {name = "logistic-chest-storage", position = {x = positions.x[1] ,y = positions.y[ii] + i}, force = "player", fast_replace = true, spill = false}, old = "steel"}
chests[#chests + 1] = {entity = {name = "logistic-chest-storage", position = {x = positions.x[2] ,y = positions.y[ii] + i}, force = "player", fast_replace = true, spill = false}, old = "steel"}
end
end
end
local surface = game.surfaces["cargo_wagon"]
for i = 1, #chests, 1 do
if objective.upgrades[9] == 1 then
surface.set_tiles({{name = "tutorial-grid", position = chests[i].entity.position}})
end
local old = nil
local oldpos = {x = chests[i].entity.position.x + 0.5, y = chests[i].entity.position.y + 0.5}
if chests[i].old == "wood" then old = surface.find_entity("wooden-chest", oldpos)
elseif chests[i].old == "iron" then old = surface.find_entity("iron-chest", oldpos)
elseif chests[i].old == "steel" then old = surface.find_entity("steel-chest", oldpos)
end
if old then
old.minable = true
old.destructible = true
end
local e = surface.create_entity(chests[i].entity)
e.destructible = false
e.minable = false
end
end
local function fusion_buy()
local objective = global.objective
if global.upgradechest[11] and global.upgradechest[11].valid then
local inv = global.upgradechest[14].get_inventory(defines.inventory.chest)
inv.insert({name = "fusion-reactor-equipment", count = 1})
end
end
local function mk2_buy()
local objective = global.objective
if global.upgradechest[13] and global.upgradechest[13].valid then
inv.insert({name = "power-armor-mk2", count = 1})
end
end
local function process_upgrade(index)
if index == 1 then
upgrade_hp()
elseif index == 3 then
spawn_acumulators()
elseif index == 4 then
upgrade_pickup()
elseif index == 5 then
upgrade_inv()
elseif index == 7 then
upgrade_water()
elseif index == 8 then
upgrade_out()
elseif index == 9 then
upgrade_storage()
elseif index == 11 then
fusion_buy()
elseif index == 12 then
mk2_buy()
elseif index == 13 then
global.objective.computermessage = 2
elseif index == 14 then
global.objective.computermessage = 4
elseif index = 15 then
if gobal.objective.upgrades[15] == 10 then
game.print({"chronosphere.message_quest6"}, {r=0.98, g=0.66, b=0.22})
end
end
end
local function check_single_upgrade(index)
local upgrades = Upgrades.upgrades()
if global.upgradechest[index] and global.upgradechest[index].valid then
local inv = global.upgradechest[index].get_inventory(defines.inventory.chest)
if global.objective.upgrades[index] < upgrades[index].max_level and global.objective.chronojumps >= upgrades[index].jump_limit then
for _, item in pairs(upgrades[index].cost) do
if inv.get_item_count(item.name) < item.count then return end
end
else
return
end
for _, item in pairs(upgrades[index].cost) do
if item.count > 0 then
inv.remove({name = item.name, count = item.count})
end
end
game.print(upgrades[index].message, {r=0.98, g=0.66, b=0.22})
global.objective.upgrades[index] = global.objective.upgrades[index] + 1
process_upgrade(index)
end
end
local function check_all_upgrades()
local upgrades = Upgrades.upgrades()
for i = 1, #upgrades, 1 do
check_single_upgrade(i)
end
end
function Public.check_upgrades()
local objective = global.objective
if not global.upgradechest then return end
if objective.hpupgradetier < 36 then
check_upgrade_hp()
end
if objective.filterupgradetier < 9 and objective.chronojumps >= (objective.filterupgradetier + 1) * 3 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 and objective.chronojumps >= (objective.invupgradetier + 1) * 5 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
if objective.poisondefense < 4 then
check_poisondefense()
end
if objective.computerupgrade < 3 and objective.chronojumps >= 15 then
check_upgrade_computer()
end
if objective.chronojumps >= 24 then
check_mk2_buy()
check_fusion_buy()
end
if objective.game_lost == true then return end
check_all_upgrades()
if objective.planet[1].name.id == 17 then
if global.fishchest then
check_win()

View File

@ -15,7 +15,7 @@ local function on_entity_damaged(event)
if not weapon.valid_for_read or not ammo.valid_for_read then return end
if weapon.name ~= "pistol" then return end
if ammo.name ~= "firearm-magazine" and ammo.name ~= "piercing-rounds-magazine" and ammo.name ~= "uranium-rounds-magazine" then return end
event.entity.damage(event.final_damage_amount * 4, player.force, "physical")
event.entity.damage(event.final_damage_amount * 4, player.force, "physical", player)
end
event.add(defines.events.on_entity_damaged, on_entity_damaged)