ammo magazine

This commit is contained in:
Brevven 2023-03-12 04:55:16 -07:00
parent 0e63324488
commit 81361d58dd
14 changed files with 375 additions and 0 deletions

View file

@ -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)

View file

@ -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

View file

@ -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")

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

BIN
graphics/icons/magazine.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.1 KiB

BIN
graphics/icons/magazine.xcf Normal file

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

View file

@ -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__

342
magazine.lua Normal file
View file

@ -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

5
me.lua
View file

@ -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()

13
settings-util.lua Normal file
View file

@ -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

View file

@ -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",