本文与游戏《求生之路2》有关。点击这里查看更多信息。
这篇条目有关 Source引擎。如需详情,点击这里。

Zh/L4D2 Campaign Add-on Tutorial: Difference between revisions

From Valve Developer Community
< Zh
Jump to navigation Jump to search
(持续汉化中...)
 
m (obsolete language category)
 
(18 intermediate revisions by 5 users not shown)
Line 1: Line 1:
{{otherlang2
{{LanguageBar|title = L4D2自制战役打包教程}}
|en=L4D2 Campaign Add-on Tutorial
{{l4D2 topicon|suf=:zh-cn}}{{source topicon|suf=:zh-cn}}{{ACategory|Left 4 Dead 2}}{{ACategory|Tutorials}}
|ru=L4D2 Campaign Add-on Tutorial:ru
本简体中文页面由 [[User:GlrWere|Gloria]] 汉化。
}}
本简体中文页面由 [[User:GlrWere|Gloria]] 汉化(W.I.P.)。


{{toc-right}}
{{toc-right}}
Line 18: Line 16:
== 安装开发工具 ==
== 安装开发工具 ==


为了创作求生之路2的三方内容,你需要安装[[Authoring Tools/SDK (Left 4 Dead 2)|求生之路2开发工具(Left 4 Dead 2 Authoring Tools)]]。它提供了用于创作游戏内容的各类程序与工具。一般来说,可以使用 [[Hammer]] 程序创建关卡,使用其它工具创建自定义[[textures|纹理]][[model|模型]]
为了创作求生之路2的三方内容,你需要安装{{L|Authoring Tools/SDK (Left 4 Dead 2)|求生之路2开发工具(Left 4 Dead 2 Authoring Tools)}}。它提供了用于创作游戏内容的各类程序与工具。一般来说,可以使用 {{L|Hammer}} 程序创建关卡,使用其它工具创建自定义{{L|textures|纹理}}{{L|model|模型}}


如何创建各类游戏资源不在这个教程的介绍范围之内。你可以进入[[L4D关卡制作基础教程]]找到相关的内容。介于这篇教程的重点在于讲解如何将所有地图内容打包到VPK中,因此当你开始学习这篇教程之前,应该已经熟悉了如何创建那些游戏内容。
如何创建各类游戏资源不在这个教程的介绍范围之内。你可以进入{{L|L4D关卡制作基础教程}}找到相关的内容。介于这篇教程的重点在于讲解如何将所有地图内容打包到VPK中,因此当你开始学习这篇教程之前,应该已经熟悉了如何创建那些游戏内容。


开发工具附带了一个叫做 Dead Line 的战役示例,包含了各类源文件示例。
开发工具附带了一个叫做 Dead Line 的战役示例,包含了各类源文件示例。
Line 30: Line 28:
  C:\Program Files\Steam\steamapps\common\left 4 dead 2\left4dead2\addons
  C:\Program Files\Steam\steamapps\common\left 4 dead 2\left4dead2\addons


{{note:zh-cn|如果你的文件夹是带连字符的,例如“'''add-ons'''”,确认它如果是空的就可以直接删除。正确的名称应该是不带连字符的“'''addons'''”。}}
{{note|如果你的文件夹是带连字符的,例如“'''add-ons'''”,确认它如果是空的就可以直接删除。正确的名称应该是不带连字符的“'''addons'''”。}}


注意:你的L4D2开发工具安装后可能并没有 'addons' 文件夹
注意:你的L4D2开发工具安装后可能并没有 'addons' 文件夹


在 'addons' 中创建一个新的文件夹,并取个合适的名称。这将会是你最后创建并发布的VPK文件名称。 so it's good practice to avoid spaces and use all lowercase letters. You may also include the game in the title, to differentiate it from add-ons for other titles, and optionally a version number. We'll use "deadline" instead of "l4d_deadline" for our example for the sake of readability.
在 'addons' 中创建一个新的文件夹,并取个合适的名称。这将会是你最后创建并发布的VPK文件名称。全部使用小写字母、避免使用空格是一个好习惯。你还可以将游戏名写入标题,同其它标题加以区分,并可以考虑添加一个版本号。为了便于阅读,我们的示例中还是使用了“deadline”而非“l4d_deadline”。


  ...\left4dead2\addons\deadline2
  ...\left4dead2\addons\deadline2


Conceptually, this add-on folder will serve as the base “game” folder for your assets, and will mirror the layout in the shipped .VPK files as we shall see below.
概念上来说,这个文件夹就相当于地图的游戏根目录,它的目录结构是下面将要介绍的用于发布的 .VPK 文件的镜像。


== Create primary game assets ==
== 创建基础游戏资源 ==


The assets you create will essentially append those shipped with the game. For a campaign, the primary assets are the .BSP and .NAV files for your map levels.
你创建的这些内容实际上将会与其它内容一块附加到游戏中。对于一张战役图来说,最基本的地图资源是 .BSP 文件和 .NAV 文件。


Make a folder called '<code>maps</code>' inside your add-on project folder:
在你的工程文件夹下新建一个 '<code>maps</code>' 文件夹:


  ...\left4dead2\addons\deadline2\maps
  ...\left4dead2\addons\deadline2\maps


Into this maps folder, copy the .BSP and .NAV files you're using for your maps. For this Dead Line tutorial example, there are three map file bsp.nav pairs:
在这个 maps 文件夹中,将你地图的 .BSP 文件和 .NAV 文件复制到这里。在 Dead Line 教程示例中,有两组 bsp/nav 地图文件:


{| {{standard-table}}
{| {{standard-table}}
|-
|-
! File
! 文件
! Description
! 描述
|-
|-
| <code>l4d_deadline01</code>  
| <code>l4d_deadline01</code>  
| Minimal starting map for co-op, versus
| 精简的初始地图,包含合作、对抗
|-
|-
| <code>l4d_deadline02</code>  
| <code>l4d_deadline02</code>  
| Final map for co-op, versus, survival, scavenge
| 最终的地图,包括合作、对抗、生存、清道夫
|}
|}


The advantage of having a single map function for multiple game modes is size reduction, which can be worth the additional authoring complexity.
在一张单独的地图中制作多种游戏模式的优点在于可以节省空间,尽管增加了制作复杂度,这样做还是值得的。


You may also optionally create custom .VTF texture images, custom .VMT material description files, and custom .MDL models which your maps can utilize. In order to keep the size of your add-on small, it's advisable to use as many textures and models from the game as possible.
你还可以创建并在地图中使用自定义的 .VTF 纹理文件、自定义的 .VMT 材质描述文件、以及自定义的 .MDL 模型文件。为了减小VPK包的体积,建议你尽可能多地使用游戏自带的纹理。


Additional .VMT and .VTF materials (see [[Creating a Material]]) should go under this folder:
额外的 .VMT .VTF 文件(见{{L|Creating a Material|自定义材质教程}})应该放在下面的文件夹中:


  ...\left4dead2\addons\deadline2\materials
  ...\left4dead2\addons\deadline2\materials


.MDL and related model files (see [[Exporting a model|exporting]] and [[compiling a model]]) should go under here:
文件与相关的模型文件(见{{L|Exporting a model|导出模型}}和{{L|compiling a model|编译模型}})应该放在下面的文件夹中:


  ...\left4dead2\addons\deadline2\models
  ...\left4dead2\addons\deadline2\models


{{note|Since "The Sacrifice" update, model .[[VTX|vtx files]] are no longer renamed when packed. For example, packing a .dx90.vtx file no longer renames to simply .vtx. All official files that were .vtx files have reverted back to .dx90.vtx.  Campaigns with custom models that were released prior to the update will be invisible in-game. Before the October 2010 update, a campaign would crash if .sw.vtx and .dx80.vtx were included for packing.}}
{{note|从“牺牲”更新开始,模型的 .{{L|VTX|vtx 文件}}在打包时将不再被重命名。例如,打包一个 .dx90.vtx 文件将不再被重命名成简单的 .vtx。所有原本是 .vtx 的官方文件都转换回了 .dx90.vtx 文件。在此更新之前发布的某些带自定义模型的战役中,模型在游戏中会变得不可见。在2010年10月的更新之前,包含了 .sw.vtx .dx80.vtx 文件的战役在打包时会崩溃。}}


And materials for your models should go under here:
模型的材质文件放在下面的文件夹中:


  ...\left4dead2\addons\deadline2\materials\models
  ...\left4dead2\addons\deadline2\materials\models


It should be noted that L4D2 treats the /deadline2 folder much the same way as the /left4dead folder, so any folders you use inside the /materials and /models that you employ must also be present in your campaign's folder.
需要注意的是,L4D2将 /deadline2 文件夹的内容当作 /left4dead 的内容一样处理,因此如果你使用了 /materials /models 下的任何纹理与模型,都应该在你的战役文件夹中添加一份。


== Create secondary game assets ==
== 创建次要游戏资源 ==


Secondary assets such as poster and thumbnail images are not strictly required, but they can give your campaigns an extra level of polish. (Besides, the poster/concept art was likely the first thing you created, wasn't it?) If you haven't already, go ahead and make a <code>materials</code> folder and a <code>vgui</code> folder inside of it:
次要的游戏资源例如海报与缩略图并不是必要的,但它们能让你的战役更加出彩。(再说了,海报/概念图恐怕是你头一项制作的东西,不是吗?)如果还没有制作的话,新建一个 <code>materials</code> 文件夹,并在其中创建一个 <code>vgui</code> 文件夹:


  ...\left4dead2\addons\deadline2\materials\vgui
  ...\left4dead2\addons\deadline2\materials\vgui


==== Campaign Poster ====
==== 地图战役海报 ====


Inside the vgui folder you'll want to place at least two .VTF files, along with .VMTs that reference them:
vgui 文件夹下需要放置两个 .VTF 文件,以及两个引用它们的 .VMT 文件:


; LoadingScreen_DeadLine2.vtf : This is a poster image that is displayed while your campaign loads. Standard size is 1024 x 1024 pixels with an alpha channel for transparency.
; LoadingScreen_DeadLine2.vtf : 这是一张在你的战役加载界面出现的海报图片。标准的尺寸为1024×1024像素,并带有表示透明度的Alpha通道。
; OutroTitle_DeadLine2.vtf : This is a title image that appears behind the end credits/stats. Standard size is 1024 x 256 pixels. Your design should look good against a black background and also allow white text in the foreground to be readable.
; OutroTitle_DeadLine2.vtf : 这是一张在关卡最后的鸣谢/数据统计界面出现的标题图片。标准的尺寸为1024×256像素。你创作的图片应该适合显示在黑色背景下,并且让上方滚动的白色文字易于阅读。


==== Map Thumbnail Previews ====
==== 地图缩略预览图 ====


In addition to these two, you'll also want to make thumbnail images for each map in your campaign. These serve to provide a visual reinforcement indication for users while they're selecting map "chapters" in the UI.
除了上述两张图片之外,你还要有展示战役每一关的缩略图。这些图片能让玩家在游戏大厅中选择地图“章节”时有可见的、更直观的提示。


To do so, create a new folder named '<code>maps</code>' under the vgui folder:
为了添加缩略图,在 vgui 文件夹下新建一个 '<code>maps</code>' 文件夹:


  ...\left4dead2\addons\deadline2\materials\vgui\maps
  ...\left4dead2\addons\deadline2\materials\vgui\maps


In this folder, you'll want to create a .VTF/.VMT pair for each map you wish to create. They should each be 256 by 128 pixels. If appropriate, you may use a single thumbnail image to represent multiple .BSP maps, such as when you have a versus or survival variant of the same level.
在这个文件夹中,为每一张地图创建 VTF/VMT 缩略图。它们的尺寸均为256×128像素。在合适的情况下,也可以使用一张缩略图表示多个 .BSP 地图,例如既用于对抗又用于生存的一关。


.VMT files which are used for interface elements such as posters, thumbnails, etc., (I.e. Those typically found in the materials/vgui folder,) often need to specify an '''UnlitGeneric''' material. See [[Deadline vgui .VMT File]] for an example.
用于界面元素的 .VMT 文件例如战役海报、缩略图等(也就是通常放在 material/vgui 文件夹中的那些文件)一般需要指定为“'''UnlitGeneric'''”材质。 见 {{L|Deadline vgui .VMT File}} 示例。


=== Creating a sound.cache file ===
=== 创建音频缓冲文件 ===


If you wish to have custom sounds in your add-on, you need to build an audio cache file that the engine uses to load your sounds.  Place your sounds in a "sound" folder in your add-on directory, then while Left 4 Dead 2 is running enter the command "snd_buildsoundcachefordirectory <path>" with the path of your sound folder.  For example, in the Deadline example, we would place sounds in:
如果在你的 add-on 中包含了自定义音频,你需要创建游戏引擎可以加载的音频缓冲文件。在VPK根目录下的“sound”文件夹放置你的音频文件,在L4D2运行时输入指令“snd_buildsoundcachefordirectory <path>”,其中path表示你放置音频的文件夹位置。例如,在 Deadline 示例中,音频文件放置在:


  ..\left4dead2\addons\deadline2\sound
  ..\left4dead2\addons\deadline2\sound


Then rebuild it with:
使用下面的指令进行重建:


  snd_buildsoundcachefordirectory "..\left4dead2\addons\deadline2"
  snd_buildsoundcachefordirectory "..\left4dead2\addons\deadline2"


This will generate a sound.cache file in the sound folder that you should include when building your VPK file.
这条指令将会在你的音频文件夹中创建一个 sound.cache 文件,在打包VPK时可以添加进去。


== Create metadata files ==
== 创建元数据文件 ==


There are a few more files that you will make in order to allow your add-on content to function in game.
此外还需要一些文件才能保证你的附件能够在游戏中正常工作。


==== addoninfo.txt ====
==== addoninfo.txt ====


The first is the addoninfo.txt file. This allows your content to be recognized by the game. It should go inside your add-on root folder, which was the first one we created way back at the top:
首先是 addoninfo.txt 文件。该文件让你的内容能被游戏识别。它应该放在VPK的根目录中,也就是上面最开始创建的文件夹:


  ...\left4dead2\addons\deadline2\addoninfo.txt
  ...\left4dead2\addons\deadline2\addoninfo.txt


This file is used by the game in the Extras-&gt;Add-ons screen. It describes your add-on in general and what it provides. The example [[Deadline AddonInfo File]] includes full comments and instructions for using it as a template for your own add-on.
这个文件用在游戏中的Add-ons界面。文件简要地描述了 add-on 中提供了什么内容。示例文件 {{L|Deadline AddonInfo File}} 中包含了完整的注释与使用说明,可以直接拿来作为你的 add-on 模板。


==== addonimage.jpg ====
==== addonimage.jpg ====


Another file you can create in the root folder is an image named addonimage.jpg. This serves as an icon to help differentiate your add-on and is displayed when an add-on is selected in the UI along with add-on details listed in the addoninfo.txt. Some JPG files may not work, depending on which application they are saved from. If you're having trouble getting you JPG to work, try exporting it from [[VTFEdit]].
另一个需要在根目录下创建的是图片文件 addonimage.jpg。它将作为你的 add-on 的图标显示在游戏的用户界面上,同时显示的还有 addoninfo.txt 中列出的内容。部分JPG格式可能会失效,这与创建它们的软件有关。如果遇到了JPG失效的头疼头疼问题,不妨使用 {{L|VTFEdit}} 来导出。


==== Mission File ====
==== Mission 文件 ====


The second required file is the [[L4D2 Mission Files|mission file]]. This describes the structure and content of your campaign and is used by the campaign selection UI, matchmaking, and the game server. This should be a .TXT file with a unique name in the '<code>missions</code>' folder, which you will also need to make:
其次需要的文件是{{L|L4D2 Mission Files|战役文件}}。 它描述了战役的结构与内容,并且会被用于战役选择的用户界面、 匹配系统、以及游戏服务器。它应当是一个有独有命名的 .TXT 文件。将它放置在 '<code>missions</code>' 文件夹中,这个文件夹也是你需要创建的:


  ...\left4dead2\addons\deadline2\missions\deadline2.txt
  ...\left4dead2\addons\deadline2\missions\deadline2.txt


The example [[Deadline Mission File]] includes full comments and instructions for using it as a template for your own mission.
示例中的 {{L|Deadline Mission File}} 文件包含了完整的注释与使用说明,可以直接拿来作为你的 mission 文件模板。


{{note|Adding a mission.txt file (or any text file) to the missions folder will flag the VPK as a campaign instead of a content pack. It is unknown whether there are other factors that affect how the VPK is treated. Specific sets of files in the VPK will not eclipse other campaigns. Such content includes, but are not limited to, unique and replacement materials/textures, models, sounds, sound cache, particles, and particles manifest. At the moment, script files (found in the scripts folder) and resource files are still eclipsed by add-ons regardless of the "type" of VPK it is packed. This causes conflicts with official and other add-on campaigns if file names are the same.}}
{{note|mission.txt(或是其它任何txt文件)添加到 missions 文件夹都会让VPK被标记为战役而不是附加内容包。尚不清楚有没有其它影响VPK标记类型的因素。VPK中特定的几组文件并不会影响到其它战役。这些内容包括但不仅限于:独有的与替换的材质/纹理、模型、音频、音频缓冲、粒子、以及粒子效果。目前,脚本文件(位于 scripts 文件夹中)以及资源文件仍然会被其他的 add-on 覆盖,不论打包成什么类型的VPK。如果出现了命名重复,将与官方或是其它 add-on 中的战役产生冲突}}


== Test it out ==
== 测试VPK ==


At this point, your add-on should be fully functional. You should be able to launch the game, go to Extras-&gt;Add-ons, and enable your add-on. If you type <code>path</code> into the console, you should see the root directory of your add-on near the bottom. This means that the game will search your add-on folder for files that it cannot find in the standard game .VPK files. Play a full game on other computers to check for an errors such as crashes and missing assets. You can continue tweaking your content in folder form until you're ready for that magical moment: Release into the wild.
目前为止,你的 add-on 应该已经功能完备了。可以进入游戏,打开Add-ons菜单来启用你的 add-on。如果在控制台中输入 <code>path</code>,你将会在底部附近看到你的 add-on 的根目录。这意味着游戏如果在标准的游戏目录下找不到对应资源时,将会进入你的 add-on 文件夹中搜索。在其它电脑中完整运行你的地图来检查有无错误,例如崩溃或是游戏资源丢失。你可以继续调整你的内容,直到准备好了面对那神奇的一刻:向外界发布。


== Packaging and shipping ==
== 打包与发布 ==


The final remaining step is to package your add-on into a .[[VPK]] for distribution.
剩余的最后一步就是将你的 add-on 文件夹打包成用于发布的 .{{L|VPK}} 文件。


The .VPK serves as a convenient, one file method for others to install your add-on folder. They need simply put the .VPK in their own add-on folder. Or, assuming they, like most non-authoring players, haven't associated the .VPK extension with something else, they can double click on it and it will install itself in the correct place.
.VPK 文件的作用是为了方便其他人只用一个文件就能安装好你的 add-on。玩家只需要将 .VPK 放在自己的 add-on 文件夹下就行了。或者,假如他们像大多数非地图作者的玩家一样,没有将 .VPK 扩展名关联到其他的程序上,就可以通过双击VPK来自动安装到正确的位置。


Every .VPK file contains a unique ID that allows the game to ensure everyone is running the same content. If you've put in meta-data properly, the game will also prompt users to download a newer version if it is required to play.
每个 .VPK 文件都有一个独一无二的ID,来确保所有人运行的是相同的内容。如果你的元数据文件配置正确,有必要的情况下,游戏将会提示玩家下载新的版本。


Navigate to this folder:
找到这个文件夹:


  C:\Program Files\Steam\steamapps\common\left 4 dead 2\bin\
  C:\Program Files\Steam\steamapps\common\left 4 dead 2\bin\


Locate the <code>vpk.exe</code> packaging utility and make a shortcut to it on your desktop. Drag your add-on root folder and drop it onto the shortcut. The utility should make a new .VPK next to your original folder. By default it will not include source files such as .VMF, .TGA, .SMD, .QC etc., and it will always strip out executable binaries. Remove the folder version of the add-on (or move it to a safe location) so that the .VPK is alone and test it out. The .VPK should function exactly as the add-on folder does. If it works, you're ready to upload it to a location you specified in the metadata files and from which it is available.
找到 <code>vpk.exe</code> 打包工具并在桌面上创建快捷方式。拖动你的 add-on 根文件夹到快捷方式上运行。该工具将会在你原有文件夹的位置创建一个 .VPK 文件。默认情况下并不会包含源文件例如 .VMF、.TGA、.SMD、.QC 等,并且会移除可执行二进制文件。移除文件夹版的 add-on(或是放到安全的位置)以便单独测试 .VPK 文件。 .VPK 文件应该能像文件夹版的一样正常工作。如果工作正常的话,就算是准备好将它上传到你在元数据文件中描述的下载位置了。


Ideally, you'll want an add-on "homepage" that includes ratings, screenshots, and player comments.  [http://media.steampowered.com/apps/513/deadline2.html A simple example can be found here.]
理想情况下,最好有一个包含了评分、截屏以及玩家评论的 add-on“主页” 。[http://media.steampowered.com/apps/513/deadline2.html 这里是一个简单的例子。]


=== Compression ===
=== 压缩 ===


Since full Left 4 Dead 2 campaigns can be very large it is advisable to compress them before uploading to file sharing sites for distribution. The open source Windows utility [http://www.7-zip.org/ 7-zip] supports compressing files in the 7z format/LZMA algorithm, which provide a very high compression ratio. The bulk of a campaigns size comes from the .bsp map files, which are highly compressible, so a vpk can be reduced to 25% or less of its original size. For example an unofficial version of Death Aboard was packaged up by a fan; the vpk was 267MB uncompressed, 92MB zipped, and 55MB with 7z.
由于一张L4D2的完整战役可能会非常大,因此建议在上传到分享站点用于发布之前,最好将它们进行压缩。开源的Windows工具 [http://www.7-zip.org/ 7-zip] 支持将文件压缩成 7z格式/LZMA算法,它的压缩率非常高。 .BSP 地图文件占了战役文件的大部分体积,而该文件可压缩性很好,因此一个vpk压缩后的体积可以减小到原来的25%甚至更低。例如一张由粉丝制作并打包的非官方地图 Death Aboard,压缩前的VPK大小为267MB,压缩成zip后大小为92MB,压缩成7z后大小仅为55MB。


== Final testing ==
== 最终测试 ==


At this point, you should test out the download prompt. Start a lobby with a local server, and invite a friend to join. When they accept, they should be prompted to download the necessary add-on, after which a browser window will opened to your add-on homepage. They should be able to download and install the add-on without having to restart the game, and then join your lobby.
进行到这一步,你应该已经测试完成了下载功能。在本地服务器上建立一个游戏大厅,邀请你的朋友加入。他们接受邀请后,将会收到下载必要的 add-on 的提示,接着会在浏览器窗口中打开你的下载主页。他们应当能够在无需重启游戏的情况下,下载并安装好你的 add-on,然后加入你的游戏大厅。


== See also ==
== 另见 ==


* [[VPK]]
* {{L|VPK}}
* [[VPK File Format]]
* {{L|VPK File Format|VPK文件格式}}
* [http://leeland.stores.yahoo.net/l4d2packmission.html L4D2 - Campaign Packager Tool]
* [http://leeland.stores.yahoo.net/l4d2packmission.html L4D2 - 战役打包工具]
 
[[Category:Left 4 Dead 2]]

Latest revision as of 04:17, 22 August 2024

English (en)Русский (ru)中文 (zh)Translate (Translate)

本简体中文页面由 Gloria 汉化。

在求生之路2代中打包你的自定义战役一共分为六个基本步骤:

  1. 创建Add-on文件夹与对应子文件夹。
  2. 创建好各类游戏资源并放入对应的子文件夹。
  3. 创建好数据描述文件(addoninfo.txt等)并放如对应的子文件夹。
  4. 将Add-on的所有内容打包成 .VPK 文件。
  5. 完整测试VPK文件,并修复出现的问题。
  6. 创建一个玩家可以从中下载你的地图的主页。

安装开发工具

为了创作求生之路2的三方内容,你需要安装求生之路2开发工具(Left 4 Dead 2 Authoring Tools)(en)。它提供了用于创作游戏内容的各类程序与工具。一般来说,可以使用 Hammer(en) 程序创建关卡,使用其它工具创建自定义纹理(en)模型(en)

如何创建各类游戏资源不在这个教程的介绍范围之内。你可以进入L4D关卡制作基础教程(en)找到相关的内容。介于这篇教程的重点在于讲解如何将所有地图内容打包到VPK中,因此当你开始学习这篇教程之前,应该已经熟悉了如何创建那些游戏内容。

开发工具附带了一个叫做 Dead Line 的战役示例,包含了各类源文件示例。

创建 Add-on 文件夹

首先,在你的求生之路2代游戏安装路径下找到 'addons' 文件夹。对于大多数人来说,应该是类似下面的路径:

C:\Program Files\Steam\steamapps\common\left 4 dead 2\left4dead2\addons
Note.png注意:如果你的文件夹是带连字符的,例如“add-ons”,确认它如果是空的就可以直接删除。正确的名称应该是不带连字符的“addons”。

注意:你的L4D2开发工具安装后可能并没有 'addons' 文件夹

在 'addons' 中创建一个新的文件夹,并取个合适的名称。这将会是你最后创建并发布的VPK文件名称。全部使用小写字母、避免使用空格是一个好习惯。你还可以将游戏名写入标题,同其它标题加以区分,并可以考虑添加一个版本号。为了便于阅读,我们的示例中还是使用了“deadline”而非“l4d_deadline”。

...\left4dead2\addons\deadline2

概念上来说,这个文件夹就相当于地图的游戏根目录,它的目录结构是下面将要介绍的用于发布的 .VPK 文件的镜像。

创建基础游戏资源

你创建的这些内容实际上将会与其它内容一块附加到游戏中。对于一张战役图来说,最基本的地图资源是 .BSP 文件和 .NAV 文件。

在你的工程文件夹下新建一个 'maps' 文件夹:

...\left4dead2\addons\deadline2\maps

在这个 maps 文件夹中,将你地图的 .BSP 文件和 .NAV 文件复制到这里。在 Dead Line 教程示例中,有两组 bsp/nav 地图文件:

文件 描述
l4d_deadline01 精简的初始地图,包含合作、对抗
l4d_deadline02 最终的地图,包括合作、对抗、生存、清道夫

在一张单独的地图中制作多种游戏模式的优点在于可以节省空间,尽管增加了制作复杂度,这样做还是值得的。

你还可以创建并在地图中使用自定义的 .VTF 纹理文件、自定义的 .VMT 材质描述文件、以及自定义的 .MDL 模型文件。为了减小VPK包的体积,建议你尽可能多地使用游戏自带的纹理。

额外的 .VMT 与 .VTF 文件(见自定义材质教程(en))应该放在下面的文件夹中:

...\left4dead2\addons\deadline2\materials

文件与相关的模型文件(见导出模型(en)编译模型(en))应该放在下面的文件夹中:

...\left4dead2\addons\deadline2\models
Note.png注意:从“牺牲”更新开始,模型的 .vtx 文件(en)在打包时将不再被重命名。例如,打包一个 .dx90.vtx 文件将不再被重命名成简单的 .vtx。所有原本是 .vtx 的官方文件都转换回了 .dx90.vtx 文件。在此更新之前发布的某些带自定义模型的战役中,模型在游戏中会变得不可见。在2010年10月的更新之前,包含了 .sw.vtx 与 .dx80.vtx 文件的战役在打包时会崩溃。

模型的材质文件放在下面的文件夹中:

...\left4dead2\addons\deadline2\materials\models

需要注意的是,L4D2将 /deadline2 文件夹的内容当作 /left4dead 的内容一样处理,因此如果你使用了 /materials 与 /models 下的任何纹理与模型,都应该在你的战役文件夹中添加一份。

创建次要游戏资源

次要的游戏资源例如海报与缩略图并不是必要的,但它们能让你的战役更加出彩。(再说了,海报/概念图恐怕是你头一项制作的东西,不是吗?)如果还没有制作的话,新建一个 materials 文件夹,并在其中创建一个 vgui 文件夹:

...\left4dead2\addons\deadline2\materials\vgui

地图战役海报

在 vgui 文件夹下需要放置两个 .VTF 文件,以及两个引用它们的 .VMT 文件:

LoadingScreen_DeadLine2.vtf
这是一张在你的战役加载界面出现的海报图片。标准的尺寸为1024×1024像素,并带有表示透明度的Alpha通道。
OutroTitle_DeadLine2.vtf
这是一张在关卡最后的鸣谢/数据统计界面出现的标题图片。标准的尺寸为1024×256像素。你创作的图片应该适合显示在黑色背景下,并且让上方滚动的白色文字易于阅读。

地图缩略预览图

除了上述两张图片之外,你还要有展示战役每一关的缩略图。这些图片能让玩家在游戏大厅中选择地图“章节”时有可见的、更直观的提示。

为了添加缩略图,在 vgui 文件夹下新建一个 'maps' 文件夹:

...\left4dead2\addons\deadline2\materials\vgui\maps

在这个文件夹中,为每一张地图创建 VTF/VMT 缩略图。它们的尺寸均为256×128像素。在合适的情况下,也可以使用一张缩略图表示多个 .BSP 地图,例如既用于对抗又用于生存的一关。

用于界面元素的 .VMT 文件例如战役海报、缩略图等(也就是通常放在 material/vgui 文件夹中的那些文件)一般需要指定为“UnlitGeneric”材质。 见 Deadline vgui .VMT File(en) 示例。

创建音频缓冲文件

如果在你的 add-on 中包含了自定义音频,你需要创建游戏引擎可以加载的音频缓冲文件。在VPK根目录下的“sound”文件夹放置你的音频文件,在L4D2运行时输入指令“snd_buildsoundcachefordirectory <path>”,其中path表示你放置音频的文件夹位置。例如,在 Deadline 示例中,音频文件放置在:

..\left4dead2\addons\deadline2\sound

使用下面的指令进行重建:

snd_buildsoundcachefordirectory "..\left4dead2\addons\deadline2"

这条指令将会在你的音频文件夹中创建一个 sound.cache 文件,在打包VPK时可以添加进去。

创建元数据文件

此外还需要一些文件才能保证你的附件能够在游戏中正常工作。

addoninfo.txt

首先是 addoninfo.txt 文件。该文件让你的内容能被游戏识别。它应该放在VPK的根目录中,也就是上面最开始创建的文件夹:

...\left4dead2\addons\deadline2\addoninfo.txt

这个文件用在游戏中的Add-ons界面。文件简要地描述了 add-on 中提供了什么内容。示例文件 Deadline AddonInfo File(en) 中包含了完整的注释与使用说明,可以直接拿来作为你的 add-on 模板。

addonimage.jpg

另一个需要在根目录下创建的是图片文件 addonimage.jpg。它将作为你的 add-on 的图标显示在游戏的用户界面上,同时显示的还有 addoninfo.txt 中列出的内容。部分JPG格式可能会失效,这与创建它们的软件有关。如果遇到了JPG失效的头疼头疼问题,不妨使用 VTFEdit(en) 来导出。

Mission 文件

其次需要的文件是战役文件(en)。 它描述了战役的结构与内容,并且会被用于战役选择的用户界面、 匹配系统、以及游戏服务器。它应当是一个有独有命名的 .TXT 文件。将它放置在 'missions' 文件夹中,这个文件夹也是你需要创建的:

...\left4dead2\addons\deadline2\missions\deadline2.txt

示例中的 Deadline Mission File(en) 文件包含了完整的注释与使用说明,可以直接拿来作为你的 mission 文件模板。

Note.png注意:将 mission.txt(或是其它任何txt文件)添加到 missions 文件夹都会让VPK被标记为战役而不是附加内容包。尚不清楚有没有其它影响VPK标记类型的因素。VPK中特定的几组文件并不会影响到其它战役。这些内容包括但不仅限于:独有的与替换的材质/纹理、模型、音频、音频缓冲、粒子、以及粒子效果。目前,脚本文件(位于 scripts 文件夹中)以及资源文件仍然会被其他的 add-on 覆盖,不论打包成什么类型的VPK。如果出现了命名重复,将与官方或是其它 add-on 中的战役产生冲突

测试VPK

目前为止,你的 add-on 应该已经功能完备了。可以进入游戏,打开Add-ons菜单来启用你的 add-on。如果在控制台中输入 path,你将会在底部附近看到你的 add-on 的根目录。这意味着游戏如果在标准的游戏目录下找不到对应资源时,将会进入你的 add-on 文件夹中搜索。在其它电脑中完整运行你的地图来检查有无错误,例如崩溃或是游戏资源丢失。你可以继续调整你的内容,直到准备好了面对那神奇的一刻:向外界发布。

打包与发布

剩余的最后一步就是将你的 add-on 文件夹打包成用于发布的 .VPK(en) 文件。

.VPK 文件的作用是为了方便其他人只用一个文件就能安装好你的 add-on。玩家只需要将 .VPK 放在自己的 add-on 文件夹下就行了。或者,假如他们像大多数非地图作者的玩家一样,没有将 .VPK 扩展名关联到其他的程序上,就可以通过双击VPK来自动安装到正确的位置。

每个 .VPK 文件都有一个独一无二的ID,来确保所有人运行的是相同的内容。如果你的元数据文件配置正确,有必要的情况下,游戏将会提示玩家下载新的版本。

找到这个文件夹:

C:\Program Files\Steam\steamapps\common\left 4 dead 2\bin\

找到 vpk.exe 打包工具并在桌面上创建快捷方式。拖动你的 add-on 根文件夹到快捷方式上运行。该工具将会在你原有文件夹的位置创建一个 .VPK 文件。默认情况下并不会包含源文件例如 .VMF、.TGA、.SMD、.QC 等,并且会移除可执行二进制文件。移除文件夹版的 add-on(或是放到安全的位置)以便单独测试 .VPK 文件。 .VPK 文件应该能像文件夹版的一样正常工作。如果工作正常的话,就算是准备好将它上传到你在元数据文件中描述的下载位置了。

理想情况下,最好有一个包含了评分、截屏以及玩家评论的 add-on“主页” 。这里是一个简单的例子。

压缩

由于一张L4D2的完整战役可能会非常大,因此建议在上传到分享站点用于发布之前,最好将它们进行压缩。开源的Windows工具 7-zip 支持将文件压缩成 7z格式/LZMA算法,它的压缩率非常高。 .BSP 地图文件占了战役文件的大部分体积,而该文件可压缩性很好,因此一个vpk压缩后的体积可以减小到原来的25%甚至更低。例如一张由粉丝制作并打包的非官方地图 Death Aboard,压缩前的VPK大小为267MB,压缩成zip后大小为92MB,压缩成7z后大小仅为55MB。

最终测试

进行到这一步,你应该已经测试完成了下载功能。在本地服务器上建立一个游戏大厅,邀请你的朋友加入。他们接受邀请后,将会收到下载必要的 add-on 的提示,接着会在浏览器窗口中打开你的下载主页。他们应当能够在无需重启游戏的情况下,下载并安装好你的 add-on,然后加入你的游戏大厅。

另见