Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/foxcapades/vsmod-thrifty-smithing
Thrifty Smithing mod for the game Vintage Story
https://github.com/foxcapades/vsmod-thrifty-smithing
game mod smithing vintage-story vintagestory vintagestory-mod
Last synced: 9 days ago
JSON representation
Thrifty Smithing mod for the game Vintage Story
- Host: GitHub
- URL: https://github.com/foxcapades/vsmod-thrifty-smithing
- Owner: Foxcapades
- License: mit
- Created: 2024-08-21T13:27:01.000Z (3 months ago)
- Default Branch: main
- Last Pushed: 2024-10-25T00:58:30.000Z (12 days ago)
- Last Synced: 2024-10-25T20:19:43.930Z (11 days ago)
- Topics: game, mod, smithing, vintage-story, vintagestory, vintagestory-mod
- Language: C#
- Homepage: https://mods.vintagestory.at/thriftysmithing
- Size: 160 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: readme.adoc
- License: license
Awesome Lists containing this project
README
= image:assets/icons/icon-32.png[] Thrifty Smithing
:source-highlighter: highlightjs
:vs-url: https://www.vintagestory.at/A link:{vs-url}[VintageStory] mod to recover scrap metal from the smithing
process that would have otherwise gone to waste.image:https://img.shields.io/github/v/tag/Foxcapades/vsmod-thrifty-smithing?label=version[GitHub Tag]
image:https://img.shields.io/badge/VS-v1.19%2B-rebeccapurple[title="Vintage Story v1.19+", link={vs-url}]
image:https://img.shields.io/github/license/Foxcapades/vsmod-thrifty-smithing[GitHub License]Once a smithing work is completed, the player who completed it will be given the
amount of whole bits that could be formed from the material removed from the
work while it was being crafted.If a smithing work is completed by a helve hammer, the scrap bits will be
dropped to the floor at the base of the anvil.== Configuration
The following configuration options are provided in the `thrifty-smithing.json`
file, with default values based on the base VintageStory experience. Most of
these should not be changed unless necessitated by changes from other mods.[source, json]
----
{
"voxelsPerIngot": 42,
"voxelsPerPlate": 81,
"materialUnitsPerIngot": 100,
"materialUnitsPerBit": 5,
"materialUnitsRecoveredModifier": 1.0,
"disallowedRecipes": []
}
----[%header, cols="2m,2a,6a"]
|===
| Option | Type | Description| voxelsPerIngot
| `int`
| The number of voxels a single ingot should be worth.Valid value range: `[1..255]`
| voxelsPerPlate
| `int`
| The number of voxels a single metal plate should be worth.Valid value range: `[1..255]`
| materialUnitsPerIngot
| `int`
| The amount of material required to craft an ingot.Valid value range: `[1..65535]`
| materialUnitsPerBit
| `int`
| The amount of material represented by a single metal bit.Valid value range: `[1..255]`
| materialUnitsRecoveredModifier
| `float`
| Percentage multiplier used to modify the amount of scrap material returned on
completion of a smithing work.The default value of `1.0` represents `100%`, a value of `0.75` would represent
`75%`, `0.5` for `50%` and so on.Valid value range: `[0.0..1.0]` (max precision of ~4 digits)
| disallowedRecipes
| array of `string`
| Asset locations for recipes that should not reward any scrap on completion.For example setting this to `["game:knifeblade-copper"]` would mean that players
are not given any scrap metal back when crafting a copper knife blade.
|===== Extending / Augmenting Thrifty Smithing
ThriftySmithing currently offers a limited mechanism through which other mods
may alter the inputs used by ThriftySmithing to calculate metal bits returned as
scrap after smithing an item.ThriftySmithing looks for `ITreeAttribute` instances in an anvil's work item
(`BlockEntityAnvil.WorkItemStack`) attributes whose names are prefixed with the
string `ef:ts:workData:`. These `ITreeAttribute` instances may contain
sub-attributes integer values under the keys `voxels`, `ingots`, and/or `plates`
which may contain positive or negative values that will be applied to the scrap
bit calculation..Example Extension
[source, csharp]
----
// Add a bunch of extra voxels to the scrap bit calculation
void SetThriftySmithingVoxels(BlockEntityAnvil anvil)
{
anvil.WorkItemStack.Attributes["ef:ts:workData:myMod"] = new TreeAttribute
{
["voxels"] = new IntAttribute(36),
}
}
----.Type Spec
--
.Root Level
[%header, cols="3m,3m,6"]
|===
| Key | Type | Notes| ef:ts:workData:*
| ITreeAttribute
| A tree attribute that may contain the sub attributes `voxels`, `ingots`,
`plates`.
|===.Sub Attributes
[%header, cols="3m,3m,6"]
|===
| Key | Type | Notes| voxels
| IntAttribute
| A positive or negative value in the range `[-128..127]` that may be provided
to add or subtract from the scrap voxels for a smithing recipe.| ingots
| IntAttribute
| A positive or negative value in the range `[-128..127]` that may be provided
to add or subtract from the count of input ingots for a smithing recipe.| plates
| IntAttribute
| A positive or negative value in the range `[-128..127]` that may be provided
to add or subtract from the count of input metal plates for a smithing recipe.
|===
--== Compatibility
* Thrifty Smithing _should_ be compatible with mod-based smithing recipes that
use base game materials.
* Thrifty Smithing _may_ be compatible with mod-based metals, assuming they
provide metal bit items with asset locations matching the base game's
`metalbit-\{material}` scheme.
* Thrifty Smithing is _probably not_ compatible with mods that overhaul or make
significant changes to the smithing system, especially with regard to anvils.
* Thrifty Smithing is _not_ compatible with mods that allow smithing items
without the use of anvils at all (it shouldn't cause a problem, it just won't
give back scrap without an anvil).=== Known Compatibilities
[cols="1,3,6"]
|===
| :green_heart: | https://mods.vintagestory.at/knapster[Knapster v2.x.x] | No issue!
| :green_heart: | https://mods.vintagestory.at/ancientarmory[Ancient Armory v1.x.x] | Works fine!
| :space_invader: | https://mods.vintagestory.at/amr[Anvil Metal Recovery] | Might work but seems silly.
|===== How it Works
=== Calculation
ifdef::env-github[]
++++
++++
endif::[]ifndef::env-github[]
image::docs/assets/scrap-calc-1.png[align="center"]
endif::[]* `Mi` : material per ingot
* `Mb` : material per metal bit
* `Vg` : voxels granted per ingot
* `Vi` : voxels input into the recipe
* `Vr` : voxels required by the recipe=== Explanation
In base VintageStory it takes 100 units of metal to create an ingot
(`Mi = 100`). One ingot, when placed on an anvil, grants 42 workable voxels
(`Vg = 42`). This gives us a material to voxel ratio of 100:42 which means
roughly 2.38095 units of material per voxel.The returned scrap is measured in whole metal bits, each of which is worth 5
units of material (`Mb = 5`). Partial bits are not recovered, meaning there is
still some material loss.The amount of scrap metal recovered after a work is equal to the number of
voxels removed during the crafting process (`Vi - Vr`) multiplied by the
material-per-voxel value divided by the amount of material per bit then rounded
down to the nearest whole number.ifdef::env-github[]
++++
++++
endif::[]ifndef::env-github[]
image::docs/assets/scrap-calc-2.png[align="center"]
endif::[]As an example we can use a knife blade. A knife blade requires 17 voxels to
complete (`Vr = 17`). Assuming the player placed an ingot instead of a metal
plate, that would mean 42 voxels went onto the anvil (`Vi = 42`). 42 input
voxels minus 17 required voxels leaves 25 voxels of scrap metal. 25 voxels
would be worth ~59.5 units of metal, which when divided into bits would give 11
whole bits that can be returned to the player and 0.9 bits
(~4.5 units of material) lost.ifdef::env-github[]
++++
++++
endif::[]ifndef::env-github[]
image::docs/assets/scrap-calc-3.png[align="center"]
endif::[]== Credits
* https://www.freepik.com/icon/anvil_1198980[Anvil Icon from Freepik]