mirror of
https://github.com/ComfyFactory/ComfyFactorio.git
synced 2025-03-25 21:29:06 +02:00
rework treasure maps
This commit is contained in:
parent
c2c411a9d5
commit
56dbf762ea
@ -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 (or officers) can steer the boat from the crow's nest by placing 50 rail signals in one of the blue boxes.\n• The quantity on an island is independent of the order in which you break rocks.\n• Passive pollution ramps up over time on each island.\n• Items dropped on the deck are transferred to the cabin when the boat moves for performance reasons.\n• Mining productivity increases naturally with leagues traveled.\nOn multiplayer, crews that are inactive for 96 hours are auto-disbanded.\n• Useful commands: /classinfo {classname} command, /plank {player}, /officer {player}, /undock, /ccolor, /clear_north_tanks, /clear_south_tanks, /tax, /reset_password
|
||||
|
||||
softmod_info_1_1=v1.7.0
|
||||
softmod_info_1_2=• Support for Factorio 2.0.\n• With the introduction of remote view, spectator mode has been retired.\n• 9 simultaneous crews now supported.\n• Performance improvements.
|
||||
softmod_info_1_2=• Support for Factorio 2.0.\n• With the introduction of remote view, spectator mode has been retired.\n• 9 simultaneous crews are now supported.\n• The treasure map mechanic has been reworked to use cameras.\n• Performance improvements.
|
||||
|
||||
softmod_info_2_1=v1.6.0–1.6.7 highlights
|
||||
softmod_info_2_2=• New runs begin on the top lane so that beginners are more likely to encounter docks.\n• Players now die rather than being temporarily marooned if they miss the boat.\n• The pause at sea now occurs after the loading time for the next destination.\n• Optional setting for new crews to disable blueprints.\n• Machines now deactivate after several minutes spent waiting at sea.\n• Private crews and captain-protected crews no longer revert to public crews when inactive. Runs now autodisband after 96 hours of inactivity.\n• Shotguns are now buffed as intended.
|
||||
@ -513,6 +513,10 @@ gui_progress_leagues=__1__ leagues
|
||||
gui_progress_current_location=Current location: __1__
|
||||
gui_progress_time_of_day=Time of day: __1__
|
||||
|
||||
gui_treasure=Treasure
|
||||
gui_treasure_discovered_maps=Discovered Maps
|
||||
gui_treasure_tooltip=The treasure maps the crew has currently found. Dig at the right location to find treasure.
|
||||
|
||||
gui_runs_play=Crews
|
||||
gui_runs_ongoing_runs=Ongoing Crews
|
||||
gui_runs_ongoing_runs_helpful_tip=To join a crew, first select it in the table below.
|
||||
@ -567,9 +571,9 @@ gui_etaframe_board_warning_tooltip=Probably time to board...
|
||||
gui_etaframe_autoundock=Auto-undock:
|
||||
gui_etaframe_loading=Loading
|
||||
gui_etaframe_defeat_krakens=Defeat the krakens!
|
||||
gui_etaframe_atsea_waiting=Captain — Click here to
|
||||
gui_etaframe_atsea_waiting=Captain — Click here to proceed
|
||||
gui_etaframe_atsea_waiting_are_you_sure=Proceed — Are you sure?
|
||||
gui_etaframe_atsea_victorious=Captain — Click here to Proceed
|
||||
gui_etaframe_atsea_victorious=Captain — Click here to proceed
|
||||
gui_etaframe_undock=Undock:
|
||||
gui_etaframe_anytime=Anytime
|
||||
gui_etaframe_next_escape_cost=Next escape cost:
|
||||
|
@ -530,7 +530,7 @@ function Public.periodic_free_resources(tick_interval)
|
||||
end
|
||||
end
|
||||
|
||||
function Public.pick_up_tick(tick_interval)
|
||||
function Public.pick_up_ghosts_tick(tick_interval)
|
||||
if Common.activecrewcount() == 0 then
|
||||
return
|
||||
end
|
||||
@ -549,83 +549,8 @@ function Public.pick_up_tick(tick_interval)
|
||||
return
|
||||
end
|
||||
|
||||
local maps = dynamic_data.treasure_maps or {}
|
||||
local buried_treasure = dynamic_data.buried_treasure or {}
|
||||
local ghosts = dynamic_data.ghosts or {}
|
||||
|
||||
for i = 1, #maps do
|
||||
local map = maps[i]
|
||||
|
||||
if map.state == 'on_ground' then
|
||||
local p = map.position
|
||||
|
||||
local nearby_characters = surface.find_entities_filtered({ position = p, radius = 3, name = 'character' })
|
||||
local nearby_characters_count = #nearby_characters
|
||||
if nearby_characters_count > 0 then
|
||||
local player
|
||||
local j = 1
|
||||
while j <= nearby_characters_count do
|
||||
if
|
||||
nearby_characters[j]
|
||||
and nearby_characters[j].valid
|
||||
and nearby_characters[j].player
|
||||
and Common.validate_player(nearby_characters[j].player)
|
||||
then
|
||||
player = nearby_characters[j].player
|
||||
break
|
||||
end
|
||||
j = j + 1
|
||||
end
|
||||
if player then
|
||||
local buried_treasure_candidates = {}
|
||||
for _, t in pairs(buried_treasure) do
|
||||
if not t.associated_to_map then
|
||||
buried_treasure_candidates[#buried_treasure_candidates + 1] = t
|
||||
end
|
||||
end
|
||||
if #buried_treasure_candidates == 0 then
|
||||
break
|
||||
end
|
||||
local chosen = buried_treasure_candidates[Math.random(#buried_treasure_candidates)]
|
||||
|
||||
chosen.associated_to_map = true
|
||||
local p2 = chosen.position
|
||||
map.buried_treasure_position = p2
|
||||
|
||||
map.state = 'picked_up'
|
||||
map.mapobject_rendering.destroy()
|
||||
|
||||
Common.notify_force_light(player.force, { 'pirates.find_map', player.name })
|
||||
|
||||
map.x_renderings = {
|
||||
rendering.draw_line({
|
||||
width = 8,
|
||||
surface = surface,
|
||||
from = { p2.x + 3, p2.y + 3 },
|
||||
to = { p2.x - 3, p2.y - 3 },
|
||||
color = { 1, 0, 0 },
|
||||
gap_length = 0.2,
|
||||
dash_length = 1,
|
||||
draw_on_ground = true,
|
||||
-- players = {player},
|
||||
}),
|
||||
rendering.draw_line({
|
||||
width = 8,
|
||||
surface = surface,
|
||||
from = { p2.x - 3, p2.y + 3 },
|
||||
to = { p2.x + 3, p2.y - 3 },
|
||||
color = { 1, 0, 0 },
|
||||
gap_length = 0.2,
|
||||
dash_length = 1,
|
||||
draw_on_ground = true,
|
||||
-- players = {player},
|
||||
}),
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if not (dynamic_data.quest_type and not dynamic_data.quest_complete) then
|
||||
return
|
||||
end
|
||||
@ -668,7 +593,7 @@ function Public.pick_up_tick(tick_interval)
|
||||
end
|
||||
end
|
||||
|
||||
function Public.interpret_shorthanded_force_name(shorthanded_name)
|
||||
local function interpret_shorthanded_force_name(shorthanded_name)
|
||||
local memory = Memory.get_crew_memory()
|
||||
|
||||
local ret
|
||||
@ -748,7 +673,7 @@ function Public.place_cached_structures(tick_interval)
|
||||
|
||||
local force_name
|
||||
if c.force then
|
||||
force_name = Public.interpret_shorthanded_force_name(c.force)
|
||||
force_name = interpret_shorthanded_force_name(c.force)
|
||||
end
|
||||
|
||||
if c.type == 'tiles' then
|
||||
@ -951,131 +876,6 @@ function Public.update_boat_stored_resources(tick_interval)
|
||||
Common.update_boat_stored_resources()
|
||||
end
|
||||
|
||||
function Public.buried_treasure_check(tick_interval)
|
||||
if Common.activecrewcount() == 0 then
|
||||
return
|
||||
end
|
||||
|
||||
-- local memory = Memory.get_crew_memory()
|
||||
local destination = Common.current_destination()
|
||||
|
||||
local remaining = destination.dynamic_data.treasure_remaining
|
||||
|
||||
if
|
||||
not (
|
||||
remaining
|
||||
and remaining > 0
|
||||
and destination.surface_name
|
||||
and destination.dynamic_data.buried_treasure
|
||||
and #destination.dynamic_data.buried_treasure > 0
|
||||
)
|
||||
then
|
||||
return
|
||||
end
|
||||
|
||||
local surface = game.surfaces[destination.surface_name]
|
||||
local treasure_table = destination.dynamic_data.buried_treasure
|
||||
|
||||
for i = 1, #treasure_table do
|
||||
local treasure = treasure_table[i]
|
||||
if not treasure then
|
||||
break
|
||||
end
|
||||
|
||||
local t = treasure.treasure
|
||||
|
||||
if t then
|
||||
local p = treasure.position
|
||||
local free = surface.can_place_entity({ name = 'wooden-chest', position = p })
|
||||
|
||||
if free then
|
||||
local inserters = {
|
||||
surface.find_entities_filtered({
|
||||
type = 'inserter',
|
||||
position = { x = p.x - 1, y = p.y },
|
||||
radius = 0.1,
|
||||
direction = defines.direction.east,
|
||||
}),
|
||||
surface.find_entities_filtered({
|
||||
type = 'inserter',
|
||||
position = { x = p.x + 1, y = p.y },
|
||||
radius = 0.1,
|
||||
direction = defines.direction.west,
|
||||
}),
|
||||
surface.find_entities_filtered({
|
||||
type = 'inserter',
|
||||
position = { x = p.x, y = p.y - 1 },
|
||||
radius = 0.1,
|
||||
direction = defines.direction.south,
|
||||
}),
|
||||
surface.find_entities_filtered({
|
||||
type = 'inserter',
|
||||
position = { x = p.x, y = p.y + 1 },
|
||||
radius = 0.1,
|
||||
direction = defines.direction.north,
|
||||
}),
|
||||
}
|
||||
|
||||
for j = 1, 4 do
|
||||
if inserters[j] and inserters[j][1] then
|
||||
local ins = inserters[j][1]
|
||||
|
||||
if
|
||||
destination.dynamic_data.treasure_remaining > 0
|
||||
and ins.held_stack.count == 0
|
||||
and ins.status == defines.entity_status.waiting_for_source_items
|
||||
then
|
||||
surface.create_entity({
|
||||
name = 'item-on-ground',
|
||||
position = p,
|
||||
stack = { name = t.name, count = 1 },
|
||||
})
|
||||
t.count = t.count - 1
|
||||
destination.dynamic_data.treasure_remaining = destination.dynamic_data.treasure_remaining
|
||||
- 1
|
||||
|
||||
if destination.dynamic_data.treasure_remaining == 0 then
|
||||
-- destroy all
|
||||
local buried_treasure = destination.dynamic_data.buried_treasure
|
||||
for _, t2 in pairs(buried_treasure) do
|
||||
t2 = nil
|
||||
end
|
||||
local maps = destination.dynamic_data.treasure_maps
|
||||
for _, m in pairs(maps) do
|
||||
if m.state == 'on_ground' then
|
||||
m.mapobject_rendering.destroy()
|
||||
elseif m.state == 'picked_up' and m.x_renderings and #m.x_renderings > 0 then
|
||||
m.x_renderings[1].destroy()
|
||||
m.x_renderings[2].destroy()
|
||||
end
|
||||
m = nil
|
||||
end
|
||||
elseif t.count <= 0 then
|
||||
treasure.treasure = nil
|
||||
|
||||
local maps = destination.dynamic_data.treasure_maps
|
||||
for _, m in pairs(maps) do
|
||||
if
|
||||
m.state == 'picked_up'
|
||||
and m.buried_treasure_position
|
||||
and m.buried_treasure_position == p
|
||||
and m.x_renderings
|
||||
and #m.x_renderings > 0
|
||||
then
|
||||
m.state = 'inactive'
|
||||
m.x_renderings[1].destroy()
|
||||
m.x_renderings[2].destroy()
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function Public.boat_movement_tick(tick_interval)
|
||||
local memory = Memory.get_crew_memory()
|
||||
local destination = Common.current_destination()
|
||||
@ -1994,30 +1794,6 @@ function Public.equalise_fluid_storages()
|
||||
end
|
||||
end
|
||||
|
||||
function Public.revealed_buried_treasure_distance_check()
|
||||
local destination = Common.current_destination()
|
||||
if Common.activecrewcount() == 0 then
|
||||
return
|
||||
end
|
||||
|
||||
if destination.dynamic_data.some_player_was_close_to_buried_treasure then
|
||||
return
|
||||
end
|
||||
|
||||
local maps = destination.dynamic_data.treasure_maps or {}
|
||||
for _, map in pairs(maps) do
|
||||
if map.state == 'picked_up' then
|
||||
for _, player in pairs(Common.crew_get_crew_members()) do
|
||||
if player.character and player.character.valid then
|
||||
if Math.distance(player.character.position, map.buried_treasure_position) <= 20 then
|
||||
destination.dynamic_data.some_player_was_close_to_buried_treasure = true
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function Public.update_pet_biter_lifetime(tick_interval)
|
||||
local memory = Memory.get_crew_memory()
|
||||
if memory.pet_biters then
|
||||
|
274
maps/pirates/buried_treasure.lua
Normal file
274
maps/pirates/buried_treasure.lua
Normal file
@ -0,0 +1,274 @@
|
||||
-- This file is part of thesixthroc's Pirate Ship softmod, licensed under GPLv3 and stored at https://github.com/ComfyFactory/ComfyFactorio and https://github.com/danielmartin0/ComfyFactorio-Pirates.
|
||||
|
||||
local Common = require('maps.pirates.common')
|
||||
local Memory = require('maps.pirates.memory')
|
||||
local Math = require('maps.pirates.math')
|
||||
local _inspect = require('utils.inspect')
|
||||
local Token = require('utils.token')
|
||||
|
||||
local Public = {}
|
||||
|
||||
function Public.pick_up_treasure_tick(tick_interval)
|
||||
if Common.activecrewcount() == 0 then
|
||||
return
|
||||
end
|
||||
|
||||
local destination = Common.current_destination()
|
||||
if not destination then
|
||||
return
|
||||
end
|
||||
local dynamic_data = destination.dynamic_data
|
||||
local surface_name = destination.surface_name
|
||||
if not (surface_name and dynamic_data) then
|
||||
return
|
||||
end
|
||||
local surface = game.surfaces[surface_name]
|
||||
if not (surface and surface.valid) then
|
||||
return
|
||||
end
|
||||
|
||||
local maps = dynamic_data.treasure_maps or {}
|
||||
local buried_treasure = dynamic_data.buried_treasure or {}
|
||||
local ghosts = dynamic_data.ghosts or {}
|
||||
|
||||
for i = 1, #maps do
|
||||
local map = maps[i]
|
||||
|
||||
if map.state == 'on_ground' then
|
||||
local p = map.position
|
||||
|
||||
local nearby_characters = surface.find_entities_filtered({ position = p, radius = 3, name = 'character' })
|
||||
local nearby_characters_count = #nearby_characters
|
||||
if nearby_characters_count > 0 then
|
||||
local player
|
||||
local j = 1
|
||||
while j <= nearby_characters_count do
|
||||
if
|
||||
nearby_characters[j]
|
||||
and nearby_characters[j].valid
|
||||
and nearby_characters[j].player
|
||||
and Common.validate_player(nearby_characters[j].player)
|
||||
then
|
||||
player = nearby_characters[j].player
|
||||
break
|
||||
end
|
||||
j = j + 1
|
||||
end
|
||||
if player then
|
||||
local buried_treasure_candidates = {}
|
||||
for _, t in pairs(buried_treasure) do
|
||||
if not t.associated_to_map then
|
||||
buried_treasure_candidates[#buried_treasure_candidates + 1] = t
|
||||
end
|
||||
end
|
||||
if #buried_treasure_candidates == 0 then
|
||||
break
|
||||
end
|
||||
local chosen = buried_treasure_candidates[Math.random(#buried_treasure_candidates)]
|
||||
|
||||
chosen.associated_to_map = true
|
||||
local p2 = chosen.position
|
||||
map.buried_treasure_position = p2
|
||||
|
||||
map.state = 'picked_up'
|
||||
map.mapobject_rendering.destroy()
|
||||
|
||||
Common.notify_force_light(player.force, { 'pirates.find_map', player.name })
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function Public.buried_treasure_tick(tick_interval)
|
||||
if Common.activecrewcount() == 0 then
|
||||
return
|
||||
end
|
||||
|
||||
-- local memory = Memory.get_crew_memory()
|
||||
local destination = Common.current_destination()
|
||||
|
||||
local remaining = destination.dynamic_data.treasure_remaining
|
||||
|
||||
if
|
||||
not (
|
||||
remaining
|
||||
and remaining > 0
|
||||
and destination.surface_name
|
||||
and destination.dynamic_data.buried_treasure
|
||||
and #destination.dynamic_data.buried_treasure > 0
|
||||
)
|
||||
then
|
||||
return
|
||||
end
|
||||
|
||||
local surface = game.surfaces[destination.surface_name]
|
||||
local treasure_table = destination.dynamic_data.buried_treasure
|
||||
|
||||
for i = 1, #treasure_table do
|
||||
local treasure = treasure_table[i]
|
||||
if not treasure then
|
||||
break
|
||||
end
|
||||
|
||||
local t = treasure.treasure
|
||||
|
||||
if t then
|
||||
local p = treasure.position
|
||||
local free = surface.can_place_entity({ name = 'wooden-chest', position = p })
|
||||
|
||||
if free then
|
||||
local inserters = {
|
||||
surface.find_entities_filtered({
|
||||
type = 'inserter',
|
||||
position = { x = p.x - 1, y = p.y },
|
||||
radius = 0.1,
|
||||
direction = defines.direction.east,
|
||||
}),
|
||||
surface.find_entities_filtered({
|
||||
type = 'inserter',
|
||||
position = { x = p.x + 1, y = p.y },
|
||||
radius = 0.1,
|
||||
direction = defines.direction.west,
|
||||
}),
|
||||
surface.find_entities_filtered({
|
||||
type = 'inserter',
|
||||
position = { x = p.x, y = p.y - 1 },
|
||||
radius = 0.1,
|
||||
direction = defines.direction.south,
|
||||
}),
|
||||
surface.find_entities_filtered({
|
||||
type = 'inserter',
|
||||
position = { x = p.x, y = p.y + 1 },
|
||||
radius = 0.1,
|
||||
direction = defines.direction.north,
|
||||
}),
|
||||
}
|
||||
|
||||
for j = 1, 4 do
|
||||
if inserters[j] and inserters[j][1] then
|
||||
local ins = inserters[j][1]
|
||||
|
||||
if
|
||||
destination.dynamic_data.treasure_remaining > 0
|
||||
and ins.held_stack.count == 0
|
||||
and ins.status == defines.entity_status.waiting_for_source_items
|
||||
then
|
||||
surface.create_entity({
|
||||
name = 'item-on-ground',
|
||||
position = p,
|
||||
stack = { name = t.name, count = 1 },
|
||||
})
|
||||
t.count = t.count - 1
|
||||
destination.dynamic_data.treasure_remaining = destination.dynamic_data.treasure_remaining
|
||||
- 1
|
||||
|
||||
if destination.dynamic_data.treasure_remaining == 0 then
|
||||
-- destroy all
|
||||
local buried_treasure = destination.dynamic_data.buried_treasure
|
||||
for _, t2 in pairs(buried_treasure) do
|
||||
t2 = nil
|
||||
end
|
||||
local maps = destination.dynamic_data.treasure_maps
|
||||
for _, m in pairs(maps) do
|
||||
if m.state == 'on_ground' then
|
||||
m.mapobject_rendering.destroy()
|
||||
end
|
||||
m = nil
|
||||
end
|
||||
elseif t.count <= 0 then
|
||||
treasure.treasure = nil
|
||||
|
||||
local maps = destination.dynamic_data.treasure_maps
|
||||
for _, m in pairs(maps) do
|
||||
if
|
||||
m.state == 'picked_up'
|
||||
and m.buried_treasure_position
|
||||
and m.buried_treasure_position == p
|
||||
then
|
||||
m.state = 'inactive'
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function Public.revealed_buried_treasure_distance_check()
|
||||
local destination = Common.current_destination()
|
||||
if Common.activecrewcount() == 0 then
|
||||
return
|
||||
end
|
||||
|
||||
if destination.dynamic_data.some_player_was_close_to_buried_treasure then
|
||||
return
|
||||
end
|
||||
|
||||
local maps = destination.dynamic_data.treasure_maps or {}
|
||||
for _, map in pairs(maps) do
|
||||
if map.state == 'picked_up' then
|
||||
for _, player in pairs(Common.crew_get_crew_members()) do
|
||||
if player.character and player.character.valid then
|
||||
if Math.distance(player.character.position, map.buried_treasure_position) <= 20 then
|
||||
destination.dynamic_data.some_player_was_close_to_buried_treasure = true
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function Public.get_picked_up_treasure_maps()
|
||||
local destination = Common.current_destination()
|
||||
if not destination then
|
||||
return {}
|
||||
end
|
||||
|
||||
local maps = destination.dynamic_data.treasure_maps
|
||||
if not maps then
|
||||
return {}
|
||||
end
|
||||
|
||||
local ret = {}
|
||||
|
||||
for _, m in pairs(maps) do
|
||||
if m.state == 'picked_up' then
|
||||
ret[#ret + 1] = m
|
||||
end
|
||||
end
|
||||
|
||||
return ret
|
||||
end
|
||||
|
||||
function Public.spawn_treasure_map_at_position(position)
|
||||
local destination = Common.current_destination()
|
||||
if not destination then
|
||||
return
|
||||
end
|
||||
|
||||
local surface = game.surfaces[destination.surface_name]
|
||||
if not surface then
|
||||
return
|
||||
end
|
||||
|
||||
local map = {}
|
||||
map.position = position
|
||||
map.mapobject_rendering = rendering.draw_sprite({
|
||||
surface = surface,
|
||||
target = position,
|
||||
sprite = 'utility/gps_map_icon',
|
||||
render_layer = 'corpse',
|
||||
x_scale = 2.4,
|
||||
y_scale = 2.4,
|
||||
})
|
||||
map.state = 'on_ground'
|
||||
map.id = tostring(Token.uid())
|
||||
|
||||
destination.dynamic_data.treasure_maps[#destination.dynamic_data.treasure_maps + 1] = map
|
||||
end
|
||||
|
||||
return Public
|
@ -40,6 +40,7 @@ Public.default_window_positions = {
|
||||
crew = { x = 364, y = 76 },
|
||||
classes = { x = 442, y = 76 },
|
||||
progress = { x = 520, y = 76 },
|
||||
treasure = { x = 676, y = 76 },
|
||||
}
|
||||
|
||||
function Public.new_window(player, name)
|
||||
@ -170,7 +171,6 @@ function Public.flow_add_section(flow, name, caption)
|
||||
flow3.style.font = 'heading-2'
|
||||
flow3.style.font_color = Public.section_header_font_color
|
||||
flow3.style.maximal_width = 300
|
||||
-- flow3.style.maximal_width = 220
|
||||
-- flow3.style.single_line = false
|
||||
|
||||
flow3 = flow2.add({
|
||||
|
@ -12,6 +12,7 @@ local GuiCrew = require('maps.pirates.gui.crew')
|
||||
local GuiClasses = require('maps.pirates.gui.classes')
|
||||
local GuiMinimap = require('maps.pirates.gui.minimap')
|
||||
local GuiInfo = require('maps.pirates.gui.info')
|
||||
local GuiTreasure = require('maps.pirates.gui.treasure')
|
||||
local Quest = require('maps.pirates.quest')
|
||||
local Balance = require('maps.pirates.balance')
|
||||
local _inspect = require('utils.inspect').inspect
|
||||
@ -28,6 +29,7 @@ local IslandEnum = require('maps.pirates.surfaces.islands.island_enum')
|
||||
local Kraken = require('maps.pirates.surfaces.sea.kraken')
|
||||
local GuiWelcome = require('maps.pirates.gui.welcome')
|
||||
local ComfyGui = require('utils.gui')
|
||||
local BuriedTreasure = require('maps.pirates.buried_treasure')
|
||||
ComfyGui.set_disabled_tab('Scoreboard', true)
|
||||
ComfyGui.set_disabled_tab('Groups', true)
|
||||
|
||||
@ -40,7 +42,7 @@ Public.classes = require('maps.pirates.gui.classes')
|
||||
Public.minimap = require('maps.pirates.gui.minimap')
|
||||
Public.info = require('maps.pirates.gui.info')
|
||||
Public.color = require('maps.pirates.gui.color')
|
||||
|
||||
Public.treasure = require('maps.pirates.gui.treasure')
|
||||
local function create_gui(player)
|
||||
local flow1, flow2, flow3, flow4
|
||||
|
||||
@ -96,6 +98,10 @@ local function create_gui(player)
|
||||
flow2.mouse_button_filter = { 'middle' } --hack to avoid press visual
|
||||
flow2.show_percent_for_small_numbers = true --as of factorio v1.1.59, there is a bug in which 1.002 displays as like 1e-2% or something. but after 1.01 it's ok
|
||||
|
||||
flow2 = GuiCommon.flow_add_floating_sprite_button(flow1, 'treasure_piratebutton')
|
||||
flow2.tooltip = { 'pirates.gui_treasure_main_tooltip' }
|
||||
flow2.sprite = 'utility/gps_map_icon'
|
||||
|
||||
flow2 = GuiCommon.flow_add_floating_sprite_button(flow1, 'minimap_piratebutton')
|
||||
flow2.tooltip = { 'pirates.gui_minimap_main_tooltip' }
|
||||
flow2.sprite = 'utility/map'
|
||||
@ -967,12 +973,15 @@ function Public.update_gui(player)
|
||||
if GuiEvo.full_update then
|
||||
GuiEvo.full_update(player)
|
||||
end
|
||||
if GuiProgress.regular_update then
|
||||
GuiProgress.regular_update(player)
|
||||
end --moved to event
|
||||
if GuiProgress.full_update then
|
||||
GuiProgress.full_update(player)
|
||||
end
|
||||
if GuiRuns.full_update then
|
||||
GuiRuns.full_update(player)
|
||||
end
|
||||
if GuiTreasure.full_update then
|
||||
GuiTreasure.full_update(player)
|
||||
end
|
||||
if GuiCrew.full_update then
|
||||
GuiCrew.full_update(player)
|
||||
end
|
||||
@ -1027,6 +1036,13 @@ function Public.update_gui(player)
|
||||
flow1.tooltip = { 'pirates.gui_progress_tooltip', tostring(memory.overworldx or 0), tostring(CoreData.victory_x) }
|
||||
-- pirates_flow.destination_piratebutton_frame.destination_piratebutton.number = memory.destinationsvisited_indices and #memory.destinationsvisited_indices or 0
|
||||
|
||||
flow1 = pirates_flow.treasure_piratebutton_frame
|
||||
local maps = BuriedTreasure.get_picked_up_treasure_maps()
|
||||
flow1.visible = #maps > 0
|
||||
local flow2 = flow1.treasure_piratebutton
|
||||
flow2.tooltip = { 'pirates.gui_treasure_tooltip', #maps }
|
||||
flow2.number = #maps
|
||||
|
||||
--== State-checking bools ==--
|
||||
|
||||
-- this is nonsense to temporarily avoid function complexity for luacheck:
|
||||
@ -1322,6 +1338,9 @@ local function on_gui_click(event)
|
||||
if GuiInfo.click then
|
||||
GuiInfo.click(event)
|
||||
end
|
||||
if GuiTreasure.click then
|
||||
GuiTreasure.click(event)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -96,9 +96,6 @@ end
|
||||
-- end
|
||||
|
||||
function Public.full_update(player)
|
||||
if Public.regular_update then
|
||||
Public.regular_update(player)
|
||||
end
|
||||
if not player.gui.screen[window_name .. '_piratewindow'] then
|
||||
return
|
||||
end
|
||||
|
104
maps/pirates/gui/treasure.lua
Normal file
104
maps/pirates/gui/treasure.lua
Normal file
@ -0,0 +1,104 @@
|
||||
-- This file is part of thesixthroc's Pirate Ship softmod, licensed under GPLv3 and stored at https://github.com/ComfyFactory/ComfyFactorio and https://github.com/danielmartin0/ComfyFactorio-Pirates.
|
||||
|
||||
-- local Utils = require 'maps.pirates.utils_local'
|
||||
-- local Math = require 'maps.pirates.math'
|
||||
local _inspect = require('utils.inspect').inspect
|
||||
local GuiCommon = require('maps.pirates.gui.common')
|
||||
local BuriedTreasure = require('maps.pirates.buried_treasure')
|
||||
local Common = require('maps.pirates.common')
|
||||
local Memory = require('maps.pirates.memory')
|
||||
local Surfaces = require('maps.pirates.surfaces.surfaces')
|
||||
|
||||
local Public = {}
|
||||
|
||||
local window_name = 'treasure'
|
||||
|
||||
function Public.toggle_window(player)
|
||||
if player.gui.screen[window_name .. '_piratewindow'] then
|
||||
player.gui.screen[window_name .. '_piratewindow'].destroy()
|
||||
return
|
||||
end
|
||||
|
||||
local flow, flow2, flow3
|
||||
flow = GuiCommon.new_window(player, window_name)
|
||||
flow.caption = { 'pirates.gui_treasure' }
|
||||
|
||||
flow2 = GuiCommon.flow_add_section(flow, 'current_maps', { 'pirates.gui_treasure_discovered_maps' })
|
||||
|
||||
flow3 = flow2.add({
|
||||
type = 'scroll-pane',
|
||||
name = 'treasure_scroll_pane',
|
||||
vertical_scroll_policy = 'auto',
|
||||
horizontal_scroll_policy = 'never',
|
||||
})
|
||||
flow3.style.maximal_height = 600
|
||||
|
||||
local treasure_grid = flow3.add({
|
||||
type = 'table',
|
||||
name = 'treasure_grid',
|
||||
column_count = 2,
|
||||
})
|
||||
treasure_grid.style.horizontal_spacing = 8
|
||||
treasure_grid.style.vertical_spacing = 8
|
||||
|
||||
GuiCommon.flow_add_close_button(flow, window_name .. '_piratebutton')
|
||||
return nil
|
||||
end
|
||||
|
||||
function Public.full_update(player)
|
||||
if Public.regular_update then
|
||||
Public.regular_update(player)
|
||||
end
|
||||
if not player.gui.screen[window_name .. '_piratewindow'] then
|
||||
return
|
||||
end
|
||||
|
||||
local destination = Common.current_destination()
|
||||
if destination.type ~= Surfaces.enum.ISLAND then
|
||||
player.gui.screen[window_name .. '_piratewindow'].destroy()
|
||||
return
|
||||
end
|
||||
|
||||
local surface = game.surfaces[destination.surface_name]
|
||||
local treasure_maps = BuriedTreasure.get_picked_up_treasure_maps()
|
||||
|
||||
local flow = player.gui.screen[window_name .. '_piratewindow']
|
||||
|
||||
local flow1 = flow.current_maps.body.treasure_scroll_pane.treasure_grid
|
||||
|
||||
for _, child in pairs(flow1.children) do
|
||||
if child.type == 'camera' then
|
||||
local matching_treasure_map = false
|
||||
for _, treasure_map in pairs(treasure_maps) do
|
||||
if child.name == treasure_map.id then
|
||||
matching_treasure_map = true
|
||||
end
|
||||
end
|
||||
if not matching_treasure_map then
|
||||
child.destroy()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
for _, treasure_map in pairs(treasure_maps) do
|
||||
local flow2 = flow1[treasure_map.id]
|
||||
|
||||
if not (flow2 and flow2.valid) then
|
||||
Common.ensure_chunks_at(surface, treasure_map.buried_treasure_position, 1)
|
||||
|
||||
flow2 = flow1.add({
|
||||
type = 'camera',
|
||||
name = treasure_map.id,
|
||||
position = treasure_map.buried_treasure_position,
|
||||
})
|
||||
flow2.surface_index = surface.index
|
||||
flow2.zoom = 0.6
|
||||
flow2.style.minimal_height = 250
|
||||
flow2.style.minimal_width = 250
|
||||
end
|
||||
end
|
||||
|
||||
flow.style.maximal_width = 1000
|
||||
end
|
||||
|
||||
return Public
|
@ -59,6 +59,7 @@ require('maps.pirates.shop.boat_upgrades')
|
||||
local Token = require('utils.token')
|
||||
local Task = require('utils.task')
|
||||
local Server = require('utils.server')
|
||||
local BuriedTreasure = require('maps.pirates.buried_treasure')
|
||||
|
||||
local Math = require('maps.pirates.math')
|
||||
|
||||
@ -155,13 +156,14 @@ local function crew_tick()
|
||||
PiratesApiOnTick.prevent_disembark(10)
|
||||
PiratesApiOnTick.prevent_unbarreling_off_ship(10)
|
||||
-- PiratesApiOnTick.shop_ratelimit_tick(10)
|
||||
PiratesApiOnTick.pick_up_tick(10)
|
||||
BuriedTreasure.pick_up_treasure_tick(10)
|
||||
PiratesApiOnTick.pick_up_ghosts_tick(10)
|
||||
QuestStructures.tick_quest_structure_entry_price_check()
|
||||
PiratesApiOnTick.update_boat_stored_resources(10)
|
||||
|
||||
if tick % 30 == 0 then
|
||||
PiratesApiOnTick.silo_update(30)
|
||||
PiratesApiOnTick.buried_treasure_check(30)
|
||||
BuriedTreasure.buried_treasure_tick(30)
|
||||
PiratesApiOnTick.apply_restrictions_to_machines(30)
|
||||
ClassPiratesApiOnTick.update_character_properties(30)
|
||||
ClassPiratesApiOnTick.class_update_auxiliary_data(30)
|
||||
@ -177,7 +179,7 @@ local function crew_tick()
|
||||
PiratesApiOnTick.update_alert_sound_frequency_tracker()
|
||||
PiratesApiOnTick.check_for_cliff_explosives_in_hold_wooden_chests()
|
||||
PiratesApiOnTick.equalise_fluid_storages() -- Made the update less often for small performance gain, but frequency can be increased if players complain
|
||||
PiratesApiOnTick.revealed_buried_treasure_distance_check()
|
||||
BuriedTreasure.revealed_buried_treasure_distance_check()
|
||||
PiratesApiOnTick.victory_continue_reminder()
|
||||
Kraken.overall_kraken_tick()
|
||||
|
||||
|
@ -5,8 +5,8 @@ local Memory = require('maps.pirates.memory')
|
||||
local Balance = require('maps.pirates.balance')
|
||||
local Common = require('maps.pirates.common')
|
||||
-- local Utils = require 'maps.pirates.utils_local'
|
||||
local Math = require 'maps.pirates.math'
|
||||
local Raffle = require 'utils.math.raffle'
|
||||
local Math = require('maps.pirates.math')
|
||||
local Raffle = require('utils.math.raffle')
|
||||
-- local Loot = require 'maps.pirates.loot'
|
||||
-- local CoreData = require 'maps.pirates.coredata'
|
||||
local IslandEnum = require('maps.pirates.surfaces.islands.island_enum')
|
||||
@ -32,7 +32,7 @@ Public.quest_icons = {
|
||||
[enum.TIME] = '[img=utility.time_editor_icon]',
|
||||
[enum.NODAMAGE] = '[item=stone-wall]',
|
||||
[enum.WORMS] = '[entity=small-worm-turret]',
|
||||
[enum.FIND] = '[img=utility.ghost_time_to_live_modifier_icon]',
|
||||
[enum.FIND] = '[img=utility.create_ghost_on_entity_death_modifier_icon]',
|
||||
[enum.RESOURCEFLOW] = '',
|
||||
[enum.RESOURCECOUNT] = '',
|
||||
[enum.FISH] = '[item=raw-fish]',
|
||||
|
@ -16,6 +16,7 @@ local Token = require('utils.token')
|
||||
local Task = require('utils.task')
|
||||
local QuestStructures = require('maps.pirates.structures.quest_structures.quest_structures')
|
||||
local IslandEnum = require('maps.pirates.surfaces.islands.island_enum')
|
||||
local BuriedTreasure = require('maps.pirates.buried_treasure')
|
||||
|
||||
local Public = {}
|
||||
local enum = IslandEnum.enum
|
||||
@ -72,26 +73,9 @@ function Public.spawn_treasure_maps(destination, points_to_avoid)
|
||||
}
|
||||
|
||||
for i = 1, num do
|
||||
local map = {}
|
||||
|
||||
local p = Hunt.mid_farness_position_1(args, points_to_avoid)
|
||||
|
||||
-- game.print(p)
|
||||
|
||||
map.position = p
|
||||
map.mapobject_rendering = rendering.draw_sprite({
|
||||
surface = surface,
|
||||
target = p,
|
||||
sprite = 'utility/gps_map_icon',
|
||||
render_layer = 'corpse',
|
||||
x_scale = 2.4,
|
||||
y_scale = 2.4,
|
||||
})
|
||||
map.state = 'on_ground'
|
||||
map.x_renderings = nil
|
||||
map.buried_treasure_position = nil
|
||||
|
||||
destination.dynamic_data.treasure_maps[#destination.dynamic_data.treasure_maps + 1] = map
|
||||
BuriedTreasure.spawn_treasure_map_at_position(p)
|
||||
end
|
||||
end
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user