From 3a51bb85cd26894c90e095284545b72105e4fdfc Mon Sep 17 00:00:00 2001 From: danielmartin0 Date: Thu, 2 Jun 2022 13:19:55 +0100 Subject: [PATCH] disable prospector, rework lumberjack --- maps/pirates/api_events.lua | 70 ++++++++++++++++------------------ maps/pirates/roles/classes.lua | 24 ++++++++++-- maps/pirates/shop/covered.lua | 6 ++- 3 files changed, 57 insertions(+), 43 deletions(-) diff --git a/maps/pirates/api_events.lua b/maps/pirates/api_events.lua index 1e1dae85..e9e7ca24 100644 --- a/maps/pirates/api_events.lua +++ b/maps/pirates/api_events.lua @@ -646,9 +646,9 @@ end local function event_pre_player_mined_item(event) -- figure out which crew this is about: - local crew_id = nil - if event.player_index and game.players[event.player_index].valid then crew_id = tonumber(string.sub(game.players[event.player_index].force.name, -3, -1)) or nil end - Memory.set_working_id(crew_id) + -- local crew_id = nil + -- if event.player_index and game.players[event.player_index].valid then crew_id = tonumber(string.sub(game.players[event.player_index].force.name, -3, -1)) or nil end + -- Memory.set_working_id(crew_id) -- local memory = Memory.get_crew_memory() -- if memory.planet[1].type.id == 11 then --rocky planet @@ -660,6 +660,10 @@ local function event_pre_player_mined_item(event) -- end end + +Public.every_nth_tree_gives_coins = 6 + + local function event_on_player_mined_entity(event) if not event.player_index then return end local player = game.players[event.player_index] @@ -677,8 +681,6 @@ local function event_on_player_mined_entity(event) return end - local every_nth_tree_gives_coins = 6 - if entity.type == 'tree' then if not event.buffer then return end local available = destination.dynamic_data.wood_remaining @@ -695,22 +697,18 @@ local function event_on_player_mined_entity(event) local give = {} if memory.classes_table and memory.classes_table[event.player_index] then if memory.classes_table[event.player_index] == Classes.enum.LUMBERJACK then - give[#give + 1] = {name = 'wood', count = 4} - if Math.random(every_nth_tree_gives_coins) == 1 then - local a = 20 - give[#give + 1] = {name = 'coin', count = a} - memory.playtesting_stats.coins_gained_by_trees_and_rocks = memory.playtesting_stats.coins_gained_by_trees_and_rocks + a - end - elseif memory.classes_table[event.player_index] == Classes.enum.WOOD_LORD then give[#give + 1] = {name = 'wood', count = 1} - give[#give + 1] = {name = 'iron-ore', count = 1} - give[#give + 1] = {name = 'copper-ore', count = 1} - give[#give + 1] = {name = 'coal', count = 1} - if Math.random(every_nth_tree_gives_coins) == 1 then - local a = 12 - give[#give + 1] = {name = 'coin', count = a} - memory.playtesting_stats.coins_gained_by_trees_and_rocks = memory.playtesting_stats.coins_gained_by_trees_and_rocks + a - end + Classes.lumberjack_bonus_items(give) + -- elseif memory.classes_table[event.player_index] == Classes.enum.WOOD_LORD then + -- give[#give + 1] = {name = 'wood', count = 1} + -- give[#give + 1] = {name = 'iron-ore', count = 1} + -- give[#give + 1] = {name = 'copper-ore', count = 1} + -- give[#give + 1] = {name = 'coal', count = 1} + -- if Math.random(every_nth_tree_gives_coins) == 1 then + -- local a = 12 + -- give[#give + 1] = {name = 'coin', count = a} + -- memory.playtesting_stats.coins_gained_by_trees_and_rocks = memory.playtesting_stats.coins_gained_by_trees_and_rocks + a + -- end end end @@ -727,25 +725,21 @@ local function event_on_player_mined_entity(event) destination.dynamic_data.wood_remaining = destination.dynamic_data.wood_remaining - amount if memory.classes_table and memory.classes_table[event.player_index] and memory.classes_table[event.player_index] == Classes.enum.LUMBERJACK then - give[#give + 1] = {name = 'wood', count = amount + 3} - if Math.random(every_nth_tree_gives_coins) == 1 then - local a = 12 - give[#give + 1] = {name = 'coin', count = a} - memory.playtesting_stats.coins_gained_by_trees_and_rocks = memory.playtesting_stats.coins_gained_by_trees_and_rocks + a - end - elseif memory.classes_table and memory.classes_table[event.player_index] and memory.classes_table[event.player_index] == Classes.enum.WOOD_LORD then - give[#give + 1] = {name = 'wood', count = amount + 3} - give[#give + 1] = {name = 'iron-ore', count = 1} - give[#give + 1] = {name = 'copper-ore', count = 1} - give[#give + 1] = {name = 'coal', count = 1} - if Math.random(every_nth_tree_gives_coins) == 1 then - local a = 12 - give[#give + 1] = {name = 'coin', count = a} - memory.playtesting_stats.coins_gained_by_trees_and_rocks = memory.playtesting_stats.coins_gained_by_trees_and_rocks + a - end + give[#give + 1] = {name = 'wood', count = amount} + Classes.lumberjack_bonus_items(give) + -- elseif memory.classes_table and memory.classes_table[event.player_index] and memory.classes_table[event.player_index] == Classes.enum.WOOD_LORD then + -- give[#give + 1] = {name = 'wood', count = amount + 3} + -- give[#give + 1] = {name = 'iron-ore', count = 1} + -- give[#give + 1] = {name = 'copper-ore', count = 1} + -- give[#give + 1] = {name = 'coal', count = 1} + -- if Math.random(every_nth_tree_gives_coins) == 1 then + -- local a = 12 + -- give[#give + 1] = {name = 'coin', count = a} + -- memory.playtesting_stats.coins_gained_by_trees_and_rocks = memory.playtesting_stats.coins_gained_by_trees_and_rocks + a + -- end else give[#give + 1] = {name = 'wood', count = amount} - if Math.random(every_nth_tree_gives_coins) == 1 then --tuned + if Math.random(Public.every_nth_tree_gives_coins) == 1 then --tuned local a = 5 give[#give + 1] = {name = 'coin', count = a} memory.playtesting_stats.coins_gained_by_trees_and_rocks = memory.playtesting_stats.coins_gained_by_trees_and_rocks + a @@ -778,7 +772,7 @@ local function event_on_player_mined_entity(event) local give = {} - if memory.overworldx > 0 then + if memory.overworldx > 0 then --no coins on first map, else the optimal strategy is to handmine everything there if memory.classes_table and memory.classes_table[event.player_index] and memory.classes_table[event.player_index] == Classes.enum.PROSPECTOR then local a = 3 give[#give + 1] = {name = 'coin', count = a} diff --git a/maps/pirates/roles/classes.lua b/maps/pirates/roles/classes.lua index 3c829dd5..fbf2c546 100644 --- a/maps/pirates/roles/classes.lua +++ b/maps/pirates/roles/classes.lua @@ -91,7 +91,7 @@ Public.class_unlocks = { Public.class_purchase_requirement = { [enum.MASTER_ANGLER] = enum.FISHERMAN, [enum.WOOD_LORD] = enum.LUMBERJACK, - -- [enum.CHIEF_EXCAVATOR] = enum.PROSPECTOR, + [enum.CHIEF_EXCAVATOR] = enum.PROSPECTOR, [enum.HATAMOTO] = enum.SAMURAI, [enum.DREDGER] = enum.MASTER_ANGLER, } @@ -108,10 +108,10 @@ function Public.initial_class_pool() enum.SAMURAI, -- enum.MERCHANT, --not interesting, breaks coin economy enum.BOATSWAIN, - enum.PROSPECTOR, + -- enum.PROSPECTOR, --lumberjack is just more fun enum.LUMBERJACK, enum.IRON_LEG, - -- enum.SMOLDERING, + -- enum.SMOLDERING, --tedious enum.GOURMET, } end @@ -269,6 +269,24 @@ local function class_on_player_used_capsule(event) end end + +function Public.lumberjack_bonus_items(give_table) + local memory = Memory.get_crew_memory() + + if Math.random(Public.every_nth_tree_gives_coins) == 1 then + local a = 12 + give_table[#give_table + 1] = {name = 'coin', count = a} + memory.playtesting_stats.coins_gained_by_trees_and_rocks = memory.playtesting_stats.coins_gained_by_trees_and_rocks + a + elseif Math.random(2) == 1 then + if Math.random(5) == 1 then + give_table[#give_table + 1] = {name = 'copper-ore', count = 1} + else + give_table[#give_table + 1] = {name = 'iron-ore', count = 1} + end + end +end + + local event = require 'utils.event' event.add(defines.events.on_player_used_capsule, class_on_player_used_capsule) diff --git a/maps/pirates/shop/covered.lua b/maps/pirates/shop/covered.lua index 69e8d73e..d7e5e496 100644 --- a/maps/pirates/shop/covered.lua +++ b/maps/pirates/shop/covered.lua @@ -48,11 +48,13 @@ Public.offers_default = { {price = {{'coin', 720}}, offer = {type = 'give-item', item = 'gate', count = 10}}, {price = {{'coin', 120}}, offer = {type = 'give-item', item = 'storage-tank', count = 4}}, {price = {{'coin', 240}}, offer = {type = 'give-item', item = 'big-electric-pole', count = 8}}, - {price = {{'coin', 240}}, offer = {type = 'give-item', item = 'steel-furnace', count = 4}}, {price = {{'coin', 360}}, offer = {type = 'give-item', item = 'stack-inserter', count = 3}}, {price = {{'coin', 900}}, offer = {type = 'give-item', item = 'piercing-shotgun-shell', count = 9}}, {price = {{'coin', 960}}, offer = {type = 'give-item', item = 'flamethrower', count = 1}}, - {price = {{'coin', 1800}}, offer = {type = 'give-item', item = 'flamethrower-ammo', count = 5}}, + {price = {{'coin', 960}}, offer = {type = 'give-item', item = 'flamethrower', count = 1}}, + {price = {{'coin', 1800}}, offer = {type = 'give-item', item = 'flamethrower-ammo', count = 6}}, + {price = {{'coin', 1800}}, offer = {type = 'give-item', item = 'flamethrower-ammo', count = 6}}, + {price = {{'coin', 1800}}, offer = {type = 'give-item', item = 'flamethrower-ammo', count = 6}}, {price = {{'coin', 1800}}, offer = {type = 'give-item', item = 'flying-robot-frame', count = 1}}, }