Difference between revisions of "ActionA"

From GRFSpecs
Jump to navigationJump to search
m (11 revisions)
(Mention Action A should not be used for non-original TTD sprites)
 
(4 intermediate revisions by 3 users not shown)
Line 1: Line 1:
 
== Introduction ==
   
'''''Modify TTD's sprites'''''
 
 
=Action A=
 
   
 
Modify TTD's sprites.
 
Modify TTD's sprites.
   
-=Introduction=-
 
   
 
Unlike actions 1 and 5, which add new sprites for new features or vehicles, action A modifies TTD's built-in sprites.
 
Unlike actions 1 and 5, which add new sprites for new features or vehicles, action A modifies TTD's built-in sprites.
   
  +
This means only sprites with a number up to (and including) 4895 may be replaced by action A. Sprites with higher numbers should not be replaced by action A, but rather action 5. It is technically possible to replace sprites with higher numbers, but the higher numbers are not stable. For example, whenever a new GUI sprite gets added to OpenTTD the canal sprite numbers will change, and a NewGRF using action A to replace the canal sprites will replace the wrong sprites.
-=Format=-
 
  +
  +
== Syntax ==
   
 
The data looks as follows:
 
The data looks as follows:
   
<pre> -+&lt;Sprite-number&gt; * &lt;Length&gt; 0A &lt;num-sets&gt; &lt;num-sprites&gt; &lt;first-sprite&gt;...+-</pre>
+
<Sprite-number> * <Length> 0A <num-sets> ( <num-sprites> <first-sprite> )...
   
  +
{|
||'''Element'''|[[GRFActionsDetailed|'''Size''']]|'''Description'''
+
!Element!![[GRFActionsDetailed|Size]]!!Description
   
  +
|-
&lt;Sprite-number&gt;|dec|A sequential sprite number
+
|<Sprite-number>||dec||A sequential sprite number
   
  +
|-
&lt;length&gt;|dec|The total number of bytes used in this action
+
|<length>||dec||The total number of bytes used in this action
   
  +
|-
0A|B|Defines action 0A
+
|0A||B||Defines action 0A
   
  +
|-
&lt;num-sets&gt;|B|How many sets of sprites to replace
+
|<num-sets>||B||How many sets of sprites to replace
   
  +
|-
&lt;num-sprites&gt;|B|How many consecutive sprites in this set
+
|<num-sprites>||B||How many consecutive sprites in this set
   
  +
|-
&lt;first-sprite&gt;|W|Number of first sprite in this set||
+
|<first-sprite>||W||Number of first sprite in this set
  +
|}
   
The set of &lt;num-sprites&gt; and &lt;first-sprite&gt; is repeated as often as &lt;num-sets&gt; specifies.
+
The set of <num-sprites> and <first-sprite> is repeated as often as <num-sets> specifies.
   
The following sprites will be RealSprites or RecolorSprites that replace the given TTD sprites. &nbsp;There must be as many of them as num-sprites of all sets added up.
+
The following sprites will be RealSprites or RecolorSprites that replace the given TTD sprites. There must be as many of them as num-sprites of all sets added up.
   
  +
== Description ==
-=Filling in the terms=-
 
   
===Sprite-number===
+
=== Sprite-number ===
   
 
This is just the number you are at.
 
This is just the number you are at.
   
===Length===
+
=== Length ===
   
 
Count the number of bytes in this action.
 
Count the number of bytes in this action.
   
===num-sets===
+
=== num-sets ===
   
 
This sets how many different sets of sprites to replace. Each set are a number of consecutive sprites.
 
This sets how many different sets of sprites to replace. Each set are a number of consecutive sprites.
   
===num-sprites===
+
=== num-sprites ===
   
 
How many consecutive sprites to replace in this particular set.
 
How many consecutive sprites to replace in this particular set.
   
===first-sprite===
+
=== first-sprite ===
   
 
The first sprite number to replace in this set.
 
The first sprite number to replace in this set.
   
-=Notes=-
+
=== Notes ===
   
 
You can find the sprite numbers by looking in trg1.pcx, they're the little numbers above each sprite, except for the climate-specific sprites which are more complicated.
 
You can find the sprite numbers by looking in trg1.pcx, they're the little numbers above each sprite, except for the climate-specific sprites which are more complicated.
Line 66: Line 73:
 
You set it to replace that number and add an Action7 which turns it off if it is not in the right climate.
 
You set it to replace that number and add an Action7 which turns it off if it is not in the right climate.
   
  +
In OpenTTD you can use the sprite aligner to get the sprite number, but be aware that only sprites with a number up to (and including) 4895 may be replaced by action A. For more information see the introduction.
One easy way to do this is to edit trg?<nowiki><nowiki>[r]</nowiki></nowiki>.grf, use grfdiff (part of the grfcodec package) to create a grd, and then use [http://www.bytetransfer.de/projects/ttdpatch/grdtogrf/|grdtogrf] to create a simple grf with the action A(s) written for you. The action7s still have to be added by hand.
 
 
You can as well use [http://www.bytetransfer.de/projects/ttdpatch/docs/|the online sprite id converter] found on the same site.
 
   
-=Example=-
+
== Example ==
   
 
Below is an example of what a real Action A pseudo-sprite could look like with the sprite entries under it.
 
Below is an example of what a real Action A pseudo-sprite could look like with the sprite entries under it.
   
<pre>3 * 5 &nbsp; &nbsp; 0A 01 0C 3A 08
+
<pre>3 * 5 0A 01 0C 3A 08
   
 
4 c:\ttd\sprites\farmset.pcx 66 8 09 31 64 -31 0
 
4 c:\ttd\sprites\farmset.pcx 66 8 09 31 64 -31 0
Line 100: Line 105:
 
15 c:\ttd\sprites\farmset.pcx 2 72 09 30 55 -29 0</pre>
 
15 c:\ttd\sprites\farmset.pcx 2 72 09 30 55 -29 0</pre>
   
  +
{|
||'''Byte'''|'''Meaning'''
+
!Byte!!Meaning
   
  +
|-
3|&lt;sprite-number&gt;
+
|3||<sprite-number>
   
  +
|-
5|&lt;length&gt; of the action in bytes; start counting at 0A (&lt;action&gt;)
+
|5||<length> of the action in bytes; start counting at 0A (<action>)
   
  +
|-
0A|&lt;action&gt;: sets this pseudo-sprite to function as action A
+
|0A||<action>: sets this pseudo-sprite to function as action A
   
  +
|-
01|&lt;num-sets&gt;: sets it to 1 set to replace
+
|01||<num-sets>: sets it to 1 set to replace
   
  +
|-
0C|&lt;num-sprites&gt;: sets it to 12 sprites in this set.
+
|0C||<num-sprites>: sets it to 12 sprites in this set.
   
  +
|-
3A 08|&lt;first-sprite&gt;: First Sprite of the set (3A 08 - Farms)||
+
|3A 08||<first-sprite>: First Sprite of the set (3A 08 - Farms)
  +
|}

Latest revision as of 09:34, 29 December 2023

Introduction

Modify TTD's sprites.


Unlike actions 1 and 5, which add new sprites for new features or vehicles, action A modifies TTD's built-in sprites.

This means only sprites with a number up to (and including) 4895 may be replaced by action A. Sprites with higher numbers should not be replaced by action A, but rather action 5. It is technically possible to replace sprites with higher numbers, but the higher numbers are not stable. For example, whenever a new GUI sprite gets added to OpenTTD the canal sprite numbers will change, and a NewGRF using action A to replace the canal sprites will replace the wrong sprites.

Syntax

The data looks as follows:

<Sprite-number> * <Length> 0A <num-sets> ( <num-sprites> <first-sprite> )...
Element Size Description
<Sprite-number> dec A sequential sprite number
<length> dec The total number of bytes used in this action
0A B Defines action 0A
<num-sets> B How many sets of sprites to replace
<num-sprites> B How many consecutive sprites in this set
<first-sprite> W Number of first sprite in this set

The set of <num-sprites> and <first-sprite> is repeated as often as <num-sets> specifies.

The following sprites will be RealSprites or RecolorSprites that replace the given TTD sprites. There must be as many of them as num-sprites of all sets added up.

Description

Sprite-number

This is just the number you are at.

Length

Count the number of bytes in this action.

num-sets

This sets how many different sets of sprites to replace. Each set are a number of consecutive sprites.

num-sprites

How many consecutive sprites to replace in this particular set.

first-sprite

The first sprite number to replace in this set.

Notes

You can find the sprite numbers by looking in trg1.pcx, they're the little numbers above each sprite, except for the climate-specific sprites which are more complicated.

Unlike actions 1 and 5, the real sprites of action A do not count towards the sprite limit.

To replace sprites in other climates, you first need to find out what the sprite number is trg1.grf.

You set it to replace that number and add an Action7 which turns it off if it is not in the right climate.

In OpenTTD you can use the sprite aligner to get the sprite number, but be aware that only sprites with a number up to (and including) 4895 may be replaced by action A. For more information see the introduction.

Example

Below is an example of what a real Action A pseudo-sprite could look like with the sprite entries under it.

3 * 5     0A 01 0C 3A 08

4 c:\ttd\sprites\farmset.pcx 66 8 09 31 64 -31 0

5 c:\ttd\sprites\farmset.pcx 146 8 09 31 64 -31 0

6 c:\ttd\sprites\farmset.pcx 226 8 09 45 48 -15 -11

7 c:\ttd\sprites\farmset.pcx 290 8 09 33 22 1 -10

8 c:\ttd\sprites\farmset.pcx 322 8 09 31 64 -31 0

9 c:\ttd\sprites\farmset.pcx 402 8 09 29 57 -26 -4

10 c:\ttd\sprites\farmset.pcx 466 8 09 31 64 -31 0

11 c:\ttd\sprites\farmset.pcx 546 8 09 31 39 -19 -6

12 c:\ttd\sprites\farmset.pcx 594 8 09 31 64 -31 0

13 c:\ttd\sprites\farmset.pcx 674 8 09 49 28 -6 -28

14 c:\ttd\sprites\farmset.pcx 722 8 09 31 64 -31 0

15 c:\ttd\sprites\farmset.pcx 2 72 09 30 55 -29 0
Byte Meaning
3 <sprite-number>
5 <length> of the action in bytes; start counting at 0A (<action>)
0A <action>: sets this pseudo-sprite to function as action A
01 <num-sets>: sets it to 1 set to replace
0C <num-sprites>: sets it to 12 sprites in this set.
3A 08 <first-sprite>: First Sprite of the set (3A 08 - Farms)