diff --git a/README.md b/README.md index 6078295..4e26678 100644 --- a/README.md +++ b/README.md @@ -11,6 +11,7 @@ See changelog.txt ### Thanks to - [snouz](https://mods.factorio.com/user/snouz) (recolored ore graphics, thumbnail style) +- Krastorio2 team for magazine icons, and some related code in magazine.lua (Licensed under GNU LGPL v3.0) ### Compatibility - [nihilistzsche](https://github.com/nihilistzsche) diff --git a/changelog.txt b/changelog.txt index f0ecd51..f18af40 100644 --- a/changelog.txt +++ b/changelog.txt @@ -2,6 +2,7 @@ Version: 0.7.0 Date: 2023-03-13 Features: + - BETA: New explosive rounds magazine item, optional. (Damage values may change) - New setting to disable the need for zircon in the early game. Changes: - Trees should spawn less often on ore diff --git a/data.lua b/data.lua index 28bbee8..b1674ca 100644 --- a/data.lua +++ b/data.lua @@ -1,6 +1,7 @@ require("zircon") require("zircon-particle") require("zirconium-recipe") +require("magazine") require("zirconium-enriched") -- Enriched for Krastorio 2 require("zirconium-recipe-se") -- Space Exploration special recipes (depends on K2 if present) -- require("zirconium-compressed") diff --git a/graphics/icons/am-magazine.png b/graphics/icons/am-magazine.png new file mode 100644 index 0000000..4d7b01c Binary files /dev/null and b/graphics/icons/am-magazine.png differ diff --git a/graphics/icons/am-magazine.xcf b/graphics/icons/am-magazine.xcf new file mode 100644 index 0000000..dfc601d Binary files /dev/null and b/graphics/icons/am-magazine.xcf differ diff --git a/graphics/icons/magazine.png b/graphics/icons/magazine.png new file mode 100644 index 0000000..5ff55b8 Binary files /dev/null and b/graphics/icons/magazine.png differ diff --git a/graphics/icons/magazine.xcf b/graphics/icons/magazine.xcf new file mode 100644 index 0000000..d7220c6 Binary files /dev/null and b/graphics/icons/magazine.xcf differ diff --git a/graphics/icons/r-magazine.png b/graphics/icons/r-magazine.png new file mode 100644 index 0000000..7eb28f5 Binary files /dev/null and b/graphics/icons/r-magazine.png differ diff --git a/graphics/icons/r-magazine.xcf b/graphics/icons/r-magazine.xcf new file mode 100644 index 0000000..2149e77 Binary files /dev/null and b/graphics/icons/r-magazine.xcf differ diff --git a/locale/en/zirconium.cfg b/locale/en/zirconium.cfg index c86ec95..3541821 100644 --- a/locale/en/zirconium.cfg +++ b/locale/en/zirconium.cfg @@ -15,6 +15,9 @@ compressed-zircon=Compressed zircon cermet=Cermet zirconium-tungstate=Zirconium tungstate zircaloy-4=Zircaloy 4 +explosive-rounds-magazine=Explosive rounds magazine +explosive-rounds-rifle-magazine=Explosive rounds rifle magazine +explosive-rounds-anti-material-rifle-magazine=Explosive rounds anti-materiel rifle magazine [item-description] zircon=Can be smelted into zirconia @@ -62,6 +65,7 @@ bzzirconium-byproduct=Output byproducts bzzirconium-enable-intermediates=Enable cermet bzzirconium-enable-sorting=Enable stone sorting bzzirconium-early=Early zircon +bzzirconium-ammo=Enable magazine [mod-setting-description] bzzirconium-recipe-bypass=Skip modifying these recipes (comma-separated list). @@ -69,6 +73,7 @@ bzzirconium-byproduct=If enabled and using Titanium mod, zirconia production wil bzzirconium-enable-intermediates=Enable cermet, an advanced intermediate made from ceramics and metals. bzzirconium-enable-sorting=Enable "sorting" recipes to convert between zircon and stone. This is no longer as useful for burner phase as it used to be, but left as an option for certain map layouts or existing factories. bzzirconium-early=If [color=green]enabled[\color], zircon is required in small quantities early in the game.\nIf [color=orange]disabled[/color], zircon is not required until after logistic science. +bzzirconium-ammo=If enabled, adds a new explosive ammunition magazine. [string-mod-setting] bzzirconium-enable-intermediates-lds=Yes, and __ITEM__cermet__ in __ITEM__low-density-structure__ bzzirconium-enable-intermediates-yes=Yes, but not in __ITEM__low-density-structure__ diff --git a/magazine.lua b/magazine.lua new file mode 100644 index 0000000..992314c --- /dev/null +++ b/magazine.lua @@ -0,0 +1,342 @@ +local futil = require("util"); +local util = require("data-util"); + +if util.me.ammo() then + local mag = { + {"zirconium-plate", 1}, + } + local ct = 1 + if mods.bztungsten then + table.insert(mag, {"tungsten-carbide", 1}) + ct = ct + 1 + end + -- add any other count-incrementing ingredients before silica, oil, and magazine + if mods.bzsilicon then + table.insert(mag, {"silica", ct}) + end + table.insert(mag, {type="fluid", name="heavy-oil", amount=ct}) + + if not mods.Krastorio2 or not util.get_setting("kr-more-realistic-weapon") then + table.insert(mag, {"piercing-rounds-magazine", ct}) + + data:extend({ + { + type = "ammo", + name = "explosive-rounds-magazine", + icon = "__bzzirconium__/graphics/icons/magazine.png", + icon_size = 64, icon_mipmaps = 4, + ammo_type = + { + category = "bullet", + action = + { + type = "direct", + action_delivery = + { + type = "instant", + source_effects = + { + type = "create-explosion", + entity_name = "explosion-gunshot" + }, + target_effects = + { + { + type = "create-entity", + entity_name = "explosion-hit", + offsets = {{0, 1}}, + offset_deviation = {{-0.5, -0.5}, {0.5, 0.5}} + }, + { + type = "damage", + damage = { amount = 5, type = "physical"} + }, + { + type = "nested-result", + action = + { + type = "area", + radius = 1, + action_delivery = + { + type = "instant", + target_effects = + { + { + type = "damage", + damage = {amount = 4, type = "explosion"} + }, + { + type = "create-entity", + entity_name = "explosion" + } + } + } + } + } + } + } + } + }, + magazine_size = 10, + subgroup = "ammo", + order = "a[basic-clips]-c[explosive-rounds-magazine]", + stack_size = 200 + }, + { + type = "recipe", + name = "explosive-rounds-magazine", + category = "crafting-with-fluid", + enabled = false, + energy_required = 6 * ct, + ingredients = mag, + result = "explosive-rounds-magazine", + result_count = ct, + }, + }) + + else + local k_target_type = "direction" -- "entity", "position" or "direction" + local rifle_range = 30 + if util.get_setting("kr-more-realistic-weapon-auto-aim") then + k_target_type = "entity" -- "entity", "position" or "direction" + rifle_range = 25 + end + + rmag = futil.table.deepcopy(mag) + table.insert(rmag, {"armor-piercing-rifle-magazine", ct}) + ammag = futil.table.deepcopy(mag) + table.insert(ammag, {"armor-piercing-anti-material-rifle-magazine", ct}) + + + data:extend({ + { + type = "ammo", + name = "explosive-rounds-rifle-magazine", + icon = "__bzzirconium__/graphics/icons/r-magazine.png", + icon_size = 64, + icon_mipmaps = 4, + ammo_type = { + category = "bullet", + cooldown_modifier = 0.8, + target_type = k_target_type, + action = { + { + type = "direct", + action_delivery = { + { + type = "projectile", + projectile = "rifle-ammo-ex", + starting_speed = 1.5, + direction_deviation = 0.15, + range_deviation = 0.15, + max_range = rifle_range, + source_effects = { + { + type = "create-explosion", + entity_name = "explosion-gunshot", + }, + }, + }, + }, + }, + }, + }, + magazine_size = 30, + subgroup = "ammo", + order = "a[basic-clips]-a04[rifle-magazine][ex]", + stack_size = 200, + }, + + { + type = "projectile", + name = "rifle-ammo-ex", + flags = { "not-on-map" }, + collision_box = bullets_collision_box, + acceleration = -0.018, + action = { + type = "direct", + action_delivery = { + type = "instant", + target_effects = { + { + type = "create-entity", + entity_name = "explosion-hit", + }, + { + type = "damage", + damage = { amount = 9, type = "physical" }, + }, + { + type = "nested-result", + action = + { + type = "area", + radius = 1.5, + action_delivery = + { + type = "instant", + target_effects = + { + { + type = "damage", + damage = {amount = 7, type = "explosion"} + }, + { + type = "create-entity", + entity_name = "explosion" + } + } + } + } + } + }, + }, + }, + animation = { + filename = util.k2assets() .. "/entities/bullets/rifle-bullet-1.png", + frame_count = 1, + width = 3, + height = 50, + priority = "high", + }, + shadow = { + filename = util.k2assets() .. "/entities/bullets/rifle-bullet-1.png", + frame_count = 1, + width = 3, + height = 50, + priority = "high", + draw_as_shadow = true, + }, + --hit_at_collision_position = true, + force_condition = "not-same", + light = { intensity = 0.45, size = 5, color = { r = 1.0, g = 1.0, b = 0.5 } }, + }, + + { + type = "recipe", + name = "explosive-rounds-rifle-magazine", + category = "crafting-with-fluid", + energy_required = 2.5*ct, + enabled = false, + ingredients = rmag, + result = "explosive-rounds-rifle-magazine", + result_count = ct, + }, + + ------------------------ + { + type = "ammo", + name = "explosive-rounds-anti-material-rifle-magazine", + icon = "__bzzirconium__/graphics/icons/am-magazine.png", + icon_size = 64, + icon_mipmaps = 4, + ammo_type = { + category = "anti-material-rifle-ammo", + target_type = k_target_type, + action = { + { + type = "direct", + action_delivery = { + { + type = "projectile", + projectile = "anti-material-rifle-ammo-ex", + starting_speed = 3, + direction_deviation = 0.02, + range_deviation = 0.02, + max_range = sniper_range, + source_effects = { + { + type = "create-explosion", + entity_name = "explosion-gunshot", + }, + }, + }, + }, + force = "not-same", + }, + }, + }, + magazine_size = 7, + subgroup = "ammo", + order = "a[basic-clips]-a08[anti-material-rifle-magazine][ex]", + stack_size = 200, + }, + + { + type = "projectile", + name = "anti-material-rifle-ammo-ex", + flags = { "not-on-map" }, + collision_box = bullets_collision_box, + acceleration = -0.025, + action = { + type = "direct", + action_delivery = { + type = "instant", + target_effects = { + { + type = "create-entity", + entity_name = "explosion-hit-p", + }, + { + type = "damage", + damage = { amount = 70, type = "physical" }, + }, + { + type = "nested-result", + action = { + type = "area", + radius = 1.5, + action_delivery = { + type = "instant", + target_effects = { + { + type = "damage", + damage = { amount = 70, type = "explosion" }, + }, + }, + }, + force = "not-same", + }, + }, + }, + }, + force = "not-same", + }, + animation = { + filename = util.k2assets() .. "/entities/bullets/anti-material-rifle-bullet-2.png", + frame_count = 1, + width = 3, + height = 50, + priority = "high", + }, + shadow = { + filename = util.k2assets() .. "/entities/bullets/anti-material-rifle-bullet-2.png", + frame_count = 1, + width = 3, + height = 50, + priority = "high", + draw_as_shadow = true, + }, + --hit_at_collision_position = true, + force_condition = "not-same", + light = { intensity = 0.45, size = 8, color = { r = 1.0, g = 0.8, b = 0.5 } }, + }, + + { + type = "recipe", + name = "explosive-rounds-anti-material-rifle-magazine", + category = "crafting-with-fluid", + energy_required = 6*ct, + enabled = false, + ingredients = ammag, + result = "explosive-rounds-anti-material-rifle-magazine", + result_count = ct, + }, + }) + + end + util.add_unlock("military-3", "explosive-rounds-magazine") + util.add_unlock("military-3", "explosive-rounds-rifle-magazine") + util.add_unlock("military-3", "explosive-rounds-anti-material-rifle-magazine") +end diff --git a/me.lua b/me.lua index 59420d9..c05fb35 100644 --- a/me.lua +++ b/me.lua @@ -16,6 +16,11 @@ function me.early() return me.get_setting("bzzirconium-early") end +function me.ammo() + return me.get_setting("bzzirconium-ammo") +end + + function me.use_cermet() if me.get_setting("bz-all-intermediates") then return true end return me.get_setting("bzzirconium-enable-intermediates") == "yes" or me.cermet_lds() diff --git a/settings-util.lua b/settings-util.lua new file mode 100644 index 0000000..5c3f13c --- /dev/null +++ b/settings-util.lua @@ -0,0 +1,13 @@ +-- WARNING WARNING WARNING +-- This file will be overwritten in mod zipfiles, edit bzlib/settings-util.lua +-- WARNING WARNING WARNING + +local util = {} + +function util.set_default_value(t, name, default) + if data.raw[t] and data.raw[t][name] then + data.raw[t][name].default_value = default + end +end + +return util diff --git a/settings.lua b/settings.lua index 5fb83a0..46fb122 100644 --- a/settings.lua +++ b/settings.lua @@ -29,6 +29,13 @@ data:extend({ default_value = true, order = "c-a-a", }, + { + type = "bool-setting", + name = "bzzirconium-ammo", + setting_type = "startup", + default_value = true, + order = "d-a-a", + }, { type = "bool-setting", name = "bzzirconium-enable-sorting",