这篇文章正在被编辑中,编辑完成前请不要同时编辑,以免撞车。此处查看需要帮助的词条列表。编辑者签名:,本提示有效期15天,过期请协助解除。
参见:MODs

MODs是“Modification“(修改)的缩写,它是可以修改或添加游戏效果的小文件包,包括用于修正外观的效果包(Art Packs),添加武器、事件、家具,以及游戏平衡性的MODs。

这个页面仅讨论制作MOD。要查找关于使用MOD的信息,请参考Installing mods

MOD制作教程

请参看Mod教程页面。如果你找不到需要的信息,请移步Modding/Random Bits of Information页面查看你所需要的信息是否被整理至适当的词条。

可修改的内容

您可以修改游戏的定义文件(Defs)、程序代码(Code)、图片(Images)和音效(Sounds)。

  • 定义文件(Defs): 指的是包含游戏定义的XML文件。游戏中含有大量此类文件。这些文件定义了游戏的所有物品、技能、故事讲述者以及很多其他类型的数据。您可以在目录“您的MOD的名字/Defs”下找到它们。这部分内容将在下面详细叙述。
  • 程序代码(Code): 您可以添加 .NET 程序集(Assemblies)到您的MOD中,游戏启动时会加载这些程序集。您可以把您的程序集DLL放在目录“您的MOD的名字/Assemblies”下。这部分内容将在下面详细叙述。
  • 图片(Images): 您可以添加MOD所需要的图片。
  • 音效(Sounds): 您可以添加MOD所需要的音效。

基础:修改定义文件

RimWorld中最基础的修改时通过修改定义文件(Defs)来实现的。

每一个定义语句(Definitions)会定义游戏中的一些内容。不同种类的定义语句(Definitions)可以定义如下内容:

  • 音效(Sound)
  • 武器(Weapons)
  • 建筑(Buildings)
  • 植物(Plants)
  • 动物(Animals)
  • 其他内容(根据需要决定)

当游戏运行时,游戏会加载MOD文件中的所有定义语句到程序池(pool)中,然后在各类情形下半随机式地从程序池中读取。例如:游戏会随机抽取某种类型的枪支来打造一个新的敌对雇佣军;或者,它会在地图边缘随机产生一种动物类型。修改游戏即意味着添加您的定义语句到程序池中然后看着游戏以某种方式使用他们。

每一类定义语句会被打包成一个包(package)。每一个包会以单个XML文件的形式保存。

成堆的包会被打包进MOD中。MOD其实就是互相联系的功能与内容组装成的模块。它可以是新武器包,新动物包,或者是游戏的完全转化(a total conversion of the game)。一个MOD通常会包含数个不同类型的包以及相应的内容(如图片和音效)。

游戏本体被一个叫做“核心”(Core)的MOD所定义。

玩家可以选择激活哪一些MOD。有些情况下,一些MODs可以立刻生效。你可以使用一个“中世纪MOD”(Medieval MOD)来代替“核心”(Core)MOD,然后添加由别人制作的武器包。游戏会使用“中世纪MOD”中的内容来运行并且会随机从额外的武器包中抽取武器生成。

MOD的文件结构

为了定义新的游戏内容,我们需要用到XML文件。这里提供一个适用于多数定义语句的格式示例:

<?xml version="1.0" encoding="utf-8" ?>
<XXXDefs>
   <XXXDef>
      <defName>我的新内容的定义语句</defName>
      <!-- 这里还会出现更多的标签,这取决于您所定义的内容 -->
   </XXXDef>
</XXXDefs>

要注意的是:XXX 必须被您所定义的内容的名称替换。例如,对于“Thing”来说,就应该是<ThingDef>

译者注:这里的“名称”必须是英文名,但这个名称不会显示在游戏中,只是一个游戏内部识别的代号。

RimWorld的MOD应该按照以下目录结构制作:

┌╴About
├╴╴╴About.xml (Contains info about the MOD)
├╴╴╴Preview.png (Image that appears above the MOD info in game. Max width 600px.)
│
├╴Assemblies (If your MOD uses any DLL files put them here)
├╴╴╴MyMOD.dll
│
├╴Defs (Contains xml definitions of the MOD)
├┬╴ThingDefs
│├╴╴╴Things.xml
│└╴╴╴Buildings.xml
├┬╴ResearchProjectDefs
│└╴╴╴MyProjects.xml
│the folder name must be specific here. Look in Core MOD to see what are other names supposed to be
│
├╴Sounds
│
├╴Source
├╴╴╴MyMOD.cs (Optionally, put the source code of your MOD here)
│
├╴Strings
│
├╴Textures (Put any image textures here, preferably in .png format.)
└┬╴Things
 ├╴╴╴MyMOD_ImageA.png
 └╴╴╴MyMOD_ImageB.png

MOD info

This is found in MODNAME/About

  • The contents of About.xml are plain text. HTML Markup tags cause NullRef's.
  • You can have an image for your MOD. Restrict the image width to 600 pixels

Textures

These are found in MODNAME/Textures

  • You can have any path you want from this point on.
  • When referencing textures in your MOD, using <graphicPath>, have the complete path relative to your MOD, including the filename (but not the file extension). Example for the RoyalBed TestMOD: <graphicPath>Things/Building/RoyalBed</graphicPath>

Interactive "things"

A thing is anything that exists in the game world. It includes resources, races (humanoid and animal), buildings, furniture, and many others.

These are defined in MODNAME/Defs/ThingDefs If you make a new workbench, you'll need to define a recipe for it. This is a list, so you can have many new recipes listed.

The recipes themselves are defined in: MODNAME/Defs/RecipeDefs In here you can define what ingredients/resources are required, what can be used, and what the default recipe is.

Any new resources will need to be defined in: MODNAME/Defs/ThingDefs

Turrets

These are defined in two files in: MODNAME/Defs/ThingDefs/Buildings_Big.xml and Weapons_Guns.xml (Remember, these can be named anything)

Buildings_Big.xml defines the structure of the turret itself. For example:

<building>
	<turretGunDef>Gun_TurretImprovised</turretGunDef>
	<burstCooldownTicks>300</burstCooldownTicks>
</building>

Weapons_Gun.xml defines the weapon the turret uses. Anything can be used as a weapon for turrets, including grenades.

Resources

These are defined in: MODNAME/Defs/ThingDefs/Resources.xml

Research projects

These are found in: MODNAME/Defs/ResearchProjectDefs

You can have research trees as well, where additional research projects get unlocked as you move through. This is how to add prerequisites:

<prerequisites>
	<li>-this is the <defName> of the prerequisite-</li>
</prerequisites>

Because it's a list, you can have multiple prerequisites for a research project.

Advice

  • The tilde key (` or ~) brings up the development console, which will report any errors or warnings it encounters when a MOD loads or during gameplay. This is the quickest way to see what, if any, errors exist in your MOD. (You don't need to turn on development MODe for this.)
  • Use development MODe (found in the options menu) to help debug your MOD, spawn items related to your MOD, or fire incidents at will. (Or just mess around, if you'd like.)

The other stuff: Code, Graphics, Sound

You can find links to tutorials on the Modding Tutorials page. There's also more tutorials about the basics there, so don't miss out on that.

References

0.0
0人评价
avatar