1
0
mirror of https://github.com/ComfyFactory/ComfyFactorio.git synced 2024-12-28 23:06:38 +02:00

Merge pull request #481 from danielmartin0/pirates

Pirate Ship update for Vanilla 2.0
This commit is contained in:
Gerkiz 2024-10-30 18:55:38 +01:00 committed by GitHub
commit b00900dbb1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
38 changed files with 719 additions and 405 deletions

View File

@ -15,14 +15,11 @@ softmod_info_new_players_2=Mine coal and other resources and bring them to the s
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.6.7
softmod_info_1_2=Corner cases of offline inventory storage fixed for players handcrafting or wearing power armor.\n• Market weapon upgrades no longer affect weapon shooting speed.\n• Fixed revenge biters not spawning for ship slots 4–7.\n• Shotguns are now buffed as intended.\n• Land mine technology disabled.
softmod_info_1_1=v1.7 highlights
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• Ship movement no longer causes players to exit the GUI of entities on the ship.\n• Performance improvements.
softmod_info_2_1=v1.6.1–1.6.6 highlights
softmod_info_2_2=• Optional setting for new crews to disable blueprints.\n• Each island now has a grace period of 2 minutes before attacks.\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• Further slowing of gameplay for small crews.
softmod_info_3_1=v1.6.0 highlights
softmod_info_3_2=• 7 simultaneous crews supported. Surface loading is paused if other crews are engaged in a fight at sea, or are loading themselves.\n• New runs begin on the top lane so that beginners are more likely to encounter docks.\n• Disconnecting players once again have their items temporarily saved. Items are returned to the crew if players don't reconnect quickly.\n• Players now die rather than being temporarily marooned if they miss the boat.\n• Melee classes can no longer hold weapons. New class added.\n• The pause at sea now occurs after the loading time for the next destination.
softmod_info_2_1=v1.6 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.
softmod_info_credits_1=Credits
softmod_info_credits_2=Designed/developed by thesixthroc. Updates from Piratux. Comfy codebase and help from Gerkiz, Hanakocz and Mew @ Comfy Industries (https://getcomfy.eu). 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
@ -67,14 +64,14 @@ parrot_set_sail_advice=Ready to sail to the next island? Click up top!
parrot_hard_praise=Steel chests for steel players! Squawk!
parrot_normal_praise=Iron chests for iron players! Squawk!
parrot_fuel_warning=Fuel is low! Quick, throw some coal to captain's cabin!
parrot_silo_warning=The silo is attracting biters...
parrot_silo_warning=The silo is attracting enemies...
parrot_0=We can wait here for as long as we like.
parrot_night_warning=Did you know biters deal more damage at night?
parrot_night_warning=Did you know enemies deal more damage at night?
parrot_boats_warning=200 leagues? I think we're being chased...
parrot_kraken_warning=400 leagues coming up? What are those pink things I spy...
parrot_need_resources_to_undock_warning=Oh no! From now on, if we won't collect resources in time, we will lose!
parrot_radioactive_tip_1=We'll need uranium-235 to push away from this island...
parrot_radioactive_tip_2=The biters don't care if we pollute here, but they evolve fast.
parrot_radioactive_tip_2=The enemies don't care if we pollute here, but they evolve fast.
parrot_maze_tip_1=Something seems wrong with our minimap.
parrot_cave_tip_1=That island looks suspiciously dark... I'm scared! Squawk!
parrot_captain_first_time_in_cabin_hint=Squawk! Captains and officers can buy rail signals to steer the ship!
@ -131,7 +128,7 @@ silo_destroyed=The silo was destroyed.
research_notification=__1__ researched.
destroyed_all_nests=All biter bases destroyed — escape cost removed.
destroyed_all_nests=All enemy bases destroyed — escape cost removed.
recover_offline_player_items=Offline player's items recovered to cabin.
@ -249,6 +246,8 @@ class_scout=Scout
class_scout_explanation_advanced=They move __1__% times faster, but receive __2__% more damage and deal __3__% less damage.
class_samurai=Samurai
class_samurai_explanation_advanced=They receive __1__% less damage, and with no weapon equipped do extra __2__ damage in melee (scales with 'physical projectile damage' research bonuses), but deal __3__% less damage otherwise.\nIf the damage dealt in melee is an overkill, the remaining damage splashes onto nearby enemies.
discard_weapon_to_inventory=As a __1__, your weapon has been placed back in your inventory.
discard_weapon_to_ground=As a __1__, your weapon has been removed. Since your inventory was full, it has been placed on the ground.
class_merchant=Merchant
class_merchant_explanation_advanced=They generate 50 doubloons per league.
class_shoresman=Shoresman
@ -401,12 +400,13 @@ highscore_heading_difficulty=Difficulty
highscore_heading_peak_players=PeakPlayers
second_element=__2__
run_condition_private=, private
run_condition_captain_protected=, cap'n-protected
run_condition_blueprints_disabled=, BPs disabled
player_count_description=__plural_for_parameter__1__{1=__1__ player|rest=__1__ players}__
run_condition_private_2=private
run_condition_captain_protected_2=cap'n-protected
run_condition_blueprints_disabled_2=BPs disabled
crewmember_displayform=[color=__2__,__3__,__4__]__5__[/color] [color=1,1,1]__6__[/color]
capacity_tooltip=Capacity. Sets the maximum number of crewmembers allowed.
difficulty_tooltip=Difficulty.\n\nHigher difficulties have higher pollution and evo, higher biter damage, lower gold loot, but higher chest loot, along with small effects on the time per island, quest requirements, and silo position.\n\nDifficulty also determines the material the ship is made out of.
difficulty_tooltip=Difficulty.\n\nHigher difficulties have higher pollution and evo, higher enemy damage, lower gold loot, but higher chest loot, along with small effects on the time per island, quest requirements, and silo position.\n\nDifficulty also determines the material the ship is made out of.
mode_tooltip=Mode.
auto_undock_tooltip=The maximum time to stay at this location.\n\nOnce this time is reached, the boat undocks automatically. The captain can choose to leave earlier by pressing this button (or typing /undock).
@ -486,9 +486,9 @@ gui_classes_take_enabled_tooltip=Equip the class to receive bonuses!
gui_classes_take_disabled_tooltip=This class is currently in use by someone
gui_classes_drop_tooltip=Unequip the class to allow someone else to take it
gui_evo_tooltip_1=Local Biter Evolution: __1__
gui_evo_tooltip_1=Local Evolution: __1__
gui_evo_tooltip_2=Leagues: __1__
gui_evo_tooltip_3=Kraken: __1__
gui_evo_tooltip_3=Sea Enemies: __1__
gui_evo_tooltip_4=Time: __1__
gui_evo_tooltip_5=Silo: __1__
gui_evo_tooltip_6=Nests: __1__
@ -508,10 +508,15 @@ gui_minimap_switch_right=Off
gui_progress=Progress
gui_progress_distance_travelled=Distance travelled:
gui_progress_leagues_hint=Travel 1000 leagues for victory!
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.
@ -566,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:

View File

@ -56,6 +56,11 @@ function Public.Tick_actions(tick_interval)
if destination.type ~= Surfaces.enum.ISLAND then
return
end
if destination.subtype and destination.subtype == IslandEnum.enum.FIRST then
return
end
if memory.boat.state ~= Boats.enum_state.LANDED and memory.boat.state ~= Boats.enum_state.RETREATING then
return
end
@ -74,7 +79,8 @@ function Public.Tick_actions(tick_interval)
if game.tick % (tick_interval * 2) == 0 and memory.boat.state == Boats.enum_state.LANDED then
local extra_evo = 2 * tick_interval / 60 * Balance.evolution_per_second()
Common.increment_evo(extra_evo)
destination.dynamic_data.evolution_accrued_time = destination.dynamic_data.evolution_accrued_time + extra_evo
destination.dynamic_data.evolution_accrued_time = (destination.dynamic_data.evolution_accrued_time or 0)
+ extra_evo
end
-- if destination.subtype == IslandEnum.enum.RED_DESERT then return end -- This was a hack to stop biter boats causing attacks, but, it has the even worse effect of stopping all floating_pollution gathering.

View File

@ -582,14 +582,14 @@ local function handle_damage_dealt_by_players(event)
end
end
if class and class == Classes.enum.SCOUT then
if event.entity.valid and class and class == Classes.enum.SCOUT then
-- event.entity.health = event.entity.health + (1 - Balance.scout_damage_dealt_multiplier) * event.final_damage_amount
Common.damage_hostile_entity(
event.entity,
-(1 - Balance.scout_damage_dealt_multiplier) * event.final_damage_amount
)
event.final_damage_amount = event.final_damage_amount * Balance.scout_damage_dealt_multiplier
elseif class and (class == Classes.enum.SAMURAI or class == Classes.enum.HATAMOTO) then
elseif event.entity.valid and class and (class == Classes.enum.SAMURAI or class == Classes.enum.HATAMOTO) then
local samurai = class == Classes.enum.SAMURAI
local hatamoto = class == Classes.enum.HATAMOTO
@ -731,13 +731,13 @@ local function handle_maze_walls_damage_resistance(event)
elseif event.damage_type.name and event.damage_type.name == 'fire' then
-- put out forest fires:
for _, e2 in
pairs(entity.surface.find_entities_filtered({
area = {
{ entity.position.x - 4, entity.position.y - 4 },
{ entity.position.x + 4, entity.position.y + 4 },
},
name = 'fire-flame-on-tree',
}))
pairs(entity.surface.find_entities_filtered({
area = {
{ entity.position.x - 4, entity.position.y - 4 },
{ entity.position.x + 4, entity.position.y + 4 },
},
name = 'fire-flame-on-tree',
}))
do
if e2.valid then
e2.destroy()
@ -1696,7 +1696,7 @@ local function event_on_research_finished(event)
force.set_gun_speed_modifier(category, current_m + factor * m)
end
elseif t == 'turret-attack' then
local category = e.ammo_category
local category = e.turret_id
local factor = Balance.player_turret_attack_modifiers()[category]
if factor then
@ -1946,7 +1946,7 @@ function Public.player_entered_vehicle(player, vehicle)
-- if not vehicle.valid then log('vehicle invalid') return end
local player_relative_pos =
{ x = player.character.position.x - vehicle.position.x, y = player.character.position.y - vehicle.position.y }
{ x = player.character.position.x - vehicle.position.x, y = player.character.position.y - vehicle.position.y }
local memory = Memory.get_crew_memory()
@ -2131,7 +2131,7 @@ function Public.event_on_chunk_generated(event)
})
else
tiles[#tiles + 1] =
{ name = 'out-of-map', position = Utils.psum({ p, { 1, terraingen_coordinates_offset } }) }
{ name = 'out-of-map', position = Utils.psum({ p, { 1, terraingen_coordinates_offset } }) }
end
end
end
@ -2179,7 +2179,7 @@ function Public.event_on_chunk_generated(event)
if special.name == 'buried-treasure' then
if destination.dynamic_data.buried_treasure and crewid ~= 0 then
destination.dynamic_data.buried_treasure[#destination.dynamic_data.buried_treasure + 1] =
{ treasure = Loot.buried_treasure_loot(), position = special.position }
{ treasure = Loot.buried_treasure_loot(), position = special.position }
end
elseif special.name == 'chest' then
local e = surface.create_entity({
@ -2253,7 +2253,7 @@ function Public.event_on_chunk_generated(event)
if special.components then
destination.dynamic_data.structures_waiting_to_be_placed[#destination.dynamic_data.structures_waiting_to_be_placed + 1] =
{ data = special, tick = game.tick }
{ data = special, tick = game.tick }
end
end
@ -2463,7 +2463,7 @@ local function event_on_market_item_purchased(event)
Shop.event_on_market_item_purchased(event)
end
local remove_boost_movement_speed_on_respawn = Token.register(function (data)
local remove_boost_movement_speed_on_respawn = Token.register(function(data)
local player = data.player
local crew_id = data.crew_id
if not (player and player.valid) then
@ -2486,7 +2486,7 @@ local remove_boost_movement_speed_on_respawn = Token.register(function (data)
Common.notify_player_expected(player, { 'pirates.respawn_speed_bonus_removed' })
end)
local boost_movement_speed_on_respawn = Token.register(function (data)
local boost_movement_speed_on_respawn = Token.register(function(data)
local player = data.player
local crew_id = data.crew_id
if not player or not player.valid then

View File

@ -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()
@ -1226,7 +1026,9 @@ function Public.loading_update_lobby(tick_interval, memory, boat, destination_in
elseif memory.loading_ticks > 410 then
if not Crowsnest.get_crowsnest_surface() then
Crew.initialise_crowsnest_1()
elseif memory.loading_ticks >= 470 then
elseif memory.loading_ticks >= 470 and not memory.initialise_crowsnest_2_called then
memory.initialise_crowsnest_2_called = true
Crew.initialise_crowsnest_2()
Overworld.ensure_lane_generated_up_to(0, Crowsnest.Data.visibilitywidth)
Overworld.ensure_lane_generated_up_to(24, Crowsnest.Data.visibilitywidth)
@ -1994,30 +1796,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

View File

@ -594,11 +594,7 @@ function Public.kraken_evo_increase_per_second()
end
function Public.sandworm_evo_increase_per_spawn()
if _DEBUG then
return 1 / 100
else
return (1 / 100) * (1 / 7) * Math.sloped(Common.difficulty_scale(), 3 / 5)
end
return (1 / 100) * (1 / 7) * Math.sloped(Common.difficulty_scale(), 3 / 5)
end
function Public.kraken_kill_reward_items()
@ -688,11 +684,11 @@ end
-- return 0.95
-- end
-- TODO: Update these for 2.0?
function Public.player_ammo_damage_modifiers() -- modifiers are fractional. bullet affects gun turrets, but flamethrower does not affect flamer turrets
local data = {
['artillery-shell'] = 0,
['biological'] = 0,
['beam'] = 0,
['bullet'] = 0.1,
['cannon-shell'] = 0,
['capsule'] = 0,
@ -700,9 +696,10 @@ function Public.player_ammo_damage_modifiers() -- modifiers are fractional. bull
['flamethrower'] = -0.5,
['grenade'] = -0.05,
['landmine'] = 0,
['laser'] = 0,
['melee'] = 0, -- only affects alien melee
['rocket'] = 0,
['shotgun-shell'] = 2,
['shotgun-shell'] = 0.875,
}
return data
end
@ -710,8 +707,6 @@ end
function Public.player_turret_attack_modifiers()
local data = {
['gun-turret'] = 0,
['artillery-turret'] = 0,
['laser-turret'] = 0,
['flamethrower-turret'] = -0.5,
}
return data
@ -728,6 +723,7 @@ function Public.player_gun_speed_modifiers()
['flamethrower'] = 0,
['grenade'] = -0.25,
['landmine'] = 0,
['laser'] = 0,
['melee'] = 0, -- only affects alien melee
['rocket'] = 0,
['shotgun-shell'] = 0,

View 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()
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 {}
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()
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 k, _ in pairs(buried_treasure) do
buried_treasure[k] = nil
end
local maps = destination.dynamic_data.treasure_maps
for k, m in pairs(maps) do
if m.state == 'on_ground' then
m.mapobject_rendering.destroy()
end
maps[k] = 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

View File

@ -19,11 +19,11 @@ local LootRaffle = require('utils.functions.loot_raffle')
local Public = {}
Public.starting_ships_count = 7
Public.active_crews_cap = 7
Public.private_run_cap = 4
Public.starting_ships_count = 9
Public.active_crews_cap = 9
Public.private_run_cap = 6
Public.protected_but_not_private_run_cap = 2
Public.minimum_run_capacity_to_enforce_space_for = 22
-- Public.minimum_run_capacity_to_enforce_space_for = 22
-- auto-disbanding when there are no players left in the crew:
-- Public.autodisband_hours = nil
@ -325,7 +325,7 @@ function Public.give(player, stacks, spill_position, short_form, spill_surface,
local text2 = ''
local stacks2 = stacks
table.sort(stacks2, function (a, b)
table.sort(stacks2, function(a, b)
return a.name < b.name
end)
@ -832,8 +832,10 @@ function Public.new_healthbar(
x_scale = size * 15,
y_scale = size,
render_layer = 'light-effect',
target = target_entity,
target_offset = { 0, -2.5 + extra_offset },
target = {
entity = target_entity,
offset = { 0, -2.5 + extra_offset },
},
surface = target_entity.surface,
})
local render2
@ -842,8 +844,10 @@ function Public.new_healthbar(
text = '',
color = { 255, 255, 255 },
scale = 1.2 + size * 2,
target = target_entity,
target_offset = { 0, -3.6 - size * 0.6 + extra_offset },
target = {
entity = target_entity,
offset = { 0, -3.6 - size * 0.6 + extra_offset },
},
surface = target_entity.surface,
alignment = 'center',
})
@ -1217,7 +1221,7 @@ function Public.add_tiles_from_blueprint(tilesTable, bp_string, tile_name, offse
if bp_tiles then
for _, tile in pairs(bp_tiles) do
tilesTable[#tilesTable + 1] =
{ name = tile_name, position = { x = tile.position.x + offset.x, y = tile.position.y + offset.y } }
{ name = tile_name, position = { x = tile.position.x + offset.x, y = tile.position.y + offset.y } }
end
end
@ -1448,7 +1452,7 @@ end
function Public.tileslist_add_area_offset(tiles_list_to_add_to, area, offset, tile_type)
for _, p in pairs(Public.orthog_positions_in_orthog_area(area)) do
tiles_list_to_add_to[#tiles_list_to_add_to + 1] =
{ name = tile_type, position = { x = offset.x + p.x, y = offset.y + p.y } }
{ name = tile_type, position = { x = offset.x + p.x, y = offset.y + p.y } }
end
end
@ -1782,7 +1786,7 @@ function Public.init_game_settings(technology_price_multiplier)
-- (0,2) for a symmetric search:
game.map_settings.path_finder.goal_pressure_ratio = -0.1 --small pressure for stupid paths
game.map_settings.path_finder.fwd2bwd_ratio = 2 -- on experiments I found that this value was symmetric, despite the vanilla game comments saying it is 1...
game.map_settings.path_finder.fwd2bwd_ratio = 2 -- on experiments I found that this value was symmetric, despite the vanilla game comments saying it is 1...
game.map_settings.max_failed_behavior_count = 2
game.map_settings.path_finder.max_work_done_per_tick = 20000
game.map_settings.path_finder.short_cache_min_algo_steps_to_cache = 100

View File

@ -6,7 +6,7 @@ local _inspect = require('utils.inspect').inspect
local Public = {}
Public.scenario_id_name = 'pirates'
Public.version_string = '1.6.7' --major.minor.patch versioning, to match factorio mod portal
Public.version_string = '1.7.4' --major.minor.patch versioning, to match factorio mod portal
Public.rocket_silo_death_causes_loss = false

View File

@ -527,7 +527,8 @@ function Public.disband_crew(donotprint)
end
if not donotprint then
local message = { 'pirates.crew_disband', memory.name, Utils.time_longform((memory.real_age or 0) / 60) }
local message =
{ 'pirates.crew_disband', memory.name, Utils.time_longform((memory.age_since_first_island or 0) / 60) }
Common.notify_game(message)
Server.to_discord_embed_raw({ '', CoreData.comfy_emojis.despair, message }, true)
@ -1017,9 +1018,9 @@ function Public.reset_crew_and_enemy_force(id)
-- crew_force.technologies['refined-flammables-5'].enabled = false
-- crew_force.technologies['refined-flammables-6'].enabled = false
-- crew_force.technologies['refined-flammables-7'].enabled = false
-- crew_force.technologies['energy-weapons-damage-5'].enabled = false --5 makes krakens too easy
-- crew_force.technologies['energy-weapons-damage-6'].enabled = false
-- crew_force.technologies['energy-weapons-damage-7'].enabled = false
-- crew_force.technologies['laser-weapons-damage-5'].enabled = false --5 makes krakens too easy
-- crew_force.technologies['laser-weapons-damage-6'].enabled = false
-- crew_force.technologies['laser-weapons-damage-7'].enabled = false
-- crew_force.technologies['physical-projectile-damage-5'].enabled = false
-- crew_force.technologies['physical-projectile-damage-6'].enabled = false
-- crew_force.technologies['physical-projectile-damage-7'].enabled = false

View File

@ -109,7 +109,15 @@ function Public.toggle_window(player)
flow = GuiCommon.new_window(player, window_name)
flow.caption = { 'pirates.gui_classes' }
flow.auto_center = true
-- Set the window position
local gui_memory = Memory.get_global_memory().player_gui_memories[player.index]
if gui_memory and gui_memory[window_name] and gui_memory[window_name].position then
flow.location = gui_memory[window_name].position
else
flow.location = GuiCommon.default_window_positions[window_name] or { x = 300, y = 76 }
end
flow.style.maximal_width = 500
flow2 = flow.add({

View File

@ -33,12 +33,14 @@ Public.rage_font_color_2 = { r = 1, g = 0.5, b = 0.1 }
Public.rage_font_color_3 = { r = 1, g = 0.1, b = 0.05 }
Public.default_window_positions = {
runs = { x = 10, y = 48 },
crew = { x = 40, y = 48 },
progress = { x = 250, y = 48 },
fuel = { x = 468, y = 48 },
minimap = { x = 10, y = 48 },
color = { x = 160, y = 96 },
minimap = { x = 10, y = 76 },
color = { x = 160, y = 76 },
info = { x = 160, y = 108 },
runs = { x = 234, y = 76 },
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)
@ -61,7 +63,7 @@ function Public.new_window(player, name)
flow.style = 'map_details_frame'
flow.style.minimal_width = 210
flow.style.natural_width = 210
flow.style.maximal_width = 270
flow.style.maximal_width = 420
flow.style.minimal_height = 80
flow.style.natural_height = 80
flow.style.maximal_height = 760
@ -169,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({
@ -194,7 +195,7 @@ function Public.flow_add_subpanel(flow, name)
flow2.style = 'tabbed_pane_frame'
flow2.style.natural_width = 100
flow2.style.top_padding = -2
flow2.style.top_margin = -8
flow2.style.top_margin = -2
return flow2
end

View File

@ -457,7 +457,7 @@ function Public.click(event)
'pirates.crew_disbanded',
player.name,
memory.name,
Utils.time_longform((memory.real_age or 0) / 60),
Utils.time_longform((memory.age_since_first_island or 0) / 60),
}
Common.notify_game(message)
Server.to_discord_embed_raw(

View File

@ -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,14 @@ 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
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:
@ -1273,7 +1290,7 @@ local function on_gui_click(event)
memory.proceed_are_you_sure_data[player.index]
and memory.proceed_are_you_sure_data[player.index] > game.tick - 60 * 4
then
local destination_index = memory.mapbeingloadeddestination_index
local destination_index = memory.map_being_loaded_destination_index
Progression.progress_to_destination(destination_index)
else
@ -1322,6 +1339,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

View File

@ -30,7 +30,7 @@ function Public.toggle_window(player)
name = window_name .. '_piratewindow',
direction = 'vertical',
})
flow.location = { x = 90, y = 90 }
flow.location = GuiCommon.default_window_positions[window_name]
flow.selected_tab_index = 1
flow.style = 'frame_tabbed_pane'
@ -56,7 +56,7 @@ function Public.toggle_window(player)
flow2 = Public.flow_add_info_tab(flow, { 'pirates.gui_info_updates' })
Public.flow_add_info_sections(flow2, { '1', '2', '3' })
Public.flow_add_info_sections(flow2, { '1', '2' })
-- Public.flow_add_info_sections(flow2, {'updates', 'bugs'})
flow2 = Public.flow_add_info_tab(flow, { 'pirates.gui_info_credits' })
@ -244,7 +244,7 @@ function Public.full_update(player)
elseif flow2.selected_tab_index == 2 then
flow2.style.height = 500
elseif flow2.selected_tab_index == 3 then
flow2.style.height = 800
flow2.style.height = 500
elseif flow2.selected_tab_index == 4 then
flow2.style.height = 350
end

View File

@ -15,6 +15,8 @@ local Public = {}
local window_name = 'progress'
function Public.toggle_window(player)
local memory = Memory.get_crew_memory()
if player.gui.screen[window_name .. '_piratewindow'] then
player.gui.screen[window_name .. '_piratewindow'].destroy()
return
@ -30,12 +32,18 @@ function Public.toggle_window(player)
name = 'leagues',
type = 'label',
})
flow3.style.left_margin = 5
flow3.style.top_margin = -3
flow3.style.bottom_margin = -3
flow3.style.single_line = false
flow3.style.maximal_width = 160
flow3.style.font = 'default-dropdown'
if (not memory.overworldx) or (memory.overworldx and memory.overworldx < 1000) then
flow3 = flow2.add({
name = 'leagues_hint',
type = 'label',
caption = { '', '[color=249,84,249]', { 'pirates.gui_progress_leagues_hint' }, '[/color]' },
})
flow3.style.top_margin = 3
flow3.style.single_line = false
end
flow2 = GuiCommon.flow_add_section(flow, 'current_location', { 'pirates.gui_progress_current_location', '' })
@ -88,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

View File

@ -259,6 +259,7 @@ function Public.toggle_window(player)
-- PROPOSALS --
flow2 = GuiCommon.flow_add_section(flow, 'proposals', { 'pirates.gui_runs_proposals' })
flow2.style.horizontal_align = 'center'
flow3 = flow2.add({
name = 'proposals_listbox',
@ -282,7 +283,8 @@ function Public.toggle_window(player)
flow4.style.minimal_width = 150
flow4.style.font = 'default-bold'
flow4.style.font_color = { r = 0.10, g = 0.10, b = 0.10 }
flow4.style.bottom_margin = 9
flow4.style.bottom_margin = 4
flow4.style.top_margin = 4
-- PROPOSAL MAKER --
@ -474,23 +476,44 @@ function Public.full_update(player)
for _, mem in pairs(global_memory.crew_memories) do
local count = (mem.crewstatus == Crew.enum.LEAVING_INITIAL_DOCK) and Boats.players_on_boat_count(mem.boat)
or #mem.crewplayerindices
local crew_info = {
'',
'[font=scenario-message-dialog]',
mem.name .. ' (',
{
'pirates.player_count_description',
count,
},
')[/font] — [item=',
CoreData.difficulty_options[mem.difficulty_option].icon,
'], [item=rail]',
mem.overworldx or 0,
', [entity=small-biter]',
string.format('%.0f', (mem.evolution_factor or 0) * 100),
'%',
}
if mem.run_is_private then
table.insert(crew_info, ', ')
table.insert(crew_info, { 'pirates.run_condition_private_2' })
end
if mem.run_is_protected then
table.insert(crew_info, ', ')
table.insert(crew_info, { 'pirates.run_condition_captain_protected_2' })
end
if mem.run_has_blueprints_disabled then
table.insert(crew_info, ', ')
table.insert(crew_info, { 'pirates.run_condition_blueprints_disabled_2' })
end
local crew_info_with_id = {
'pirates.second_element',
mem.id,
{
'',
mem.name .. ' (' .. count .. (count == 1 and ' player' or ' players') .. ') — ',
'[item=',
CoreData.difficulty_options[mem.difficulty_option].icon,
'], ',
'[item=rail]',
mem.overworldx or 0,
mem.run_is_private and { 'pirates.run_condition_private' } or '',
mem.run_is_protected and { 'pirates.run_condition_captain_protected' } or '',
mem.run_has_blueprints_disabled and { 'pirates.run_condition_blueprints_disabled' } or '',
},
crew_info,
}
table.insert(wrappedmemories, crew_info)
table.insert(wrappedmemories, crew_info_with_id)
end
GuiCommon.update_listbox(ongoing_runs.body.ongoing_runs_listbox, wrappedmemories)
@ -561,13 +584,31 @@ function Public.full_update(player)
for _, proposal in pairs(global_memory.crewproposals) do
local proposal_info = {
'',
proposal.name .. '',
'[item=rail]',
0,
proposal.run_is_private and { 'pirates.run_condition_private' } or '',
proposal.run_is_protected and { 'pirates.run_condition_captain_protected' } or '',
proposal.run_has_blueprints_disabled and { 'pirates.run_condition_blueprints_disabled' } or '',
'[font=scenario-message-dialog]',
proposal.name .. '[/font]',
}
if proposal.run_is_private or proposal.run_is_protected or proposal.run_has_blueprints_disabled then
local i = 0
table.insert(proposal_info, '')
if proposal.run_is_private then
table.insert(proposal_info, { 'pirates.run_condition_private_2' })
i = i + 1
end
if proposal.run_is_protected then
if i > 0 then
table.insert(proposal_info, ', ')
end
table.insert(proposal_info, { 'pirates.run_condition_captain_protected_2' })
i = i + 1
end
if proposal.run_has_blueprints_disabled then
if i > 0 then
table.insert(proposal_info, ', ')
end
table.insert(proposal_info, { 'pirates.run_condition_blueprints_disabled_2' })
-- i = i + 1
end
end
table.insert(wrappedproposals, proposal_info)
end
GuiCommon.update_listbox(proposals.body.proposals_listbox, wrappedproposals)

View 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

View File

@ -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')
@ -136,11 +137,13 @@ local function crew_tick()
local destination = Common.current_destination()
local tick = game.tick
if memory.age and memory.overworldx and memory.overworldx > 0 then
memory.age = memory.age + 5
end
if memory.real_age then
memory.real_age = memory.real_age + 5
if #Common.crew_get_crew_members() > 0 then
if memory.age and memory.overworldx and memory.overworldx > 0 then
memory.age = memory.age + 5
end
if memory.age_since_first_island then
memory.age_since_first_island = memory.age_since_first_island + 5
end
end
PiratesApiOnTick.boat_movement_tick(5) --arguments are tick intervals
@ -153,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)
@ -175,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()

View File

@ -107,7 +107,7 @@ function Public.go_from_starting_dock_to_first_destination()
memory.crewstatus = Crew.enum.ADVENTURING
memory.age = 0
memory.real_age = 0
memory.age_since_first_island = 0
local message = '[' .. memory.name .. '] Crew members: '
local b = false

View File

@ -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]',

View File

@ -523,8 +523,10 @@ local function class_on_player_used_capsule(event)
rendering.draw_text({
text = '~' .. player.name .. "'s minion~",
surface = player.character.surface,
target = e,
target_offset = { 0, -2.6 },
target = {
entity = e,
offset = { 0, -2.6 },
},
color = player.force.color,
scale = 1.05,
font = 'default-large-semibold',

View File

@ -85,6 +85,10 @@ function Public.class_update_auxiliary_data(tick_interval)
local data = class_auxiliary_data[player_index]
processed_players[player_index] = true
if not data.shaman_charge then
data.shaman_charge = 0
end
if data.shaman_charge < Balance.shaman_max_charge then
-- charge from accumulators
local power_need = Balance.shaman_max_charge - data.shaman_charge
@ -367,8 +371,18 @@ function Public.update_character_properties(tick_interval)
if main_inv.can_insert(main_gun_inv[1]) then
main_inv.insert(main_gun_inv[1])
Common.notify_player_expected(
player,
{ 'pirates.discard_weapon_to_inventory', Classes.display_form(class) }
)
else
player.character.surface.spill_item_stack(player.character.position, main_gun_inv[1])
Common.notify_player_error(
player,
{ 'pirates.discard_weapon_to_ground', Classes.display_form(class) }
)
end
main_gun_inv.remove(main_gun_inv[1])

View File

@ -500,8 +500,10 @@ function Public.place_boat(boat, floor_tile, place_entities_bool, correct_tiles,
-- boat.parrot.render = rendering.draw_sprite{
-- sprite = "file/parrot/parrot_idle_fly_1.png",
-- surface = surface,
-- target = ee,
-- target_offset = Utils.psum{boat.parrot.position_relative_to_boat, boat.parrot.sprite_extra_offset},
-- target = {
-- entity = ee,
-- offset = Utils.psum{boat.parrot.position_relative_to_boat, boat.parrot.sprite_extra_offset},
-- },
-- x_scale = 2.8,
-- y_scale = 2.8,
-- visible = false,
@ -510,8 +512,10 @@ function Public.place_boat(boat, floor_tile, place_entities_bool, correct_tiles,
-- text = 'Parrot',
-- color = CoreData.colors.parrot,
-- surface = surface,
-- target = ee,
-- target_offset = Utils.psum{boat.parrot.position_relative_to_boat, boat.parrot.text_extra_offset},
-- target = {
-- entity = ee,
-- offset = Utils.psum{boat.parrot.position_relative_to_boat, boat.parrot.text_extra_offset},
-- },
-- visible = false,
-- alignment = 'center',
-- }
@ -575,7 +579,7 @@ function Public.place_boat(boat, floor_tile, place_entities_bool, correct_tiles,
-- local p = Utils.psum{boat.position, scope.Data.comfy_rendering_position}
-- boat.rendering_comfy = rendering.draw_sprite{
-- sprite = "file/comfy2.png",
-- render_layer = '125',
-- render_layer = 'corpse',
-- surface = surface,
-- target = p,
-- }
@ -1039,6 +1043,8 @@ local function process_entity_on_boat_unteleportable(
-- end
boat.deck_whitebelts[#boat.deck_whitebelts + 1] = ee
end
return ee
end
end
@ -1110,8 +1116,10 @@ local function process_entity_on_boat_teleportable(
rendering.draw_text({
text = '~' .. owner.name .. "'s minion~",
surface = newsurface,
target = ee,
target_offset = { 0, -2.6 },
target = {
entity = ee,
offset = { 0, -2.6 },
},
color = owner.force.color,
scale = 1.05,
font = 'default-large-semibold',
@ -1158,8 +1166,10 @@ local function process_entity_on_boat_teleportable(
-- local r = rendering.draw_sprite{
-- sprite = "file/parrot/parrot_idle_fly_1.png",
-- surface = newsurface,
-- target = ee,
-- target_offset = Utils.psum{boat.parrot.position_relative_to_boat, boat.parrot.sprite_extra_offset},
-- target = {
-- entity = ee,
-- offset = Utils.psum{boat.parrot.position_relative_to_boat, boat.parrot.sprite_extra_offset},
-- },
-- x_scale = 2.8,
-- y_scale = 2.8,
-- }
@ -1167,8 +1177,10 @@ local function process_entity_on_boat_teleportable(
-- text = 'Parrot',
-- color = CoreData.colors.parrot,
-- surface = newsurface,
-- target = ee,
-- target_offset = Utils.psum{boat.parrot.position_relative_to_boat, boat.parrot.text_extra_offset},
-- target = {
-- entity = ee,
-- offset = Utils.psum{boat.parrot.position_relative_to_boat, boat.parrot.text_extra_offset},
-- },
-- alignment = 'center',
-- }
-- rendering.destroy(boat.parrot.render)
@ -1204,6 +1216,8 @@ local function process_entity_on_boat_teleportable(
end
end
end
return ee
end
local function process_entity_on_boat(
@ -1223,6 +1237,15 @@ local function process_entity_on_boat(
unique_entities_list[#unique_entities_list + 1] = e
local name = e.name
local players_with_gui_open = {}
for _, player in pairs(game.connected_players) do
if player.opened == e then
table.insert(players_with_gui_open, player)
end
end
local ee
-- NOTE: This sometimes causes items on belts to be sent to cabin, which maybe could be fixed?
if name == 'item-on-ground' then
Common.give_items_to_crew({ { name = e.stack.name, count = e.stack.count } })
@ -1239,7 +1262,7 @@ local function process_entity_on_boat(
Utils.contains(CoreData.unteleportable_names, name)
or (name == 'entity-ghost' and Utils.contains(CoreData.unteleportable_names, e.ghost_name))
then
process_entity_on_boat_unteleportable(
ee = process_entity_on_boat_unteleportable(
memory,
boat,
newsurface,
@ -1251,7 +1274,7 @@ local function process_entity_on_boat(
name
)
else
process_entity_on_boat_teleportable(
ee = process_entity_on_boat_teleportable(
memory,
boat,
newsurface,
@ -1264,6 +1287,12 @@ local function process_entity_on_boat(
)
end
end
if ee and ee.valid then
for _, player in ipairs(players_with_gui_open) do
player.opened = ee
end
end
end
end
@ -1425,7 +1454,7 @@ local function teleport_handle_renderings(boat, oldsurface_name, newsurface_name
-- rendering.destroy(boat.rendering_comfy)
-- boat.rendering_comfy = rendering.draw_sprite{
-- sprite = "file/comfy2.png",
-- render_layer = '125',
-- render_layer = 'corpse',
-- surface = newsurface,
-- target = p,
-- }

View File

@ -344,8 +344,10 @@ function Public.create_cabin_surface()
rendering.draw_text({
color = { 60, 255, 124 },
scale = 1.6,
target = e,
target_offset = { 0, -6 },
target = {
entity = e,
offset = { 0, -6 },
},
surface = e.surface,
alignment = 'center',
text = "Captain's Market",

View File

@ -7,7 +7,7 @@ Public.display_names = { { 'pirates.location_displayname_cave_1' } }
Public.terraingen_frame_width = 640
Public.terraingen_frame_height = 640
Public.static_params_default = {
decorative_settings = prototypes.space_location.nauvis.map_gen_settings.autoplace_settings.decorative.settings,
decorative_preset = 'nauvis',
base_starting_treasure = 1000,
base_starting_rock_material = 800,
base_starting_wood = 1200,

View File

@ -12,7 +12,7 @@ Public.terraingen_frame_width = 325
Public.terraingen_frame_height = 325
Public.static_params_default = {
starting_time_of_day = 0,
decorative_settings = prototypes.space_location.nauvis.map_gen_settings.autoplace_settings.decorative.settings,
decorative_preset = 'nauvis',
daynightcycletype = 1,
boat_extra_distance_from_shore = 0,
-- boat_extra_distance_from_shore = 0.1 * Common.boat_default_starting_distance_from_shore,

View File

@ -91,7 +91,7 @@ function Public.terrain(args)
if noises.forest_abs_suppressed(p) < 0.6 then
if noises.height(p) > 0.12 then
local rockdensity = 0.0018 * Math.slopefromto(noises.rock_abs(p), -0.15, 0.3)
local rockdensity = 0.003 * Math.slopefromto(noises.rock(p), 0, 0.4)
local rockrng = Math.random()
if rockrng < rockdensity then
args.entities[#args.entities + 1] = IslandsCommon.random_rock_1(args.p)
@ -104,6 +104,20 @@ function Public.terrain(args)
end
end
end
if noises.height(p) > 0.15 then
-- Place lettuce:
local lettuce_density = 0.005 * Math.slopefromto(noises.rock(p), -0.05, -0.4)
local lettuce_rng = Math.random()
-- if lettuce_rng < lettuce_density then
-- args.decoratives[#args.decoratives + 1] = { name = 'green-lettuce-lichen-1x1', position = args.p }
-- elseif lettuce_rng < lettuce_density * 4 then
-- args.decoratives[#args.decoratives + 1] = { name = 'green-bush-mini', position = args.p }
-- end
if lettuce_rng < lettuce_density * 4 then
args.decoratives[#args.decoratives + 1] = { name = 'green-bush-mini', position = args.p }
end
end
end
function Public.chunk_structures(args)

View File

@ -17,7 +17,7 @@ Public.terraingen_frame_height = 896
Public.static_params_default = {
starting_time_of_day = 0,
daynightcycletype = 1,
decorative_settings = prototypes.space_location.nauvis.map_gen_settings.autoplace_settings.decorative.settings,
decorative_preset = 'nauvis',
base_starting_treasure = 1000,
base_starting_rock_material = 800,
base_starting_wood = 1200,

View File

@ -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
@ -41,8 +42,10 @@ Public['IslandsCommon'] = require('maps.pirates.surfaces.islands.common')
-- destination.dynamic_data.rocketsilohptext = rendering.draw_text{
-- text = 'HP: ' .. destination.dynamic_data.rocketsilohp .. ' / ' .. destination.dynamic_data.rocketsilomaxhp,
-- surface = surface,
-- target = destination.dynamic_data.rocketsilos[1],
-- target_offset = {0, 4.5},
-- target = {
-- entity = destination.dynamic_data.rocketsilos[1],
-- offset = {0, 4.5},
-- },
-- color = {0, 255, 0},
-- scale = 1.20,
-- font = 'default-game',
@ -70,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 = '125',
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
@ -131,7 +117,7 @@ function Public.spawn_ghosts(destination, points_to_avoid)
surface = surface,
target = p,
sprite = 'utility/create_ghost_on_entity_death_modifier_icon',
render_layer = '125',
render_layer = 'corpse',
x_scale = 1,
y_scale = 1,
})

View File

@ -13,7 +13,7 @@ Public.terraingen_frame_height = 896
Public.static_params_default = {
starting_time_of_day = 0,
daynightcycletype = 1,
decorative_settings = prototypes.space_location.nauvis.map_gen_settings.autoplace_settings.decorative.settings,
decorative_preset = 'nauvis',
base_starting_treasure = 1000,
base_starting_rock_material = 800,
base_starting_wood = 1200,

View File

@ -19,8 +19,8 @@ Public.static_params_default = {
base_starting_rock_material = 1200,
base_starting_wood = 800,
base_starting_treasure_maps = 1,
decorative_settings = prototypes.space_location.nauvis.map_gen_settings.autoplace_settings.decorative.settings,
-- decorative_settings = prototypes.space_location.fulgora.map_gen_settings.autoplace_settings.decorative.settings,
decorative_preset = 'nauvis',
-- decorative_preset = 'fulgora',
}
function Public.base_ores() --here, just for the gui:

View File

@ -16,7 +16,7 @@ Public.terraingen_frame_height = 700
Public.static_params_default = {
starting_time_of_day = 0,
daynightcycletype = 1,
decorative_settings = prototypes.space_location.nauvis.map_gen_settings.autoplace_settings.decorative.settings,
decorative_preset = 'nauvis',
base_starting_treasure = 0,
base_starting_rock_material = 8600,
base_starting_wood = 600,

View File

@ -11,7 +11,7 @@ Public.display_names = { { 'pirates.location_displayname_standard_1' } }
Public.terraingen_frame_width = 896
Public.terraingen_frame_height = 896
Public.static_params_default = {
decorative_settings = prototypes.space_location.nauvis.map_gen_settings.autoplace_settings.decorative.settings,
decorative_preset = 'nauvis',
base_starting_treasure = 1000,
base_starting_rock_material = 800,
base_starting_wood = 1200,

View File

@ -11,7 +11,7 @@ Public.display_names = { { 'pirates.location_displayname_standard_variant_1' } }
Public.terraingen_frame_width = 896
Public.terraingen_frame_height = 896
Public.static_params_default = {
decorative_settings = prototypes.space_location.nauvis.map_gen_settings.autoplace_settings.decorative.settings,
decorative_preset = 'nauvis',
base_starting_treasure = 1000,
base_starting_rock_material = 800,
base_starting_wood = 1200,

View File

@ -14,7 +14,7 @@ Public.static_params_default = {
starting_time_of_day = 0.26,
daynightcycletype = 1,
brightness_visual_weights = { 0, 0, 0 },
decorative_settings = prototypes.space_location.nauvis.map_gen_settings.autoplace_settings.decorative.settings,
decorative_preset = 'nauvis',
base_starting_treasure = 1000,
base_starting_rock_material = 800,
base_starting_wood = 1200,

View File

@ -15,8 +15,8 @@ Public.static_params_default = {
daynightcycletype = 4,
min_brightness = 0.05,
brightness_visual_weights = { 1, 1, 1 }, --almost pitch black
decorative_settings = prototypes.space_location.nauvis.map_gen_settings.autoplace_settings.decorative.settings,
-- decorative_settings = prototypes.space_location.vulcanus.map_gen_settings.autoplace_settings.decorative.settings,
decorative_preset = 'nauvis',
-- decorative_preset = 'vulcanus',
base_starting_rock_material = 800,
}

File diff suppressed because one or more lines are too long

View File

@ -765,8 +765,10 @@ function Public.create_surface(destination)
--todo: put into static_params
if destination.static_params.decorative_settings ~= nil then
mgs.autoplace_settings.decorative = { settings = destination.static_params.decorative_settings }
if destination.static_params.decorative_preset ~= nil then
mgs.autoplace_settings.decorative = {
settings = prototypes.space_location[destination.static_params.decorative_preset].map_gen_settings.autoplace_settings.decorative.settings,
}
end
-- TODO: Remove this code if Wube fixes this 'bug'