diff --git a/locale/en/pirates.cfg b/locale/en/pirates.cfg index 75c6fd3b..62c5d37b 100644 --- a/locale/en/pirates.cfg +++ b/locale/en/pirates.cfg @@ -632,4 +632,7 @@ cmd_explain_clear_south_tanks=Clear ship's south fluid storage tanks on deck and cmd_explain_dev=is a dev command. gui_crew_window_spectator_controls=Spectator Controls -gui_crew_window_spectator_goto_surface=Go to Surface \ No newline at end of file +gui_crew_window_spectator_goto_surface=Go to Surface + +market_description_purchase_attack_upgrade=10% damage upgrade for the crew. +market_event_attack_upgrade_purchased=__1__ bought a 10% damage upgrade for the crew. \ No newline at end of file diff --git a/maps/pirates/api_events.lua b/maps/pirates/api_events.lua index be617ddf..8354a9d9 100644 --- a/maps/pirates/api_events.lua +++ b/maps/pirates/api_events.lua @@ -1410,39 +1410,11 @@ function Public.research_apply_buffs(event) end -function Public.apply_flamer_nerfs() - local memory = Memory.get_crew_memory() - -- local difficulty = memory.difficulty - local force = memory.force - - -- This code matches the vanilla game. Written by Hanakocz I think. - local flame_researches = { - [1] = {name = 'refined-flammables-1', bonus = 0.2}, - [2] = {name = 'refined-flammables-2', bonus = 0.2}, - [3] = {name = 'refined-flammables-3', bonus = 0.2}, - [4] = {name = 'refined-flammables-4', bonus = 0.3}, - [5] = {name = 'refined-flammables-5', bonus = 0.3}, - [6] = {name = 'refined-flammables-6', bonus = 0.4}, - [7] = {name = 'refined-flammables-7', bonus = 0.2} - } - local flamer_power = 0 - for i = 1, 6, 1 do - if force.technologies[flame_researches[i].name].researched then - flamer_power = flamer_power + flame_researches[i].bonus - end - end - flamer_power = flamer_power + (force.technologies[flame_researches[7].name].level - 7) * 0.2 - - -- TODO: Check this code is valid after Factorio 2.0 - force.set_ammo_damage_modifier('flamethrower', flamer_power * Balance.flamers_tech_multipliers() + (1 - Balance.flamers_base_damage_multiplier())) - force.set_turret_attack_modifier('flamethrower-turret', flamer_power * Balance.flamers_tech_multipliers() + (1 - Balance.flamers_base_damage_multiplier())) -end - local function event_on_research_finished(event) -- figure out which crew this is about: local research = event.research - local p_force = research.force - local crew_id = Common.get_id_from_force_name(p_force.name) + local force = research.force + local crew_id = Common.get_id_from_force_name(force.name) Memory.set_working_id(crew_id) local memory = Memory.get_crew_memory() @@ -1453,42 +1425,39 @@ local function event_on_research_finished(event) Server.to_discord_embed_raw({'', '[' .. memory.name .. '] ', {'pirates.research_notification', game.technology_prototypes[research.name].localised_name}}, true) end - Public.apply_flamer_nerfs() - -- Public.research_apply_buffs(event) -- this is broken right now - for _, e in ipairs(research.effects) do - local t = e.type + local t = e.type if t == 'ammo-damage' then local category = e.ammo_category local factor = Balance.player_ammo_damage_modifiers()[category] if factor then - local current_m = p_force.get_ammo_damage_modifier(category) + local current_m = force.get_ammo_damage_modifier(category) local m = e.modifier - p_force.set_ammo_damage_modifier(category, current_m + factor * m) + force.set_ammo_damage_modifier(category, current_m + factor * m) end elseif t == 'gun-speed' then local category = e.ammo_category local factor = Balance.player_gun_speed_modifiers()[category] if factor then - local current_m = p_force.get_gun_speed_modifier(category) + local current_m = force.get_gun_speed_modifier(category) local m = e.modifier - p_force.set_gun_speed_modifier(category, current_m + factor * m) + force.set_gun_speed_modifier(category, current_m + factor * m) end elseif t == 'turret-attack' then local category = e.ammo_category local factor = Balance.player_turret_attack_modifiers()[category] if factor then - local current_m = p_force.get_turret_attack_modifier(category) + local current_m = force.get_turret_attack_modifier(category) local m = e.modifier - p_force.set_turret_attack_modifier(category, current_m + factor * m) + force.set_turret_attack_modifier(category, current_m + factor * m) end end end - Crew.disable_recipes(p_force) + Crew.disable_recipes(force) end local function event_on_player_joined_game(event) diff --git a/maps/pirates/balance.lua b/maps/pirates/balance.lua index d5a9e82d..d8d07565 100644 --- a/maps/pirates/balance.lua +++ b/maps/pirates/balance.lua @@ -501,14 +501,19 @@ end function Public.class_cost(at_dock) if at_dock then - return 10000 + return 8000 else - return 6000 + return 5000 end -- return Math.ceil(10000 / (Public.crew_scale()*10/4)^(1/6)) end +function Public.weapon_damage_upgrade_price() + return {{name = 'coin', amount = 4000}, {name = 'steel-plate', amount = 100}} --NOTE: Should be different to other 'nothing' costs. See the use of this function in shop.lua. +end + + Public.quest_structures_first_appear_at = 40 Public.coin_sell_amount = 300 @@ -616,10 +621,10 @@ end Public.research_buffs = { --currently disabled anyway -- these already give .1 productivity so we're adding .1 to get to 20% - ['mining-productivity-1'] = {['mining_drill_productivity_bonus'] = .2}, - ['mining-productivity-2'] = {['mining_drill_productivity_bonus'] = .2}, - ['mining-productivity-3'] = {['mining_drill_productivity_bonus'] = .2}, - ['mining-productivity-4'] = {['mining_drill_productivity_bonus'] = .2}, + ['mining-productivity-1'] = {['mining_drill_productivity_bonus'] = .1}, + ['mining-productivity-2'] = {['mining_drill_productivity_bonus'] = .1}, + ['mining-productivity-3'] = {['mining_drill_productivity_bonus'] = .1}, + ['mining-productivity-4'] = {['mining_drill_productivity_bonus'] = .1}, -- -- these already give .1 productivity so we're adding .1 to get to 20% -- ['mining-productivity-1'] = {['mining-drill-productivity-bonus'] = .1, ['character-inventory-slots-bonus'] = 5}, -- ['mining-productivity-2'] = {['mining-drill-productivity-bonus'] = .1, ['character-inventory-slots-bonus'] = 5}, @@ -627,18 +632,6 @@ Public.research_buffs = { --currently disabled anyway -- ['mining-productivity-4'] = {['mining-drill-productivity-bonus'] = .1, ['character-inventory-slots-bonus'] = 5}, } - -function Public.flamers_tech_multipliers() - return 0.4 -end - -function Public.flamers_base_damage_multiplier() - return 0.4 -end - - - - function Public.player_ammo_damage_modifiers() -- modifiers are fractional. bullet affects gun turrets, but flamethrower does not affect flamer turrets local data = { ['artillery-shell'] = 0, @@ -647,7 +640,7 @@ function Public.player_ammo_damage_modifiers() -- modifiers are fractional. bull ['cannon-shell'] = 0, ['capsule'] = 0, ['electric'] = 0, - ['flamethrower'] = 0, --these nerfs are elsewhere for finer control + ['flamethrower'] = -0.6, --these nerfs are elsewhere for finer control ['grenade'] = -0.05, ['landmine'] = 0, ['melee'] = 0, -- doesn't do anything apparently @@ -661,6 +654,7 @@ function Public.player_turret_attack_modifiers() ['gun-turret'] = 0, ['artillery-turret'] = 0, ['laser-turret'] = 0, + ['flamethrower-turret'] = -0.6, } return data end @@ -672,7 +666,7 @@ function Public.player_gun_speed_modifiers() ['cannon-shell'] = 0, ['capsule'] = 0, ['electric'] = 0, - ['flamethrower'] = 0, --these nerfs are elsewhere for finer control + ['flamethrower'] = 0, ['grenade'] = -0.25, ['landmine'] = 0, ['melee'] = 0, -- doesn't do anything apparently diff --git a/maps/pirates/crew.lua b/maps/pirates/crew.lua index f92fa032..6da2a74c 100644 --- a/maps/pirates/crew.lua +++ b/maps/pirates/crew.lua @@ -700,22 +700,27 @@ function Public.initialise_crew(accepted_proposal) local global_memory = Memory.get_global_memory() local new_id = Public.generate_new_crew_id() - - global_memory.crew_active_ids[#global_memory.crew_active_ids + 1] = new_id - - Memory.initialise_crew_memory(new_id) - Memory.set_working_id(new_id) + if not new_id then return end game.reset_time_played() -- affects the multiplayer lobby view + global_memory.crew_active_ids[#global_memory.crew_active_ids + 1] = new_id + + global_memory.crew_memories[new_id] = {} + + Memory.set_working_id(new_id) + local memory = Memory.get_crew_memory() + memory.id = new_id + + memory.game_lost = false + memory.game_won = false + local secs = Server.get_current_time() if not secs then secs = 0 end memory.secs_id = secs - memory.id = new_id - memory.force_name = Common.get_crew_force_name(new_id) memory.enemy_force_name = Common.get_enemy_force_name(new_id) memory.ancient_enemy_force_name = Common.get_ancient_hostile_force_name(new_id) @@ -822,6 +827,53 @@ function Public.initialise_crew(accepted_proposal) boat.dockedposition = boat.position boat.speed = 0 boat.cannonscount = 2 + + Public.set_initial_damage_modifiers() +end + +function Public.set_initial_damage_modifiers() + local memory = Memory.get_crew_memory() + local force = memory.force + + local ammo_damage_modifiers = Balance.player_ammo_damage_modifiers() + local turret_attack_modifiers = Balance.player_turret_attack_modifiers() + local gun_speed_modifiers = Balance.player_gun_speed_modifiers() + + for category, factor in pairs(ammo_damage_modifiers) do + force.set_ammo_damage_modifier(category, factor) + end + + for category, factor in pairs(turret_attack_modifiers) do + force.set_turret_attack_modifier(category, factor) + end + + for category, factor in pairs(gun_speed_modifiers) do + force.set_gun_speed_modifier(category, factor) + end +end + +function Public.buff_all_damage(amount) + local memory = Memory.get_crew_memory() + local force = memory.force + + local ammo_damage_modifiers = Balance.player_ammo_damage_modifiers() + local turret_attack_modifiers = Balance.player_turret_attack_modifiers() + local gun_speed_modifiers = Balance.player_gun_speed_modifiers() + + for category, factor in pairs(ammo_damage_modifiers) do + local current_modifier = force.get_ammo_damage_modifier(category) + force.set_ammo_damage_modifier(category, current_modifier + amount * (1 + factor)) + end + + for category, factor in pairs(turret_attack_modifiers) do + local current_modifier = force.get_turret_attack_modifier(category) + force.set_turret_attack_modifier(category, current_modifier + amount * (1 + factor)) + end + + for category, factor in pairs(gun_speed_modifiers) do + local current_modifier = force.get_gun_speed_modifier(category) + force.set_gun_speed_modifier(category, current_modifier + amount * (1 + factor)) + end end diff --git a/maps/pirates/memory.lua b/maps/pirates/memory.lua index 6c1ebcca..059d6d34 100644 --- a/maps/pirates/memory.lua +++ b/maps/pirates/memory.lua @@ -41,15 +41,6 @@ function Public.global_reset_memory() pirates_global_memory.last_players_health = {} --used to make damage reduction work somewhat properly end -function Public.initialise_crew_memory(id) - - pirates_global_memory.crew_memories[id] = {} - local memory = pirates_global_memory.crew_memories[id] - - memory.game_lost = false - memory.game_won = false -end - function Public.fallthrough_crew_memory() --could make this a metatable, but metatables and factorio global seem not to play nicely return { id = 0, diff --git a/maps/pirates/overworld.lua b/maps/pirates/overworld.lua index fd14860f..7eb0dfb1 100644 --- a/maps/pirates/overworld.lua +++ b/maps/pirates/overworld.lua @@ -52,7 +52,7 @@ local C = {STANDARD, STANDARD2, RED_DESERT, HORSESHOE, WALKWAYS} local D = {NIL, NIL, NIL, STANDARD, STANDARD2, RED_DESERT, HORSESHOE, WALKWAYS, SWAMP, CAVE} local destinationScheme = { - [0] = {HORSESHOE, NIL, NIL}, + [0] = {FIRST, NIL, NIL}, [1] = {HORSESHOE, HORSESHOE, HORSESHOE}, --map where you break rocks [2] = {STANDARD2, STANDARD2, STANDARD2}, --aesthetically different to previous map [3] = {DOCK, NIL, NIL}, diff --git a/maps/pirates/shop/shop.lua b/maps/pirates/shop/shop.lua index 7094fe42..fbe64372 100644 --- a/maps/pirates/shop/shop.lua +++ b/maps/pirates/shop/shop.lua @@ -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' @@ -223,25 +223,35 @@ function Public.event_on_market_item_purchased(event) else - if thisPurchaseData.offer_type == 'nothing' and destination.static_params.class_for_sale then + if thisPurchaseData.offer_type == 'nothing' then + local isDamageUpgrade = thisPurchaseData.price[1].amount == Balance.weapon_damage_upgrade_price()[1].amount and thisPurchaseData.price[1].name == Balance.weapon_damage_upgrade_price()[1].name and thisPurchaseData.price[2] and thisPurchaseData.price[2].amount == Balance.weapon_damage_upgrade_price()[2].amount and thisPurchaseData.price[2].name == Balance.weapon_damage_upgrade_price()[2].name - local class_for_sale = destination.static_params.class_for_sale - -- if not class_for_sale then return end - local required_class = Classes.class_purchase_requirement[class_for_sale] + if isDamageUpgrade then + Common.notify_force_light(player.force, {'pirates.market_event_attack_upgrade_purchased', player.name}) + market.remove_market_item(offer_index) - local ok = Classes.try_unlock_class(class_for_sale, player, false) + Crew.buff_all_damage(0.1) - if ok then - market.remove_market_item(offer_index) - else -- if this happens, I believe there is something wrong with code - if force and force.valid then - Common.notify_force_error(force, {'pirates.class_purchase_error_prerequisite_class', Classes.display_form(required_class)}) + elseif destination.static_params.class_for_sale then + + local class_for_sale = destination.static_params.class_for_sale + -- if not class_for_sale then return end + local required_class = Classes.class_purchase_requirement[class_for_sale] + + local ok = Classes.try_unlock_class(class_for_sale, player, false) + + if ok then + market.remove_market_item(offer_index) + else -- if this happens, I believe there is something wrong with code + if force and force.valid then + Common.notify_force_error(force, {'pirates.class_purchase_error_prerequisite_class', Classes.display_form(required_class)}) + end + + --refund + refunds = refunds + 1 + Public.refund_items(player, thisPurchaseData.price, 1) + log('Error purchasing class: ' .. class_for_sale) end - - --refund - refunds = refunds + 1 - Public.refund_items(player, thisPurchaseData.price, 1) - log('Error purchasing class: ' .. class_for_sale) end else Common.notify_force_light(player.force, {'pirates.market_event_buy', player.name, thisPurchaseData.offer_giveitem_count .. ' ' .. thisPurchaseData.offer_giveitem_name, thisPurchaseData.price[1].amount .. ' ' .. thisPurchaseData.price[1].name}) diff --git a/maps/pirates/structures/quest_structures/furnace1/furnace1.lua b/maps/pirates/structures/quest_structures/furnace1/furnace1.lua index 33f97cde..db3ce005 100644 --- a/maps/pirates/structures/quest_structures/furnace1/furnace1.lua +++ b/maps/pirates/structures/quest_structures/furnace1/furnace1.lua @@ -106,6 +106,14 @@ function Public.create_step2_entities() quest_structure_data.market.add_market_item(o) end + quest_structure_data.market.add_market_item{ + price = Balance.weapon_damage_upgrade_price(), + offer = { + type = "nothing", + effect_description = {'pirates.market_description_purchase_attack_upgrade'} + } + } + if destination.static_params.class_for_sale then quest_structure_data.market.add_market_item{price={{'coin', Balance.class_cost(false)}}, offer={type="nothing", effect_description = {'pirates.market_description_purchase_class', Classes.display_form(destination.static_params.class_for_sale)}}} diff --git a/maps/pirates/structures/quest_structures/market1/market1.lua b/maps/pirates/structures/quest_structures/market1/market1.lua index 996e9c78..80165111 100644 --- a/maps/pirates/structures/quest_structures/market1/market1.lua +++ b/maps/pirates/structures/quest_structures/market1/market1.lua @@ -96,6 +96,14 @@ function Public.create_step2_entities() quest_structure_data.market.add_market_item(o) end + quest_structure_data.market.add_market_item{ + price = Balance.weapon_damage_upgrade_price(), + offer = { + type = "nothing", + effect_description = {'pirates.market_description_purchase_attack_upgrade'} + } + } + if destination.static_params.class_for_sale then quest_structure_data.market.add_market_item{price={{'coin', Balance.class_cost(false)}}, offer={type="nothing", effect_description = {'pirates.market_description_purchase_class', Classes.display_form(destination.static_params.class_for_sale)}}} diff --git a/maps/pirates/surfaces/islands/cave/cave_source.lua b/maps/pirates/surfaces/islands/cave/cave_source.lua index b1a7abb0..e04fadd1 100644 --- a/maps/pirates/surfaces/islands/cave/cave_source.lua +++ b/maps/pirates/surfaces/islands/cave/cave_source.lua @@ -27,6 +27,15 @@ local function spawn_market(args, is_main) local offers if is_main then offers = ShopCovered.market_generate_coin_offers(6) + + offers[#offers+1] = { + price = Balance.weapon_damage_upgrade_price(), + offer = { + type = "nothing", + effect_description = {'pirates.market_description_purchase_attack_upgrade'} + } + } + if destination_data.static_params.class_for_sale then offers[#offers+1] = {price={{'coin', Balance.class_cost(true)}}, offer={type="nothing", effect_description = {'pirates.market_description_purchase_class', Classes.display_form(destination_data.static_params.class_for_sale)}}} end diff --git a/maps/pirates/surfaces/surfaces.lua b/maps/pirates/surfaces/surfaces.lua index 685fdb00..4e02c409 100644 --- a/maps/pirates/surfaces/surfaces.lua +++ b/maps/pirates/surfaces/surfaces.lua @@ -103,7 +103,6 @@ function Public.on_surface_generation(destination) -- local memory = Memory.get_crew_memory() -- game.map_settings.pollution.enemy_attack_pollution_consumption_modifier = Balance.defaultai_attack_pollution_consumption_modifier() - -- Event_functions.flamer_nerfs() if destination.type == enum.ISLAND then local subtype = destination.subtype @@ -270,7 +269,6 @@ function Public.destination_on_arrival(destination) local memory = Memory.get_crew_memory() -- game.map_settings.pollution.enemy_attack_pollution_consumption_modifier = Balance.defaultai_attack_pollution_consumption_modifier() - -- Event_functions.flamer_nerfs() log('Playthrough stats:') log(_inspect(memory.playtesting_stats))