mirror of
https://github.com/ComfyFactory/ComfyFactorio.git
synced 2026-06-20 16:32:28 +02:00
Class check code cleanup
Changes: - Cleaned up code that checks for player's class and changed to get_class() where possible - Deprecated /setclass command (it was equivelant to /unlock + /take command as well as slightly outdated since class GUI was added)
This commit is contained in:
+15
-39
@@ -499,7 +499,7 @@ local function damage_dealt_by_players_changes(event)
|
||||
for _, p2 in pairs(nearby_players) do
|
||||
if p2.player and p2.player.valid then
|
||||
local p2_index = p2.player.index
|
||||
if event.entity.valid and player_index ~= p2_index and memory.classes_table[p2_index] and memory.classes_table[p2_index] == Classes.enum.QUARTERMASTER then
|
||||
if event.entity.valid and player_index ~= p2_index and Classes.get_class(p2_index) == Classes.enum.QUARTERMASTER then
|
||||
event.entity.damage((Balance.quartermaster_bonus_physical_damage - 1) * event.final_damage_amount, character.force, 'impact', character) --triggers this function again, but not physical this time
|
||||
end
|
||||
end
|
||||
@@ -766,6 +766,8 @@ local function event_on_player_mined_entity(event)
|
||||
return
|
||||
end
|
||||
|
||||
local class = Classes.get_class(event.player_index)
|
||||
|
||||
if entity.type == 'tree' then
|
||||
if not event.buffer then return end
|
||||
local available = destination.dynamic_data.wood_remaining
|
||||
@@ -773,29 +775,16 @@ local function event_on_player_mined_entity(event)
|
||||
|
||||
if available and destination.type == Surfaces.enum.ISLAND then
|
||||
|
||||
if destination and destination.subtype and destination.subtype == IslandEnum.enum.MAZE then
|
||||
if destination.subtype == IslandEnum.enum.MAZE then
|
||||
if Math.random(1, 38) == 1 then
|
||||
tick_tack_trap(memory.enemy_force_name, entity.surface, entity.position)
|
||||
return
|
||||
end
|
||||
|
||||
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 = 1}
|
||||
Classes.lumberjack_bonus_items(give)
|
||||
-- wood lord is disabled
|
||||
-- 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
|
||||
if class == Classes.enum.LUMBERJACK then
|
||||
give[#give + 1] = {name = 'wood', count = 1}
|
||||
Classes.lumberjack_bonus_items(give)
|
||||
end
|
||||
|
||||
if #give > 0 then
|
||||
@@ -810,19 +799,9 @@ 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
|
||||
if class == Classes.enum.LUMBERJACK then
|
||||
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(Balance.every_nth_tree_gives_coins) == 1 then --tuned
|
||||
@@ -843,12 +822,12 @@ local function event_on_player_mined_entity(event)
|
||||
local fish_amount = 0
|
||||
local to_give = {}
|
||||
|
||||
if memory.classes_table and memory.classes_table[event.player_index] and memory.classes_table[event.player_index] == Classes.enum.MASTER_ANGLER then
|
||||
if class == Classes.enum.MASTER_ANGLER then
|
||||
fish_amount = Balance.base_caught_fish_amount + Balance.master_angler_fish_bonus
|
||||
to_give[#to_give + 1] = {name = 'raw-fish', count = fish_amount}
|
||||
to_give[#to_give + 1] = {name = 'coin', count = Balance.master_angler_coin_bonus}
|
||||
|
||||
elseif memory.classes_table and memory.classes_table[event.player_index] and memory.classes_table[event.player_index] == Classes.enum.DREDGER then
|
||||
elseif class == Classes.enum.DREDGER then
|
||||
fish_amount = Balance.base_caught_fish_amount + Balance.dredger_fish_bonus
|
||||
to_give[#to_give + 1] = {name = 'raw-fish', count = fish_amount}
|
||||
to_give[#to_give + 1] = Loot.dredger_loot()[1]
|
||||
@@ -1022,22 +1001,19 @@ local function base_kill_rewards(event)
|
||||
end
|
||||
end
|
||||
|
||||
local class
|
||||
local class_is_chef = false
|
||||
|
||||
if revenge_target and
|
||||
revenge_target.valid and
|
||||
revenge_target.player and
|
||||
revenge_target.player.index and
|
||||
memory.classes_table and
|
||||
memory.classes_table[revenge_target.player.index]
|
||||
revenge_target.player.index
|
||||
then
|
||||
class = memory.classes_table[revenge_target.player.index]
|
||||
class_is_chef = Classes.get_class(revenge_target.player.index) == Classes.enum.CHEF
|
||||
end
|
||||
|
||||
local class_is_chef = (class and class == Classes.enum.CHEF) and true or false
|
||||
|
||||
|
||||
-- no worm loot in the maze except for chefs:
|
||||
local maze = (destination.subtype and destination.subtype == IslandEnum.enum.MAZE)
|
||||
local maze = destination.subtype == IslandEnum.enum.MAZE
|
||||
if maze and not (entity_name == 'biter-spawner' or entity_name == 'spitter-spawner') and not (class_is_chef) then return end
|
||||
|
||||
local iron_amount
|
||||
|
||||
@@ -9,23 +9,19 @@ local Server = require 'utils.server'
|
||||
local Math = require 'maps.pirates.math'
|
||||
local Ai = require 'maps.pirates.ai'
|
||||
local Memory = require 'maps.pirates.memory'
|
||||
local Gui = require 'maps.pirates.gui.gui'
|
||||
local Common = require 'maps.pirates.common'
|
||||
local CoreData = require 'maps.pirates.coredata'
|
||||
local PlayerColors = require 'maps.pirates.player_colors'
|
||||
local Utils = require 'maps.pirates.utils_local'
|
||||
|
||||
local Balance = require 'maps.pirates.balance'
|
||||
local Crew = require 'maps.pirates.crew'
|
||||
local Roles = require 'maps.pirates.roles.roles'
|
||||
local Structures = require 'maps.pirates.structures.structures'
|
||||
local Boats = require 'maps.pirates.structures.boats.boats'
|
||||
local Surfaces = require 'maps.pirates.surfaces.surfaces'
|
||||
local Overworld = require 'maps.pirates.overworld'
|
||||
local Islands = require 'maps.pirates.surfaces.islands.islands'
|
||||
local Progression = require 'maps.pirates.progression'
|
||||
local Crowsnest = require 'maps.pirates.surfaces.crowsnest'
|
||||
local Hold = require 'maps.pirates.surfaces.hold'
|
||||
local PiratesApiEvents = require 'maps.pirates.api_events'
|
||||
local Upgrades = require 'maps.pirates.boat_upgrades'
|
||||
local Effects = require 'maps.pirates.effects'
|
||||
@@ -39,7 +35,6 @@ local CustomEvents = require 'maps.pirates.custom_events'
|
||||
local Classes = require 'maps.pirates.roles.classes'
|
||||
|
||||
local Gui = require 'maps.pirates.gui.gui'
|
||||
local GUIcolor = require 'maps.pirates.gui.color'
|
||||
|
||||
|
||||
|
||||
@@ -232,27 +227,6 @@ end)
|
||||
-- player.print('[color=gray]' .. Roles.get_classes_print_string() .. '[/color]')
|
||||
-- end)
|
||||
|
||||
-- commands.add_command(
|
||||
-- 'classinfo',
|
||||
-- {'pirates.cmd_explain_classinfo'},
|
||||
-- function(cmd)
|
||||
-- local param = tostring(cmd.parameter)
|
||||
-- local player = game.players[cmd.player_index]
|
||||
-- if not Common.validate_player(player) then return end
|
||||
|
||||
-- if param and param ~= 'nil' then
|
||||
-- local string = Roles.get_class_print_string(param, false)
|
||||
-- if string then
|
||||
-- Common.notify_player_expected(player, {'', {'pirates.class_definition_for'}, ' ', string})
|
||||
-- else
|
||||
-- Common.notify_player_error(player, {'pirates.cmd_error_invalid_class_name', param})
|
||||
-- end
|
||||
-- else
|
||||
-- --Common.notify_player_expected(player, '/classinfo {classname} returns the definition of the named class.')
|
||||
-- Common.notify_player_expected(player, {'', '/classinfo ', {'pirates.cmd_explain_classinfo'}})
|
||||
-- end
|
||||
-- end)
|
||||
|
||||
commands.add_command(
|
||||
'classinfo',
|
||||
{'pirates.cmd_explain_classinfo'},
|
||||
@@ -484,24 +458,6 @@ function(cmd)
|
||||
end
|
||||
end)
|
||||
|
||||
-- Equip a class passed in parameter (although I think this command is redundant since there is /take command?)
|
||||
commands.add_command(
|
||||
'setclass',
|
||||
{'pirates.cmd_explain_dev'},
|
||||
function(cmd)
|
||||
cmd_set_memory(cmd)
|
||||
|
||||
local param = tostring(cmd.parameter)
|
||||
if check_admin(cmd) then
|
||||
local player = game.players[cmd.player_index]
|
||||
local memory = Memory.get_crew_memory()
|
||||
if not Common.validate_player(player) then return end
|
||||
if not memory.classes_table then memory.classes_table = {} end
|
||||
memory.classes_table[player.index] = param
|
||||
player.print('Set own class to ' .. param .. '.')
|
||||
end
|
||||
end)
|
||||
|
||||
commands.add_command(
|
||||
'setevo',
|
||||
{'pirates.cmd_explain_dev'},
|
||||
@@ -621,7 +577,9 @@ function(cmd)
|
||||
local memory = Memory.get_crew_memory()
|
||||
if not Common.is_id_valid(memory.id) then return end
|
||||
local player = game.players[cmd.player_index]
|
||||
Classes.try_unlock_class(param, player, true)
|
||||
if not Classes.try_unlock_class(param, player, true) then
|
||||
Common.notify_player_error(player, {'pirates.cmd_error_invalid_class_name', param})
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
|
||||
@@ -327,98 +327,96 @@ end
|
||||
|
||||
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
|
||||
if not event.player_index then return end
|
||||
|
||||
local player = game.players[event.player_index]
|
||||
if not player then return end
|
||||
if not player.valid then return end
|
||||
if not player.character then return end
|
||||
if not player.character.valid then return end
|
||||
|
||||
if not event.item then return end
|
||||
if event.item.name ~= 'raw-fish' then return end
|
||||
|
||||
local class = Public.get_class(player.index)
|
||||
if not class then return end
|
||||
|
||||
local crew_id = Common.get_id_from_force_name(player.force.name)
|
||||
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
|
||||
|
||||
local global_memory = Memory.get_global_memory()
|
||||
global_memory.last_players_health[event.player_index] = player.character.health
|
||||
|
||||
if memory.classes_table and memory.classes_table[player_index] then
|
||||
local class = memory.classes_table[player_index]
|
||||
if class == Public.enum.GOURMET then
|
||||
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
|
||||
if class == Public.enum.GOURMET then
|
||||
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
|
||||
end
|
||||
end
|
||||
end
|
||||
if multiplier > 0 then
|
||||
-- Idea behind this: A diminishing return for ore granted every time fish is eaten. But slowly "reset" the diminishing return overtime
|
||||
local timescale = 60*30 * Math.max((Balance.game_slowness_scale())^(2/3),0.8)
|
||||
if memory.gourmet_recency_tick then
|
||||
multiplier = multiplier * Math.clamp(0.2, 5, (1/5)^((memory.gourmet_recency_tick - game.tick)/(60*300)))
|
||||
memory.gourmet_recency_tick = Math.max(memory.gourmet_recency_tick, game.tick - timescale*10) + timescale
|
||||
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
|
||||
end
|
||||
end
|
||||
multiplier = multiplier * 5
|
||||
memory.gourmet_recency_tick = game.tick - timescale*10 + timescale
|
||||
end
|
||||
if multiplier > 0 then
|
||||
-- Idea behind this: A diminishing return for ore granted every time fish is eaten. But slowly "reset" the diminishing return overtime
|
||||
local timescale = 60*30 * Math.max((Balance.game_slowness_scale())^(2/3),0.8)
|
||||
if memory.gourmet_recency_tick then
|
||||
multiplier = multiplier * Math.clamp(0.2, 5, (1/5)^((memory.gourmet_recency_tick - game.tick)/(60*300)))
|
||||
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
|
||||
Public.class_ore_grant(player, 15 * multiplier, Balance.gourmet_ore_scaling_enabled)
|
||||
Public.class_ore_grant(player, 15 * multiplier, Balance.gourmet_ore_scaling_enabled)
|
||||
end
|
||||
elseif class == Public.enum.ROCK_EATER then
|
||||
local required_count = Balance.rock_eater_required_stone_furnace_to_heal_count
|
||||
if player.get_item_count('stone-furnace') >= required_count then
|
||||
player.remove_item({name='stone-furnace', count=required_count})
|
||||
player.insert({name='raw-fish', count=1})
|
||||
end
|
||||
elseif class == Public.enum.SOLDIER then
|
||||
local chance = Balance.soldier_defender_summon_chance
|
||||
if Math.random() < chance then
|
||||
local random_vec = Math.random_vec(3)
|
||||
local e = player.surface.create_entity{
|
||||
name = 'defender',
|
||||
position = Utils.psum{player.character.position, random_vec},
|
||||
speed = 1.5,
|
||||
force = player.force
|
||||
}
|
||||
if e and e.valid then
|
||||
e.combat_robot_owner = player.character
|
||||
end
|
||||
elseif class == Public.enum.ROCK_EATER then
|
||||
local required_count = Balance.rock_eater_required_stone_furnace_to_heal_count
|
||||
if player.get_item_count('stone-furnace') >= required_count then
|
||||
player.remove_item({name='stone-furnace', count=required_count})
|
||||
player.insert({name='raw-fish', count=1})
|
||||
end
|
||||
elseif class == Public.enum.SOLDIER then
|
||||
local chance = Balance.soldier_defender_summon_chance
|
||||
if Math.random() < chance then
|
||||
local random_vec = Math.random_vec(3)
|
||||
local e = player.surface.create_entity{
|
||||
name = 'defender',
|
||||
position = Utils.psum{player.character.position, random_vec},
|
||||
speed = 1.5,
|
||||
force = player.force
|
||||
}
|
||||
if e and e.valid then
|
||||
e.combat_robot_owner = player.character
|
||||
end
|
||||
end
|
||||
elseif class == Public.enum.VETERAN then
|
||||
local chance = Balance.veteran_destroyer_summon_chance
|
||||
if Math.random() < chance then
|
||||
local random_vec = Math.random_vec(3)
|
||||
local e = player.surface.create_entity{
|
||||
name = 'destroyer',
|
||||
position = Utils.psum{player.character.position, random_vec},
|
||||
speed = 1.5,
|
||||
force = player.force
|
||||
}
|
||||
if e and e.valid then
|
||||
e.combat_robot_owner = player.character
|
||||
end
|
||||
end
|
||||
elseif class == Public.enum.VETERAN then
|
||||
local chance = Balance.veteran_destroyer_summon_chance
|
||||
if Math.random() < chance then
|
||||
local random_vec = Math.random_vec(3)
|
||||
local e = player.surface.create_entity{
|
||||
name = 'destroyer',
|
||||
position = Utils.psum{player.character.position, random_vec},
|
||||
speed = 1.5,
|
||||
force = player.force
|
||||
}
|
||||
if e and e.valid then
|
||||
e.combat_robot_owner = player.character
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -454,6 +452,8 @@ function Public.try_unlock_class(class_for_sale, player, force_unlock)
|
||||
return false
|
||||
end
|
||||
|
||||
if not Public.class_is_obtainable(class_for_sale) then return false end
|
||||
|
||||
if required_class then
|
||||
-- check if pre-requisite class is taken by someone
|
||||
for p_index, chosen_class in pairs(memory.classes_table) do
|
||||
|
||||
@@ -100,9 +100,9 @@ function Public.tag_text(player)
|
||||
tags[#tags + 1] = 'Officer'
|
||||
end
|
||||
|
||||
local classes_table = memory.classes_table
|
||||
if classes_table and classes_table[player.index] then
|
||||
tags[#tags + 1] = Classes.eng_form[classes_table[player.index]]
|
||||
local class = Classes.get_class(player.index)
|
||||
if class then
|
||||
tags[#tags + 1] = Classes.eng_form[class]
|
||||
end
|
||||
|
||||
for i, t in ipairs(tags) do
|
||||
@@ -223,9 +223,11 @@ function Public.player_left_so_redestribute_roles(player)
|
||||
|
||||
local memory = Memory.get_crew_memory()
|
||||
|
||||
local class = Classes.get_class(player.index)
|
||||
|
||||
-- free up the class
|
||||
if memory.classes_table and memory.classes_table[player.index] then
|
||||
memory.spare_classes[#memory.spare_classes + 1] = memory.classes_table[player.index]
|
||||
if class then
|
||||
memory.spare_classes[#memory.spare_classes + 1] = class
|
||||
memory.classes_table[player.index] = nil
|
||||
|
||||
for _, class_entry in ipairs(memory.unlocked_classes) do
|
||||
|
||||
@@ -26,8 +26,7 @@ function Public.class_update_auxiliary_data(tickinterval)
|
||||
|
||||
for _, player in pairs(crew) do
|
||||
local player_index = player.index
|
||||
local class = memory.classes_table[player_index]
|
||||
if class and class == Classes.enum.IRON_LEG then
|
||||
if Classes.get_class(player_index) == Classes.enum.IRON_LEG then
|
||||
if (not class_auxiliary_data[player_index]) then class_auxiliary_data[player_index] = {} end
|
||||
local data = class_auxiliary_data[player_index]
|
||||
processed_players[player_index] = true
|
||||
@@ -68,7 +67,7 @@ function Public.class_renderings(tickinterval)
|
||||
|
||||
for _, player in pairs(crew) do
|
||||
local player_index = player.index
|
||||
local class = memory.classes_table[player_index]
|
||||
local class = Classes.get_class(player_index)
|
||||
if class then
|
||||
if not class_renderings[player_index] then class_renderings[player_index] = {} end
|
||||
local rendering_data = class_renderings[player_index]
|
||||
@@ -166,7 +165,7 @@ function Public.update_character_properties(tickinterval)
|
||||
if Common.validate_player_and_character(player) then
|
||||
local player_index = player.index
|
||||
local character = player.character
|
||||
local class = memory.classes_table and memory.classes_table[player_index] or nil
|
||||
local class = Classes.get_class(player_index)
|
||||
if class then
|
||||
--local max_reach_bonus = 0
|
||||
-- if memory.classes_table[player_index] == Classes.enum.DECKHAND then
|
||||
@@ -186,6 +185,35 @@ function Public.update_character_properties(tickinterval)
|
||||
character.character_reach_distance_bonus = 0
|
||||
end
|
||||
|
||||
|
||||
local speed_boost = Balance.base_extra_character_speed
|
||||
|
||||
if memory.speed_boost_characters and memory.speed_boost_characters[player_index] then
|
||||
speed_boost = speed_boost * Balance.respawn_speed_boost
|
||||
elseif class == Classes.enum.SCOUT then
|
||||
speed_boost = speed_boost * Balance.scout_extra_speed
|
||||
elseif (class == Classes.enum.DECKHAND) or (class == Classes.enum.BOATSWAIN) or (class == Classes.enum.SHORESMAN) then
|
||||
local surfacedata = Surfaces.SurfacesCommon.decode_surface_name(player.surface.name)
|
||||
local type = surfacedata.type
|
||||
local on_ship_bool = (type == Surfaces.enum.HOLD) or (type == Surfaces.enum.CABIN) or (type == Surfaces.enum.CROWSNEST) or (player.surface.name == memory.boat.surface_name and Boats.on_boat(memory.boat, player.position))
|
||||
local hold_bool = (type == Surfaces.enum.HOLD)
|
||||
|
||||
if class == Classes.enum.DECKHAND then
|
||||
if on_ship_bool and (not hold_bool) then
|
||||
speed_boost = speed_boost * Balance.deckhand_extra_speed
|
||||
end
|
||||
elseif class == Classes.enum.BOATSWAIN then
|
||||
if hold_bool then
|
||||
speed_boost = speed_boost * Balance.boatswain_extra_speed
|
||||
end
|
||||
elseif class == Classes.enum.SHORESMAN then
|
||||
if not on_ship_bool then
|
||||
speed_boost = speed_boost * Balance.shoresman_extra_speed
|
||||
end
|
||||
end
|
||||
end
|
||||
character.character_running_speed_modifier = speed_boost - 1
|
||||
|
||||
--character.character_reach_distance_bonus = max_reach_bonus
|
||||
end
|
||||
|
||||
@@ -217,36 +245,6 @@ function Public.update_character_properties(tickinterval)
|
||||
-- player.character_inventory_slots_bonus = 0
|
||||
-- end
|
||||
-- end
|
||||
|
||||
local speed_boost = Balance.base_extra_character_speed
|
||||
|
||||
if memory.speed_boost_characters and memory.speed_boost_characters[player_index] then
|
||||
speed_boost = speed_boost * Balance.respawn_speed_boost
|
||||
elseif memory.classes_table and memory.classes_table[player_index] then
|
||||
if class == Classes.enum.SCOUT then
|
||||
speed_boost = speed_boost * Balance.scout_extra_speed
|
||||
elseif (class == Classes.enum.DECKHAND) or (class == Classes.enum.BOATSWAIN) or (class == Classes.enum.SHORESMAN) then
|
||||
local surfacedata = Surfaces.SurfacesCommon.decode_surface_name(player.surface.name)
|
||||
local type = surfacedata.type
|
||||
local on_ship_bool = (type == Surfaces.enum.HOLD) or (type == Surfaces.enum.CABIN) or (type == Surfaces.enum.CROWSNEST) or (player.surface.name == memory.boat.surface_name and Boats.on_boat(memory.boat, player.position))
|
||||
local hold_bool = (type == Surfaces.enum.HOLD)
|
||||
|
||||
if class == Classes.enum.DECKHAND then
|
||||
if on_ship_bool and (not hold_bool) then
|
||||
speed_boost = speed_boost * Balance.deckhand_extra_speed
|
||||
end
|
||||
elseif class == Classes.enum.BOATSWAIN then
|
||||
if hold_bool then
|
||||
speed_boost = speed_boost * Balance.boatswain_extra_speed
|
||||
end
|
||||
elseif class == Classes.enum.SHORESMAN then
|
||||
if not on_ship_bool then
|
||||
speed_boost = speed_boost * Balance.shoresman_extra_speed
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
character.character_running_speed_modifier = speed_boost - 1
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -257,40 +255,37 @@ function Public.class_rewards_tick(tickinterval)
|
||||
local crew = Common.crew_get_crew_members()
|
||||
|
||||
for _, player in pairs(crew) do
|
||||
local class = Classes.get_class(player.index)
|
||||
if Common.validate_player_and_character(player) and
|
||||
game.tick % tickinterval == 0 and
|
||||
memory.classes_table and
|
||||
memory.classes_table[player.index]
|
||||
then
|
||||
local class = memory.classes_table[player.index]
|
||||
class and
|
||||
not Boats.is_boat_at_sea() and --it is possible to spend infinite time here, so don't give out freebies
|
||||
(
|
||||
class == Classes.enum.DECKHAND or
|
||||
class == Classes.enum.SHORESMAN or
|
||||
class == Classes.enum.BOATSWAIN or
|
||||
class == Classes.enum.QUARTERMASTER
|
||||
)
|
||||
then --watch out for this line! (why?)
|
||||
local surfacedata = Surfaces.SurfacesCommon.decode_surface_name(player.surface.name)
|
||||
local type = surfacedata.type
|
||||
local on_ship_bool = (type == Surfaces.enum.HOLD) or (type == Surfaces.enum.CABIN) or (type == Surfaces.enum.CROWSNEST) or (player.surface.name == memory.boat.surface_name and Boats.on_boat(memory.boat, player.position))
|
||||
local hold_bool = (type == Surfaces.enum.HOLD)
|
||||
|
||||
if not Boats.is_boat_at_sea() and --it is possible to spend infinite time here, so don't give out freebies
|
||||
(
|
||||
class == Classes.enum.DECKHAND or
|
||||
class == Classes.enum.SHORESMAN or
|
||||
class == Classes.enum.BOATSWAIN or
|
||||
class == Classes.enum.QUARTERMASTER
|
||||
)
|
||||
then --watch out for this line! (why?)
|
||||
local surfacedata = Surfaces.SurfacesCommon.decode_surface_name(player.surface.name)
|
||||
local type = surfacedata.type
|
||||
local on_ship_bool = (type == Surfaces.enum.HOLD) or (type == Surfaces.enum.CABIN) or (type == Surfaces.enum.CROWSNEST) or (player.surface.name == memory.boat.surface_name and Boats.on_boat(memory.boat, player.position))
|
||||
local hold_bool = (type == Surfaces.enum.HOLD)
|
||||
if class == Classes.enum.DECKHAND and on_ship_bool and (not hold_bool) then
|
||||
Classes.class_ore_grant(player, Balance.deckhand_ore_grant_multiplier, Balance.deckhand_ore_scaling_enabled)
|
||||
elseif class == Classes.enum.BOATSWAIN and hold_bool then
|
||||
Classes.class_ore_grant(player, Balance.boatswain_ore_grant_multiplier, Balance.boatswain_ore_scaling_enabled)
|
||||
elseif class == Classes.enum.SHORESMAN and (not on_ship_bool) then
|
||||
Classes.class_ore_grant(player, Balance.shoresman_ore_grant_multiplier, Balance.shoresman_ore_scaling_enabled)
|
||||
elseif class == Classes.enum.QUARTERMASTER then
|
||||
local nearby_players = #player.surface.find_entities_filtered{position = player.position, radius = Balance.quartermaster_range, name = 'character'}
|
||||
|
||||
if class == Classes.enum.DECKHAND and on_ship_bool and (not hold_bool) then
|
||||
Classes.class_ore_grant(player, Balance.deckhand_ore_grant_multiplier, Balance.deckhand_ore_scaling_enabled)
|
||||
elseif class == Classes.enum.BOATSWAIN and hold_bool then
|
||||
Classes.class_ore_grant(player, Balance.boatswain_ore_grant_multiplier, Balance.boatswain_ore_scaling_enabled)
|
||||
elseif class == Classes.enum.SHORESMAN and (not on_ship_bool) then
|
||||
Classes.class_ore_grant(player, Balance.shoresman_ore_grant_multiplier, Balance.shoresman_ore_scaling_enabled)
|
||||
elseif class == Classes.enum.QUARTERMASTER then
|
||||
local nearby_players = #player.surface.find_entities_filtered{position = player.position, radius = Balance.quartermaster_range, name = 'character'}
|
||||
|
||||
if nearby_players > 1 then
|
||||
Classes.class_ore_grant(player, nearby_players - 1, Balance.quartermaster_ore_scaling_enabled)
|
||||
end
|
||||
if nearby_players > 1 then
|
||||
Classes.class_ore_grant(player, nearby_players - 1, Balance.quartermaster_ore_scaling_enabled)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- Smoldering class is disabled
|
||||
-- if memory.classes_table and memory.classes_table[player.index] then
|
||||
@@ -312,7 +307,6 @@ function Public.class_rewards_tick(tickinterval)
|
||||
-- end
|
||||
-- end
|
||||
-- end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user