diff --git a/data/json/items/fake.json b/data/json/items/fake.json index d45514fdc9d2..7fe222ea68d6 100644 --- a/data/json/items/fake.json +++ b/data/json/items/fake.json @@ -63,7 +63,7 @@ "to_hit": 2, "cutting": 8, "techniques": "PRECISE", - "flags": [ "TRADER_AVOID", "NO_DROP", "UNBREAKABLE_MELEE", "SPEAR" ], + "flags": [ "TRADER_AVOID", "NO_DROP", "UNBREAKABLE_MELEE", "STAB" ], "qualities": [ [ "CUT", 1 ], [ "CUT_FINE", 5 ], [ "BUTCHER", 50 ] ] }, { diff --git a/data/json/items/melee/bludgeons.json b/data/json/items/melee/bludgeons.json index 504d63eedffd..455b620f57a1 100644 --- a/data/json/items/melee/bludgeons.json +++ b/data/json/items/melee/bludgeons.json @@ -469,7 +469,7 @@ "description": "This is a versatile polearm with a spiked hammer head, a spike, and a hook attached to a long stick.", "price": "500 USD", "material": [ "wood", "steel" ], - "flags": [ "DURABLE_MELEE", "REACH_ATTACK", "NONCONDUCTIVE", "POLEARM", "SHEATH_SPEAR", "SPEAR", "ALWAYS_TWOHAND" ], + "flags": [ "DURABLE_MELEE", "REACH_ATTACK", "NONCONDUCTIVE", "POLEARM", "SHEATH_SPEAR", "SPEAR", "ALWAYS_TWOHAND", "STAB" ], "techniques": [ "WBLOCK_1", "WIDE", "SWEEP" ], "weight": "3200 g", "volume": "3750 ml", @@ -488,7 +488,7 @@ "price": "40 USD", "price_postapoc": "5 USD", "material": [ "wood", "aluminum" ], - "flags": [ "REACH_ATTACK", "NONCONDUCTIVE", "POLEARM", "SHEATH_SPEAR", "SPEAR", "ALWAYS_TWOHAND", "FRAGILE_MELEE" ], + "flags": [ "REACH_ATTACK", "NONCONDUCTIVE", "POLEARM", "SHEATH_SPEAR", "SPEAR", "ALWAYS_TWOHAND", "FRAGILE_MELEE", "STAB" ], "techniques": [ "WBLOCK_1", "SWEEP" ], "weight": "2700 g", "volume": "3750 ml", @@ -601,7 +601,7 @@ "volume": "1500 ml", "bashing": 38, "cutting": 6, - "flags": [ "DURABLE_MELEE", "SPEAR", "NONCONDUCTIVE" ], + "flags": [ "DURABLE_MELEE", "STAB", "NONCONDUCTIVE" ], "price": "1200 USD", "price_postapoc": "80 USD", "qualities": [ [ "HAMMER", 1 ] ] @@ -617,7 +617,7 @@ "material": [ "budget_steel", "wood" ], "bashing": 26, "cutting": 1, - "flags": [ "SPEAR", "NONCONDUCTIVE" ], + "flags": [ "STAB", "NONCONDUCTIVE" ], "price": "120 USD", "price_postapoc": "10 USD" }, @@ -632,7 +632,7 @@ "material": [ "aluminum", "wood" ], "bashing": 26, "cutting": 1, - "flags": [ "SPEAR", "NONCONDUCTIVE", "FRAGILE_MELEE" ], + "flags": [ "STAB", "NONCONDUCTIVE", "FRAGILE_MELEE" ], "price": "120 USD", "price_postapoc": "5 USD", "qualities": [ ] @@ -902,7 +902,7 @@ "//": "Craftable from steel, shouldn't be silver. A warhammer is essentially one end of a pickaxe with balancing weight on the other and crushes/pierces the armor.", "material": [ "iron", "wood" ], "techniques": [ "WBLOCK_1", "BRUTAL", "SWEEP" ], - "flags": [ "DURABLE_MELEE", "SPEAR", "NONCONDUCTIVE", "BELT_CLIP" ], + "flags": [ "DURABLE_MELEE", "STAB", "NONCONDUCTIVE", "BELT_CLIP" ], "volume": "1250 ml", "bashing": 22, "cutting": 23, diff --git a/data/json/items/melee/spears_and_polearms.json b/data/json/items/melee/spears_and_polearms.json index db9621ba68da..c66827f22e26 100644 --- a/data/json/items/melee/spears_and_polearms.json +++ b/data/json/items/melee/spears_and_polearms.json @@ -15,7 +15,7 @@ "bashing": 5, "cutting": 23, "qualities": [ [ "COOK", 1 ] ], - "flags": [ "SPEAR", "REACH_ATTACK", "NONCONDUCTIVE", "SHEATH_SPEAR" ], + "flags": [ "SPEAR", "REACH_ATTACK", "NONCONDUCTIVE", "SHEATH_SPEAR", "STAB" ], "price": "20 USD", "price_postapoc": "5 USD" }, @@ -34,7 +34,7 @@ "bashing": 5, "cutting": 11, "price_postapoc": "10 cent", - "flags": [ "SPEAR" ], + "flags": [ "STAB" ], "techniques": [ "WBLOCK_1" ], "qualities": [ [ "COOK", 1 ] ] }, @@ -69,7 +69,7 @@ "volume": "1250 ml", "bashing": 4, "cutting": 13, - "flags": [ "SPEAR", "REACH_ATTACK", "NPC_THROWN", "SHEATH_SPEAR" ], + "flags": [ "SPEAR", "REACH_ATTACK", "NPC_THROWN", "SHEATH_SPEAR", "STAB" ], "price": "40 USD", "qualities": [ [ "COOK", 1 ] ] }, @@ -91,7 +91,7 @@ "color": "brown", "techniques": "WBLOCK_1", "qualities": [ [ "COOK", 1 ] ], - "flags": [ "SPEAR", "REACH_ATTACK", "NONCONDUCTIVE", "SHEATH_SPEAR" ] + "flags": [ "SPEAR", "REACH_ATTACK", "NONCONDUCTIVE", "SHEATH_SPEAR", "STAB" ] }, { "id": "spear_knife", @@ -112,7 +112,7 @@ "color": "brown", "techniques": "WBLOCK_1", "qualities": [ [ "CUT", 1 ], [ "COOK", 1 ] ], - "flags": [ "SPEAR", "REACH_ATTACK", "NONCONDUCTIVE", "SHEATH_SPEAR" ] + "flags": [ "SPEAR", "REACH_ATTACK", "NONCONDUCTIVE", "SHEATH_SPEAR", "STAB" ] }, { "id": "spear_knife_superior", @@ -141,7 +141,7 @@ "symbol": "/", "color": "brown", "qualities": [ [ "COOK", 1 ] ], - "flags": [ "SPEAR", "REACH_ATTACK", "NONCONDUCTIVE", "SHEATH_SPEAR" ] + "flags": [ "SPEAR", "REACH_ATTACK", "NONCONDUCTIVE", "SHEATH_SPEAR", "STAB" ] }, { "id": "spear_forked", @@ -159,7 +159,7 @@ "volume": "1500 ml", "bashing": 6, "cutting": 18, - "flags": [ "SPEAR", "REACH_ATTACK", "NONCONDUCTIVE", "SHEATH_SPEAR" ], + "flags": [ "SPEAR", "REACH_ATTACK", "NONCONDUCTIVE", "SHEATH_SPEAR", "STAB" ], "price": "49 USD", "qualities": [ [ "COOK", 1 ] ] }, @@ -181,7 +181,7 @@ "to_hit": -1, "bashing": 6, "cutting": 25, - "flags": [ "SPEAR", "REACH_ATTACK", "SHEATH_SPEAR" ], + "flags": [ "SPEAR", "REACH_ATTACK", "SHEATH_SPEAR", "STAB" ], "qualities": [ [ "COOK", 1 ] ] }, { @@ -199,7 +199,7 @@ "techniques": [ "WBLOCK_1", "IMPALE" ], "to_hit": 1, "cutting": 20, - "flags": [ "SPEAR", "REACH_ATTACK", "NONCONDUCTIVE", "SHEATH_SPEAR" ], + "flags": [ "SPEAR", "REACH_ATTACK", "NONCONDUCTIVE", "SHEATH_SPEAR", "STAB" ], "qualities": [ [ "COOK", 1 ] ] }, { @@ -215,7 +215,7 @@ "material": [ "steel", "wood" ], "to_hit": 1, "cutting": 30, - "flags": [ "DURABLE_MELEE", "SPEAR", "REACH_ATTACK", "NONCONDUCTIVE", "SHEATH_SPEAR" ] + "flags": [ "DURABLE_MELEE", "SPEAR", "REACH_ATTACK", "NONCONDUCTIVE", "SHEATH_SPEAR", "STAB" ] }, { "id": "spear_rebar", @@ -232,7 +232,7 @@ "bashing": 5, "cutting": 15, "techniques": [ "WBLOCK_1" ], - "flags": [ "SPEAR", "REACH_ATTACK", "SHEATH_SPEAR" ], + "flags": [ "SPEAR", "REACH_ATTACK", "SHEATH_SPEAR", "STAB" ], "qualities": [ [ "COOK", 1 ], [ "HAMMER", 1 ] ] }, { @@ -253,7 +253,7 @@ "color": "light_gray", "techniques": [ "WBLOCK_1" ], "qualities": [ [ "COOK", 1 ] ], - "flags": [ "SPEAR", "REACH_ATTACK", "SHEATH_SPEAR" ] + "flags": [ "SPEAR", "REACH_ATTACK", "SHEATH_SPEAR", "STAB" ] }, { "id": "qiang", @@ -271,7 +271,7 @@ "volume": "2500 ml", "bashing": 5, "cutting": 31, - "flags": [ "DURABLE_MELEE", "SPEAR", "REACH_ATTACK", "NONCONDUCTIVE", "SHEATH_SPEAR" ], + "flags": [ "DURABLE_MELEE", "SPEAR", "REACH_ATTACK", "NONCONDUCTIVE", "SHEATH_SPEAR", "STAB" ], "price": "800 USD", "qualities": [ [ "COOK", 1 ] ] }, @@ -334,7 +334,7 @@ "color": "light_gray", "techniques": "WBLOCK_1", "qualities": [ [ "CUT", 1 ], [ "BUTCHER", -42 ] ], - "flags": [ "REACH_ATTACK", "POLEARM", "NONCONDUCTIVE", "SHEATH_SPEAR", "FRAGILE_MELEE" ] + "flags": [ "REACH_ATTACK", "POLEARM", "NONCONDUCTIVE", "SHEATH_SPEAR", "FRAGILE_MELEE", "SPEAR", "STAB" ] }, { "id": "glaive", @@ -348,7 +348,7 @@ "price": "500 USD", "material": [ "steel", "wood" ], "qualities": [ [ "CUT", 1 ], [ "BUTCHER", -28 ] ], - "flags": [ "DURABLE_MELEE", "REACH_ATTACK", "NONCONDUCTIVE", "POLEARM", "SHEATH_SPEAR", "ALWAYS_TWOHAND" ], + "flags": [ "DURABLE_MELEE", "REACH_ATTACK", "NONCONDUCTIVE", "POLEARM", "SHEATH_SPEAR", "ALWAYS_TWOHAND", "SPEAR", "STAB" ], "techniques": [ "WIDE", "WBLOCK_1" ], "weight": "2100 g", "volume": "2500 ml", @@ -372,7 +372,7 @@ "bashing": 7, "cutting": 45, "qualities": [ [ "CUT", 1 ], [ "BUTCHER", -24 ] ], - "flags": [ "DURABLE_MELEE", "REACH_ATTACK", "NONCONDUCTIVE", "POLEARM", "SHEATH_SPEAR", "ALWAYS_TWOHAND" ], + "flags": [ "DURABLE_MELEE", "REACH_ATTACK", "NONCONDUCTIVE", "POLEARM", "SHEATH_SPEAR", "ALWAYS_TWOHAND", "SPEAR", "STAB" ], "price": "800 USD", "price_postapoc": "95 USD" }, @@ -385,7 +385,7 @@ "material": [ "budget_steel", "wood" ], "bashing": 29, "cutting": 11, - "flags": [ "REACH_ATTACK", "NONCONDUCTIVE", "POLEARM", "SHEATH_SPEAR", "ALWAYS_TWOHAND" ], + "flags": [ "REACH_ATTACK", "NONCONDUCTIVE", "POLEARM", "SHEATH_SPEAR", "ALWAYS_TWOHAND", "SPEAR", "STAB" ], "price_postapoc": "15 USD" }, { @@ -420,7 +420,7 @@ "volume": "2250 ml", "bashing": 6, "cutting": 40, - "flags": [ "STAB", "POLEARM", "REACH_ATTACK", "SHEATH_SPEAR" ], + "flags": [ "STAB", "POLEARM", "REACH_ATTACK", "SHEATH_SPEAR", "SPEAR" ], "//": "Description says it can slash. STAB currently doesn't slash, but at least it doesn't give the spear bonus", "price": "80 USD", "price_postapoc": "45 USD", @@ -442,7 +442,7 @@ "volume": "1 L", "cutting": 11, "thrown_damage": [ { "damage_type": "bash", "amount": 5 }, { "damage_type": "stab", "amount": 11 } ], - "flags": [ "SPEAR", "SHEATH_SPEAR", "JAVELIN" ], + "flags": [ "SHEATH_SPEAR", "JAVELIN", "STAB" ], "price": "40 USD", "price_postapoc": "250 cent", "qualities": [ [ "COOK", 1 ] ] @@ -460,7 +460,7 @@ "bashing": 5, "cutting": 19, "thrown_damage": [ { "damage_type": "bash", "amount": 5 }, { "damage_type": "stab", "amount": 17 } ], - "flags": [ "SPEAR", "NONCONDUCTIVE", "SHEATH_SPEAR", "JAVELIN" ], + "flags": [ "NONCONDUCTIVE", "SHEATH_SPEAR", "JAVELIN", "STAB" ], "price": "90 USD", "price_postapoc": "5 USD" }, @@ -507,7 +507,17 @@ "color": "brown", "techniques": [ "IMPALE", "WBLOCK_1" ], "qualities": [ [ "COOK", 1 ] ], - "flags": [ "DURABLE_MELEE", "POLEARM", "SPEAR", "REACH_ATTACK", "REACH3", "NONCONDUCTIVE", "SHEATH_SPEAR", "ALWAYS_TWOHAND" ] + "flags": [ + "DURABLE_MELEE", + "POLEARM", + "SPEAR", + "REACH_ATTACK", + "REACH3", + "NONCONDUCTIVE", + "SHEATH_SPEAR", + "ALWAYS_TWOHAND", + "STAB" + ] }, { "id": "pike_inferior", @@ -521,7 +531,7 @@ "cutting": 8, "material": [ "budget_steel", "wood" ], "looks_like": "pike", - "flags": [ "POLEARM", "SPEAR", "REACH_ATTACK", "REACH3", "NONCONDUCTIVE", "ALWAYS_TWOHAND" ] + "flags": [ "POLEARM", "SPEAR", "REACH_ATTACK", "REACH3", "NONCONDUCTIVE", "ALWAYS_TWOHAND", "STAB" ] }, { "id": "pike_fake", @@ -537,7 +547,7 @@ "cutting": 2, "material": [ "aluminum", "wood" ], "looks_like": "pike", - "flags": [ "POLEARM", "SPEAR", "REACH_ATTACK", "REACH3", "NONCONDUCTIVE", "ALWAYS_TWOHAND", "FRAGILE_MELEE" ] + "flags": [ "POLEARM", "SPEAR", "REACH_ATTACK", "REACH3", "NONCONDUCTIVE", "ALWAYS_TWOHAND", "FRAGILE_MELEE", "STAB" ] }, { "id": "spear_dory", @@ -558,7 +568,7 @@ "color": "yellow", "techniques": [ "WBLOCK_1", "IMPALE" ], "qualities": [ [ "COOK", 1 ] ], - "flags": [ "SPEAR", "REACH_ATTACK", "DURABLE_MELEE", "SHEATH_SPEAR", "NONCONDUCTIVE" ] + "flags": [ "SPEAR", "REACH_ATTACK", "DURABLE_MELEE", "SHEATH_SPEAR", "NONCONDUCTIVE", "STAB" ] }, { "id": "ji", @@ -579,6 +589,6 @@ "symbol": "/", "color": "yellow", "techniques": [ "WBLOCK_1", "DEF_DISARM" ], - "flags": [ "DURABLE_MELEE", "POLEARM", "REACH_ATTACK", "ALWAYS_TWOHAND", "NONCONDUCTIVE", "SHEATH_SPEAR" ] + "flags": [ "DURABLE_MELEE", "POLEARM", "REACH_ATTACK", "ALWAYS_TWOHAND", "NONCONDUCTIVE", "SHEATH_SPEAR", "SPEAR", "STAB" ] } ] diff --git a/data/json/items/resources/wood.json b/data/json/items/resources/wood.json index a24624ffaa37..420b098d7875 100644 --- a/data/json/items/resources/wood.json +++ b/data/json/items/resources/wood.json @@ -82,7 +82,7 @@ "weight": "2250 g", "volume": "3750 ml", "bashing": 25, - "flags": [ "SPEAR", "REACH_ATTACK", "NONCONDUCTIVE" ], + "flags": [ "SPEAR", "REACH_ATTACK", "NONCONDUCTIVE", "STAB" ], "price": "40 USD", "price_postapoc": "50 cent", "qualities": [ [ "HAMMER", 1 ] ] diff --git a/data/json/items/tool/med.json b/data/json/items/tool/med.json index 014ba8f08f96..e2f2fc7f9114 100644 --- a/data/json/items/tool/med.json +++ b/data/json/items/tool/med.json @@ -97,7 +97,7 @@ "color": "light_gray", "techniques": "PRECISE", "qualities": [ [ "CUT", 1 ], [ "CUT_FINE", 3 ] ], - "flags": [ "SPEAR", "SHEATH_KNIFE" ] + "flags": [ "STAB", "SHEATH_KNIFE" ] }, { "id": "smoxygen_tank", @@ -189,7 +189,7 @@ "seals": true, "watertight": true, "use_action": "BLOOD_DRAW", - "flags": [ "SPEAR" ] + "flags": [ "STAB" ] }, { "id": "wrapped_rad_badge", diff --git a/data/json/items/tool/tailoring.json b/data/json/items/tool/tailoring.json index 7dde7264f079..39ee439e7d94 100644 --- a/data/json/items/tool/tailoring.json +++ b/data/json/items/tool/tailoring.json @@ -16,7 +16,7 @@ "symbol": ";", "color": "yellow", "qualities": [ [ "LEATHER_AWL", 1 ] ], - "flags": [ "SPEAR", "BELT_CLIP", "FRAGILE_MELEE" ] + "flags": [ "STAB", "BELT_CLIP", "FRAGILE_MELEE" ] }, { "id": "awl_steel", diff --git a/data/json/items/tool/workshop.json b/data/json/items/tool/workshop.json index 53eb355a4ff1..e8ea3ad4d899 100644 --- a/data/json/items/tool/workshop.json +++ b/data/json/items/tool/workshop.json @@ -690,7 +690,7 @@ "color": "dark_gray", "use_action": "PICKAXE", "techniques": [ "WBLOCK_1" ], - "flags": [ "SPEAR", "DURABLE_MELEE", "NONCONDUCTIVE", "DIG_TOOL", "SHEATH_AXE" ] + "flags": [ "STAB", "DURABLE_MELEE", "NONCONDUCTIVE", "DIG_TOOL", "SHEATH_AXE" ] }, { "id": "pin_reamer", @@ -799,7 +799,7 @@ "symbol": ";", "color": "yellow", "qualities": [ [ "SCREW", 1 ] ], - "flags": [ "SPEAR", "BELT_CLIP" ] + "flags": [ "STAB", "BELT_CLIP" ] }, { "id": "screwdriver_set", @@ -889,7 +889,7 @@ }, { "flame": false, "type": "cauterize" } ], - "flags": [ "SPEAR", "BELT_CLIP", "ALLOWS_REMOTE_USE" ], + "flags": [ "STAB", "BELT_CLIP", "ALLOWS_REMOTE_USE" ], "magazines": [ [ "battery", @@ -1147,7 +1147,7 @@ "color": "light_gray", "techniques": "PRECISE", "qualities": [ [ "CUT", 1 ], [ "CUT_FINE", 2 ] ], - "flags": [ "SPEAR", "SHEATH_KNIFE" ] + "flags": [ "STAB", "SHEATH_KNIFE" ] }, { "id": "wrench", diff --git a/data/mods/TEST_DATA/items.json b/data/mods/TEST_DATA/items.json index eaf3e7be5878..9c6b33326698 100644 --- a/data/mods/TEST_DATA/items.json +++ b/data/mods/TEST_DATA/items.json @@ -174,7 +174,7 @@ "symbol": ";", "color": "yellow", "qualities": [ [ "SCREW", 1 ] ], - "flags": [ "SPEAR", "BELT_CLIP" ] + "flags": [ "STAB", "BELT_CLIP" ] }, { "id": "test_sonic_screwdriver", diff --git a/deno.lock b/deno.lock index ea7c3d1fc897..ca8684915bac 100644 --- a/deno.lock +++ b/deno.lock @@ -258,6 +258,7 @@ "https://deno.land/x/catjazz@v0.0.3/deps/std/path.ts": "7096502d941de6b2b14c7c6790878838c4053bf5f19f562d1ffba88100fe091d", "https://deno.land/x/catjazz@v0.0.3/deps/ts_pattern.ts": "7526636f48b8e3f873ca434cad40a5eb87e1949e77d414b590a7f7f57300f790", "https://deno.land/x/catjazz@v0.0.3/deps/zod.ts": "767f25e9a6e77e7beeba2c0d7338eef29c5918942da54e797ebc0b683f32e341", + "https://deno.land/x/catjazz@v0.0.3/mod.ts": "c0064d7b65c149ce893a3f52441d85fb8d1f3af685ab3117428b25a7cb9dc4f5", "https://deno.land/x/catjazz@v0.0.3/units/currency.ts": "2af55063b799cbe96914590363d5199bb17c80d4e5b916c01a24181f100267f4", "https://deno.land/x/catjazz@v0.0.3/units/energy.ts": "77f15846e5dc805ea1b446d1ba19aee6e5424450083c4267df552f5745d51750", "https://deno.land/x/catjazz@v0.0.3/units/mod.ts": "a814ea5846aba39ba9efabb24496013efdd4a7e1c9241d7f86bf781b0fdb8f51", @@ -268,6 +269,7 @@ "https://deno.land/x/catjazz@v0.0.3/utils/id.ts": "d5cb52b03643fa656e47db6c286e587c66a94d247b5214573f0798243540fe93", "https://deno.land/x/catjazz@v0.0.3/utils/json_fmt.ts": "c1e60944a33866603361a55f1f684db9dc8dfdba77b1b6fb28f8fa8485ff9d6f", "https://deno.land/x/catjazz@v0.0.3/utils/parse.ts": "dc72e8d7943ac788fad65af82a151752335ca569ca5da3e242ee2015a8d397c9", + "https://deno.land/x/catjazz@v0.0.3/utils/query.ts": "5605700320323c52fe39f714404877cc565381e39f59d49c0c532fb4441122ba", "https://deno.land/x/catjazz@v0.0.3/utils/timeit.ts": "4cf912ce42eec3ae9e67edf1ef82327c9c138d7ef75c4ec6a4483df796f2a31d", "https://deno.land/x/catjazz@v0.0.3/utils/transform.ts": "1bdc94edbe21ed7b0b579c4504ccf6d6d9f8752c11dc3452f80308a81e0e0393", "https://deno.land/x/cliffy@v1.0.0-rc.3/_utils/distance.ts": "02af166952c7c358ac83beae397aa2fbca4ad630aecfcd38d92edb1ea429f004", diff --git a/doc/src/content/docs/en/mod/json/reference/json_flags.md b/doc/src/content/docs/en/mod/json/reference/json_flags.md index f65b75ea86f5..0e3eb5145866 100644 --- a/doc/src/content/docs/en/mod/json/reference/json_flags.md +++ b/doc/src/content/docs/en/mod/json/reference/json_flags.md @@ -885,7 +885,9 @@ List of known flags, used in both `terrain.json` and `furniture.json`. volume not bigger than 2) - `SHEATH_SWORD` Item can be sheathed in a sword scabbard - `SPEAR` When making reach attacks intervening THIN_OBSTACLE terrain is not an obstacle. Should be - paired with REACH_ATTACK. + paired with `REACH_ATTACK`. +- `STAB` A legacy flag that converts an weapon's damage type into pierce. This is a hack as we + cannot use the damage object used by ammo to specify the damage type of melee weapon. - `UNARMED_WEAPON` Wielding this item still counts as unarmed combat. - `WHIP` Has a chance of disarming the opponent. diff --git a/scripts/migrations/4211.ts b/scripts/migrations/4211.ts new file mode 100644 index 000000000000..a9a39c4a4abf --- /dev/null +++ b/scripts/migrations/4211.ts @@ -0,0 +1,37 @@ +import { baseCli } from "$catjazz/mod.ts" +import { z } from "$catjazz/deps/zod.ts" + +/** + * [PR#4211](https://github.com/cataclysmbnteam/Cataclysm-BN/pull/4211) + * + * for items with `SPEAR` flag, + * 1. if it has `REACH_ATTACK`, also add `STAB` flag. + * 2. if it does **NOT** have `REACH_ATTACK`, replace `SPEAR` with `STAB` + */ +export const spearToStab = (xs: string[]): string[] => { + // if it already has STAB, it's already been converted + const hasStab = xs.includes("STAB") + if (hasStab) return xs + + const hasSpear = xs.includes("SPEAR") + if (!hasSpear) return xs + + const hasReachAttack = xs.includes("REACH_ATTACK") + if (hasReachAttack) return [...xs, "STAB"] + + if (!hasSpear && !hasReachAttack) return xs + return xs.map((x) => x === "SPEAR" ? "STAB" : x) +} + +export const schema = z + .object({ flags: z.array(z.string()).transform(spearToStab) }) + .passthrough() + +if (import.meta.main) { + const main = baseCli({ + desc: "Migrate SPEAR without REACH_ATTACK to STAB", + schema, + }) + + await main().parse(Deno.args) +} diff --git a/scripts/migrations/4211_test.ts b/scripts/migrations/4211_test.ts new file mode 100644 index 000000000000..4a271524a2ca --- /dev/null +++ b/scripts/migrations/4211_test.ts @@ -0,0 +1,115 @@ +import { assertEquals } from "$std/assert/assert_equals.ts" +import { schema } from "./4211.ts" +import { spearToStab } from "./4211.ts" + +Deno.test("If an item has both SPEAR AND REACH_ATTACK, just add STAB.", () => { + const pitchfork = { + id: "pitchfork", + type: "GENERIC", + category: "weapons", + weapon_category: ["SPEARS"], + name: { str: "pitchfork" }, + description: + "An agricultural tool with long wooden shaft and four spikes. Is used to lift hay.", + weight: "1000 g", + color: "brown", + symbol: "/", + material: ["steel", "wood"], + techniques: ["WBLOCK_1", "DEF_DISARM"], + volume: "1750 ml", + bashing: 5, + cutting: 23, + qualities: [["COOK", 1]], + flags: ["SPEAR", "REACH_ATTACK", "NONCONDUCTIVE", "SHEATH_SPEAR"], + price: "20 USD", + price_postapoc: "5 USD", + } + const expected = { + id: "pitchfork", + type: "GENERIC", + category: "weapons", + weapon_category: ["SPEARS"], + name: { str: "pitchfork" }, + description: + "An agricultural tool with long wooden shaft and four spikes. Is used to lift hay.", + weight: "1000 g", + color: "brown", + symbol: "/", + material: ["steel", "wood"], + techniques: ["WBLOCK_1", "DEF_DISARM"], + volume: "1750 ml", + bashing: 5, + cutting: 23, + qualities: [["COOK", 1]], + flags: ["SPEAR", "REACH_ATTACK", "NONCONDUCTIVE", "SHEATH_SPEAR", "STAB"], + price: "20 USD", + price_postapoc: "5 USD", + } + assertEquals(schema.parse(pitchfork), expected) +}) + +Deno.test("If an item has SPEAR but does NOT have REACH_ATTACK, replace SPEAR with STAB", () => { + const morningstar = { + id: "morningstar", + type: "GENERIC", + category: "weapons", + weapon_category: ["MORNINGSTARS"], + name: { "str": "morningstar" }, + description: + "A medieval weapon consisting of a wood handle with a heavy, spiked iron ball on the end. It deals devastating crushing damage, with a small amount of piercing to boot.", + weight: "1400 g", + to_hit: -1, + color: "dark_gray", + symbol: "/", + material: ["iron", "wood"], + techniques: ["SWEEP"], + volume: "1500 ml", + bashing: 38, + cutting: 6, + flags: ["DURABLE_MELEE", "SPEAR", "NONCONDUCTIVE"], + price: "1200 USD", + price_postapoc: "80 USD", + qualities: [["HAMMER", 1]], + } + const expected = { + id: "morningstar", + type: "GENERIC", + category: "weapons", + weapon_category: ["MORNINGSTARS"], + name: { "str": "morningstar" }, + description: + "A medieval weapon consisting of a wood handle with a heavy, spiked iron ball on the end. It deals devastating crushing damage, with a small amount of piercing to boot.", + weight: "1400 g", + to_hit: -1, + color: "dark_gray", + symbol: "/", + material: ["iron", "wood"], + techniques: ["SWEEP"], + volume: "1500 ml", + bashing: 38, + cutting: 6, + flags: ["DURABLE_MELEE", "STAB", "NONCONDUCTIVE"], + price: "1200 USD", + price_postapoc: "80 USD", + qualities: [["HAMMER", 1]], + } + assertEquals(schema.parse(morningstar), expected) +}) + +Deno.test("spearToStab", async (t) => { + await t.step("if a flag already has STAB, ignore it", () => { + assertEquals(spearToStab(["STAB"]), ["STAB"]) + assertEquals(spearToStab(["SPEAR", "STAB"]), ["SPEAR", "STAB"]) + }) + await t.step("if a flag has both SPEAR and REACH_ATTACK, add STAB", () => { + assertEquals(spearToStab(["SPEAR", "REACH_ATTACK"]), ["SPEAR", "REACH_ATTACK", "STAB"]) + }) + + await t.step( + "if a flag has SPEAR but not REACH_ATTACK, replace SPEAR with STAB with its position kept", + () => { + assertEquals(spearToStab(["SPEAR"]), ["STAB"]) + assertEquals(spearToStab(["FOO", "SPEAR", "BAR"]), ["FOO", "STAB", "BAR"]) + }, + ) +}) diff --git a/src/item_factory.cpp b/src/item_factory.cpp index 6188c92f7160..1e4ecf94de0f 100644 --- a/src/item_factory.cpp +++ b/src/item_factory.cpp @@ -192,7 +192,7 @@ void Item_factory::finalize_pre( itype &obj ) obj.item_tags.insert( flag_NO_REPAIR ); } - if( obj.has_flag( flag_STAB ) || obj.has_flag( flag_SPEAR ) ) { + if( obj.has_flag( flag_STAB ) ) { std::swap( obj.melee[DT_CUT], obj.melee[DT_STAB] ); }