Explorar o código

【新增】让玩具枪与弹匣兼容 7.62x25 并扩展 Alpha Dog 瞄具槽

实测确认 SPT 客户端开火门控读取武器 Chambers 过滤器而非单值 ammoCaliber,故以追加膛室 / 弹匣装填位白名单的方式,在保留原 20x1mm 玩具弹能力的同时叠加全部 7 种 7.62x25 托卡列夫弹药,不改动 ammoCaliber。

另将 M14 SAGE International DCSB 瞄具基座加入 Alpha Dog Alpha 9 9x19 声音抑制器的 mod_scope 槽(复用本模组已为 Aim Sports 三轨添加的同一基座)。

csproj 0.13.0→0.15.0;新增 4 条单元测试。
PJ568 hai 1 mes
pai
achega
8603bc0e7b

+ 2 - 2
README.md

@@ -1,6 +1,6 @@
 # PJ568's Weapon Cross Modding
 
-> 一个 SPT 4.1.x 服务端插件:往目标物品槽的过滤器白名单里追加配件 id,让指定武器、瞄具、枪托与握把实现跨武器兼容。
+> 一个 SPT 4.1.x 服务端插件:往目标物品槽的过滤器白名单里追加配件 id,让指定武器、瞄具、枪托与握把实现跨武器兼容;并让 20x1mm 玩具枪与其弹匣在保留玩具弹的同时兼容 7.62x25 托卡列夫弹药。
 
 ![PPSh-41 满配跨武器改装展示](assets/PPSh-MDR.webp)
 
@@ -38,7 +38,7 @@ SPT `4.1.x`。
 
 # PJ568's Weapon Cross Modding
 
-> An SPT 4.1.x server plugin that appends accessory ids to slot filter whitelists, enabling cross-weapon compatibility between selected weapons, optics, stocks and grips.
+> An SPT 4.1.x server plugin that appends accessory ids to slot filter whitelists, enabling cross-weapon compatibility between selected weapons, optics, stocks and grips; it also lets the 20x1mm toy gun and its magazine accept 7.62x25 Tokarev ammunition while keeping the toy rounds.
 
 ![PPSh-41 fully-kitted cross-weapon build showcase](assets/PPSh-MDR.webp)
 

+ 3 - 3
WeaponCrossModding.csproj

@@ -13,9 +13,9 @@
       钉到 4.1.2 是当前最稳的策略;服务端校验 mod 编译引用的 SPTarkov.Server.Core
       AssemblyVersion,使用 4.1.2 编译的 mod 可被 4.1.5 宿主加载。
     -->
-    <Version>0.13.0</Version>
-    <AssemblyVersion>0.13.0.0</AssemblyVersion>
-    <FileVersion>0.13.0.0</FileVersion>
+    <Version>0.15.0</Version>
+    <AssemblyVersion>0.15.0.0</AssemblyVersion>
+    <FileVersion>0.15.0.0</FileVersion>
     <AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
   </PropertyGroup>
 

+ 4 - 2
docs/compatibility.md

@@ -14,11 +14,12 @@
 - **原版物品**:RPD 520mm 枪管、M700 全部 4 种枪管、ORSIS T-5000M 660mm 枪管、SKS 与 OP-SKS 的 520mm 枪管、TAPCO Intrafuse SKS 枪身套件、Fab Defence UAS SKS 枪身套件及其枪托槽配件(TAPCO Intrafuse 缓冲管、Fab Defence UAS 折叠枪托)、SKS / OP-SKS 照门固定环、SKS / OP-SKS / SVT-40 / AVT-40 枪本体与 SVT-40 625mm 枪管、SVDS 照门固定环、SVDS 枪本体与 SVDS 枪管、PPSh-41 71 发弹鼓,以及 AKM PBS-1 7.62x39 消音器均为原版物品,不依赖 `WTT-ContentBackport`。
 - **PPSh-41 上机匣槽**:`mod_reciever` 槽同时承载 PPSh-41 防尘盖、TAPCO Intrafuse SKS 与 Fab Defence UAS SKS 枪身套件,共用同一槽位,因此彼此天然二选一。
 - **新增互斥**:两个 SKS 枪身套件与除 KS-23 金属枪托之外的全部 PPSh-41 枪托(含原装木制枪托与 Zveno 缓冲管转接器)互不兼容;两个 SKS 枪身套件与 PPSh-41 的 71 发弹鼓互不兼容;KS-23 金属枪托与两个 SKS 枪身套件枪托槽可装的配件互不兼容;TKPD 导轨防尘盖与 SKS / OP-SKS / SVT-40 / AVT-40 / SVDS 枪本体互不兼容;SVDS 照门固定环护木槽可装的莫辛 200mm、M700 全部 4 种与 ORSIS T-5000M 枪管与 SVDS 枪本体互不兼容;SVDS 枪管与自身互不兼容(防止重复安装);SVDS 照门固定环与 PPSh-41 防尘盖、TAPCO Intrafuse SKS 枪身套件互不兼容;SVDS 照门固定环护木槽可装的 3 种原版 SVDS 护木与 PPSh-41 枪本体互不兼容;SVDS 照门固定环护木槽可装的 SVT-40 / AVT-40 625mm 枪管与 SVDS 枪本体互不兼容;TKPD 导轨防尘盖与自身互不兼容(防止重复安装);MDR BLK LBL ALX 20 脚架与自身互不兼容(防止重复安装);5 种 SKS 导气管防尘盖与 UltiMAK M1-B AK 导气管套件彼此之间(含与自身)互不兼容,使一把武器上最多只能装一个。
-- **新增兼容**:Fab Defence UAS SKS 枪身套件的下导轨(`mod_tactical_002`)新增兼容 AK-100 系列聚合物护木可安装的全部 33 种前握把(含 Zenit RK 系列、BCM MOD.3、KAC、ASh-12、Tactical Dynamics 镂空、TangoDown Stubby BGV-MK46K 三色、Fortis Shift 等)。
+- **新增兼容**:Fab Defence UAS SKS 枪身套件的下导轨(`mod_tactical_002`)新增兼容 AK-100 系列聚合物护木可安装的全部 33 种前握把(含 Zenit RK 系列、BCM MOD.3、KAC、ASh-12、Tactical Dynamics 镂空、TangoDown Stubby BGV-MK46K 三色、Fortis Shift 等);Alpha Dog Alpha 9 9x19 声音抑制器的 `mod_scope` 槽新增兼容 M14 SAGE International DCSB 瞄具基座。
 - 插件只改写物品数据库,不注册 Harmony patch,也不与客户端插件争抢运行时方法。
 
 ## 已知限制
 
+- **玩具枪跨口径为实验性**:20x1mm 玩具枪与其原装弹匣的 7.62x25 兼容,只通过追加膛室 / 装填位白名单实现,**未改动武器单值 `ammoCaliber`**。若客户端以 `ammoCaliber` 作为开火硬门控,则同一武器模板「既打 20x1mm 又打 7.62x25」可能无法实际开火;届时可改为克隆一个 `ammoCaliber = Caliber762x25TT` 的武器模板,或接受该枪仅打 7.62x25。
 - **依赖物品 id 与槽位名**:注入目标取自具体物品 id 与槽位名;若上游数据在版本更新中变更,相关条目会跳过或失效。
 - **必须由服务端加载**:这是服务端模组,仅在服务端数据库层面放宽白名单;未部署到服务端时游戏内不会生效。
 - **版本敏感**:`SPTarkov.Server.Core` 等依赖与 SPT 服务端版本对齐,跨越 4.1.x 之外的版本可能需要重新适配。
@@ -52,11 +53,12 @@
 - **Vanilla items**: the RPD 520 mm barrel, all four M700 barrels, the ORSIS T-5000M 660 mm barrel, the SKS and OP-SKS 520 mm barrels, the TAPCO Intrafuse SKS chassis kit, the Fab Defence UAS SKS chassis kit and their stock-slot parts (TAPCO Intrafuse buffer tube, Fab Defence UAS folding stock), the SKS / OP-SKS rear sight blocks, the SKS / OP-SKS / SVT-40 / AVT-40 weapons and the SVT-40 625 mm barrel, the SVDS rear sight block, the SVDS weapon and the SVDS barrel, the PPSh-41 71-round drum magazine, and the AKM PBS-1 7.62x39 suppressor are all vanilla items and do not depend on `WTT-ContentBackport`.
 - **PPSh-41 upper receiver slot**: the `mod_reciever` slot carries the PPSh-41 dust cover, the TAPCO Intrafuse SKS and the Fab Defence UAS SKS chassis kits; since they share the same slot, they are inherently an either/or choice.
 - **New exclusions**: the two SKS chassis kits are incompatible with every PPSh-41 stock except the KS-23 metal stock (including the PPSh wooden stock and the Zveno buffer tube adapter) and with the PPSh-41 71-round drum magazine; the KS-23 metal stock is incompatible with the parts accepted by the two SKS chassis kits' stock slots; the TKPD railed dust cover is incompatible with the SKS, OP-SKS, SVT-40, AVT-40 and SVDS weapons; the Mosin 200 mm, all four M700 and the ORSIS T-5000M barrels accepted by the SVDS rear sight block's handguard slot are incompatible with the SVDS weapon; the SVDS barrel is incompatible with itself (to prevent duplicate mounting); the SVDS rear sight block is incompatible with the PPSh-41 dust cover and with the TAPCO Intrafuse SKS chassis kit; the 3 vanilla SVDS handguards accepted by the SVDS rear sight block's handguard slot are incompatible with the PPSh-41 weapon itself; the SVT-40 / AVT-40 625 mm barrel accepted by that handguard slot is incompatible with the SVDS weapon; the TKPD railed dust cover is incompatible with itself (to prevent duplicate mounting); the MDR BLK LBL ALX 20 bipod is incompatible with itself (to prevent duplicate mounting); the 5 SKS gas-tube covers and the UltiMAK M1-B AK gas tube kit are mutually incompatible with each other (including with themselves), so at most one can be installed on a weapon.
-- **New compatibility**: the Fab Defence UAS SKS chassis kit's lower rail (`mod_tactical_002`) now accepts all 33 foregrips compatible with the AK-100 series polymer handguards (Zenit RK series, BCM MOD.3, KAC, ASh-12, Tactical Dynamics skeletonized, TangoDown Stubby BGV-MK46K in three colors, Fortis Shift, and 25 others).
+- **New compatibility**: the Fab Defence UAS SKS chassis kit's lower rail (`mod_tactical_002`) now accepts all 33 foregrips compatible with the AK-100 series polymer handguards (Zenit RK series, BCM MOD.3, KAC, ASh-12, Tactical Dynamics skeletonized, TangoDown Stubby BGV-MK46K in three colors, Fortis Shift, and 25 others); the Alpha Dog Alpha 9 9x19 sound suppressor's `mod_scope` slot now accepts the M14 SAGE International DCSB scope mount.
 - The plugin only rewrites the item database. It registers no Harmony patch and never contends with client plugins for runtime methods.
 
 ## Known Limitations
 
+- **The toy gun's cross-caliber support is experimental**: the 7.62x25 compatibility for the 20x1mm toy gun and its stock magazine is implemented only by appending to the chamber / cartridge whitelists, **without changing the weapon's single-value `ammoCaliber`**. If the client uses `ammoCaliber` as a hard firing gate, a single weapon template that fires both 20x1mm and 7.62x25 may not actually fire; in that case, either clone a weapon template with `ammoCaliber = Caliber762x25TT`, or accept that the gun only fires 7.62x25.
 - **Depends on item ids and slot names**: the injection targets come from concrete item ids and slot names; if upstream data changes in a version update, the affected entries are skipped or stop applying.
 - **Must be loaded by the server**: this is a server mod that widens whitelists only at the server database level; it has no in-game effect unless deployed to the server.
 - **Version sensitive**: dependencies such as `SPTarkov.Server.Core` are version-aligned with the SPT server, and going beyond the 4.1.x line may require re-adaptation.

+ 10 - 0
docs/features.md

@@ -10,6 +10,7 @@
 - SKS / OP-SKS 照门固定环的 `mod_sight_rear` 照门槽:新增 TKPD 导轨防尘盖。
 - SVT-40 625mm 枪管的 `mod_sight_rear` 照门槽:新增 TKPD 导轨防尘盖与 5 种 SKS 导气管防尘盖(OP-SKS 标准、SKS 木制标准、TAPCO、Fab Defence UAS、ATI Monte Carlo;即原生 SKS 导气箍可装的那 5 种)。
 - SVDS 照门固定环的 `mod_sight_rear` 照门槽:新增 TKPD 导轨防尘盖、3 种 SKS 导气管防尘盖(OP-SKS 标准、SKS 木制标准、ATI Monte Carlo)与 UltiMAK M1-B AK 导气管套件。
+- Alpha Dog Alpha 9 9x19 声音抑制器的 `mod_scope` 槽:新增 M14 SAGE International DCSB 瞄具基座。
 
 ## 枪管与枪托
 
@@ -22,6 +23,10 @@
 - AA-12 457mm 枪管的 `mod_mount` 导轨槽:新增 M60 脚架。
 - MP-18 与 Marlin MXLR 的 `mod_stock` 枪托槽:新增 KS-23 金属枪托。
 
+## 弹药与口径
+
+- 20x1mm 玩具枪(`weapon_ussr_pd_20x1mm`)与其原装弹匣(`mag_pd_ussr_toygun_std_20x1mm_18`):在保留原 20x1mm 玩具弹能力的同时,新增对全部 7 种 7.62x25 托卡列夫弹药(AKBS、FMJ43、LRN、LRNPC、P Gl、Pst gzh、T Gzh)的兼容。做法是向武器膛室(`Chambers`)与弹匣装填位(`Cartridges`)白名单追加弹药 id,不改动武器单值 `ammoCaliber`。
+
 ## 握把与配件
 
 - Aim Sports“三轨”的第一个战术配件槽(`mod_tactical_000`):新增 13 款前握把(Zenit RK 系列、镂空型、垂直型、BCM MOD.3、TangoDown Stubby BGV-MK46K;不含 KeyMod / M-LOK 型)、SV-98 隔热带与 Fortis Shift 战术前握把。
@@ -64,6 +69,7 @@
 - `mod_sight_rear` sight slot of the SKS / OP-SKS rear sight blocks: adds the TKPD railed dust cover.
 - `mod_sight_rear` sight slot of the SVT-40 625 mm barrel: adds the TKPD railed dust cover and the 5 SKS gas-tube covers (OP-SKS standard, SKS wooden standard, TAPCO, Fab Defence UAS, ATI Monte Carlo; the five accepted by the native SKS gas block).
 - `mod_sight_rear` sight slot of the SVDS rear sight block: adds the TKPD railed dust cover, the 3 SKS gas-tube covers (OP-SKS standard, SKS wooden standard, ATI Monte Carlo) and the UltiMAK M1-B AK gas tube kit.
+- `mod_scope` slot of the Alpha Dog Alpha 9 9x19 sound suppressor: adds the M14 SAGE International DCSB scope mount.
 
 ## Barrels and stocks
 
@@ -76,6 +82,10 @@
 - `mod_mount` rail slot of the AA-12 457 mm barrel: adds the M60 bipod.
 - `mod_stock` slot of the MP-18 and Marlin MXLR: adds the KS-23 metal stock.
 
+## Ammunition and caliber
+
+- 20x1mm toy gun (`weapon_ussr_pd_20x1mm`) and its stock magazine (`mag_pd_ussr_toygun_std_20x1mm_18`): while keeping the original 20x1mm toy-round capability, adds compatibility with all 7 types of 7.62x25 Tokarev ammunition (AKBS, FMJ43, LRN, LRNPC, P Gl, Pst gzh, T Gzh). It appends the ammo ids to the weapon's chamber (`Chambers`) and the magazine's cartridge (`Cartridges`) whitelists without touching the weapon's single-value `ammoCaliber`.
+
 ## Grips and accessories
 
 - First tactical slot (`mod_tactical_000`) of the Aim Sports tri-rail: adds 13 foregrips (Zenit RK series, skeletonized, vertical, BCM MOD.3, TangoDown Stubby BGV-MK46K; excluding KeyMod / M-LOK types), the SV-98 heat ribbon and the Fortis Shift tactical foregrip.

+ 24 - 4
docs/principle.md

@@ -4,7 +4,7 @@
 
 ## 数据模型
 
-SPT 服务端把所有物品模板存放在 `TemplateTable.Items`(`Dictionary<MongoId, TemplateItem>`)中。与兼容性相关的字段有两处:
+SPT 服务端把所有物品模板存放在 `TemplateTable.Items`(`Dictionary<MongoId, TemplateItem>`)中。与兼容性相关的字段有三处:
 
 ### 槽位过滤器
 
@@ -16,6 +16,15 @@ SPT 服务端把所有物品模板存放在 `TemplateTable.Items`(`Dictionary<
 
 **要让一件物品能装进某个槽位,就是把这个物品的 id 加进该槽位过滤器的白名单。**
 
+### 弹药容器
+
+除槽位外,武器与弹匣还各有一个「弹药容器」,其结构与槽位一致(同样是 `Slot` 列表,同样有 `Properties.Filters[].Filter`):
+
+- 武器:`Properties.Chambers`(膛室,`Slot.Name` 为 `patron_in_weapon`),决定能上膛的弹药模板。
+- 弹匣:`Properties.Cartridges`(装填位,`Slot.Name` 为 `cartridges`),决定能装填的弹药模板。
+
+**要让武器或弹匣接受某种弹药,就是把这个弹药的模板 id 加进对应容器的过滤器白名单。**
+
 ### 冲突列表
 
 `TemplateItem.Properties.ConflictingItems` 是 `HashSet<MongoId>`。若 A 的 `ConflictingItems` 含 B 的 id(或反之),则 A 与 B 不能同时安装在一件武器上。
@@ -31,7 +40,8 @@ SPT 服务端把所有物品模板存放在 `TemplateTable.Items`(`Dictionary<
    - 若宿主 id 不在 `Items` 中,记警告并跳过;若宿主没有槽位,记警告并跳过。
    - 按槽位名(`OrdinalIgnoreCase`)找到宿主的所有同名槽。
    - 对每个槽的每个 `SlotFilter`,把各 id 加入 `Filter`。
-3. 对每一组互斥关系,调用 `AddConflictingItems`,把冲突 id 加入宿主物品的 `ConflictingItems`。
+3. 对每一组「宿主物品 + 弹药容器 + 待追加弹药 id」,调用 `AddAmmoIdsToContainer`,逻辑与上一步相同,只是把目标槽换成武器的 `Chambers` 或弹匣的 `Cartridges`。
+4. 对每一组互斥关系,调用 `AddConflictingItems`,把冲突 id 加入宿主物品的 `ConflictingItems`。
 4. 整个过程包在 `try/catch` 中:任何异常都被记录为 `error`,不会中断服务端启动。
 
 ## 幂等
@@ -67,7 +77,7 @@ SPT 服务端把所有物品模板存放在 `TemplateTable.Items`(`Dictionary<
 
 ## Data Model
 
-The SPT server stores every item template in `TemplateTable.Items` (`Dictionary<MongoId, TemplateItem>`). Two fields are relevant to compatibility:
+The SPT server stores every item template in `TemplateTable.Items` (`Dictionary<MongoId, TemplateItem>`). Three fields are relevant to compatibility:
 
 ### Slot filters
 
@@ -79,6 +89,15 @@ Each `TemplateItem`'s `Properties.Slots` is a list of `Slot`. Every `Slot` has:
 
 **Making an item fit a slot means adding that item's id to the slot filter's whitelist.**
 
+### Ammo containers
+
+Besides slots, weapons and magazines each have an "ammo container" with the same structure as a slot (also a list of `Slot`, also with `Properties.Filters[].Filter`):
+
+- Weapon: `Properties.Chambers` (the chamber, `Slot.Name` is `patron_in_weapon`), which determines the ammo templates that can be chambered.
+- Magazine: `Properties.Cartridges` (the loading position, `Slot.Name` is `cartridges`), which determines the ammo templates that can be loaded.
+
+**Making a weapon or magazine accept an ammo type means adding that ammo's template id to the corresponding container filter's whitelist.**
+
 ### Conflict list
 
 `TemplateItem.Properties.ConflictingItems` is a `HashSet<MongoId>`. If A's `ConflictingItems` contains B's id (or vice versa), A and B cannot be installed on the same weapon.
@@ -94,7 +113,8 @@ The plugin entry implements `IOnLoad` and is registered with `[Injectable(Inject
    - If the owner id is missing from `Items`, log a warning and skip; if the owner has no slots, log a warning and skip.
    - Find all same-named slots (case-insensitive, `OrdinalIgnoreCase`).
    - For every `SlotFilter` of every matching slot, add the ids to `Filter`.
-3. For each mutual exclusion, call `AddConflictingItems` to add the conflicting id to the owner item's `ConflictingItems`.
+3. For each group of "owner item + ammo container + ammo ids to add", call `AddAmmoIdsToContainer`, which works exactly like the previous step but targets the weapon's `Chambers` or the magazine's `Cartridges` instead of a slot.
+4. For each mutual exclusion, call `AddConflictingItems` to add the conflicting id to the owner item's `ConflictingItems`.
 4. The whole process is wrapped in `try/catch`: any exception is logged as `error` and never interrupts server startup.
 
 ## Idempotency

+ 6 - 2
docs/verification.md

@@ -14,7 +14,7 @@
 [Info][...] WeaponCrossModding: added '<物品 id>' to slot '<槽位名>' (<宿主物品名>)
 ```
 
-槽位名应涵盖 `mod_scope`、`mod_sight_front`、`mod_sight_rear`、`mod_barrel`、`mod_stock`、`mod_tactical`、`mod_tactical_000`、`mod_tactical_001`、`mod_pistol_grip`、`mod_mount`、`mod_muzzle`、`mod_reciever`;互斥关系另会输出 `added conflicting item '…' to '…'`。
+槽位名应涵盖 `mod_scope`、`mod_sight_front`、`mod_sight_rear`、`mod_barrel`、`mod_stock`、`mod_tactical`、`mod_tactical_000`、`mod_tactical_001`、`mod_pistol_grip`、`mod_mount`、`mod_muzzle`、`mod_reciever`;弹药注入使用 `patron_in_weapon`(武器膛室)与 `cartridges`(弹匣装填位)两个槽名;互斥关系另会输出 `added conflicting item '…' to '…'`。
 
 ## 验证步骤
 
@@ -28,11 +28,13 @@
    - 在 SVDS 照门固定环的护木槽安装莫辛 200mm、M700、ORSIS T-5000M、SVDS 枪管或 SVT-40 625mm 枪管;
    - 在 SKS / OP-SKS 照门固定环或 SVDS 照门固定环的照门槽安装 TKPD 导轨防尘盖;在 SVT-40 625mm 枪管的照门槽安装 5 种 SKS 导气管防尘盖(OP-SKS 标准、SKS 木制标准、TAPCO、Fab Defence UAS、ATI Monte Carlo);在 SVDS 照门固定环的照门槽安装 OP-SKS 标准 / SKS 木制标准 / ATI Monte Carlo 3 种导气管防尘盖或 UltiMAK M1-B AK 导气管套件;
    - 在 SVDS 照门固定环的护木槽安装照门固定环自身;
+   - 在 Alpha Dog Alpha 9 9x19 声音抑制器的 `mod_scope` 槽安装 M14 DCSB 瞄具基座;
    - 在 RPD 520mm 枪管的枪口装置槽安装 AKM PBS-1 7.62x39 消音器;
    - 在 730mm 标准莫辛枪管或 SVT-40 标准枪口装置的前准星槽安装 MDR BLK LBL ALX 脚架(16 或 20 型号);
    - 在 AA-12 457mm 枪管的导轨槽安装 M60 脚架;
    - 在 Fab Defence UAS SKS 枪身套件的下导轨(`mod_tactical_002`)或 UltiMAK M1-B AK 导气管套件的战术配件槽(`mod_tactical_000`)安装 MDR BLK LBL ALX 20 脚架;
    - 在 MP-18 或 Marlin MXLR 的枪托槽安装 KS-23 金属枪托;
+   - 清客户端缓存后,给 20x1mm 玩具枪的原装弹匣压入 7.62x25 托卡列夫子弹(全部 7 种任选),插枪并尝试开火,确认能否正常发射;同时确认原 20x1mm 玩具弹仍可使用;
    - 尝试同时安装 PPSh-41 防尘盖与 HUXWRX HX-QD 消音器,确认二者互斥;
    - 尝试在 PPSh-41 上同时安装 SKS 枪身套件与任一非 KS-23 枪托(含 Zveno 缓冲管转接器),确认二者互斥;
    - 尝试在 PPSh-41 上同时安装 SKS 枪身套件与 71 发弹鼓,确认二者互斥;
@@ -75,7 +77,7 @@ followed by the individual injections:
 [Info][...] WeaponCrossModding: added '<item id>' to slot '<slot name>' (<owner item name>)
 ```
 
-The slot names should cover `mod_scope`, `mod_sight_front`, `mod_sight_rear`, `mod_barrel`, `mod_stock`, `mod_tactical`, `mod_tactical_000`, `mod_tactical_001`, `mod_pistol_grip`, `mod_mount`, `mod_muzzle`, `mod_reciever`; conflicts also print `added conflicting item '…' to '…'`.
+The slot names should cover `mod_scope`, `mod_sight_front`, `mod_sight_rear`, `mod_barrel`, `mod_stock`, `mod_tactical`, `mod_tactical_000`, `mod_tactical_001`, `mod_pistol_grip`, `mod_mount`, `mod_muzzle`, `mod_reciever`; ammo injections use the two slot names `patron_in_weapon` (weapon chamber) and `cartridges` (magazine cartridge slot); conflicts also print `added conflicting item '…' to '…'`.
 
 ## Verification Steps
 
@@ -89,11 +91,13 @@ The slot names should cover `mod_scope`, `mod_sight_front`, `mod_sight_rear`, `m
    - mount a Mosin 200 mm, M700, ORSIS T-5000M, SVDS or SVT-40 625 mm barrel in the SVDS rear sight block's handguard slot;
    - mount the TKPD railed dust cover on the sight slot of the SKS / OP-SKS rear sight blocks or the SVDS rear sight block; the 5 SKS gas-tube covers (OP-SKS standard, SKS wooden standard, TAPCO, Fab Defence UAS, ATI Monte Carlo) on the SVT-40 625 mm barrel's sight slot; and the OP-SKS standard / SKS wooden standard / ATI Monte Carlo covers or the UltiMAK M1-B AK gas tube kit on the SVDS rear sight block's sight slot;
    - mount the SVDS rear sight block itself in its own handguard slot;
+   - mount the M14 DCSB scope mount on the Alpha Dog Alpha 9 9x19 sound suppressor's `mod_scope` slot;
    - mount an AKM PBS-1 7.62x39 suppressor on the muzzle device slot of the RPD 520 mm barrel;
    - mount an MDR BLK LBL ALX bipod (16 or 20 model) on the front sight slot of the 730 mm standard Mosin barrel or the SVT-40 standard muzzle;
    - mount an M60 bipod on the rail slot of the AA-12 457 mm barrel;
    - mount an MDR BLK LBL ALX 20 bipod on the lower rail (`mod_tactical_002`) of the Fab Defence UAS SKS chassis kit or the tactical slot (`mod_tactical_000`) of the UltiMAK M1-B AK gas tube kit;
    - mount a KS-23 metal stock on the stock slot of the MP-18 or Marlin MXLR;
+   - after clearing the client cache, load 7.62x25 Tokarev rounds (any of the 7 types) into the stock magazine of the 20x1mm toy gun, insert it and try to fire, confirming whether it fires; also confirm the original 20x1mm toy rounds still work;
    - try mounting the PPSh-41 dust cover and a HUXWRX HX-QD suppressor together and confirm they are mutually exclusive;
    - try mounting an SKS chassis kit on the PPSh-41 together with any non-KS-23 stock (including the Zveno buffer tube adapter) and confirm they are mutually exclusive;
    - try mounting an SKS chassis kit on the PPSh-41 together with the 71-round drum magazine and confirm they are mutually exclusive;

+ 76 - 0
src/Mod.cs

@@ -66,6 +66,9 @@ namespace Pj568.WeaponCrossModding;
 ///  45. 让 SVDS 照门固定环的照门槽支持安装 OP-SKS 标准 / SKS 木制标准 / ATI Monte Carlo 3 种 SKS 导气管防尘盖与 UltiMAK M1-B AK 导气管套件;
 ///  46. 让 5 种 SKS 导气管防尘盖与 UltiMAK M1-B AK 导气管套件彼此之间(含与自身)互不兼容,使一把武器上最多只能装一个;
 ///  47. 让 UltiMAK M1-B AK 导气管套件的战术配件槽(mod_tactical_000)支持安装 MDR BLK LBL ALX 20 脚架。
+///  48. 让 20x1mm 玩具枪与其原装弹匣在保留 20x1mm 能力的同时支持全部 7 种 7.62x25 托卡列夫弹药
+///      (只补膛室与弹匣装填位白名单,不动武器单值 ammoCaliber)。
+///  49. 让 Alpha Dog Alpha 9 9x19 声音抑制器的 mod_scope 槽支持安装 M14 SAGE International DCSB 瞄具基座。
 ///
 /// 做法:往目标槽的 SlotFilter.Filter(HashSet&lt;MongoId&gt;)追加物品 id(幂等)。
 /// </summary>
@@ -136,6 +139,10 @@ public class WeaponCrossModdingPlugin(
     // M14 SAGE International DCSB 瞄具基座。
     private const string M14DcsbMountId = "5addbffe5acfc4001714dfac";
 
+    // Alpha Dog Alpha 9 9x19 声音抑制器(其 mod_scope 槽承载 M14 DCSB 瞄具基座)。
+    private const string AlphaDogSuppressorId = "5a33a8ebc4a282000c5a950d";
+    private const string AlphaDogSuppressorLabel = "Alpha Dog 9x19 suppressor";
+
     // PPSh-41 防尘盖(mod_reciever 槽承载物品)。
     private const string Ppsh41DustCoverId = "5ea03e5009aa976f2e7a514b";
 
@@ -292,6 +299,25 @@ public class WeaponCrossModdingPlugin(
     // PPSh-41 7.62x25 71 发弹鼓。
     private const string Ppsh71DrumMagId = "5ea034f65aad6446a939737e";
 
+    // 20x1mm 玩具枪(weapon_ussr_pd_20x1mm)与其原装弹匣(mag_pd_ussr_toygun_std_20x1mm_18)。
+    // 实验性最小改法:只往膛室与弹匣装填位白名单追加 7.62x25,不动单值 ammoCaliber,故保留原 20x1mm 能力。
+    private const string ToyGunId = "66015072e9f84d5680039678";
+    private const string ToyGunMagId = "66015dc4aaad2f54cb04c56a";
+    private const string ToyGunLabel = "20x1mm toy gun";
+    private const string ToyGunMagLabel = "20x1mm toy gun magazine";
+
+    // 7.62x25 托卡列夫弹药(Caliber762x25TT)全部 7 种。
+    private static readonly (string Id, string Label)[] Caliber762x25Ammo =
+    [
+        ("5735fdcd2459776445391d61", "AKBS"),
+        ("5735ff5c245977640e39ba7e", "FMJ43"),
+        ("573601b42459776410737435", "LRN"),
+        ("573602322459776445391df1", "LRNPC"),
+        ("5736026a245977644601dc61", "P Gl"),
+        ("573603562459776430731618", "Pst gzh"),
+        ("573603c924597764442bd9cb", "T Gzh"),
+    ];
+
     // SKS / OP-SKS 照门固定环(mod_sight_rear 照门槽宿主)与 TKPD 导轨防尘盖(由 WTT 注入)。
     private const string SksRearSightBlockId = "634f04d82e5def262d0b30c6";
     private const string OpsksRearSightBlockId = "634f05a21f9f536910079b56";
@@ -507,6 +533,9 @@ public class WeaponCrossModdingPlugin(
             // Aim Sports“三轨”的瞄具槽:追加 M14 DCSB 瞄具基座。
             AddItemIdsToSlot(items, AimSportsTriRailId, AimSportsTriRailLabel, ScopeSlotName, M14DcsbMountId);
 
+            // Alpha Dog 9x19 声音抑制器的 mod_scope 槽:追加 M14 DCSB 瞄具基座。
+            AddItemIdsToSlot(items, AlphaDogSuppressorId, AlphaDogSuppressorLabel, ScopeSlotName, M14DcsbMountId);
+
             // Fab Defence UAS SKS 枪身套件的下导轨(mod_tactical_002):追加 MDR BLK LBL ALX 20 脚架与 AK-100 聚合物护木兼容的全部前握把。
             AddItemIdsToSlot(items, FabDefenceUasSksId, FabDefenceUasSksLabel, FabDefenceUasLowerRailSlotName, [AlxBipod20Id, .. Ak100PolymerHandguardForegripIds]);
 
@@ -530,6 +559,11 @@ public class WeaponCrossModdingPlugin(
             // MP-18 与 Marlin MXLR 的 mod_stock 枪托槽:追加 KS-23 金属枪托。
             AddItemIdsToSlot(items, Mp18RifleId, Mp18RifleLabel, StockSlotName, Ks23MetalStockId);
             AddItemIdsToSlot(items, MarlinMxlrId, MarlinMxlrLabel, StockSlotName, Ks23MetalStockId);
+
+            // 20x1mm 玩具枪与其原装弹匣:在原有 20x1mm 能力之上,追加 7.62x25 托卡列夫全部 7 种弹药。
+            // 只补 Chambers / Cartridges 白名单,不改 ammoCaliber;能否实际开火由实机验证判定。
+            AddAmmoIdsToContainer(items, ToyGunId, ToyGunLabel, isChamber: true, [.. Caliber762x25Ammo.Select(x => x.Id)]);
+            AddAmmoIdsToContainer(items, ToyGunMagId, ToyGunMagLabel, isChamber: false, [.. Caliber762x25Ammo.Select(x => x.Id)]);
         }
         catch (Exception ex)
         {
@@ -580,6 +614,48 @@ public class WeaponCrossModdingPlugin(
         }
     }
 
+    /// <summary>
+    /// 往 <paramref name="ownerId"/> 的膛室(Chambers)或弹匣装填位(Cartridges)各 Filter 追加弹药 id(幂等)。
+    /// 这两者都是 <see cref="Slot"/> 列表,其 <c>Properties.Filters[].Filter</c> 决定可容纳的弹药模板。
+    /// </summary>
+    private void AddAmmoIdsToContainer(
+        Dictionary<MongoId, TemplateItem> items,
+        string ownerId,
+        string ownerLabel,
+        bool isChamber,
+        params string[] ammoIds)
+    {
+        if (!items.TryGetValue(ownerId, out TemplateItem? owner))
+        {
+            logger.Warning($"WeaponCrossModding: {ownerLabel} id '{ownerId}' not found in Items");
+            return;
+        }
+
+        IEnumerable<Slot>? containers = isChamber ? owner.Properties?.Chambers : owner.Properties?.Cartridges;
+        if (containers is null)
+        {
+            logger.Warning($"WeaponCrossModding: {ownerLabel} has no {(isChamber ? "chambers" : "cartridges")}");
+            return;
+        }
+
+        foreach (Slot container in containers.Where(c => c is not null))
+        {
+            IEnumerable<SlotFilter>? filters = container.Properties?.Filters;
+            if (filters is null)
+            {
+                continue;
+            }
+
+            foreach (SlotFilter filter in filters)
+            {
+                foreach (string ammoId in ammoIds)
+                {
+                    AddToFilter(filter, ammoId, owner, container);
+                }
+            }
+        }
+    }
+
     /// <summary>
     /// 让 PPSh-41 防尘盖与 HUXWRX HX-QD 消音器(含黄褐色变体)互不兼容(幂等)。
     /// 防尘盖为原版物品、必定存在;消音器由 WTT-ContentBackport 注入,若不在 Items 中则跳过

+ 112 - 0
tests/WeaponCrossModding.Tests/ModTests.cs

@@ -136,6 +136,7 @@ public class WeaponCrossModdingPluginTests
     private const string StormwerkzLowerHandguardRailId = "66992f7d9950f5f4cd0602a8";
 
     private const string M14DcsbMountId = "5addbffe5acfc4001714dfac";
+    private const string AlphaDogSuppressorId = "5a33a8ebc4a282000c5a950d";
 
     private const string Sv98HeatRibbonId = "56083eab4bdc2d26448b456a";
     private const string FortisShiftForegripId = "59f8a37386f7747af3328f06";
@@ -155,6 +156,21 @@ public class WeaponCrossModdingPluginTests
     private const string MarlinMxlrId = "67c6de3ce39861860909e8e5";
     private const string Ks23MetalStockId = "5e848dc4e4dbc5266a4ec63d";
 
+    // 20x1mm 玩具枪、其原装弹匣与玩具弹,以及 7.62x25 托卡列夫全部 7 种弹药。
+    private const string ToyGunId = "66015072e9f84d5680039678";
+    private const string ToyGunMagId = "66015dc4aaad2f54cb04c56a";
+    private const string ToyAmmoId = "6601546f86889319850bd566";
+    private static readonly string[] Caliber762x25AmmoIds =
+    [
+        "5735fdcd2459776445391d61", // AKBS
+        "5735ff5c245977640e39ba7e", // FMJ43
+        "573601b42459776410737435", // LRN
+        "573602322459776445391df1", // LRNPC
+        "5736026a245977644601dc61", // P Gl
+        "573603562459776430731618", // Pst gzh
+        "573603c924597764442bd9cb", // T Gzh
+    ];
+
     // Marlin MXLR .308 ME 杠杆步枪 mod_stock 槽的真实初始 filter。
     private static readonly string[] MarlinMxlrStockIds =
     [
@@ -244,6 +260,31 @@ public class WeaponCrossModdingPluginTests
         Properties = new TemplateItemProperties { ConflictingItems = [] },
     };
 
+    // 构造带膛室(Chambers)或弹匣装填位(Cartridges)的物品;二者结构均为 Slot 过滤器列表。
+    private static TemplateItem ItemWithAmmoContainer(string name, bool isChamber, params string[] initialFilter)
+    {
+        var filter = new SlotFilter
+        {
+            Filter = new HashSet<MongoId>(initialFilter.Select(id => new MongoId(id))),
+        };
+        var container = new Slot
+        {
+            Name = isChamber ? "patron_in_weapon" : "cartridges",
+            Properties = new SlotProperties { Filters = [filter] },
+        };
+        return new TemplateItem
+        {
+            Name = name,
+            Properties = isChamber
+                ? new TemplateItemProperties { Chambers = [container] }
+                : new TemplateItemProperties { Cartridges = [container] },
+        };
+    }
+
+    private static HashSet<MongoId> AmmoFilterOf(TemplateItem item, bool isChamber) =>
+        (isChamber ? item.Properties!.Chambers! : item.Properties!.Cartridges!)
+            .Single().Properties!.Filters!.Single().Filter!;
+
     private static HashSet<MongoId> FilterOf(TemplateItem item, string slotName) =>
         item.Properties!.Slots!.Single(s => s.Name == slotName).Properties!.Filters!.Single().Filter!;
 
@@ -982,6 +1023,77 @@ public class WeaponCrossModdingPluginTests
         Assert.Contains(new MongoId(Ks23MetalStockId), fabStock.Properties!.ConflictingItems!);
     }
 
+    [Fact]
+    public async Task AddsCaliber762x25ToToyGunChambersKeeping20x1mm()
+    {
+        var gun = ItemWithAmmoContainer("weapon_ussr_pd_20x1mm", isChamber: true, ToyAmmoId);
+        gun.Properties!.AmmoCaliber = "Caliber20x1mm";
+        var items = new Dictionary<MongoId, TemplateItem> { [new MongoId(ToyGunId)] = gun };
+
+        await BuildPlugin(items).OnLoadAsync(CancellationToken.None);
+
+        var filter = AmmoFilterOf(gun, isChamber: true);
+        Assert.Contains(new MongoId(ToyAmmoId), filter);
+        foreach (string id in Caliber762x25AmmoIds)
+        {
+            Assert.Contains(new MongoId(id), filter);
+        }
+        Assert.Equal(1 + Caliber762x25AmmoIds.Length, filter.Count);
+
+        // 实验性最小改法:不动单值 ammoCaliber,仅补白名单,故 20x1mm 能力保留。
+        Assert.Equal("Caliber20x1mm", gun.Properties.AmmoCaliber);
+    }
+
+    [Fact]
+    public async Task AddsCaliber762x25ToToyGunMagazineCartridgesKeeping20x1mm()
+    {
+        var mag = ItemWithAmmoContainer("mag_pd_ussr_toygun_std_20x1mm_18", isChamber: false, ToyAmmoId);
+        var items = new Dictionary<MongoId, TemplateItem> { [new MongoId(ToyGunMagId)] = mag };
+
+        await BuildPlugin(items).OnLoadAsync(CancellationToken.None);
+
+        var filter = AmmoFilterOf(mag, isChamber: false);
+        Assert.Contains(new MongoId(ToyAmmoId), filter);
+        foreach (string id in Caliber762x25AmmoIds)
+        {
+            Assert.Contains(new MongoId(id), filter);
+        }
+        Assert.Equal(1 + Caliber762x25AmmoIds.Length, filter.Count);
+    }
+
+    [Fact]
+    public async Task ToyGunAmmoInjectionIsIdempotent()
+    {
+        var gun = ItemWithAmmoContainer("weapon_ussr_pd_20x1mm", isChamber: true, ToyAmmoId);
+        var mag = ItemWithAmmoContainer("mag_pd_ussr_toygun_std_20x1mm_18", isChamber: false, ToyAmmoId);
+        var items = new Dictionary<MongoId, TemplateItem>
+        {
+            [new MongoId(ToyGunId)] = gun,
+            [new MongoId(ToyGunMagId)] = mag,
+        };
+        var plugin = BuildPlugin(items);
+
+        await plugin.OnLoadAsync(CancellationToken.None);
+        await plugin.OnLoadAsync(CancellationToken.None);
+
+        Assert.Equal(1 + Caliber762x25AmmoIds.Length, AmmoFilterOf(gun, isChamber: true).Count);
+        Assert.Equal(1 + Caliber762x25AmmoIds.Length, AmmoFilterOf(mag, isChamber: false).Count);
+    }
+
+    [Fact]
+    public async Task AddsM14DcsbMountToAlphaDogScopeSlot()
+    {
+        var alphaDog = ItemWithSlot("silencer_all_alpha_dog_alpha_9_9x19", "mod_scope", "58d39d3d86f77445bb794ae7");
+        var items = new Dictionary<MongoId, TemplateItem> { [new MongoId(AlphaDogSuppressorId)] = alphaDog };
+
+        await BuildPlugin(items).OnLoadAsync(CancellationToken.None);
+
+        var filter = FilterOf(alphaDog, "mod_scope");
+        Assert.Contains(new MongoId("58d39d3d86f77445bb794ae7"), filter);
+        Assert.Contains(new MongoId(M14DcsbMountId), filter);
+        Assert.Equal(2, filter.Count);
+    }
+
     [Fact]
     public async Task MissingItemsDoNotThrow()
     {