# 七日杀 XML Mod 制作完整技能指南
七日杀安装目录必须先从当前工作区、用户提供路径或 Steam 库中确认。以下统一用 $GameRoot 表示游戏根目录:
$GameRoot
常见确认方式:
# 如果当前工作目录已经在七日杀目录内,优先使用当前目录
$GameRoot = (Get-Location).Path
# 或由用户明确提供
$GameRoot = "<用户提供的七日杀安装目录>"
# 或从常见 Steam libraryfolders.vdf 中确认库目录后再拼接 steamapps\common\7 Days To Die
# 注意:不同玩家可能在任意盘符、任意 Steam 库,不得写死路径。
# 校验是否是有效游戏根目录
Test-Path (Join-Path $GameRoot "Data\Config")
Test-Path (Join-Path $GameRoot "7DaysToDie_Data\Managed")
所有原版 XML、注释说明、可用词条、Buff 属性、触发器和 DLL 都必须从当前玩家实际安装目录读取,不得凭记忆编造。不要假设游戏一定安装在 C 盘或某个固定盘符。
原版配置目录由 $GameRoot 拼出:
$GameRoot\Data\Config
常用原版 XML 文件:
| 文件 | 主要用途 |
|---|---|
| ----- | --------- |
buffs.xml | Buff、属性、触发器、效果组、需求条件 |
items.xml | 物品、武器、工具、消耗品 |
blocks.xml | 方块、形状、碰撞、材质关联 |
recipes.xml | 配方、解锁、材料消耗 |
loot.xml | 战利品组、概率、掉落表 |
progression.xml | 技能、书籍、职业、等级进度 |
entityclasses.xml | 实体、僵尸、动物、玩家实体属性 |
entitygroups.xml | 实体组和刷新引用 |
traders.xml | 商人、商品组、阶段限制 |
Localization.txt | 本地化键和值 |
制作 XML 前必须先搜索原版是否存在对应标签、属性、值、action、trigger、requirement 或枚举。
# 搜索某个 XML 词条是否在原版出现过
Select-String -Path (Join-Path $GameRoot "Data\Config\*.xml") -Pattern "triggered_effect|passive_effect|ModifyCVar|onSelfBuffStart"
# 查询某个被动属性是否存在
Select-String -LiteralPath (Join-Path $GameRoot "Data\Config\buffs.xml") -Pattern 'name="RunSpeed"'
# 查询某个触发器是否存在
Select-String -LiteralPath (Join-Path $GameRoot "Data\Config\buffs.xml") -Pattern 'trigger="onSelfBuffStart"'
除非用户明确允许,否则不得自创任何 XML 词条。
这里的“XML 词条”包括但不限于:
| 类型 | 示例 | 规则 |
|---|---|---|
| ----- | ------ | ------ |
| 标签名 | buff、effect_group、passive_effect | 必须原版出现过 |
| 属性名 | name、operation、value、tags | 必须原版出现过 |
| 属性值枚举 | base_add、perc_set、onSelfBuffStart | 必须原版出现过 |
| action | ModifyCVar、AddBuff、RemoveBuff | 必须原版出现过 |
| trigger | onSelfBuffStart、onSelfBuffUpdate | 必须原版出现过 |
| requirement | CVarCompare、HasBuff | 必须原版出现过 |
| passive_effect name | RunSpeed、EntityDamage | 必须原版出现过 |
<!-- 错误:未确认原版存在 SuperRunSpeed、onSelfJumpTwice、DoMagicDamage -->
<passive_effect name="SuperRunSpeed" operation="base_add" value="2"/>
<triggered_effect trigger="onSelfJumpTwice" action="DoMagicDamage"/>
<!-- 正确:RunSpeed、base_add、onSelfBuffStart、ModifyCVar 都应先在原版 XML 中确认存在 -->
<passive_effect name="RunSpeed" operation="base_add" value="0.2"/>
<triggered_effect trigger="onSelfBuffStart" action="ModifyCVar" cvar="$example" operation="set" value="1"/>
每次制作 XML 都按以下流程执行:
用户需求
↓
定位相关原版 XML 文件
↓
搜索原版标签、属性、属性值和引用方式
↓
复制原版写法作为模板
↓
只修改必要数值或引用
↓
写入 Modlet Config XML
↓
检查 XPath 和 XML 格式
默认只制作 Modlet,不直接修改 Data\Config 下的原版文件。
原版 XML 只用于读取和比对,Mod 文件应放入:
$GameRoot\Mods\你的Mod名\Config
buffs.xml 内注释已经给全游戏属性和游戏触发器说明。
处理 Buff 相关需求时,必须优先读取:
$GameRoot\Data\Config\buffs.xml
重点查找内容:
| 内容 | 查询目标 |
|---|---|
| ----- | --------- |
| 游戏属性 | passive_effect name="..." 以及 Buff 文件注释 |
| 游戏触发器 | triggered_effect trigger="..." 以及 Buff 文件注释 |
| 触发动作 | triggered_effect action="..." |
| 条件判断 | requirement name="..." |
| 运算方式 | operation="..." |
被动属性必须使用原版已经出现过的 passive_effect 名称和 operation。
<effect_group>
<passive_effect name="RunSpeed" operation="base_add" value="0.1"/>
<passive_effect name="EntityDamage" operation="perc_add" value="0.2" tags="melee"/>
</effect_group>
写作前检查:
Select-String -LiteralPath (Join-Path $GameRoot "Data\Config\buffs.xml") -Pattern 'passive_effect name="RunSpeed"'
Select-String -LiteralPath (Join-Path $GameRoot "Data\Config\buffs.xml") -Pattern 'operation="base_add"'
触发器和 action 必须使用 buffs.xml 注释或正文中已经出现过的内容。
<effect_group>
<triggered_effect trigger="onSelfBuffStart" action="ModifyCVar" cvar="$example" operation="set" value="1"/>
<triggered_effect trigger="onSelfBuffRemove" action="RemoveCVar" cvar="$example"/>
</effect_group>
写作前检查:
Select-String -LiteralPath (Join-Path $GameRoot "Data\Config\buffs.xml") -Pattern 'trigger="onSelfBuffStart"'
Select-String -LiteralPath (Join-Path $GameRoot "Data\Config\buffs.xml") -Pattern 'action="ModifyCVar"'
requirement 的 name、operation、属性组合必须从原版复制或确认。
<triggered_effect trigger="onSelfBuffUpdate" action="ModifyCVar" cvar="$example" operation="add" value="1">
<requirement name="CVarCompare" cvar="$example" operation="LT" value="10"/>
</triggered_effect>
推荐 Modlet 结构:
Mods\ExampleMod
├── ModInfo.xml
└── Config
├── buffs.xml
├── items.xml
├── blocks.xml
└── recipes.xml
<?xml version="1.0" encoding="UTF-8"?>
<xml>
<Name value="ExampleMod"/>
<DisplayName value="Example Mod"/>
<Description value="Example 7 Days To Die XML modlet."/>
<Author value="Codex"/>
<Version value="1.0.0"/>
</xml>
七日杀 Modlet 通常使用 XPath 补丁方式修改原版 XML。
<?xml version="1.0" encoding="UTF-8"?>
<configs>
<append xpath="/buffs">
<buff name="exampleBuff">
<stack_type value="ignore"/>
<duration value="10"/>
<effect_group>
<passive_effect name="RunSpeed" operation="base_add" value="0.1"/>
</effect_group>
</buff>
</append>
</configs>
注意:即使使用模板,也必须先确认其中每个标签、属性、属性值在原版中存在。若用户没有允许新增业务 name,则不要新增 exampleBuff 这类新命名词条。
XPath 补丁应尽量精确,避免影响无关节点。
<!-- 精确修改某个 buff 的 duration -->
<set xpath="/buffs/buff[@name='buffDrugSteroids']/duration/@value">600</set>
<!-- 精确追加到某个 buff 的 effect_group -->
<append xpath="/buffs/buff[@name='buffDrugSteroids']/effect_group">
<passive_effect name="RunSpeed" operation="base_add" value="0.1"/>
</append>
原版翻译文件是 Localization.txt,路径由 $GameRoot 拼出:
$GameRoot\Data\Config\Localization.txt
凡是 XML 中出现 name_key、description_key、tooltip_key、display_value_key、物品显示名、方块显示名、Buff 显示名等本地化键,都必须同步检查或补充翻译文件。
Localization.txt 是 CSV 格式,原版表头为:
Key,File,Type,UsedInMainMenu,NoTranslate,english,Context / Alternate Text,german,spanish,french,italian,japanese,koreana,polish,brazilian,russian,turkish,schinese,tchinese
新增翻译行必须保持同样列顺序,不得随意删列、换列或改表头。
参考原版 Buff 翻译行:
buffExampleName,buffs,Buff,,x,Example Buff,,,,,,,,,,,,示例 Buff,範例 Buff
buffExampleDesc,buffs,Buff,,x,Example description.,,,,,,,,,,,,示例描述。,範例描述。
buffExampleTooltip,buffs,Buff,,x,Example tooltip.,,,,,,,,,,,,示例提示。,範例提示。
列含义:
| 列 | 说明 |
|---|---|
| ---- | ------ |
Key | XML 中引用的本地化键,例如 name_key |
File | 来源文件分类,例如 buffs、items、blocks、recipes |
Type | 类型,例如 Buff、Item、Block、mod |
UsedInMainMenu | 原版多数为空,除非原版相同场景有用法 |
NoTranslate | 原版常用 x,表示不交给翻译流程处理 |
english | 英文文本 |
schinese | 简体中文文本 |
tchinese | 繁体中文文本 |
XML 中只写 key,不直接写显示文本。
<buff name="exampleBuff" name_key="buffExampleName" description_key="buffExampleDesc" tooltip_key="buffExampleTooltip">
<display_value_key value="buffExampleShort"/>
</buff>
对应翻译文件需要补充:
buffExampleName,buffs,Buff,,x,Example Buff,,,,,,,,,,,,示例 Buff,範例 Buff
buffExampleDesc,buffs,Buff,,x,Example description.,,,,,,,,,,,,示例描述。,範例描述。
buffExampleTooltip,buffs,Buff,,x,Example tooltip.,,,,,,,,,,,,示例提示。,範例提示。
buffExampleShort,buffs,Buff,,x,Example,,,,,,,,,,,,示例,範例
Modlet 需要翻译时,应在 Mod 目录中提供自己的 Config\Localization.txt,不要直接修改原版翻译文件。
推荐结构:
Mods\ExampleMod
├── ModInfo.xml
└── Config
├── buffs.xml
└── Localization.txt
Localization.txt,复制相同领域的行格式。Key 必须和 XML 中的 name_key、description_key、tooltip_key、display_value_key 完全一致。File 和 Type 必须参考原版同类条目,不确定时先搜索相似 key。\n,不要直接写真实换行破坏 CSV 行。Data\Config\Localization.txt。当前玩家实际安装目录的原版托管 DLL 位于:
$GameRoot\7DaysToDie_Data\Managed
常用 DLL:
| DLL | 用途 |
|---|---|
| ----- | ------ |
Assembly-CSharp.dll | 游戏主要 C# 逻辑,查询类、枚举、XML 解析逻辑 |
Assembly-CSharp-firstpass.dll | firstpass 编译程序集 |
UnityEngine*.dll | Unity 引擎相关 API |
XUi*.dll | 游戏 UI 系统相关程序集 |
如果安装了 Dedicated Server,优先检查:
$GameRoot\7DaysToDieServer_Data\Managed
不存在该目录时,说明当前目录主要是客户端安装,不要假设服务器 DLL 存在。
$GameRoot = "<用户提供或已确认的七日杀安装目录>"
$ClientManaged = Join-Path $GameRoot "7DaysToDie_Data\Managed"
$ServerManaged = Join-Path $GameRoot "7DaysToDieServer_Data\Managed"
Get-ChildItem -LiteralPath $ClientManaged -Filter *.dll |
Select-Object FullName
if (Test-Path -LiteralPath $ServerManaged) {
Get-ChildItem -LiteralPath $ServerManaged -Filter *.dll |
Select-Object FullName
}
读取 DLL 仅用于确认原版类型、枚举、字段和 XML 解析逻辑。
推荐工具:
| 工具 | 用途 |
|---|---|
| ----- | ------ |
| ILSpy | 读取 C# 反编译源码 |
| dnSpyEx | 搜索类、方法、字符串、枚举 |
| dotPeek | 辅助浏览程序集 |
原则:
明确需求
↓
确认目标 XML 文件
↓
搜索原版相似实现
↓
确认标签、属性、枚举、Buff 属性、触发器
↓
编写最小 XPath 补丁
↓
检查 XML 格式和 XPath 命中范围
↓
启动游戏或服务器验证日志
Data\Config\buffs.xml,确认 Buff 属性、触发器、action、requirement。items.xml,方块搜 blocks.xml。Data\Config\*.xml,确认跨文件引用方式。7DaysToDie_Data\Managed 下 DLL。| 场景 | 推荐做法 |
|---|---|
| ----- | --------- |
| 修改数值 | 使用 精确定位属性 |
| 添加效果 | 使用 追加到明确节点 |
| 移除内容 | 使用 精确匹配完整 XPath |
| 替换结构 | 优先拆成 remove + append,并说明原因 |
| 多文件联动 | 每个 XML 文件单独放在 Config 下对应文件名 |
buffs.xml 注释或正文。Data\Config。Config\Localization.txt。共 1 个版本