2022-06-01 20:50:36 +02:00
|
|
|
-- This file is part of thesixthroc's Pirate Ship softmod, licensed under GPLv3 and stored at https://github.com/danielmartin0/ComfyFactorio-Pirates.
|
|
|
|
|
2021-10-13 10:21:53 +02:00
|
|
|
|
|
|
|
local Balance = require 'maps.pirates.balance'
|
2022-03-19 23:20:55 +02:00
|
|
|
local _inspect = require 'utils.inspect'.inspect
|
2021-10-13 10:21:53 +02:00
|
|
|
local Memory = require 'maps.pirates.memory'
|
|
|
|
local Math = require 'maps.pirates.math'
|
|
|
|
local Common = require 'maps.pirates.common'
|
|
|
|
local Utils = require 'maps.pirates.utils_local'
|
|
|
|
local CoreData = require 'maps.pirates.coredata'
|
2022-05-29 13:36:27 +02:00
|
|
|
local SurfacesCommon = require 'maps.pirates.surfaces.common'
|
2022-03-19 23:20:55 +02:00
|
|
|
-- local Server = require 'utils.server'
|
2021-10-13 10:21:53 +02:00
|
|
|
|
|
|
|
local Public = {}
|
|
|
|
local enum = {
|
2022-05-29 13:36:27 +02:00
|
|
|
DECKHAND = 'deckhand',
|
|
|
|
FISHERMAN = 'fisherman',
|
|
|
|
SCOUT = 'scout',
|
|
|
|
SAMURAI = 'samurai',
|
|
|
|
MERCHANT = 'merchant',
|
|
|
|
SHORESMAN = 'shoresman',
|
|
|
|
BOATSWAIN = 'boatswain',
|
|
|
|
PROSPECTOR = 'prospector',
|
|
|
|
LUMBERJACK = 'lumberjack',
|
|
|
|
MASTER_ANGLER = 'master_angler',
|
|
|
|
WOOD_LORD = 'wood_lord',
|
|
|
|
CHIEF_EXCAVATOR = 'chief_excavator',
|
|
|
|
HATAMOTO = 'hatamoto',
|
|
|
|
IRON_LEG = 'iron_leg',
|
|
|
|
QUARTERMASTER = 'quartermaster',
|
|
|
|
DREDGER = 'dredger',
|
|
|
|
SMOLDERING = 'smoldering',
|
|
|
|
GOURMET = 'gourmet',
|
2021-10-13 10:21:53 +02:00
|
|
|
}
|
|
|
|
Public.enum = enum
|
|
|
|
|
2022-05-29 13:36:27 +02:00
|
|
|
-- function Public.Class_List()
|
|
|
|
-- local ret = {}
|
|
|
|
-- for _,v in pairs(enum) do
|
|
|
|
-- ret[#ret + 1] = v
|
|
|
|
-- end
|
|
|
|
-- end
|
2021-10-13 10:21:53 +02:00
|
|
|
|
2022-05-29 13:36:27 +02:00
|
|
|
Public.eng_form = {
|
2021-10-13 10:21:53 +02:00
|
|
|
[enum.DECKHAND] = 'Deckhand',
|
|
|
|
[enum.FISHERMAN] = 'Fisherman',
|
|
|
|
[enum.SCOUT] = 'Scout',
|
|
|
|
[enum.SAMURAI] = 'Samurai',
|
|
|
|
[enum.MERCHANT] = 'Merchant',
|
|
|
|
[enum.SHORESMAN] = 'Shoresman',
|
|
|
|
[enum.BOATSWAIN] = 'Boatswain',
|
2022-02-24 21:39:03 +02:00
|
|
|
[enum.PROSPECTOR] = 'Prospector',
|
2022-03-01 23:59:48 +02:00
|
|
|
[enum.LUMBERJACK] = 'Lumberjack',
|
2022-03-04 19:57:58 +02:00
|
|
|
[enum.MASTER_ANGLER] = 'Master Angler',
|
2022-05-29 13:36:27 +02:00
|
|
|
[enum.WOOD_LORD] = 'Wood Lord',
|
2022-03-04 19:57:58 +02:00
|
|
|
[enum.CHIEF_EXCAVATOR] = 'Chief Excavator',
|
2022-03-07 11:50:25 +02:00
|
|
|
[enum.HATAMOTO] = 'Hatamoto',
|
2022-03-04 19:57:58 +02:00
|
|
|
[enum.IRON_LEG] = 'Iron Leg',
|
|
|
|
[enum.QUARTERMASTER] = 'Quartermaster',
|
2022-03-06 03:05:26 +02:00
|
|
|
[enum.DREDGER] = 'Dredger',
|
2022-03-07 22:15:47 +02:00
|
|
|
[enum.SMOLDERING] = 'Smoldering',
|
|
|
|
[enum.GOURMET] = 'Gourmet',
|
2021-10-13 10:21:53 +02:00
|
|
|
}
|
2022-05-29 13:36:27 +02:00
|
|
|
|
|
|
|
function Public.display_form(class)
|
|
|
|
return {'pirates.class_' .. class}
|
|
|
|
end
|
|
|
|
|
|
|
|
function Public.explanation(class)
|
|
|
|
return {'pirates.class_' .. class .. '_explanation'}
|
|
|
|
end
|
|
|
|
|
2022-06-02 15:07:17 +02:00
|
|
|
function Public.explanation_advanced(class)
|
2022-06-02 21:08:55 +02:00
|
|
|
local explanation = 'pirates.class_' .. class .. '_explanation_advanced'
|
2022-06-06 16:55:24 +02:00
|
|
|
local full_explanation
|
2022-06-03 21:38:46 +02:00
|
|
|
|
2022-06-02 21:08:55 +02:00
|
|
|
if class == enum.DECKHAND then
|
2022-06-03 21:38:46 +02:00
|
|
|
local extra_speed = Public.percentage_points_difference_from_100_percent(Balance.deckhand_extra_speed)
|
2022-06-02 21:08:55 +02:00
|
|
|
local ore_amount = Public.ore_grant_amount(Balance.deckhand_ore_grant_multiplier, Balance.deckhand_ore_scaling_enabled)
|
|
|
|
local tick_rate = Balance.class_reward_tick_rate_in_seconds
|
2022-06-03 15:41:49 +02:00
|
|
|
full_explanation = {'', {explanation, extra_speed, ore_amount, tick_rate}}
|
|
|
|
elseif class == enum.BOATSWAIN then
|
2022-06-03 21:38:46 +02:00
|
|
|
local extra_speed = Public.percentage_points_difference_from_100_percent(Balance.boatswain_extra_speed)
|
2022-06-03 15:41:49 +02:00
|
|
|
local ore_amount = Public.ore_grant_amount(Balance.boatswain_ore_grant_multiplier, Balance.boatswain_ore_scaling_enabled)
|
|
|
|
local tick_rate = Balance.class_reward_tick_rate_in_seconds
|
|
|
|
full_explanation = {'', {explanation, extra_speed, ore_amount, tick_rate}}
|
|
|
|
elseif class == enum.SHORESMAN then
|
2022-06-03 21:38:46 +02:00
|
|
|
local extra_speed = Public.percentage_points_difference_from_100_percent(Balance.shoresman_extra_speed)
|
2022-06-03 15:41:49 +02:00
|
|
|
local ore_amount = Public.ore_grant_amount(Balance.shoresman_ore_grant_multiplier, Balance.shoresman_ore_scaling_enabled)
|
|
|
|
local tick_rate = Balance.class_reward_tick_rate_in_seconds
|
|
|
|
full_explanation = {'', {explanation, extra_speed, ore_amount, tick_rate}}
|
|
|
|
elseif class == enum.QUARTERMASTER then
|
|
|
|
local range = Balance.quartermaster_range
|
2022-06-03 21:38:46 +02:00
|
|
|
local extra_physical = Public.percentage_points_difference_from_100_percent(Balance.quartermaster_bonus_physical_damage)
|
2022-06-03 15:41:49 +02:00
|
|
|
full_explanation = {'', {explanation, range, extra_physical}}
|
|
|
|
elseif class == enum.FISHERMAN then
|
|
|
|
local extra_range = Balance.fisherman_reach_bonus
|
|
|
|
full_explanation = {'', {explanation, extra_range}}
|
|
|
|
elseif class == enum.MASTER_ANGLER then
|
|
|
|
local extra_range = Balance.master_angler_reach_bonus
|
|
|
|
local extra_fish = Balance.master_angler_fish_bonus
|
|
|
|
local extra_coins = Balance.master_angler_coin_bonus
|
|
|
|
full_explanation = {'', {explanation, extra_range, extra_fish, extra_coins}}
|
|
|
|
elseif class == enum.SCOUT then
|
2022-06-03 21:38:46 +02:00
|
|
|
local extra_speed = Public.percentage_points_difference_from_100_percent(Balance.scout_extra_speed)
|
|
|
|
local received_damage = Public.percentage_points_difference_from_100_percent(Balance.scout_damage_taken_multiplier)
|
|
|
|
local dealt_damage = Public.percentage_points_difference_from_100_percent(Balance.scout_damage_dealt_multiplier)
|
2022-06-03 15:41:49 +02:00
|
|
|
full_explanation = {'', {explanation, extra_speed, received_damage, dealt_damage}}
|
|
|
|
elseif class == enum.SAMURAI then
|
2022-06-03 21:38:46 +02:00
|
|
|
local received_damage = Public.percentage_points_difference_from_100_percent(Balance.samurai_damage_taken_multiplier)
|
2022-06-03 22:58:10 +02:00
|
|
|
local melee_damage = Balance.samurai_damage_dealt_with_melee
|
2022-06-03 21:38:46 +02:00
|
|
|
local non_melee_damage = Public.percentage_points_difference_from_100_percent(Balance.samurai_damage_dealt_when_not_melee_multiplier)
|
2022-06-03 15:41:49 +02:00
|
|
|
full_explanation = {'', {explanation, received_damage, melee_damage, non_melee_damage}}
|
|
|
|
elseif class == enum.HATAMOTO then
|
2022-06-03 21:38:46 +02:00
|
|
|
local received_damage = Public.percentage_points_difference_from_100_percent(Balance.hatamoto_damage_taken_multiplier)
|
2022-06-03 22:58:10 +02:00
|
|
|
local melee_damage = Balance.hatamoto_damage_dealt_with_melee
|
2022-06-03 21:38:46 +02:00
|
|
|
local non_melee_damage = Public.percentage_points_difference_from_100_percent(Balance.hatamoto_damage_dealt_when_not_melee_multiplier)
|
2022-06-03 15:41:49 +02:00
|
|
|
full_explanation = {'', {explanation, received_damage, melee_damage, non_melee_damage}}
|
|
|
|
elseif class == enum.IRON_LEG then
|
2022-06-03 21:38:46 +02:00
|
|
|
local received_damage = Public.percentage_points_difference_from_100_percent(Balance.iron_leg_damage_taken_multiplier)
|
2022-06-03 15:41:49 +02:00
|
|
|
local iron_ore_required = Balance.iron_leg_iron_ore_required
|
|
|
|
full_explanation = {'', {explanation, received_damage, iron_ore_required}}
|
|
|
|
else
|
|
|
|
full_explanation = {'', {explanation}}
|
2022-06-02 21:08:55 +02:00
|
|
|
end
|
|
|
|
|
2022-06-05 13:02:51 +02:00
|
|
|
full_explanation[#full_explanation + 1] = Public.class_is_obtainable(class) and {'', ' ', {'pirates.class_obtainable'}} or {'', ' ', {'pirates.class_unobtainable'}}
|
2022-06-02 21:08:55 +02:00
|
|
|
|
|
|
|
return full_explanation
|
2022-06-02 15:07:17 +02:00
|
|
|
end
|
|
|
|
|
2022-05-29 13:36:27 +02:00
|
|
|
-- Public.display_form = {
|
|
|
|
-- [enum.DECKHAND] = {'pirates.class_deckhand'},
|
|
|
|
-- }
|
|
|
|
-- Public.explanation = {
|
|
|
|
-- [enum.DECKHAND] = {'pirates.class_deckhand_explanation'},
|
|
|
|
-- }
|
|
|
|
|
|
|
|
|
2022-06-03 21:38:46 +02:00
|
|
|
-- returns by how much % result changes when you multiply it by multiplier
|
|
|
|
-- for example consider these multiplier cases {0.6, 1.2}:
|
|
|
|
-- number * 0.6 -> result decreased by 40%
|
|
|
|
-- number * 1.2 -> result increased by 20%
|
|
|
|
function Public.percentage_points_difference_from_100_percent(multiplier)
|
2022-06-03 15:41:49 +02:00
|
|
|
if(multiplier < 1) then
|
|
|
|
return (1 - multiplier) * 100
|
|
|
|
else
|
|
|
|
return (multiplier - 1) * 100
|
|
|
|
end
|
|
|
|
end
|
2022-05-29 13:36:27 +02:00
|
|
|
|
2021-10-13 10:21:53 +02:00
|
|
|
|
2022-03-04 19:57:58 +02:00
|
|
|
Public.class_unlocks = {
|
|
|
|
[enum.FISHERMAN] = {enum.MASTER_ANGLER},
|
2022-04-30 00:48:34 +02:00
|
|
|
-- [enum.LUMBERJACK] = {enum.WOOD_LORD}, --not that interesting
|
2022-03-07 22:15:47 +02:00
|
|
|
-- [enum.PROSPECTOR] = {enum.CHIEF_EXCAVATOR}, --breaks the resource pressure in the game too strongly I think
|
2022-03-07 11:50:25 +02:00
|
|
|
[enum.SAMURAI] = {enum.HATAMOTO},
|
2022-03-06 03:05:26 +02:00
|
|
|
[enum.MASTER_ANGLER] = {enum.DREDGER},
|
2022-03-04 19:57:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
Public.class_purchase_requirement = {
|
|
|
|
[enum.MASTER_ANGLER] = enum.FISHERMAN,
|
|
|
|
[enum.WOOD_LORD] = enum.LUMBERJACK,
|
2022-06-02 14:19:55 +02:00
|
|
|
[enum.CHIEF_EXCAVATOR] = enum.PROSPECTOR,
|
2022-03-07 11:50:25 +02:00
|
|
|
[enum.HATAMOTO] = enum.SAMURAI,
|
2022-03-06 03:05:26 +02:00
|
|
|
[enum.DREDGER] = enum.MASTER_ANGLER,
|
2022-03-04 19:57:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function Public.initial_class_pool()
|
|
|
|
return {
|
|
|
|
enum.DECKHAND,
|
2022-03-07 22:15:47 +02:00
|
|
|
enum.DECKHAND, --good for afk players
|
|
|
|
enum.SHORESMAN,
|
|
|
|
enum.SHORESMAN,
|
|
|
|
enum.QUARTERMASTER,
|
2022-03-04 19:57:58 +02:00
|
|
|
enum.FISHERMAN,
|
|
|
|
enum.SCOUT,
|
|
|
|
enum.SAMURAI,
|
2022-03-09 01:36:03 +02:00
|
|
|
-- enum.MERCHANT, --not interesting, breaks coin economy
|
2022-03-04 19:57:58 +02:00
|
|
|
enum.BOATSWAIN,
|
2022-06-02 14:19:55 +02:00
|
|
|
-- enum.PROSPECTOR, --lumberjack is just more fun
|
2022-03-04 19:57:58 +02:00
|
|
|
enum.LUMBERJACK,
|
|
|
|
enum.IRON_LEG,
|
2022-06-02 14:19:55 +02:00
|
|
|
-- enum.SMOLDERING, --tedious
|
2022-03-07 22:15:47 +02:00
|
|
|
enum.GOURMET,
|
2022-03-04 19:57:58 +02:00
|
|
|
}
|
|
|
|
end
|
|
|
|
|
2022-06-02 21:08:55 +02:00
|
|
|
function Public.class_is_obtainable(class)
|
|
|
|
local obtainable_class_pool = Public.initial_class_pool()
|
2022-06-05 13:02:51 +02:00
|
|
|
|
2022-06-02 21:08:55 +02:00
|
|
|
for _, unlocked_class_list in pairs(Public.class_unlocks) do
|
2022-06-05 13:02:51 +02:00
|
|
|
for _, unlocked_class in ipairs(unlocked_class_list) do
|
2022-06-02 21:08:55 +02:00
|
|
|
obtainable_class_pool[#obtainable_class_pool + 1] = unlocked_class
|
|
|
|
end
|
|
|
|
end
|
2022-06-05 13:02:51 +02:00
|
|
|
|
2022-06-02 21:08:55 +02:00
|
|
|
for _, unlockable_class in ipairs(obtainable_class_pool) do
|
|
|
|
if unlockable_class == class then
|
2022-06-03 15:41:49 +02:00
|
|
|
return true
|
2022-06-02 21:08:55 +02:00
|
|
|
end
|
|
|
|
end
|
2022-06-05 13:02:51 +02:00
|
|
|
|
2022-06-03 15:41:49 +02:00
|
|
|
return false
|
2022-06-02 21:08:55 +02:00
|
|
|
end
|
|
|
|
|
2022-03-04 19:57:58 +02:00
|
|
|
|
|
|
|
function Public.assign_class(player_index, class, self_assigned)
|
|
|
|
local memory = Memory.get_crew_memory()
|
2022-03-13 20:19:59 +02:00
|
|
|
local player = game.players[player_index]
|
2022-03-04 19:57:58 +02:00
|
|
|
|
|
|
|
if not memory.classes_table then memory.classes_table = {} end
|
|
|
|
|
2022-03-13 20:19:59 +02:00
|
|
|
if memory.classes_table[player_index] == class then
|
2022-05-29 13:36:27 +02:00
|
|
|
Common.notify_player_error(player, {'pirates.error_class_assign_redundant', Public.display_form(class)})
|
2022-03-13 20:19:59 +02:00
|
|
|
return false
|
|
|
|
end
|
|
|
|
|
2022-03-04 19:57:58 +02:00
|
|
|
if Utils.contains(memory.spare_classes, class) then -- verify that one is spare
|
2022-03-13 20:19:59 +02:00
|
|
|
|
2022-03-14 14:44:30 +02:00
|
|
|
Public.try_renounce_class(player, false)
|
2022-03-19 23:20:55 +02:00
|
|
|
|
2022-03-04 19:57:58 +02:00
|
|
|
memory.classes_table[player_index] = class
|
2022-03-19 23:20:55 +02:00
|
|
|
|
2022-03-04 19:57:58 +02:00
|
|
|
local force = memory.force
|
|
|
|
if force and force.valid then
|
|
|
|
if self_assigned then
|
2022-05-29 13:36:27 +02:00
|
|
|
Common.notify_force_light(force,{'pirates.class_take_spare', player.name, Public.display_form(memory.classes_table[player_index]), Public.explanation(memory.classes_table[player_index])})
|
2022-03-04 19:57:58 +02:00
|
|
|
else
|
2022-05-29 13:36:27 +02:00
|
|
|
Common.notify_force_light(force,{'pirates.class_give_spare', Public.display_form(memory.classes_table[player_index]), player.name, Public.explanation(memory.classes_table[player_index])})
|
2022-03-04 19:57:58 +02:00
|
|
|
end
|
|
|
|
end
|
2022-03-19 23:20:55 +02:00
|
|
|
|
2022-03-04 19:57:58 +02:00
|
|
|
memory.spare_classes = Utils.ordered_table_with_single_value_removed(memory.spare_classes, class)
|
2022-03-13 20:19:59 +02:00
|
|
|
return true
|
|
|
|
else
|
2022-05-29 13:36:27 +02:00
|
|
|
Common.notify_player_error(player, {'pirates.error_class_assign_unavailable_class'})
|
2022-03-13 20:19:59 +02:00
|
|
|
return false
|
2022-03-04 19:57:58 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2022-05-29 13:36:27 +02:00
|
|
|
function Public.try_renounce_class(player, whisper_failure_message, impersonal_bool)
|
2022-03-04 19:57:58 +02:00
|
|
|
local memory = Memory.get_crew_memory()
|
|
|
|
|
|
|
|
local force = memory.force
|
2022-03-13 20:19:59 +02:00
|
|
|
if force and force.valid and player and player.index then
|
|
|
|
if memory.classes_table and memory.classes_table[player.index] then
|
2022-03-04 19:57:58 +02:00
|
|
|
if force and force.valid then
|
2022-05-29 13:36:27 +02:00
|
|
|
if impersonal_bool then
|
|
|
|
Common.notify_force_light(force,{'pirates.class_becomes_spare', Public.display_form(memory.classes_table[player.index])})
|
2022-03-04 19:57:58 +02:00
|
|
|
else
|
2022-05-29 13:36:27 +02:00
|
|
|
Common.notify_force_light(force,{'pirates.class_give_up', player.name, Public.display_form(memory.classes_table[player.index])})
|
2022-03-04 19:57:58 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
memory.spare_classes[#memory.spare_classes + 1] = memory.classes_table[player.index]
|
|
|
|
memory.classes_table[player.index] = nil
|
2022-03-14 14:44:30 +02:00
|
|
|
elseif whisper_failure_message then
|
2022-05-29 13:36:27 +02:00
|
|
|
Common.notify_player_error(player, {'pirates.class_give_up_error_no_class'})
|
2022-03-04 19:57:58 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
function Public.generate_class_for_sale()
|
|
|
|
local memory = Memory.get_crew_memory()
|
|
|
|
|
2022-03-19 23:20:55 +02:00
|
|
|
-- if #memory.available_classes_pool == 0 then
|
|
|
|
-- -- memory.available_classes_pool = Public.initial_class_pool() --reset to initial state
|
|
|
|
-- -- turned off as this makes too many classes
|
|
|
|
-- end
|
2022-03-09 01:36:03 +02:00
|
|
|
|
|
|
|
local class
|
|
|
|
if #memory.available_classes_pool > 0 then
|
|
|
|
class = memory.available_classes_pool[Math.random(#memory.available_classes_pool)]
|
2022-03-07 22:15:47 +02:00
|
|
|
end
|
2022-03-04 19:57:58 +02:00
|
|
|
|
2022-03-07 22:15:47 +02:00
|
|
|
return class
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-06-02 21:08:55 +02:00
|
|
|
function Public.class_ore_grant(player, how_much, enable_scaling)
|
2022-06-03 22:47:10 +02:00
|
|
|
local count = Public.ore_grant_amount(how_much, enable_scaling)
|
2022-06-03 22:53:01 +02:00
|
|
|
|
2022-03-13 03:44:32 +02:00
|
|
|
if Math.random(4) == 1 then
|
2022-03-07 22:15:47 +02:00
|
|
|
Common.flying_text_small(player.surface, player.position, '[color=0.85,0.58,0.37]+' .. count .. '[/color]')
|
2022-03-09 01:36:03 +02:00
|
|
|
Common.give_items_to_crew{{name = 'copper-ore', count = count}}
|
2022-03-04 19:57:58 +02:00
|
|
|
else
|
2022-03-07 22:15:47 +02:00
|
|
|
Common.flying_text_small(player.surface, player.position, '[color=0.7,0.8,0.8]+' .. count .. '[/color]')
|
2022-03-09 01:36:03 +02:00
|
|
|
Common.give_items_to_crew{{name = 'iron-ore', count = count}}
|
2022-03-04 19:57:58 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2022-06-02 21:08:55 +02:00
|
|
|
function Public.ore_grant_amount(how_much, enable_scaling)
|
|
|
|
if enable_scaling then
|
|
|
|
return Math.ceil(how_much * Balance.class_resource_scale())
|
|
|
|
else
|
|
|
|
return Math.ceil(how_much)
|
|
|
|
end
|
|
|
|
end
|
2022-03-07 22:15:47 +02:00
|
|
|
|
|
|
|
local function class_on_player_used_capsule(event)
|
|
|
|
|
|
|
|
local player = game.players[event.player_index]
|
|
|
|
if not player or not player.valid then
|
|
|
|
return
|
|
|
|
end
|
|
|
|
local player_index = player.index
|
|
|
|
|
|
|
|
local crew_id = tonumber(string.sub(player.force.name, -3, -1)) or nil
|
|
|
|
Memory.set_working_id(crew_id)
|
|
|
|
local memory = Memory.get_crew_memory()
|
|
|
|
|
|
|
|
if not (player.character and player.character.valid) then
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
|
|
|
local item = event.item
|
|
|
|
if not (item and item.name and item.name == 'raw-fish') then return end
|
|
|
|
|
2022-06-02 15:07:17 +02:00
|
|
|
local global_memory = Memory.get_global_memory()
|
|
|
|
global_memory.last_players_health[event.player_index] = player.character.health
|
|
|
|
|
2022-03-07 22:15:47 +02:00
|
|
|
if memory.classes_table and memory.classes_table[player_index] then
|
|
|
|
local class = memory.classes_table[player_index]
|
2022-03-14 14:44:30 +02:00
|
|
|
if class == Public.enum.GOURMET then
|
2022-05-29 13:36:27 +02:00
|
|
|
local multiplier = 0
|
|
|
|
local surfacedata = SurfacesCommon.decode_surface_name(player.surface.name)
|
|
|
|
if surfacedata.type == SurfacesCommon.enum.CABIN then
|
|
|
|
multiplier = 0.25
|
|
|
|
elseif surfacedata.type == SurfacesCommon.enum.CROWSNEST then
|
|
|
|
multiplier = 0.15
|
|
|
|
else
|
|
|
|
local tile = player.surface.get_tile(player.position)
|
|
|
|
if tile.valid then
|
|
|
|
if tile.name == CoreData.world_concrete_tile then
|
|
|
|
multiplier = 1.5
|
|
|
|
elseif tile.name == 'cyan-refined-concrete' then
|
|
|
|
multiplier = 1.6
|
|
|
|
elseif tile.name == CoreData.walkway_tile then
|
|
|
|
multiplier = 1
|
|
|
|
elseif tile.name == 'orange-refined-concrete' then
|
|
|
|
multiplier = 0.5
|
|
|
|
elseif tile.name == CoreData.enemy_landing_tile then
|
|
|
|
multiplier = 0.3
|
|
|
|
elseif tile.name == CoreData.static_boat_floor then
|
|
|
|
multiplier = 0.1
|
2022-03-07 22:15:47 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2022-05-29 13:36:27 +02:00
|
|
|
if multiplier > 0 then
|
|
|
|
local timescale = 60*30 * Math.max((Balance.game_slowness_scale())^(2/3),0.8)
|
|
|
|
if memory.gourmet_recency_tick then
|
2022-06-01 20:50:36 +02:00
|
|
|
multiplier = multiplier *Math.clamp(0.2, 5, (1/5)^((memory.gourmet_recency_tick - game.tick)/(60*300)))
|
2022-05-29 13:36:27 +02:00
|
|
|
memory.gourmet_recency_tick = Math.max(memory.gourmet_recency_tick, game.tick - timescale*10) + timescale
|
|
|
|
else
|
|
|
|
multiplier = multiplier * 5
|
|
|
|
memory.gourmet_recency_tick = game.tick - timescale*10 + timescale
|
|
|
|
end
|
2022-06-02 21:08:55 +02:00
|
|
|
Public.class_ore_grant(player, 10 * multiplier, Balance.gourmet_ore_scaling_enabled)
|
2022-05-29 13:36:27 +02:00
|
|
|
end
|
2022-03-07 22:15:47 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2022-06-02 14:19:55 +02:00
|
|
|
|
|
|
|
function Public.lumberjack_bonus_items(give_table)
|
|
|
|
local memory = Memory.get_crew_memory()
|
|
|
|
|
2022-06-02 21:08:55 +02:00
|
|
|
if Math.random(Balance.every_nth_tree_gives_coins) == 1 then
|
2022-06-02 14:19:55 +02:00
|
|
|
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
|
|
|
|
|
|
|
|
|
2022-03-07 22:15:47 +02:00
|
|
|
local event = require 'utils.event'
|
|
|
|
event.add(defines.events.on_player_used_capsule, class_on_player_used_capsule)
|
|
|
|
|
2021-10-13 10:21:53 +02:00
|
|
|
return Public
|