require "util" require "mod-gui" function getLevelReqs(levelID) local LIFactor = 1.03; local stageFactor = 1; if levelID > 30 then stageFactor = 2 end if levelID > 100 then stageFactor = 3 end if levelID > 136 then stageFactor = 4 end local r = {}; r.requirements = {}; r.time = 400 * stageFactor; if levelID > 115 then stageFactor = 3 / math.pow(1.022, (levelID-115)) end if levelID > 136 then stageFactor = 4 / math.pow(1.022, (levelID-115)) end if levelID < 5 then r.requirements['iron-plate'] = 25*levelID r.requirements['copper-plate'] = 25*levelID r.requirements['stone'] = 35*levelID r.requirements['coal'] = 35*levelID end if levelID > 4 and levelID < 15 and levelID % 4 == 3 then r.requirements['stone'] = math.floor(stageFactor * 450*math.pow(LIFactor,levelID)) end if levelID > 4 and levelID < 19 and levelID % 4 == 1 then r.requirements['coal'] = math.floor(stageFactor * 450*math.pow(LIFactor,levelID)) end if levelID > 4 and levelID < 17 and levelID % 6 == 1 then r.requirements['iron-plate'] = math.floor(stageFactor * 300*math.pow(LIFactor,levelID)) end if levelID > 4 and levelID < 19 and levelID % 4 == 1 then r.requirements['copper-plate'] = math.floor(stageFactor * 300*math.pow(LIFactor,levelID)) end if levelID > 4 and levelID < 23 and levelID % 4 == 0 then r.requirements['stone-furnace'] = math.floor(stageFactor * 75*math.pow(LIFactor,levelID)) end if levelID > 4 and levelID < 27 and levelID % 4 == 1 then r.requirements['stone-brick'] = math.floor(stageFactor * 188*math.pow(LIFactor,levelID)) end if levelID > 4 and levelID < 17 and levelID % 6 == 0 then r.requirements['copper-cable'] = math.floor(stageFactor * 500*math.pow(LIFactor,levelID)) end if levelID > 4 and levelID < 20 and levelID % 10 == 5 then r.requirements['iron-stick'] = math.floor(stageFactor * 500*math.pow(LIFactor,levelID)) end if levelID > 4 and levelID < 23 and levelID % 6 == 5 then r.requirements['pipe'] = math.floor(stageFactor * 250*math.pow(LIFactor,levelID)) end if levelID > 4 and levelID < 25 and levelID % 5 == 1 then r.requirements['iron-gear-wheel'] = math.floor(stageFactor * 125*math.pow(LIFactor,levelID)) end if levelID > 4 and levelID < 27 and levelID % 8 == 6 then r.requirements['firearm-magazine'] = math.floor(stageFactor * 62.5*math.pow(LIFactor,levelID)) end if levelID > 4 and levelID % 37 == 6 then r.requirements['iron-chest'] = math.floor(stageFactor * 31.3*math.pow(LIFactor,levelID)) end if levelID > 4 and levelID % 37 == 7 then r.requirements['pistol'] = math.floor(stageFactor * 25*math.pow(LIFactor,levelID)) end if levelID > 4 and levelID < 38 and levelID % 6 == 0 then r.requirements['transport-belt'] = math.floor(stageFactor * 150*math.pow(LIFactor,levelID)) end if levelID > 4 and levelID < 32 and levelID % 4 == 3 then r.requirements['electronic-circuit'] = math.floor(stageFactor * 88.3*math.pow(LIFactor,levelID)) end if levelID > 4 and levelID % 37 == 8 then r.requirements['burner-inserter'] = math.floor(stageFactor * 73.2*math.pow(LIFactor,levelID)) end if levelID > 4 and levelID % 15 == 7 then r.requirements['science-pack-1'] = math.floor(stageFactor * 73.2*math.pow(LIFactor,levelID)) end if levelID > 4 and levelID % 37 == 9 then r.requirements['iron-axe'] = math.floor(stageFactor * 60*math.pow(LIFactor,levelID)) end if levelID > 4 and levelID % 29 == 9 then r.requirements['pipe-to-ground'] = math.floor(stageFactor * 30*math.pow(LIFactor,levelID)) end if levelID > 4 and levelID % 29 == 8 then r.requirements['boiler'] = math.floor(stageFactor * 27.3*math.pow(LIFactor,levelID)) end if levelID > 4 and levelID % 37 == 10 then r.requirements['burner-mining-drill'] = math.floor(stageFactor * 17.7*math.pow(LIFactor,levelID)) end if levelID > 4 and levelID % 37 == 11 then r.requirements['steam-engine'] = math.floor(stageFactor * 7.15*math.pow(LIFactor,levelID)) end if levelID > 4 and levelID < 37 and levelID % 4 == 0 then r.requirements['inserter'] = math.floor(stageFactor * 36.6*math.pow(LIFactor,levelID)) end if levelID > 4 and levelID % 37 == 12 then r.requirements['offshore-pump'] = math.floor(stageFactor * 25*math.pow(LIFactor,levelID)) end if levelID > 4 and levelID % 29 == 10 then r.requirements['repair-pack'] = math.floor(stageFactor * 21.5*math.pow(LIFactor,levelID)) end if levelID > 6 and levelID < 37 and levelID % 5 == 3 then r.requirements['electric-mining-drill'] = math.floor(stageFactor * 7.7*math.pow(LIFactor,levelID)) end if levelID > 7 and levelID < 41 and levelID % 4 == 2 then r.requirements['radar'] = math.floor(stageFactor * 6.4*math.pow(LIFactor,levelID)) end if levelID > 7 and levelID % 37 == 14 then r.requirements['lab'] = math.floor(stageFactor * 3.8*math.pow(LIFactor,levelID)) end if levelID > 10 and levelID % 37 == 15 then r.requirements['light-armor'] = math.floor(stageFactor * 6.25*math.pow(LIFactor,levelID)) end if levelID > 8 and levelID % 15 == 10 then r.requirements['science-pack-2'] = math.floor(stageFactor * 25*math.pow(LIFactor,levelID)) end if levelID > 8 and levelID < 35 and levelID % 9 == 1 then r.requirements['underground-belt'] = math.floor(stageFactor * 25*math.pow(LIFactor,levelID)) end if levelID > 10 and levelID < 42 and levelID % 6 == 2 then r.requirements['assembling-machine-1'] = math.floor(stageFactor * 8.1*math.pow(LIFactor,levelID)) end if levelID > 10 and levelID < 42 and levelID % 5 == 4 then r.requirements['splitter'] = math.floor(stageFactor * 10*math.pow(LIFactor,levelID)) end if levelID > 9 and levelID % 29 == 15 then r.requirements['long-handed-inserter'] = math.floor(stageFactor * 21.5*math.pow(LIFactor,levelID)) end if levelID > 13 and levelID < 45 and levelID % 4 == 3 then r.requirements['fast-inserter'] = math.floor(stageFactor * 15*math.pow(LIFactor,levelID)) end if levelID > 15 and levelID < 45 and levelID % 4 == 2 then r.requirements['steel-plate'] = math.floor(stageFactor * 50*math.pow(LIFactor,levelID)) end if levelID > 10 and levelID % 29 == 16 then r.requirements['steel-chest'] = math.floor(stageFactor * 5.18*math.pow(LIFactor,levelID)) end if levelID > 15 and levelID < 60 and levelID % 4 == 0 then r.requirements['stone-wall'] = math.floor(stageFactor * 31.3*math.pow(LIFactor,levelID)) end if levelID > 18 and levelID % 37 == 17 then r.requirements['steel-axe'] = math.floor(stageFactor * 8.11*math.pow(LIFactor,levelID)) end if levelID > 18 and levelID % 37 == 18 then r.requirements['submachine-gun'] = math.floor(stageFactor * 6.4*math.pow(LIFactor,levelID)) end if levelID > 16 and levelID < 60 and levelID % 4 == 3 then r.requirements['gun-turret'] = math.floor(stageFactor * 4.62*math.pow(LIFactor,levelID)) end if levelID > 16 and levelID % 29 == 17 then r.requirements['small-lamp'] = math.floor(stageFactor * 40.6*math.pow(LIFactor,levelID)) end if levelID > 20 and levelID % 37 == 21 then r.requirements['heavy-armor'] = math.floor(stageFactor * 0.63*math.pow(LIFactor,levelID)) end if levelID > 17 and levelID < 65 and levelID % 5 == 0 then r.requirements['assembling-machine-2'] = math.floor(stageFactor * 3.66*math.pow(LIFactor,levelID)) end if levelID > 15 and levelID % 29 == 18 then r.requirements['filter-inserter'] = math.floor(stageFactor * 7.5*math.pow(LIFactor,levelID)) end if levelID > 20 and levelID < 43 and levelID % 4 == 1 then r.requirements['empty-barrel'] = math.floor(stageFactor * 41.7*math.pow(LIFactor,levelID)) end if levelID > 20 and levelID < 65 and levelID % 5 == 1 then r.requirements['storage-tank'] = math.floor(stageFactor * 5*math.pow(LIFactor,levelID)) end if levelID > 20 and levelID % 37 == 22 then r.requirements['water-barrel'] = math.floor(stageFactor * 30*math.pow(LIFactor,levelID)) end if levelID > 21 and levelID % 19 == 4 then r.requirements['landfill'] = math.floor(stageFactor * 18.8*math.pow(LIFactor,levelID)) end if levelID > 22 and levelID % 37 == 24 then r.requirements['steel-furnace'] = math.floor(stageFactor * 4.84*math.pow(LIFactor,levelID)) end if levelID > 23 and levelID < 65 and levelID % 4 == 1 then r.requirements['fast-transport-belt'] = math.floor(stageFactor * 17.7*math.pow(LIFactor,levelID)) end if levelID > 24 and levelID % 37 == 26 then r.requirements['chemical-plant'] = math.floor(stageFactor * 3.85*math.pow(LIFactor,levelID)) end if levelID > 25 and levelID % 37 == 27 then r.requirements['pumpjack'] = math.floor(stageFactor * 3*math.pow(LIFactor,levelID)) end if levelID > 25 and levelID % 37 == 28 then r.requirements['oil-refinery'] = math.floor(stageFactor * 1.43*math.pow(LIFactor,levelID)) end if levelID > 25 and levelID % 19 == 8 then r.requirements['crude-oil-barrel'] = math.floor(stageFactor * 4.35*math.pow(LIFactor,levelID)) end if levelID > 25 and levelID < 75 and levelID % 5 == 4 then r.requirements['fast-underground-belt'] = math.floor(stageFactor * 4.17*math.pow(LIFactor,levelID)) end if levelID > 27 and levelID % 19 == 10 then r.requirements['heavy-oil-barrel'] = math.floor(stageFactor * 3.58*math.pow(LIFactor,levelID)) end if levelID > 27 and levelID % 19 == 11 then r.requirements['light-oil-barrel'] = math.floor(stageFactor * 3.58*math.pow(LIFactor,levelID)) end if levelID > 28 and levelID % 19 == 12 then r.requirements['petroleum-gas-barrel'] = math.floor(stageFactor * 3.58*math.pow(LIFactor,levelID)) end if levelID > 30 and levelID < 66 and levelID % 5 == 2 then r.requirements['fast-splitter'] = math.floor(stageFactor * 2.73*math.pow(LIFactor,levelID)) end if levelID > 30 and levelID % 19 == 13 then r.requirements['lubricant-barrel'] = math.floor(stageFactor * 3.04*math.pow(LIFactor,levelID)) end if levelID > 30 and levelID < 80 and levelID % 5 == 3 then r.requirements['concrete'] = math.floor(stageFactor * 230*math.pow(LIFactor,levelID)) end if levelID > 31 and levelID < 72 and levelID % 8 == 1 then r.requirements['piercing-rounds-magazine'] = math.floor(stageFactor * 15.8*math.pow(LIFactor,levelID)) end if levelID > 32 and levelID < 80 and levelID % 6 == 4 then r.requirements['plastic-bar'] = math.floor(stageFactor * 88.3*math.pow(LIFactor,levelID)) end if levelID > 30 and levelID % 37 == 35 then r.requirements['green-wire'] = math.floor(stageFactor * 62.5*math.pow(LIFactor,levelID)) end if levelID > 30 and levelID % 37 == 36 then r.requirements['red-wire'] = math.floor(stageFactor * 62.5*math.pow(LIFactor,levelID)) end if levelID > 33 and levelID < 85 and levelID % 8 == 3 then r.requirements['sulfur'] = math.floor(stageFactor * 60*math.pow(LIFactor,levelID)) end if levelID > 33 and levelID % 37 == 4 then r.requirements['arithmetic-combinator'] = math.floor(stageFactor * 27.3*math.pow(LIFactor,levelID)) end if levelID > 33 and levelID % 37 == 3 then r.requirements['decider-combinator'] = math.floor(stageFactor * 27.3*math.pow(LIFactor,levelID)) end if levelID > 33 and levelID % 37 == 5 then r.requirements['constant-combinator'] = math.floor(stageFactor * 25*math.pow(LIFactor,levelID)) end if levelID > 38 and levelID % 37 == 13 then r.requirements['power-switch'] = math.floor(stageFactor * 16.7*math.pow(LIFactor,levelID)) end if levelID > 40 and levelID % 37 == 16 then r.requirements['programmable-speaker'] = math.floor(stageFactor * 11.6*math.pow(LIFactor,levelID)) end if levelID > 40 and levelID % 19 == 6 then r.requirements['sulfuric-acid-barrel'] = math.floor(stageFactor * 1.5*math.pow(LIFactor,levelID)) end if levelID > 40 and levelID < 89 and levelID % 8 == 2 then r.requirements['grenade'] = math.floor(stageFactor * 21.5*math.pow(LIFactor,levelID)) end if levelID > 42 and levelID < 93 and levelID % 5 == 0 then r.requirements['uranium-ore'] = math.floor(stageFactor * 188*math.pow(LIFactor,levelID)) end if levelID > 50 and levelID % 37 == 20 then r.requirements['medium-electric-pole'] = math.floor(stageFactor * 17.7*math.pow(LIFactor,levelID)) end if levelID > 50 and levelID % 37 == 23 then r.requirements['big-electric-pole'] = math.floor(stageFactor * 7.15*math.pow(LIFactor,levelID)) end if levelID > 45 and levelID < 95 and levelID % 6 == 5 then r.requirements['battery'] = math.floor(stageFactor * 16.7*math.pow(LIFactor,levelID)) end if levelID > 45 and levelID % 15 == 3 then r.requirements['military-science-pack'] = math.floor(stageFactor * 5.1*math.pow(LIFactor,levelID)) end if levelID > 51 and levelID < 91 and levelID % 5 == 3 then r.requirements['engine-unit'] = math.floor(stageFactor * 23.1*math.pow(LIFactor,levelID)) end if levelID > 50 and levelID % 29 == 25 then r.requirements['pump'] = math.floor(stageFactor * 12.5*math.pow(LIFactor,levelID)) end if levelID > 52 and levelID % 19 == 16 then r.requirements['gate'] = math.floor(stageFactor * 8.83*math.pow(LIFactor,levelID)) end if levelID > 54 and levelID < 85 and levelID % 5 == 1 then r.requirements['solar-panel'] = math.floor(stageFactor * 3*math.pow(LIFactor,levelID)) end if levelID > 54 and levelID < 85 and levelID % 6 == 2 then r.requirements['advanced-circuit'] = math.floor(stageFactor * 15.8*math.pow(LIFactor,levelID)) end if levelID > 54 and levelID % 15 == 11 then r.requirements['science-pack-3'] = math.floor(stageFactor * 3.53*math.pow(LIFactor,levelID)) end if levelID > 52 and levelID % 15 == 9 then r.requirements['substation'] = math.floor(stageFactor * 1.58*math.pow(LIFactor,levelID)) end if levelID > 58 and levelID < 95 and levelID % 6 == 0 then r.requirements['electric-engine-unit'] = math.floor(stageFactor * 10.4*math.pow(LIFactor,levelID)) end if levelID > 53 and levelID % 19 == 0 then r.requirements['rail'] = math.floor(stageFactor * 68.2*math.pow(LIFactor,levelID)) end if levelID > 58 and levelID % 19 == 3 then r.requirements['cargo-wagon'] = math.floor(stageFactor * 1.5*math.pow(LIFactor,levelID)) end if levelID > 58 and levelID % 19 == 5 then r.requirements['locomotive'] = math.floor(stageFactor * 0.53*math.pow(LIFactor,levelID)) end if levelID > 62 and levelID < 98 and levelID % 5 == 4 then r.requirements['effectivity-module'] = math.floor(stageFactor * 2.31*math.pow(LIFactor,levelID)) end if levelID > 64 and levelID < 100 and levelID % 5 == 1 then r.requirements['productivity-module'] = math.floor(stageFactor * 2.31*math.pow(LIFactor,levelID)) end if levelID > 66 and levelID < 93 and levelID % 5 == 0 then r.requirements['speed-module'] = math.floor(stageFactor * 2.31*math.pow(LIFactor,levelID)) end if levelID > 65 and levelID < 110 and levelID % 5 == 2 then r.requirements['stack-inserter'] = math.floor(stageFactor * 2*math.pow(LIFactor,levelID)) end if levelID > 60 and levelID % 37 == 25 then r.requirements['accumulator'] = math.floor(stageFactor * 2.73*math.pow(LIFactor,levelID)) end if levelID > 70 and levelID % 19 == 14 then r.requirements['stack-filter-inserter'] = math.floor(stageFactor * 1.5*math.pow(LIFactor,levelID)) end if levelID > 60 and levelID % 29 == 4 then r.requirements['car'] = math.floor(stageFactor * 1.67*math.pow(LIFactor,levelID)) end if levelID > 60 and levelID % 29 == 6 then r.requirements['train-stop'] = math.floor(stageFactor * 5.56*math.pow(LIFactor,levelID)) end if levelID > 70 and levelID % 29 == 14 then r.requirements['rail-signal'] = math.floor(stageFactor * 30*math.pow(LIFactor,levelID)) end if levelID > 60 and levelID % 29 == 11 then r.requirements['rail-chain-signal'] = math.floor(stageFactor * 30*math.pow(LIFactor,levelID)) end if levelID > 70 and levelID < 120 and levelID % 7 == 2 then r.requirements['flying-robot-frame'] = math.floor(stageFactor * 3*math.pow(LIFactor,levelID)) end if levelID > 71 and levelID % 19 == 18 then r.requirements['roboport'] = math.floor(stageFactor * 0.2*math.pow(LIFactor,levelID)) end if levelID > 75 and levelID % 19 == 1 then r.requirements['construction-robot'] = math.floor(stageFactor * 2.31*math.pow(LIFactor,levelID)) end if levelID > 80 and levelID % 19 == 9 then r.requirements['logistic-robot'] = math.floor(stageFactor * 1.77*math.pow(LIFactor,levelID)) end if levelID > 74 and levelID % 37 == 19 then r.requirements['fluid-wagon'] = math.floor(stageFactor * 0.81*math.pow(LIFactor,levelID)) end if levelID > 80 and levelID % 37 == 29 then r.requirements['modular-armor'] = math.floor(stageFactor * 0.3*math.pow(LIFactor,levelID)) end if levelID > 80 and levelID % 37 == 30 then r.requirements['night-vision-equipment'] = math.floor(stageFactor * 1.58*math.pow(LIFactor,levelID)) end if levelID > 80 and levelID % 37 == 31 then r.requirements['solar-panel-equipment'] = math.floor(stageFactor * 0.46*math.pow(LIFactor,levelID)) end if levelID > 75 and levelID < 108 and levelID % 11 == 0 then r.requirements['battery-equipment'] = math.floor(stageFactor * 1.67*math.pow(LIFactor,levelID)) end if levelID > 80 and levelID % 19 == 15 then r.requirements['heat-pipe'] = math.floor(stageFactor * 3*math.pow(LIFactor,levelID)) end if levelID > 85 and levelID % 19 == 17 then r.requirements['heat-exchanger'] = math.floor(stageFactor * 1.43*math.pow(LIFactor,levelID)) end if levelID > 90 and levelID % 19 == 2 then r.requirements['steam-turbine'] = math.floor(stageFactor * 1.31*math.pow(LIFactor,levelID)) end if levelID > 76 and levelID < 118 and levelID % 8 == 7 then r.requirements['processing-unit'] = math.floor(stageFactor * 2.31*math.pow(LIFactor,levelID)) end if levelID > 80 and levelID < 109 and levelID % 11 == 0 then r.requirements['energy-shield-equipment'] = math.floor(stageFactor * 1.58*math.pow(LIFactor,levelID)) end if levelID > 85 and levelID < 130 and levelID % 7 == 3 then r.requirements['electric-furnace'] = math.floor(stageFactor * 1.43*math.pow(LIFactor,levelID)) end if levelID > 80 and levelID % 15 == 6 then r.requirements['centrifuge'] = math.floor(stageFactor * 0.1*math.pow(LIFactor,levelID)) end if levelID > 105 and levelID % 15 == 4 then r.requirements['nuclear-reactor'] = math.floor(stageFactor * 0.05*math.pow(LIFactor,levelID)) end if levelID > 88 and levelID < 135 and levelID % 7 == 0 then r.requirements['uranium-238'] = math.floor(stageFactor * 15.8*math.pow(LIFactor,levelID)) end if levelID > 88 and levelID % 15 == 14 then r.requirements['production-science-pack'] = math.floor(stageFactor * 1.77*math.pow(LIFactor,levelID)) end if levelID > 88 and levelID < 115 and levelID % 6 == 2 then r.requirements['personal-roboport-equipment'] = math.floor(stageFactor * 0.25*math.pow(LIFactor,levelID)) end if levelID > 90 and levelID < 115 and levelID % 8 == 4 then r.requirements['effectivity-module-2'] = math.floor(stageFactor * 0.2*math.pow(LIFactor,levelID)) end if levelID > 88 and levelID < 125 and levelID % 8 == 6 then r.requirements['productivity-module-2'] = math.floor(stageFactor * 0.2*math.pow(LIFactor,levelID)) end if levelID > 90 and levelID < 122 and levelID % 7 == 4 then r.requirements['speed-module-2'] = math.floor(stageFactor * 0.2*math.pow(LIFactor,levelID)) end if levelID > 100 and levelID < 125 and levelID % 6 == 1 then r.requirements['uranium-235'] = math.floor(stageFactor * 0.15*math.pow(LIFactor,levelID)) end if levelID > 100 and levelID % 37 == 32 then r.requirements['exoskeleton-equipment'] = math.floor(stageFactor * 0.12*math.pow(LIFactor,levelID)) end if levelID > 100 and levelID % 9 == 6 then r.requirements['high-tech-science-pack'] = math.floor(stageFactor * 1.08*math.pow(LIFactor,levelID)) end if levelID > 100 and levelID % 29 == 19 then r.requirements['uranium-fuel-cell'] = math.floor(stageFactor * 0.11*math.pow(LIFactor,levelID)) end if levelID > 100 and levelID % 29 == 20 then r.requirements['battery-mk2-equipment'] = math.floor(stageFactor * 0.057*math.pow(LIFactor,levelID)) end if levelID > 100 and levelID < 140 and levelID % 7 == 1 then r.requirements['defender-capsule'] = math.floor(stageFactor * 7.5*math.pow(LIFactor,levelID)) end if levelID > 102 and levelID < 145 and levelID % 11 == 7 then r.requirements['explosives'] = math.floor(stageFactor * 42.9*math.pow(LIFactor,levelID)) end if levelID > 100 and levelID % 37 == 33 then r.requirements['flamethrower'] = math.floor(stageFactor * 4.62*math.pow(LIFactor,levelID)) end if levelID > 110 and levelID % 29 == 22 then r.requirements['flamethrower-ammo'] = math.floor(stageFactor * 3.62*math.pow(LIFactor,levelID)) end if levelID > 100 and levelID % 37 == 34 then r.requirements['flamethrower-turret'] = math.floor(stageFactor * 0.86*math.pow(LIFactor,levelID)) end if levelID > 100 and levelID % 37 == 0 then r.requirements['rocket-launcher'] = math.floor(stageFactor * 7.32*math.pow(LIFactor,levelID)) end if levelID > 110 and levelID < 122 and levelID % 5 == 3 then r.requirements['rocket'] = math.floor(stageFactor * 21.5*math.pow(LIFactor,levelID)) end if levelID > 100 and levelID % 37 == 1 then r.requirements['land-mine'] = math.floor(stageFactor * 12.5*math.pow(LIFactor,levelID)) end if levelID > 110 and levelID < 128 and levelID % 4 == 1 then r.requirements['laser-turret'] = math.floor(stageFactor * 0.63*math.pow(LIFactor,levelID)) end if levelID > 100 and levelID % 29 == 23 then r.requirements['slowdown-capsule'] = math.floor(stageFactor * 11.2*math.pow(LIFactor,levelID)) end if levelID > 100 and levelID % 37 == 2 then r.requirements['power-armor'] = math.floor(stageFactor * 0.19*math.pow(LIFactor,levelID)) end if levelID > 100 and levelID % 29 == 24 then r.requirements['poison-capsule'] = math.floor(stageFactor * 7.15*math.pow(LIFactor,levelID)) end if levelID > 118 and levelID < 155 and levelID % 4 == 0 then r.requirements['cannon-shell'] = math.floor(stageFactor * 9.68*math.pow(LIFactor,levelID)) end if levelID > 120 and levelID < 150 and levelID % 8 == 2 then r.requirements['explosive-cannon-shell'] = math.floor(stageFactor * 7.7*math.pow(LIFactor,levelID)) end if levelID > 120 and levelID < 148 and levelID % 6 == 5 then r.requirements['distractor-capsule'] = math.floor(stageFactor * 1.16*math.pow(LIFactor,levelID)) end if levelID > 110 and levelID % 29 == 0 then r.requirements['tank'] = math.floor(stageFactor * 0.28*math.pow(LIFactor,levelID)) end if levelID > 110 and levelID % 29 == 1 then r.requirements['explosive-rocket'] = math.floor(stageFactor * 8.83*math.pow(LIFactor,levelID)) end if levelID > 110 and levelID % 29 == 2 then r.requirements['energy-shield-mk2-equipment'] = math.floor(stageFactor * 0.08*math.pow(LIFactor,levelID)) end if levelID > 110 and levelID % 29 == 3 then r.requirements['personal-laser-defense-equipment'] = math.floor(stageFactor * 0.097*math.pow(LIFactor,levelID)) end if levelID > 110 and levelID % 29 == 5 then r.requirements['discharge-defense-equipment'] = math.floor(stageFactor * 0.045*math.pow(LIFactor,levelID)) end if levelID > 130 and levelID < 155 and levelID % 7 == 2 then r.requirements['used-up-uranium-fuel-cell'] = math.floor(stageFactor * 0.3*math.pow(LIFactor,levelID)) end if levelID > 155 and levelID < 170 and levelID % 9 == 5 then r.requirements['used-up-uranium-fuel-cell'] = math.floor(stageFactor * 0.3*math.pow(LIFactor,levelID)) end if levelID > 130 and levelID % 15 == 13 then r.requirements['express-transport-belt'] = math.floor(stageFactor * 5.36*math.pow(LIFactor,levelID)) end if levelID > 133 and levelID % 15 == 0 then r.requirements['express-underground-belt'] = math.floor(stageFactor * 1.43*math.pow(LIFactor,levelID)) end if levelID > 133 and levelID % 15 == 1 then r.requirements['express-splitter'] = math.floor(stageFactor * 0.45*math.pow(LIFactor,levelID)) end if levelID > 133 and levelID % 15 == 2 then r.requirements['assembling-machine-3'] = math.floor(stageFactor * 0.37*math.pow(LIFactor,levelID)) end if levelID > 112 and levelID % 19 == 7 then r.requirements['beacon'] = math.floor(stageFactor * 0.49*math.pow(LIFactor,levelID)) end if levelID > 133 and levelID % 15 == 5 then r.requirements['effectivity-module-3'] = math.floor(stageFactor * 0.03*math.pow(LIFactor,levelID)) end if levelID > 135 and levelID % 15 == 8 then r.requirements['productivity-module-3'] = math.floor(stageFactor * 0.03*math.pow(LIFactor,levelID)) end if levelID > 135 and levelID % 15 == 12 then r.requirements['speed-module-3'] = math.floor(stageFactor * 0.03*math.pow(LIFactor,levelID)) end if levelID > 110 and levelID % 29 == 7 then r.requirements['personal-roboport-mk2-equipment'] = math.floor(stageFactor * 0.013*math.pow(LIFactor,levelID)) end if levelID > 110 and levelID % 29 == 12 then r.requirements['cluster-grenade'] = math.floor(stageFactor * 1.5*math.pow(LIFactor,levelID)) end if levelID > 110 and levelID % 29 == 13 then r.requirements['destroyer-capsule'] = math.floor(stageFactor * 0.22*math.pow(LIFactor,levelID)) end if levelID > 125 and levelID % 29 == 21 then r.requirements['uranium-rounds-magazine'] = math.floor(stageFactor * 6.6*math.pow(LIFactor,levelID)) end if levelID > 125 and levelID % 29 == 26 then r.requirements['uranium-cannon-shell'] = math.floor(stageFactor * 5*math.pow(LIFactor,levelID)) end if levelID > 125 and levelID % 29 == 27 then r.requirements['explosive-uranium-cannon-shell'] = math.floor(stageFactor * 4.3*math.pow(LIFactor,levelID)) end if levelID > 125 and levelID % 29 == 28 then r.requirements['fusion-reactor-equipment'] = math.floor(stageFactor * 0.0077*math.pow(LIFactor,levelID)) end if levelID > 140 and levelID % 9 == 1 then r.requirements['rocket-fuel'] = math.floor(stageFactor * 8.34*math.pow(LIFactor,levelID)) end if levelID > 145 and levelID % 9 == 3 then r.requirements['low-density-structure'] = math.floor(stageFactor * 3.07*math.pow(LIFactor,levelID)) end if levelID > 145 and levelID % 9 == 7 then r.requirements['rocket-control-unit'] = math.floor(stageFactor * 0.97*math.pow(LIFactor,levelID)) end if levelID > 150 and levelID % 9 == 0 then r.requirements['rocket-silo'] = math.floor(stageFactor * 0.0062*math.pow(LIFactor,levelID)) end if levelID > 150 and levelID % 9 == 2 then r.requirements['satellite'] = math.floor(stageFactor * 0.0062*math.pow(LIFactor,levelID)) end if levelID > 150 and levelID % 9 == 4 then r.requirements['space-science-pack'] = math.floor(stageFactor * 0.5*math.pow(LIFactor,levelID)) end if levelID > 155 and levelID % 9 == 8 then r.requirements['atomic-bomb'] = math.floor(stageFactor * 0.0058*math.pow(LIFactor,levelID)) end if levelID > 170 and levelID % 9 == 5 then r.requirements['power-armor-mk2'] = math.floor(stageFactor * 0.0052*math.pow(LIFactor,levelID)) end return r; end global.standings = {} global.standings.teams = {} global.eventeams = false global.standings.teams['tocu'] = {name = "Tocu", human = true, level = 1, points = 0, chests={}, deliveries=getLevelReqs(1).requirements} global.standings.teams['dirda'] = {name = "Dirda", human = true, level = 1, points = 0, chests={}, deliveries=getLevelReqs(1).requirements} global.standings.teams['strindberg'] = {name = "Superturbo Strindberg", human = false, level = 1, points = 0, speed = 100, lastfin = 0 } global.standings.teams['freddie'] = {name = "Fast Freddie", human = false, level = 1, points = 0, speed = 119, lastfin = 0 } global.standings.teams['charlie'] = {name = "Capable Charlie", human = false, level = 1, points = 0, speed = 143, lastfin = 0 } global.standings.teams['daniel'] = {name = "Decent Daniel", human = false, level = 1, points = 0, speed = 171, lastfin = 0 } global.standings.teams['tony'] = {name = "Trailing Tony", human = false, level = 1, points = 0, speed = 207, lastfin = 0 } function get_player_team(player) return get_force_team(player.force) end function get_force_team(force) return global.standings.teams[force.name] or global.standings.teams['tocu'] end function get_level_player(player) local theF = get_player_team(player) return theF.level end -- Return the tick when an AI is expected to finish a given level. -- If the AI has already completed the level, return nil. -- Humans will also return nil. function get_level_eta(team, level) if team.human then return nil; end -- humans have no ETA if level < team.level then return nil; end -- completed levels have no ETA local tick = team.lastfin; -- time when team completed its previous level for i=team.level,level do -- iterate all levels from previous to the desired one tick = tick + math.floor(60 * team.speed * getLevelReqs(i).time / 100); end return tick; end -- Return the amount of points you would get by handing in level right now. function get_level_points(level) local r = 0; for fid, force in pairs(global.standings.teams) do if force.level <= level then r = r + 1; end end return r; end -- Announce a message to all human players function announce(msg) for k, player in pairs (game.players) do player.print(msg); end end script.on_init(function() game.create_force('tocu') game.create_force('dirda') game.forces['tocu'].set_cease_fire('dirda', true) game.forces['dirda'].set_cease_fire('tocu', true) --game.players[1].force = game.forces['tocu'] end) script.on_event(defines.events, function(event) if event.name == defines.events.on_player_created then on_joined(game.players[event.player_index]) end if event.name == defines.events.on_tick then on_update(event.tick) end if event.name == defines.events.on_player_mined_entity then on_remove(game.players[event.player_index].force, event.entity) end if event.name == defines.events.on_robot_mined_entity then on_remove(event.robot.force, event.entity) end if event.name == defines.events.on_built_entity then on_build(game.players[event.player_index].force, event.created_entity) end if event.name == defines.events.on_robot_built_entity then on_build(event.robot.force, event.created_entity) end if event.name == defines.events.on_entity_died then on_remove(event.entity.force, event.entity) end end) function on_joined(player) player.insert{name = "iron-plate", count = 21} player.insert{name = "logistic-chest-active-provider", count = 6} -- temp team assignment if(not global.eventeams) then player.force = game.forces['tocu'] player.print("You are on team Tocu!"); else player.force = game.forces['dirda'] player.print("You are on team Dirda!"); end global.eventeams = not global.eventeams; make_frame(player) end function on_build(force, building) if building.name ~= "logistic-chest-active-provider" then return; end local team = get_force_team(force) team.chests[building.position] = building; local c = 0; end function on_remove(force, building) if building.name ~= "logistic-chest-active-provider" then return; end local team = get_force_team(force) local c = 0; for k,v in pairs(team.chests) do if k.x == building.position.x and k.y == building.position.y then team.chests[k] = nil; break; end end end function on_update(tick) if (tick % 60 ~= 0) then return end local status_update_needed = false; for fid, force in pairs(global.standings.teams) do if force.human then local delivered_something = false; -- check each chest owned by the human force, remove possible items needed for delivery. local force_update_needed = false; for k, chest in pairs(force.chests) do local inventory = chest.get_inventory(defines.inventory.chest); local contents = inventory.get_contents(); for deliveryname, deliveryamount in pairs(force.deliveries) do if contents[deliveryname] then -- if > 0 items of the wanted type exists in this chest local counttoconsume = math.min(deliveryamount, contents[deliveryname]); inventory.remove{name = deliveryname, count = counttoconsume} force.deliveries[deliveryname] = force.deliveries[deliveryname] - counttoconsume; if force.deliveries[deliveryname] == 0 then force.deliveries[deliveryname] = nil; end delivered_something = true; status_update_needed = true end end end -- does the human force now advance to the next level? if delivered_something then local c = 0; for deliveryname, deliveryamount in pairs(force.deliveries) do c = 1; break; end if c == 0 then -- we can advance. Increase level, fetch new delivery requirements. local pointgain = get_level_points(force.level); announce(force.name .. " has completed level " .. force.level .. " (+" .. pointgain .. ")"); force.points = force.points + pointgain; force.level = force.level + 1; local r = getLevelReqs(force.level); force.deliveries = r.requirements; end end else -- has the AI force has advanced yet? local eta = get_level_eta(force, force.level) - game.tick; if(eta < 0) then --announce(force.name .. " has completed level " .. force.level); local pointgain = get_level_points(force.level); force.points = force.points + pointgain; force.lastfin = get_level_eta(force, force.level); force.level = force.level + 1; end end -- not human end -- Also update menus for human players. for k, player in pairs (game.players) do update_frame(player) end end -- Make Frame. Run once per player, at the time of player creation. And never again. function make_frame(player) local flow = mod_gui.get_frame_flow(player) -- Deliveries frame local deliveryboard = flow.add{type= "frame", name= "supply_deliveryboard", direction= "vertical"} local deliveryflow = deliveryboard.add{type= "table", name= "supply_deliveryflow", colspan=1} deliveryflow.add{type="label", caption="This Level", style="caption_label_style"}; deliveryflow.add{type= "table", name= "supply_deliverytable", colspan=3}; deliveryflow.add{type="label", caption="Next Level", style="caption_label_style"}; deliveryflow.add{type= "table", name= "supply_deliverytablenext", colspan=3}; deliveryflow.add{type="label", caption="Next Next Level", style="caption_label_style"}; deliveryflow.add{type= "table", name= "supply_deliverytablenextnext", colspan=3}; -- Scoreboard Frame local scoreboard = flow.add{type= "frame", name= "supply_scoreboard", direction= "vertical"} local scoretable = scoreboard.add{type= "table", name= "supply_scoretable", colspan=4} update_frame(player); return frame end -- UPdate frame. Called once per updating tick. TODO: Split in three functions. function update_frame(player) local score = mod_gui.get_frame_flow(player).supply_scoreboard.supply_scoretable; local myteam = get_player_team(player); -- update standing score.clear(); score.add{type="label", caption="Name", style="caption_label_style"} score.add{type="label", caption="Level", style="caption_label_style"} score.add{type="label", caption="Score", style="caption_label_style"} score.add{type="label", caption="ETA:Lv" .. myteam.level, style="caption_label_style"} for k,v in scoresorted_pairs(global.standings.teams) do score.add{type= "label", caption=v.name} score.add{type= "label", caption=v.level} score.add{type= "label", caption=v.points} if 0 and v.level <= myteam.level then -- do not list teams that already completed the level if v.human then if v ~= myteam then local x = score.add{type= "label", caption="UNKNOWN" } x.style.font_color = {r=0.92, g=0.88, b=0.11}; else local x = score.add{type= "label", caption="SOON"} x.style.font_color = {r=0.92, g=0.88, b=0.11}; end else local eta = format_time(get_level_eta(v, myteam.level) - game.tick); score.add{type= "label", caption=eta } end else local x = score.add{type= "label", caption="DONE"} x.style.font_color = {r=0.82, g=0.18, b=0.11}; end end -- updatee deliveries local delivery = mod_gui.get_frame_flow(player).supply_deliveryboard.supply_deliveryflow.supply_deliverytable; delivery.clear(); for k,v in pairs(myteam.deliveries) do delivery.add{type="sprite-button", sprite="item/" .. k, style="icon_button_style"} delivery.add{type= "label", caption=game.item_prototypes[k].localised_name, style="bold_label_style"} delivery.add{type= "label", caption=" x" ..v, style="bold_label_style"} end local deliverynext = mod_gui.get_frame_flow(player).supply_deliveryboard.supply_deliveryflow.supply_deliverytablenext; deliverynext.clear(); for k,v in pairs(getLevelReqs(myteam.level+1).requirements) do deliverynext.add{type="sprite-button", sprite="item/" .. k, style="icon_button_style"} deliverynext.add{type= "label", caption=game.item_prototypes[k].localised_name, style="bold_label_style"} deliverynext.add{type= "label", caption=" x" ..v, style="bold_label_style"} end local deliverynextnext = mod_gui.get_frame_flow(player).supply_deliveryboard.supply_deliveryflow.supply_deliverytablenextnext; deliverynextnext.clear(); for k,v in pairs(getLevelReqs(myteam.level+2).requirements) do deliverynextnext.add{type="sprite-button", sprite="item/" .. k, style="icon_button_style"} deliverynextnext.add{type= "label", caption=game.item_prototypes[k].localised_name, style="bold_label_style"} deliverynextnext.add{type= "label", caption=" x" ..v, style="bold_label_style"} end end function format_time(tick) local m = math.floor(tick / 3600); local s = math.floor((tick % 3600) / 60); if( s < 10) then s = "0" .. s; end return m .. ":" .. s; end function scoresorted_pairs(t) local keys = {} for k in pairs(t) do keys[#keys+1] = k end table.sort(keys, function(a,b) if(t[a].points == t[b].points) then return t[a].name < t[b].name end return t[a].points > t[b].points end) -- return the iterator function local i = 0 return function() i = i + 1 if keys[i] then return keys[i], t[keys[i]] end end end