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

scrapyard becomes lumberjack!

This commit is contained in:
Gerkiz 2020-05-10 02:42:10 +02:00
parent 853fa01a00
commit 0ee4d245cd
21 changed files with 387 additions and 520 deletions

View File

@ -4,30 +4,30 @@ _DEBUG = false
_DUMP_ENV = false
require 'utils.server'
require "utils.server_commands"
require "utils.utils"
require "utils.table"
require "utils.color_data"
require "utils.session_data"
require "chatbot"
require "commands"
require "antigrief"
require "modules.corpse_markers"
require "modules.floaty_chat"
require "modules.autohotbar"
require 'utils.server_commands'
require 'utils.utils'
require 'utils.table'
require 'utils.color_data'
require 'utils.session_data'
require 'chatbot'
require 'commands'
require 'antigrief'
require 'modules.corpse_markers'
require 'modules.floaty_chat'
require 'modules.autohotbar'
require "comfy_panel.main"
require "comfy_panel.player_list"
require "comfy_panel.admin"
require "comfy_panel.group"
require "comfy_panel.poll"
require "comfy_panel.score"
require "comfy_panel.config"
require 'comfy_panel.main'
require 'comfy_panel.player_list'
require 'comfy_panel.admin'
require 'comfy_panel.group'
require 'comfy_panel.poll'
require 'comfy_panel.score'
require 'comfy_panel.config'
require "modules.autostash"
require 'modules.autostash'
---- enable modules here ----
--require "modules.admins_operate_biters"
--require 'modules.admins_operate_biters'
--require "modules.the_floor_is_lava"
--require "modules.biters_landfill_on_death"
--require "modules.autodecon_when_depleted"
@ -44,7 +44,7 @@ require "modules.autostash"
--require "modules.fluids_are_explosive"
--require "modules.hunger"
--require "modules.hunger_games"
--require "modules.pistol_buffs"
--require 'modules.pistol_buffs'
--require "modules.players_trample_paths"
--require "modules.railgun_enhancer"
--require "modules.restrictive_fluid_mining"
@ -69,15 +69,15 @@ require "modules.autostash"
--require "maps.chronosphere.main"
--require "maps.fish_defender.main"
--require "maps.biter_battles_v2.main"
--require "maps.mountain_fortress_v2.main"
--require 'maps.mountain_fortress_v2.main'
--require 'maps.lumberjack.main'
--require "maps.dungeons.main"
--require "maps.island_troopers.main"
--require "maps.biter_hatchery.main"
--require "maps.junkyard_pvp.main"
--require "maps.scrapyard.main"
--require "maps.cave_choppy.cave_miner"
--require "maps.wave_of_death.WoD"
--require "maps.planet_prison"
--require 'maps.planet_prison'
--require "maps.stone_maze.main"
--require "maps.choppy"
--require "maps.overgrowth"
@ -145,13 +145,13 @@ if _DEBUG then
end
local function on_player_created(event)
local player = game.players[event.player_index]
player.gui.top.style = 'slot_table_spacing_horizontal_flow'
player.gui.left.style = 'slot_table_spacing_vertical_flow'
local player = game.players[event.player_index]
player.gui.top.style = 'slot_table_spacing_horizontal_flow'
player.gui.left.style = 'slot_table_spacing_vertical_flow'
end
local function on_init()
game.forces.player.research_queue_enabled = true
game.forces.player.research_queue_enabled = true
end
local loaded = _G.package.loaded

View File

@ -21,7 +21,7 @@ function Public.init_enemy_weapon_damage()
['shotgun-shell'] = 0
}
local e, s, sd = game.forces.enemy, game.forces.scrap, game.forces.scrap_defense
local e, s, sd = game.forces.enemy, game.forces.defenders, game.forces.lumber_defense
for k, v in pairs(data) do
e.set_ammo_damage_modifier(k, v)
@ -34,7 +34,7 @@ local function enemy_weapon_damage()
if game.tick < 100 then
goto rtn
end
local e, s, sd = game.forces.enemy, game.forces.scrap, game.forces.scrap_defense
local e, s, sd = game.forces.enemy, game.forces.defenders, game.forces.lumber_defense
local data = {
['artillery-shell'] = 0.5,

View File

@ -1,4 +1,4 @@
local WPT = require 'maps.scrapyard.table'
local WPT = require 'maps.lumberjack.table'
local Event = require 'utils.event'
local math_random = math.random

View File

@ -1,5 +1,5 @@
local Color = require 'utils.color_presets'
local WPT = require 'maps.scrapyard.table'
local WPT = require 'maps.lumberjack.table'
commands.add_command(
'rainbow_mode',
@ -27,7 +27,7 @@ if _DEBUG then
'reset_game',
'Debug only, reset the game!',
function()
local reset_map = require 'maps.scrapyard.main'.reset_map
local reset_map = require 'maps.lumberjack.main'.reset_map
local player = game.player

View File

@ -4,14 +4,14 @@ local Map_score = require 'comfy_panel.map_score'
local BiterRolls = require 'modules.wave_defense.biter_rolls'
local unearthing_worm = require 'functions.unearthing_worm'
local unearthing_biters = require 'functions.unearthing_biters'
local Loot = require 'maps.scrapyard.loot'
local Loot = require 'maps.lumberjack.loot'
local Pets = require 'modules.biter_pets'
local tick_tack_trap = require 'functions.tick_tack_trap'
local RPG = require 'maps.scrapyard.rpg'
local Scrap = require 'maps.scrapyard.mining_scrap'
local RPG = require 'maps.lumberjack.rpg'
local Mining = require 'maps.lumberjack.mining'
-- tables
local WPT = require 'maps.scrapyard.table'
local WPT = require 'maps.lumberjack.table'
local WD = require 'modules.wave_defense.table'
-- module
@ -74,7 +74,7 @@ end
local function is_protected(entity)
local this = WPT.get_table()
if string.sub(entity.surface.name, 0, 9) ~= 'scrapyard' then
if string.sub(entity.surface.name, 0, 10) ~= 'lumberjack' then
return true
end
local protected = {this.locomotive, this.locomotive_cargo}
@ -95,8 +95,8 @@ local function protect_train(event)
if event.entity == this.locomotive_cargo or event.entity == this.locomotive then
if event.cause then
if
event.cause.force.index == 2 or event.cause.force.name == 'scrap_defense' or
event.cause.force.name == 'scrap'
event.cause.force.index == 2 or event.cause.force.name == 'lumber_defense' or
event.cause.force.name == 'defenders'
then
if this.locomotive_health <= 0 then
goto continue
@ -190,7 +190,7 @@ end
local function on_player_mined_entity(event)
local this = WPT.get_table()
Scrap.on_player_mined_entity(event)
Mining.on_player_mined_entity(event)
local entity = event.entity
local player = game.players[event.player_index]
@ -212,7 +212,7 @@ local function on_player_mined_entity(event)
end
end
if entity.name == 'mineable-wreckage' then
if entity.type ~= 'simple-entity' or entity.type ~= 'tree' then
this.mined_scrap = this.mined_scrap + 1
give_coin(player)
@ -232,7 +232,7 @@ local function on_player_mined_entity(event)
end
end
if entity.force.name ~= 'scrap' then
if entity.force.name ~= 'defenders' then
return
end
local positions = {}
@ -289,6 +289,8 @@ end
local function on_entity_died(event)
local this = WPT.get_table()
Mining.on_entity_died(event)
local entity = event.entity
if not entity.valid then
return
@ -305,7 +307,7 @@ local function on_entity_died(event)
end
end
if entity.name == 'mineable-wreckage' then
if entity.type ~= 'simple-entity' or entity.type ~= 'tree' then
if math.random(1, 32) == 1 then
hidden_biter(event.entity)
return
@ -319,7 +321,7 @@ local function on_entity_died(event)
return
end
end
if entity.force.name ~= 'scrap' then
if entity.force.name ~= 'defenders' then
return
end
local positions = {}
@ -343,7 +345,7 @@ local function on_entity_died(event)
end
local function on_robot_built_entity(event)
if string.sub(event.created_entity.surface.name, 0, 9) ~= 'scrapyard' then
if string.sub(event.created_entity.surface.name, 0, 10) ~= 'lumberjack' then
return
end
local y = event.created_entity.position.y
@ -371,7 +373,7 @@ local function on_robot_built_entity(event)
end
local function on_built_entity(event)
if string.sub(event.created_entity.surface.name, 0, 9) ~= 'scrapyard' then
if string.sub(event.created_entity.surface.name, 0, 10) ~= 'lumberjack' then
return
end
local player = game.players[event.player_index]

View File

@ -1,5 +1,5 @@
local RPG = require 'maps.scrapyard.rpg'
local WPT = require 'maps.scrapyard.table'
local RPG = require 'maps.lumberjack.rpg'
local WPT = require 'maps.lumberjack.table'
local floor = math.floor
local format_number = require 'util'.format_number
@ -7,7 +7,7 @@ local function create_gui(player)
local label
local line
local frame = player.gui.top.add({type = 'frame', name = 'scrapyard'})
local frame = player.gui.top.add({type = 'frame', name = 'lumberjack'})
frame.style.minimal_height = 38
frame.style.maximal_height = 38
@ -57,10 +57,10 @@ local function update_gui(player)
local rpg = RPG.get_table()
local st = WPT.get_table()
if not player.gui.top.scrapyard then
if not player.gui.top.lumberjack then
create_gui(player)
end
local gui = player.gui.top.scrapyard
local gui = player.gui.top.lumberjack
if rpg.global_pool == 0 then
gui.global_pool.caption = 'XP: 0'
@ -70,8 +70,8 @@ local function update_gui(player)
gui.global_pool.tooltip = 'Get this number over 5k to get some of this mad XP! \\o/'
end
gui.scrap_mined.caption = ' [img=entity.mineable-wreckage]: ' .. format_number(st.mined_scrap, true)
gui.scrap_mined.tooltip = 'Amount of scrap mined.'
gui.scrap_mined.caption = ' [img=entity.tree-01]: ' .. format_number(st.mined_scrap, true)
gui.scrap_mined.tooltip = 'Amount of trees harvested.'
gui.biters_killed.caption = ' [img=entity.small-biter]: ' .. format_number(st.biters_killed, true)
gui.biters_killed.tooltip = 'Amount of biters killed.'

View File

@ -1,6 +1,6 @@
local Public = {}
local Constants = require 'maps.scrapyard.icw.constants'
local Constants = require 'maps.lumberjack.icw.constants'
local table_insert = table.insert
local table_remove = table.remove

View File

@ -1,7 +1,7 @@
local Global = require 'utils.global'
local Event = require 'utils.event'
local Functions = require 'maps.scrapyard.icw.functions'
local Constants = require 'maps.scrapyard.icw.constants'
local Functions = require 'maps.lumberjack.icw.functions'
local Constants = require 'maps.lumberjack.icw.constants'
local Public = {}
local math_round = math.round

View File

@ -1,10 +1,10 @@
local Event = require 'utils.event'
local Power = require 'maps.scrapyard.power'
local ICW = require 'maps.scrapyard.icw.main'
local WPT = require 'maps.scrapyard.table'
local RPG = require 'maps.scrapyard.rpg'
local Terrain = require 'maps.scrapyard.terrain'
require 'maps.scrapyard.locomotive_market'
local Power = require 'maps.lumberjack.power'
local ICW = require 'maps.lumberjack.icw.main'
local WPT = require 'maps.lumberjack.table'
local RPG = require 'maps.lumberjack.rpg'
local Terrain = require 'maps.lumberjack.terrain'
require 'maps.lumberjack.locomotive_market'
local random = math.random
@ -46,7 +46,7 @@ local function rebuild_energy_overworld(data)
end
this.old_ow_energy = this.ow_energy.energy
this.ow_energy.destroy()
this.energy['scrapyard'] = nil
this.energy['lumberjack'] = nil
end
end
this.ow_energy =

View File

@ -1,7 +1,7 @@
local Event = require 'utils.event'
local WPT = require 'maps.scrapyard.table'
local WPT = require 'maps.lumberjack.table'
local WD = require 'modules.wave_defense.table'
local ICW = require 'maps.scrapyard.icw.main'
local ICW = require 'maps.lumberjack.icw.main'
local format_number = require 'util'.format_number
local grandmaster = '[color=blue]Grandmaster:[/color]'

View File

@ -156,7 +156,7 @@ function Public.add(surface, position, chest)
end
end
local e = surface.create_entity({name = chest, position = position, force = 'scrap'})
local e = surface.create_entity({name = chest, position = position, force = 'defenders'})
e.minable = false
local i = e.get_inventory(defines.inventory.chest)
for x = 1, math_random(2, 6), 1 do
@ -323,7 +323,7 @@ function Public.add_rare(surface, position, chest, magic)
end
end
local e = surface.create_entity({name = chest, position = position, force = 'scrap'})
local e = surface.create_entity({name = chest, position = position, force = 'defenders'})
e.minable = false
local i = e.get_inventory(defines.inventory.chest)
for x = 1, math_random(2, 7), 1 do

View File

@ -1,8 +1,8 @@
-- modules
require 'maps.scrapyard.player_list'
require 'maps.scrapyard.comfylatron'
require 'maps.scrapyard.commands'
require 'maps.scrapyard.corpse_util'
require 'maps.lumberjack.player_list'
require 'maps.lumberjack.comfylatron'
require 'maps.lumberjack.commands'
require 'maps.lumberjack.corpse_util'
require 'on_tick_schedule'
require 'modules.dynamic_landfill'
@ -22,22 +22,22 @@ require 'modules.pistol_buffs'
local Explosives = require 'modules.explosives'
local Color = require 'utils.color_presets'
local Entities = require 'maps.scrapyard.entities'
local update_gui = require 'maps.scrapyard.gui'
local ICW = require 'maps.scrapyard.icw.main'
local Entities = require 'maps.lumberjack.entities'
local update_gui = require 'maps.lumberjack.gui'
local ICW = require 'maps.lumberjack.icw.main'
local WD = require 'modules.wave_defense.table'
local Map = require 'modules.map_info'
local RPG = require 'maps.scrapyard.rpg'
local RPG = require 'maps.lumberjack.rpg'
local Reset = require 'functions.soft_reset'
local Terrain = require 'maps.scrapyard.terrain'
local Terrain = require 'maps.lumberjack.terrain'
local Event = require 'utils.event'
local WPT = require 'maps.scrapyard.table'
local Locomotive = require 'maps.scrapyard.locomotive'.locomotive_spawn
local render_train_hp = require 'maps.scrapyard.locomotive'.render_train_hp
local WPT = require 'maps.lumberjack.table'
local Locomotive = require 'maps.lumberjack.locomotive'.locomotive_spawn
local render_train_hp = require 'maps.lumberjack.locomotive'.render_train_hp
local Score = require 'comfy_panel.score'
local Poll = require 'comfy_panel.poll'
local Collapse = require 'modules.collapse'
local Balance = require 'maps.scrapyard.balance'
local Balance = require 'maps.lumberjack.balance'
local Public = {}
local math_random = math.random
@ -63,14 +63,14 @@ local disabled_tiles = {
local grandmaster = '[color=blue]Grandmaster:[/color]'
local function create_forces_and_disable_tech()
game.create_force('scrap')
game.create_force('scrap_defense')
game.forces.player.set_friend('scrap', true)
game.forces.enemy.set_friend('scrap', true)
game.forces.enemy.set_friend('scrap_defense', true)
game.forces.scrap.set_friend('player', true)
game.forces.scrap.set_friend('enemy', true)
game.forces.scrap.share_chart = false
game.create_force('defenders')
game.create_force('lumber_defense')
game.forces.player.set_friend('defenders', true)
game.forces.enemy.set_friend('defenders', true)
game.forces.enemy.set_friend('lumber_defense', true)
game.forces.defenders.set_friend('player', true)
game.forces.defenders.set_friend('enemy', true)
game.forces.defenders.share_chart = false
game.forces.player.technologies['landfill'].enabled = false
game.forces.player.technologies['optics'].researched = true
game.forces.player.recipes['cargo-wagon'].enabled = false
@ -135,7 +135,7 @@ function Public.reset_map()
}
if not this.active_surface_index then
this.active_surface_index = game.create_surface('scrapyard', map_gen_settings).index
this.active_surface_index = game.create_surface('lumberjack', map_gen_settings).index
else
game.forces.player.set_spawn_position({0, 25}, game.surfaces[this.active_surface_index])
this.active_surface_index =
@ -196,16 +196,16 @@ function Public.reset_map()
RPG.rpg_reset_all_players()
if game.forces.scrap_defense then
if game.forces.lumber_defense then
Balance.init_enemy_weapon_damage()
else
log('scrap_defense not found')
log('lumber_defense not found')
end
set_difficulty()
rendering.draw_text {
text = 'Welcome to Scrapyard!',
text = 'Welcome to Lumberjack!',
surface = surface,
target = {-0, 30},
color = {r = 0.98, g = 0.66, b = 0.22},
@ -314,7 +314,7 @@ end
local function on_player_changed_position(event)
local this = WPT.get_table()
local player = game.players[event.player_index]
if string.sub(player.surface.name, 0, 9) ~= 'scrapyard' then
if string.sub(player.surface.name, 0, 10) ~= 'lumberjack' then
return
end
local position = player.position
@ -527,28 +527,6 @@ local function darkness(data)
end
end
local function scrap_randomness(data)
local this = data.this
local rnd = math.random
if rnd(1, 32) == 1 then
if this.scrap_enabled then
return
end
this.scrap_enabled = true
game.print(grandmaster .. ' Scrap is back!', {r = 1, g = 0.5, b = 0.1})
game.print(grandmaster .. ' Output from scrap is now randomized.', {r = 1, g = 0.5, b = 0.1})
return
elseif rnd(1, 64) == 1 then
if not this.scrap_enabled then
return
end
this.scrap_enabled = false
game.print(grandmaster .. ' It seems that the scrap is temporarily gone.', {r = 1, g = 0.5, b = 0.1})
game.print(grandmaster .. ' Output from scrap is now only ores.', {r = 1, g = 0.5, b = 0.1})
return
end
end
local function transfer_pollution(data)
local surface = data.surface
local this = data.this
@ -561,7 +539,6 @@ local function transfer_pollution(data)
end
local tick_minute_functions = {
[300 * 2 + 30 * 2] = scrap_randomness,
[300 * 3 + 30 * 1] = darkness,
[300 * 3 + 30 * 0] = transfer_pollution
}
@ -624,19 +601,21 @@ local on_init = function()
global.custom_highscore.description = 'Wagon distance reached:'
game.forces.scrap.share_chart = false
game.forces.defenders.share_chart = false
global.rocks_yield_ore_maximum_amount = 500
global.rocks_yield_ore_base_amount = 50
global.rocks_yield_ore_distance_modifier = 0.025
local T = Map.Pop_info()
T.main_caption = 'S c r a p y a r d '
T.sub_caption = ' ---defend the choo---'
T.main_caption = 'L u m b e r j a c k '
T.sub_caption = ''
T.text =
table.concat(
{
'Welcome lumberlover!\n',
'\n',
'The biters have catched the scent of fish in the cargo wagon.\n',
'Guide the choo through the black mist and protect it for as long as possible!\n',
'Guide the choo and protect it for as long as possible!\n',
'This will not be an easy task however,\n',
'since their strength and numbers increase over time.\n',
'\n',
@ -644,16 +623,10 @@ local on_init = function()
'Mining productivity research, will overhaul your mining equipment,\n',
'reinforcing your pickaxe as well as increasing the size of your backpack.\n',
'\n',
'Scrap randomness seems to occur frequently, sometimes mining scrap\n',
'does not output scrap, weird...\n',
'\n',
"We've also noticed that solar eclipse occuring, \n",
'we have yet to solve this mystery\n',
'\n',
'Good luck, over and out!',
'\n',
'\n',
'\n'
'Good luck, over and out!'
}
)
T.main_caption_color = {r = 150, g = 150, b = 0}

211
maps/lumberjack/mining.lua Normal file
View File

@ -0,0 +1,211 @@
local WPT = require 'maps.lumberjack.table'
local Public = {}
local max_spill = 60
local math_random = math.random
local math_floor = math.floor
local math_sqrt = math.sqrt
local function create_particles(surface, name, position, amount, cause_position)
local direction_mod = (-100 + math_random(0, 200)) * 0.0004
local direction_mod_2 = (-100 + math_random(0, 200)) * 0.0004
if cause_position then
direction_mod = (cause_position.x - position.x) * 0.025
direction_mod_2 = (cause_position.y - position.y) * 0.025
end
for i = 1, amount, 1 do
local m = math_random(4, 10)
local m2 = m * 0.005
surface.create_particle(
{
name = name,
position = position,
frame_speed = 1,
vertical_speed = 0.130,
height = 0,
movement = {
(m2 - (math_random(0, m) * 0.01)) + direction_mod,
(m2 - (math_random(0, m) * 0.01)) + direction_mod_2
}
}
)
end
end
local function mining_chances_ores()
local data = {
{name = 'tree', chance = 500},
{name = 'iron-ore', chance = 570},
{name = 'copper-ore', chance = 570},
{name = 'stone', chance = 550},
{name = 'coal', chance = 545},
{name = 'uranium-ore', chance = 1}
}
return data
end
local function ore_yield_amounts()
local data = {
['iron-ore'] = 28,
['copper-ore'] = 28,
['stone'] = 20,
['coal'] = 28,
['uranium-ore'] = 1,
['tree-01'] = 1,
['tree-02'] = 1,
['tree-02-red'] = 1,
['tree-03'] = 1,
['tree-04'] = 1,
['tree-05'] = 1,
['tree-06'] = 1,
['tree-06-brown'] = 1,
['tree-07'] = 1,
['tree-08'] = 1,
['tree-08-brown'] = 1,
['tree-08-red'] = 1,
['tree-09'] = 1,
['tree-09-brown'] = 1,
['tree-09-red'] = 1
}
return data
end
local tree_raffle_ores = {}
for _, t in pairs(mining_chances_ores()) do
for x = 1, t.chance, 1 do
table.insert(tree_raffle_ores, t.name)
end
end
local size_of_ore_raffle = #tree_raffle_ores
local function get_amount(data)
local entity = data.entity
local this = data.this
local distance_to_center = math_floor(math_sqrt(entity.position.x ^ 2 + entity.position.y ^ 2))
local distance_modifier = 0.25
local base_amount = 35
local maximum_amount = 100
if this.rocks_yield_ore_distance_modifier then
distance_modifier = this.rocks_yield_ore_distance_modifier
end
if this.rocks_yield_ore_base_amount then
base_amount = this.rocks_yield_ore_base_amount
end
if this.rocks_yield_ore_maximum_amount then
maximum_amount = this.rocks_yield_ore_maximum_amount
end
local amount = base_amount + (distance_to_center * distance_modifier)
if amount > maximum_amount then
amount = maximum_amount
end
local m = (70 + math_random(0, 60)) * 0.01
amount = math_floor(amount * ore_yield_amounts()[entity.name] * m)
if amount < 1 then
amount = 1
end
return amount
end
local function tree_randomness(data)
local entity = data.entity
local player = data.player
local tree
tree = tree_raffle_ores[math.random(1, size_of_ore_raffle)]
data.tree = tree
local tree_amount = get_amount(data)
local position = {x = entity.position.x, y = entity.position.y}
if tree_amount > max_spill then
player.surface.spill_item_stack(position, {name = tree, count = max_spill}, true)
tree_amount = tree_amount - max_spill
local inserted_count = player.insert({name = tree, count = tree_amount})
tree_amount = tree_amount - inserted_count
if tree_amount > 0 then
player.surface.spill_item_stack(position, {name = tree, count = tree_amount}, true)
end
else
if tree == 'tree' then
tree = 'wood'
end
player.surface.spill_item_stack(position, {name = tree, count = tree_amount}, true)
end
if tree_amount <= 0 then
tree_amount = math_random(1, 10)
end
player.surface.create_entity(
{
name = 'flying-text',
position = position,
text = '+' .. tree_amount .. ' [img=item/' .. tree .. ']',
color = {r = 200, g = 160, b = 30}
}
)
create_particles(player.surface, 'shell-particle', position, 64, {x = player.position.x, y = player.position.y})
end
function Public.on_player_mined_entity(event)
local entity = event.entity
if not entity.valid then
return
end
if entity.type ~= 'tree' then
return
end
local player = game.players[event.player_index]
local this = WPT.get_table()
if not player then
return
end
event.buffer.clear()
local data = {
this = this,
entity = entity,
player = player
}
tree_randomness(data)
end
function Public.on_entity_died(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
return Public

View File

@ -6,7 +6,7 @@ end
local Event = require 'utils.event'
local play_time = require 'utils.session_data'
local Tabs = require 'comfy_panel.main'
local RPG = require 'maps.scrapyard.rpg'
local RPG = require 'maps.lumberjack.rpg'
local symbol_asc = ''
local symbol_desc = ''

View File

@ -1,5 +1,5 @@
local Event = require 'utils.event'
local WPT = require 'maps.scrapyard.table'
local WPT = require 'maps.lumberjack.table'
local function balance(t)
local g = 0
@ -20,20 +20,20 @@ end
local function tick()
local this = WPT.get_table()
if not this.energy['scrapyard'] then
this.energy['scrapyard'] = this.ow_energy
if not this.energy['lumberjack'] then
this.energy['lumberjack'] = this.ow_energy
end
if not this.energy['loco'] then
this.energy['loco'] = this.lo_energy
end
local scrapyard = this.energy['scrapyard']
local lumberjack = this.energy['lumberjack']
local loco = this.energy['loco']
if not scrapyard or not loco then
if not lumberjack or not loco then
return
end
if not scrapyard.valid or not loco.valid then
if not lumberjack.valid or not loco.valid then
return
end
balance(this.energy)
@ -46,7 +46,7 @@ local function built_entity(event)
end
local player = game.players[event.player_index]
local surface = entity.surface
if surface.name ~= 'scrapyard' then
if surface.name ~= 'lumberjack' then
return
end
if

View File

@ -1091,7 +1091,7 @@ end
local function on_player_changed_position(event)
local player = game.players[event.player_index]
if string.sub(player.surface.name, 0, 9) ~= 'scrapyard' then
if string.sub(player.surface.name, 0, 10) ~= 'lumberjack' then
return
end
distance(player)

View File

@ -31,7 +31,6 @@ function Public.reset_table()
this.cargo_health = 10000
this.cargo_max_health = 10000
this.revealed_spawn = 0
this.scrap_enabled = true
this.left_top = {
x = 0,
y = 0

View File

@ -1,15 +1,14 @@
local Biters = require 'modules.wave_defense.biter_rolls'
local WD = require 'modules.wave_defense.table'
local ICW = require 'maps.scrapyard.icw.main'
local ICW = require 'maps.lumberjack.icw.main'
local Event = require 'utils.event'
local Market = require 'functions.basic_markets'
local create_entity_chain = require 'functions.create_entity_chain'
local create_tile_chain = require 'functions.create_tile_chain'
local noise_v1 = require 'utils.simplex_noise'.d2
local map_functions = require 'tools.map_functions'
local WPT = require 'maps.scrapyard.table'
local WPT = require 'maps.lumberjack.table'
local shapes = require 'tools.shapes'
local Loot = require 'maps.scrapyard.loot'
local Loot = require 'maps.lumberjack.loot'
local get_noise = require 'utils.get_noise'
local Public = {}
@ -39,8 +38,6 @@ local rock_raffle = {
'rock-huge'
}
local size_of_rock_raffle = #rock_raffle
local scrap_entities = {
'crash-site-assembling-machine-1-broken',
'crash-site-assembling-machine-2-broken',
@ -93,34 +90,23 @@ local scrap_buildings = {
}
local spawner_raffle = {'biter-spawner', 'biter-spawner', 'biter-spawner', 'spitter-spawner'}
local trees = {'dead-grey-trunk', 'dead-grey-trunk', 'dry-tree'}
local more_colors = {
'black-refined-concrete',
'brown-refined-concrete',
'red-refined-concrete',
'blue-refined-concrete'
}
local trees_terrain = {
['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
'tree-01',
'tree-02',
'tree-02-red',
'tree-03',
'tree-04',
'tree-05',
'tree-06',
'tree-06-brown',
'tree-07',
'tree-08',
'tree-08-brown',
'tree-08-red',
'tree-09',
'tree-09-brown',
'tree-09-red'
}
local function place_wagon(data)
@ -148,7 +134,7 @@ local function place_wagon(data)
end
for _, e in pairs(
surface.find_entities_filtered(
{position = tile.position, force = {'neutral', 'enemy', 'scrap_defense', 'scrap'}}
{position = tile.position, force = {'neutral', 'enemy', 'lumber_defense', 'defenders'}}
)
) do
e.destroy()
@ -175,7 +161,7 @@ local function place_random_scrap_entity(surface, position)
if r < 15 then
local e =
surface.create_entity(
{name = scrap_buildings[math_random(1, #scrap_buildings)], position = position, force = 'scrap'}
{name = scrap_buildings[math_random(1, #scrap_buildings)], position = position, force = 'defenders'}
)
if e.name == 'nuclear-reactor' then
create_entity_chain(
@ -195,7 +181,7 @@ local function place_random_scrap_entity(surface, position)
return
end
if r < 75 then
local e = surface.create_entity({name = 'gun-turret', position = position, force = 'scrap_defense'})
local e = surface.create_entity({name = 'gun-turret', position = position, force = 'lumber_defense'})
if math_abs(position.y) < Public.level_depth * 2.5 then
e.insert({name = 'piercing-rounds-magazine', count = math_random(64, 128)})
else
@ -206,7 +192,7 @@ local function place_random_scrap_entity(surface, position)
local e =
surface.create_entity(
{name = 'storage-tank', position = position, force = 'scrap', direction = math_random(0, 3)}
{name = 'storage-tank', position = position, force = 'defenders', direction = math_random(0, 3)}
)
local fluids = {'crude-oil', 'lubricant', 'heavy-oil', 'light-oil', 'petroleum-gas', 'sulfuric-acid', 'water'}
e.fluidbox[1] = {name = fluids[math_random(1, #fluids)], amount = math_random(15000, 25000)}
@ -218,11 +204,11 @@ end
local function create_inner_content(surface, pos, noise)
if math_random(1, 90000) == 1 then
if noise < 0.3 or noise > -0.3 then
map_functions.draw_noise_entity_ring(surface, pos, 'laser-turret', 'scrap_defense', 0, 2)
map_functions.draw_noise_entity_ring(surface, pos, 'accumulator', 'scrap_defense', 2, 3)
map_functions.draw_noise_entity_ring(surface, pos, 'substation', 'scrap_defense', 3, 4)
map_functions.draw_noise_entity_ring(surface, pos, 'solar-panel', 'scrap_defense', 4, 6)
map_functions.draw_noise_entity_ring(surface, pos, 'stone-wall', 'scrap_defense', 6, 7)
map_functions.draw_noise_entity_ring(surface, pos, 'laser-turret', 'lumber_defense', 0, 2)
map_functions.draw_noise_entity_ring(surface, pos, 'accumulator', 'lumber_defense', 2, 3)
map_functions.draw_noise_entity_ring(surface, pos, 'substation', 'lumber_defense', 3, 4)
map_functions.draw_noise_entity_ring(surface, pos, 'solar-panel', 'lumber_defense', 4, 6)
map_functions.draw_noise_entity_ring(surface, pos, 'stone-wall', 'lumber_defense', 6, 7)
create_tile_chain(surface, {name = 'concrete', position = pos}, math_random(16, 32), 50)
create_tile_chain(surface, {name = 'concrete', position = pos}, math_random(16, 32), 50)
@ -256,13 +242,13 @@ local function wall(data)
else
surface.set_tiles({{name = 'dirt-7', position = p}})
if math_random(1, 5) ~= 1 then
surface.create_entity({name = 'mineable-wreckage', position = p})
surface.create_entity({name = trees_terrain[math_random(1, #trees_terrain)], position = p})
end
end
else
surface.set_tiles({{name = 'dirt-7', position = p}})
if surface.can_place_entity({name = 'stone-wall', position = p, force = 'scrap_defense'}) then
if surface.can_place_entity({name = 'stone-wall', position = p, force = 'lumber_defense'}) then
if math_random(1, 512) == 1 and y > 3 and y < 28 then
if math_random(1, 2) == 1 then
Loot.add(surface, p, 'wooden-chest')
@ -275,7 +261,7 @@ local function wall(data)
if math_random(1, y + 1) == 1 then
local e =
surface.create_entity(
{name = 'stone-wall', position = p, force = 'scrap_defense'}
{name = 'stone-wall', position = p, force = 'lumber_defense'}
)
e.minable = false
end
@ -283,7 +269,7 @@ local function wall(data)
if math_random(1, 32 - y) == 1 then
local e =
surface.create_entity(
{name = 'stone-wall', position = p, force = 'scrap_defense'}
{name = 'stone-wall', position = p, force = 'lumber_defense'}
)
e.minable = false
end
@ -297,17 +283,17 @@ local function wall(data)
end
if math_random(1, 16) == 1 then
if surface.can_place_entity({name = 'small-worm-turret', position = p, force = 'scrap_defense'}) then
if surface.can_place_entity({name = 'small-worm-turret', position = p, force = 'lumber_defense'}) then
Biters.wave_defense_set_worm_raffle(math_abs(p.y) * worm_level_modifier)
surface.create_entity(
{name = Biters.wave_defense_roll_worm_name(), position = p, force = 'scrap_defense'}
{name = Biters.wave_defense_roll_worm_name(), position = p, force = 'lumber_defense'}
)
end
end
if math_random(1, 32) == 1 then
if surface.can_place_entity({name = 'gun-turret', position = p, force = 'scrap_defense'}) then
local e = surface.create_entity({name = 'gun-turret', position = p, force = 'scrap_defense'})
if surface.can_place_entity({name = 'gun-turret', position = p, force = 'lumber_defense'}) then
local e = surface.create_entity({name = 'gun-turret', position = p, force = 'lumber_defense'})
if math_abs(p.y) < Public.level_depth * 2.5 then
e.insert({name = 'piercing-rounds-magazine', count = math_random(64, 128)})
else
@ -336,7 +322,7 @@ local function process_level_9_position(data)
tiles[#tiles + 1] = {name = 'dirt-7', position = p}
local no_rocks_2 = get_noise('no_rocks_2', p, seed)
if math_random(1, 2) == 1 and no_rocks_2 > -0.5 then
entities[#entities + 1] = {name = rock_raffle[math_random(1, size_of_rock_raffle)], position = p}
entities[#entities + 1] = {name = trees_terrain[math_random(1, #trees_terrain)], position = p}
end
if math_random(1, 1024) == 1 then
treasure[#treasure + 1] = p
@ -347,7 +333,7 @@ local function process_level_9_position(data)
entities[#entities + 1] = {
name = Biters.wave_defense_roll_worm_name(),
position = p,
force = 'scrap_defense'
force = 'lumber_defense'
}
end
return
@ -386,8 +372,6 @@ local function process_level_8_position(data)
local seed = data.seed
local tiles = data.tiles
local entities = data.entities
local markets = data.markets
local treasure = data.treasure
local scrapyard = get_noise('scrapyard', p, seed)
@ -407,12 +391,12 @@ local function process_level_8_position(data)
if scrapyard < -0.25 or scrapyard > 0.25 then
if math_random(1, 256) == 1 then
entities[#entities + 1] = {name = 'gun-turret', position = p, force = 'scrap_defense'}
entities[#entities + 1] = {name = 'gun-turret', position = p, force = 'lumber_defense'}
end
tiles[#tiles + 1] = {name = 'dirt-7', position = p}
if scrapyard < -0.55 or scrapyard > 0.55 then
if math_random(1, 2) == 1 then
entities[#entities + 1] = {name = rock_raffle[math_random(1, size_of_rock_raffle)], position = p}
entities[#entities + 1] = {name = trees_terrain[math_random(1, #trees_terrain)], position = p}
end
return
end
@ -423,23 +407,23 @@ local function process_level_8_position(data)
entities[#entities + 1] = {
name = Biters.wave_defense_roll_worm_name(),
position = p,
force = 'scrap_defense'
force = 'lumber_defense'
}
end
if math_random(1, 96) == 1 then
entities[#entities + 1] = {
name = scrap_entities[math_random(1, scrap_entities_index)],
position = p,
force = 'scrap_defense'
force = 'lumber_defense'
}
end
if math_random(1, 5) > 1 then
entities[#entities + 1] = {name = 'mineable-wreckage', position = p}
entities[#entities + 1] = {name = trees_terrain[math_random(1, #trees_terrain)], position = p}
end
if math_random(1, 256) == 1 then
create_inner_content(surface, p, scrapyard)
entities[#entities + 1] = {name = 'land-mine', position = p, force = 'scrap_defense'}
entities[#entities + 1] = {name = 'land-mine', position = p, force = 'lumber_defense'}
end
return
end
@ -460,7 +444,7 @@ local function process_level_8_position(data)
if math_floor(large_caves * 10) % 4 < 3 then
tiles[#tiles + 1] = {name = 'dirt-7', position = p}
if math_random(1, 2) == 1 then
entities[#entities + 1] = {name = rock_raffle[math_random(1, size_of_rock_raffle)], position = p}
entities[#entities + 1] = {name = trees_terrain[math_random(1, #trees_terrain)], position = p}
end
return
end
@ -472,7 +456,7 @@ local function process_level_8_position(data)
tiles[#tiles + 1] = {name = 'stone-path', position = p}
if math_random(1, 256) == 1 then
entities[#entities + 1] = {name = 'land-mine', position = p, force = 'scrap_defense'}
entities[#entities + 1] = {name = 'land-mine', position = p, force = 'lumber_defense'}
end
end
@ -573,7 +557,7 @@ local function process_level_7_position(data)
tiles[#tiles + 1] = {name = 'dirt-7', position = p}
if math_random(1, 100) > 15 then
entities[#entities + 1] = {name = rock_raffle[math_random(1, size_of_rock_raffle)], position = p}
entities[#entities + 1] = {name = trees_terrain[math_random(1, #trees_terrain)], position = p}
end
if math_random(1, 256) == 1 then
treasure[#treasure + 1] = p
@ -586,7 +570,6 @@ local function process_level_6_position(data)
local seed = data.seed
local tiles = data.tiles
local entities = data.entities
local markets = data.markets
local treasure = data.treasure
local large_caves = get_noise('large_caves', p, seed)
@ -599,7 +582,7 @@ local function process_level_6_position(data)
treasure[#treasure + 1] = p
end
if math_random(1, 3) > 1 then
entities[#entities + 1] = {name = 'mineable-wreckage', position = p}
entities[#entities + 1] = {name = trees_terrain[math_random(1, #trees_terrain)], position = p}
end
return
end
@ -615,7 +598,7 @@ local function process_level_6_position(data)
entities[#entities + 1] = {
name = Biters.wave_defense_roll_worm_name(),
position = p,
force = 'scrap_defense'
force = 'lumber_defense'
}
end
return
@ -640,7 +623,7 @@ local function process_level_6_position(data)
treasure[#treasure + 1] = p
end
if math_random(1, 2) > 1 then
entities[#entities + 1] = {name = 'mineable-wreckage', position = p}
entities[#entities + 1] = {name = trees_terrain[math_random(1, #trees_terrain)], position = p}
end
return
end
@ -653,7 +636,6 @@ local function process_level_5_position(data)
local seed = data.seed
local tiles = data.tiles
local entities = data.entities
local markets = data.markets
local treasure = data.treasure
local small_caves = get_noise('small_caves', p, seed)
@ -666,7 +648,7 @@ local function process_level_5_position(data)
treasure[#treasure + 1] = p
end
if math_random(1, 3) > 1 then
entities[#entities + 1] = {name = 'mineable-wreckage', position = p}
entities[#entities + 1] = {name = trees_terrain[math_random(1, #trees_terrain)], position = p}
end
return
end
@ -682,7 +664,7 @@ local function process_level_5_position(data)
entities[#entities + 1] = {
name = Biters.wave_defense_roll_worm_name(),
position = p,
force = 'scrap_defense'
force = 'lumber_defense'
}
end
return
@ -707,7 +689,7 @@ local function process_level_5_position(data)
treasure[#treasure + 1] = p
end
if math_random(1, 2) > 1 then
entities[#entities + 1] = {name = 'mineable-wreckage', position = p}
entities[#entities + 1] = {name = trees_terrain[math_random(1, #trees_terrain)], position = p}
end
return
end
@ -753,7 +735,7 @@ local function process_level_4_position(data)
entities[#entities + 1] = {
name = Biters.wave_defense_roll_worm_name(),
position = p,
force = 'scrap_defense'
force = 'lumber_defense'
}
end
if math_random(1, 1024) == 1 then
@ -765,7 +747,7 @@ local function process_level_4_position(data)
tiles[#tiles + 1] = {name = 'dirt-7', position = p}
--tiles[#tiles + 1] = {name = more_colors[math_random(1, #more_colors)].. "-refined-concrete", position = p}
if math_random(1, 3) > 1 then
entities[#entities + 1] = {name = 'mineable-wreckage', position = p}
entities[#entities + 1] = {name = trees_terrain[math_random(1, #trees_terrain)], position = p}
end
if math_random(1, 2048) == 1 then
treasure[#treasure + 1] = p
@ -789,7 +771,7 @@ local function process_level_4_position(data)
tiles[#tiles + 1] = {name = 'dirt-7', position = p}
--tiles[#tiles + 1] = {name = colors[math_random(1, #colors)].. "-refined-concrete", position = p}
if math_random(1, 5) > 1 then
entities[#entities + 1] = {name = 'mineable-wreckage', position = p}
entities[#entities + 1] = {name = trees_terrain[math_random(1, #trees_terrain)], position = p}
end
if math_random(1, 1024) == 1 then
treasure[#treasure + 1] = p
@ -815,7 +797,7 @@ local function process_level_4_position(data)
tiles[#tiles + 1] = {name = 'dirt-7', position = p}
--tiles[#tiles + 1] = {name = more_colors[math_random(1, #more_colors)].. "-refined-concrete", position = p}
if math_random(1, 100) > 30 then
entities[#entities + 1] = {name = 'mineable-wreckage', position = p}
entities[#entities + 1] = {name = trees_terrain[math_random(1, #trees_terrain)], position = p}
end
return
end
@ -840,7 +822,7 @@ local function process_level_3_position(data)
if noise_cave_ponds > -0.79 then
tiles[#tiles + 1] = {name = 'dirt-7', position = p}
--tiles[#tiles + 1] = {name = more_colors[math_random(1, #more_colors)].. "-refined-concrete", position = p}
entities[#entities + 1] = {name = 'mineable-wreckage', position = p}
entities[#entities + 1] = {name = trees_terrain[math_random(1, #trees_terrain)], position = p}
else
tiles[#tiles + 1] = {name = 'grass-' .. math_floor(noise_cave_ponds * 32) % 3 + 1, position = p}
if math_random(1, 32) == 1 then
@ -918,7 +900,7 @@ local function process_level_3_position(data)
entities[#entities + 1] = {
name = Biters.wave_defense_roll_worm_name(),
position = p,
force = 'scrap_defense'
force = 'lumber_defense'
}
end
if math_random(1, 512) == 1 then
@ -951,7 +933,7 @@ local function process_level_3_position(data)
place_random_scrap_entity(surface, p)
end
if math_random(1, 100) > 30 then
entities[#entities + 1] = {name = 'mineable-wreckage', position = p}
entities[#entities + 1] = {name = trees_terrain[math_random(1, #trees_terrain)], position = p}
end
return
end
@ -1038,7 +1020,7 @@ local function process_level_2_position(data)
entities[#entities + 1] = {
name = Biters.wave_defense_roll_worm_name(),
position = p,
force = 'scrap_defense'
force = 'lumber_defense'
}
end
if math_random(1, 64) == 1 then
@ -1068,7 +1050,7 @@ local function process_level_2_position(data)
place_random_scrap_entity(surface, p)
end
if math_random(1, 100) > 30 then
entities[#entities + 1] = {name = 'mineable-wreckage', position = p}
entities[#entities + 1] = {name = trees_terrain[math_random(1, #trees_terrain)], position = p}
end
return
end
@ -1155,7 +1137,7 @@ local function process_level_1_position(data)
entities[#entities + 1] = {
name = Biters.wave_defense_roll_worm_name(),
position = p,
force = 'scrap_defense'
force = 'lumber_defense'
}
end
if math_random(1, 1024) == 1 then
@ -1194,7 +1176,7 @@ local function process_level_1_position(data)
place_random_scrap_entity(surface, p)
end
if math_random(1, 100) > 30 then
entities[#entities + 1] = {name = 'mineable-wreckage', position = p}
entities[#entities + 1] = {name = trees_terrain[math_random(1, #trees_terrain)], position = p}
end
end
@ -1547,7 +1529,7 @@ end
local function on_chunk_generated(event)
local this = WPT.get_table()
if string.sub(event.surface.name, 0, 9) ~= 'scrapyard' then
if string.sub(event.surface.name, 0, 10) ~= 'lumberjack' then
return
end
local surface = event.surface

View File

@ -1,300 +0,0 @@
local WPT = require 'maps.scrapyard.table'
local Public = {}
local max_spill = 60
local math_random = math.random
local math_floor = math.floor
local math_sqrt = math.sqrt
local function create_particles(surface, name, position, amount, cause_position)
local direction_mod = (-100 + math_random(0, 200)) * 0.0004
local direction_mod_2 = (-100 + math_random(0, 200)) * 0.0004
if cause_position then
direction_mod = (cause_position.x - position.x) * 0.025
direction_mod_2 = (cause_position.y - position.y) * 0.025
end
for i = 1, amount, 1 do
local m = math_random(4, 10)
local m2 = m * 0.005
surface.create_particle(
{
name = name,
position = position,
frame_speed = 1,
vertical_speed = 0.130,
height = 0,
movement = {
(m2 - (math_random(0, m) * 0.01)) + direction_mod,
(m2 - (math_random(0, m) * 0.01)) + direction_mod_2
}
}
)
end
end
local function mining_chances_scrap()
local data = {
{name = 'iron-plate', chance = 400},
{name = 'iron-gear-wheel', chance = 390},
{name = 'copper-plate', chance = 400},
{name = 'copper-cable', chance = 380},
{name = 'electronic-circuit', chance = 150},
{name = 'steel-plate', chance = 120},
{name = 'solid-fuel', chance = 89},
{name = 'pipe', chance = 75},
{name = 'stone', chance = 50},
{name = 'iron-stick', chance = 50},
{name = 'battery', chance = 20},
{name = 'empty-barrel', chance = 10},
{name = 'crude-oil-barrel', chance = 10},
{name = 'lubricant-barrel', chance = 10},
{name = 'petroleum-gas-barrel', chance = 10},
{name = 'sulfuric-acid-barrel', chance = 10},
{name = 'heavy-oil-barrel', chance = 10},
{name = 'light-oil-barrel', chance = 10},
{name = 'water-barrel', chance = 10},
{name = 'green-wire', chance = 10},
{name = 'red-wire', chance = 10},
{name = 'explosives', chance = 5},
{name = 'advanced-circuit', chance = 5},
{name = 'nuclear-fuel', chance = 1},
{name = 'pipe-to-ground', chance = 10},
{name = 'plastic-bar', chance = 5},
{name = 'rocket-fuel', chance = 3},
{name = 'engine-unit', chance = 4},
{name = 'logistic-robot', chance = 1},
{name = 'construction-robot', chance = 1},
{name = 'land-mine', chance = 3},
{name = 'grenade', chance = 10},
{name = 'rocket', chance = 3},
{name = 'explosive-rocket', chance = 3},
{name = 'cannon-shell', chance = 2},
{name = 'explosive-cannon-shell', chance = 2},
{name = 'explosive-uranium-cannon-shell', chance = 1},
{name = 'artillery-shell', chance = 1},
{name = 'cluster-grenade', chance = 2},
{name = 'defender-capsule', chance = 5},
{name = 'destroyer-capsule', chance = 1},
{name = 'distractor-capsule', chance = 2}
}
return data
end
local function mining_chances_ores()
local data = {
{name = 'iron-ore', chance = 570},
{name = 'copper-ore', chance = 570},
{name = 'stone', chance = 550},
{name = 'coal', chance = 545},
{name = 'uranium-ore', chance = 1}
}
return data
end
local function ore_yield_amounts()
local data = {
['iron-ore'] = 28,
['copper-ore'] = 28,
['stone'] = 20,
['coal'] = 28,
['uranium-ore'] = 1,
['mineable-wreckage'] = 1
}
return data
end
local function scrap_yield_amounts()
local data = {
['iron-plate'] = 12,
['iron-gear-wheel'] = 12,
['iron-stick'] = 12,
['stone'] = 5,
['copper-plate'] = 12,
['copper-cable'] = 12,
['electronic-circuit'] = 4,
['steel-plate'] = 4,
['pipe'] = 5,
['solid-fuel'] = 6,
['empty-barrel'] = 3,
['crude-oil-barrel'] = 3,
['lubricant-barrel'] = 3,
['petroleum-gas-barrel'] = 3,
['sulfuric-acid-barrel'] = 3,
['heavy-oil-barrel'] = 3,
['light-oil-barrel'] = 3,
['water-barrel'] = 3,
['battery'] = 2,
['explosives'] = 4,
['advanced-circuit'] = 2,
['nuclear-fuel'] = 0.1,
['pipe-to-ground'] = 1,
['plastic-bar'] = 4,
['processing-unit'] = 1,
['used-up-uranium-fuel-cell'] = 1,
['uranium-fuel-cell'] = 0.3,
['rocket-fuel'] = 0.3,
['rocket-control-unit'] = 0.3,
['low-density-structure'] = 0.3,
['heat-pipe'] = 1,
['green-wire'] = 8,
['red-wire'] = 8,
['engine-unit'] = 2,
['electric-engine-unit'] = 2,
['logistic-robot'] = 0.3,
['construction-robot'] = 0.3,
['land-mine'] = 1,
['grenade'] = 2,
['rocket'] = 2,
['explosive-rocket'] = 2,
['cannon-shell'] = 2,
['explosive-cannon-shell'] = 2,
['uranium-cannon-shell'] = 2,
['explosive-uranium-cannon-shell'] = 2,
['artillery-shell'] = 0.3,
['cluster-grenade'] = 0.3,
['defender-capsule'] = 2,
['destroyer-capsule'] = 0.3,
['distractor-capsule'] = 0.3,
['mineable-wreckage'] = 1
}
return data
end
local scrap_raffle_scrap = {}
for _, t in pairs(mining_chances_scrap()) do
for x = 1, t.chance, 1 do
table.insert(scrap_raffle_scrap, t.name)
end
end
local size_of_scrap_raffle = #scrap_raffle_scrap
local scrap_raffle_ores = {}
for _, t in pairs(mining_chances_ores()) do
for x = 1, t.chance, 1 do
table.insert(scrap_raffle_ores, t.name)
end
end
local size_of_ore_raffle = #scrap_raffle_ores
local function get_amount(data)
local entity = data.entity
local this = data.this
local scrap = data.scrap
local scrap_amount = scrap_yield_amounts()
local distance_to_center = math_floor(math_sqrt(entity.position.x ^ 2 + entity.position.y ^ 2))
local distance_modifier = 0.25
local base_amount = 35
local maximum_amount = 100
if this.rocks_yield_ore_distance_modifier then
distance_modifier = this.rocks_yield_ore_distance_modifier
end
if this.rocks_yield_ore_base_amount then
base_amount = this.rocks_yield_ore_base_amount
end
if this.rocks_yield_ore_maximum_amount then
maximum_amount = this.rocks_yield_ore_maximum_amount
end
local amount = base_amount + (distance_to_center * distance_modifier)
if amount > maximum_amount then
amount = maximum_amount
end
local m = (70 + math_random(0, 60)) * 0.01
if this.scrap_enabled then
local amount_bonus =
(game.forces.enemy.evolution_factor * 2) + (game.forces.player.mining_drill_productivity_bonus * 2)
local r1 = math.ceil(scrap_amount[scrap] * (1.3 + (amount_bonus * 1.3)))
local r2 = math.ceil(scrap_amount[scrap] * (1.7 + (amount_bonus * 1.7)))
if not r1 or not r2 then
return
end
amount = math_random(r1, r2)
else
amount = math_floor(amount * ore_yield_amounts()[entity.name] * m)
end
if amount < 1 then
amount = 1
end
return amount
end
local function scrap_randomness(data)
local entity = data.entity
local this = data.this
local player = data.player
local scrap
if this.scrap_enabled then
scrap = scrap_raffle_scrap[math.random(1, size_of_scrap_raffle)]
else
scrap = scrap_raffle_ores[math.random(1, size_of_ore_raffle)]
end
data.scrap = scrap
local scrap_amount = get_amount(data)
local position = {x = entity.position.x, y = entity.position.y}
if scrap_amount > max_spill then
player.surface.spill_item_stack(position, {name = scrap, count = max_spill}, true)
scrap_amount = scrap_amount - max_spill
local inserted_count = player.insert({name = scrap, count = scrap_amount})
scrap_amount = scrap_amount - inserted_count
if scrap_amount > 0 then
player.surface.spill_item_stack(position, {name = scrap, count = scrap_amount}, true)
end
else
player.surface.spill_item_stack(position, {name = scrap, count = scrap_amount}, true)
end
if scrap_amount <= 0 then
scrap_amount = math_random(1, 10)
end
player.surface.create_entity(
{
name = 'flying-text',
position = position,
text = '+' .. scrap_amount .. ' [img=item/' .. scrap .. ']',
color = {r = 200, g = 160, b = 30}
}
)
create_particles(player.surface, 'shell-particle', position, 64, {x = player.position.x, y = player.position.y})
end
function Public.on_player_mined_entity(event)
local entity = event.entity
if not entity.valid then
return
end
if entity.type ~= 'simple-entity' then
return
end
local player = game.players[event.player_index]
local this = WPT.get_table()
if not player then
return
end
event.buffer.clear()
local data = {
this = this,
entity = entity,
player = player
}
scrap_randomness(data)
end
return Public