mirror of
https://github.com/ComfyFactory/ComfyFactorio.git
synced 2025-02-07 13:31:40 +02:00
Hold and power purchase changes
Changes: - Extra hold and power upgrades now can only be purchased at captain's cabin instead of docks.
This commit is contained in:
parent
e9f5abe5f2
commit
f539fe2fb5
@ -424,11 +424,11 @@ local size_of_item_names = #item_names
|
||||
function Public.TweakItemWorth(updates)
|
||||
item_names = {}
|
||||
for k, v in pairs(updates) do
|
||||
item_worths[k] = v
|
||||
item_worths[k] = v
|
||||
end
|
||||
item_names = {}
|
||||
for k, _ in pairs(item_worths) do
|
||||
table_insert(item_names, k)
|
||||
table_insert(item_names, k)
|
||||
end
|
||||
|
||||
size_of_item_names = #item_names
|
||||
@ -532,9 +532,14 @@ end
|
||||
|
||||
--tier = float 0-1; 1 = everything unlocked
|
||||
function Public.get_tech_blacklist(tier)
|
||||
if not tier then
|
||||
return
|
||||
end
|
||||
|
||||
local blacklist = {}
|
||||
local size_of_tech_tier_list = #tech_tier_list
|
||||
local min_index = math_floor(size_of_tech_tier_list * tier)
|
||||
tier = math.clamp(tier, 0, 1)
|
||||
local min_index = math_floor(size_of_tech_tier_list * tier) + 1
|
||||
for i = size_of_tech_tier_list, min_index, -1 do
|
||||
blacklist[tech_tier_list[i]] = true
|
||||
end
|
||||
|
@ -178,7 +178,7 @@ market_description_upgrade_merchants=Unlock merchant ships on future islands.
|
||||
market_description_upgrade_rockets=Unlock the sale of rockets at island markets.
|
||||
market_description_purchase_class=Purchase the class __1__.
|
||||
market_description_extra_time_at_sea=Relax at sea: Increase the next destination's loading time by 60 seconds.
|
||||
|
||||
market_description_reroll_prices=Reroll prices.
|
||||
|
||||
market_event_sell=__1__ sold __2__ for __3__.
|
||||
market_event_trade=__1__ traded away __2__ for __3__.
|
||||
|
@ -8,6 +8,8 @@ local Utils = require 'maps.pirates.utils_local'
|
||||
local CoreData = require 'maps.pirates.coredata'
|
||||
local Memory = require 'maps.pirates.memory'
|
||||
local _inspect = require 'utils.inspect'.inspect
|
||||
|
||||
local LootRaffle = require 'functions.loot_raffle'
|
||||
-- local simplex_noise = require 'utils.simplex_noise'.d2
|
||||
-- local perlin_noise = require 'utils.perlin_noise'
|
||||
-- local Force_health_booster = require 'modules.force_health_booster'
|
||||
@ -1530,4 +1532,61 @@ function Public.is_id_valid(id)
|
||||
end
|
||||
end
|
||||
|
||||
-- NOTE: Items here are either unobtainable or hard to find/get
|
||||
-- Connected with crew.lua recipe and technology disables
|
||||
function Public.get_item_blacklist(tier)
|
||||
local blacklist = LootRaffle.get_tech_blacklist(tier)
|
||||
blacklist['landfill'] = true
|
||||
blacklist['concrete'] = true
|
||||
blacklist['hazard-concrete'] = true
|
||||
blacklist['locomotive'] = true
|
||||
blacklist['cargo-wagon'] = true
|
||||
blacklist['fluid-wagon'] = true
|
||||
blacklist['train-stop'] = true
|
||||
blacklist['rail-signal'] = true
|
||||
blacklist['rail-chain-signal'] = true
|
||||
blacklist['refined-concrete'] = true
|
||||
blacklist['refined-hazard-concrete'] = true
|
||||
blacklist['flamethrower-turret'] = true
|
||||
blacklist['tank'] = true
|
||||
blacklist['cannon-shell'] = true
|
||||
blacklist['explosive-cannon-shell'] = true
|
||||
blacklist['speed-module-3'] = true
|
||||
blacklist['productivity-module-3'] = true
|
||||
blacklist['effectivity-module-3'] = true
|
||||
blacklist['space-science-pack'] = true
|
||||
blacklist['rocket-control-unit'] = true
|
||||
blacklist['artillery-wagon'] = true
|
||||
blacklist['artillery-turret'] = true
|
||||
blacklist['artillery-targeting-remote'] = true
|
||||
blacklist['uranium-cannon-shell'] = true
|
||||
blacklist['explosive-uranium-cannon-shell'] = true
|
||||
blacklist['satellite'] = true
|
||||
blacklist['rocket-silo'] = true
|
||||
blacklist['destroyer-capsule'] = true
|
||||
blacklist['spidertron'] = true
|
||||
blacklist['discharge-defense-remote'] = true
|
||||
blacklist['discharge-defense-equipment'] = true
|
||||
blacklist['express-loader'] = true
|
||||
blacklist['land-mine'] = true
|
||||
blacklist['wood'] = true -- too easy to acquire
|
||||
|
||||
return blacklist
|
||||
end
|
||||
|
||||
-- tier: affects amount of items and rarity returned
|
||||
-- scale: final result of formula with tier scaled
|
||||
-- tech_tier: float in range [0; 1]; 1 = everything unlocked
|
||||
function Public.pick_random_price(tier, scale, tech_tier)
|
||||
if tier < 0 or scale < 0 then return end
|
||||
|
||||
local item_stacks = LootRaffle.roll(math.floor(scale * (tier ^ 2 + 10 * tier)), 100, Public.get_item_blacklist(tech_tier))
|
||||
local price = {}
|
||||
for _, item_stack in pairs(item_stacks) do
|
||||
price[#price+1] = {name = item_stack.name, amount = item_stack.count}
|
||||
end
|
||||
|
||||
return price
|
||||
end
|
||||
|
||||
return Public
|
@ -806,7 +806,7 @@ function Public.summon_crew()
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
-- NOTE: Connected with common.lua item blacklist
|
||||
function Public.reset_crew_and_enemy_force(id)
|
||||
local crew_force = game.forces[Common.get_crew_force_name(id)]
|
||||
local enemy_force = game.forces[Common.get_enemy_force_name(id)]
|
||||
@ -979,7 +979,7 @@ function Public.reset_crew_and_enemy_force(id)
|
||||
crew_force.technologies['speed-module'].enabled = true
|
||||
crew_force.technologies['speed-module-2'].enabled = false
|
||||
crew_force.technologies['speed-module-3'].enabled = false
|
||||
crew_force.technologies['effectivity-module'].enabled = false
|
||||
crew_force.technologies['effectivity-module'].enabled = true
|
||||
crew_force.technologies['effectivity-module-2'].enabled = false
|
||||
crew_force.technologies['effectivity-module-3'].enabled = false
|
||||
crew_force.technologies['automation-3'].enabled = true
|
||||
@ -1028,7 +1028,7 @@ function Public.reset_crew_and_enemy_force(id)
|
||||
Public.disable_recipes(crew_force)
|
||||
end
|
||||
|
||||
|
||||
-- NOTE: Connected with common.lua item blacklist
|
||||
function Public.disable_recipes(crew_force)
|
||||
crew_force.recipes['pistol'].enabled = false
|
||||
-- crew_force.recipes['centrifuge'].enabled = false
|
||||
|
@ -349,18 +349,20 @@ function Public.generate_overworld_destination(p)
|
||||
-- end
|
||||
boat_for_sale_type = Boats.enum.SLOOP
|
||||
|
||||
local upgrade_for_sale
|
||||
if macro_p.x == 0 then
|
||||
upgrade_for_sale = nil
|
||||
elseif macro_p.x == 3 then
|
||||
upgrade_for_sale = Upgrades.enum.MORE_POWER
|
||||
elseif macro_p.x == 7 then
|
||||
upgrade_for_sale = Upgrades.enum.EXTRA_HOLD
|
||||
elseif macro_p.x % 16 < 8 then
|
||||
upgrade_for_sale = Upgrades.enum.MORE_POWER
|
||||
else
|
||||
upgrade_for_sale = Upgrades.enum.EXTRA_HOLD
|
||||
end --upgrades like UNLOCK_MERCHANTS will slot themselves in when necessary, due to .overwrite_a_dock_upgrade()
|
||||
local upgrade_for_sale = nil
|
||||
-- These upgrades have been made to be exclusive purchase at captain's cabin
|
||||
-- local upgrade_for_sale
|
||||
-- if macro_p.x == 0 then
|
||||
-- upgrade_for_sale = nil
|
||||
-- elseif macro_p.x == 3 then
|
||||
-- upgrade_for_sale = Upgrades.enum.MORE_POWER
|
||||
-- elseif macro_p.x == 7 then
|
||||
-- upgrade_for_sale = Upgrades.enum.EXTRA_HOLD
|
||||
-- elseif macro_p.x % 16 < 8 then
|
||||
-- upgrade_for_sale = Upgrades.enum.MORE_POWER
|
||||
-- else
|
||||
-- upgrade_for_sale = Upgrades.enum.EXTRA_HOLD
|
||||
-- end --upgrades like UNLOCK_MERCHANTS will slot themselves in when necessary, due to .overwrite_a_dock_upgrade()
|
||||
-- one day it's worth making this system more readable
|
||||
|
||||
local static_params = Utils.deepcopy(Dock.Data.static_params_default)
|
||||
|
@ -134,6 +134,7 @@ function Public.go_from_starting_dock_to_first_destination()
|
||||
Shop.Captains.initialise_captains_shop()
|
||||
|
||||
Hold.create_hold_surface(1)
|
||||
boat.EEI_stage = 1
|
||||
Cabin.create_cabin_surface()
|
||||
|
||||
local items = Balance.starting_items_crew_upstairs()
|
||||
@ -169,7 +170,6 @@ function Public.go_from_starting_dock_to_first_destination()
|
||||
-- go:
|
||||
-- Public.progress_to_destination(1) --index of first destination
|
||||
|
||||
boat.EEI_stage = 1
|
||||
Boats.update_EEIs(boat)
|
||||
|
||||
-- if Common.difficulty_scale() == 1 then
|
||||
|
@ -4,7 +4,7 @@
|
||||
local Memory = require 'maps.pirates.memory'
|
||||
-- local Roles = require 'maps.pirates.roles.roles'
|
||||
local Classes = require 'maps.pirates.roles.classes'
|
||||
local Crew = require 'maps.pirates.crew'
|
||||
-- local Crew = require 'maps.pirates.crew'
|
||||
-- local Boats = require 'maps.pirates.structures.boats.boats'
|
||||
-- local Dock = require 'maps.pirates.surfaces.dock'
|
||||
local Balance = require 'maps.pirates.balance'
|
||||
@ -15,6 +15,7 @@ local Math = require 'maps.pirates.math'
|
||||
local _inspect = require 'utils.inspect'.inspect
|
||||
local SurfacesCommon = require 'maps.pirates.surfaces.common'
|
||||
local Upgrades = require 'maps.pirates.boat_upgrades'
|
||||
local Cabin = require 'maps.pirates.surfaces.cabin'
|
||||
-- local Upgrades = require 'maps.pirates.boat_upgrades'
|
||||
|
||||
local Public = {}
|
||||
@ -302,25 +303,36 @@ function Public.event_on_market_item_purchased(event)
|
||||
end
|
||||
else
|
||||
-- print:
|
||||
if (thisPurchaseData.price and thisPurchaseData.price[1]) then
|
||||
if not (thisPurchaseData.price[1].name and thisPurchaseData.price[1].name == 'burner-mining-drill') then --this one is too boring to announce
|
||||
if thisPurchaseData.in_captains_cabin and thisPurchaseData.offer_type == 'nothing' then
|
||||
Common.notify_force_light(player.force, {'pirates.market_event_buy', player.name, {'pirates.extra_time_at_sea'}, thisPurchaseData.price[1].amount .. ' ' .. thisPurchaseData.price[1].name})
|
||||
else
|
||||
Public.print_transaction(player, trade_count - refunds, thisPurchaseData.offer_giveitem_name, thisPurchaseData.offer_giveitem_count, thisPurchaseData.price)
|
||||
end
|
||||
end
|
||||
end
|
||||
-- if (thisPurchaseData.price and thisPurchaseData.price[1]) then
|
||||
-- if not (thisPurchaseData.price[1].name and thisPurchaseData.price[1].name == 'burner-mining-drill') then --this one is too boring to announce
|
||||
-- if thisPurchaseData.in_captains_cabin and thisPurchaseData.offer_type == 'nothing' then
|
||||
-- Common.notify_force_light(player.force, {'pirates.market_event_buy', player.name, {'pirates.extra_time_at_sea'}, thisPurchaseData.price[1].amount .. ' ' .. thisPurchaseData.price[1].name})
|
||||
-- else
|
||||
-- Public.print_transaction(player, trade_count - refunds, thisPurchaseData.offer_giveitem_name, thisPurchaseData.offer_giveitem_count, thisPurchaseData.price)
|
||||
-- end
|
||||
-- end
|
||||
-- end
|
||||
|
||||
if thisPurchaseData.in_captains_cabin and thisPurchaseData.offer_type == 'nothing' then
|
||||
local success = Crew.try_add_extra_time_at_sea(60 * 60)
|
||||
if not success then
|
||||
Common.notify_player_error(player, {'pirates.market_error_maximum_loading_time'})
|
||||
-- refund:
|
||||
Public.refund_items(player, thisPurchaseData.price, 1)
|
||||
refunds = refunds + 1
|
||||
if offer_index == Cabin.enum.SLOT_EXTRA_HOLD then
|
||||
Upgrades.execute_upgade(Upgrades.enum.EXTRA_HOLD, player)
|
||||
elseif offer_index == Cabin.enum.SLOT_MORE_POWER then
|
||||
Upgrades.execute_upgade(Upgrades.enum.MORE_POWER, player)
|
||||
end
|
||||
|
||||
Cabin.handle_purchase(market, offer_index)
|
||||
|
||||
-- local success = Crew.try_add_extra_time_at_sea(60 * 60)
|
||||
-- if not success then
|
||||
-- Common.notify_player_error(player, {'pirates.market_error_maximum_loading_time'})
|
||||
-- -- refund:
|
||||
-- Public.refund_items(player, thisPurchaseData.price, 1)
|
||||
-- refunds = refunds + 1
|
||||
-- end
|
||||
else
|
||||
if thisPurchaseData.price and thisPurchaseData.price[1] then
|
||||
Public.print_transaction(player, trade_count - refunds, thisPurchaseData.offer_giveitem_name, thisPurchaseData.offer_giveitem_count, thisPurchaseData.price)
|
||||
end
|
||||
|
||||
if thisPurchaseData.decay_type == 'static' then
|
||||
if not inv then return end
|
||||
|
@ -157,7 +157,7 @@ end
|
||||
|
||||
|
||||
function Public.update_EEIs(boat)
|
||||
local EEI_stage = boat.EEI_stage or 1
|
||||
local EEI_stage = boat.EEI_stage
|
||||
|
||||
local multiplier
|
||||
if EEI_stage > #Balance.EEI_stages then --sensible out of bounds behaviour:
|
||||
|
@ -11,8 +11,12 @@ local _inspect = require 'utils.inspect'.inspect
|
||||
local SurfacesCommon = require 'maps.pirates.surfaces.common'
|
||||
|
||||
local Public = {}
|
||||
|
||||
local enum = {
|
||||
DEFAULT = 'Default',
|
||||
SLOT_EXTRA_HOLD = 5,
|
||||
SLOT_MORE_POWER = 6,
|
||||
SLOT_REROLL_PRICES = 7,
|
||||
}
|
||||
Public.enum = enum
|
||||
|
||||
@ -95,7 +99,7 @@ Public.Data.input_chests = {
|
||||
|
||||
Public.Data.surfacename_rendering_pos = {x = -0.5, y = -15}
|
||||
|
||||
|
||||
Public.market_price_scale = 300
|
||||
|
||||
Public.cabin_shop_data = {
|
||||
{
|
||||
@ -114,6 +118,18 @@ Public.cabin_shop_data = {
|
||||
price = {{'coin', 1000}, {'explosives', 5}},
|
||||
offer = {type='give-item', item = 'cliff-explosives', count = 5},
|
||||
},
|
||||
{
|
||||
price = {}, -- price set later
|
||||
offer = {type='nothing', effect_description={'pirates.market_description_upgrade_hold'}}
|
||||
},
|
||||
{
|
||||
price = {}, -- price set later
|
||||
offer = {type='nothing', effect_description={'pirates.market_description_upgrade_power'}}
|
||||
},
|
||||
{
|
||||
price = {{'coin', 100}, {'raw-fish', 1}},
|
||||
offer = {type='nothing', effect_description={'pirates.market_description_reroll_prices'}}
|
||||
},
|
||||
--disabled now that we can wait after any destination:
|
||||
-- {
|
||||
-- price = {{'coin', 25}},
|
||||
@ -265,7 +281,8 @@ function Public.create_cabin_surface()
|
||||
e.destructible = false
|
||||
e.minable = false
|
||||
e.rotatable = false
|
||||
for _, offer in pairs(Public.cabin_shop_data) do
|
||||
for i, offer in pairs(Public.cabin_shop_data) do
|
||||
offer.price = Public.get_market_random_price(i) or offer.price
|
||||
e.add_market_item(offer)
|
||||
end
|
||||
end
|
||||
@ -333,4 +350,29 @@ function Public.chunk_structures()
|
||||
return nil
|
||||
end
|
||||
|
||||
function Public.handle_purchase(market, slot)
|
||||
local offers = market.get_market_items()
|
||||
market.clear_market_items()
|
||||
for i, offer in pairs(offers) do
|
||||
if i == slot or slot == enum.SLOT_REROLL_PRICES then
|
||||
offer.price = Public.get_market_random_price(i) or offer.price
|
||||
end
|
||||
market.add_market_item(offer)
|
||||
end
|
||||
end
|
||||
|
||||
function Public.get_market_random_price(slot)
|
||||
local memory = Memory.get_crew_memory()
|
||||
|
||||
if slot == enum.SLOT_EXTRA_HOLD then
|
||||
local tier = memory.hold_surface_count
|
||||
return Common.pick_random_price(tier, Public.market_price_scale, math.min(0.8, 0.05 + tier * 0.2))
|
||||
elseif slot == enum.SLOT_MORE_POWER then
|
||||
local tier = memory.boat.EEI_stage
|
||||
return Common.pick_random_price(tier, 0.5*Public.market_price_scale, math.min(0.8, 0.05 + tier * 0.2))
|
||||
end
|
||||
|
||||
return nil
|
||||
end
|
||||
|
||||
return Public
|
@ -1,3 +1,6 @@
|
||||
-- This file is part of thesixthroc's Pirate Ship softmod, licensed under GPLv3 and stored at https://github.com/danielmartin0/ComfyFactorio-Pirates.
|
||||
|
||||
|
||||
local Public = {}
|
||||
|
||||
local enum = {
|
||||
|
@ -519,6 +519,7 @@ function Public.generate_detailed_island_data(destination)
|
||||
tiles = tiles3,
|
||||
entities = entities3,
|
||||
decoratives = {},
|
||||
specials = {},
|
||||
seed = destination.seed,
|
||||
iconized_generation = true
|
||||
}
|
||||
@ -631,6 +632,7 @@ function Public.generate_detailed_island_data(destination)
|
||||
tiles = tiles3,
|
||||
entities = {},
|
||||
decoratives = {},
|
||||
specials = {},
|
||||
seed = destination.seed,
|
||||
iconized_generation = true
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user