diff --git a/angelsexploration/changelog.txt b/angelsexploration/changelog.txt index 0c59a5f3c..4a7201db3 100644 --- a/angelsexploration/changelog.txt +++ b/angelsexploration/changelog.txt @@ -1,4 +1,15 @@ --------------------------------------------------------------------------------------------------- +Version: 0.3.13 +Date: 23.12.2021 + Bugfixes: + - Fixed crash when the bob enemies do not drop artifacts (setting disabled) + - Fixed crash when there are too many types of spawners or biters/spawner (737) + - Fixed crash when a spawner spawns something else than a unit (737) + - Fixed gathering turrets would remain idle after they all deactivated + - Fixed incorrect tips and tricks information when bob enemies do not drop artifacts + - Fixed crash when tips and tricks localisation would be too long + - Fixed crash when AAI is processing configuration changes when exploration is not initialized +--------------------------------------------------------------------------------------------------- Version: 0.3.12 Date: 19.12.2021 Changes: diff --git a/angelsexploration/info.json b/angelsexploration/info.json index 3c2bac9a4..a7ebdc937 100644 --- a/angelsexploration/info.json +++ b/angelsexploration/info.json @@ -1,6 +1,6 @@ { "name": "angelsexploration", - "version": "0.3.12", + "version": "0.3.13", "factorio_version": "1.1", "title": "Angel's Exploration (BETA)", "author": "Arch666Angel", diff --git a/angelsexploration/prototypes/entities/biter-builder.lua b/angelsexploration/prototypes/entities/biter-builder.lua index efa59f3cb..dd61be551 100644 --- a/angelsexploration/prototypes/entities/biter-builder.lua +++ b/angelsexploration/prototypes/entities/biter-builder.lua @@ -1088,7 +1088,12 @@ function angelsmods.functions.compile_alien_data() -- creates an overview of the for _,spawner in pairs(data.raw["unit-spawner"]) do spawners[spawner.name] = {} for _,spawn in pairs(spawner.result_units) do - spawners[spawner.name][spawn.unit or spawn[1]] = combine_spawn_data(spawners[spawner.name][spawn.unit or spawn[1]], calculate_spawn_data(spawn.spawn_points or spawn[2])) + local spawn_name = spawn.unit or spawn[1] + if data.raw['unit'][spawn_name] then + spawners[spawner.name][spawn_name] = combine_spawn_data(spawners[spawner.name][spawn_name], calculate_spawn_data(spawn.spawn_points or spawn[2])) + else + --log(spawn_name) + end end end diff --git a/angelsexploration/prototypes/entities/gathering-turret.lua b/angelsexploration/prototypes/entities/gathering-turret.lua index dba2ce1e4..a485efc43 100644 --- a/angelsexploration/prototypes/entities/gathering-turret.lua +++ b/angelsexploration/prototypes/entities/gathering-turret.lua @@ -53,6 +53,12 @@ data:extend( offsets = {{0, 1}}, damage_type_filters = "fire" }, + trigger_target_mask = + { + "common", + "ground-unit", + "angels_gathering_turret_start_collecting_trigger" + }, open_sound = sounds.machine_open, close_sound = sounds.machine_close, diff --git a/angelsexploration/prototypes/overrides/biter-updates.lua b/angelsexploration/prototypes/overrides/biter-updates.lua index fb73d53df..2d5ac973e 100644 --- a/angelsexploration/prototypes/overrides/biter-updates.lua +++ b/angelsexploration/prototypes/overrides/biter-updates.lua @@ -119,7 +119,7 @@ if mods["bobenemies"] then for _, biter in pairs({"behemoth-biter", "behemoth-spitter"}) do local unit = data.raw.unit[biter] if biter then - for _,loot in pairs(unit.loot) do + for _,loot in pairs(unit.loot or {}) do if loot.item == "small-alien-artifact" then loot.count_min = ((loot.count_min == nil and 1) or loot.count_min) / 4 -- 4 -> 1 loot.count_max = ((loot.count_max == nil and 1) or loot.count_max) / 4 -- 12 -> 3 diff --git a/angelsexploration/prototypes/tips-and-tricks/1-2-native-inhabitants/1-2-native-inhabitants-functions.lua b/angelsexploration/prototypes/tips-and-tricks/1-2-native-inhabitants/1-2-native-inhabitants-functions.lua deleted file mode 100644 index 9cf66f79e..000000000 --- a/angelsexploration/prototypes/tips-and-tricks/1-2-native-inhabitants/1-2-native-inhabitants-functions.lua +++ /dev/null @@ -1,157 +0,0 @@ -local generate_spawner_data = function() - -- map biter spawn range on each spawner - local spawners = {} - local calculate_spawn_data = function(raw_spawn_points) - local spawn_points = {} - for _,spawn_point in pairs(raw_spawn_points) do -- convert indices to numbers - table.insert(spawn_points, util.table.deepcopy(spawn_point)) - end - - local _,first_spawn_point = next(spawn_points) - if (first_spawn_point.evolution_factor or first_spawn_point[1]) ~= 0 and - (first_spawn_point.spawn_weight or first_spawn_point[2]) ~= 0 then - table.insert(spawn_points, 1, {0,0}) -- insert start spawn point (if needed) - end - - local res = {} -- look for spawn ranges (=wanted data) - for spawn_idx,spawn_point in pairs(spawn_points) do - if ((#res)%2) == 0 then -- looking for a weight > 0 - if (spawn_point.spawn_weight or spawn_point[2]) ~= 0 then - if spawn_idx == 1 then - table.insert(res, 0) -- spawns from the start - else - table.insert(res, spawn_points[spawn_idx-1].evolution_factor or spawn_points[spawn_idx-1][1]) - end - end - else -- looking for a weight == 0 - table.insert(res, spawn_point.evolution_factor or spawn_point[1]) - end - end - - return ((#res)>0) and res or nil -- return the result (if any) - end - local combine_spawn_data = function(spawn_data_1, spawn_data_2) - if spawn_data_1 == nil then return spawn_data_2 end - if spawn_data_2 == nil then return spawn_data_1 end - log("TODO!!!") - return spawn_data_1 - end - for _,spawner in pairs(data.raw["unit-spawner"]) do - spawners[spawner.name] = {} - for _,spawn in pairs(spawner.result_units) do - spawners[spawner.name][spawn.unit or spawn[1]] = combine_spawn_data(spawners[spawner.name][spawn.unit or spawn[1]], calculate_spawn_data(spawn.spawn_points or spawn[2])) - end - end - - -- map units to single spawner (=earliest) - local units = {} - for spawner,spawner_data in pairs(spawners) do - for unit,spawn_data in pairs(spawner_data) do - units[unit] = units[unit] or {} - units[unit][spawner] = spawn_data[1] -- first point this unit is spawning - end - end - for unit,spawn_data in pairs(units) do - local lowest_evo_factor = 2 - for spawner,evo_factor in pairs(spawn_data) do - if evo_factor < lowest_evo_factor then - lowest_evo_factor = evo_factor - end - end - if lowest_evo_factor > 1 then - lowest_evo_factor = -lowest_evo_factor - end - local spawners_to_remove = {} - local highest_evo_factor_2 = 0 - for spawner,evo_factor in pairs(spawn_data) do - if evo_factor == lowest_evo_factor then - local evo_factor_2 = (#spawners[spawner][unit]) > 1 and spawners[spawner][unit][2] or 1 - if evo_factor_2 > highest_evo_factor_2 then - highest_evo_factor_2 = evo_factor_2 - end - else - table.insert(spawners_to_remove, spawner) - end - end - local picked = false - for spawner,evo_factor in pairs(spawn_data) do - if evo_factor == lowest_evo_factor then - local evo_factor_2 = (#spawners[spawner][unit]) > 1 and spawners[spawner][unit][2] or 1 - if evo_factor_2 < highest_evo_factor_2 or picked then - table.insert(spawners_to_remove, spawner) - else - picked = true -- picking the first if multiple spawners are 'equal' - end - end - end - for _,spawner_to_remove in pairs(spawners_to_remove) do - units[unit][spawner_to_remove] = nil - end - end - - -- map all units to the spawner they are assigned to - spawners = {} - for unit,unit_data in pairs(units) do - for spawner,evo_factor in pairs(unit_data) do - spawners[spawner] = spawners[spawner] or {} - spawners[spawner][unit] = evo_factor - end - end - - -- order biters in rising evolution factor for each spawner - local order_units - order_units = function(units) - local highest_evo_factor = -1 - for _,evo_factor in pairs(units) do - if evo_factor > highest_evo_factor then - highest_evo_factor = evo_factor - end - end - if highest_evo_factor < 0 then return units end -- recursion end - local ordered_units = util.table.deepcopy(units) - for unit,evo_factor in pairs(ordered_units) do - if evo_factor == highest_evo_factor then - ordered_units[unit] = nil - ordered_units = order_units(ordered_units) -- recursion - table.insert(ordered_units, {[unit]=evo_factor}) - return ordered_units - end - end - end - for spawner,unit_data in pairs(spawners) do - spawners[spawner] = order_units(unit_data) - end - - -- order spawners in rising evolution factor in unique biter spawns - local order_spawners - order_spawners = function(spawners) - local highest_evo_factor = -1 - for _,spawner_data in pairs(spawners) do - local _,evo_factor = next(spawner_data[1]) - if evo_factor > highest_evo_factor then - highest_evo_factor = evo_factor - end - end - if highest_evo_factor < 0 then return spawners end -- recursion end - local ordered_spawners = util.table.deepcopy(spawners) - for spawner,spawner_data in pairs(ordered_spawners) do - local _,evo_factor = next(spawner_data[1]) - if evo_factor == highest_evo_factor then - ordered_spawners[spawner] = nil - ordered_spawners = order_spawners(ordered_spawners) -- recursion - table.insert(ordered_spawners, {[spawner]=util.table.deepcopy(spawner_data)}) - return ordered_spawners - end - end - end - return order_spawners(spawners) -end - -local num_to_char = function(num) - return string.char(string.byte("a")+num-1) -end - -return { - ["generate_spawner_data"] = generate_spawner_data, - ["num_to_char"] = num_to_char -} diff --git a/angelsexploration/prototypes/tips-and-tricks/1-2-x-native-houses/1-2-x-native-houses-description.lua b/angelsexploration/prototypes/tips-and-tricks/1-2-x-native-houses/1-2-x-native-houses-description.lua index 4c187c0f9..3a987fd25 100644 --- a/angelsexploration/prototypes/tips-and-tricks/1-2-x-native-houses/1-2-x-native-houses-description.lua +++ b/angelsexploration/prototypes/tips-and-tricks/1-2-x-native-houses/1-2-x-native-houses-description.lua @@ -1,5 +1,21 @@ local tnt = angelsmods.functions.TNT +local function compress_localised_string(localised_string) + if type(localised_string)~='table' or localised_string[1]~="" then return localised_string end + local compressed_localised_string = {""} + for idx=2,#localised_string,19 do + local compressed_string_section = {""} + for i=idx,math.min(#localised_string, idx+19) do + table.insert(compressed_string_section, util.table.deepcopy(localised_string[i])) + end + table.insert(compressed_localised_string, compressed_string_section) + end + if #compressed_localised_string>20 then + return compress_localised_string(compressed_localised_string) + end + return compressed_localised_string +end + return function(spawner_name, spawn_data) local spawner = data.raw["unit-spawner"][spawner_name] if not spawner then return "Unknown entity '"..(spawner_name or 'nil').."'." end @@ -26,11 +42,11 @@ return function(spawner_name, spawn_data) table.insert(spawn_description, spawn_unit) end end - table.insert(description, spawn_description) + table.insert(description, compress_localised_string(spawn_description)) -- LOOT INFO local loot = spawner.loot - if loot then + if loot and (#loot>0) then local loot_description = {"", {"tips-and-tricks-description.angels-native-inhabitants-spawner-loot"}} for _,drop in pairs(loot) do local min = tnt.number_to_string(drop.count_min or 1) @@ -64,7 +80,7 @@ return function(spawner_name, spawn_data) table.insert(drop_description, (data.raw.item[drop.item] or {}).localised_name or {"tips-and-tricks-description.angels-native-inhabitants-spawner-loot-item-name", "__ITEM__"..drop.item.."__"}) table.insert(loot_description, drop_description) end - table.insert(description, loot_description) + table.insert(description, compress_localised_string(loot_description)) end return description diff --git a/angelsexploration/prototypes/tips-and-tricks/1-2-x-native-houses/1-2-x-native-houses.lua b/angelsexploration/prototypes/tips-and-tricks/1-2-x-native-houses/1-2-x-native-houses.lua index c8f83df97..d1e63cead 100644 --- a/angelsexploration/prototypes/tips-and-tricks/1-2-x-native-houses/1-2-x-native-houses.lua +++ b/angelsexploration/prototypes/tips-and-tricks/1-2-x-native-houses/1-2-x-native-houses.lua @@ -2,7 +2,7 @@ local create_description = require "prototypes.tips-and-tricks.1-2-x-native-hous local navive_data = angelsmods.functions.compile_alien_data() for spawner_idx, spawner_data in pairs(navive_data) do - local spawner_char = string.char(string.byte("a")+spawner_idx-1) + local spawner_char = string.char(string.byte("a")+math.floor(spawner_idx/26)) .. string.char(string.byte("a")+(spawner_idx%26)-1) local spawner_name, spawn_data = next(spawner_data) data:extend( { diff --git a/angelsexploration/prototypes/tips-and-tricks/1-2-x-x-native-aliens/1-2-x-x-native-aliens-description.lua b/angelsexploration/prototypes/tips-and-tricks/1-2-x-x-native-aliens/1-2-x-x-native-aliens-description.lua index 6a9bbba7f..f65dc60fd 100644 --- a/angelsexploration/prototypes/tips-and-tricks/1-2-x-x-native-aliens/1-2-x-x-native-aliens-description.lua +++ b/angelsexploration/prototypes/tips-and-tricks/1-2-x-x-native-aliens/1-2-x-x-native-aliens-description.lua @@ -1,5 +1,21 @@ local tnt = angelsmods.functions.TNT +local function compress_localised_string(localised_string) + if type(localised_string)~='table' or localised_string[1]~="" then return localised_string end + local compressed_localised_string = {""} + for idx=2,#localised_string,19 do + local compressed_string_section = {""} + for i=idx,math.min(#localised_string, idx+19) do + table.insert(compressed_string_section, util.table.deepcopy(localised_string[i])) + end + table.insert(compressed_localised_string, compressed_string_section) + end + if #compressed_localised_string>20 then + return compress_localised_string(compressed_localised_string) + end + return compressed_localised_string +end + local deals_area_damage = function(attack_parameters) -- checks if these attack parameters deal damange in an area around the target return true -- TODO @@ -35,7 +51,7 @@ return function(spawner_name, unit_name, evolution_factor) -- LOOT INFO local loot = unit.loot - if loot then + if loot and (#loot>0) then local loot_description = {"", {"tips-and-tricks-description.angels-native-inhabitants-unit-loot"}} for _,drop in pairs(loot) do local min = tnt.number_to_string(drop.count_min or 1) @@ -67,7 +83,7 @@ return function(spawner_name, unit_name, evolution_factor) end table.insert(drop_description, "[img=item."..drop.item.."]") table.insert(drop_description, (data.raw.item[drop.item] or {}).localised_name or {"tips-and-tricks-description.angels-native-inhabitants-unit-loot-item-name", "__ITEM__"..drop.item.."__"}) - table.insert(loot_description, drop_description) + table.insert(loot_description, compress_localised_string(drop_description)) end table.insert(description, loot_description) end diff --git a/angelsexploration/prototypes/tips-and-tricks/1-2-x-x-native-aliens/1-2-x-x-native-aliens.lua b/angelsexploration/prototypes/tips-and-tricks/1-2-x-x-native-aliens/1-2-x-x-native-aliens.lua index 66fac223f..7b6120cca 100644 --- a/angelsexploration/prototypes/tips-and-tricks/1-2-x-x-native-aliens/1-2-x-x-native-aliens.lua +++ b/angelsexploration/prototypes/tips-and-tricks/1-2-x-x-native-aliens/1-2-x-x-native-aliens.lua @@ -2,10 +2,10 @@ local create_description = require "prototypes.tips-and-tricks.1-2-x-x-native-al local navive_data = angelsmods.functions.compile_alien_data() for spawner_idx, spawner_data in pairs(navive_data) do - local spawner_char = string.char(string.byte("a")+spawner_idx-1) + local spawner_char = string.char(string.byte("a")+math.floor(spawner_idx/26)) .. string.char(string.byte("a")+(spawner_idx%26)-1) local spawner_name, spawn_data = next(spawner_data) for unit_idx, unit_data in pairs(spawn_data) do - local unit_char = string.char(string.byte("a")+unit_idx-1) + local unit_char = string.char(string.byte("a")+math.floor(unit_idx/26)) .. string.char(string.byte("a")+(unit_idx%26)-1) local unit_name, evolution_factor = next(unit_data) data:extend( { diff --git a/angelsexploration/src/gathering-turret.lua b/angelsexploration/src/gathering-turret.lua index 90c4d6866..4d71241f9 100644 --- a/angelsexploration/src/gathering-turret.lua +++ b/angelsexploration/src/gathering-turret.lua @@ -68,12 +68,14 @@ function gathering_turret:init_force_data(force_name) return force_whitelist end - global.GT_data.force_data[force_name] = - { - ["turret_range"] = self:get_gathering_radius(), -- the actual gathering range of the turret - ["turret_speed"] = self:get_gathering_speed(), -- the actual gathering speed (tiles/s) of this turret - ["turret_whitelist"] = create_whitelist_for_force(), -- the list of items whitelisted to be collected - } + if global.GT_data and global.GT_data.force_data then + global.GT_data.force_data[force_name] = + { + ["turret_range"] = self:get_gathering_radius(), -- the actual gathering range of the turret + ["turret_speed"] = self:get_gathering_speed(), -- the actual gathering speed (tiles/s) of this turret + ["turret_whitelist"] = create_whitelist_for_force(), -- the list of items whitelisted to be collected + } + end end @@ -422,7 +424,7 @@ end function gathering_turret:update_gathering_target_whitelist(force_name, technology_name, allow_gathering) -- This function updates the gathering whitelist depending on which items are researched - local force_data = global.GT_data.force_data[force_name] + local force_data = global.GT_data and global.GT_data.force_data and global.GT_data.force_data[force_name] if force_data then local gathering_items = self:get_whitelisted_gathering_items() local force_whitelist = force_data["turret_whitelist"] diff --git a/angelsexploration/src/tips-and-tricks-triggers.lua b/angelsexploration/src/tips-and-tricks-triggers.lua index 08b99504b..0dc597811 100644 --- a/angelsexploration/src/tips-and-tricks-triggers.lua +++ b/angelsexploration/src/tips-and-tricks-triggers.lua @@ -65,7 +65,7 @@ end -- Setter functions to alter data into the data structure ------------------------------------------------------------------------------- function tips_and_tricks_triggers:remove_trigger(force_name, trigger_name) - if force_name and global.TNT_data.force_data[force_name] then + if force_name and global.TNT_data and global.TNT_data.force_data[force_name] then local force_triggers = global.TNT_data.force_data[force_name]["trigger_data"] local triggers_to_remove = {} for trigger_key,trigger_value in pairs(force_triggers) do