mirror of
https://github.com/ComfyFactory/ComfyFactorio.git
synced 2025-01-24 03:47:58 +02:00
v1.0.4.6
This commit is contained in:
parent
8561df034e
commit
cdfb9e0d66
@ -154,7 +154,8 @@ function Public.flying_text_small(surface, position, text) --differs just in the
|
||||
surface.create_entity(
|
||||
{
|
||||
name = 'flying-text',
|
||||
position = {position.x - 0.06, position.y - 1.5},
|
||||
position = {position.x - 0.08, position.y - 1.5},
|
||||
-- position = {position.x - 0.06, position.y - 1.5},
|
||||
text = text,
|
||||
}
|
||||
)
|
||||
|
@ -5,8 +5,8 @@ local inspect = require 'utils.inspect'.inspect
|
||||
local Public = {}
|
||||
|
||||
Public.scenario_id_name = 'pirates'
|
||||
Public.version_string = '1.0.4.5.2'
|
||||
Public.version_float = 1.0452
|
||||
Public.version_string = '1.0.4.6'
|
||||
Public.version_float = 1.046
|
||||
|
||||
Public.blueprint_library_allowed = true
|
||||
Public.blueprint_importing_allowed = true
|
||||
|
@ -666,8 +666,8 @@ local function event_on_player_mined_entity(event)
|
||||
give[#give + 1] = {name = 'coin', count = 3}
|
||||
give[#give + 1] = {name = entity.name, count = 7}
|
||||
elseif memory.classes_table and memory.classes_table[event.player_index] and memory.classes_table[event.player_index] == Classes.enum.CHIEF_EXCAVATOR then
|
||||
give[#give + 1] = {name = 'coin', count = 5}
|
||||
give[#give + 1] = {name = entity.name, count = 14}
|
||||
give[#give + 1] = {name = 'coin', count = 4}
|
||||
give[#give + 1] = {name = entity.name, count = 12}
|
||||
else
|
||||
if memory.overworldx > 0 then
|
||||
give[#give + 1] = {name = 'coin', count = 1}
|
||||
@ -1461,36 +1461,6 @@ local function event_on_market_item_purchased(event)
|
||||
Shop.event_on_market_item_purchased(event)
|
||||
end
|
||||
|
||||
local function event_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
|
||||
|
||||
if memory.classes_table and memory.classes_table[player_index] then
|
||||
local class = memory.classes_table[player_index]
|
||||
if class == Classes.enum.SAMURAI then
|
||||
-- vanilla heal is 80HP
|
||||
player.character.health = player.character.health + 200
|
||||
elseif class == Classes.enum.HATAMOTO then
|
||||
player.character.health = player.character.health + 350
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
local remove_boost_movement_speed_on_respawn =
|
||||
@ -1584,7 +1554,6 @@ event.add(defines.events.on_rocket_launched, event_on_rocket_launched)
|
||||
event.add(defines.events.on_console_chat, event_on_console_chat)
|
||||
event.add(defines.events.on_market_item_purchased, event_on_market_item_purchased)
|
||||
event.add(defines.events.on_player_respawned, event_on_player_respawned)
|
||||
event.add(defines.events.on_player_used_capsule, event_on_player_used_capsule)
|
||||
|
||||
|
||||
return Public
|
@ -26,6 +26,8 @@ local enum = {
|
||||
IRON_LEG = 14,
|
||||
QUARTERMASTER = 15,
|
||||
DREDGER = 16,
|
||||
SMOLDERING = 17,
|
||||
GOURMET = 18,
|
||||
}
|
||||
Public.enum = enum
|
||||
|
||||
@ -46,6 +48,8 @@ Public.Class_List = {
|
||||
enum.IRON_LEG,
|
||||
enum.QUARTERMASTER,
|
||||
enum.DREDGER,
|
||||
enum.SMOLDERING,
|
||||
enum.GOURMET,
|
||||
}
|
||||
|
||||
Public.display_form = {
|
||||
@ -65,6 +69,8 @@ Public.display_form = {
|
||||
[enum.IRON_LEG] = 'Iron Leg',
|
||||
[enum.QUARTERMASTER] = 'Quartermaster',
|
||||
[enum.DREDGER] = 'Dredger',
|
||||
[enum.SMOLDERING] = 'Smoldering',
|
||||
[enum.GOURMET] = 'Gourmet',
|
||||
}
|
||||
Public.explanation = {
|
||||
[enum.DECKHAND] = 'They move faster and generate ore for the captain\'s cabin whilst onboard above deck, but move slower offboard.',
|
||||
@ -81,14 +87,16 @@ Public.explanation = {
|
||||
[enum.CHIEF_EXCAVATOR] = 'They find many more resources when handmining ore.',
|
||||
[enum.HATAMOTO] = 'They are very tough, and *with no weapon equipped* fight well by melee.',
|
||||
[enum.IRON_LEG] = 'They are very resistant to damage when carrying 2500 iron ore.',
|
||||
[enum.QUARTERMASTER] = 'Nearby crew generate a little ore for the captain\'s cabin, and have extra physical attack.',
|
||||
[enum.QUARTERMASTER] = 'Nearby crewmates generate a little ore for the captain\'s cabin, and have extra physical attack.',
|
||||
[enum.DREDGER] = 'They find surprising items when they fish.',
|
||||
[enum.SMOLDERING] = 'They periodically convert wood into coal, if they have less than 25 coal.',
|
||||
[enum.GOURMET] = 'They generate ore for the captain\'s cabin by eating fish in fancy locations on an empty stomach.',
|
||||
}
|
||||
|
||||
Public.class_unlocks = {
|
||||
[enum.FISHERMAN] = {enum.MASTER_ANGLER},
|
||||
[enum.LUMBERJACK] = {enum.WOOD_LORD},
|
||||
[enum.PROSPECTOR] = {enum.CHIEF_EXCAVATOR},
|
||||
-- [enum.PROSPECTOR] = {enum.CHIEF_EXCAVATOR}, --breaks the resource pressure in the game too strongly I think
|
||||
[enum.SAMURAI] = {enum.HATAMOTO},
|
||||
[enum.MASTER_ANGLER] = {enum.DREDGER},
|
||||
}
|
||||
@ -96,31 +104,29 @@ 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,
|
||||
}
|
||||
|
||||
function Public.initial_class_pool()
|
||||
-- if _DEBUG then
|
||||
-- return {
|
||||
-- enum.QUARTERMASTER,
|
||||
-- }
|
||||
-- end
|
||||
return {
|
||||
enum.DECKHAND,
|
||||
enum.DECKHAND, --good for afk players
|
||||
enum.SHORESMAN,
|
||||
enum.SHORESMAN,
|
||||
enum.QUARTERMASTER,
|
||||
enum.QUARTERMASTER,
|
||||
enum.FISHERMAN,
|
||||
enum.SCOUT,
|
||||
enum.SAMURAI,
|
||||
enum.MERCHANT,
|
||||
enum.SHORESMAN,
|
||||
enum.SHORESMAN,
|
||||
enum.BOATSWAIN,
|
||||
enum.PROSPECTOR,
|
||||
enum.LUMBERJACK,
|
||||
enum.IRON_LEG,
|
||||
enum.QUARTERMASTER,
|
||||
enum.QUARTERMASTER,
|
||||
enum.SMOLDERING,
|
||||
enum.GOURMET,
|
||||
}
|
||||
end
|
||||
|
||||
@ -173,14 +179,89 @@ end
|
||||
function Public.generate_class_for_sale()
|
||||
local memory = Memory.get_crew_memory()
|
||||
|
||||
if #memory.available_classes_pool > 0 then
|
||||
if #memory.available_classes_pool == 0 then
|
||||
memory.available_classes_pool = Public.initial_class_pool() --reset to initial state
|
||||
end
|
||||
|
||||
local class = memory.available_classes_pool[Math.random(#memory.available_classes_pool)]
|
||||
|
||||
return class
|
||||
end
|
||||
|
||||
|
||||
|
||||
function Public.class_ore_grant(player, how_much, disable_scaling)
|
||||
local count
|
||||
if disable_scaling then
|
||||
count = Math.ceil(how_much)
|
||||
else
|
||||
return nil
|
||||
count = Math.ceil(how_much * Balance.class_resource_scale())
|
||||
end
|
||||
if Math.random(3) == 1 then
|
||||
Common.flying_text_small(player.surface, player.position, '[color=0.85,0.58,0.37]+' .. count .. '[/color]')
|
||||
Common.give_reward_items{{name = 'copper-ore', count = count}}
|
||||
else
|
||||
Common.flying_text_small(player.surface, player.position, '[color=0.7,0.8,0.8]+' .. count .. '[/color]')
|
||||
Common.give_reward_items{{name = 'iron-ore', count = count}}
|
||||
end
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
if memory.classes_table and memory.classes_table[player_index] then
|
||||
local class = memory.classes_table[player_index]
|
||||
if class == Public.enum.SAMURAI then
|
||||
-- vanilla heal is 80HP
|
||||
player.character.health = player.character.health + 200
|
||||
elseif class == Public.enum.HATAMOTO then
|
||||
player.character.health = player.character.health + 350
|
||||
elseif class == Public.enum.GOURMET then
|
||||
local tile = player.surface.get_tile(player.position)
|
||||
if tile.valid then
|
||||
local multiplier = 0
|
||||
if tile.name == CoreData.world_concrete_tile then
|
||||
multiplier = 1.5
|
||||
elseif tile.name == 'cyan-refined-concrete' then
|
||||
multiplier = 1.5
|
||||
elseif tile.name == CoreData.walkway_tile then
|
||||
multiplier = 1
|
||||
elseif tile.name == 'orange-refined-concrete' then
|
||||
multiplier = 1
|
||||
end
|
||||
if multiplier > 0 then
|
||||
if memory.gourmet_recency_tick then
|
||||
multiplier = multiplier * Math.max(0.2, Math.min(5, (1/5)^((memory.gourmet_recency_tick - game.tick)/(60*300))))
|
||||
memory.gourmet_recency_tick = Math.max(memory.gourmet_recency_tick, game.tick - 60*300) + 60*30
|
||||
else
|
||||
multiplier = multiplier * 5
|
||||
memory.gourmet_recency_tick = game.tick - 60*300 + 60*30
|
||||
end
|
||||
Public.class_ore_grant(player, 12 * multiplier, true)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local event = require 'utils.event'
|
||||
event.add(defines.events.on_player_used_capsule, class_on_player_used_capsule)
|
||||
|
||||
return Public
|
@ -128,19 +128,6 @@ function Public.update_tags(player)
|
||||
|
||||
local str = Public.tag_text(player)
|
||||
player.tag = str
|
||||
|
||||
if game.tick % 1200 == 0 and Common.validate_player_and_character(player) then
|
||||
local memory = Memory.get_crew_memory()
|
||||
if memory.classes_table and memory.classes_table[player.index] and memory.classes_table[player.index] == Classes.enum.IRON_LEG then
|
||||
local inv = player.get_inventory(defines.inventory.character_main)
|
||||
if not (inv and inv.valid) then return end
|
||||
local count = inv.get_item_count('iron-ore')
|
||||
if count and count < 2500 then
|
||||
local rgb = CoreData.colors.notify_error
|
||||
Common.flying_text(player.surface, player.position, '[color=' .. rgb.r .. ',' .. rgb.g .. ',' .. rgb.b .. ']missing iron ore[/color]')
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function Public.player_privilege_level(player)
|
||||
|
@ -18,7 +18,6 @@ local CoreData = require 'maps.pirates.coredata'
|
||||
local Overworld = require 'maps.pirates.overworld'
|
||||
local Utils = require 'maps.pirates.utils_local'
|
||||
local Crew = require 'maps.pirates.crew'
|
||||
local Overworld = require 'maps.pirates.overworld'
|
||||
local Math = require 'maps.pirates.math'
|
||||
local inspect = require 'utils.inspect'.inspect
|
||||
|
||||
@ -76,6 +75,8 @@ function Public.class_renderings(tickinterval)
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
function Public.update_character_properties(tickinterval)
|
||||
local memory = Memory.get_crew_memory()
|
||||
|
||||
@ -163,27 +164,38 @@ function Public.update_character_properties(tickinterval)
|
||||
end
|
||||
end
|
||||
|
||||
local function class_ore_grant(player, how_much)
|
||||
if Math.random(3) == 1 then
|
||||
Common.flying_text_small(player.surface, player.position, '[color=0.85,0.58,0.37]+[/color]')
|
||||
Common.give_reward_items{{name = 'copper-ore', count = Math.ceil(how_much * Balance.class_resource_scale())}}
|
||||
else
|
||||
Common.flying_text_small(player.surface, player.position, '[color=0.7,0.8,0.8]+[/color]')
|
||||
Common.give_reward_items{{name = 'iron-ore', count = Math.ceil(how_much * Balance.class_resource_scale())}}
|
||||
end
|
||||
end
|
||||
|
||||
function Public.class_rewards_tick(tickinterval)
|
||||
--assuming tickinterval = 6 seconds for now
|
||||
local memory = Memory.get_crew_memory()
|
||||
|
||||
if not (memory.boat and memory.boat.state and memory.boat.state == Structures.Boats.enum_state.ATSEA_LOADING_MAP) then --it is possible to spend extra time here, so don't give out freebies
|
||||
|
||||
local crew = Common.crew_get_crew_members()
|
||||
for _, player in pairs(crew) do
|
||||
if Common.validate_player_and_character(player) then
|
||||
local player_index = player.index
|
||||
|
||||
if memory.classes_table and memory.classes_table[player_index] then
|
||||
if game.tick % (60*6) == 0 and Common.validate_player_and_character(player) then
|
||||
if memory.classes_table[player.index] == Classes.enum.SMOLDERING then
|
||||
local inv = player.get_inventory(defines.inventory.character_main)
|
||||
if not (inv and inv.valid) then return end
|
||||
local max_coal = 25
|
||||
-- local max_transfer = 1
|
||||
local wood_count = inv.get_item_count('wood')
|
||||
local coal_count = inv.get_item_count('coal')
|
||||
if wood_count >= 1 and coal_count < max_coal then
|
||||
-- local count = Math.min(wood_count, max_coal-coal_count, max_transfer)
|
||||
local count = 1
|
||||
inv.remove({name = 'wood', count = count})
|
||||
inv.insert({name = 'coal', count = count})
|
||||
Common.flying_text_small(player.surface, player.position, '[item=coal]')
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
if game.tick % (60*6) == 0 and (not (memory.boat and memory.boat.state and memory.boat.state == Structures.Boats.enum_state.ATSEA_LOADING_MAP)) then --it is possible to spend extra time here, so don't give out freebies
|
||||
|
||||
if memory.classes_table and memory.classes_table[player_index] then
|
||||
local class = memory.classes_table[player_index]
|
||||
if class == Classes.enum.DECKHAND or class == Classes.enum.SHORESMAN or class == Classes.enum.BOATSWAIN then
|
||||
@ -193,11 +205,11 @@ function Public.class_rewards_tick(tickinterval)
|
||||
local hold_bool = surfacedata.type == Surfaces.enum.HOLD
|
||||
|
||||
if class == Classes.enum.DECKHAND and on_ship_bool and (not hold_bool) then
|
||||
class_ore_grant(player, 5)
|
||||
Classes.class_ore_grant(player, 5)
|
||||
elseif class == Classes.enum.BOATSWAIN and hold_bool then
|
||||
class_ore_grant(player, 8)
|
||||
Classes.class_ore_grant(player, 7)
|
||||
elseif class == Classes.enum.SHORESMAN and (not on_ship_bool) then
|
||||
class_ore_grant(player, 3)
|
||||
Classes.class_ore_grant(player, 3)
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -209,7 +221,7 @@ function Public.class_rewards_tick(tickinterval)
|
||||
if p2.player and p2.player.valid then
|
||||
local p2_index = p2.player.index
|
||||
if p2_index ~= player_index and memory.classes_table[p2_index] and memory.classes_table[p2_index] == Classes.enum.QUARTERMASTER then
|
||||
class_ore_grant(p2, 2)
|
||||
Classes.class_ore_grant(p2, 2)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user