Răsfoiți Sursa

【新增】让 AA-12 与 MP-18/MXLR 兼容 M60 脚架和 KS-23 枪托

新增 AA-12 457 mm 枪管导轨槽白名单 M60 脚架;新增 MP-18 与 Marlin MXLR 枪托槽白名单 KS-23 金属枪托。
PJ568 1 lună în urmă
părinte
comite
e6967b38b4

+ 2 - 2
README.md

@@ -16,7 +16,7 @@
 | CR 50DS 前准星槽与战术设备槽 | PPSh-41 枪管与枪托槽 |
 | --- | --- |
 | ![Chiappa 犀牛 50DS 左轮手枪](assets/50DS.webp) | ![PPSh-41 冲锋枪](assets/PPSh.webp) |
-| 前准星槽装瞄具基座;战术设备槽装 RK 系列前握把。 | 枪管槽装莫辛纳甘枪管并挂三轨;枪托槽装 M14ALCS (MOD-0) 枪托;730mm 莫辛枪管的准星槽可装 MDR BLK LBL ALX 脚架(16 / 20)。 |
+| 前准星槽装瞄具基座;战术设备槽装 RK 系列前握把。 | 枪管槽装莫辛纳甘枪管并挂三轨;枪托槽装 M14ALCS (MOD-0) 枪托;730mm 莫辛枪管的准星槽可装 MDR BLK LBL ALX 脚架(16 / 20);AA-12 457mm 枪管的导轨槽可装 M60 脚架,MP-18 与 Marlin MXLR 的枪托槽可装 KS-23 金属枪托。 |
 
 ## 文档
 
@@ -54,7 +54,7 @@ All injections are idempotent: an id already present is never added twice.
 | CR 50DS front sight and tactical slots | PPSh-41 barrel and stock slots |
 | --- | --- |
 | ![Chiappa Rhino 50DS revolver](assets/50DS.webp) | ![PPSh-41 SMG](assets/PPSh.webp) |
-| The front sight slot takes a scope base; the tactical slot takes an RK-series foregrip. | The barrel slot takes a Mosin barrel with the tri-rail mounted on it; the stock slot takes the M14ALCS (MOD-0) buttstock; the 730 mm Mosin barrel's front sight slot takes an MDR BLK LBL ALX bipod (16 / 20). |
+| The front sight slot takes a scope base; the tactical slot takes an RK-series foregrip. | The barrel slot takes a Mosin barrel with the tri-rail mounted on it; the stock slot takes the M14ALCS (MOD-0) buttstock; the 730 mm Mosin barrel's front sight slot takes an MDR BLK LBL ALX bipod (16 / 20); the AA-12 457 mm barrel's rail slot takes an M60 bipod, and the MP-18 and Marlin MXLR stock slots take a KS-23 metal stock. |
 
 ## Documentation
 

+ 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.2.0</Version>
-    <AssemblyVersion>0.2.0.0</AssemblyVersion>
-    <FileVersion>0.2.0.0</FileVersion>
+    <Version>0.3.0</Version>
+    <AssemblyVersion>0.3.0.0</AssemblyVersion>
+    <FileVersion>0.3.0.0</FileVersion>
     <AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
   </PropertyGroup>
 

+ 2 - 0
docs/compatibility.md

@@ -10,6 +10,7 @@
 - **`WTT-ContentBackport`**:部分物品由该模组注入,例如 HUXWRX HX-QD 7.62x51 消音器(黑 / 黄褐色)、Tyrant Designs MOD Chevron AR-15 镂空手枪式握把(黑 / 黄 / 红)以及 MDR BLK LBL ALX 脚架(16 与 20 型号)。
   - 这些物品作为**白名单新增项**时,插件只追加 id,不要求其存在,因此无论该模组是否安装都能正常加载。
   - 这些物品作为**冲突目标**时(HUXWRX 消音器),若其尚未注入,插件仅记 `Debug` 并跳过;由于 PPSh-41 防尘盖一侧的冲突记录仍会建立,互斥关系依旧成立,并避免了对第三方模组加载顺序的依赖。
+  - Marlin MXLR 杠杆步枪由该模组注入,且本插件将其用作**槽位宿主**(区别于仅作白名单新增项的其它 WTT 物品);若其未在本插件运行前注入,对应条目会记 `not found in Items` 警告并跳过。
 - 插件只改写物品数据库,不注册 Harmony patch,也不与客户端插件争抢运行时方法。
 
 ## 已知限制
@@ -43,6 +44,7 @@
 - **`WTT-ContentBackport`**: some items are injected by that mod, such as the HUXWRX HX-QD 7.62x51 suppressors (black / tan), the Tyrant Designs MOD Chevron AR-15 skeletonized pistol grips (black / yellow / red) and the MDR BLK LBL ALX bipods (16 and 20 models).
   - When these items are **whitelist additions**, the plugin only appends their ids and does not require them to exist, so it loads fine whether or not that mod is installed.
   - When these items are **conflict targets** (the HUXWRX suppressors), if they are not yet injected the plugin only logs `Debug` and skips; because the PPSh-41 dust cover side still records the conflict, the exclusion still holds, avoiding any dependency on third-party load order.
+  - The Marlin MXLR lever-action rifle is injected by that mod, and this plugin uses it as a **slot owner** (unlike other WTT items that are only whitelist additions); if it is not injected before this plugin runs, the affected entry logs a `not found in Items` warning and is skipped.
 - The plugin only rewrites the item database. It registers no Harmony patch and never contends with client plugins for runtime methods.
 
 ## Known Limitations

+ 4 - 0
docs/features.md

@@ -13,6 +13,8 @@
 - PPSh-41 冲锋枪的 `mod_barrel` 枪管槽:新增莫辛纳甘全部 4 种尺寸枪管(200mm 锯短、220mm 锯短螺纹、514mm 卡宾、730mm 标准)。
 - PPSh-41 冲锋枪的 `mod_stock` 枪托槽:新增 Benelli M3 可伸缩枪托、PKM 木制枪托、Zenit PT-2 "Klassika" PK 机枪枪托、PKP 聚合物枪托、Ultima MP-155 塑料手枪式握把、KS-23 金属枪托与 M14 SAGE International M14ALCS (MOD-0) 枪托。
 - 730mm 标准莫辛枪管的 `mod_sight_front` 前准星槽:新增 MDR BLK LBL ALX 脚架(16 与 20 型号,由 `WTT-ContentBackport` 注入;与莫辛准星共用同一槽位,二者互斥)。
+- AA-12 457mm 枪管的 `mod_mount` 导轨槽:新增 M60 脚架。
+- MP-18 与 Marlin MXLR 的 `mod_stock` 枪托槽:新增 KS-23 金属枪托。
 
 ## 握把与配件
 
@@ -43,6 +45,8 @@
 - `mod_barrel` slot of the PPSh-41: adds all four Mosin barrel lengths (200 mm sawn-off, 220 mm threaded sawn-off, 514 mm carbine, 730 mm standard).
 - `mod_stock` slot of the PPSh-41: adds the Benelli M3 telescopic stock, the PKM wooden stock, the Zenit PT-2 "Klassika" PK stock, the PKP polymer stock, the Ultima MP-155 plastic pistol grip, the KS-23 metal stock and the M14 SAGE International M14ALCS (MOD-0) buttstock.
 - `mod_sight_front` slot of the 730 mm standard Mosin barrel: adds the MDR BLK LBL ALX bipods (16 and 20 models, injected by `WTT-ContentBackport`; shared with the Mosin front sight, so the two are mutually exclusive).
+- `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.
 
 ## Grips and accessories
 

+ 2 - 2
docs/principle.md

@@ -10,7 +10,7 @@ SPT 服务端把所有物品模板存放在 `TemplateTable.Items`(`Dictionary<
 
 每个 `TemplateItem` 的 `Properties.Slots` 是一个 `Slot` 列表。每个 `Slot` 有:
 
-- `Name`:槽位名,如 `mod_scope`、`mod_sight_front`、`mod_barrel`、`mod_stock`、`mod_tactical`、`mod_tactical_000`、`mod_tactical_001`、`mod_pistol_grip`。
+- `Name`:槽位名,如 `mod_scope`、`mod_sight_front`、`mod_barrel`、`mod_stock`、`mod_tactical`、`mod_tactical_000`、`mod_tactical_001`、`mod_pistol_grip`、`mod_mount`。
 - `Properties.Filters`:`SlotFilter` 列表。
 - `SlotFilter.Filter`:`HashSet<MongoId>`,即该槽位允许安装的物品 id 白名单。
 
@@ -73,7 +73,7 @@ The SPT server stores every item template in `TemplateTable.Items` (`Dictionary<
 
 Each `TemplateItem`'s `Properties.Slots` is a list of `Slot`. Every `Slot` has:
 
-- `Name`: the slot name, such as `mod_scope`, `mod_sight_front`, `mod_barrel`, `mod_stock`, `mod_tactical`, `mod_tactical_000`, `mod_tactical_001`, `mod_pistol_grip`.
+- `Name`: the slot name, such as `mod_scope`, `mod_sight_front`, `mod_barrel`, `mod_stock`, `mod_tactical`, `mod_tactical_000`, `mod_tactical_001`, `mod_pistol_grip` and `mod_mount`.
 - `Properties.Filters`: a list of `SlotFilter`.
 - `SlotFilter.Filter`: a `HashSet<MongoId>`, the whitelist of item ids the slot accepts.
 

+ 6 - 2
docs/verification.md

@@ -14,7 +14,7 @@
 [Info][...] WeaponCrossModding: added '<物品 id>' to slot '<槽位名>' (<宿主物品名>)
 ```
 
-槽位名应涵盖 `mod_scope`、`mod_sight_front`、`mod_barrel`、`mod_stock`、`mod_tactical`、`mod_tactical_000`、`mod_tactical_001`、`mod_pistol_grip`;互斥关系另会输出 `added conflicting item '…' to '…'`。
+槽位名应涵盖 `mod_scope`、`mod_sight_front`、`mod_barrel`、`mod_stock`、`mod_tactical`、`mod_tactical_000`、`mod_tactical_001`、`mod_pistol_grip`、`mod_mount`;互斥关系另会输出 `added conflicting item '…' to '…'`。
 
 ## 验证步骤
 
@@ -25,6 +25,8 @@
    - 在 CR 200DS / CR 50DS 前准星槽安装 StormWerkz 顶盖导轨或 MP-18 瞄具基座;
    - 在 PPSh-41 上安装莫辛纳甘枪管或 M14ALCS (MOD-0) 枪托;
    - 在 730mm 标准莫辛枪管的前准星槽安装 MDR BLK LBL ALX 脚架(16 或 20 型号);
+   - 在 AA-12 457mm 枪管的导轨槽安装 M60 脚架;
+   - 在 MP-18 或 Marlin MXLR 的枪托槽安装 KS-23 金属枪托;
    - 尝试同时安装 PPSh-41 防尘盖与 HUXWRX HX-QD 消音器,确认二者互斥。
 4. 若修改了物品 id,重新运行单元测试确认夹具仍与代码一致。
 
@@ -54,7 +56,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_barrel`, `mod_stock`, `mod_tactical`, `mod_tactical_000`, `mod_tactical_001`, `mod_pistol_grip`; conflicts also print `added conflicting item '…' to '…'`.
+The slot names should cover `mod_scope`, `mod_sight_front`, `mod_barrel`, `mod_stock`, `mod_tactical`, `mod_tactical_000`, `mod_tactical_001`, `mod_pistol_grip`, `mod_mount`; conflicts also print `added conflicting item '…' to '…'`.
 
 ## Verification Steps
 
@@ -65,6 +67,8 @@ The slot names should cover `mod_scope`, `mod_sight_front`, `mod_barrel`, `mod_s
    - mount the StormWerkz top cover rail or MP-18 scope base on the CR 200DS / CR 50DS front sight slot;
    - mount a Mosin barrel or the M14ALCS (MOD-0) buttstock on the PPSh-41;
    - mount an MDR BLK LBL ALX bipod (16 or 20 model) on the front sight slot of the 730 mm standard Mosin barrel;
+   - mount an M60 bipod on the rail slot of the AA-12 457 mm barrel;
+   - mount a KS-23 metal stock on the stock slot of the MP-18 or Marlin MXLR;
    - try mounting the PPSh-41 dust cover and a HUXWRX HX-QD suppressor together and confirm they are mutually exclusive.
 4. If you changed any item id, re-run the unit tests to confirm the fixtures still match the code.
 

+ 25 - 0
src/Mod.cs

@@ -33,6 +33,8 @@ namespace Pj568.WeaponCrossModding;
 ///  15. 让 CR 50DS 转轮手枪的战术设备槽支持安装 Zenit RK 系列前握把、KAC MWS 脚架转接器
 ///      与 BT10 V8 Atlas 折叠脚架;
 ///  16. 让 730mm 标准莫辛枪管的前准星槽支持安装 MDR BLK LBL ALX 脚架(16 与 20 型号);
+///  17. 让 AA-12 457mm 枪管的导轨槽(mod_mount)支持安装 M60 脚架;
+///  18. 让 MP-18 与 Marlin MXLR 的枪托槽(mod_stock)支持安装 KS-23 金属枪托;
 ///
 /// 做法:往目标槽的 SlotFilter.Filter(HashSet&lt;MongoId&gt;)追加物品 id(幂等)。
 /// </summary>
@@ -46,6 +48,7 @@ public class WeaponCrossModdingPlugin(
     private const string BarrelSlotName = "mod_barrel";
     private const string StockSlotName = "mod_stock";
     private const string TacticalSlotName = "mod_tactical";
+    private const string MountSlotName = "mod_mount";
 
     // UZI StormWerkz 瞄具基座(顶盖导轨)
     private const string StormwerkzTopCoverRailId = "6698c90829e062525d0ad8ad";
@@ -157,6 +160,18 @@ public class WeaponCrossModdingPlugin(
     // AS VAL Rotor 43 手枪式握把附缓冲管转接器(自带 AR 规格缓冲管与 mod_stock_000 槽)。
     private const string AsValRotor43GripId = "5a69a2ed8dc32e000d46d1f1";
 
+    // AA-12 457mm 枪管(mod_mount 导轨槽宿主)。
+    private const string Aa12Barrel457Id = "670fced86a7e274b1a0964e8";
+
+    // MP-18 7.62x54R 单发步枪。
+    private const string Mp18RifleId = "61f7c9e189e6fb1a5e3ea78d";
+
+    // Marlin MXLR .308 ME 杠杆步枪(由 WTT-ContentBackport 注入)。
+    private const string MarlinMxlrId = "67c6de3ce39861860909e8e5";
+
+    // M60 脚架。
+    private const string M60BipodId = "66012d9a3dff5074ed002e33";
+
     // 日志中用于标识槽位承载者的短名。
     private const string MountLabel = "mount";
     private const string Cr200DsLabel = "CR 200DS";
@@ -164,6 +179,9 @@ public class WeaponCrossModdingPlugin(
     private const string Ppsh41Label = "PPSh-41";
     private const string M14ButtstockLabel = "M14ALCS (MOD-0) stock";
     private const string MosinBarrel730Label = "Mosin 730mm barrel";
+    private const string Aa12Barrel457Label = "AA-12 457mm barrel";
+    private const string Mp18RifleLabel = "MP-18 rifle";
+    private const string MarlinMxlrLabel = "Marlin MXLR";
 
     public Task OnLoadAsync(CancellationToken cancellationToken)
     {
@@ -214,6 +232,13 @@ public class WeaponCrossModdingPlugin(
 
             // UZI StormWerkz 护木底轨的 mod_tactical 槽:追加 Zenit RK 系列前握把。
             AddItemIdsToSlot(items, StormwerkzLowerHandguardRailId, StormwerkzLowerHandguardLabel, TacticalSlotName, ZenitRkForegripIds);
+
+            // AA-12 457mm 枪管的 mod_mount 导轨槽:追加 M60 脚架。
+            AddItemIdsToSlot(items, Aa12Barrel457Id, Aa12Barrel457Label, MountSlotName, M60BipodId);
+
+            // MP-18 与 Marlin MXLR 的 mod_stock 枪托槽:追加 KS-23 金属枪托。
+            AddItemIdsToSlot(items, Mp18RifleId, Mp18RifleLabel, StockSlotName, Ks23MetalStockId);
+            AddItemIdsToSlot(items, MarlinMxlrId, MarlinMxlrLabel, StockSlotName, Ks23MetalStockId);
         }
         catch (Exception ex)
         {

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

@@ -68,6 +68,26 @@ public class WeaponCrossModdingPluginTests
     private const string AlxBipod16Id = "680f6d9a4d7624d36e06527b";
     private const string AlxBipod20Id = "680f7e4aeee716732708e84e";
 
+    private const string Aa12457BarrelId = "670fced86a7e274b1a0964e8";
+    private const string Aa12MountExistingId = "6710cea62bb09af72f0e6bf8";
+    private const string M60BipodId = "66012d9a3dff5074ed002e33";
+    private const string Mp18RifleId = "61f7c9e189e6fb1a5e3ea78d";
+    private const string Mp18StockExistingAId = "61f803b8ced75b2e852e35f8";
+    private const string Mp18StockExistingBId = "61f7b234ea4ab34f2f59c3ec";
+    private const string MarlinMxlrId = "67c6de3ce39861860909e8e5";
+    private const string Ks23MetalStockId = "5e848dc4e4dbc5266a4ec63d";
+
+    // Marlin MXLR .308 ME 杠杆步枪 mod_stock 槽的真实初始 filter。
+    private static readonly string[] MarlinMxlrStockIds =
+    [
+        "67c541ba5b84f7f36c03e555",
+        "67c541ca26265106dd0697a0",
+        "67c541d45b84f7f36c03e557",
+        "67ff1f9f32abb9a4280b5178",
+        "67ff1fa88e8db1dcb80ccada",
+        "67ff2c16c593c7b94a095e56",
+    ];
+
     // 与 src/Mod.cs 对应:M14ALCS (MOD-0) 枪托握把位的新增握把。
     private static readonly string[] M14AlcsPistolGripCompatIds =
     [
@@ -375,6 +395,53 @@ public class WeaponCrossModdingPluginTests
         Assert.Contains(new MongoId(M14DcsbMountId), filter);
     }
 
+    [Fact]
+    public async Task AddsM60BipodToAa12457BarrelMountSlot()
+    {
+        var barrel = ItemWithSlot("barrel_aa12_457mm", "mod_mount", Aa12MountExistingId);
+        var items = new Dictionary<MongoId, TemplateItem> { [new MongoId(Aa12457BarrelId)] = barrel };
+
+        await BuildPlugin(items).OnLoadAsync(CancellationToken.None);
+
+        var filter = FilterOf(barrel, "mod_mount");
+        Assert.Contains(new MongoId(Aa12MountExistingId), filter);
+        Assert.Contains(new MongoId(M60BipodId), filter);
+        Assert.Equal(2, filter.Count);
+    }
+
+    [Fact]
+    public async Task AddsKs23StockToMp18StockSlot()
+    {
+        var rifle = ItemWithSlot("weapon_mp18_762x54r", "mod_stock", Mp18StockExistingAId, Mp18StockExistingBId);
+        var items = new Dictionary<MongoId, TemplateItem> { [new MongoId(Mp18RifleId)] = rifle };
+
+        await BuildPlugin(items).OnLoadAsync(CancellationToken.None);
+
+        var filter = FilterOf(rifle, "mod_stock");
+        Assert.Contains(new MongoId(Mp18StockExistingAId), filter);
+        Assert.Contains(new MongoId(Mp18StockExistingBId), filter);
+        Assert.Contains(new MongoId(Ks23MetalStockId), filter);
+        Assert.Equal(3, filter.Count);
+    }
+
+    [Fact]
+    public async Task AddsKs23StockToMarlinMxlrStockSlot()
+    {
+        var rifle = ItemWithSlot("weapon_marlin_mxlr_308", "mod_stock", MarlinMxlrStockIds);
+        var items = new Dictionary<MongoId, TemplateItem> { [new MongoId(MarlinMxlrId)] = rifle };
+
+        await BuildPlugin(items).OnLoadAsync(CancellationToken.None);
+
+        var filter = FilterOf(rifle, "mod_stock");
+        foreach (var id in MarlinMxlrStockIds)
+        {
+            Assert.Contains(new MongoId(id), filter);
+        }
+
+        Assert.Contains(new MongoId(Ks23MetalStockId), filter);
+        Assert.Equal(MarlinMxlrStockIds.Length + 1, filter.Count);
+    }
+
     [Fact]
     public async Task MissingItemsDoNotThrow()
     {