查看: 7309|回复: 1
打印 上一主题 下一主题
收起左侧

OpenTTD的GRF文件编辑

[复制链接]
跳转到指定楼层
楼主
Diablo 发表于 2013-6-22 15:47:53 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

欢迎来到嗨皮网,马上注册结交更多鸟友,享用更多功能

您需要 登录 才可以下载或查看,没有帐号?注册

x
grfcodec拆分grf得pcx和nfo,前者图象后者定义,用ps或画图之类修改pcx,用记事本等修改nfo或用grfmaker导入nfo修改后输出,最后用grfcodec压缩得grf。

GRF制作教程汉化

Preliminaries
NOTE TO AUTHORS: Read the LocalStyleGuide, otherwise the page may be rolled back to the last well-commented edit. (This applies everywhere, not just on the pages that mention it.)
(这段话意思不明白,以后慢慢补)
To write:
- explain GRFCodec / GRFWizard
- explain hex codes: specific examples using Windows calculator, ideally with screenshots
- maybe: explain DOS/Windows version and how to convert between them
- other things?

What's a .GRF file?

什么是.GRF文件

As you probably already found out ttd can load new graphics files with help of the patch. These files have the extension .grf and are located in the newgrf folder.

正如你发现TTD可以通过补丁来加载新的图形文件,这些扩展的.grf文件放在NEWGRF目录中

These .grf files are made by the GRFcodec, this program merges a .pcx file and a .nfo file. (links to george his tut now, but I think on top of that page should be an explanation about pcx files and their pallete ) In this tutorial we won't look at those 2 file types yet, at first we shall try to explain the basics.

这些.grf文件是由the GRFcodec生成的,这个程序用来合并.pcx 文件和.nfo文件(链接到george的关于绘制.pcx的教程),在这个教程里,我们将首先解决基本的,而不是以上两个文件的说明。

The GRFCodec and the GRFWizard

程序GRFCodec 和GRFWizard

Like said before a .grf file is a file made by the GRFCodec. The codec is a package of 3 programs:
1. GRFCodec: Convert a GRF into an editable PCX file and vice versa
2. GRFDiff: Compare two GRF files for differences, and write only the differences to a GRD file
3. GRFMerge: Take a GRD file and merge it back into the GRF file

正如前面所说的,一个.grf文件是由GRFCodec生成的,这个程序包包括了3个程序:
1、GRFCodec :转换.grf,包括编译和反编译;
2、GRFDiff:比较两个grf文件,并将不同之处写入GRD文件;
3、GRFMerge:读取GRD文件并合并到GRF文件中。

In this tutorial we will only use the first program, if you want more info about the other programs look here.
The GRFCodec is a command line program. This means it's option are only been set in the command line, there is no nice user interface. For the nice interface you can download the GRFWizard This program is really helpful. Be warned though for the GRFWizard to work you need the GRFCodec too.

在这个教程里,我们仅仅使用第一个程序,如果你想得到另外两个程序更多的信息,请参考这里.

When you run the GRFWizard for the first time you have to point it to the codec, when you have done this everything is really straight forward, you can encode your homemade sprites (sprites are the little drawings that represent one side of a building/vehicle) or you can decode a grf from someone else.

当你第一次运行GRFWizard时,你必须为它指定codec的路径。当你弄完这一切后,你就可以编译你自己定义的sprites了(sprites就是缩小比例的建筑/运输工具的图样)或者反编译别人的grf文件。

When you want to encode graphics you have to point the wizard which grf file you want to encode the 2nd step is to tell it in which you placed the NFO and PCX. All these file should have the same name.

当你想要编译grf文件,你需要指定哪个grf文件需要编译,第二步就告诉程序你将.nfo和.pcx文件放在哪里了。这些文件需要同样的名字,例如:aaa.nfo和aaa.pcx

If you want to encode totally new graphics you have to make a "fake" grf. Just make a new txt file and rename it to the grf you want to encode.
If you choose to decode a grf, the nfo and pcx will be extracted to a map called sprites in the in the folder where you placed the grfcodec in.

如果你想要完全地编译新图形图像文件,你可以编译一个“假冒的”grf文件,仅仅生成一个.txt文件,并将它的名字改成你想要得到的grf文件名。
如果你反编译一个.grf文件,生成的.nfo和.pcx文件将被解压到grfcodec\sprites目录下。

Hex 十六进制
some sort of text here to explain why you need to understand hex?


以下文字是解释了为什么你需要了解十六进制,后面的不用翻译了吧?最简单的是就windows下的计算器。

HEX is a way of counting. You normally count from 1 till 9 and then go to 10,11 etc. In HEX it works a bit differently: you count from 0 till 9 but then you go one with A, B,C,D,E,F. So 1 till 9 is just 1 till 9, but then it gets funky A=10, B=11, C=12 and so one till F= 15. when you reach F you just do like you would do normally, you start at 0 again but now with a 1 in front thus 10 (gee thats almost like normal counting! ) so 10=16 If you want a better understandable explanation visit this link.

Now it would be rather uneasy if you have to count it all by yourself (or at least for me being of the lazy generation) so you can use the windows calculator for that.
If you open it it take any hex, so you have to go to scientific. Just open view and click on scientific mode.
If you did it correctly it will look like this:

(sorry I had to eat, I will see this page later on again)

NFO Filesnfo文件

The fundamental files that control your new graphics are the .nfo and the .pcx file. The .pcx file contains the actual drawings, and the .nfo file the instructions what to do with them.

你的grf文件是由.nfo和.pcx构成。.pcx文件是图形文件而.nfo文件是用于告诉程序怎么使用.pcx文件

To get started开始

To draw a new train, you first need a base from which to start working. Since you probably aren't familiar with all the intricacies yet, it's best to copy one of TTD's vehicles and then draw your own graphics. Basically, you follow these steps:

要绘制一个新的火车,你首先需要一个基础模型来开始工作。可能你不是太熟悉,最好的方法是拷贝一个ttd的运输工具,然后来绘制你自己的图形。你要按照以下的基本步骤来


  • Extract TTD's trg1r.grf (or trg1.grf for the DOS version)
  • Look through trg1r.pcx for a vehicle similar to the one you're going to make
  • Copy the corresponding data from the .nfo file into your own file
  • Encode and decode again your own file
1、解压TTD中的trg1r.grf(或者dos版本中的trg1.grf)
2、在trg1r.pcx中查找一个与你想要绘制图形相似的运输工具
3、从.nfo文件中拷贝相应的数据到你自己的文件中
4、编译或者反编译你的文件

Now to look at these steps in a bit more details.
现在来详细解释一下

1. Extract TTD's trg1r.grf1、解压ttd的trg1r.grf

First of all, you need to download grfcodec and unzip it into your TTD folder. Then you open a DOS command window. If you are using Windows 2000 or Windows XP you can open a DOS command window by typing cmd in the execute option in the start menu. When you see the command window run grfcodec like this:

首先,你需要下载grfcodec并解压到你的ttd目录中,然后打开一个dos命令行窗口。如果你使用win2000或者xp,你可以通过“开始”菜单中的“运行”,输入“CMD”命令,然后你输入以下命令

cd C:\TTD (change to your TTD folder)
grfcodec -d trg1r.grf (decode trg1r.grf; use trg1.grf for the DOS version of TTD)


This will make a new folder called sprites, and will put trg1r.pcx and trg1r.nfo in it.

以上命令会生成个新的目录,/sprites,并生成trg1r.pcx和trg1r.nfo文件

You can also use GRFWizard with grfcodec. It will add a user interface to grfcodec. Just follow the options in the wizard to decode a .grf file, it will also add a sprites folder and generate the .nfo and .pcx files.

你也可以使用grfwizard,它将为grfcodec添加一个用户界面。通过反编译一个.grf文件,它也会添加一个sprites目录和生成.pcx、.nfo文件。

2. Look through trg1r.pcx2、查看trg1r.pcx

You now open trg1r.pcx from the sprites folder. There are many graphics programs to view and edit .pcx files.
你现在可以在sprites目录打开trg1r.pcx文件,有很多程序可以查看和编辑.pcx文件。

Look for a vehicle that is similar to the one you want to make. For example, if you want to make a train engine with 8 views, you can use the SH 125. So you go looking for its graphics in trg1r.pcx. For the SH 125, you'll find them at numbers 2941 to 2948 (those are the little numbers above the images). Write down those numbers. For example, this is what it might look like:

找到一个与你想要绘制的图形相似的运输工具。例如,你想要绘制一个火车头的8方向图,你可以查看SH 125。对于SH 125来讲,你可以看到他们的数字为2941到2948(在相应图像上的小数字)。如图所示

11-3-3 12:57:18 上传
下载附件 (3.38 KB)





3. Copy the corresponding data from the .nfo file into your own file3、从.nfo文件中拷贝相应的数据到你自己的文件中

So now that we know what sprites to base the graphics on, we need to copy those into a new file. Open the trg1r.nfo file in a text editor, for example Notepad. Also, open another .nfo file for your own graphics, say for example "mytrain.nfo".

现在,我们知道了相应的图形对应的数字,我们需要拷贝这些数据到新的文件里。用文本编辑器打开trg1r.nfo,例如 notepad。同样的,创建一个名为“mytrain.nfo”的文件。

Now, copy and paste the first three lines beginning with "//" to your mytrain.nfo file. While they may look like comments, they are actually important.

现在,拷贝粘贴前三行包括"//"的字段到mytrain.nfo文件中。看起来只是注释,其实它们很重要。

In the next step, find the lines beginning with the sprite numbers you're written down in the previous step. In the example above, we'd find the lines with numbers 2941 to 2948. Copy those eight (or however many) lines to your mytrain.nfo file as well.

接下来,找到你刚才记下的几个数字的那几行,拷贝到mytrain.nfo文件中。

4. Encode and decode again your own file编译和反编译你的文件

Now we want to make our own .grf file. Unfortunately, grfcodec is a bit picky and will complain loudly if your lines are not numbered properly. To make grfcodec shut up, you have to go through your .nfo file, and change the numbers at the beginning of the lines to go from 0 to 7.

现在我们要生成自己的.grf文件了。不幸的是,grfcodec有一点讲究,并且会大声的报警,如果你的语句不是正确的。为了让编译通过,你要检查你的.nfo文件,并把每段开头的几个数字,改成0-7

At this point, your .nfo file should look something like this:
修改后的文件如下所示:

// Automatically generated by GRFCODEC. Do not modify!
// (Info version 6)
// Format: spritenum pcxfile xpos ypos compression ysize xsize xrel yrel
0 C:\TTD\SPRITES\trg1.pcx 530 10664 01 18 8 -3 -10
1 C:\TTD\SPRITES\trg1.pcx 546 10664 09 15 20 -14 -6
2 C:\TTD\SPRITES\trg1.pcx 578 10664 01 12 28 -14 -6
3 C:\TTD\SPRITES\trg1.pcx 626 10664 09 16 20 -4 -8
4 C:\TTD\SPRITES\trg1.pcx 658 10664 01 18 8 -3 -10
5 C:\TTD\SPRITES\trg1.pcx 674 10664 09 16 20 -14 -7
6 C:\TTD\SPRITES\trg1.pcx 706 10664 01 12 28 -14 -6
7 C:\TTD\SPRITES\trg1.pcx 754 10664 09 15 20 -4 -7


Now run grfcodec again, first to encode and then to decode your file. This creates mytrain.pcx and changes your .nfo to refer to that copy of the sprites:

现在重新运行grfcodec,首先编译和反编译你的文件。将会生成mytrain.pcx并修改你的.nfo来指向你拷贝你的sprites。

grfcodec -e mytrain.grf (encode your mytrain.grf file)
grfcodec -d mytrain.grf -p 2 (decode your mytrain.grf file again)


Leave off the "-p 2" if you're working with the DOS graphics instead of the Windows graphics.
“-p 2”命令开关是用来生成DOS版本的grf

Good job!做得好

Now you have your own mytrain.grf file with the corresponding mytrain.nfo and mytrain.pcx files. We'll use this as a base for making these graphics TTDPatch compatible.

现在你将有自己的.grf文件了,我们通过这个基本方法来生成ttdpatch适用的grf文件。

Note that you can't yet take your mytrain.grf file and put it in TTDPatch's newgrfw.cfg file yet, because it doesn't have the necessary information to allow TTDPatch to know what to do with it.

注意,你仍然不能在游戏中调用它,因为它没有必须的信息来让ttdpatch知道该怎么运用它。

However, you can go ahead and edit the graphics in mytrain.pcx to your liking and make them look like your train.
然而,你可以不断修改.pcx文件里的图形来更加完善。

Once you're ready, go on to the next section.
当你准备好后,进入下一单元。

The First Vehicle第一个运输工具

This section of the tutorial takes the rudimentary mytrain.grf file you made in the previous step, and turns it into a .grf file usable by TTDPatch.

本单元介绍了如何将上一步中生成的.grf文件转换成ttdpatch可用的.grf文件。

Here's what you have to do:
这里,我们将做的是


  • Figure out "pseudosprites"
  • Add the special first pseudosprite
  • Give your file an GRFID
  • Add an "action 1" to introduce your vehicle graphics
  • Use actions 2 and 3 to link your graphics to a vehicle in TTD
  • Adjust the first pseudosprite again, and renumber all sprites
  • Encode and add to newgrf(w).cfg
1、弄明白"假sprites"
2、添加特殊的第一个"假sprite"
3、标注grfid
4、增加"action 1 "来介绍你的grf文件
5、使用action2和3来使你的图形连接ttd里相应的运输工具
6、调整第一个假sprits,并重新编号所有的spirtes
7、编译并添加到游戏里。

Now let's look at this in more detail.
现在来详细介绍每个步骤

1) Figure out pseudosprites1、弄明白"假sprites"

If you've looked through trg1r.nfo, you may have noticed that some entries look different to the usual ones.
如果你查看trg1r.nfo时,你可以注意到一些段落与普遍的要些差别

Usual entry:
普通段落

24 C:\TTD\SPRITES\trg1r.pcx 450 8 01 9 7 0 0

This one is different:
不同的:

771 * 17 10 00 F0 F0 F0 F0 F0 F0 F0 F0 F0 F0 F0 F0 EF EF EF


The first one refers to an image in the PCX file. The second one is some additional data that's not an image. These types of entries are called "pseudosprites", and in TTDPatch .grf files they are used to give TTDPatch information what it should do with the graphics in the file.

第一个段落,是指向pcx中的一个图形,第二个段落是一些额外的数据,并不是一个图形。这些段落就叫“假sprites”,在ttdpatch中,.grf文件给予ttdpatch信息来让ttd运行这些图形。

Here's what you have to know:
这里,我们需要知道


  • The first number is the well-known sprite number, simply counting entries from the beginning of the file
  • Then follows an asterisk "*", where you would normally have the PCX filename
  • Then there's another number, which is the length of the following data
  • And finally the actual data, as a bunch of hex codes
第一个数字就是通常说的spirte编号,简单的计录从文件开始的段落数
紧接着的“*”和你通常的pcx文件名,
然后是另一个数字,就是接下来的数据“长度”
最后一串数字就是实际使用的数据。

So, that's what you have to know about pseudosprites for now. Let's get started...
至此,以上就是解释了什么叫“假sprite”,让我们开始吧。

2) Add the special first pseudosprite添加特殊的第一个“假sprite”

For TTDPatch graphics files, the first entry in the .nfo is special, and tells TTDPatch how many lines the file has. Since we don't yet know how big it will be, we add it but don't put any useful data in.

在.grf文件中,.nfo文件的第一个段落是特殊的,是为了告诉ttdpatch,该文件中有多少行。因此,在我们仍然不知道文件有多大时,我们添加它但不放入有用的数据。

Here's what you do: in your mytrain.nfo file, after the comment lines (those that begin with "//"), but before the first entry, insert the following line:

这里,你要在你的.nfo文件中,在注释行("//"开头的)后面和第一段落前面,插入以下行:

0 * 4 00 00 00 00


3) Give your file an GRFID3、标注grfid

Apart from the first line which we've added in the previous step, TTDPatch .nfo files are organized by "actions". These actions tell TTDPatch what to do with the graphics in your file. In our specific case, we need to tell TTDPatch to use those graphics for a train engine.

除开上一步我们添加的第一行外,TTDPATCH的.nfo文件通常是由“actions”组成。这些“actions”(后面翻译将改成脚本了)告诉ttdpatch怎么运行你文件里的图形。在本教程中,我们需要告诉ttdpatch使用这些图形用作一个火车头。

Before you go any further, just let me make clear what the different ID's mean that we will refer to. Here's a table:

在你深入研究前,请让我解释不同的ID意味着我们的指向,如下表所示:

ID TypePurpose
Vehicle IDA generic vehicle/station/building slot whose properties can be defined using an Action 0. A Cargo ID can be associated with this using Action 3.
set ID (called cargo ID for vehicles)A ID asociated with one or more Spritesets using an Action 2. Can be asociated with a Vehicle ID using Action 3.
SpritesetA value unique to each Action 1. Defines a set of 8/4 views i.e. a set of sprites. Is in an action 2
GRFIDA word value used to differentiate between different grf files. This should be globally unique!

ID 类型目的
运输工具 ID通过使用脚本0来定义运输工具/站台/建筑的统一接口。货物ID通过使用脚本3来产生联系
固定ID (运输货物类型的ID)
一个ID通过使用脚本2来与一个或多个sprites产生联系。通过使用脚本3来与运输工具的ID产生联系。
Spriteset对应脚本1中的一个唯一值
A value unique to each Action 1. Defines a set of 8/4 views i.e. a set of sprites. Is in an action 2
GRFID一个唯一值用来区别不同的grf文件。


Just keep that in mind and refer to it later on.
Now, lets continue.

记住以上信息并明白后面示例的意义。
现在继续

The first step to do that is by using an Action 8, which gives your file an GRFID, and allows people to turn it on or off in the GRF Status Window.

第一步,使用脚本8,赋予你的.grf文件一个grfid,然后允许玩家在游戏中开启和关闭

You have to choose the GRFID yourself. To find a good GRFID to use, for example use the initials of your first and last name, plus two numbers.

你必须自己选择一个grfid。例如最好的方法就是使用你姓名的首字母,加2个数字。

For example, for this tutorial, we'll use the initials "TW". In addition, we need two numbers to identify the file. These you can pick however you like, you'll use them to distinguish different graphics files made by you. Those will have the same initials, but must get different GRFIDs, so you pick different numbers. For example, here we pick 3 and 5.

例如,在本教程中,我们将使用"TW"。另外,我们需要2个数字来表明文件身份。数字可以是你喜欢的,你可以区别你自己的不同文件。这样,不同grf文件的grfid拥有相同的首字母,但必须拥有不同的grfid,所以你必须使用不同的数字。例如,这里我们选择了3和5

This means we get the following GRFID:
这样,我们得到以下的grfid


"TW" 03 05


You may also write the initials as hex codes. If you aren't familiar with hex codes, you can use the Hex Converter to help you. Simply enter your initials and click convert, and then write down the hex codes. This is more complicated, so very few people do it, but the result would be the following equivalent GRFID:

54 57 03 05
你也可以将缩写字母以十六进制的方式表达。如果你不熟悉十六进制,你可以使用转换器来帮助你。只需要输入你的字母,点击转换就可以了。这个结构很复杂,所以很少人用,但结果是一样的。

This form is the official form for a GRFID, and should be used in all non-.nfo contexts. In .nfos, you may use whichever form you prefer.

这个是指定的grfid方式,并被使用在非.nfo环境中。在.nfo文件中,你可以使用你更喜欢的。

The 54 57 are the hex codes for "TW". In both cases, 03 and 05 are the numbers we've picked, written in hex.

54 57 是"TW"的十六进制表达式,同时,03 05是我们选择的数字,也是以十六进制表达的。

Therefore, you insert the following line immediately after the line which you've added in the previous step:
1 * 8 08 06 "TW" 03 05 00 00

因些,你将以下表达方式插入在上一步中我们建立的行之前。

This gives your graphics file the GRFID. This action 8 must always be present in your files, and it must be one of the first lines. If you don't have an action 8, TTDPatch will complain about "invalid sprites" or an "incorrect version", and refuse to load your file.

这样你的grf文件就有了grfid,脚本8必须出现在你的文件里,而且必须是第一行。如果你没有定义脚本8,TTDPATCH将会报错,并拒绝加载你的文件。

You can optionally give your file also a name and a description or copyright info, but that's beyond the scope of this tutorial. Check the docs for action 8 for more details.

你也可以通过脚本8来定义一个名字和一个描述或者版权信息。以上已经超出了本教程的范围,请参考脚本8

4) Add an action 1
添加脚本1

Right, so now the file has an GRFID. In the next step, we need to tell TTDPatch that there will be a bunch of graphics in this file. You might think that that's obvious, but nothing is obvious to computers, so we have to tell it.

现在,文件有了grfid。下一步,我们需要告诉ttdpatch,文件中有一系列的图形。这是必须的。

This happens through an Action 1 entry, that tells TTDPatch there will be one or more sets of graphics in the file. In our case it looks like this:
2 * 4 01 00 01 08

通过脚本1的段落,就能告诉TTDpatch有一个或多个系列的图形在这个文件里,在我们的教程里,表达如下:

Add this line right after the above action 8. It's worth decoding what this line means. you can just read it from the left to the right. We have the following:

在脚本8定义行之后添加上面那行,该行的表达意义可以参考下表


CodeMeaning
01Action 1
00Feature 0, meaning trains
01One set of graphics
08Each set has eight views


代码意义
01脚本1
00特征 0, 代表火车
01一个系列的图片
08每个系列有8个视角




For more details on these, in particular to see what "features" there are, check the Action 1 docs.

请参考脚本1的文档,来明白特征的意义及相关的细节。

After this follow the eight lines with the actual graphics that we already have in the .nfo file. So at this point your file should look something like this:

现在,接下来的8行就是我们已经保存在.nfo文件中的,如下所示:

// Automatically generated by GRFCODEC. Do not modify!
// (Info version 6)
// Format: spritenum pcxfile xpos ypos compression ysize xsize xrel yrel
0 * 4 00 00 00 00
1 * 8 08 06 "TW" 03 05 00 00
2 * 4 01 00 01 08
0 C:\TTD\SPRITES\mytrain.pcx 66 8 01 18 8 -3 -10
1 C:\TTD\SPRITES\mytrain.pcx 82 8 09 15 20 -14 -6
2 C:\TTD\SPRITES\mytrain.pcx 114 8 01 12 28 -14 -6
3 C:\TTD\SPRITES\mytrain.pcx 162 8 09 16 20 -4 -8
4 C:\TTD\SPRITES\mytrain.pcx 194 8 01 18 8 -3 -10
5 C:\TTD\SPRITES\mytrain.pcx 210 8 09 16 20 -14 -7
6 C:\TTD\SPRITES\mytrain.pcx 242 8 01 12 28 -14 -6
7 C:\TTD\SPRITES\mytrain.pcx 290 8 09 15 20 -4 -7


However, if you're doing this for one of your files, you have to choose your own GRFID of course because 54 57 03 05 is reserved for the file we're making in this tutorial.

然而,你需要修改grfid,因为54 57 03 05是教程专用的。

5) Using actions 2 and 3
使用脚本2和3

At this point, TTDPatch knows the GRFID of your file, and it has loaded the graphics for it. The only thing that remains to be done is linking these graphics to one of TTD's vehicles. Note that you can't add new vehicles as such, you can only replace existing ones. This means that you also have to decide which one to replace, so you have to find out the vehicle ID of that vehicle. Since we've based the graphics on the SH 125 here, we might as well replace that one, although you're free to use whichever vehicle you want. There's a list of vehicle IDs here. You can pick any train number from the list, don't forget to convert the number to hex.
Warning: You can only replace trains with trains and ships with ships and so on.

这时,TTDpatch已经知道你的grf文件的grfid了,并且加载了图形。剩下的就是将这些图形与ttd里的运输工具产生替换。注意,你不能添加新的运输工具,你只能替换已有的。这就意味着你可以考虑替换哪一个,因此你需要找出该运输工具的ID。既然我们基于的SH 125,我们最好是替换它,虽然你有自由选择权。这里有一个运输工具ID的列表,你可以从列表中找到一个,别忘了把ID转换成十六进制。
警告:你只能火车替换火车,轮船替换轮船等等。

To associate graphics with a vehicle, we use Action 2 and Action 3. Action 2 is called a "cargo ID", because it contains various states of animation of one particular cargo. This isn't really important for the train engine we're making, but for example wagons may be able to carry different cargos that should also look differently.

通过脚本2和3,可以将图形与一个运输工具联系起来。脚本2被叫做“货物ID",因为它包含了不同状态下的特定货物的动画。这对我们要生成的火车头来说不是特别重要,但例如绘制车厢时就能运输不同的货物而且也看起来不同。

For our train engine, we define one cargo ID like this:
11 * 9 02 00 00 01 01 00 00 00 00

对于我们的火车头,我们定义一个货物id如下:

This is already getting a bit complicated, so let's look at it in detail:

看起来很复杂,我们列表来看细节:



CodesMeaning
02Action 2
00Feature 00, meaning trains
00We define Cargo ID 0 (the first number available)
01There is only one set of graphics we have while in motion
01And also only one set while loading
00 00Use the first set while in motion
00 00And also while loading/unloading


代码含义
02脚本2
00特征00 ,代表火车
00我们定义货物 ID 0 (第一个可用的数字)
01在运行中,我们只有一个系列的图形
01在装载时也只有一个系列的图形
00 00在运行中,使用第一个系列
00 00在装/卸载中也使用第一个系列



Instead of cargo ID 0, we could have defined any other number, but it makes sense to start with the first number.

我们可以定义货物ID用其它的数字而不是0,但第一个数字起作用。

Regarding the number of sets, it's possible to show various states of animation depending on how full the vehicle is, and whether it's in motion or whether it's loading or unloading. However, for train engines that's unimportant, so we'll forget about it for now.

就系列的数字而言,它可以展示不同状态下的动画不表示该运输工具的满载情况或者是否在运行或者是否在装/卸载。然后,对火车头来讲,这不重要。所以我们现在要忘掉它。

The last sets of two 00 codes tells TTDPatch which sprite-sets to use, referring to the most recent action 1. Since we've only had one set there, and sets are numbered starting from 0, that means we have set 0. We put down the set number 00, followed by another 00 because TTDPatch needs that. If we were using set 1, it would be 01 00.

最后的代码设置为00 00 来告诉TTDPatch使用哪一个sprite系列,指向最近的脚本1。既然我们这里只有一个系列,并且编号从0开始的。因为记为00,紧跟的00 是因为ttdpatch需要它。如果我们需要使用系列1,将是01 00

This is our cargo ID definition. Now we attach this cargo ID to the vehicle using action 3. The SH 125 has vehicle ID 22, or 16 in hex, so we use the following:
12 * 7 03 00 01 16 00 00 00

这是我们的货物id定义,现在我们通过脚本3给这个运输工具赋予货物id,SH 125 的运输工具ID是22,十六进制为16,因此我们这样写:

Again in more detail:
代码含义如下:


代码含义
03脚本 3
00特征 00, 代表火车
01对一个运输工具附加以下图片
16运输工具的 ID是 16 (十六进制)
00没有定义特殊的货物图形
00 00在任何情况下都使用货物ID为0


We could give the same graphics to several vehicles, but that's usually not useful. For wagons, we could also define various cargo IDs and attach them depending on what cargo the wagon carries, but for engines that doesn't matter and so we just use cargo ID 0. Again the first 00 refers to cargo ID 0, and the second 00 is required because TTDPatch needs it.

我们可以对几个运输工具使用同样的图形,但通常没有用。对车厢来讲,我们可以定义多个货物ID并对运输不同的货物时附加不同的图形。但对火车头来讲,就不重要了,所以我们只使用货物ID0。第一个00指向货物ID0,第二个00是TTDPATCH需要的。(通常以00结尾)

At this point, we only need one more action: we need to tell TTDPatch to actually use these new graphics. Action 3 only says if the vehicle uses new graphics, then these are what it should use. To actually make it use new graphics we use Action 0, like this:
13 * 7 00 00 01 01 16 12 FD

现在,我们只需要再加一个脚本,我们需要告诉TTDpatch来使用这些新图形。脚本3仅仅定义了是否使用新图形,如果要使它能使用,我们使用脚本0,如下所示:

In more detail:
代码含义:


CodeMeaning
00Action 0
00Feature 0, meaning trains
01We set one property
01For one vehicle
16Starting at vehicle 16
12We set property 12 (sprite type)
FDAnd we set it to FD


代码含义
00脚本0
00特征0, 代表火车
01定义一个属性
01对一个运输工具
16从运输工具ID 16开始
12设置属性12 (sprite 类型)
FD属性参数设置为 FD



We could set more than one property to give the vehicle for example different power and speed, but for now we only want to see the new graphics, and for trains that means we need to set property 12 to FD, which tells TTDPatch to use new graphics for this vehicle ID. For the other property, check the action 0 docs.

我们可以对运输工具设置多个属性,例如不同的动力和速度,但现在我们只是设置替换图形,对火车而言,我们需要设置属性12 为FD,将告诉TTDpatch对这个ID的运输工具来使用新的图形,其它属性,请查看脚本0的文档

6) Adjust and renumber
调整和重编号

Now we're basically done, we told TTDPatch what graphics to use for what vehicle. We only need to renumber the file and adjust the first pseudosprite. So you go through all the entries, make sure they start at zero and that the following number increases by one. In this case, the last number ends up being 13.

现在,基础的已经做完了,我们告诉了TTDpatch使用什么图形来替换什么运输工具。我们只需要对文件重编号和调整第一个假sprite。因此你检查所有的段落,确认编号从0开始,后面每一段落的数字是递增的。在本文中,最后的编号为13。

Now we have to adjust the first entry, because it needs to tell TTDPatch how many lines to expect for the rest of the file. Since the last line is 13, we set it to 13, but we have to write it in hex in little endian format. 13 in hex is D, which has to have zeroes added from the left to make eight digits, or 0000000D. Now you cut these into groups of two (00 00 00 0D) and write them in the opposite order (0D 00 00 00). That's what you put in the first entry.

现在我们要调整第一段落,因为需要告诉ttdpatch剩余有多少行。既然有13行,我们设置为13,但是我们必须使用十六进制的D来表示13。因为需要增加0来满足8位数,例如0000000D。现在将它们按两位一组分隔开来(00 00 00 0D),然后反过来写(0D 00 00 00),这就是你第一段落的内容。

Now your mytrain.nfo file is done, and it should look like this:
现在,你的.nfo文件做好了,应该像如下所示:

// Automatically generated by GRFCODEC. Do not modify!
// (Info version 6)
// Format: spritenum pcxfile xpos ypos compression ysize xsize xrel yrel
0 * 4 0D 00 00 00
1 * 8 08 06 "TW" 03 05 00 00
2 * 4 01 00 01 08
3 C:\TTD\SPRITES\mytrain.pcx 66 8 01 18 8 -3 -10
4 C:\TTD\SPRITES\mytrain.pcx 82 8 09 15 20 -14 -6
5 C:\TTD\SPRITES\mytrain.pcx 114 8 01 12 28 -14 -6
6 C:\TTD\SPRITES\mytrain.pcx 162 8 09 16 20 -4 -8
7 C:\TTD\SPRITES\mytrain.pcx 194 8 01 18 8 -3 -10
8 C:\TTD\SPRITES\mytrain.pcx 210 8 09 16 20 -14 -7
9 C:\TTD\SPRITES\mytrain.pcx 242 8 01 12 28 -14 -6
10 C:\TTD\SPRITES\mytrain.pcx 290 8 09 15 20 -4 -7
11 * 9 02 00 00 01 01 00 00 00 00
12 * 7 03 00 01 16 00 00 00
13 * 7 00 00 01 01 16 12 FD


7) Encode and add
编译和增加

Now all we have to do is encode the file:

现在,我们要做的就是编译文件

grfcodec -e mytrain.grf


and then add it to newgrf(w).cfg to test it!

然后添加到游戏中测试

Make sure to check the GRF Status Window to see that your file is enabled. If not, click on its red flag and then click "apply". If you get any error messages, write down the sprite number that's incorrect, and then fix the mistake in the corresponding line in the mytrain.nfo file.

请检查grf状态窗口,看看你的grf是否能用。如果不能,请检查红色标记,然后选择运用。如果你得到错误信息,记下错误sprite的数字,然后修正.nfo文件里相应的行。

Further reading
更多

Basically, now you know most of what's needed to make your own graphics. Further details can be found in the GRFActionsDetailed page, which tells you everything about all the actions there are.

基本上,你已经知道了编译文件中绝大多数需要注意的地方。更多的细节可以查看grfactionsdetailed。

The next few sections will cover in some more detail the most common tasks for making new graphics, but other than that you're on your own now!

Action 0脚本0

Defining new graphics feature properties

定义新图形特征和属性

What does it do?

它是怎么工作

Action 0 is similar to TTDAlter in that it changes the feature properties of 'features', i.e. vehicles, stations, bridges, houses and more. That means that you can change properties like:

脚本0有点类似于TTDAlter,改变“特征”属性,运输工具、站台、桥梁、房屋等等的“特征属性”。也就是说,你可以来用修改以下属性:


  • vehicle introduction date
  • top speed
  • wagon capacity
and many more.

运输工具的信息、最高速度,车厢容量,以及更多

Format

格式

The data for Action 0 looks as follows:

脚本0的数据如下所示:

<Sprite-number> * <Length> 00 <Feature> <Num-props> <Num-info> <Id> (<roperty <New-info>)...

Here is a short overview of what every term means:
下表是每一个代码的含义

ElementSizeDescription
<Sprite-number> decA sequential sprite number
<Length> decThe total number of bytes in the action
00 BAction type. In this case, 00
<Feature> BWhich type of feature you would like to change
<Num-props> BHow many properties you would like to change per vehicle or station
<Num-info> BHow many vehicles/stations you would like to change
<Id> B*The ID of the first vehicle/station to change
<Property> BWhat property to change for each vehicle/station
<New-info> VThe new value of the property


代码数据类型描述
<Sprite-number> decsprite编号
<Length> dec在这个脚本的数据总量
00 B在本例中,定义为脚本0
<Feature> B你想要修改哪类特征
<Num-props> B你想要修改一个站台/运输工具的多少个属性
<Num-info> B你想要修改多少个站台/运输工具
<Id> B*第一个要修改的站台/运输工具的ID
<Property> B每个站台/运输工具的哪一个属性需要修改
<New-info> V修改后的属性值


You can put an Action 0 anywhere after Action 8 in the GRF file.

你可以将在脚本8之后的任何地方放置脚本0

The <Id> is an extended byte since 2.0.1 alpha 61, to support the definition of >255 sound effects.

从ttdpatch2.01.alpha 61 后,id字段被扩展用以支持>255的音效定义

Filling in the terms
填充代码

Sprite-numberAction 0 can appear anywhere in the GRF file, so set it to the sprite number you are currently at.

脚本0可以出现在grf文件的任何地方,所以将它设置为你目前所在行的编号

LengthThe total number of bytes in Action 0. Start counting from <Action>, the bit that sets the pseudo-sprite to act as the specified action.

脚本0中的总字节数,从<action>计算起,该位被设置成假sprite用来使脚本起作用

ActionThe type of action this pseudo-sprites defines. It should be 00 here because we want this pseudo-sprite to act as Action 0.

假sprite定义的脚本类型,这里我们需要设置00为假sprite来使脚本0起作用

FeatureThis sets the type of feature that you wish to change. Set it to:
本代码设置你想要修改的特征,设置如下:

00 for trains    火车
01 for road vehicles    汽车
02 for ships       轮船
03 for planes        飞机
04 for stations       站台
05 for canals        隧道
06 for bridges      桥梁
07 for houses (see defaults)   房屋(查看默认)
08 for global variables     全局变量
09 for industry tiles (see defaults)   
0A for industries (see defaults)     工业
0B for cargos (see defaults)    货物
0C for sound effects       音效
0D for airports (No official properties)   机场(非官方属性)
0E for signals (Action 0 is not valid for this feature)  信号灯(脚本0不可用在这个特征上)
0F for newobjects  新事物

Note that the above list is the master list for all actions where not stated otherwise.
(不会翻译)

Num-propsThis is the number of properties that you wish to change per vehicle or station. Note: even if you wish to set the same properties to the same value for different vehicles then you must still repeat the properties and their values for each vehicle.

这个数字定义了你想要修改的每个站台或者运输工具的属性。注意:即便你想要将不同运输工具的同一属性设置成同一个值,你也必须重复对每一个运输工具的设置

Num-infoSimply the number of vehicles that you will change using this action 0.

你想通过脚本0来修改的运输工具数量

IdThe Vehicle ID of the first vehicle or station to change. If num-info is greater than one, this vehicle/station and the following vehicles/stations will be changed.

你想要修改的第一个运输工具或站台的ID。如果数量大于一个的话,这个运输工具/站台和接下来的一个运输工具/站台将会被改变。

PropertyThe number of the property that will be changed. This and the New-info section are repeated as many times as there are properties to set; in total, there are <num-props> property bytes.
See relevant sub-section (links at the bottom) for more details.

这个数字是你将要修改的属性值。这和New-info字段一直重复到有多少个需要修改的属性值。这就是<num-pros>里设置的值。

New-infoThe new information that will replace the previous information for the specified property. This is a variable size; dependent upon the property. Each property byte is followed by <num-info> new-info sections.

新的信息将会取代指定属性的预定义信息。这是一个可变的数组,取决于属性,跟在<num-info>字段后。

The appropriate \b, \w, and \d escape sequences can be quite useful for most <new-info>s. See the discussion of escape sequences for further information.

适当的使用\b,\w和\d对更多的<new-info>有好处(排版顺序),请查看相关的讨论。

Features and properties
特征和属性

Each feature has its own very specific properties. These are explained in detail in the pages listed below:

每一个特征都有自己指定的属性,如下所示:




    Action0General - Action 0 properties common to all vehicle types   脚本0中所有运输工具类型的通用属性Action0Trains - Action 0 properties for trains  脚本0中火车的属性Action0RoadVehicles - Action 0 properties for road vehicles  脚本0中汽车的属性Action0Ships - Action 0 properties for ships  脚本0中轮船的属性Action0Planes - Action 0 properties for planes  脚本0中飞机的属性Action0Stations - Action 0 properties for new stations 脚本0中新站台的属性Action0Canals - Action 0 - Properties for canals / rivers 脚本0中隧道/河流的属性Action0Bridges - Defining properties of bridges 桥梁的属性定义Action0Houses - Action 0 properties of houses 脚本0中房屋的属性
    • DefaultHouseProps - Default property values for TTD's houses ttd中房屋的默认属性
    Action0GeneralVariables - Action 0 properties for general variables 脚本0中全局变量的属性Action0IndustryTiles - Action 0 properties for industry tiles 脚本0中 Action0Industries - Action 0 properties for industries 脚本0中工业的属性 Action0Cargos - Action 0 properties for cargo types 脚本0的货物类型的属性
    • CargoDefaultProps - Default property values for TTD's cargo types TTD中默认的货物类型属性
    Action0SoundEffects - Action 0 properties for new sound effects 脚本0中新音效的属性
  • Action0Objects - Action 0 properties for new objects 脚本0中新事物的属性

You will also find the minimum GRF version (in Action 8) that supports this property, or alternatively if the property was introduced between version changes, the patch version number that you can check with Action 7.

你也可以找到最低版本的grf(在脚本8中)来支持这个属性或者在脚本7中找到可选的替代这些的版本。

Example
例如

For examples please see the action 0 entries for each feature.

请查看脚本0的链接来获得详情

Action 0 - General properties for all vehicle types
脚本0-所有运输工具类型的通用属性

Defining properties of vehicles.

运输工具的属性定义

Introduction
The four vehicle types (trains, road vehicles, ships and planes) all have some common properties, which are described here.

介绍
四种运输工具(火车、汽车、轮船和飞机)都有一些共同的属性,如下所述:

Properties


NumberVersionSizeDescription
00Wdate of introduction
02Breliability decay speed
03Bvehicle life in years
04Bmodel life in years
06Bclimate availability
072Bload amount


属性


序号版本大小描述
00W引入日期(感觉像是提前通知的试用时间)
02B可靠性的衰减速度
03B寿命
04B(好像是制造日期)
06B适用的气候类型
072B装载量



Properties 00 to 06 only apply to new games, or when using Cht: ResetVehicles.

属性00-06只在新游戏里生效,或者使用作弊命令(TTDPATCH中)。

Description

描述

Date of introduction
引入日期

The date is specified as number of days since 1920 where TTD counts 365,25 days in a year. It will have a random number from 0 to 511 days added to it at the start of every new game, or after using "Cht: ResetVehicles". Note that TTD stops updating vehicle type data after the game ends in 2050, so all dates of introduction should be no later than in 2044, to ensure that all vehicle types can be introduced and reach their maximum reliability.

这个日期详述了一个天数,从1920年起,每一年为365.25天。在新开始一个游戏或者使用作弊命令时,将会随机增加0-511天在这个数上。注意,ttd会在2050后停止更新车辆类型,因此这个日期不能晚于2044年。以保证这个运输工具能引入且达到最大的可靠性。

If the property value is 729 (2D9h) or less, i.e. before 1922, the random number is not added and the vehicle is introduced at exactly the given date.

如果这个数小于等于729(2D9H),例如,在1922年前,这个数字就不再增加随机数了。

The \w<date> escape sequence is especially useful here. See the discussion of escape sequences for further information.

命令\w<日期>特别有用,请参考相关教程为获取更多的信息。

Reliability decay speed
可靠性的衰减速度

The reliability decay speed is set when a new vehicle is bought, and specifies how quickly the reliability decays after servicing. The initial TTD default for all vehicles is 20. If a vehicle goes without servicing for a long time, or if it gets very, very old, this number increases, meaning faster decay and more breakdowns. Larger numbers mean faster decay, smaller number slower decay. If set to 0, reliability never decreases in normal operation.

当一个运输工具购买以后,可靠性的衰减速度决定了该运输工具在维修后的可靠性衰减程序,

Vehicle life
运输工具的寿命

The number of years before a particular vehicle is considered too old and needs replacing,

决定了特定运输工具需要更新的年限。

Model life
模型年限

The number of years that this model can be bought in the game (if PersistentEngines is off). Usually this should be at least twice or three times as long as the vehicle life. When starting a new game, a random amount between 31 months and 17 years is added to this as well.

这个数字定义了这个运输工具可以购买的时间(如果ttdpatch里的某个开关为关的话,openttd里好像是车辆永不过期)。通常这个数字应该是运输工具寿命的2-3倍。当开始一个新游戏时,一个随机在31个月-17年的数字将会被加入这个数里。

If the early retirement property (26/1B/16/16) is not set, the model life works like this:

如果最早退役属性(26/1B/16/16)没有设置,模型年限将按以下方式运行:


PhaseDurationReliability
17 to 38 monthsincreases from 48-73% to 75-100%
2prop. 04 less 8 yearsstays constant at peak, 75-100%
310 to 20.5 yearsdecreases from peak to 25-50%


阶段持续时间可靠性
17 -38月由 48-73% 增加到 75-100%
24- 8年保持在 75-100%
310 -20.5年衰减到 25-50%



(the ranges in time and reliability are randomized at the start of each game)

时间和可靠性的范围在新游戏生成时随机生成。

At the end of phase 3, the model is retired and removed from the purchase list. Note that when the model reliability starts dropping in phase 3, so does the reliability of every single vehicle of this make in the game.

在阶段3之后,模型退役并从购买列表中移除。注意,当模型可靠性在第三阶段开始下降时,每一个由些模型制造的运输工具都会降低可靠性。

If persistentengines is on, the model never gets to within two years of the end of phase 2, it is kept in phase 2 as long as at least one vehicle of this make is in the game.

如果持续车头为开启的话,模型将不会到达阶段2的末两年,每一个由此模型制造的运输工具将保持在第2阶段

If the early retirement property is set, the vehicle is retired this many years before the end of phase 2 (can be negative if desired), but not if persistentengines would keep the model alive.

不会翻了

Climate availability
气候

This is a bit mask of the climates in which this model is available. Simply add the values for the climates:

模型在该气候不可用时,该字段设置了隐藏属性,仅仅添加以下值


BitValueClimate
01Temperate
12Arctic
24Tropical
38Toyland


气候
01温带
12寒带
24沙漠
38玩具




For example, 1+2+4 = 07 would make a vehicle available in all climates except Toyland.

例如:1+2+4=07将使一个运输可以在除玩具外的所有气候中使用。

Load amount
装载量

This is the amount of cargo transferred per unit of time if using gradualloading. The default is 5 for trains and road vehicles, 10 for ships and 20 for aircraft.

如果使用渐进装载的话,这个量是每单位时间货物的装载量。火车和汽车默认为5,轮船是10,飞机是20
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 转播转播 分享分享 分享淘帖 支持支持 反对反对
沙发
 楼主| Diablo 发表于 2013-6-22 15:48:48 | 只看该作者
Action 0 - Properties for train vehicles脚本0-火车属性

Defining properties of train vehicles.

定义了火车的属性



Properties

属性

Number版本/Version
大小/Size描述/Description
05BTrack type (0=railroad, 1=monorail, 2=maglev)
轨道类型,0=普通铁路,1=单轨,2=磁悬
08BAI special flag: set to 1 if engine is 'optimized' for passenger service (AI won't use it for other cargo), 0 otherwise
09WSpeed in mph*1.6 (see below)
速度(MPH单位)乘以1.6
(参加下文)
0BWPower (0 for wagons)
马力(0代表挂车)
0DBRunning cost factor (0 for wagons)
运行费用因素(0为挂车)
0EDRunning cost base, see below
基础运行费,参下
12BSprite ID (FD for new graphics)
13BDual-headed flag; 1 if dual-headed engine, 0 otherwise
14BCargo capacity
货物量
15BCargo type, see column 3 (type B) in CargoTypes
货物类型,参考 CargoTypes
16BWeight in tons
重量(吨)
17BCost factor
造价因素
18BEngine rank for the AI (AI selects the highest-rank engine of those it can buy)
Ai优先权(电脑玩家拥有AI,在游戏里他们只会买优先权最高的)
191BEngine traction type, see below
1A1BNot a property, but an action: sort the purchase list
1B6WPower added by each wagon connected to this engine, see below
1C6BRefit cost, using 50% of the purchase price cost base
1D6DBit mask of cargo types available for refitting, see column 2 (bit value) in CargoTypes
1E6BCallback flags bit mask, see below
1F(a)BCoefficient of tractive effort
20(b)BCoefficient of air drag
212BMake vehicle shorter by this amount, see below
226BSet visual effect type (steam/smoke/sparks) as well as position, see below
236BSet how much weight is added by making wagons powered (i.e. weight of engine), see below
24(c)BHigh byte of vehicle weight, weight will be prop.24*256+prop.16
25(c)BUser-defined bit mask to set when checking veh. var. 42
26(c)BRetire vehicle early, this many years before the end of phase 2 (see Action0General)
27(d)BMiscellaneous flags
28(d)WRefittable cargo classes
29(d)WNon-refittable cargo classes
2A(e)DLong format introduction date

序号版本大小描述
05B轨道类型 (0=铁轨, 1=单轨, 2=磁悬浮)
08B电脑玩家的特殊标志:如果该车头适合用于客运时,该值设置为1, 电脑将优先用于客运而不是货运。设置为0则无效。
09W以mph*1.6的速度 (参见后文)
0BW动力 (车厢为0)
0DB运营费用因子(车厢为0)
0ED运营基本费用(参见后文)
12BSprite ID (FD 为新图形图像)
13B多引擎标志; 1为是, 0 为否
14B可装载量
15B货物种类,参见第3 段(类型 B) CargoTypes
16B重量(吨)
17B购买成本因子
18B电脑玩家的引擎评价(AI选择所能购买引擎中评价最高的。)
191B引擎运输类型,参见后文
1A1B非属性值,索引购买列表
1B6W该车头所连接的每个车厢的附加动力,参见后文
1C6B改造费用,购买成本基本费用的50%
1D6D掩盖可改造的货物类型,参见第2段 (bit值)  CargoTypes
1E6BCallback flags bit mask, see below
1F(a)B索引系数??
20(b)B空气阻力系数
212B该值使得火车更短??参见后文
226B设置动画效果 (蒸汽/油烟/火花),参见后文
236B引擎重量及整趟列车总重量,参见后文
24(c)B运输工具的重量, 重量将是属性值24*256+属性值.16
25(c)B自定义的bit mask 用来检查车辆值. 42
26(c)B退役的运输工具,这个值设置了在第2阶段时的退役年限 (see Action0General)
27(d)B多样性标志
28(d)W可改造货物类型
29(d)W不可改造的货物类型
2A(e)D长格式的介绍文本


Version codes:  版本代号

CodeVersion
(a)2.0.1 alpha 19
(b)2.0.1 alpha 27
(c)2.0.1 alpha 44
(d)2.0.1 alpha 58
(e)2.5 r1210, OpenTTD r7191

代号版本 ttdpatch
(a)2.0.1 alpha 19
(b)2.0.1 alpha 27
(c)2.0.1 alpha 44
(d)2.0.1 alpha 58
(e)2.5 r1210, OpenTTD r7191


Comments  注释:
Speed (09)  速度(09)
Train speed is in units of mph*1.6, i.e. approximately km/h.

火车速度的单位是mph*1.6,也就是接近于公里/小时

For wagons, this value is only used if the "wagonspeedlimit" switch is on, and it limits the speed of the train to that of the lowest wagon speed. This limit is ignored for wagons with a livery override for the current train, so that train sets always get their max speed from the engine's max speed.

对车厢来说,这个值只在“车厢限速”为开时,才有用。这个值限定了火车速度为整趟列车中最低速度车厢的速度。

For wagons, a value of 0 means "default" (which depends on cargo type and date of introduction), and FFFF means no limit.

对车厢来讲,“0”为默认值(引进日期和货物类型决定的)FFFF为无限制

Power (0B) 动力(0B)
The power of the engine, in HP.  

引擎动力,单位:马力。

A value of 0 means that the vehicle will be a wagon, otherwise it will be an engine.

0代表着这个运输工具为车厢,否则将是一个车头。


Running cost base (0E) and factor (0D)    运营基本费用(0E)和因子(0D)
TTD calculates all costs by multiplying a 32-bit base amount with an 8-bit factor. The base amount is changed according to inflation, whereas the factor remains constant.

ttd通过一个32位的基本费用和8位的因子来计算所有的费用。基本费用由通货膨胀决定,而因子却保持不变。

For the running costs of train vehicles, the following base amounts are available depending on the vehicle type (the value here is a pointer into TTD's memory where the actual amount is stored):

对运营费用来讲,下列的基本费用将由运输工具类型来决定(这个值是一个指针来指向实际存储的费用)

TypeValuein little-endian notation
Steam engines4C3030 4C 00 00
Diesel engines4C3636 4C 00 00
Electric engines4C3C3C 4C 00 00
Wagons000 00 00 00

类型二进制表达方式
蒸汽机车4C3030 4C 00 00
内燃机车4C3636 4C 00 00
电力机车4C3C3C 4C 00 00
车厢000 00 00 00


Theoretically, you could use pointers to other base amounts available in TTD, but these are the numbers TTD uses for train vehicles.

理论上讲,你可以使用指针来指向ttd中其它基本可用的费用,但这些是ttd中用于火车的基本数字。

The following are some real values for maintenance costs depending on the setting of the above two factors. This value is correct for medium difficulty, but increases and decreases for hard and easy difficulties respectively. These are the costs of a new game starting in 1921, because they obviously increase with inflation over time (unless noinflation is turned on).

下面就是以上两个因素设置后,会影响到的一些真实的保养成本。这个值是以中等难度为校正的,而困难/简单条件下时将会增加/或减少。这些是一个开始于1921年的新游戏时的成本,因为它们受到通货膨胀的影响(除非禁止通货膨胀)

Running cost base 4C30 (steam)   基本运行成本 4C30(蒸汽)


Running cost factorMaintenance cost
01$ 42
10$ 700
20$ 1.400
80$ 5.600
A0$ 7.000
FF$ 11.112
运行费用因子维护费用
01$ 42
10$ 700
20$ 1.400
80$ 5.600
A0$ 7.000
FF$ 11.112


Running cost base 4C36 (diesel)   基本运行成本 4C36(内燃)

Running cost factorMaintenance cost
01$ 40
10$ 650
20$ 1.300
80$ 5.200
A0$ 6.500
FF$ 10.318
运行费用因子维护费用
01$ 40
10$ 650
20$ 1.300
80$ 5.200
A0$ 6.500
FF$ 10.318


Running cost base 4C3C (electric) 基本运行成本 4C36(电气)

运行费用因子维护费用
01$ 36
10$ 600
20$ 1.200
80$ 4.800
A0$ 6.000
FF$ 9.524
Running cost factorMaintenance cost
01$ 36
10$ 600
20$ 1.200
80$ 4.800
A0$ 6.000
FF$ 9.524


Cost factor (17)   购买成本因子
The cost factor is a bit-coded value which determines how expensive an engine is. There is no distinction between steam, diesel or electric engines, they all use the same cost factor. The table below gives you some values to use for finding the right price for your engines.

购买成本因子是决定车头的购买成本的。该因子不受到车型的影响,蒸汽、内燃及电力车头都受同一个因子影响。下面的列表给出的值将让你决定你所设计的车头的正确价格


Cost factor   购买因子

Cost factorPrice
01$ 3.124
10$ 50.000
20$ 100.000
80$ 400.000
A0$ 500.000
FF$ 796.874

购买因子价格
01$ 3.124
10$ 50.000
20$ 100.000
80$ 400.000
A0$ 500.000
FF$ 796.874



Engine traction type (19)   引擎动力类型
This sets the traction type of a train engine, i.e. whether it is powered by steam, diesel, electric, monorail or maglev technology. It also sets the corresponding sound effect of the engine, and if property 22 is not set, the visual effect as well.

这个值设置了火车动力类型,也就是蒸汽、内燃、电力、单轨或者磁悬浮。同时也设置了相对应的音效,如果属性22没有设置,动画效果也将是相对应的。

The following ranges are available (and it does not matter which value you pick):
下表中的范围是可用参数(你在范围内所挑选的值不影响效果)

ValuesTraction type
00..07Steam
08..27Diesel
28..31Electric
32..37Monorail
38..41Maglev
动力类型
00..07蒸汽
08..27内燃
28..31电力
32..37单轨
38..41磁悬浮



The default if this property is not set is 00, i.e. steam.
默认值为00,也就是蒸汽

Sort vehicle list (1A)   索引车辆列表(1A)

This is not a property as such, but an action. It forces TTDPatch to shuffle the vehicle this "property" is being set for in front of the vehicle with the given value of the property. The order of this list is only used in the train purchase window.

这个值不是一个属性值,而是一个脚本,仅在车辆购买列表中使用,用来靠前显示给定值的车辆。

For example, setting prop. 1A for vehicle 09 to a value of 07 would lead to the following internal list: ... 05 06 09 07 08 0A 0B ...

This property can not simply be overwritten, because the list is already shuffled when trying to do so. It is possible to reset the list to its original order with a special action 0 that has num-info set to 0, and only sets property 1A for trains:
00 00 01 00 00 1A

Resetting the list should however only be done by sets that contain replacements for all train vehicles.

Powered train wagons (1B and 23, see also 22)
Normally, train wagons are unpowered in TTD, and if you set property 0B to a non-zero value, they become engines instead. Therefore, to model real-life trains where wagons have power, a different mechanism is needed.

To make train wagons powered, you set property 1B of the engine instead of the wagon. This determines how much power each wagon adds to the train when attached to this engine. This only applies to wagons with a graphics override for this engine as well. This means that for example passenger wagons (with an override) will add power, but coal wagons (with no override) will not.

In addition to adding power, these wagons are also heavier by the amount set in property 23.

Callbacks (1E)
For trains, the following callbacks have to be enabled by setting the corresponding bit in property 1E (certain other, not as frequently used callbacks are available without setting a bit here):


BitValueVariable 0C valueCallback
0110Powered wagons and visual effect
1211Wagon length
2412Load amount
3815Set refitted capacity
41016Build articulated engines
52019show a suffix after the cargo type name
6402DSelect color mapping for vehicle
78033Sound effect callbacks


Bit is the bit you have to set, you do this by adding all the values for all the bits. Variable 0C value is what variable 0C will be set to, for checking it in the variational action 2 for callbacks.

Callbacks 1D (Can wagon be attached?), 23 (Additional text in purchase screen), 31 (Start/stop check), 32 (32-day callback), 34 (Autoreplace vehicle selection) and 36 (Change Vehicle Properties) do not need a bit to activate them, they are always active and will be used if defined in the action 3/action 2 chain.

Coefficient of tractive effort (1F)
This cofficient sets what fraction of the vehicle weight is equal to the maximum tractive effort. This includes the effect of having some unpowered axles, as well as the coefficient of friction that is available.

Theoretically, this value should be calculated by taking the ratio of adhesive weight Wadh (i.e. the vehicle weight that rests on powered axles) times the coefficient of friction &micro; between the wheels and the rails to the total vehicle weight W, times 255, and convert to hex:
prop. 1F = HEX ((Wadh * &micro; / W) * 255)

With prop. 1F having a value of FF, the tractive effort is equal to the vehicle weight, for 80, it is half, and so on. If not set, a default of 4C is used, for a fraction of 0.30, corresponding to Wadh=W and a coefficient of friction of 0.30, which is the value used by the patch before 2.0.1 alpha 19.

Sometimes you know the real-life tractive effort instead of adhesive weight and coefficient of friction. To help calculating prop. 1F in that case, here's a small example using the NS 1600 (Electric) with a mass of 84 tons and real-life tractive effort (TEreal) of 259 kN. To quickly find the value for property 1F you fill in the following formula:
prop. 1F = HEX ((TEreal / (Mass * g) * 255)

That may look confusing but you already know all variables:
prop. 1F = HEX ((259 / (84 * 9.8) * 255)
prop. 1F = HEX (0.3146 *255) = HEX(80.229)

HEX calculations only work with figures in the natural domain: each figure has to be a positive and round figure. Therefore the value you convert to HEX isn't 80.229 but 80:
HEX 80 = 50

Property 1F for the NS 1600 (Electric) would then be: 1F 50.

Coefficient of air drag (20)
This property sets the air drag coefficient c2 used for the realistic acceleration model, from 01 (no airdrag) to FF (most air drag) in arbitrary units. 00 means to use the default value that depends on the top speed (to simulate the fact that high-speed engines are more streamlined).

The default values are the following:

top speed (mph)<16162432486496128196256...
c2192128966448322416128


For higher speeds, the series is continued in the same manner.

Air drag in Newtons will then be c2*v*v with v in m/s, although it is probably futile to attempt to make c2 a realistic number due to the lack of TTd's consistent scaling. If a train doesn't reach its historical top speed, you might try setting the value of prop. 20 one or two steps lower than the default above, otherwise it's probably a good idea to leave it at the default.

Shorter train vehicles (21)
This property reduces the length of train vehicles, in units of 1/8th (12.5%). The value 00 means the vehicle has the full length, 01 means shorter by 1/8th (12.5%), up to 05=shorter by 5/8ths (62.5%). Larger numbers will not work properly, except at the end of the train*. The vehicle length is set whenever it leaves a depot. This property does not work for the first vehicle in a train (i.e. the engine).

* This means that it is only safe to use values larger than 05 in the length callback making sure that they are only returned for the very last vehicle in the train. Otherwise the train will occasionally fall apart, with the wagons after the shortest one stopping to move.

Visual effects and wagon power (22)
By default, the visual effect of train engines is determined by the traction type (property 19). With this option you can change the type of effect as well as the position of it relative to the vehicle. (Note, currently only the positioning of steam actually works.) The position of the effect provides a range from 0 to F that is added to the type of the effect.

Position 0 corresponds to a point half a vehicle length ahead of the vehicle, 4 is the front of the vehicle, 8 the middle, C the end and F is a half length behind the vehicle. Intermediate values are in-between.

Additionally, this property can be used to disable powered wagons of this type, although that is usually done with callback 10 instead (which has the same meaning as prop. 22, but is more flexible).

RangeEffect type
00..0FUse the default effect type from property 19, but reposition it
10..1FSteam puffs
20..2FDiesel fumes
30..3FElectric sparks
40Disable visual effect
80+10..80+3FSame as above, but disable wagon power
80+40Disable both visual effect and wagon power


For example, 28 would make the wagon powered and emit diesel fumes, but 80+28 = A8 would only emit the diesel fumes without adding power.

Miscellaneous flags (27)
This is a bit mask, with the following bits:

BitValueMeaning
01Vehicle tilts in curves, and thus gets speed bonus
12Uses two company colors
24Vehicle is a multiple unit (DMU/EMU), for colour selection


The tilting speed bonus only applies if all vehicles in the train have this bit set, and only if the "curves" switch is on. For realistic curves, it gives the train two free curving pieces with no speed decrease, and for other settings, it increases the curves setting by one (0->1, 1->2, 2->2).

Cargo classes (28, 29)
To make vehicle sets more compatible with future new cargo definitions, these two properties allow vehicles to define what type of cargo they should be refittable to. A wagon will be refittable to all cargo types that match the classes set in prop. 28 except for the ones that match the classes set in prop. 29. In addition, afterwards those cargo types listed in prop. 1D will be toggled. In terms of logic, it is
Refit list = (cargos from prop. 28 AND NOT cargos from prop. 29) XOR cargos from prop. 1D

This means, if a cargo type is in the list because it matches prop. 28 but not prop 29, having the respective bit set in prop. 1D will disable it again. Conversely, if the cargo type is not in the list, the bit in prop. 1D will add it. This way, if props. 28/29 are unset, prop. 1D will retain the original meaning, but it is still able to selectively add or remove certain cargo types even if props. 28/29 are used.

As a consequence, you have both full control over the cargo types that you know of (using prop. 1D), and those you don't know of yet (using props. 28/29). Leave the bits for cargos that you don't know of unset in prop. 1D, and set/clear the bits for known cargos to add/remove them from the list as appropriate.

The class list is a bit mask, with the following bits defined so far:

BitValueCargo classes
01Passengers
12Mail
24Express cargo (Goods,Food,Candy)
38Armored cargo (Valuables/Gold/Diamonds)
410Bulk freight (Coal,Grain etc.,Ore,Fruit)
520Piece goods (Livestock,Wood,Steel,Paper)
640Liquids (Oil,Water,Rubber)
780Refrigerated cargo (Food, Fruit)
8100Hazardous cargo (radioactive, explosive etc)
9200covered/sheltered freight (transportation in box vans, silo wagons, etc.)
158000Special (used for livery refit tricks rather than actual cargos)


Note that cargo types may belong to several classes. This is the reason for making two properties, an additive and a subtractive one, because this way a vehicle can be specified to be refittable to, for example, all express cargo that does not require refrigeration (i.e., from the default cargos, no food).

For the cargo types added in this way, the vehicle will probably have no specific graphics (in action 3) to show the cargo load. In this case, the default will be used, which should therefore be sufficiently generic-looking if possible. However, using vehicle variable 47 you can at least select the graphics most appropriate for the cargo type's class.

Long format introduction date (2A)
Set the vehicle introduction date, in days since the year 0. This takes account of leap years; dividable by 4, but not 100 unless 400. A start date of 1920-01-01 is obtained with a value of 701265 (51 B3 0A 00). This property must be set after property 00 to take effect. In TTDPatch, dates after 2044 will be limited to 2044.


Example

Below is an example of what a real Action 0 pseudo-sprite could look like for a train engine.
(A basic version)

10 * 14 00 00 03 01 02 09 C0 00 0B D8 0E 12 FD


BytesMeaning
10<Sprite-number>
14<Length>: of the action in bytes; start counting at 0 (<action>)
00<action>: sets this pseudo-sprite to function as action 0
00<Feature>: In this case Train
03<Num-props>: 3 Properties to change
01<Num-info>: 1 vehicle ID to make changes to
02<ids...>: vehcile ID (02 - Ploddyphut Choo-Choo)
Properties
09<Speed>
C0 00<Value>: Value for Speed (192 Km/h)
0B<Power>
D8 0E<value>: value for Power (3800 HP)
12<Sprite ID>
FD<value>: FD for new graphics

快速回复 返回顶部 返回列表