1
0
mirror of https://github.com/ComfyFactory/ComfyFactorio.git synced 2024-12-28 23:06:38 +02:00

Added cave_choppy

Multi surfaces with cave_miner and choppy.
This commit is contained in:
Gerkiz 2019-06-24 13:22:35 +02:00
parent 4a44a3dc45
commit bf4b8baf22
7 changed files with 2818 additions and 0 deletions

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,115 @@
0.21
Ore bonus yield limited at the maximum biter difficulty.
0.20
a big part of the lootboxes are now hidden within the rocks
0.19
markets are now also fish bank terminals
fish can not be deconstructed anymore
0.18
cargo wagons, tanks and cars can now only detonate with less than 150 health
0.17
explosives are now a new game mechanic
loot rebalances
ore yield balance
0.16
oil should no longer clutter
increased rock destruction performance (maybe)
rocks now heal over time
0.15
players in vehicles no longer get hungry
faster mining speed but lower ore yield for more exploration
new fully staged chest loot
0.14
hunger over time reduced
reduced worms
ore vein spawn fix
0.13
biter attack events frequency reduced
players in vehicles are safe from random biter spawns
hunger gain from passing time reduced
0.12
reduced ore spill from rock destruction to reduce lagspike
ore veins are usually bigger now and can appear earlier
biters have a bit more damage against rocks
market adjustments
readded worms in main tunnels
crude oil is allowed to spawn a bit closer
access to the lakes and labyrinth areas should be a bit wider now
damage against huge rocks has been increased
biter spawn interval adjustments
0.11
mining speed buff
ore veins are more common
0.10
difficulty adjustments
spawn fixes
0.09
ore veins are more common with more yield
added info panel
added more worms
added extra bases in main mine shafts
adjusted running speed modifier
adjusted biter attack events
modified chest loot tables
mining trees now makes you earn fish
0.08
rock "labyrinth" biome
periodic biter attack events, the mines have become more dangerous
custom spawn trees
0.07
small chance that rocks might reveal an ore vein
rocks now always drop stone
players are now getting hungry
0.06
added stats gui
mining productivity research will now upgrade your backpack to ease your mining
fishing is more enjoyable now
rebalanced oil spots
spawn inventory loadout changes
0.05
biter & worm generation is now completely custom
biters claws now have a hard time to dig through the solid rock
secret shops spawn now in lake biomes
mining productivity research boosts cave rock mining speed for triple the value
0.04
biters no longer instantly surround the player
0.03
market nerf
darkness buff
mining productivity research now applies to cave rock mining
lakes now have fish
added cave treasure
0.02
space cleared around enemy spawners
fish market adjustments
maximum ore spill variable (rest gets inserted directly)
biters now also pop out of destroyed rocks
adjustments to ore chances
noise adjustments
different enemies now spawn the deeper you dig
enemy spawn pool redone
darkness is now a hazard, stay near lamps for survival
caves are now permanently dark
added lake biomes
0.01
diggy diggy hole

View File

@ -0,0 +1,155 @@
--This will add a new game mechanic so that containers with explosives actually go boom when they get damaged.
--Made by MewMew
local event = require 'utils.event'
local damage_per_explosive = 100
local empty_tile_damage_decay = 100
local out_of_map_tile_health = 1500
local circle_coordinates = {
[1] = {{x = 0, y = 0}},
[2] = {{x = -1, y = -1},{x = 1, y = -1},{x = 0, y = -1},{x = -1, y = 0},{x = -1, y = 1},{x = 0, y = 1},{x = 1, y = 1},{x = 1, y = 0}},
[3] = {{x = -2, y = -1},{x = -1, y = -2},{x = 1, y = -2},{x = 0, y = -2},{x = 2, y = -1},{x = -2, y = 1},{x = -2, y = 0},{x = 2, y = 1},{x = 2, y = 0},{x = -1, y = 2},{x = 1, y = 2},{x = 0, y = 2}},
[4] = {{x = -1, y = -3},{x = 1, y = -3},{x = 0, y = -3},{x = -3, y = -1},{x = -2, y = -2},{x = 3, y = -1},{x = 2, y = -2},{x = -3, y = 0},{x = -3, y = 1},{x = 3, y = 1},{x = 3, y = 0},{x = -2, y = 2},{x = -1, y = 3},{x = 0, y = 3},{x = 1, y = 3},{x = 2, y = 2}},
[5] = {{x = -3, y = -3},{x = -2, y = -3},{x = -1, y = -4},{x = -2, y = -4},{x = 1, y = -4},{x = 0, y = -4},{x = 2, y = -3},{x = 3, y = -3},{x = 2, y = -4},{x = -3, y = -2},{x = -4, y = -1},{x = -4, y = -2},{x = 3, y = -2},{x = 4, y = -1},{x = 4, y = -2},{x = -4, y = 1},{x = -4, y = 0},{x = 4, y = 1},{x = 4, y = 0},{x = -3, y = 3},{x = -3, y = 2},{x = -4, y = 2},{x = -2, y = 3},{x = 2, y = 3},{x = 3, y = 3},{x = 3, y = 2},{x = 4, y = 2},{x = -2, y = 4},{x = -1, y = 4},{x = 0, y = 4},{x = 1, y = 4},{x = 2, y = 4}},
[6] = {{x = -1, y = -5},{x = -2, y = -5},{x = 1, y = -5},{x = 0, y = -5},{x = 2, y = -5},{x = -3, y = -4},{x = -4, y = -3},{x = 3, y = -4},{x = 4, y = -3},{x = -5, y = -1},{x = -5, y = -2},{x = 5, y = -1},{x = 5, y = -2},{x = -5, y = 1},{x = -5, y = 0},{x = 5, y = 1},{x = 5, y = 0},{x = -5, y = 2},{x = -4, y = 3},{x = 4, y = 3},{x = 5, y = 2},{x = -3, y = 4},{x = -2, y = 5},{x = -1, y = 5},{x = 0, y = 5},{x = 1, y = 5},{x = 3, y = 4},{x = 2, y = 5}},
[7] = {{x = -4, y = -5},{x = -3, y = -5},{x = -2, y = -6},{x = -1, y = -6},{x = 0, y = -6},{x = 1, y = -6},{x = 3, y = -5},{x = 2, y = -6},{x = 4, y = -5},{x = -5, y = -4},{x = -5, y = -3},{x = -4, y = -4},{x = 4, y = -4},{x = 5, y = -4},{x = 5, y = -3},{x = -6, y = -1},{x = -6, y = -2},{x = 6, y = -1},{x = 6, y = -2},{x = -6, y = 1},{x = -6, y = 0},{x = 6, y = 1},{x = 6, y = 0},{x = -5, y = 3},{x = -6, y = 2},{x = 5, y = 3},{x = 6, y = 2},{x = -5, y = 4},{x = -4, y = 4},{x = -4, y = 5},{x = -3, y = 5},{x = 3, y = 5},{x = 4, y = 4},{x = 5, y = 4},{x = 4, y = 5},{x = -1, y = 6},{x = -2, y = 6},{x = 1, y = 6},{x = 0, y = 6},{x = 2, y = 6}},
[8] = {{x = -1, y = -7},{x = -2, y = -7},{x = 1, y = -7},{x = 0, y = -7},{x = 2, y = -7},{x = -5, y = -5},{x = -4, y = -6},{x = -3, y = -6},{x = 3, y = -6},{x = 4, y = -6},{x = 5, y = -5},{x = -6, y = -3},{x = -6, y = -4},{x = 6, y = -4},{x = 6, y = -3},{x = -7, y = -1},{x = -7, y = -2},{x = 7, y = -1},{x = 7, y = -2},{x = -7, y = 1},{x = -7, y = 0},{x = 7, y = 1},{x = 7, y = 0},{x = -7, y = 2},{x = -6, y = 3},{x = 6, y = 3},{x = 7, y = 2},{x = -5, y = 5},{x = -6, y = 4},{x = 5, y = 5},{x = 6, y = 4},{x = -3, y = 6},{x = -4, y = 6},{x = -2, y = 7},{x = -1, y = 7},{x = 0, y = 7},{x = 1, y = 7},{x = 3, y = 6},{x = 2, y = 7},{x = 4, y = 6}},
[9] = {{x = -4, y = -7},{x = -3, y = -7},{x = -2, y = -8},{x = -1, y = -8},{x = 0, y = -8},{x = 1, y = -8},{x = 3, y = -7},{x = 2, y = -8},{x = 4, y = -7},{x = -5, y = -6},{x = -6, y = -6},{x = -6, y = -5},{x = 5, y = -6},{x = 6, y = -5},{x = 6, y = -6},{x = -7, y = -4},{x = -7, y = -3},{x = 7, y = -4},{x = 7, y = -3},{x = -8, y = -2},{x = -8, y = -1},{x = 8, y = -1},{x = 8, y = -2},{x = -8, y = 0},{x = -8, y = 1},{x = 8, y = 1},{x = 8, y = 0},{x = -7, y = 3},{x = -8, y = 2},{x = 7, y = 3},{x = 8, y = 2},{x = -7, y = 4},{x = -6, y = 5},{x = 6, y = 5},{x = 7, y = 4},{x = -5, y = 6},{x = -6, y = 6},{x = -4, y = 7},{x = -3, y = 7},{x = 3, y = 7},{x = 5, y = 6},{x = 4, y = 7},{x = 6, y = 6},{x = -2, y = 8},{x = -1, y = 8},{x = 0, y = 8},{x = 1, y = 8},{x = 2, y = 8}},
[10] = {{x = -3, y = -9},{x = -1, y = -9},{x = -2, y = -9},{x = 1, y = -9},{x = 0, y = -9},{x = 3, y = -9},{x = 2, y = -9},{x = -5, y = -7},{x = -6, y = -7},{x = -5, y = -8},{x = -4, y = -8},{x = -3, y = -8},{x = 3, y = -8},{x = 5, y = -7},{x = 5, y = -8},{x = 4, y = -8},{x = 6, y = -7},{x = -7, y = -5},{x = -7, y = -6},{x = -8, y = -5},{x = 7, y = -5},{x = 7, y = -6},{x = 8, y = -5},{x = -9, y = -3},{x = -8, y = -4},{x = -8, y = -3},{x = 8, y = -4},{x = 8, y = -3},{x = 9, y = -3},{x = -9, y = -1},{x = -9, y = -2},{x = 9, y = -1},{x = 9, y = -2},{x = -9, y = 1},{x = -9, y = 0},{x = 9, y = 1},{x = 9, y = 0},{x = -9, y = 3},{x = -9, y = 2},{x = -8, y = 3},{x = 8, y = 3},{x = 9, y = 3},{x = 9, y = 2},{x = -7, y = 5},{x = -8, y = 5},{x = -8, y = 4},{x = 7, y = 5},{x = 8, y = 5},{x = 8, y = 4},{x = -7, y = 6},{x = -6, y = 7},{x = -5, y = 7},{x = 5, y = 7},{x = 7, y = 6},{x = 6, y = 7},{x = -5, y = 8},{x = -4, y = 8},{x = -3, y = 8},{x = -3, y = 9},{x = -2, y = 9},{x = -1, y = 9},{x = 0, y = 9},{x = 1, y = 9},{x = 3, y = 8},{x = 2, y = 9},{x = 3, y = 9},{x = 5, y = 8},{x = 4, y = 8}},
[11] = {{x = -5, y = -9},{x = -4, y = -9},{x = -3, y = -10},{x = -1, y = -10},{x = -2, y = -10},{x = 1, y = -10},{x = 0, y = -10},{x = 3, y = -10},{x = 2, y = -10},{x = 5, y = -9},{x = 4, y = -9},{x = -7, y = -7},{x = -6, y = -8},{x = 7, y = -7},{x = 6, y = -8},{x = -9, y = -5},{x = -8, y = -6},{x = 9, y = -5},{x = 8, y = -6},{x = -9, y = -4},{x = -10, y = -3},{x = 9, y = -4},{x = 10, y = -3},{x = -10, y = -2},{x = -10, y = -1},{x = 10, y = -1},{x = 10, y = -2},{x = -10, y = 0},{x = -10, y = 1},{x = 10, y = 1},{x = 10, y = 0},{x = -10, y = 2},{x = -10, y = 3},{x = 10, y = 3},{x = 10, y = 2},{x = -9, y = 4},{x = -9, y = 5},{x = 9, y = 5},{x = 9, y = 4},{x = -8, y = 6},{x = -7, y = 7},{x = 7, y = 7},{x = 8, y = 6},{x = -6, y = 8},{x = -5, y = 9},{x = -4, y = 9},{x = 4, y = 9},{x = 5, y = 9},{x = 6, y = 8},{x = -3, y = 10},{x = -2, y = 10},{x = -1, y = 10},{x = 0, y = 10},{x = 1, y = 10},{x = 2, y = 10},{x = 3, y = 10}},
[12] = {{x = -3, y = -11},{x = -2, y = -11},{x = -1, y = -11},{x = 0, y = -11},{x = 1, y = -11},{x = 2, y = -11},{x = 3, y = -11},{x = -7, y = -9},{x = -6, y = -9},{x = -5, y = -10},{x = -4, y = -10},{x = 5, y = -10},{x = 4, y = -10},{x = 7, y = -9},{x = 6, y = -9},{x = -9, y = -7},{x = -7, y = -8},{x = -8, y = -8},{x = -8, y = -7},{x = 7, y = -8},{x = 8, y = -7},{x = 8, y = -8},{x = 9, y = -7},{x = -9, y = -6},{x = -10, y = -5},{x = 9, y = -6},{x = 10, y = -5},{x = -11, y = -3},{x = -10, y = -4},{x = 10, y = -4},{x = 11, y = -3},{x = -11, y = -2},{x = -11, y = -1},{x = 11, y = -1},{x = 11, y = -2},{x = -11, y = 0},{x = -11, y = 1},{x = 11, y = 1},{x = 11, y = 0},{x = -11, y = 2},{x = -11, y = 3},{x = 11, y = 3},{x = 11, y = 2},{x = -10, y = 5},{x = -10, y = 4},{x = 10, y = 5},{x = 10, y = 4},{x = -9, y = 7},{x = -9, y = 6},{x = -8, y = 7},{x = 8, y = 7},{x = 9, y = 7},{x = 9, y = 6},{x = -8, y = 8},{x = -7, y = 8},{x = -7, y = 9},{x = -6, y = 9},{x = 7, y = 8},{x = 7, y = 9},{x = 6, y = 9},{x = 8, y = 8},{x = -5, y = 10},{x = -4, y = 10},{x = -3, y = 11},{x = -2, y = 11},{x = -1, y = 11},{x = 0, y = 11},{x = 1, y = 11},{x = 2, y = 11},{x = 3, y = 11},{x = 4, y = 10},{x = 5, y = 10}},
[13] = {{x = -5, y = -11},{x = -4, y = -11},{x = -3, y = -12},{x = -1, y = -12},{x = -2, y = -12},{x = 1, y = -12},{x = 0, y = -12},{x = 3, y = -12},{x = 2, y = -12},{x = 4, y = -11},{x = 5, y = -11},{x = -8, y = -9},{x = -7, y = -10},{x = -6, y = -10},{x = 6, y = -10},{x = 7, y = -10},{x = 8, y = -9},{x = -10, y = -7},{x = -9, y = -8},{x = 9, y = -8},{x = 10, y = -7},{x = -11, y = -5},{x = -10, y = -6},{x = 10, y = -6},{x = 11, y = -5},{x = -11, y = -4},{x = -12, y = -3},{x = 11, y = -4},{x = 12, y = -3},{x = -12, y = -1},{x = -12, y = -2},{x = 12, y = -1},{x = 12, y = -2},{x = -12, y = 1},{x = -12, y = 0},{x = 12, y = 1},{x = 12, y = 0},{x = -12, y = 3},{x = -12, y = 2},{x = 12, y = 3},{x = 12, y = 2},{x = -11, y = 5},{x = -11, y = 4},{x = 11, y = 4},{x = 11, y = 5},{x = -10, y = 7},{x = -10, y = 6},{x = 10, y = 6},{x = 10, y = 7},{x = -9, y = 8},{x = -8, y = 9},{x = 9, y = 8},{x = 8, y = 9},{x = -7, y = 10},{x = -5, y = 11},{x = -6, y = 10},{x = -4, y = 11},{x = 5, y = 11},{x = 4, y = 11},{x = 7, y = 10},{x = 6, y = 10},{x = -3, y = 12},{x = -2, y = 12},{x = -1, y = 12},{x = 0, y = 12},{x = 1, y = 12},{x = 2, y = 12},{x = 3, y = 12}},
[14] = {{x = -3, y = -13},{x = -1, y = -13},{x = -2, y = -13},{x = 1, y = -13},{x = 0, y = -13},{x = 3, y = -13},{x = 2, y = -13},{x = -7, y = -11},{x = -6, y = -11},{x = -5, y = -12},{x = -6, y = -12},{x = -4, y = -12},{x = 5, y = -12},{x = 4, y = -12},{x = 7, y = -11},{x = 6, y = -11},{x = 6, y = -12},{x = -10, y = -9},{x = -9, y = -9},{x = -9, y = -10},{x = -8, y = -10},{x = 9, y = -9},{x = 9, y = -10},{x = 8, y = -10},{x = 10, y = -9},{x = -11, y = -7},{x = -10, y = -8},{x = 11, y = -7},{x = 10, y = -8},{x = -11, y = -6},{x = -12, y = -6},{x = -12, y = -5},{x = 11, y = -6},{x = 12, y = -6},{x = 12, y = -5},{x = -13, y = -3},{x = -12, y = -4},{x = 12, y = -4},{x = 13, y = -3},{x = -13, y = -2},{x = -13, y = -1},{x = 13, y = -1},{x = 13, y = -2},{x = -13, y = 0},{x = -13, y = 1},{x = 13, y = 1},{x = 13, y = 0},{x = -13, y = 2},{x = -13, y = 3},{x = 13, y = 3},{x = 13, y = 2},{x = -12, y = 5},{x = -12, y = 4},{x = 12, y = 5},{x = 12, y = 4},{x = -11, y = 6},{x = -11, y = 7},{x = -12, y = 6},{x = 11, y = 7},{x = 11, y = 6},{x = 12, y = 6},{x = -10, y = 8},{x = -10, y = 9},{x = -9, y = 9},{x = 9, y = 9},{x = 10, y = 9},{x = 10, y = 8},{x = -9, y = 10},{x = -8, y = 10},{x = -7, y = 11},{x = -6, y = 11},{x = 7, y = 11},{x = 6, y = 11},{x = 8, y = 10},{x = 9, y = 10},{x = -6, y = 12},{x = -5, y = 12},{x = -4, y = 12},{x = -3, y = 13},{x = -2, y = 13},{x = -1, y = 13},{x = 0, y = 13},{x = 1, y = 13},{x = 2, y = 13},{x = 3, y = 13},{x = 5, y = 12},{x = 4, y = 12},{x = 6, y = 12}},
[15] = {{x = -5, y = -13},{x = -6, y = -13},{x = -4, y = -13},{x = -3, y = -14},{x = -1, y = -14},{x = -2, y = -14},{x = 1, y = -14},{x = 0, y = -14},{x = 3, y = -14},{x = 2, y = -14},{x = 5, y = -13},{x = 4, y = -13},{x = 6, y = -13},{x = -9, y = -11},{x = -8, y = -11},{x = -8, y = -12},{x = -7, y = -12},{x = 7, y = -12},{x = 8, y = -12},{x = 8, y = -11},{x = 9, y = -11},{x = -11, y = -9},{x = -10, y = -10},{x = 10, y = -10},{x = 11, y = -9},{x = -12, y = -7},{x = -11, y = -8},{x = -12, y = -8},{x = 11, y = -8},{x = 12, y = -8},{x = 12, y = -7},{x = -13, y = -5},{x = -13, y = -6},{x = 13, y = -5},{x = 13, y = -6},{x = -13, y = -4},{x = -14, y = -3},{x = 13, y = -4},{x = 14, y = -3},{x = -14, y = -2},{x = -14, y = -1},{x = 14, y = -1},{x = 14, y = -2},{x = -14, y = 0},{x = -14, y = 1},{x = 14, y = 1},{x = 14, y = 0},{x = -14, y = 2},{x = -14, y = 3},{x = 14, y = 3},{x = 14, y = 2},{x = -13, y = 4},{x = -13, y = 5},{x = 13, y = 5},{x = 13, y = 4},{x = -13, y = 6},{x = -12, y = 7},{x = 12, y = 7},{x = 13, y = 6},{x = -11, y = 9},{x = -11, y = 8},{x = -12, y = 8},{x = 11, y = 8},{x = 11, y = 9},{x = 12, y = 8},{x = -9, y = 11},{x = -10, y = 10},{x = -8, y = 11},{x = 9, y = 11},{x = 8, y = 11},{x = 10, y = 10},{x = -7, y = 12},{x = -8, y = 12},{x = -6, y = 13},{x = -5, y = 13},{x = -4, y = 13},{x = 5, y = 13},{x = 4, y = 13},{x = 7, y = 12},{x = 6, y = 13},{x = 8, y = 12},{x = -3, y = 14},{x = -2, y = 14},{x = -1, y = 14},{x = 0, y = 14},{x = 1, y = 14},{x = 2, y = 14},{x = 3, y = 14}},
[16] = {{x = -3, y = -15},{x = -1, y = -15},{x = -2, y = -15},{x = 1, y = -15},{x = 0, y = -15},{x = 3, y = -15},{x = 2, y = -15},{x = -7, y = -13},{x = -8, y = -13},{x = -5, y = -14},{x = -6, y = -14},{x = -4, y = -14},{x = 5, y = -14},{x = 4, y = -14},{x = 7, y = -13},{x = 6, y = -14},{x = 8, y = -13},{x = -9, y = -12},{x = -10, y = -11},{x = 9, y = -12},{x = 10, y = -11},{x = -11, y = -10},{x = -12, y = -9},{x = 11, y = -10},{x = 12, y = -9},{x = -13, y = -7},{x = -13, y = -8},{x = 13, y = -7},{x = 13, y = -8},{x = -14, y = -6},{x = -14, y = -5},{x = 14, y = -5},{x = 14, y = -6},{x = -15, y = -3},{x = -14, y = -4},{x = 15, y = -3},{x = 14, y = -4},{x = -15, y = -2},{x = -15, y = -1},{x = 15, y = -1},{x = 15, y = -2},{x = -15, y = 0},{x = -15, y = 1},{x = 15, y = 1},{x = 15, y = 0},{x = -15, y = 2},{x = -15, y = 3},{x = 15, y = 3},{x = 15, y = 2},{x = -14, y = 5},{x = -14, y = 4},{x = 14, y = 5},{x = 14, y = 4},{x = -13, y = 7},{x = -14, y = 6},{x = 13, y = 7},{x = 14, y = 6},{x = -13, y = 8},{x = -12, y = 9},{x = 12, y = 9},{x = 13, y = 8},{x = -11, y = 10},{x = -10, y = 11},{x = 10, y = 11},{x = 11, y = 10},{x = -9, y = 12},{x = -8, y = 13},{x = -7, y = 13},{x = 7, y = 13},{x = 8, y = 13},{x = 9, y = 12},{x = -6, y = 14},{x = -5, y = 14},{x = -4, y = 14},{x = -3, y = 15},{x = -2, y = 15},{x = -1, y = 15},{x = 0, y = 15},{x = 1, y = 15},{x = 2, y = 15},{x = 3, y = 15},{x = 4, y = 14},{x = 5, y = 14},{x = 6, y = 14}},
[17] = {{x = -5, y = -15},{x = -6, y = -15},{x = -3, y = -16},{x = -4, y = -16},{x = -4, y = -15},{x = -1, y = -16},{x = -2, y = -16},{x = 1, y = -16},{x = 0, y = -16},{x = 3, y = -16},{x = 2, y = -16},{x = 5, y = -15},{x = 4, y = -15},{x = 4, y = -16},{x = 6, y = -15},{x = -9, y = -13},{x = -10, y = -13},{x = -8, y = -14},{x = -7, y = -14},{x = 7, y = -14},{x = 9, y = -13},{x = 8, y = -14},{x = 10, y = -13},{x = -11, y = -12},{x = -11, y = -11},{x = -12, y = -11},{x = -10, y = -12},{x = 11, y = -11},{x = 11, y = -12},{x = 10, y = -12},{x = 12, y = -11},{x = -13, y = -10},{x = -13, y = -9},{x = -12, y = -10},{x = 13, y = -9},{x = 13, y = -10},{x = 12, y = -10},{x = -14, y = -7},{x = -14, y = -8},{x = 14, y = -7},{x = 14, y = -8},{x = -15, y = -6},{x = -15, y = -5},{x = 15, y = -5},{x = 15, y = -6},{x = -15, y = -4},{x = -16, y = -4},{x = -16, y = -3},{x = 15, y = -4},{x = 16, y = -3},{x = 16, y = -4},{x = -16, y = -2},{x = -16, y = -1},{x = 16, y = -1},{x = 16, y = -2},{x = -16, y = 0},{x = -16, y = 1},{x = 16, y = 1},{x = 16, y = 0},{x = -16, y = 2},{x = -16, y = 3},{x = 16, y = 3},{x = 16, y = 2},{x = -16, y = 4},{x = -15, y = 4},{x = -15, y = 5},{x = 15, y = 5},{x = 15, y = 4},{x = 16, y = 4},{x = -15, y = 6},{x = -14, y = 7},{x = 14, y = 7},{x = 15, y = 6},{x = -13, y = 9},{x = -14, y = 8},{x = 13, y = 9},{x = 14, y = 8},{x = -13, y = 10},{x = -12, y = 10},{x = -12, y = 11},{x = -11, y = 11},{x = 11, y = 11},{x = 12, y = 11},{x = 12, y = 10},{x = 13, y = 10},{x = -11, y = 12},{x = -10, y = 12},{x = -10, y = 13},{x = -9, y = 13},{x = 9, y = 13},{x = 10, y = 13},{x = 10, y = 12},{x = 11, y = 12},{x = -8, y = 14},{x = -7, y = 14},{x = -6, y = 15},{x = -5, y = 15},{x = -4, y = 15},{x = 4, y = 15},{x = 5, y = 15},{x = 7, y = 14},{x = 6, y = 15},{x = 8, y = 14},{x = -4, y = 16},{x = -3, y = 16},{x = -2, y = 16},{x = -1, y = 16},{x = 0, y = 16},{x = 1, y = 16},{x = 2, y = 16},{x = 3, y = 16},{x = 4, y = 16}},
[18] = {{x = -3, y = -17},{x = -4, y = -17},{x = -1, y = -17},{x = -2, y = -17},{x = 1, y = -17},{x = 0, y = -17},{x = 3, y = -17},{x = 2, y = -17},{x = 4, y = -17},{x = -9, y = -15},{x = -8, y = -15},{x = -7, y = -15},{x = -7, y = -16},{x = -6, y = -16},{x = -5, y = -16},{x = 5, y = -16},{x = 7, y = -15},{x = 7, y = -16},{x = 6, y = -16},{x = 9, y = -15},{x = 8, y = -15},{x = -11, y = -13},{x = -10, y = -14},{x = -9, y = -14},{x = 9, y = -14},{x = 11, y = -13},{x = 10, y = -14},{x = -13, y = -11},{x = -12, y = -12},{x = 13, y = -11},{x = 12, y = -12},{x = -15, y = -9},{x = -14, y = -10},{x = -14, y = -9},{x = 14, y = -10},{x = 14, y = -9},{x = 15, y = -9},{x = -15, y = -8},{x = -15, y = -7},{x = -16, y = -7},{x = 15, y = -8},{x = 15, y = -7},{x = 16, y = -7},{x = -16, y = -6},{x = -16, y = -5},{x = 16, y = -5},{x = 16, y = -6},{x = -17, y = -3},{x = -17, y = -4},{x = 17, y = -3},{x = 17, y = -4},{x = -17, y = -1},{x = -17, y = -2},{x = 17, y = -1},{x = 17, y = -2},{x = -17, y = 1},{x = -17, y = 0},{x = 17, y = 1},{x = 17, y = 0},{x = -17, y = 3},{x = -17, y = 2},{x = 17, y = 3},{x = 17, y = 2},{x = -17, y = 4},{x = -16, y = 5},{x = 16, y = 5},{x = 17, y = 4},{x = -15, y = 7},{x = -16, y = 7},{x = -16, y = 6},{x = 15, y = 7},{x = 16, y = 7},{x = 16, y = 6},{x = -15, y = 9},{x = -15, y = 8},{x = -14, y = 9},{x = 14, y = 9},{x = 15, y = 9},{x = 15, y = 8},{x = -14, y = 10},{x = -13, y = 11},{x = 13, y = 11},{x = 14, y = 10},{x = -12, y = 12},{x = -11, y = 13},{x = 11, y = 13},{x = 12, y = 12},{x = -10, y = 14},{x = -9, y = 14},{x = -9, y = 15},{x = -8, y = 15},{x = -7, y = 15},{x = 7, y = 15},{x = 9, y = 14},{x = 9, y = 15},{x = 8, y = 15},{x = 10, y = 14},{x = -7, y = 16},{x = -6, y = 16},{x = -5, y = 16},{x = -4, y = 17},{x = -3, y = 17},{x = -2, y = 17},{x = -1, y = 17},{x = 0, y = 17},{x = 1, y = 17},{x = 2, y = 17},{x = 3, y = 17},{x = 4, y = 17},{x = 5, y = 16},{x = 6, y = 16},{x = 7, y = 16}},
[19] = {{x = -7, y = -17},{x = -6, y = -17},{x = -5, y = -17},{x = -3, y = -18},{x = -4, y = -18},{x = -1, y = -18},{x = -2, y = -18},{x = 1, y = -18},{x = 0, y = -18},{x = 3, y = -18},{x = 2, y = -18},{x = 5, y = -17},{x = 4, y = -18},{x = 7, y = -17},{x = 6, y = -17},{x = -10, y = -15},{x = -9, y = -16},{x = -8, y = -16},{x = 9, y = -16},{x = 8, y = -16},{x = 10, y = -15},{x = -13, y = -13},{x = -11, y = -14},{x = -12, y = -14},{x = -12, y = -13},{x = 11, y = -14},{x = 13, y = -13},{x = 12, y = -13},{x = 12, y = -14},{x = -13, y = -12},{x = -14, y = -12},{x = -14, y = -11},{x = 13, y = -12},{x = 14, y = -11},{x = 14, y = -12},{x = -15, y = -10},{x = -16, y = -9},{x = 15, y = -10},{x = 16, y = -9},{x = -17, y = -7},{x = -16, y = -8},{x = 16, y = -8},{x = 17, y = -7},{x = -17, y = -5},{x = -17, y = -6},{x = 17, y = -6},{x = 17, y = -5},{x = -18, y = -3},{x = -18, y = -4},{x = 18, y = -4},{x = 18, y = -3},{x = -18, y = -1},{x = -18, y = -2},{x = 18, y = -2},{x = 18, y = -1},{x = -18, y = 1},{x = -18, y = 0},{x = 18, y = 0},{x = 18, y = 1},{x = -18, y = 3},{x = -18, y = 2},{x = 18, y = 2},{x = 18, y = 3},{x = -17, y = 5},{x = -18, y = 4},{x = 17, y = 5},{x = 18, y = 4},{x = -17, y = 7},{x = -17, y = 6},{x = 17, y = 7},{x = 17, y = 6},{x = -16, y = 9},{x = -16, y = 8},{x = 16, y = 9},{x = 16, y = 8},{x = -15, y = 10},{x = -14, y = 11},{x = 14, y = 11},{x = 15, y = 10},{x = -14, y = 12},{x = -13, y = 12},{x = -13, y = 13},{x = -12, y = 13},{x = 12, y = 13},{x = 13, y = 13},{x = 13, y = 12},{x = 14, y = 12},{x = -12, y = 14},{x = -11, y = 14},{x = -10, y = 15},{x = 10, y = 15},{x = 11, y = 14},{x = 12, y = 14},{x = -9, y = 16},{x = -7, y = 17},{x = -8, y = 16},{x = -5, y = 17},{x = -6, y = 17},{x = 5, y = 17},{x = 7, y = 17},{x = 6, y = 17},{x = 8, y = 16},{x = 9, y = 16},{x = -3, y = 18},{x = -4, y = 18},{x = -1, y = 18},{x = -2, y = 18},{x = 1, y = 18},{x = 0, y = 18},{x = 3, y = 18},{x = 2, y = 18},{x = 4, y = 18}},
[20] = {{x = -3, y = -19},{x = -4, y = -19},{x = -1, y = -19},{x = -2, y = -19},{x = 1, y = -19},{x = 0, y = -19},{x = 3, y = -19},{x = 2, y = -19},{x = 4, y = -19},{x = -9, y = -17},{x = -7, y = -18},{x = -8, y = -17},{x = -5, y = -18},{x = -6, y = -18},{x = 5, y = -18},{x = 7, y = -18},{x = 6, y = -18},{x = 9, y = -17},{x = 8, y = -17},{x = -11, y = -16},{x = -11, y = -15},{x = -12, y = -15},{x = -10, y = -16},{x = 11, y = -15},{x = 11, y = -16},{x = 10, y = -16},{x = 12, y = -15},{x = -13, y = -14},{x = -14, y = -13},{x = 13, y = -14},{x = 14, y = -13},{x = -15, y = -12},{x = -15, y = -11},{x = -16, y = -11},{x = 15, y = -11},{x = 15, y = -12},{x = 16, y = -11},{x = -17, y = -9},{x = -16, y = -10},{x = 16, y = -10},{x = 17, y = -9},{x = -17, y = -8},{x = -18, y = -7},{x = 17, y = -8},{x = 18, y = -7},{x = -18, y = -6},{x = -18, y = -5},{x = 18, y = -5},{x = 18, y = -6},{x = -19, y = -4},{x = -19, y = -3},{x = 19, y = -3},{x = 19, y = -4},{x = -19, y = -2},{x = -19, y = -1},{x = 19, y = -1},{x = 19, y = -2},{x = -19, y = 0},{x = -19, y = 1},{x = 19, y = 1},{x = 19, y = 0},{x = -19, y = 2},{x = -19, y = 3},{x = 19, y = 3},{x = 19, y = 2},{x = -19, y = 4},{x = -18, y = 5},{x = 18, y = 5},{x = 19, y = 4},{x = -18, y = 7},{x = -18, y = 6},{x = 18, y = 7},{x = 18, y = 6},{x = -17, y = 9},{x = -17, y = 8},{x = 17, y = 9},{x = 17, y = 8},{x = -16, y = 10},{x = -16, y = 11},{x = -15, y = 11},{x = 15, y = 11},{x = 16, y = 11},{x = 16, y = 10},{x = -15, y = 12},{x = -14, y = 13},{x = 14, y = 13},{x = 15, y = 12},{x = -13, y = 14},{x = -12, y = 15},{x = -11, y = 15},{x = 11, y = 15},{x = 12, y = 15},{x = 13, y = 14},{x = -11, y = 16},{x = -10, y = 16},{x = -9, y = 17},{x = -8, y = 17},{x = 9, y = 17},{x = 8, y = 17},{x = 10, y = 16},{x = 11, y = 16},{x = -7, y = 18},{x = -5, y = 18},{x = -6, y = 18},{x = -4, y = 19},{x = -3, y = 19},{x = -2, y = 19},{x = -1, y = 19},{x = 0, y = 19},{x = 1, y = 19},{x = 2, y = 19},{x = 3, y = 19},{x = 4, y = 19},{x = 5, y = 18},{x = 7, y = 18},{x = 6, y = 18}},
[21] = {{x = -7, y = -19},{x = -5, y = -19},{x = -6, y = -19},{x = -3, y = -20},{x = -4, y = -20},{x = -1, y = -20},{x = -2, y = -20},{x = 1, y = -20},{x = 0, y = -20},{x = 3, y = -20},{x = 2, y = -20},{x = 5, y = -19},{x = 4, y = -20},{x = 7, y = -19},{x = 6, y = -19},{x = -11, y = -17},{x = -10, y = -17},{x = -9, y = -18},{x = -8, y = -18},{x = 9, y = -18},{x = 8, y = -18},{x = 10, y = -17},{x = 11, y = -17},{x = -13, y = -15},{x = -14, y = -15},{x = -12, y = -16},{x = 13, y = -15},{x = 12, y = -16},{x = 14, y = -15},{x = -15, y = -14},{x = -15, y = -13},{x = -14, y = -14},{x = 15, y = -13},{x = 15, y = -14},{x = 14, y = -14},{x = -17, y = -11},{x = -16, y = -12},{x = 16, y = -12},{x = 17, y = -11},{x = -17, y = -10},{x = -18, y = -9},{x = 17, y = -10},{x = 18, y = -9},{x = -19, y = -7},{x = -18, y = -8},{x = 18, y = -8},{x = 19, y = -7},{x = -19, y = -6},{x = -19, y = -5},{x = 19, y = -6},{x = 19, y = -5},{x = -20, y = -4},{x = -20, y = -3},{x = 20, y = -3},{x = 20, y = -4},{x = -20, y = -2},{x = -20, y = -1},{x = 20, y = -1},{x = 20, y = -2},{x = -20, y = 0},{x = -20, y = 1},{x = 20, y = 1},{x = 20, y = 0},{x = -20, y = 2},{x = -20, y = 3},{x = 20, y = 3},{x = 20, y = 2},{x = -20, y = 4},{x = -19, y = 5},{x = 19, y = 5},{x = 20, y = 4},{x = -19, y = 7},{x = -19, y = 6},{x = 19, y = 7},{x = 19, y = 6},{x = -18, y = 9},{x = -18, y = 8},{x = 18, y = 9},{x = 18, y = 8},{x = -17, y = 11},{x = -17, y = 10},{x = 17, y = 11},{x = 17, y = 10},{x = -16, y = 12},{x = -15, y = 13},{x = 15, y = 13},{x = 16, y = 12},{x = -15, y = 14},{x = -14, y = 14},{x = -14, y = 15},{x = -13, y = 15},{x = 13, y = 15},{x = 14, y = 15},{x = 14, y = 14},{x = 15, y = 14},{x = -12, y = 16},{x = -11, y = 17},{x = -10, y = 17},{x = 11, y = 17},{x = 10, y = 17},{x = 12, y = 16},{x = -9, y = 18},{x = -8, y = 18},{x = -7, y = 19},{x = -5, y = 19},{x = -6, y = 19},{x = 5, y = 19},{x = 6, y = 19},{x = 7, y = 19},{x = 9, y = 18},{x = 8, y = 18},{x = -4, y = 20},{x = -3, y = 20},{x = -2, y = 20},{x = -1, y = 20},{x = 0, y = 20},{x = 1, y = 20},{x = 2, y = 20},{x = 3, y = 20},{x = 4, y = 20}},
[22] = {{x = -3, y = -21},{x = -4, y = -21},{x = -1, y = -21},{x = -2, y = -21},{x = 1, y = -21},{x = 0, y = -21},{x = 3, y = -21},{x = 2, y = -21},{x = 4, y = -21},{x = -10, y = -19},{x = -9, y = -19},{x = -8, y = -19},{x = -7, y = -20},{x = -5, y = -20},{x = -6, y = -20},{x = 5, y = -20},{x = 7, y = -20},{x = 6, y = -20},{x = 9, y = -19},{x = 8, y = -19},{x = 10, y = -19},{x = -13, y = -17},{x = -12, y = -17},{x = -11, y = -18},{x = -10, y = -18},{x = 11, y = -18},{x = 10, y = -18},{x = 13, y = -17},{x = 12, y = -17},{x = -15, y = -15},{x = -13, y = -16},{x = -14, y = -16},{x = 13, y = -16},{x = 15, y = -15},{x = 14, y = -16},{x = -17, y = -13},{x = -16, y = -14},{x = -16, y = -13},{x = 17, y = -13},{x = 16, y = -13},{x = 16, y = -14},{x = -17, y = -12},{x = -18, y = -11},{x = 17, y = -12},{x = 18, y = -11},{x = -19, y = -10},{x = -19, y = -9},{x = -18, y = -10},{x = 18, y = -10},{x = 19, y = -10},{x = 19, y = -9},{x = -19, y = -8},{x = -20, y = -7},{x = 19, y = -8},{x = 20, y = -7},{x = -20, y = -6},{x = -20, y = -5},{x = 20, y = -6},{x = 20, y = -5},{x = -21, y = -4},{x = -21, y = -3},{x = 21, y = -3},{x = 21, y = -4},{x = -21, y = -2},{x = -21, y = -1},{x = 21, y = -1},{x = 21, y = -2},{x = -21, y = 0},{x = -21, y = 1},{x = 21, y = 1},{x = 21, y = 0},{x = -21, y = 2},{x = -21, y = 3},{x = 21, y = 3},{x = 21, y = 2},{x = -21, y = 4},{x = -20, y = 5},{x = 20, y = 5},{x = 21, y = 4},{x = -20, y = 7},{x = -20, y = 6},{x = 20, y = 7},{x = 20, y = 6},{x = -19, y = 9},{x = -19, y = 8},{x = 19, y = 9},{x = 19, y = 8},{x = -19, y = 10},{x = -18, y = 11},{x = -18, y = 10},{x = 18, y = 11},{x = 18, y = 10},{x = 19, y = 10},{x = -17, y = 13},{x = -17, y = 12},{x = -16, y = 13},{x = 16, y = 13},{x = 17, y = 13},{x = 17, y = 12},{x = -16, y = 14},{x = -15, y = 15},{x = 15, y = 15},{x = 16, y = 14},{x = -14, y = 16},{x = -13, y = 16},{x = -13, y = 17},{x = -12, y = 17},{x = 13, y = 16},{x = 13, y = 17},{x = 12, y = 17},{x = 14, y = 16},{x = -11, y = 18},{x = -10, y = 18},{x = -10, y = 19},{x = -9, y = 19},{x = -8, y = 19},{x = 9, y = 19},{x = 8, y = 19},{x = 11, y = 18},{x = 10, y = 18},{x = 10, y = 19},{x = -7, y = 20},{x = -6, y = 20},{x = -5, y = 20},{x = -3, y = 21},{x = -4, y = 21},{x = -1, y = 21},{x = -2, y = 21},{x = 1, y = 21},{x = 0, y = 21},{x = 3, y = 21},{x = 2, y = 21},{x = 4, y = 21},{x = 5, y = 20},{x = 7, y = 20},{x = 6, y = 20}},
[23] = {{x = -8, y = -21},{x = -7, y = -21},{x = -6, y = -21},{x = -5, y = -21},{x = -3, y = -22},{x = -4, y = -22},{x = -1, y = -22},{x = -2, y = -22},{x = 1, y = -22},{x = 0, y = -22},{x = 3, y = -22},{x = 2, y = -22},{x = 5, y = -21},{x = 4, y = -22},{x = 7, y = -21},{x = 6, y = -21},{x = 8, y = -21},{x = -12, y = -19},{x = -11, y = -19},{x = -10, y = -20},{x = -9, y = -20},{x = -8, y = -20},{x = 9, y = -20},{x = 8, y = -20},{x = 11, y = -19},{x = 10, y = -20},{x = 12, y = -19},{x = -14, y = -17},{x = -13, y = -18},{x = -12, y = -18},{x = 13, y = -18},{x = 12, y = -18},{x = 14, y = -17},{x = -15, y = -16},{x = -16, y = -15},{x = 15, y = -16},{x = 16, y = -15},{x = -17, y = -14},{x = -18, y = -13},{x = 17, y = -14},{x = 18, y = -13},{x = -19, y = -12},{x = -19, y = -11},{x = -18, y = -12},{x = 18, y = -12},{x = 19, y = -12},{x = 19, y = -11},{x = -20, y = -10},{x = -20, y = -9},{x = 20, y = -10},{x = 20, y = -9},{x = -21, y = -8},{x = -21, y = -7},{x = -20, y = -8},{x = 20, y = -8},{x = 21, y = -8},{x = 21, y = -7},{x = -21, y = -6},{x = -21, y = -5},{x = 21, y = -6},{x = 21, y = -5},{x = -22, y = -4},{x = -22, y = -3},{x = 22, y = -3},{x = 22, y = -4},{x = -22, y = -2},{x = -22, y = -1},{x = 22, y = -1},{x = 22, y = -2},{x = -22, y = 0},{x = -22, y = 1},{x = 22, y = 1},{x = 22, y = 0},{x = -22, y = 2},{x = -22, y = 3},{x = 22, y = 3},{x = 22, y = 2},{x = -22, y = 4},{x = -21, y = 5},{x = 21, y = 5},{x = 22, y = 4},{x = -21, y = 7},{x = -21, y = 6},{x = 21, y = 7},{x = 21, y = 6},{x = -21, y = 8},{x = -20, y = 9},{x = -20, y = 8},{x = 20, y = 8},{x = 20, y = 9},{x = 21, y = 8},{x = -19, y = 11},{x = -20, y = 10},{x = 19, y = 11},{x = 20, y = 10},{x = -19, y = 12},{x = -18, y = 13},{x = -18, y = 12},{x = 18, y = 13},{x = 18, y = 12},{x = 19, y = 12},{x = -17, y = 14},{x = -16, y = 15},{x = 16, y = 15},{x = 17, y = 14},{x = -15, y = 16},{x = -14, y = 17},{x = 14, y = 17},{x = 15, y = 16},{x = -13, y = 18},{x = -12, y = 18},{x = -12, y = 19},{x = -11, y = 19},{x = 11, y = 19},{x = 13, y = 18},{x = 12, y = 18},{x = 12, y = 19},{x = -10, y = 20},{x = -9, y = 20},{x = -8, y = 20},{x = -8, y = 21},{x = -7, y = 21},{x = -6, y = 21},{x = -5, y = 21},{x = 5, y = 21},{x = 7, y = 21},{x = 6, y = 21},{x = 8, y = 20},{x = 9, y = 20},{x = 8, y = 21},{x = 10, y = 20},{x = -4, y = 22},{x = -3, y = 22},{x = -2, y = 22},{x = -1, y = 22},{x = 0, y = 22},{x = 1, y = 22},{x = 2, y = 22},{x = 3, y = 22},{x = 4, y = 22}}
}
local function process_explosion_tile(pos, explosion_index, current_radius)
local surface = game.surfaces[global.explosion_schedule[explosion_index].surface]
local target_entities = surface.find_entities_filtered({area={{pos.x - 0.5, pos.y - 0.5},{pos.x + 0.499, pos.y + 0.499}}})
local explosion_animation = "explosion"
local tile = surface.get_tile(pos)
if tile.name == "out-of-map" then
if global.explosion_schedule[explosion_index].damage_remaining >= out_of_map_tile_health then
explosion_animation = "big-explosion"
surface.set_tiles({{name = "dirt-5", position = pos}}, true)
end
global.explosion_schedule[explosion_index].damage_remaining = global.explosion_schedule[explosion_index].damage_remaining - out_of_map_tile_health
else
local decay_explosion = true
for _, entity in pairs(target_entities) do
if entity.health then
decay_explosion = false
end
end
if decay_explosion then global.explosion_schedule[explosion_index].damage_remaining = global.explosion_schedule[explosion_index].damage_remaining - empty_tile_damage_decay end
end
for _, entity in pairs(target_entities) do
if entity.health then
if entity.health < global.explosion_schedule[explosion_index].damage_remaining then
explosion_animation = "big-explosion"
if entity.health > 500 then explosion_animation = "big-artillery-explosion" end
global.explosion_schedule[explosion_index].damage_remaining = global.explosion_schedule[explosion_index].damage_remaining - entity.health
entity.damage(999999, "player", "explosion")
else
entity.damage(global.explosion_schedule[explosion_index].damage_remaining, "player", "explosion")
global.explosion_schedule[explosion_index].damage_remaining = global.explosion_schedule[explosion_index].damage_remaining - entity.health
end
end
end
if global.explosion_schedule[explosion_index].damage_remaining > 5000 and current_radius < 2 then
if math.random(1,2) == 1 then
explosion_animation = "big-explosion"
else
explosion_animation = "big-artillery-explosion"
end
end
surface.create_entity({name = explosion_animation, position = pos})
if global.explosion_schedule[explosion_index].damage_remaining <= 0 then return false end
return true
end
local function create_explosion_schedule(entity)
local inventory = defines.inventory.chest
if entity.type == "car" then inventory = defines.inventory.car_trunk end
local i = entity.get_inventory(inventory)
local explosives_amount = i.get_item_count("explosives")
if explosives_amount < 1 then return end
local center_position = entity.position
if not global.explosion_schedule then global.explosion_schedule = {} end
global.explosion_schedule[#global.explosion_schedule + 1] = {}
global.explosion_schedule[#global.explosion_schedule].surface = entity.surface.name
global.explosion_schedule[#global.explosion_schedule].damage_remaining = damage_per_explosive * explosives_amount
for current_radius = 1, 23, 1 do
global.explosion_schedule[#global.explosion_schedule][current_radius] = {}
global.explosion_schedule[#global.explosion_schedule][current_radius].trigger_tick = game.tick + (current_radius * 8)
local circle_coords = circle_coordinates[current_radius]
for index, tile_position in pairs(circle_coords) do
local pos = {x = center_position.x + tile_position.x, y = center_position.y + tile_position.y}
global.explosion_schedule[#global.explosion_schedule][current_radius][index] = {x = pos.x, y = pos.y}
end
end
entity.die("player")
end
local function on_entity_damaged(event)
local entity = event.entity
if entity.type == "container" or entity.type == "logistic-container" then
if math.random(1,3) == 1 or entity.health <= 0 then create_explosion_schedule(event.entity) return end
end
if entity.type == "cargo-wagon" or entity.type == "car" then
if entity.health <= 0 then create_explosion_schedule(entity) return end
if entity.health < 150 and math.random(1,3) == 1 then create_explosion_schedule(entity) return end
end
end
local function on_tick(event)
if global.explosion_schedule then
local tick = game.tick
local explosion_schedule_is_alive = false
for explosion_index = 1, #global.explosion_schedule, 1 do
if #global.explosion_schedule[explosion_index] > 0 then
explosion_schedule_is_alive = true
local surface = game.surfaces[global.explosion_schedule[explosion_index].surface]
for radius = 1, #global.explosion_schedule[explosion_index], 1 do
if global.explosion_schedule[explosion_index][radius].trigger_tick == tick then
for tile_index = 1, #global.explosion_schedule[explosion_index][radius], 1 do
local continue_explosion = process_explosion_tile(global.explosion_schedule[explosion_index][radius][tile_index], explosion_index, radius)
if not continue_explosion then
global.explosion_schedule[explosion_index] = {}
break
end
end
if radius == #global.explosion_schedule[explosion_index] then global.explosion_schedule[explosion_index] = {} end
break
end
end
end
end
if not explosion_schedule_is_alive then global.explosion_schedule = nil end
end
end
event.add(defines.events.on_entity_damaged, on_entity_damaged)
event.add(defines.events.on_tick, on_tick)

View File

@ -0,0 +1,36 @@
local items = {}
items.spawn = {
{price = {{"raw-fish", 5}}, offer = {type = 'give-item', item = 'rail', count = 4}},
{price = {{"raw-fish", 150}}, offer = {type = 'give-item', item = 'infinity-chest', count = 1}},
{price = {{"raw-fish", 5}}, offer = {type = 'give-item', item = 'rail-signal', count = 2}},
{price = {{"raw-fish", 5}}, offer = {type = 'give-item', item = 'rail-chain-signal', count = 2}},
{price = {{"raw-fish", 10}}, offer = {type = 'give-item', item = 'train-stop'}},
{price = {{"raw-fish", 94}}, offer = {type = 'give-item', item = 'locomotive'}},
{price = {{"raw-fish", 35}}, offer = {type = 'give-item', item = 'cargo-wagon'}},
{price = {{"raw-fish", 1}}, offer = {type = 'give-item', item = 'red-wire', count = 1}},
{price = {{"raw-fish", 1}}, offer = {type = 'give-item', item = 'green-wire', count = 1}},
{price = {{"raw-fish", 4}}, offer = {type = 'give-item', item = 'decider-combinator'}},
{price = {{"raw-fish", 4}}, offer = {type = 'give-item', item = 'arithmetic-combinator'}},
{price = {{"raw-fish", 2}}, offer = {type = 'give-item', item = 'constant-combinator'}},
{price = {{"raw-fish", 4}}, offer = {type = 'give-item', item = 'programmable-speaker'}},
{price = {{"raw-fish", 2}}, offer = {type = 'give-item', item = 'small-lamp'}},
{price = {{"raw-fish", 2}}, offer = {type = 'give-item', item = 'firearm-magazine'}},
{price = {{"raw-fish", 4}}, offer = {type = 'give-item', item = 'piercing-rounds-magazine'}},
{price = {{"raw-fish", 3}}, offer = {type = 'give-item', item = 'grenade'}},
{price = {{"raw-fish", 2}}, offer = {type = 'give-item', item = 'land-mine'}},
{price = {{"raw-fish", 1}}, offer = {type = 'give-item', item = 'explosives', count = 2}},
{price = {{"raw-fish", 40}}, offer = {type = 'give-item', item = 'cliff-explosives'}},
{price = {{"raw-fish", 5}}, offer = {type = 'give-item', item = 'wood', count = 25}},
{price = {{"raw-fish", 5}}, offer = {type = 'give-item', item = 'iron-ore', count = 25}},
{price = {{"raw-fish", 5}}, offer = {type = 'give-item', item = 'copper-ore', count = 25}},
{price = {{"raw-fish", 5}}, offer = {type = 'give-item', item = 'stone', count = 25}},
{price = {{"raw-fish", 5}}, offer = {type = 'give-item', item = 'coal', count = 25}},
{price = {{"raw-fish", 5}}, offer = {type = 'give-item', item = 'uranium-ore', count = 20}},
{price = {{'wood', 25}}, offer = {type = 'give-item', item = "raw-fish", count = 2}},
{price = {{'iron-ore', 25}}, offer = {type = 'give-item', item = "raw-fish", count = 2}},
{price = {{'copper-ore', 25}}, offer = {type = 'give-item', item = "raw-fish", count = 2}},
{price = {{'stone', 25}}, offer = {type = 'give-item', item = "raw-fish", count = 2}},
{price = {{'coal', 25}}, offer = {type = 'give-item', item = "raw-fish", count = 2}},
{price = {{'uranium-ore', 20}}, offer = {type = 'give-item', item = "raw-fish", count = 2}}
}
return items

563
maps/cave_choppy/choppy.lua Normal file
View File

@ -0,0 +1,563 @@
--choppy-- mewmew made this --
-- modified by gerkiz
require "on_tick_schedule"
require "modules.dynamic_landfill"
require "modules.satellite_score"
require "modules.spawners_contain_biters"
--require "maps.choppy_map_intro"
local unearthing_worm = require "functions.unearthing_worm"
local unearthing_biters = require "functions.unearthing_biters"
local tick_tack_trap = require "functions.tick_tack_trap"
local create_entity_chain = require "functions.create_entity_chain"
local create_tile_chain = require "functions.create_tile_chain"
local Module = require "modules.infinity_chest"
local simplex_noise = require 'utils.simplex_noise'.d2
local event = require 'utils.event'
local table_insert = table.insert
local math_random = math.random
local map_functions = require "tools.map_functions"
local disabled_for_deconstruction = {
["fish"] = true,
["rock-huge"] = true,
["rock-big"] = true,
["sand-rock-big"] = true,
["mineable-wreckage"] = true
}
local tile_replacements = {
["dirt-1"] = "grass-1",
["dirt-2"] = "grass-2",
["dirt-3"] = "grass-3",
["dirt-4"] = "grass-4",
["dirt-5"] = "grass-1",
["sand-1"] = "grass-1",
["sand-2"] = "grass-2",
["sand-3"] = "grass-3",
["dry-dirt"] = "grass-2",
["red-desert-0"] = "grass-1",
["red-desert-1"] = "grass-2",
["red-desert-2"] = "grass-3",
["red-desert-3"] = "grass-4",
}
local rocks = {"rock-big", "rock-big", "rock-huge"}
local decos = {"green-hairy-grass", "green-hairy-grass", "green-hairy-grass", "green-hairy-grass", "green-hairy-grass", "green-hairy-grass", "green-carpet-grass", "green-carpet-grass","green-pita"}
local decos_inside_forest = {"brown-asterisk","brown-asterisk", "brown-carpet-grass","brown-hairy-grass"}
local noises = {
["forest_location"] = {{modifier = 0.006, weight = 1}, {modifier = 0.01, weight = 0.25}, {modifier = 0.05, weight = 0.15}, {modifier = 0.1, weight = 0.05}},
["forest_density"] = {{modifier = 0.01, weight = 1}, {modifier = 0.05, weight = 0.5}, {modifier = 0.1, weight = 0.025}}
}
local function get_noise(name, pos, seed)
local noise = 0
for _, n in pairs(noises[name]) do
noise = noise + simplex_noise(pos.x * n.modifier, pos.y * n.modifier, seed) * n.weight
seed = seed + 10000
end
return noise
end
local function shuffle(tbl)
local size = #tbl
for i = size, 1, -1 do
local rand = math_random(size)
tbl[i], tbl[rand] = tbl[rand], tbl[i]
end
return tbl
end
local entities_to_convert = {
["coal"] = true,
["copper-ore"] = true,
["iron-ore"] = true,
["uranium-ore"] = true,
["stone"] = true,
["angels-ore1"] = true,
["angels-ore2"] = true,
["angels-ore3"] = true,
["angels-ore4"] = true,
["angels-ore5"] = true,
["angels-ore6"] = true,
["thorium-ore"] = true
}
local trees_to_remove = {
["dead-dry-hairy-tree"] = true,
["dead-grey-trunk"] = true,
["dead-tree-desert"] = true,
["dry-hairy-tree"] = true,
["dry-tree"] = true,
["tree-01"] = true,
["tree-02"] = true,
["tree-02-red"] = true,
["tree-03"] = true,
["tree-04"] = true,
["tree-05"] = true,
["tree-06"] = true,
["tree-06-brown"] = true,
["tree-07"] = true,
["tree-08"] = true,
["tree-08-brown"] = true,
["tree-08-red"] = true,
["tree-09"] = true,
["tree-09-brown"] = true,
["tree-09-red"] = true
}
local info = [[
You are a lumberjack with a passion to chop.
Different kinds of trees, yield different kinds of ore and wood.
Yes, they seem to draw minerals out of the ground and manifesting it as "fruit".
Their yield increases with distance. Mining Productivity Research will increase chopping speed and backpack size.
Beware, sometimes there are some bugs hiding underneath the trees.
Even dangerous traps have been encountered before.
These mysterious ore trees don't burn very well, so do not worry if some of them catch on fire.
Also, there seems to be an elevator that goes down to the mine. Who knows what one can find down there...
Choppy Choppy Wood
]]
local choppy_messages = {
"We should branch out.",
"Wood? Well that's the root of the problem.",
"Going out for chopping? Son of a birch.",
"Why do trees hate tests? Because they get stumped by the questions.",
"What happens to the most lovely trees every Valentine’s Day? They get all sappy.",
"Ever wondered how trees get online? They just log in."
}
local function create_map_intro_button(player)
if player.gui.top["map_intro_button"] then return end
local b = player.gui.top.add({type = "sprite-button", caption = "?", name = "map_intro_button", tooltip = "Map Info"})
b.style.font_color = {r = 0.1, g = 0.8, b = 0.1}
b.style.font = "heading-1"
b.style.minimal_height = 38
b.style.minimal_width = 38
b.style.top_padding = 2
b.style.left_padding = 4
b.style.right_padding = 4
b.style.bottom_padding = 2
end
local function create_choppy_stats_gui(player)
if player.gui.top["choppy_stats_frame"] then player.gui.top["choppy_stats_frame"].destroy() end
local captions = {}
local caption_style = {{"font", "default-bold"}, {"font_color",{ r=0.63, g=0.63, b=0.63}}, {"top_padding",2}, {"left_padding",0},{"right_padding",0},{"minimal_width",0}}
local stat_numbers = {}
local stat_number_style = {{"font", "default-bold"}, {"font_color",{ r=0.77, g=0.77, b=0.77}}, {"top_padding",2}, {"left_padding",0},{"right_padding",0},{"minimal_width",0}}
local separators = {}
local separator_style = {{"font", "default-bold"}, {"font_color",{ r=0.15, g=0.15, b=0.89}}, {"top_padding",2}, {"left_padding",2},{"right_padding",2},{"minimal_width",0}}
local frame = player.gui.top.add { type = "frame", name = "choppy_stats_frame" }
local t = frame.add { type = "table", column_count = 16 }
captions[1] = t.add { type = "label", caption = '[img=item/iron-ore] :' }
global.total_ores_mined = global.stats_ores_found + game.forces.player.item_production_statistics.get_input_count("coal") + game.forces.player.item_production_statistics.get_input_count("iron-ore") + game.forces.player.item_production_statistics.get_input_count("copper-ore") + game.forces.player.item_production_statistics.get_input_count("uranium-ore")
stat_numbers[1] = t.add { type = "label", caption = global.total_ores_mined }
separators[1] = t.add { type = "label", caption = "|"}
captions[2] = t.add { type = "label", caption = '[img=entity.tree-04] :' }
stat_numbers[2] = t.add { type = "label", caption = global.stats_wood_chopped }
separators[2] = t.add { type = "label", caption = "|"}
captions[3] = t.add { type = "label", caption = '[img=item.productivity-module] :' }
local x = math.floor(game.forces.player.manual_mining_speed_modifier * 100)
local str = ""
if x > 0 then str = str .. "+" end
str = str .. tostring(x)
str = str .. "%"
stat_numbers[3] = t.add { type = "label", caption = str }
if game.forces.player.manual_mining_speed_modifier > 0 or game.forces.player.mining_drill_productivity_bonus > 0 then
separators[3] = t.add { type = "label", caption = "|"}
captions[3] = t.add { type = "label", caption = '[img=utility.hand] :' }
local str = "+"
str = str .. tostring(game.forces.player.mining_drill_productivity_bonus * 100)
str = str .. "%"
stat_numbers[3] = t.add { type = "label", caption = str }
end
for _, s in pairs (caption_style) do
for _, l in pairs (captions) do
l.style[s[1]] = s[2]
end
end
for _, s in pairs (stat_number_style) do
for _, l in pairs (stat_numbers) do
l.style[s[1]] = s[2]
end
end
for _, s in pairs (separator_style) do
for _, l in pairs (separators) do
l.style[s[1]] = s[2]
end
end
stat_numbers[1].style.minimal_width = 9 * string.len(tostring(global.stats_ores_found))
stat_numbers[2].style.minimal_width = 9 * string.len(tostring(global.stats_rocks_broken))
end
local function create_map_intro(player)
if player.gui.left["map_intro_frame"] then player.gui.left["map_intro_frame"].destroy() end
local frame = player.gui.left.add {type = "frame", name = "map_intro_frame", direction = "vertical"}
local t = frame.add {type = "table", column_count = 1}
local b = frame.add {type = "button", caption = "Close", name = "close_map_intro_frame", align = "right"}
b.style.font = "default"
b.style.minimal_height = 30
b.style.minimal_width = 30
b.style.top_padding = 2
b.style.left_padding = 4
b.style.right_padding = 4
b.style.bottom_padding = 2
local frame = t.add {type = "frame"}
local l = frame.add {type = "label", caption = info}
l.style.single_line = false
l.style.font = "heading-3"
l.style.font_color = {r=0.95, g=0.95, b=0.95}
end
local function on_gui_click(event)
if not event then return end
if not event.element then return end
if not event.element.valid then return end
local player = game.players[event.element.player_index]
local name = event.element.name
local frame = player.gui.top["choppy_stats_frame"]
if name == "map_intro_button" and frame == nil then create_choppy_stats_gui(player) end
if name == "map_intro_button" and frame then
if player.gui.left["map_intro_frame"] then
frame.destroy()
player.gui.left["map_intro_frame"].destroy()
else
create_map_intro(player)
end
return
end
if name == "close_map_intro_frame" then player.gui.left["map_intro_frame"].destroy() end
end
local function refresh_gui()
for _, player in pairs(game.connected_players) do
local frame = player.gui.top["choppy_stats_frame"]
if (frame) then
create_choppy_stats_gui(player)
create_map_intro_button(player)
end
end
end
local function process_entity(e)
if not e.valid then return end
if trees_to_remove[e.name] then
e.destroy()
return
end
if entities_to_convert[e.name] then
if math_random(1,100) > 33 then e.surface.create_entity({name = rocks[math_random(1, #rocks)], position = e.position}) end
e.destroy()
return
end
end
local function process_tile(surface, pos, tile, seed)
if tile.collides_with("player-layer") then return end
if not surface.can_place_entity({name = "tree-01", position = pos}) then return end
if math_random(1, 100000) == 1 then
local wrecks = {"big-ship-wreck-1", "big-ship-wreck-2", "big-ship-wreck-3"}
local e = surface.create_entity{name = wrecks[math_random(1,#wrecks)], position = pos, force = "neutral"}
e.insert({name = "raw-fish", count = math_random(3, 25)})
if math_random(1, 3) == 1 then e.insert({name = "wood", count = math_random(11, 44)}) end
end
local noise_forest_location = get_noise("forest_location", pos, seed)
--local r = math.ceil(math.abs(get_noise("forest_density", pos, seed + 4096)) * 10)
--local r = 5 - math.ceil(math.abs(noise_forest_location) * 3)
--r = 2
if noise_forest_location > 0.095 then
if noise_forest_location > 0.6 then
if math_random(1,100) > 42 then surface.create_entity({name = "tree-08-brown", position = pos}) end
else
if math_random(1,100) > 42 then surface.create_entity({name = "tree-01", position = pos}) end
end
surface.create_decoratives({check_collision=false, decoratives={{name = decos_inside_forest[math_random(1, #decos_inside_forest)], position = pos, amount = math_random(1, 2)}}})
return
end
if noise_forest_location < -0.095 then
if noise_forest_location < -0.6 then
if math_random(1,100) > 42 then surface.create_entity({name = "tree-04", position = pos}) end
else
if math_random(1,100) > 42 then surface.create_entity({name = "tree-02-red", position = pos}) end
end
surface.create_decoratives({check_collision=false, decoratives={{name = decos_inside_forest[math_random(1, #decos_inside_forest)], position = pos, amount = math_random(1, 2)}}})
return
end
surface.create_decoratives({check_collision=false, decoratives={{name = decos[math_random(1, #decos)], position = pos, amount = math_random(1, 2)}}})
end
local function on_chunk_generated(event)
local surface = event.surface
if surface.name ~= "choppy" then return end
local left_top = event.area.left_top
local tiles = {}
local entities = {}
local seed = game.surfaces[1].map_gen_settings.seed
--surface.destroy_decoratives({area = event.area})
for _, e in pairs(surface.find_entities_filtered({area = event.area})) do
process_entity(e)
end
for x = 0.5, 31.5, 1 do
for y = 0.5, 31.5, 1 do
local tile_to_insert = false
local pos = {x = left_top.x + x, y = left_top.y + y}
local tile = surface.get_tile(pos)
if tile_replacements[tile.name] then
table_insert(tiles, {name = tile_replacements[tile.name], position = pos})
end
process_tile(surface, pos, tile, seed)
end
end
surface.set_tiles(tiles, true)
for _, e in pairs(surface.find_entities_filtered({area = event.area, type = "unit-spawner"})) do
for _, entity in pairs (e.surface.find_entities_filtered({area = {{e.position.x - 7, e.position.y - 7},{e.position.x + 7, e.position.y + 7}}, force = "neutral"})) do
if entity.valid then entity.destroy() end
end
end
if global.spawn_generated then return end
if left_top.x < 96 then return end
for _, e in pairs (surface.find_entities_filtered({area = {{-50, -50},{50, 50}}})) do
local distance_to_center = math.sqrt(e.position.x^2 + e.position.y^2)
if e.valid then
if distance_to_center < 8 and e.type == "tree" and math_random(1,5) ~= 1 then e.destroy() end
end
end
global.spawn_generated = true
end
local function on_marked_for_deconstruction(event)
if disabled_for_deconstruction[event.entity.name] then
event.entity.cancel_deconstruction(game.players[event.player_index].force.name)
end
if event.entity.type == "tree" then
event.entity.cancel_deconstruction(game.players[event.player_index].force.name)
end
end
local function on_player_joined_game(event)
local player = game.players[event.player_index]
local surface = player.surface
if global.map_choppy_init_done then return end
--game.map_settings.pollution.min_pollution_to_damage_trees = 1000000
--game.map_settings.pollution.pollution_per_tree_damage = 0
--game.map_settings.pollution.pollution_restored_per_tree_damage = 0
game.surfaces["choppy"].ticks_per_day = game.surfaces["choppy"].ticks_per_day * 2
global.entity_yield = {
["tree-01"] = {"iron-ore"},
["tree-02-red"] = {"copper-ore"},
["tree-04"] = {"coal"},
["tree-08-brown"] = {"stone"},
["rock-big"] = {"uranium-ore"},
["rock-huge"] = {"uranium-ore"}
}
if game.item_prototypes["angels-ore1"] then
global.entity_yield["tree-01"] = {"angels-ore1", "angels-ore2"}
global.entity_yield["tree-02-red"] = {"angels-ore5", "angels-ore6"}
global.entity_yield["tree-04"] = {"coal"}
global.entity_yield["tree-08-brown"] = {"angels-ore3", "angels-ore4"}
else
game.map_settings.pollution.ageing = 0
end
if game.item_prototypes["thorium-ore"] then
global.entity_yield["rock-big"] = {"uranium-ore", "thorium-ore"}
global.entity_yield["rock-huge"] = {"uranium-ore", "thorium-ore"}
end
global.map_choppy_init_done = true
end
local function changed_surface(event)
local player = game.players[event.player_index]
local surface = player.surface
if surface.name ~= "choppy" then goto continue end
player.print("Warped to Choppy!", { r=0.10, g=0.75, b=0.5})
player.play_sound {path = 'utility/mining_wood', volume_modifier = 1}
if player.gui.top["caver_miner_stats_toggle_button"] then player.gui.top["caver_miner_stats_toggle_button"].destroy() end
if player.gui.left["cave_miner_info"] then player.gui.left["cave_miner_info"].destroy() end
if player.gui.top["hunger_frame"] then player.gui.top["hunger_frame"].destroy() end
if player.gui.top["caver_miner_stats_frame"] then player.gui.top["caver_miner_stats_frame"].destroy() end
--create_map_intro(player)
create_map_intro_button(player)
create_choppy_stats_gui(player)
player.print(choppy_messages[math_random(1,#choppy_messages)], { r=0.10, g=0.75, b=0.5})
::continue::
end
local function get_amount(entity)
local distance_to_center = math.sqrt(entity.position.x^2 + entity.position.y^2)
local amount = 25 + (distance_to_center * 0.1)
if amount > 1000 then amount = 1000 end
amount = math.random(math.ceil(amount * 0.5), math.ceil(amount * 1.5))
return amount
end
local function trap(entity)
if math_random(1,1024) == 1 then tick_tack_trap(entity.surface, entity.position) return end
if math_random(1,256) == 1 then unearthing_worm(entity.surface, entity.position) end
if math_random(1,128) == 1 then unearthing_biters(entity.surface, entity.position, math_random(4,8)) end
end
local function on_player_mined_entity(event)
local entity = event.entity
local surface = entity.surface
if surface ~= game.surfaces["choppy"] then return end
if not entity.valid then return end
if entity.type == "tree" then
trap(entity)
end
if global.entity_yield[entity.name] then
if event.buffer then event.buffer.clear() end
if not event.player_index then return end
local amount = get_amount(entity)
local second_item_amount = math_random(2,5)
local second_item = "wood"
if entity.type == "simple-entity" then
amount = amount * 2
second_item_amount = math_random(8,16)
second_item = "stone"
end
local main_item = global.entity_yield[entity.name][math_random(1,#global.entity_yield[entity.name])]
local amount_of_choppie = math.round(amount * 0.15,0)
entity.surface.create_entity({
name = "flying-text",
position = entity.position,
text = "+" .. amount .. " [item=" .. main_item .. "] +" .. second_item_amount .. " [item=" .. second_item .. "]",
color = {r=0.8,g=0.8,b=0.8}})
global.stats_ores_found = global.stats_ores_found + amount
global.stats_wood_chopped = global.stats_wood_chopped + 1
refresh_gui()
local player = game.players[event.player_index]
local inserted_count = player.insert({name = main_item, count = amount})
amount = amount - inserted_count
if amount > 0 then
entity.surface.spill_item_stack(entity.position,{name = main_item, count = amount}, true)
end
local inserted_count = player.insert({name = second_item, count = second_item_amount})
second_item_amount = second_item_amount - inserted_count
if second_item_amount > 0 then
entity.surface.spill_item_stack(entity.position,{name = second_item, count = second_item_amount}, true)
end
end
end
local function on_research_finished(event)
event.research.force.character_inventory_slots_bonus = game.forces.player.mining_drill_productivity_bonus * 500
if not event.research.force.technologies["steel-axe"].researched then return end
event.research.force.manual_mining_speed_modifier = 1 + game.forces.player.mining_drill_productivity_bonus * 2
refresh_gui()
end
local function on_entity_died(event)
if event.entity.surface.name ~= "choppy" then return end
on_player_mined_entity(event)
if not event.entity.valid then return end
if event.entity.type == "tree" then
for _, entity in pairs (event.entity.surface.find_entities_filtered({area = {{event.entity.position.x - 4, event.entity.position.y - 4},{event.entity.position.x + 4, event.entity.position.y + 4}}, name = "fire-flame-on-tree"})) do
if entity.valid then entity.destroy() end
end
end
end
local function init_surface(surface)
surface.map_gen_settings = {}
return surface
end
local function init()
local storage = {}
local newPlace = init_surface(game.create_surface("choppy"))
local surface = game.surfaces["choppy"]
newPlace.request_to_generate_chunks({0,0}, 4)
global.surface_choppy_elevator = surface.create_entity({name = "player-port", position = {1, -4}, force = game.forces.neutral})
global.surface_choppy_chest = Module.create_chest(surface, {1, -8}, storage)
rendering.draw_text{
text = "Storage",
surface = surface,
target = global.surface_choppy_chest,
target_offset = {0, 0.4},
color = { r=0.98, g=0.66, b=0.22},
alignment = "center"
}
rendering.draw_text{
text = "Elevator",
surface = surface,
target = global.surface_choppy_elevator,
target_offset = {0, 1},
color = { r=0.98, g=0.66, b=0.22},
alignment = "center"
}
global.surface_choppy_chest.minable = false
global.surface_choppy_chest.destructible = false
global.surface_choppy_elevator.minable = false
global.surface_choppy_elevator.destructible = false
end
event.on_init(init)
event.add(defines.events.on_player_changed_surface, changed_surface)
event.add(defines.events.on_research_finished, on_research_finished)
event.add(defines.events.on_marked_for_deconstruction, on_marked_for_deconstruction)
event.add(defines.events.on_player_joined_game, on_player_joined_game)
event.add(defines.events.on_player_mined_entity, on_player_mined_entity)
event.add(defines.events.on_entity_died, on_entity_died)
event.add(defines.events.on_gui_click, on_gui_click)
event.add(defines.events.on_chunk_generated, on_chunk_generated)

View File

@ -0,0 +1,146 @@
local Event = require "utils.event"
local Global = require "utils.global"
local function validate_player(player)
if not player then return false end
if not player.valid then return false end
if not player.character then return false end
if not player.connected then return false end
if not game.players[player.name] then return false end
return true
end
local cooldowns = {}
local chests = {}
local inventories = {}
Global.register({
chests = chests,
inventories = inventories
}, function(global)
chests = global.chests
inventories = global.inventories
end)
Global.register({
cooldowns = cooldowns
}, function(global)
cooldowns = global.cooldowns
end)
local function check_player_ports(event)
for _, player in pairs(game.connected_players) do
if not validate_player(player) then goto continue end
if not cooldowns[player.name] then
cooldowns[player.name] = game.tick
end
--if cooldowns[player.name] - game.tick > 0 then goto continue end
if player.surface.find_entity("player-port", player.position) then
if cooldowns[player.name] > game.tick then
player.play_sound{path="utility/armor_insert", volume_modifier=1}
if math.random(1,3) == 1 then
player.surface.create_entity({
name = "flying-text",
position = player.position,
text = math.ceil((cooldowns[tostring(player.name)] - game.tick)/60),
color = {r = math.random(130, 170), g = math.random(130, 170), b = 130}
})
end
goto continue end
local surface_name = player.surface.name == "cave_miner" and "choppy" or "cave_miner"
local pos = surface_name == "cave_miner" and global.surface_cave_elevator.position or {1, -4}
local safe_pos = game.surfaces[surface_name].find_non_colliding_position("character", pos, 20, 1)
if safe_pos then
player.teleport(safe_pos, surface_name)
else
player.teleport({0, -3}, surface_name)
end
cooldowns[player.name] = game.tick + 900
end
--[[
if cooldowns[player.name] > game.tick then
local text = rendering.draw_text{
text = "Cooldown:" .. math.ceil((cooldowns[player.name] - game.tick)/60) .. " seconds",
surface = "choppy",
target = global.surface_choppy_elevator,
target_offset = {0, 5},
color = { r=0.98, g=0.66, b=0.22},
alignment = "center"
}
else
rendering.destroy(text)
end
if math.random(1, 2) == 1 then
rendering.destroy(text)
]]--
::continue::
end
end
local function built_entity(event)
local entity = event.created_entity
if not entity or not entity.valid then return end
if entity.name ~= "player-port" then return end
entity.minable = false
entity.destructible = false
entity.operable = false
local surface = entity.surface
end
local function tick()
if not chests["cave_miner"] then
chests["cave_miner"] = global.surface_cave_chest
end
if not chests["choppy"] then
chests["choppy"] = global.surface_choppy_chest
end
local cave = chests["cave_miner"]
local tree = chests["choppy"]
if not cave or not tree then return end
if not cave.valid or not tree.valid then return end
local civ = tree.get_inventory(defines.inventory.chest)
local oiv = cave.get_inventory(defines.inventory.chest)
local ci = civ.get_contents()
local oi = oiv.get_contents()
for item, count in pairs(ci) do
local count2 = oi[item] or 0
local diff = count-count2
if diff > 1 then
local count2 = oiv.insert{name = item, count = math.floor(diff/2)}
if count2 > 0 then
civ.remove{name = item, count = count2}
end
elseif diff < -1 then
local count2 = civ.insert{name = item, count = math.floor(-diff/2)}
if count2 > 0 then
oiv.remove{name = item, count = count2}
end
end
end
for item, count in pairs(oi) do
if count > 1 and not ci[item] then
local count2 = civ.insert{name = item, count = math.floor(count/2)}
if count2 > 0 then
oiv.remove{name = item, count = count2}
end
end
end
end
Event.add(defines.events.on_tick, tick)
Event.on_nth_tick(60, check_player_ports)
Event.add(defines.events.on_built_entity, built_entity)

264
modules/infinity_chest.lua Normal file
View File

@ -0,0 +1,264 @@
local Module = {}
local Event = require 'utils.event'
local Token = require 'utils.token'
local Gui = require 'utils.gui'
local Task = require 'utils.task'
local Global = require 'utils.global'
local format = string.format
local chests = {}
local chests_next = {}
Global.register(
{chests = chests, chests_next = chests_next},
function(tbl)
chests = tbl.chests
chests_next = tbl.chests_next
end
)
local chest_gui_frame_name = Gui.uid_name()
local chest_content_table_name = Gui.uid_name()
function Module.create_chest(surface, position, storage)
local entity = surface.create_entity {name = 'infinity-chest', position = position, force = 'neutral'}
chests[entity.unit_number] = {entity = entity, storage = storage}
return entity
end
local function built_entity(event)
local entity = event.created_entity
if not entity or not entity.valid or entity.name ~= 'infinity-chest' then
return
end
entity.active = false
chests[entity.unit_number] = {entity = entity, storage = {}}
end
local function get_stack_size(name)
local proto = game.item_prototypes[name]
if not proto then
log('item prototype ' .. name .. ' not found')
return 1
end
return proto.stack_size
end
local function do_item(name, count, inv, storage)
local size = get_stack_size(name)
local diff = count - size
if diff == 0 then
return
end
local new_amount = 0
if diff > 0 then
inv.remove({name = name, count = diff})
local prev = storage[name] or 0
new_amount = prev + diff
elseif diff < 0 then
local prev = storage[name]
if not prev then
return
end
diff = math.min(prev, -diff)
local inserted = inv.insert({name = name, count = diff})
new_amount = prev - inserted
end
if new_amount == 0 then
storage[name] = nil
else
storage[name] = new_amount
end
end
local function tick()
local chest_id, chest_data = next(chests, chests_next[1])
chests_next[1] = chest_id
if not chest_id then
return
end
local entity = chest_data.entity
if not entity or not entity.valid then
chests[chest_id] = nil
else
local storage = chest_data.storage
local inv = entity.get_inventory(1) --defines.inventory.chest
local contents = inv.get_contents()
for name, count in pairs(contents) do
do_item(name, count, inv, storage)
end
for name, _ in pairs(storage) do
if not contents[name] then
do_item(name, 0, inv, storage)
end
end
end
end
local function create_chest_gui_content(frame, player, chest)
local storage = chest.storage
local inv = chest.entity.get_inventory(1).get_contents()
local grid = frame[chest_content_table_name]
if grid then
grid.clear()
else
grid = frame.add {type = 'table', name = chest_content_table_name, column_count = 10, style = 'slot_table'}
end
for name, count in pairs(storage) do
local number = count + (inv[name] or 0)
grid.add {
type = 'sprite-button',
sprite = 'item/' .. name,
number = number,
tooltip = name,
--style = 'slot_button'
enabled = false
}
end
for name, count in pairs(inv) do
if not storage[name] then
grid.add {
type = 'sprite-button',
sprite = 'item/' .. name,
number = count,
tooltip = name,
--style = 'slot_button'
enabled = false
}
end
end
player.opened = frame
end
local chest_gui_content_callback
chest_gui_content_callback =
Token.register(
function(data)
local player = data.player
if not player or not player.valid then
return
end
local opened = data.opened
if not opened or not opened.valid then
return
end
local entity = data.chest.entity
if not entity.valid then
player.opened = nil
opened.destroy()
return
end
if not player.connected then
player.opened = nil
opened.destroy()
return
end
create_chest_gui_content(opened, player, data.chest)
Task.set_timeout_in_ticks(60, chest_gui_content_callback, data)
end
)
local function gui_opened(event)
if not event.gui_type == defines.gui_type.entity then
return
end
local entity = event.entity
if not entity or not entity.valid or entity.name ~= 'infinity-chest' then
return
end
local chest = chests[entity.unit_number]
if not chest then
return
end
local player = game.get_player(event.player_index)
if not player or not player.valid then
return
end
local frame =
player.gui.center.add {
type = 'frame',
name = chest_gui_frame_name,
caption = 'Infinite Storage Chest',
direction = 'vertical'
}
local text =
frame.add {
type = 'label',
caption = format('This chest stores unlimited quantity of items (up to 48 different item types).\nThe chest is best used with an inserter to add / remove items.\nIf the chest is mined or destroyed the items are lost.')
}
text.style.single_line = false
local content_header = frame.add {type = 'label', caption = 'Content'}
content_header.style.font = 'default-listbox'
create_chest_gui_content(frame, player, chest)
Task.set_timeout_in_ticks(60, chest_gui_content_callback, {player = player, chest = chest, opened = frame})
end
Event.add(defines.events.on_built_entity, built_entity)
Event.add(defines.events.on_robot_built_entity, built_entity)
Event.add(defines.events.on_tick, tick)
Event.add(defines.events.on_gui_opened, gui_opened)
Event.add(
defines.events.on_player_died,
function(event)
local player = game.get_player(event.player_index or 0)
if not player or not player.valid then
return
end
local element = player.gui.center
if element and element.valid then
element = element[chest_gui_frame_name]
if element and element.valid then
element.destroy()
end
end
end
)
Gui.on_custom_close(
chest_gui_frame_name,
function(event)
event.element.destroy()
end
)
return Module