RGFX

From OHRRPGCE-Wiki
Jump to navigationJump to search
Wip.png
This article or section discusses a brand new feature which is not included in the latest stable version, and may not even be in the next stable version. It can, however, be found in a nightly build, which can be found on the Downloads page. If you wish to discuss this feature, feel free to use the talk page or contact the developers.

.rgfx (RELOAD graphics) files are a RELOAD-based file format which stores spritesets or backdrops, including animations and other metadata. All previous PT# and MXS graphics lumps except for tilesets (TIL) are upgraded to .rgfx files as of Fufluns. Fonts (FNT) will likely also be converted to a .rgfx or a variant in future.

Each .rgfx file has its own set of global animations, which are used as the defaults for all spritesets in that file which don't provide at least one animation with that name.

Currently the following lumps exist:

Lump name Type of Sprite Previous lump Default dimensions Fixed size Mainly used by
attacks.rgfx Attack spritesets .PT6 50x50 x 3 No Attacks
backdrops.rgfx Backdrops .MXS N/A No Textboxes, Formations, GEN
boxborders.rgfx Box borders .PT7 16x16 x 16 Yes UI colors & box styles
enemies.rgfx Enemy spritesets .PT1, .PT2, .PT3 N/A No Enemies
heroes.rgfx Hero spritesets .PT0 32x40 x 8 No Heros
portraits.rgfx Portrait spritesets .PT8 50x50 x 1 No Textboxes, Heroes
walkabouts.rgfx Walkabout spritesets .PT4 20x20 x 8 No Heros, NPCs
weapons.rgfx Weapon spritesets .PT5 24x24 x 2 No Items

If an .rgfx file is missing, the old .pt/.mxs file is loaded instead.

Default dimensions and frame counts don't really matter.

Box borders can't have animations, and must have 16 16x16 frames with frame ids 0...15.

Enemies backcompt mapping[edit]

When old games are upgraded, the old small/medium/large enemy graphics lumps are combined into a single lump called enemies.rgfx. Each of the old graphics is assigned a new ID number in enemies.rgfx in addition to their old ID number, so they can be referred to in either way. When the upgrade occurs, first all small enemy sprites get ID numbers counting upwards from 0, then the medium ones get the next IDs, and finally the large sprites. So if you had 10 + 5 + 4 sprites, the last large enemy sprite becomes enemy spriteset ID 18. After upgrade you can continue adding more small/medium/large sprites, and they get the next available ID number, so will no longer be in small,medium,large order.

To find the enemy sprite ID of a small/medium/large enemy sprite, use the lookup table contained in backcompat_ids.

rgfx file format[edit]

All nodes are mandatory if not indicated as (optional) or (multiple).

  • rgfx - Root node
    • version int - Equal to CURRENT_RGFX_VERSION, currently 1. Used to indicate backwards-incompatible changes (though you could try to read a future-version file, don't modify it or you might produce something corrupt)
    • spritesets - Holds the sprites.
      • spriteset int (multiple) - One per spriteset. Value is the spriteset ID, counting from 0. Spriteset can appear in any order!
        • defpal int (optional) - The default "16-color" palette (indexing into the master palette). Present only for "double paletted" 4/8-bit sprites. If absent, the sprite is "single paletted" directly using the master palette. Currently, Backdrops are always single paletted, other sprites are always double paletted.
        • info str (optional) - Description. Currently saved only for converted enemy graphics, a string like "Small Enemy 3".
        • animations (optional) - See #animations. May be omitted if there are none, even if other spritesets have animations.
        • frameset - See #frameset. The frames.
    • animations (optional) - See #animations. The global animations. May be omitted if there are none, even if spritesets have animations.
    • backcompat_ids (optional) - Only present in enemies.rgfx, and optional there too. Has one child for each small/medium/large enemy sprite.
      • key int (multiple) - Equal to (ptno * 1000000 + id) where ptno = {smallenemy: 1, mediumenemy: 2, largeenemy: 3}, and id is the original small/medium/large spriteset ID
        • idx int - The new ID number, as used in spritesets

frameset[edit]

Stores an array of Frames, that is, images. In future they'll likely also occur in other lumps.

Each frame is the same size, format, and bitdepth. There must be at least one frame.

  • frameset
    • format int (optional, default 0) - Storage format of the pixel data in image. An unknown value means the data can't be read.
      0: row-major order, bits bits per pixel, so each image node is w*h*bits/8 bytes long.
    • bits int (optional, default 8) - Equal to 8 for paletted data (including originally 4-bit graphics), or 32 for BGRX (X should be set to 255) (Note: 32 bit Frames are never saved yet, so I might change this to RGBA/RGBX)
    • w int - Width of each frame
    • h int - Height of each frame
    • frames
      • frame (multiple) - Frame nodes must appear in order of increasing id.
        • id - Frame ID. Must be non-negative and unique in this frameset.
        • image string - Pixels stored according to format.

animations[edit]

An animations node holds either animations specific to a spriteset or the global animations.

There can be multiple animations with the same name. Typically they will have different variants (if they don't, the later ones will be shadowed, but must be preserved).

  • animations
    • anim (multiple)
      • name str - Animation name, eg "walk"
      • variant str (optional) - Variant, eg "left"
      • ops - Sequence of animation commands. Each child is one of the following:
        • wait (multiple) - Wait milliseconds. Displayed in number of ticks.
          • arg1 int - Milliseconds
        • waitms (multiple) - Wait milliseconds. Displayed in milliseconds.
          • arg1 int - Milliseconds
        • frame (multiple) - Change the frame
          • arg1 int - Frame ID
        • repeat (multiple) - End of animation, loop to the top unless looping disabled, in which case stop.
        • setoffset (multiple) - Set the visual offset of the sprite
          • arg1 int - X
          • arg2 int - Y
        • addoffset (multiple) - Change the visual offset of the sprite by adding to its existing one
          • arg1 int - X
          • arg2 int - Y