1
0
mirror of https://github.com/ComfyFactory/ComfyFactorio.git synced 2025-02-03 13:12:11 +02:00

Merge branch 'develop' into develop

This commit is contained in:
Gerkiz 2022-12-20 13:50:55 +01:00 committed by GitHub
commit 529879d691
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
17 changed files with 169 additions and 129 deletions

View File

@ -178,15 +178,17 @@ local function teleport_players(surface, small_force_chunk)
end
local function equip_players(player_starting_items)
for k, player in pairs(game.connected_players) do
for _, player in pairs(game.connected_players) do
if player.character then
player.character.destroy()
end
player.character = nil
player.set_controller({type = defines.controllers.god})
player.create_character()
for item, amount in pairs(player_starting_items) do
player.insert({name = item, count = amount})
if player_starting_items then
for item, amount in pairs(player_starting_items) do
player.insert({name = item, count = amount})
end
end
Modifiers.update_player_modifiers(player)
end
@ -261,10 +263,10 @@ function Public.get_reset_counter()
end
--- Customizes the message with the mapkeeper param.
---@param boolean <true/false>
function Public.enable_mapkeeper(boolean)
if boolean and type(boolean) == 'boolean' then
this.enable_mapkeeper = boolean or false
---@param state boolean
function Public.enable_mapkeeper(state)
if state and type(state) == 'boolean' then
this.enable_mapkeeper = state or false
end
end

View File

@ -16,7 +16,7 @@ softmod_info_tips_1=Features of the game that are hard to work out alone
softmod_info_tips_2=• The captain can steer the boat from the crow's nest by placing 100 rail signals in one of the blue boxes.\n• Resources granted to the ship appear in the captain's cabin.\n• Charging a silo drains power from everything else on its network.\n• The quantity of ore available on an island is independent of the order in which you break rocks.\n• Passive pollution ramps up over time on each island.\n• The strength of attacks is proportional to the number of remaining nests. (The time-based rate of evolution is proportional to nests too, but destroying a nest will immediately jump evolution by most of the amount it 'would have' made had it survived.)\n• Lab productivity increases with each league.\n• item-on-ground entities on the deck are moved to the cabin when the boat moves, for performance reasons.\n• Commands: /ccolor gives you a fun color. /classinfo {classname} gives the description of the named class. To manage your class, use /take {classname} or /giveup.
softmod_info_updates_1=Significant recent changes
softmod_info_updates_2=v1.4.2\n• Disabled 'disband crew' button.\n• Increased amount of fish caught by all fishing classes.\n• Enabled concrete tech.\n• Fixed Mysterious caves island always having the same layout.\n• Fixed issue where power could get disconnected between deck and hold.\n• Added /clear_north_tanks and /clear_south_tanks commands to clear fluid from ship's storage tanks.\n\nv1.4.1\n• Cannon upgrade is now more expensive and appears less often.\n• Bugfixes.\n\nv1.4.0\n• New private runs: Protect your run by a password.\n• New island: Mysterious caves.\n• New technologies now available: Car and nuclear energy.\n• New way to unlock extra holds and power upgrades.\n• Various island related balance changes.
softmod_info_updates_2=v1.4.2\n• Disabled 'disband crew' button.\n• Increased amount of fish caught by all fishing classes.\n• Enabled concrete tech.\n• Fixed Mysterious caves island always having the same layout.\n• Fixed issue where power could get disconnected between deck and hold.\n• Added /clear_north_tanks and /clear_south_tanks commands to clear fluid from ship's storage tanks.\n• Difficulty of Hard and Nightmare increased. Resistive roles slightly nerfed.\n\nv1.4.0\n• New private runs: Protect your run by a password.\n• New island: Mysterious caves.\n• New technologies now available: Car and nuclear energy.\n• New way to unlock extra holds and power upgrades.\n• Various island related balance changes.
softmod_info_credits_1=Credits
softmod_info_credits_2=Pirate Ship designed and coded by thesixthroc. Updates from Piratux. Comfy codebase and help from Gerkiz, Hanakocz and Mew @ Comfy Industries (https://getcomfy.eu). Some island structure blueprints contributed by Mattisso.\n\nCome chat with us: https://getcomfy.eu/discord\n\n"Those white gloves. I'll never forget them 'till the day I die." - Dr. John

View File

@ -137,16 +137,16 @@ function Public.wave_size_rng() -- random variance in attack sizes
wave_size_multiplier = 0
elseif memory.overworldx > 0 then
local rng2 = Math.random(1000)
if rng2 <= 900 then
if rng2 <= 890 then
wave_size_multiplier = 1
elseif rng2 <= 975 then
elseif rng2 <= 970 then
wave_size_multiplier = 1.5
elseif rng2 <= 985 then
wave_size_multiplier = 2
elseif rng2 <= 995 then
wave_size_multiplier = 2.5
else
wave_size_multiplier = 3
else
wave_size_multiplier = 4
end
end

View File

@ -6,6 +6,7 @@ local Math = require 'maps.pirates.math'
-- local Raffle = require 'maps.pirates.raffle'
-- local Memory = require 'maps.pirates.memory'
local Common = require 'maps.pirates.common'
local CoreData = require 'maps.pirates.coredata'
-- local Utils = require 'maps.pirates.utils_local'
-- local _inspect = require 'utils.inspect'.inspect
@ -36,13 +37,13 @@ Public.class_reward_tick_rate_in_seconds = 7
Public.poison_damage_multiplier = 1.85
Public.every_nth_tree_gives_coins = 6
Public.samurai_damage_taken_multiplier = 0.26
Public.samurai_damage_taken_multiplier = 0.32
Public.samurai_damage_dealt_when_not_melee_multiplier = 0.75
Public.samurai_damage_dealt_with_melee = 25
Public.hatamoto_damage_taken_multiplier = 0.16
Public.hatamoto_damage_taken_multiplier = 0.21
Public.hatamoto_damage_dealt_when_not_melee_multiplier = 0.75
Public.hatamoto_damage_dealt_with_melee = 45
Public.iron_leg_damage_taken_multiplier = 0.18
Public.iron_leg_damage_taken_multiplier = 0.24
Public.iron_leg_iron_ore_required = 3000
Public.deckhand_extra_speed = 1.25
Public.deckhand_ore_grant_multiplier = 5
@ -93,7 +94,7 @@ Public.EEI_stages = { --multipliers
function Public.scripted_biters_pollution_cost_multiplier()
return 1.45 / Math.sloped(Common.difficulty_scale(), 1/3) * (1 + 1.2 / ((1 + (Common.overworldx()/40))^(1.5+Common.difficulty_scale()))) -- the complicated factor just makes the early-game easier; in particular the first island, but on easier difficulties the next few islands as well
return 1.25 / Math.sloped(Common.difficulty_scale(), 1/2) * (1 + 1.2 / ((1 + (Common.overworldx()/40))^(1.5+Common.difficulty_scale()))) -- the complicated factor just makes the early-game easier; in particular the first island, but on easier difficulties the next few islands as well
end
function Public.cost_to_leave_multiplier()
@ -211,7 +212,7 @@ end
function Public.silo_total_pollution()
return (
365 * (Common.difficulty_scale()^(1.2)) * Public.crew_scale()^(3/10) * (3.2 + 0.7 * (Common.overworldx()/40)^(1.6)) / Math.sloped(Common.difficulty_scale(), 1/5) --shape of the curve with x is tuned. Final factor of difficulty is to offset a change made to scripted_biters_pollution_cost_multiplier
347 * (Common.difficulty_scale()^(1.0)) * Public.crew_scale()^(3/10) * (3.2 + 0.7 * (Common.overworldx()/40)^(1.6)) --shape of the curve with x is tuned.
)
end
@ -245,8 +246,8 @@ function Public.boat_passive_pollution_per_minute(time)
end
return boost * (
2.73 * (Common.difficulty_scale()^(1.1)) * (Common.overworldx()/40)^(1.8) * (Public.crew_scale())^(52/100)-- There is no _explicit_ T dependence, but it depends almost the same way on the crew_scale as T does.
) / Math.sloped(Common.difficulty_scale(), 1/5) --Final factor of difficulty is to offset a change made to scripted_biters_pollution_cost_multiplier
2.60 * (Common.difficulty_scale()^(0.8)) * (Common.overworldx()/40)^(1.8) * (Public.crew_scale())^(52/100)-- There is no _explicit_ T dependence, but it depends almost the same way on the crew_scale as T does.
)
end
@ -259,6 +260,15 @@ function Public.base_evolution_leagues(leagues)
else
evo = (0.0201 * (overworldx/40)) * Math.sloped(Common.difficulty_scale(), 1/5)
local difficulty_name = CoreData.get_difficulty_option_informal_name_from_value(Common.difficulty_scale())
if difficulty_name == 'normal' then
evo = evo + 0.01
elseif difficulty_name == 'hard' then
evo = evo + 0.02
elseif difficulty_name == 'nightmare' then
evo = evo + 0.04
end
if overworldx > 600 and overworldx < 1000 then
evo = evo + (0.0025 * (overworldx - 600)/40)
elseif overworldx >= 1000 then

View File

@ -120,11 +120,11 @@ Public.difficulty_options = {
--For the value of Easy difficulty, we are pulled in two directions: We wish to make the game comfy to play for those who haven't played it, but we also wish to represent the game mechanics faithfully so that Normal is not a crazy distance away.
{value = 0.5, icon = 'item/firearm-magazine', text = {'pirates.difficulty_easy'}, associated_color = {r = 50, g = 255, b = 50}},
{value = 0.9, icon = 'item/piercing-rounds-magazine', text = {'pirates.difficulty_normal'}, associated_color = {r = 255, g = 255, b = 50}},
{value = 0.95, icon = 'item/piercing-rounds-magazine', text = {'pirates.difficulty_normal'}, associated_color = {r = 255, g = 255, b = 50}},
{value = 1.4, icon = 'item/uranium-rounds-magazine', text = {'pirates.difficutly_hard'}, associated_color = {r = 255, g = 50, b = 50}},
{value = 1.5, icon = 'item/uranium-rounds-magazine', text = {'pirates.difficutly_hard'}, associated_color = {r = 255, g = 50, b = 50}},
{value = 2.1, icon = 'item/atomic-bomb', text = {'pirates.difficulty_nightmare'}, associated_color = {r = 170, g = 60, b = 60}},
{value = 2.2, icon = 'item/atomic-bomb', text = {'pirates.difficulty_nightmare'}, associated_color = {r = 170, g = 60, b = 60}},
}
function Public.get_difficulty_option_from_value(difficulty_value)
-- given a difficulty value, key in to the closesy entry in the above table. (organising things this way allows us to make changes to the 'value' keys in the above table without disrupting e.g. past highscores data)

View File

@ -315,7 +315,8 @@ function Public.afk_player_tick(player)
-- local global_memory = Memory.get_global_memory()
local memory = Memory.get_crew_memory()
if Common.is_captain(player) and #Common.crew_get_nonafk_crew_members() > 0 then
if Common.is_captain(player) and #Common.crew_get_nonafk_crew_members() >= 6 then
-- in this case, lose captainhood
local force = memory.force
if force and force.valid then

View File

@ -141,9 +141,9 @@ end
function Public.close_position_try_avoiding_entities(args, points_to_avoid, farness_boost_low, farness_boost_high)
farness_boost_low = farness_boost_low or 0
farness_boost_high = farness_boost_high or 0
function Public.close_position_try_avoiding_entities(args, points_to_avoid, farness_low, farness_high)
farness_low = farness_low or 0.06
farness_high = farness_high or 0.19
points_to_avoid = points_to_avoid or {}
-- local memory = Memory.get_crew_memory()
@ -168,7 +168,7 @@ function Public.close_position_try_avoiding_entities(args, points_to_avoid, farn
if (not Utils.contains(CoreData.tiles_that_conflict_with_resource_layer, tile.name)) and (not Utils.contains(CoreData.edgemost_tile_names, tile.name)) then
local p3 = {x = p2.x + args.static_params.terraingen_coordinates_offset.x, y = p2.y + args.static_params.terraingen_coordinates_offset.y}
if IslandsCommon.island_farness_1(args)(p3) > 0.06 + farness_boost_low and IslandsCommon.island_farness_1(args)(p3) < 0.19 + farness_boost_high then
if IslandsCommon.island_farness_1(args)(p3) > farness_low and IslandsCommon.island_farness_1(args)(p3) < farness_high then
local allowed = true
if tries < 40 and #surface.find_entities({{p2.x - 8, p2.y - 8}, {p2.x + 8, p2.y + 8}}) > 0 then
allowed = false

View File

@ -169,15 +169,15 @@ function Public.spawn_ores_on_arrival(destination, points_to_avoid)
noise_generator = Utils.noise_generator({}, 0),
}
local farness_boost_low, farness_boost_high = 0, 0
local farness_low, farness_high = 0.06, 0.25
if destination.subtype == enum.MAZE then
farness_boost_low = 0.08
farness_boost_high = 0.25
farness_low = 0.14
farness_high = 0.44
end
for _, ore in pairs(ores) do
if destination.static_params.abstract_ore_amounts[ore] then
local p = Hunt.close_position_try_avoiding_entities(args, points_to_avoid, farness_boost_low, farness_boost_high)
local p = Hunt.close_position_try_avoiding_entities(args, points_to_avoid, farness_low, farness_high)
if p then
points_to_avoid[#points_to_avoid + 1] = {x=p.x, y=p.y, r=11}

View File

@ -160,7 +160,13 @@ function Public.near_another_town(force_name, position, surface, radius)
end
function Public.in_restricted_zone(surface, position)
if surface.name ~= 'nauvis' then
local this = ScenarioTable.get_table()
local map_surface = game.get_surface(this.active_surface_index)
if not map_surface or not map_surface.valid then
return
end
if surface.name ~= map_surface.name then
return false
end
local chunk_position = {}
@ -205,7 +211,11 @@ local function prevent_landfill_in_restricted_zone(event)
if tile == nil or not tile.valid then
return
end
local surface = game.surfaces[event.surface_index]
local this = ScenarioTable.get_table()
local surface = game.get_surface(this.active_surface_index)
if not surface or not surface.valid then
return
end
local fail = false
local position
for _, t in pairs(event.tiles) do
@ -275,7 +285,11 @@ local function prevent_tiles_near_towns(event)
if tile == nil or not tile.valid then
return
end
local surface = game.surfaces[event.surface_index]
local this = ScenarioTable.get_table()
local surface = game.get_surface(this.active_surface_index)
if not surface or not surface.valid then
return
end
local force_name
if player_index ~= nil then
local player = game.get_player(player_index)

View File

@ -8,10 +8,14 @@ function Public.reset()
if this.testing_mode then
return
end
local map_surface = game.get_surface(this.active_surface_index)
if not map_surface or not map_surface.valid then
return
end
for index = 1, table.size(game.forces), 1 do
local force = game.forces[index]
if force ~= nil then
force.clear_chart('nauvis')
force.clear_chart(map_surface.name)
end
end
end
@ -39,13 +43,16 @@ local function update_forces(id)
end
local function on_chunk_charted(event)
local surface = game.surfaces[event.surface_index]
local this = ScenarioTable.get_table()
local surface = game.get_surface(this.active_surface_index)
if not surface or not surface.valid then
return
end
local force = event.force
local area = event.area
local markets = surface.find_entities_filtered({area = area, name = 'market'})
for _, market in pairs(markets) do
local force_name = market.force.name
local this = ScenarioTable.get_table()
local town_center = this.town_centers[force_name]
if not town_center then
return

View File

@ -97,22 +97,22 @@ local function update_score()
},
field2 = {
text1 = 'Town researched:',
text2 = winner.name .. ' with a score of ' .. winner.research_counter .. ' techs!',
text2 = winner.research_counter .. ' techs!',
inline = 'false'
},
field3 = {
text1 = 'Town upgrades:',
text2 = winner.name .. ' upgraded their town with:\nCrafting speed:' .. winner.upgrades.crafting_speed .. '\nMining speed:' .. winner.upgrades.mining_speed,
text2 = 'Crafting speed:' .. winner.upgrades.crafting_speed .. '\nMining speed:' .. winner.upgrades.mining_speed,
inline = 'false'
},
field4 = {
text1 = 'Town health:',
text2 = winner.name .. ' had a health of ' .. winner.health .. ' left!',
text2 = winner.health .. 'hp left!',
inline = 'false'
},
field5 = {
text1 = 'Town coins:',
text2 = winner.name .. ' had ' .. winner.coin_balance .. ' coins stashed!',
text2 = winner.coin_balance .. ' coins stashed!',
inline = 'false'
}
}
@ -135,7 +135,9 @@ local function update_score()
subheader.style.horizontally_stretchable = true
subheader.style.vertical_align = 'center'
subheader.add {type = 'label', style = 'subheader_label', caption = {'', 'Survive 2 days (48h) to win!'}}
local days = this.required_time_to_win / 24
subheader.add {type = 'label', style = 'subheader_label', caption = {'', 'Survive for ' .. days .. ' days (' .. this.required_time_to_win .. 'h) to win!'}}
if not next(subheader.children) then
subheader.destroy()
@ -246,8 +248,6 @@ local function on_nth_tick(event)
if not tick_actions[seconds] then
return
end
--game.surfaces['nauvis'].play_sound({path = 'utility/alert_destroyed', volume_modifier = 1})
--log('seconds = ' .. seconds)
tick_actions[seconds]()
end

View File

@ -1,5 +1,6 @@
local Event = require 'utils.event'
local ScenarioTable = require 'maps.scrap_towny_ffa.table'
local SoftReset = require 'functions.soft_reset'
local math_random = math.random
local table_shuffle = table.shuffle_table
@ -11,8 +12,12 @@ local map_width = 2560
local map_height = 2560
function Public.nuke(position)
local surface = game.surfaces['nauvis']
surface.create_entity({name = 'atomic-rocket', position = position, target = position, speed = 0.5})
local this = ScenarioTable.get_table()
local map_surface = game.get_surface(this.active_surface_index)
if not map_surface or not map_surface.valid then
return
end
map_surface.create_entity({name = 'atomic-rocket', position = position, target = position, speed = 0.5})
end
function Public.armageddon()
@ -63,14 +68,10 @@ function Public.armageddon()
end
function Public.initialize()
if game.surfaces['nauvis'] then
-- clear the surface
game.surfaces['nauvis'].clear(false)
end
local surface = game.surfaces['nauvis']
local this = ScenarioTable.get_table()
local surface_seed = game.surfaces['nauvis']
-- this overrides what is in the map_gen_settings.json file
local mgs = surface.map_gen_settings
local mgs = surface_seed.map_gen_settings
mgs.default_enable_all_autoplace_controls = true -- don't mess with this!
mgs.autoplace_controls = {
coal = {frequency = 2, size = 0.1, richness = 0.2},
@ -106,10 +107,6 @@ function Public.initialize()
cliff_elevation_interval = 10,
richness = 0.4
}
-- water = 0 means no water allowed
-- water = 1 means elevation is not reduced when calculating water tiles (elevation < 0)
-- water = 2 means elevation is reduced by 10 when calculating water tiles (elevation < 0)
-- or rather, the water table is 10 above the normal elevation
mgs.water = 0.5
mgs.peaceful_mode = false
mgs.starting_area = 'none'
@ -120,56 +117,10 @@ function Public.initialize()
--mgs.starting_points = {
-- {x = 0, y = 0}
--}
-- here we put the named noise expressions for the specific noise-layer if we want to override them
mgs.property_expression_names = {
-- here we are overriding the moisture noise-layer with a fixed value of 0 to keep moisture consistently dry across the map
-- it allows to free up the moisture noise expression
-- low moisture
--moisture = 0,
-- here we are overriding the aux noise-layer with a fixed value to keep aux consistent across the map
-- it allows to free up the aux noise expression
-- aux should be not sand, nor red sand
--aux = 0.5,
-- here we are overriding the temperature noise-layer with a fixed value to keep temperature consistent across the map
-- it allows to free up the temperature noise expression
-- temperature should be 20C or 68F
--temperature = 20,
-- here we are overriding the cliffiness noise-layer with a fixed value of 0 to disable cliffs
-- it allows to free up the cliffiness noise expression (which may or may not be useful)
-- disable cliffs
--cliffiness = 0,
-- we can disable starting lakes two ways, one by setting starting-lake-noise-amplitude = 0
-- or by making the elevation a very large number
-- make sure starting lake amplitude is 0 to disable starting lakes
['starting-lake-noise-amplitude'] = 0,
-- allow enemies to get up close on spawn
['starting-area'] = 0,
-- this accepts a string representing a named noise expression
-- or number to determine the elevation based on x, y and distance from starting points
-- we can not add a named noise expression at this point, we can only reference existing ones
-- if we have any custom noise expressions defined from a mod, we will be able to use them here
-- setting it to a fixed number would mean a flat map
-- elevation < 0 means there is water unless the water table has been changed
--elevation = -1,
--elevation = 0,
--elevation-persistence = 0,
-- testing
--["control-setting:moisture:bias"] = 0.5,
--["control-setting:moisture:frequency:multiplier"] = 0,
--["control-setting:aux:bias"] = 0.5,
--["control-setting:aux:frequency:multiplier"] = 1,
--["control-setting:temperature:bias"] = 0.01,
--["control-setting:temperature:frequency:multiplier"] = 100,
--["tile:water:probability"] = -1000,
--["tile:deep-water:probability"] = -1000,
-- a constant intensity means base distribution will be consistent with regard to distance
['enemy-base-intensity'] = 1,
-- adjust this value to set how many nests spawn per tile
['enemy-base-frequency'] = 0.4,
@ -177,6 +128,23 @@ function Public.initialize()
['enemy-base-radius'] = 12
}
mgs.seed = math_random(10000, 999999)
if not this.active_surface_index then
this.active_surface_index = game.create_surface('towny', mgs).index
else
this.active_surface_index = SoftReset.soft_reset_map(game.surfaces[this.active_surface_index], mgs, nil).index
end
local surface = game.get_surface(this.active_surface_index)
if not surface or not surface.valid then
return
end
if math.random(1, 32) == 1 then
this.required_time_to_win = 168
this.required_time_to_win_in_ticks = 36288000
end
surface.map_gen_settings = mgs
surface.peaceful_mode = false
surface.always_day = false
@ -184,11 +152,6 @@ function Public.initialize()
surface.clear(true)
surface.regenerate_entity({'rock-huge', 'rock-big', 'sand-rock-big'})
surface.regenerate_decorative()
-- this will force generate the entire map
--Server.to_discord_embed('ScrapTownyFFA Map Regeneration in Progress')
--surface.request_to_generate_chunks({x=0,y=0},64)
--surface.force_generate_chunk_requests()
--Server.to_discord_embed('Regeneration Complete')
end
local function on_tick()

View File

@ -44,9 +44,12 @@ end
function Public.spawn(player)
-- first time spawn point
local surface = game.surfaces['nauvis']
local this = ScenarioTable.get_table()
local surface = game.get_surface(this.active_surface_index)
if not surface or not surface.valid then
return
end
local spawn_point = Spawn.get_new_spawn_point(player, surface)
local this = ScenarioTable.get()
this.strikes[player.name] = 0
Spawn.clear_spawn_point(spawn_point, surface)
-- reset cooldown

View File

@ -11,7 +11,6 @@ local table_insert = table.insert
-- game duration in ticks
-- 7d * 24h * 60m * 60s * 60t
-- local game_duration = 36288000
local game_duration = 36288000
local armageddon_duration = 3600
local warning_duration = 600
local mapkeeper = '[color=blue]Mapkeeper:[/color]'
@ -58,7 +57,10 @@ local function do_soft_reset()
this.game_reset_tick = nil
this.game_won = false
ScenarioTable.reset_table()
local surface = game.surfaces['nauvis']
local surface = game.get_surface(this.active_surface_index)
if not surface or not surface.valid then
return
end
if get_victorious_force() then
surface.play_sound({path = 'utility/game_won', volume_modifier = 1})
else
@ -152,17 +154,19 @@ local function on_tick()
end
end
if (tick + armageddon_duration + warning_duration) % game_duration == 0 then
local required_time_to_win_in_ticks = ScenarioTable.get('required_time_to_win_in_ticks')
if (tick + armageddon_duration + warning_duration) % required_time_to_win_in_ticks == 0 then
warning()
end
if (tick + armageddon_duration) % game_duration == 0 then
if (tick + armageddon_duration) % required_time_to_win_in_ticks == 0 then
armageddon()
end
if (tick + 1) % game_duration == 0 then
if (tick + 1) % required_time_to_win_in_ticks == 0 then
Nauvis.clear_nuke_schedule()
Team.reset_all_forces()
end
if tick % game_duration == 0 then
if tick % required_time_to_win_in_ticks == 0 then
has_the_game_ended()
end
end

View File

@ -266,7 +266,12 @@ end
local function on_chunk_generated(event)
--log("scrap_towny_ffa::on_chunk_generated")
local surface = event.surface
if (surface.name ~= 'nauvis') then
local this = ScenarioTable.get_table()
local map_surface = game.get_surface(this.active_surface_index)
if not map_surface or not map_surface.valid then
return
end
if (surface.name ~= map_surface.name) then
return
end
local seed = surface.map_gen_settings.seed
@ -329,7 +334,11 @@ end
local function on_chunk_charted(event)
local force = event.force
local surface = game.surfaces[event.surface_index]
local this = ScenarioTable.get_table()
local surface = game.get_surface(this.active_surface_index)
if not surface or not surface.valid then
return
end
if force.valid then
if force == game.forces['player'] or force == game.forces['rogue'] then
force.clear_chart(surface)

View File

@ -38,6 +38,7 @@ function Public.reset_table()
this.spaceships = {}
this.suicides = {}
this.required_time_to_win = 48
this.required_time_to_win_in_ticks = 10368000
this.announced_message = nil
this.soft_reset = true
this.winner = nil

View File

@ -532,11 +532,15 @@ function Public.update_town_chart_tags()
end
end
end
local surface = game.get_surface(this.active_surface_index)
if not surface or not surface.valid then
return
end
if game.forces['player'] ~= nil then
game.forces['player'].clear_chart(game.surfaces['nauvis'])
game.forces['player'].clear_chart(surface)
end
if game.forces['rogue'] ~= nil then
game.forces['rogue'].clear_chart(game.surfaces['nauvis'])
game.forces['rogue'].clear_chart(surface)
end
end
@ -680,16 +684,16 @@ local function disable_cluster_grenades(force)
force.recipes['cluster-grenade'].enabled = false
end
local function enable_radar(force)
local function enable_radar(surface, force)
force.recipes['radar'].enabled = true
force.share_chart = true
force.clear_chart('nauvis')
force.clear_chart(surface.name)
end
local function disable_radar(force)
local function disable_radar(surface, force)
force.recipes['radar'].enabled = false
force.share_chart = false
force.clear_chart('nauvis')
force.clear_chart(surface.name)
end
local function disable_achievements(permission_group)
@ -705,6 +709,10 @@ function Public.add_new_force(force_name)
local this = ScenarioTable.get_table()
-- disable permissions
local force = game.create_force(force_name)
local surface = game.get_surface(this.active_surface_index)
if not surface or not surface.valid then
return
end
local permission_group = game.permissions.create_group(force_name)
reset_permissions(permission_group)
enable_blueprints(permission_group)
@ -714,7 +722,7 @@ function Public.add_new_force(force_name)
disable_rockets(force)
disable_nukes(force)
disable_cluster_grenades(force)
enable_radar(force)
enable_radar(surface, force)
disable_achievements(permission_group)
disable_tips_and_tricks(permission_group)
-- friendly fire
@ -858,8 +866,13 @@ local function kill_force(force_name, cause)
end
local function on_forces_merged()
local this = ScenarioTable.get_table()
local map_surface = game.get_surface(this.active_surface_index)
if not map_surface or not map_surface.valid then
return
end
-- Remove any ghosts that have been moved into neutral after a town is destroyed. This caused desyncs before.
for _, e in pairs(game.surfaces.nauvis.find_entities_filtered({force = 'neutral', type = 'entity-ghost'})) do
for _, e in pairs(map_surface.find_entities_filtered({force = 'neutral', type = 'entity-ghost'})) do
if e.valid then
e.destroy()
end
@ -888,6 +901,10 @@ local function setup_player_force()
local force = game.forces.player
local permission_group = game.permissions.create_group('outlander')
-- disable permissions
local surface = game.get_surface(this.active_surface_index)
if not surface or not surface.valid then
return
end
reset_permissions(permission_group)
disable_blueprints(permission_group)
disable_deconstruct(permission_group)
@ -896,7 +913,7 @@ local function setup_player_force()
disable_rockets(force)
disable_nukes(force)
disable_cluster_grenades(force)
disable_radar(force)
disable_radar(surface, force)
disable_achievements(permission_group)
disable_tips_and_tricks(permission_group)
-- disable research
@ -926,6 +943,10 @@ local function setup_rogue_force()
end
local permission_group = game.permissions.create_group('rogue')
-- disable permissions
local surface = game.get_surface(this.active_surface_index)
if not surface or not surface.valid then
return
end
reset_permissions(permission_group)
disable_blueprints(permission_group)
disable_deconstruct(permission_group)
@ -934,7 +955,7 @@ local function setup_rogue_force()
disable_rockets(force)
disable_nukes(force)
disable_cluster_grenades(force)
disable_radar(force)
disable_radar(surface, force)
disable_achievements(permission_group)
disable_tips_and_tricks(permission_group)
-- disable research
@ -1090,7 +1111,12 @@ local function on_post_entity_died(event)
if prototype ~= 'character' then
return
end
local entities = game.surfaces[event.surface_index].find_entities_filtered({position = event.position, radius = 1})
local this = ScenarioTable.get_table()
local surface = game.get_surface(this.active_surface_index)
if not surface or not surface.valid then
return
end
local entities = surface.find_entities_filtered({position = event.position, radius = 1})
for _, e in pairs(entities) do
if e.type == 'character-corpse' then
Public.remove_key(e.character_corpse_player_index)