mirror of
https://github.com/ComfyFactory/ComfyFactorio.git
synced 2025-02-13 13:49:33 +02:00
more scrapyard fixes
This commit is contained in:
parent
b4bc0254a9
commit
07ac6061e5
@ -14,6 +14,7 @@ require "modules.wave_defense.main"
|
||||
require "maps.scrapyard.comfylatron"
|
||||
require "modules.explosives"
|
||||
|
||||
local Color = require 'utils.color_presets'
|
||||
local ICW = require "maps.scrapyard.icw.main"
|
||||
local WD = require "modules.wave_defense.table"
|
||||
local Map = require 'modules.map_info'
|
||||
@ -76,6 +77,21 @@ local function set_objective_health(entity, final_damage_amount)
|
||||
rendering.set_text(this.health_text, "HP: " .. this.locomotive_health .. " / " .. this.locomotive_max_health)
|
||||
end
|
||||
|
||||
local function set_difficulty()
|
||||
local wave_defense_table = WD.get_table()
|
||||
local player_count = #game.connected_players
|
||||
|
||||
wave_defense_table.max_active_biters = 1024
|
||||
|
||||
-- threat gain / wave
|
||||
wave_defense_table.threat_gain_multiplier = 2 + player_count * 0.1
|
||||
|
||||
|
||||
--20 Players for fastest wave_interval
|
||||
wave_defense_table.wave_interval = 3600 - player_count * 90
|
||||
if wave_defense_table.wave_interval < 1800 then wave_defense_table.wave_interval = 1800 end
|
||||
end
|
||||
|
||||
function Public.reset_map()
|
||||
local this = Scrap_table.get_table()
|
||||
local wave_defense_table = WD.get_table()
|
||||
@ -261,21 +277,8 @@ function Public.reset_map()
|
||||
surface.create_entity({name = "electric-beam", position = {-196, 190}, source = {-196, 190}, target = {196,190}})
|
||||
|
||||
RPG.rpg_reset_all_players()
|
||||
end
|
||||
|
||||
local function set_difficulty()
|
||||
local wave_defense_table = WD.get_table()
|
||||
local player_count = #game.connected_players
|
||||
|
||||
wave_defense_table.max_active_biters = 1024
|
||||
|
||||
-- threat gain / wave
|
||||
wave_defense_table.threat_gain_multiplier = 2 + player_count * 0.1
|
||||
|
||||
|
||||
--20 Players for fastest wave_interval
|
||||
wave_defense_table.wave_interval = 3600 - player_count * 90
|
||||
if wave_defense_table.wave_interval < 1800 then wave_defense_table.wave_interval = 1800 end
|
||||
set_difficulty()
|
||||
end
|
||||
|
||||
local function is_protected(entity)
|
||||
@ -327,14 +330,15 @@ local function on_player_changed_position(event)
|
||||
if position.x >= 960 * 0.5 then return end
|
||||
if position.x < 960 * -0.5 then return end
|
||||
if position.y < 5 then
|
||||
if not this.players[player.index].tiles_enabled then goto continue end
|
||||
for x = -1,1 do
|
||||
for y = -1,1 do
|
||||
local _pos = {position.x+x,position.y+y}
|
||||
local steps = this.steps[player.index]
|
||||
local steps = this.players[player.index].steps
|
||||
local shallow, deepwater = surface.get_tile(_pos).name == "water-shallow", surface.get_tile(_pos).name == "deepwater-green"
|
||||
if shallow or deepwater then goto continue end
|
||||
change_tile(surface, _pos, steps)
|
||||
this.steps[player.index] = this.steps[player.index] + 1
|
||||
this.players[player.index].steps = this.players[player.index].steps + 1
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -360,16 +364,21 @@ local function on_player_joined_game(event)
|
||||
local surface = game.surfaces[this.active_surface_index]
|
||||
local player = game.players[event.player_index]
|
||||
|
||||
if not this.steps[player.index] then this.steps[player.index] = 0 end
|
||||
--if not this.scrap_enabled[player.index] then this.scrap_enabled[player.index] = true end
|
||||
|
||||
set_difficulty(event)
|
||||
|
||||
if not this.first_join[player.index] then
|
||||
player.print("[color=blue]Grandmaster:[/color] Greetings, newly joined [color=yellow]" .. player.name .. "[/color]!", {r = 1, g = 0.5, b = 0.1})
|
||||
player.print("[color=blue]Grandmaster:[/color] Do read the map info.", {r = 1, g = 0.5, b = 0.1})
|
||||
if not this.players[player.index] then this.players[player.index] = {
|
||||
tiles_enabled = true,
|
||||
steps = 0,
|
||||
first_join = false
|
||||
}
|
||||
end
|
||||
|
||||
if not this.players[player.index].first_join then
|
||||
player.print("[color=blue]Grandmaster:[/color] Greetings, newly joined " .. player.name .. "!", {r = 1, g = 0.5, b = 0.1})
|
||||
player.print("[color=blue]Grandmaster:[/color] Please read the map info.", {r = 1, g = 0.5, b = 0.1})
|
||||
player.print("[color=blue]Grandmaster:[/color] Guide the choo through the black mist.", {r = 1, g = 0.5, b = 0.1})
|
||||
this.first_join[player.index] = true
|
||||
player.print("[color=blue]Grandmaster:[/color] To disable rainbow mode, type in console: /rainbow_mode", Color.info)
|
||||
this.players[player.index].first_join = true
|
||||
end
|
||||
|
||||
if player.surface.index ~= this.active_surface_index then
|
||||
@ -511,6 +520,7 @@ function Public.loco_died()
|
||||
wave_defense_table.target = nil
|
||||
game.print("[color=blue]Grandmaster:[/color] Oh noooeeeew, they destroyed my train!", {r = 1, g = 0.5, b = 0.1})
|
||||
game.print("[color=blue]Grandmaster:[/color] Better luck next time.", {r = 1, g = 0.5, b = 0.1})
|
||||
game.print("[color=blue]Grandmaster:[/color] Game will soft-reset shortly.", {r = 1, g = 0.5, b = 0.1})
|
||||
for i = 1, 12, 1 do
|
||||
surface.create_entity({name = "big-artillery-explosion", position = this.locomotive.position})
|
||||
end
|
||||
@ -658,6 +668,12 @@ 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!"
|
||||
})
|
||||
T.main_caption_color = {r = 150, g = 150, b = 0}
|
||||
@ -684,7 +700,8 @@ local function darkness(this)
|
||||
local surface = game.surfaces[this.active_surface_index]
|
||||
if rnd(1, 64) == 1 then
|
||||
if surface.freeze_daytime then return end
|
||||
game.print("[color=blue]Grandmaster:[/color] A solar eclipse has occured!", {r = 1, g = 0.5, b = 0.1})
|
||||
game.print("[color=blue]Grandmaster:[/color] darkness has surrounded us!", {r = 1, g = 0.5, b = 0.1})
|
||||
game.print("[color=blue]Grandmaster:[/color] builds some lamps!", {r = 1, g = 0.5, b = 0.1})
|
||||
surface.min_brightness = 0.10
|
||||
surface.brightness_visual_weights = {0.90, 0.90, 0.90}
|
||||
surface.daytime = 0.42
|
||||
@ -693,10 +710,10 @@ local function darkness(this)
|
||||
return
|
||||
elseif rnd(1, 32) == 1 then
|
||||
if not surface.freeze_daytime then return end
|
||||
game.print("[color=blue]Grandmaster:[/color] Sunlight, finally!", {r = 1, g = 0.5, b = 0.1})
|
||||
game.print("[color=blue]Grandmaster:[/color] sunlight, finally!", {r = 1, g = 0.5, b = 0.1})
|
||||
surface.min_brightness = 1
|
||||
surface.brightness_visual_weights = {1, 0, 0, 0}
|
||||
surface.daytime = 0.5
|
||||
surface.daytime = 0.7
|
||||
surface.freeze_daytime = false
|
||||
surface.solar_power_multiplier = 1
|
||||
return
|
||||
@ -709,14 +726,14 @@ local function scrap_randomness(this)
|
||||
if rnd(1, 32) == 1 then
|
||||
if not this.scrap_enabled then return end
|
||||
this.scrap_enabled = false
|
||||
game.print("[color=blue]Grandmaster:[/color] It seems that the scrap is temporarily gone.", {r = 1, g = 0.5, b = 0.1})
|
||||
game.print("[color=blue]Grandmaster:[/color] Output from scrap is now only ores.", {r = 1, g = 0.5, b = 0.1})
|
||||
game.print("[color=blue]Grandmaster:[/color] it seems that the scrap is temporarily gone.", {r = 1, g = 0.5, b = 0.1})
|
||||
game.print("[color=blue]Grandmaster:[/color] output from scrap is now only ores.", {r = 1, g = 0.5, b = 0.1})
|
||||
return
|
||||
elseif rnd(1, 32) == 1 then
|
||||
if this.scrap_enabled then return end
|
||||
this.scrap_enabled = true
|
||||
game.print("[color=blue]Grandmaster:[/color] Scrap is back!", {r = 1, g = 0.5, b = 0.1})
|
||||
game.print("[color=blue]Grandmaster:[/color] Output from scrap is now randomized.", {r = 1, g = 0.5, b = 0.1})
|
||||
game.print("[color=blue]Grandmaster:[/color] scrap is back!", {r = 1, g = 0.5, b = 0.1})
|
||||
game.print("[color=blue]Grandmaster:[/color] output from scrap is now randomized.", {r = 1, g = 0.5, b = 0.1})
|
||||
return
|
||||
end
|
||||
end
|
||||
@ -738,6 +755,26 @@ local on_tick = function()
|
||||
end
|
||||
end
|
||||
|
||||
commands.add_command(
|
||||
'rainbow_mode',
|
||||
'This will prevent new tiles from spawning when walking',
|
||||
function(cmd)
|
||||
local player = game.player
|
||||
local this = Scrap_table.get_table()
|
||||
if player and player.valid then
|
||||
if this.players[player.index].tiles_enabled == false then
|
||||
this.players[player.index].tiles_enabled = true
|
||||
player.print("Rainbow mode: ON", Color.green)
|
||||
return
|
||||
end
|
||||
if this.players[player.index].tiles_enabled == true then
|
||||
this.players[player.index].tiles_enabled = false
|
||||
player.print("Rainbow mode: OFF", Color.warning)
|
||||
return
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
if _DEBUG then
|
||||
commands.add_command(
|
||||
'reset_game',
|
||||
@ -756,7 +793,7 @@ commands.add_command(
|
||||
end)
|
||||
end
|
||||
|
||||
Event.on_nth_tick(5, on_tick)
|
||||
Event.on_nth_tick(10, on_tick)
|
||||
Event.on_init(on_init)
|
||||
Event.add(defines.events.on_entity_damaged, on_entity_damaged)
|
||||
Event.add(defines.events.on_player_joined_game, on_player_joined_game)
|
||||
|
@ -3,6 +3,7 @@ local Scrap_table = require "maps.scrapyard.table"
|
||||
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
|
||||
@ -62,15 +63,8 @@ local function mining_chances_scrap()
|
||||
{name = "nuclear-fuel", chance = 1},
|
||||
{name = "pipe-to-ground", chance = 10},
|
||||
{name = "plastic-bar", chance = 5},
|
||||
{name = "processing-unit", chance = 2},
|
||||
{name = "used-up-uranium-fuel-cell", chance = 1},
|
||||
{name = "uranium-fuel-cell", chance = 1},
|
||||
{name = "rocket-fuel", chance = 3},
|
||||
{name = "rocket-control-unit", chance = 1},
|
||||
{name = "low-density-structure", chance = 1},
|
||||
{name = "heat-pipe", chance = 1},
|
||||
{name = "engine-unit", chance = 4},
|
||||
{name = "electric-engine-unit", chance = 2},
|
||||
{name = "logistic-robot", chance = 1},
|
||||
{name = "construction-robot", chance = 1},
|
||||
{name = "land-mine", chance = 3},
|
||||
@ -79,7 +73,6 @@ local function mining_chances_scrap()
|
||||
{name = "explosive-rocket", chance = 3},
|
||||
{name = "cannon-shell", chance = 2},
|
||||
{name = "explosive-cannon-shell", chance = 2},
|
||||
{name = "uranium-cannon-shell", chance = 1},
|
||||
{name = "explosive-uranium-cannon-shell", chance = 1},
|
||||
{name = "artillery-shell", chance = 1},
|
||||
{name = "cluster-grenade", chance = 2},
|
||||
@ -102,10 +95,10 @@ end
|
||||
|
||||
local function scrap_yield_amounts()
|
||||
local data = {
|
||||
["iron-ore"] = 10,
|
||||
["copper-ore"] = 10,
|
||||
["stone"] = 8,
|
||||
["coal"] = 6,
|
||||
["iron-ore"] = 28,
|
||||
["copper-ore"] = 28,
|
||||
["stone"] = 20,
|
||||
["coal"] = 28,
|
||||
["iron-plate"] = 4,
|
||||
["iron-gear-wheel"] = 6,
|
||||
["iron-stick"] = 6,
|
||||
@ -155,7 +148,8 @@ local function scrap_yield_amounts()
|
||||
["defender-capsule"] = 2,
|
||||
["destroyer-capsule"] = 0.3,
|
||||
["distractor-capsule"] = 0.3,
|
||||
["uranium-ore"] = 1
|
||||
["uranium-ore"] = 1,
|
||||
["mineable-wreckage"] = 1,
|
||||
}
|
||||
return data
|
||||
end
|
||||
@ -178,6 +172,29 @@ end
|
||||
|
||||
local size_of_ore_raffle = #scrap_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 * scrap_yield_amounts()[entity.name] * m)
|
||||
if amount < 1 then amount = 1 end
|
||||
|
||||
return amount
|
||||
end
|
||||
|
||||
local function scrap_randomness(data)
|
||||
local entity = data.entity
|
||||
local this = data.this
|
||||
@ -196,11 +213,7 @@ local function scrap_randomness(data)
|
||||
scrap = scrap_raffle_ores[math.random(1, size_of_ore_raffle)]
|
||||
end
|
||||
|
||||
local amount_bonus = (game.forces.enemy.evolution_factor * 2) + (game.forces.player.mining_drill_productivity_bonus * 2)
|
||||
local r1 = math.ceil(scrap_yield_amounts()[scrap] * (0.3 + (amount_bonus * 0.3)))
|
||||
local r2 = math.ceil(scrap_yield_amounts()[scrap] * (1.7 + (amount_bonus * 1.7)))
|
||||
if not r1 or not r2 then return end
|
||||
local amount = math.random(r1, r2)
|
||||
local amount = get_amount(data)
|
||||
|
||||
local position = {x = entity.position.x, y = entity.position.y}
|
||||
|
||||
|
@ -178,11 +178,11 @@ local function add_gui_increase_stat(element, name, player, width)
|
||||
e.style.minimal_width = 38
|
||||
e.style.font = "default-large-semibold"
|
||||
e.style.font_color = {0,0,0}
|
||||
e.style.horizontal_align = "center"
|
||||
e.style.vertical_align = "center"
|
||||
e.style.horizontal_align = "center"
|
||||
e.style.vertical_align = "center"
|
||||
e.style.padding = 0
|
||||
e.style.margin = 0
|
||||
e.tooltip = "Rightclick to allocate 5 points."
|
||||
e.style.margin = 0
|
||||
e.tooltip = "Right-click to allocate 3 points."
|
||||
|
||||
return e
|
||||
end
|
||||
|
@ -2,7 +2,22 @@
|
||||
local Global = require 'utils.global'
|
||||
local Event = require 'utils.event'
|
||||
|
||||
local this = {}
|
||||
local this = {
|
||||
players = {},
|
||||
game_lost = false,
|
||||
game_won = false,
|
||||
energy = {},
|
||||
wave_counter = 0,
|
||||
locomotive_health = 10000,
|
||||
locomotive_max_health = 10000,
|
||||
cargo_health = 10000,
|
||||
cargo_max_health = 10000,
|
||||
revealed_spawn = 0,
|
||||
scrap_enabled = true,
|
||||
rocks_yield_ore_maximum_amount = 999,
|
||||
rocks_yield_ore_base_amount = 50,
|
||||
rocks_yield_ore_distance_modifier = 0.025
|
||||
}
|
||||
local Public = {}
|
||||
|
||||
Global.register(
|
||||
@ -27,9 +42,7 @@ function Public.reset_table()
|
||||
this.cargo_health = 10000
|
||||
this.cargo_max_health = 10000
|
||||
this.revealed_spawn = 0
|
||||
this.steps = {}
|
||||
this.scrap_enabled = true
|
||||
this.first_join = {}
|
||||
end
|
||||
|
||||
function Public.get_table()
|
||||
|
Loading…
x
Reference in New Issue
Block a user