1
0
mirror of https://github.com/Refactorio/RedMew.git synced 2025-01-18 03:21:47 +02:00

Merge pull request #743 from plague006/create_market_on_launch

Create market on launch
This commit is contained in:
Matthew 2019-02-16 17:01:51 -05:00 committed by GitHub
commit e508c9133c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 116 additions and 113 deletions

View File

@ -88,6 +88,10 @@ global.config = {
-- adds a market
market = {
enabled = true,
-- will create a standard market on game startup
create_standard_market = true,
-- the coordinates at which the standard market will be created
standard_market_location = {x = 0, y = -5},
currency = currency,
-- defines the chance that killing an entity will drop coins and the min and max it can drop upon death

View File

@ -8,6 +8,7 @@ local Command = require 'utils.command'
local Global = require 'utils.global'
local Retailer = require 'features.retailer'
local Ranks = require 'resources.ranks'
local RS = require 'map_gen.shared.redmew_surface'
local market_items = require 'resources.market_items'
local fish_market_bonus_message = require 'resources.fish_messages'
@ -16,8 +17,9 @@ local pairs = pairs
local round = math.round
local random = math.random
local format = string.format
local currency = global.config.market.currency
local entity_drop_amount = global.config.market.entity_drop_amount
local market_config = global.config.market
local currency = market_config.currency
local entity_drop_amount = market_config.entity_drop_amount
-- local vars
@ -74,7 +76,7 @@ local function unregister_event()
end
local function spawn_market(args, player)
if args.removeall == 'removeall' then
if args and args.removeall == 'removeall' then
local count = 0
for _, market in pairs(markets) do
if market.valid then
@ -85,18 +87,22 @@ local function spawn_market(args, player)
player.print(count .. ' markets removed')
return
end
local surface = RS.get_surface()
local force = game.forces.player
local maket_spawn_pos = market_config.standard_market_location
local surface = player.surface
local force = player.force
if player then -- If we have a player, this is coming from a player running the command
surface = player.surface
force = player.force
maket_spawn_pos = player.position
maket_spawn_pos.y = round(maket_spawn_pos.y - 4)
maket_spawn_pos.x = round(maket_spawn_pos.x)
player.print('Market added. To remove it, highlight it with your cursor and use the /destroy command, or use /market removeall to remove all markets placed.')
end
local pos = player.position
pos.y = round(pos.y - 4)
pos.x = round(pos.x)
local market = surface.create_entity({name = 'market', position = pos})
local market = surface.create_entity({name = 'market', position = maket_spawn_pos})
markets[#markets + 1] = market
market.destructible = false
player.print('Market added. To remove it, highlight it with your cursor and use the /destroy command, or use /market removall to remove all markets placed.')
Retailer.add_market('fish_market', market)
@ -106,7 +112,7 @@ local function spawn_market(args, player)
end
end
force.add_chart_tag(surface, {icon = {type = 'item', name = currency}, position = pos, text = 'Market'})
force.add_chart_tag(surface, {icon = {type = 'item', name = currency}, position = maket_spawn_pos, text = 'Market'})
end
local function fish_earned(event, amount)
@ -317,3 +323,6 @@ Event.add(defines.events.on_entity_died, fish_drop_entity_died)
Event.add(Retailer.events.on_market_purchase, market_item_purchased)
Event.add(defines.events.on_player_crafted_item, fish_player_crafted_item)
Event.add(defines.events.on_player_created, player_created)
if global.config.market.create_standard_market then
Event.on_init(spawn_market)
end

View File

@ -23,6 +23,7 @@ RS.set_map_gen_settings(
MGSP.cliff_none
}
)
global.config.market.create_standard_market = false
ScenarioInfo.set_map_name('Christmas Tree of Terror')
ScenarioInfo.set_map_description("Triangle of death's Christmas cousin")

View File

@ -1,11 +1,8 @@
--[[
This map uses custom ore gen. When generating the map, under the resource settings tab use Size = 'None' for all resources.
]]
local b = require 'map_gen.shared.builders'
local Random = require 'map_gen.shared.random'
local degrees = require "utils.math".degrees
local math = require "utils.math"
local table = require "utils.table"
local degrees = require 'utils.math'.degrees
local math = require 'utils.math'
local table = require 'utils.table'
local Perlin = require 'map_gen.shared.perlin_noise'
local ore_seed1 = 1000
local ore_seed2 = ore_seed1 * 2
@ -40,9 +37,9 @@ market.entity_drop_amount = {
['medium-spitter'] = {low = 1, high = 3, chance = 0.05},
['big-spitter'] = {low = 1, high = 3, chance = 0.05},
['behemoth-spitter'] = {low = 1, high = 10, chance = 0.05},
['medium-biter'] = {low = 1, high = 3, chance = 0.05},
['big-biter'] = {low = 1, high = 5, chance = 0.05},
['behemoth-biter'] = {low = 1, high = 10, chance = 0.05}
['medium-biter'] = {low = 1, high = 3, chance = 0.05},
['big-biter'] = {low = 1, high = 5, chance = 0.05},
['behemoth-biter'] = {low = 1, high = 10, chance = 0.05}
}
-- Setup the scenario map information because everyone gets upset if you don't
@ -86,8 +83,8 @@ v_track = b.single_y_pattern(v_track, 15)
local square = b.rectangle(130, 130)
local ore_square = b.rectangle(20,20)
local small_ore_square = b.rectangle(18,18)
local ore_square = b.rectangle(20, 20)
local small_ore_square = b.rectangle(18, 18)
local leg = b.rectangle(32, 480)
local head = b.translate(b.oval(32, 64), 0, -64)
@ -107,7 +104,7 @@ local spider = b.any(list)
local function value(base, mult, pow)
return function(x, y)
local d_sq = x * x + y * y
return base + mult * d_sq ^ ( pow / 2 ) -- d ^ pow
return base + mult * d_sq ^ (pow / 2) -- d ^ pow
end
end
@ -146,7 +143,7 @@ for r = 1, 50 do
local row = {}
pattern[r] = row
for c = 1, 50 do
row[c] = square
row[c] = square
end
end
@ -157,34 +154,34 @@ for r = 1, 50 do
local row = {}
ore_pattern[r] = row
for c = 1, 50 do
local i = random_ore:next_int(1, ore_t)
local index = table.binary_search(total_ore_weights, i)
if (index < 0) then
index = bit32.bnot(index)
end
local ore_data = ores[index]
local i = random_ore:next_int(1, ore_t)
local index = table.binary_search(total_ore_weights, i)
if (index < 0) then
index = bit32.bnot(index)
end
local ore_data = ores[index]
local ore_shape = ore_data.transform(small_ore_square)
local ore = b.resource(ore_shape, ore_data.resource, ore_data.value)
local ore_shape = ore_data.transform(small_ore_square)
local ore = b.resource(ore_shape, ore_data.resource, ore_data.value)
local shape = ore_square
shape = b.apply_entity(shape, ore)
row[c] = shape
local shape = ore_square
shape = b.apply_entity(shape, ore)
row[c] = shape
end
end
-- create a mask to place over the ore grid
local mask_square = b.rectangle(60,60)
local mask_square = b.rectangle(60, 60)
mask_square = b.change_tile(mask_square, true, 'sand-1')
local mask_group = b.any{
local mask_group =
b.any {
mask_square,
b.translate(mask_square,90,0),
b.translate(mask_square,0,90),
b.translate(mask_square,90,90)
b.translate(mask_square, 90, 0),
b.translate(mask_square, 0, 90),
b.translate(mask_square, 90, 90)
}
mask_group = b.translate(mask_group,-60,-60)
mask_group = b.translate(mask_group, -60, -60)
-- sort out the starting ore patches
local start_patch = b.scale(spider, 0.1, 0.1)
@ -284,15 +281,14 @@ map = b.choose(b.rectangle(300, 300), start, map)
local resource_islands = b.grid_pattern(ore_pattern, 50, 50, 30, 30)
resource_islands = b.change_tile(resource_islands, true, 'sand-1')
local mask_pattern =
{
{mask_group, mask_group, mask_group},
local mask_pattern = {
{mask_group, mask_group, mask_group},
{mask_group, mask_group, mask_group},
{mask_group, mask_group, mask_group}
}
local resource_mask = b.grid_pattern(mask_pattern, 3, 3, 300, 300)
resource_mask = b.translate(resource_mask,-130,-130)
resource_mask = b.translate(resource_mask, -130, -130)
resource_islands = b.choose(resource_mask, resource_islands, b.empty_shape)
local paths =
@ -309,81 +305,76 @@ map = b.any {map, paths, resource_islands, sea}
map = b.change_map_gen_collision_tile(map, 'water-tile', 'grass-1')
local function on_init()
local surface = RS.get_surface()
local player_force = game.forces.player
local enemy_force = game.forces.enemy
player_force.technologies["landfill"].enabled = false -- disable landfill
player_force.technologies['landfill'].enabled = false -- disable landfill
--enemy_force.set_ammo_damage_modifier('melee', 1) -- +100% biter damage
enemy_force.set_ammo_damage_modifier('biological', 1) -- +100% spitter/worm damage
game.map_settings.enemy_expansion.enabled = true
-- Set up non-standard market so we can add logistics network things without editing a different file
Retailer.set_item('items', {price = 2, name = 'raw-fish'})
Retailer.set_item('items', {price = 1, name = 'rail'})
Retailer.set_item('items', {price = 2, name = 'rail-signal'})
Retailer.set_item('items', {price = 2, name = 'rail-chain-signal'})
Retailer.set_item('items', {price = 15, name = 'train-stop'})
Retailer.set_item('items', {price = 75, name = 'locomotive'})
Retailer.set_item('items', {price = 30, name = 'cargo-wagon'})
Retailer.set_item('items', {price = 15, name = 'steel-axe'})
Retailer.set_item('items', {price = 15, name = 'submachine-gun'})
Retailer.set_item('items', {price = 15, name = 'shotgun'})
Retailer.set_item('items', {price = 250, name = 'combat-shotgun'})
Retailer.set_item('items', {price = 25, name = 'railgun'})
Retailer.set_item('items', {price = 250, name = 'flamethrower'})
Retailer.set_item('items', {price = 175, name = 'rocket-launcher'})
Retailer.set_item('items', {price = 250, name = 'tank-cannon'})
Retailer.set_item('items', {price = 75, name = 'tank-flamethrower'})
Retailer.set_item('items', {price = 1, name = 'firearm-magazine'})
Retailer.set_item('items', {price = 5, name = 'piercing-rounds-magazine'})
Retailer.set_item('items', {price = 20, name = 'uranium-rounds-magazine'})
Retailer.set_item('items', {price = 2, name = 'shotgun-shell'})
Retailer.set_item('items', {price = 10, name = 'piercing-shotgun-shell'})
Retailer.set_item('items', {price = 5, name = 'railgun-dart'})
Retailer.set_item('items', {price = 25, name = 'flamethrower-ammo'})
Retailer.set_item('items', {price = 15, name = 'rocket'})
Retailer.set_item('items', {price = 25, name = 'explosive-rocket'})
Retailer.set_item('items', {price = 20, name = 'cannon-shell'})
Retailer.set_item('items', {price = 30, name = 'explosive-cannon-shell'})
Retailer.set_item('items', {price = 75, name = 'explosive-uranium-cannon-shell'})
Retailer.set_item('items', {price = 3, name = 'land-mine'})
Retailer.set_item('items', {price = 5, name = 'grenade'})
Retailer.set_item('items', {price = 35, name = 'cluster-grenade'})
Retailer.set_item('items', {price = 5, name = 'defender-capsule'})
Retailer.set_item('items', {price = 75, name = 'destroyer-capsule'})
Retailer.set_item('items', {price = 35, name = 'poison-capsule'})
Retailer.set_item('items', {price = 350, name = 'modular-armor'})
Retailer.set_item('items', {price = 875, name = 'power-armor'})
Retailer.set_item('items', {price = 40, name = 'solar-panel-equipment'})
Retailer.set_item('items', {price = 875, name = 'fusion-reactor-equipment'})
Retailer.set_item('items', {price = 100, name = 'battery-equipment'})
Retailer.set_item('items', {price = 625, name = 'battery-mk2-equipment'})
Retailer.set_item('items', {price = 250, name = 'belt-immunity-equipment'})
Retailer.set_item('items', {price = 100, name = 'night-vision-equipment'})
Retailer.set_item('items', {price = 150, name = 'exoskeleton-equipment'})
Retailer.set_item('items', {price = 250, name = 'personal-roboport-equipment'})
Retailer.set_item('items', {price = 10, name = 'construction-robot'})
Retailer.set_item('items', {price = 2, name = 'logistic-robot'})
Retailer.set_item('items', {price = 75, name = 'roboport'})
Retailer.set_item('items', {price = 50, name = 'logistic-chest-active-provider'})
Retailer.set_item('items', {price = 50, name = 'logistic-chest-passive-provider'})
Retailer.set_item('items', {price = 50, name = 'logistic-chest-requester'})
Retailer.set_item('items', {price = 50, name = 'logistic-chest-storage'})
Retailer.set_item('items', {price = 6, name = 'big-electric-pole'})
Retailer.set_item('items', {price = 3, name = 'medium-electric-pole'})
Retailer.set_item('items', {price = 50, name = 'substation'})
global.config.market.create_standard_market = false
Retailer.set_item('items', {price = 2, name = 'raw-fish'})
Retailer.set_item('items', {price = 1, name = 'rail'})
Retailer.set_item('items', {price = 2, name = 'rail-signal'})
Retailer.set_item('items', {price = 2, name = 'rail-chain-signal'})
Retailer.set_item('items', {price = 15, name = 'train-stop'})
Retailer.set_item('items', {price = 75, name = 'locomotive'})
Retailer.set_item('items', {price = 30, name = 'cargo-wagon'})
Retailer.set_item('items', {price = 15, name = 'steel-axe'})
Retailer.set_item('items', {price = 15, name = 'submachine-gun'})
Retailer.set_item('items', {price = 15, name = 'shotgun'})
Retailer.set_item('items', {price = 250, name = 'combat-shotgun'})
Retailer.set_item('items', {price = 25, name = 'railgun'})
Retailer.set_item('items', {price = 250, name = 'flamethrower'})
Retailer.set_item('items', {price = 175, name = 'rocket-launcher'})
Retailer.set_item('items', {price = 250, name = 'tank-cannon'})
Retailer.set_item('items', {price = 75, name = 'tank-flamethrower'})
Retailer.set_item('items', {price = 1, name = 'firearm-magazine'})
Retailer.set_item('items', {price = 5, name = 'piercing-rounds-magazine'})
Retailer.set_item('items', {price = 20, name = 'uranium-rounds-magazine'})
Retailer.set_item('items', {price = 2, name = 'shotgun-shell'})
Retailer.set_item('items', {price = 10, name = 'piercing-shotgun-shell'})
Retailer.set_item('items', {price = 5, name = 'railgun-dart'})
Retailer.set_item('items', {price = 25, name = 'flamethrower-ammo'})
Retailer.set_item('items', {price = 15, name = 'rocket'})
Retailer.set_item('items', {price = 25, name = 'explosive-rocket'})
Retailer.set_item('items', {price = 20, name = 'cannon-shell'})
Retailer.set_item('items', {price = 30, name = 'explosive-cannon-shell'})
Retailer.set_item('items', {price = 75, name = 'explosive-uranium-cannon-shell'})
Retailer.set_item('items', {price = 3, name = 'land-mine'})
Retailer.set_item('items', {price = 5, name = 'grenade'})
Retailer.set_item('items', {price = 35, name = 'cluster-grenade'})
Retailer.set_item('items', {price = 5, name = 'defender-capsule'})
Retailer.set_item('items', {price = 75, name = 'destroyer-capsule'})
Retailer.set_item('items', {price = 35, name = 'poison-capsule'})
Retailer.set_item('items', {price = 350, name = 'modular-armor'})
Retailer.set_item('items', {price = 875, name = 'power-armor'})
Retailer.set_item('items', {price = 40, name = 'solar-panel-equipment'})
Retailer.set_item('items', {price = 875, name = 'fusion-reactor-equipment'})
Retailer.set_item('items', {price = 100, name = 'battery-equipment'})
Retailer.set_item('items', {price = 625, name = 'battery-mk2-equipment'})
Retailer.set_item('items', {price = 250, name = 'belt-immunity-equipment'})
Retailer.set_item('items', {price = 100, name = 'night-vision-equipment'})
Retailer.set_item('items', {price = 150, name = 'exoskeleton-equipment'})
Retailer.set_item('items', {price = 250, name = 'personal-roboport-equipment'})
Retailer.set_item('items', {price = 10, name = 'construction-robot'})
Retailer.set_item('items', {price = 2, name = 'logistic-robot'})
Retailer.set_item('items', {price = 75, name = 'roboport'})
Retailer.set_item('items', {price = 50, name = 'logistic-chest-active-provider'})
Retailer.set_item('items', {price = 50, name = 'logistic-chest-passive-provider'})
Retailer.set_item('items', {price = 50, name = 'logistic-chest-requester'})
Retailer.set_item('items', {price = 50, name = 'logistic-chest-storage'})
Retailer.set_item('items', {price = 6, name = 'big-electric-pole'})
Retailer.set_item('items', {price = 3, name = 'medium-electric-pole'})
Retailer.set_item('items', {price = 50, name = 'substation'})
Retailer.set_market_group_label('items', 'Items Market')
local item_market_1 = surface.create_entity({name = 'market', position={0,0}})
Retailer.set_market_group_label('items', 'Items Market')
local item_market_1 = surface.create_entity({name = 'market', position = {0, 0}})
item_market_1.destructible = false
Retailer.add_market('items', item_market_1)
end
Event.on_init(on_init)

View File

@ -1,9 +1,7 @@
-- Map by grilledham, modified by Jayefuu
-- This map uses custom ore gen. When generating the map, under the resource settings tab use Size = 'None' for all resources.
-- This variation on grid_islands.lua has 1) Greater island separation 2) 4 not 2 rail tracks 3) Whole map rotated 45 degrees
-- For best balance run the following commands after map generation:
-- /market
-- /silent-command game.forces["player"].technologies["landfill"].enabled = false
-- /silent-command game.forces.player.character_running_speed_modifier = 1.5
-- /silent-command game.difficulty_settings.technology_price_multiplier=2

View File

@ -1,6 +1,5 @@
-- Map by Jayefuu and grilled ham, concept by claude47, 2018-12-02
-- Add market with /market
-- Hover over the market and run:
-- /silent-command game.player.selected.add_market_item{price={{MARKET_ITEM, 100}}, offer={type="give-item", item="landfill"}}

View File

@ -22,6 +22,7 @@ RS.set_map_gen_settings(
MGSP.cliff_none
}
)
global.config.market.create_standard_market = false
local generator