OJT Format (Shadowcaster)
Jump to navigation
Jump to search
Overview
Shadowcaster OJT files describe a list of static objects present in a given level. These files are a linear list of 57-byte records with no header.
uint32_t Tag; // does not have to necessarily be unique.
uint32_t Ptr_Prev; // typically if there is a previous OJT record before this one, this is set to sizeof(ojt_record) (57).
uint32_t Ptr_Next; // same as above, but forwards in the file.
uint8_t Collision; // typically zero for a non-solid object, or 1 for a solid one.
uint8_t Gravity; // a bitfield describing the object's relationship to gravity.
// some known values: 0 = no gravity; 1 = hangs from ceiling; 3 = spawn on ceiling, subject to gravity.
char DisplayName[20]; // not used by the game. a string that usually contains the name of the sprite used. seems to be an editor leftover?
uint32_t Pic; // a literal lump number from RAVDATA.DAT. This is the graphic the object will use in the 3D view.
uint32_t Width; // the object's width (or "radius" if you prefer), represented in frac-units (0-63 within a tile).
uint32_t Height; // same as the above, but the object's height along Z+.
uint32_t Unknown;
uint8_t TileX;
uint8_t TileY; // the object's coarse tile X/Y coordinates (0-31 are valid).
uint8_t Sides; // the number of sides the sprite has. for example: 0 = one-sided sprite, 8 = eight-sided sprite (like Doom).
uint16_t SubTileX;
uint16_t SubTileY; // the object's sub-tile X/Y fractional values (0-63 are valid).
Reading an OJT file
Adapted from MapCaster GML:
for(i = 0; i < NumOjtsInFile; i++) {
ojt.Tag = buffer_read(ojt_file, buffer_u32);
ojt.Ptr_Prev = buffer_read(ojt_file, buffer_u32);
ojt.Ptr_Next = buffer_read(ojt_file, buffer_u32);
ojt.Collision = buffer_read(ojt_file, buffer_u8);
ojt.Gravity = buffer_read(ojt_file, buffer_u8)
ojt.DisplayName = ReadString(20);
ojt.Pic = buffer_read(ojt_file, buffer_u32);
ojt.Width = buffer_read(ojt_file, buffer_u32);
ojt.Height = buffer_read(ojt_file, buffer_u32);
ojt.Unknown = buffer_read(ojt_file, buffer_u32);
ojt.x = buffer_read(ojt_file, buffer_u8) * TILESIZE; // TILESIZE = 64 in Shadowcaster
ojt.y = buffer_read(ojt_file, buffer_u8) * TILESIZE; // TILESIZE = 64 in Shadowcaster
ojt.Sides = buffer_read(ojt_file, buffer_u8);
ojt.x += buffer_read(ojt_file, buffer_u16);
ojt.y += buffer_read(ojt_file, buffer_u16);
}