1
0
mirror of https://github.com/Refactorio/RedMew.git synced 2024-12-10 10:00:00 +02:00

Added configurable pollution to outposts

My plan is to make a harder crash site version where getting free resources from outposts creates pollution.

My intention is to balance it so it's still better to get items from outposts, but this commit is intended to give me a way to take saved games and test different amounts of pollution to check for balance. I don't intend to test this on live for a while but want to test it offline, this will give me the ability to turn it on half way through a game.

Need to consider how it doesn't take into account what the item is so it will be better to get free end-game items and probably limit how much iron we let into base later in the game. Might also create interesting meta where we are careful about what resources we take from outposts depending upon the pollution making setting.
This commit is contained in:
Jayefuu 2021-02-02 18:26:17 +00:00
parent eafb3d8bdd
commit d3aa8f18e0
2 changed files with 62 additions and 2 deletions

View File

@ -86,6 +86,8 @@ destroy=Destroys the entity under your cursor when you run this command
quick_bar_save=Saves your quick bars server-side for future maps
quick_bar_load=Loads your quick bars from the server (overwriting existing bars)
quick_bar_delete=Erases your saved quick bars from the server
set_pollution_multiplier=EXPERIMENTAL. An integer which gets multiplied by 0.01 to give the amount of pollution crash site magic crafters emit. Default is 0
get_pollution_multiplier=The current pollution multiplier for crash site. The default is 0.
[command_custom_help]
tp=<blank|mode|player> 3 different uses: "/tp" to tp to selected entity. "/tp mode" to toggle tp mode. "/tp Newcott" to tp to Newcott.

View File

@ -1,4 +1,6 @@
--local Random = require 'map_gen.shared.random'
local Command = require 'utils.command'
local Ranks = require 'resources.ranks'
local Token = require 'utils.token'
local Global = require 'utils.global'
local Event = require 'utils.event'
@ -61,6 +63,7 @@ local magic_fluid_crafters = {index = 1}
local outposts = {}
local artillery_outposts = {index = 1}
local outpost_count = 0
local pollution_multiplier = 0
Global.register(
{
@ -70,7 +73,9 @@ Global.register(
magic_crafters = magic_crafters,
magic_fluid_crafters = magic_fluid_crafters,
outposts = outposts,
artillery_outposts = artillery_outposts
artillery_outposts = artillery_outposts,
pollution_multiplier = pollution_multiplier
},
function(tbl)
refill_turrets = tbl.refil_turrets
@ -80,6 +85,7 @@ Global.register(
magic_fluid_crafters = tbl.magic_fluid_crafters
outposts = tbl.outposts
artillery_outposts = tbl.artillery_outposts
pollution_multiplier = tbl.pollution_multiplier
end
)
@ -1213,6 +1219,31 @@ local function do_artillery_turrets_targets()
end
end
local function set_pollution_multiplier(args, player)
game.print(args.multiplier)
local multipliers = {}
for m in string.gmatch(args.multiplier, "%-?%d+") do -- Assuming the surface name isn't a valid number.
table.insert(multipliers, tonumber(m))
end
if not multipliers or #multipliers ~= 1 then
game.player.print("Fail")
return
end
local old_multiplier = pollution_multiplier
pollution_multiplier = multipliers[1]
for _, p in pairs(game.players) do
if p.admin then
p.print(player.name..' changed magic crafter pollution multiplier from '..old_multiplier..' to '..pollution_multiplier)
end
end
end
local function get_pollution_multiplier(player)
game.player.print('Current pollution multiplier is: '..pollution_multiplier)
end
local function do_magic_crafters()
local limit = #magic_crafters
if limit == 0 then
@ -1247,7 +1278,11 @@ local function do_magic_crafters()
local fcount = floor(count)
if fcount > 0 then
if entity.get_output_inventory().can_insert(data.item) then -- No pollution once full. Taking items out of crafters makes pollution
local pollution_amount = pollution_multiplier * 0.01
entity.surface.pollute(entity.position, pollution_amount)
entity.get_output_inventory().insert {name = data.item, count = fcount}
end
data.last_tick = tick - (count - fcount) / rate
end
end
@ -1891,4 +1926,27 @@ Event.add(Retailer.events.on_market_purchase, do_outpost_upgrade)
Event.add(defines.events.on_selected_entity_changed, market_selected)
Command.add(
'set_pollution_multiplier',
{
description = {'command_description.set_pollution_multiplier'},
arguments = {'multiplier'},
required_rank = Ranks.admin,
capture_excess_arguments = true,
allowed_by_server = true
},
set_pollution_multiplier
)
Command.add(
'get_pollution_multiplier',
{
description = {'command_description.get_pollution_multiplier'},
required_rank = Ranks.admin,
capture_excess_arguments = true,
allowed_by_server = false
},
get_pollution_multiplier
)
return Public