mirror of
https://github.com/ComfyFactory/ComfyFactorio.git
synced 2025-01-26 03:52:22 +02:00
Fixed class issues
Changes: - Fixed class GUI issues - added /remove_classes command (removes all classes) - made /unlock <class> command available while not in debug as well (unlocks a class)
This commit is contained in:
parent
81b81305b6
commit
e37f74a7e3
@ -1,6 +1,6 @@
|
||||
require 'utils.data_stages'
|
||||
_LIFECYCLE = _STAGE.control -- Control stage
|
||||
_DEBUG = true
|
||||
_DEBUG = false
|
||||
_DUMP_ENV = false
|
||||
|
||||
require 'utils.server'
|
||||
@ -112,7 +112,7 @@ require 'utils.freeplay'
|
||||
--require 'maps.chronosphere.main'
|
||||
|
||||
--![[Adventure as a crew of pirates]]--
|
||||
require 'maps.pirates.main'
|
||||
--require 'maps.pirates.main'
|
||||
|
||||
--![[Launch rockets in increasingly harder getting worlds.]]--
|
||||
--require 'maps.journey.main'
|
||||
|
@ -16,7 +16,7 @@ softmod_info_tips_1=Features of the game that are hard to work out alone
|
||||
softmod_info_tips_2=• The captain can steer the boat from the crow's nest by placing 100 rail signals in one of the blue boxes.\n• Resources granted to the ship appear in the captain's cabin.\n• Charging a silo drains power from everything else on its network.\n• The quantity of ore available on an island is independent of the order in which you break rocks.\n• Passive pollution ramps up over time on each island.\n• The strength of attacks is proportional to the number of remaining nests. (The time-based rate of evolution is proportional to nests too, but destroying a nest will immediately jump evolution by most of the amount it 'would have' made had it survived.)\n• Lab productivity increases with each league.\n• item-on-ground entities on the deck are moved to the cabin when the boat moves, for performance reasons.\n• Commands: /ccolor gives you a fun color. /classinfo {classname} gives the description of the named class. To manage your class, use /take {classname} or /giveup.
|
||||
|
||||
softmod_info_updates_1=Significant recent changes
|
||||
softmod_info_updates_2=v1.3.2\n• Fixed a case where class could remain taken when last player in crew left the game.\n• Classes that generate ore passively now don't generate ore when at sea\n\nv1.3.1\n• Fixed quartermaster and its tooltip. Also buffed physical damage buff it provides to nearby players from 10% to 30%.\n• Slightly increased amount of items received from purchasing items in covered structure market\n\nv1.3\n• Hold chests are now destructible.\n• Fluid is now transportable between decks.\n• New classes, and new 'Class Window'.\n• Many other improvements, small features, and balance changes.\n\nv1.2\n• Mod portal release.
|
||||
softmod_info_updates_2=v1.3.2\n• Fixed a case where class could remain taken when last player in crew left the game.\n• Fixed a case where buying a class upgrade would wrongly update the unlocked classes and cause some classes to be untakable\n• Classes that generate ore passively now don't generate ore when at sea\n\nv1.3.1\n• Fixed quartermaster and its tooltip. Also buffed physical damage buff it provides to nearby players from 10% to 30%.\n• Slightly increased amount of items received from purchasing items in covered structure market\n\nv1.3\n• Hold chests are now destructible.\n• Fluid is now transportable between decks.\n• New classes, and new 'Class Window'.\n• Many other improvements, small features, and balance changes.\n\nv1.2\n• Mod portal release.
|
||||
|
||||
softmod_info_credits_1=Credits
|
||||
softmod_info_credits_2=Pirate Ship designed and coded by thesixthroc. Updates from Piratux. Comfy codebase and help from Gerkiz, Hanakocz and Mew @ Comfy Industries (https://getcomfy.eu). Some island structure blueprints contributed by Mattisso.\n\nCome chat with us: https://getcomfy.eu/discord\n\n"Those white gloves. I'll never forget them 'till the day I die." - Dr. John
|
||||
|
@ -310,13 +310,14 @@ local function damage_to_players_changes(event)
|
||||
-- if not (event.cause.name == 'small-biter') or (event.cause.name == 'small-spitter') or (event.cause.name == 'medium-biter') or (event.cause.name == 'medium-spitter') or (event.cause.name == 'big-biter') or (event.cause.name == 'big-spitter') or (event.cause.name == 'behemoth-biter') or (event.cause.name == 'behemoth-spitter') then return end
|
||||
|
||||
local player_index = event.entity.player.index
|
||||
local class = memory.classes_table and memory.classes_table[player_index]
|
||||
local player = game.players[player_index]
|
||||
|
||||
if not (player and player.valid and player.character and player.character.valid) then
|
||||
return
|
||||
end
|
||||
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
|
||||
|
||||
local class = Classes.get_class(player_index)
|
||||
local damage_multiplier = 1
|
||||
|
||||
--game.print('on damage info: {name: ' .. event.damage_type.name .. ', object_name: ' .. event.damage_type.object_name .. '}')
|
||||
@ -436,15 +437,15 @@ local function damage_dealt_by_players_changes(event)
|
||||
local acid = event.damage_type.name == 'acid'
|
||||
|
||||
local player_index = player.index
|
||||
local class = memory.classes_table and memory.classes_table[player_index]
|
||||
local class = Classes.get_class(player_index)
|
||||
|
||||
if class and class == Classes.enum.SCOUT and event.final_health > 0 then --lethal damage must be unaffected
|
||||
event.entity.health = event.entity.health + (1 - Balance.scout_damage_dealt_multiplier) * event.final_damage_amount
|
||||
elseif class and (class == Classes.enum.SAMURAI or class == Classes.enum.HATAMOTO) then
|
||||
local samurai = memory.classes_table[player_index] == Classes.enum.SAMURAI
|
||||
local hatamoto = memory.classes_table[player_index] == Classes.enum.HATAMOTO
|
||||
local samurai = class == Classes.enum.SAMURAI
|
||||
local hatamoto = class == Classes.enum.HATAMOTO
|
||||
|
||||
--==Note this!
|
||||
--==Note this! (what the hell is this)
|
||||
if not (samurai or hatamoto) then return end
|
||||
|
||||
local no_weapon = (not (character.get_inventory(defines.inventory.character_guns) and character.get_inventory(defines.inventory.character_guns)[character.selected_gun_index] and character.get_inventory(defines.inventory.character_guns)[character.selected_gun_index].valid_for_read))
|
||||
@ -786,6 +787,7 @@ local function event_on_player_mined_entity(event)
|
||||
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}
|
||||
|
@ -38,6 +38,7 @@ local Highscore = require 'maps.pirates.highscore'
|
||||
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'
|
||||
|
||||
|
||||
@ -609,6 +610,46 @@ function(cmd)
|
||||
end
|
||||
end)
|
||||
|
||||
-- Unlock a class
|
||||
commands.add_command(
|
||||
'unlock',
|
||||
{'pirates.cmd_explain_dev'},
|
||||
function(cmd)
|
||||
cmd_set_memory(cmd)
|
||||
local param = tostring(cmd.parameter)
|
||||
if check_admin(cmd) then
|
||||
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)
|
||||
end
|
||||
end)
|
||||
|
||||
-- Remove all classes
|
||||
commands.add_command(
|
||||
'remove_classes',
|
||||
{'pirates.cmd_explain_dev'},
|
||||
function(cmd)
|
||||
cmd_set_memory(cmd)
|
||||
local param = tostring(cmd.parameter)
|
||||
if check_admin(cmd) then
|
||||
local memory = Memory.get_crew_memory()
|
||||
if not Common.is_id_valid(memory.id) then return end
|
||||
|
||||
if not Gui.classes then return end
|
||||
|
||||
memory.spare_classes = {}
|
||||
memory.classes_table = {}
|
||||
memory.unlocked_classes = {}
|
||||
memory.available_classes_pool = Classes.initial_class_pool()
|
||||
|
||||
local players = Common.crew_get_crew_members_and_spectators()
|
||||
|
||||
for _, player in pairs(players) do
|
||||
Gui.classes.full_update(player, true)
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
if _DEBUG then
|
||||
|
||||
@ -1181,21 +1222,6 @@ if _DEBUG then
|
||||
end
|
||||
end)
|
||||
|
||||
-- Unlock a class
|
||||
commands.add_command(
|
||||
'unlock',
|
||||
{'pirates.cmd_explain_dev'},
|
||||
function(cmd)
|
||||
cmd_set_memory(cmd)
|
||||
local param = tostring(cmd.parameter)
|
||||
if check_admin(cmd) then
|
||||
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)
|
||||
end
|
||||
end)
|
||||
|
||||
commands.add_command(
|
||||
'piratux_test',
|
||||
'is a dev command of piratux.',
|
||||
|
@ -168,7 +168,14 @@ end
|
||||
|
||||
|
||||
|
||||
function Public.full_update(player)
|
||||
function Public.full_update(player, force_refresh)
|
||||
force_refresh = force_refresh or nil
|
||||
-- close and open the window to reconstruct the window (not really necessary when window is closed, but doesn't really matter as it should be ran once and only when necessary)
|
||||
if force_refresh then
|
||||
Public.toggle_window(player)
|
||||
Public.toggle_window(player)
|
||||
end
|
||||
|
||||
if not player.gui.screen[window_name .. '_piratewindow'] then return end
|
||||
local flow = player.gui.screen[window_name .. '_piratewindow']
|
||||
|
||||
|
@ -33,10 +33,12 @@ ComfyGui.set_disabled_tab('Groups', true)
|
||||
|
||||
|
||||
local Public = {}
|
||||
-- this seems to be never used
|
||||
local enum = {
|
||||
PROGRESS = 'progress',
|
||||
RUNS = 'runs',
|
||||
CREW = 'crew',
|
||||
CLASSES = 'classes',
|
||||
FUEL = 'fuel',
|
||||
MINIMAP = 'minimap',
|
||||
INFO = 'info',
|
||||
@ -54,6 +56,8 @@ Public.color = require 'maps.pirates.gui.color'
|
||||
|
||||
|
||||
function Public.update_crew_gui(which_gui)
|
||||
if not Public[which_gui] then return end
|
||||
|
||||
local players = Common.crew_get_crew_members_and_spectators()
|
||||
|
||||
for _, player in pairs(players) do
|
||||
|
@ -79,6 +79,7 @@ function Public.initialise_crew_memory(id) --mostly serves as a dev reference of
|
||||
|
||||
memory.available_classes_pool = nil
|
||||
-- Duplicating unlocked classes data for consistency reasons (this way, entries will remain in the same order when unlocked class data changes)
|
||||
-- @TODO Might have to consider sacrificing consistency(or find a way to retain consistency) to reduce the chance of contradicting data which results in weird bugs (this happened once already)
|
||||
memory.unlocked_classes = nil
|
||||
|
||||
memory.seconds_until_alert_sound_can_be_played_again = 0
|
||||
|
@ -443,8 +443,12 @@ function Public.lumberjack_bonus_items(give_table)
|
||||
end
|
||||
|
||||
function Public.try_unlock_class(class_for_sale, player, force_unlock)
|
||||
force_unlock = force_unlock or nil
|
||||
local memory = Memory.get_crew_memory()
|
||||
|
||||
if not class_for_sale then return false end
|
||||
if not player then return false end
|
||||
|
||||
local required_class = Public.class_purchase_requirement[class_for_sale]
|
||||
|
||||
if not (memory.classes_table and memory.spare_classes) then
|
||||
@ -459,7 +463,7 @@ function Public.try_unlock_class(class_for_sale, player, force_unlock)
|
||||
|
||||
-- update GUI data
|
||||
for _, class_entry in ipairs(memory.unlocked_classes) do
|
||||
if class_entry.taken_by == player.index then
|
||||
if class_entry.taken_by == p_index then
|
||||
class_entry.class = class_for_sale
|
||||
break
|
||||
end
|
||||
@ -518,6 +522,25 @@ function Public.try_unlock_class(class_for_sale, player, force_unlock)
|
||||
return false
|
||||
end
|
||||
|
||||
function Public.has_class(player_index)
|
||||
local memory = Memory.get_crew_memory()
|
||||
|
||||
if memory.classes_table and memory.classes_table[player_index] then
|
||||
return true
|
||||
else
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
function Public.get_class(player_index)
|
||||
local memory = Memory.get_crew_memory()
|
||||
|
||||
if Public.has_class(player_index) then
|
||||
return memory.classes_table[player_index]
|
||||
else
|
||||
return nil
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
local event = require 'utils.event'
|
||||
|
@ -211,7 +211,7 @@ function Public.event_on_market_item_purchased(event)
|
||||
-- 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)
|
||||
local ok = Classes.try_unlock_class(class_for_sale, player, false)
|
||||
|
||||
if ok then
|
||||
if force and force.valid then
|
||||
|
Loading…
x
Reference in New Issue
Block a user