Guest User

revenant-maps-dat-file-format.ksy

a guest
Feb 8th, 2024
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
YAML 18.31 KB | Gaming | 0 0
  1. meta:
  2.   id: revenant_map_sector
  3.   file-extension: dat
  4.   endian: le
  5.  
  6. doc: |
  7.   REVENANT MAP SECTOR FILE FORMAT
  8.    This document is intended for those who wish to make large
  9.    scale map editors for Revenant custom modules. Currently Revenant
  10.    does not have a large scale map editor, which makes it difficult to
  11.    realize the grand scope and vision of many potential game designer worlds.
  12.    With the ability to directly generate Revenant sector files, the aspiring
  13.    designer can build his own tools, or use third party tools to generate
  14.    the large areas in his main map.
  15.    
  16.    Revenant Maps and Sectors
  17.    After unzipping a revenant RVM module file, you will find a subdirectory
  18.    in the module called MAP. This directory will typically contain a large
  19.    number of Revenant map sector files. These files describe the objects
  20.    and tiles appearing at a specific location at a specific level in a map
  21.    for that module. In revenant, game maps are divided up into levels, and
  22.    sectors. A level is complete and separate continuous map. A revenant
  23.    module may contain up to 255 levels. A sector is a 1024 by 1024 map unit
  24.    grid within a level map that describes every object contained within in.
  25.    Each sector is stored in a separate file, with the name of the file
  26.    indicating the level number and the x,y sector location in that level.
  27.    
  28.    Sector filenames are formatted as follows: lv_sx_sy.DAT
  29.    Where 'lv' is a level number from 0 to 255, 'sx' and 'sy' are the x,y
  30.    position of the sector in map units divided by 1024. Since maps have a
  31.    maximum size of 32,768 x 32,768 units, the x,y sector numbers go
  32.    from 0 to 31.
  33.    
  34.    For example, a file with the filename: 2_5_15.DAT Would contain all the
  35.    tiles, characters, gold, etc. for the section of map level 2
  36.    from x = 5120 (5 * 1024) to 6143, y =  15360 (15 * 1024) to 16383.
  37.    
  38.    Map Sector File Format
  39.    The basic format of a map sector file is simply a small file header,
  40.    followed by a streamed list of unordered 'objects' that are within that
  41.    sector. Objects are considered to be in the sector in which their
  42.    registration point (the position shown in the game editor when moving
  43.    the object) is between the minimum and maximum x,y map units for that
  44.    sector. This means that the edges of objects can overlap into other
  45.    sectors (and usually do), since the registration point of an object
  46.    is typically near the center of the object.
  47.    
  48.    NOTE: object x,y positions stored in object records do not necessarily
  49.    have to be within the sector boundries.  The upper bits of the object
  50.    position are set when the object is loaded so the object will always be
  51.    within the sector it was loaded from regardless of what it's x,y position
  52.    is in its object record. This means that sector files can be renamed to
  53.    'move' a sector to a new map location. The original revenant large scale
  54.    maps were created using this renaming scheme.
  55.  
  56. seq:
  57.   - id: header
  58.     type: sector_header
  59.     doc: |
  60.      After the header, the objects are stored in no particular order..
  61.  
  62.   - id: objects
  63.     type: object_record
  64.     repeat: expr
  65.     repeat-expr: header.obj_count
  66.     doc: |
  67.      All object records begin with the same common object header.
  68.       This header contains the basic object type, the size of the
  69.       object data block, and also the size of the object inventory block.
  70.       These block size can be used to skip objects in a file, or to check to
  71.       see if an overflow or underflow has occured when reading object data.
  72.  
  73. types:
  74.   str_with_len:
  75.     seq:
  76.       - id: len
  77.         type: u1
  78.          
  79.       - id: value
  80.         type: str
  81.         size: len
  82.         encoding: KOI8-R
  83.  
  84.   sector_header:
  85.     seq:
  86.       - id: magic
  87.         contents: [0x4d, 0x41, 0x50, 0x20]
  88.         doc: |
  89.          Four character code signature "MAP " (space at end)
  90.       - id: version
  91.         type: u4
  92.         valid:
  93.           eq: 15
  94.         doc: |
  95.          The version number of the file (currently 15)
  96.       - id: unknown1
  97.         type: u4
  98.       - id: obj_count
  99.         type: u4
  100.         doc: |
  101.          Number of map objects in the file
  102.  
  103.   object_record:
  104.     seq:
  105.       - id: obj_version
  106.         type: s2
  107.         doc: |
  108.          Object version number. This is used internally for versioning of
  109.           object data (i.e. when we add new data to an object, we increment
  110.           this value so that the stream functions can read older data
  111.           files correctly). If this value is -1, this means that there is
  112.           an empty space in the sector at this index. No more data is read
  113.           after a -1 place holder (the next object record begins immediately
  114.           after the -1).
  115.  
  116.       - id: obj_data
  117.         if: obj_version != -1
  118.         type: common_obj_header
  119.  
  120.   common_obj_header:
  121.     seq:
  122.       - id: obj_class
  123.         type: u2
  124.         enum: obj_class
  125.         doc: |
  126.          The class of the object. This is the same as the classes
  127.           in the CLASS.DEF file
  128.       - id: unique_id
  129.         type: u4
  130.         doc: |
  131.          The object unique id value for this object from the
  132.           CLASS.DEF file. (The 0xFFFFFFF values).
  133.           The unique id is the tag used to lookup what kind
  134.           of object this is in the game objects list. Each
  135.           object of any given type (i.e. Greater Healing
  136.           Potion) has a separate unique id.
  137.       - id: obj_data_size
  138.         type: u2
  139.         doc: |
  140.          Size of the object's data block following the common object header.
  141.           The includes ONLY the data for the object itself, not it's
  142.           inventory list.
  143.       - id: block_size
  144.         type: u2
  145.         doc: |
  146.          Complete size of the object following the common object header
  147.           including both the object data and it's following inventory data.
  148.           If no inventory data is stored, this will be identical
  149.           to obj_data_size
  150.          
  151.       - id: object_data
  152.         size: obj_data_size
  153.         if: obj_data_size > 0
  154.         type:
  155.           switch-on: obj_class
  156.           cases:
  157.             'obj_class::character': object_data_block_for_character
  158.             'obj_class::container': object_data_block_for_container
  159.             _: object_data_block_for_rest
  160.  
  161.   object_data_block_for_rest:
  162.     seq:
  163.     - id: base_obj_data
  164.       type: common_base_object_data
  165.      
  166.     - id: base_obj_data_after_pos
  167.       type: common_base_object_data_after_pos(base_obj_data.flags)
  168.      
  169.   object_data_block_for_container:
  170.     seq:
  171.     - id: base_obj_data
  172.       type: common_base_object_data
  173.      
  174.     - id: velocity_data
  175.       type: velocity_object_data_block
  176.      
  177.     - id: base_obj_data_after_pos
  178.       type: common_base_object_data_after_pos(base_obj_data.flags)
  179.      
  180.     - id: num_items
  181.       type: u4
  182.       doc: |
  183.        INVENTORY DATA BLOCK
  184.         The inventory data block is simply the number of items in the object's
  185.         inventory, followed by each item in the inventory. If there are NO
  186.         items in the inventory, the inventory block will not be stored, and
  187.         the ObjDataSize will be identical to the BlockSize in the object header.
  188.         DWORD   NumItems        Number of items in the inventory for this object
  189.         This is then followed by each of the objects that are contained in
  190.         this object's inventory.  NOTE: inventory's can be nested arbitrarily
  191.         deep, but except for players (which are NOT stored in sector files),
  192.         the inventory of most objects in the game will only be 1 level deep.
  193.         Typically only monsters and container objects have inventories.
  194.      
  195.   common_base_object_data:
  196.     seq:
  197.     - id: name
  198.       type: str_with_len
  199.       doc: |
  200.        The name of the object. If this is blank, the name of the object
  201.         type will be used for this object.
  202.      
  203.     - id: flags
  204.       type: object_flags
  205.       doc: |
  206.        The flags for this object. See the flag table below for
  207.         descriptions of these flags.
  208.        
  209.     - id: pos_x
  210.       type: s4
  211.       valid:
  212.         min: 0
  213.         max: 32768
  214.       doc: |
  215.        The map unit location of the object. This is an absolute position
  216.         relative to the origin of the map (top corner of map in the editor
  217.         with x going down and right, and y going down and left). The x and
  218.         y positions of the object should be within the current sector boundry
  219.         (though they don't have to be). X,Y values can be from 0 to 32768,
  220.         and the Z value can be from 0 to 511. Values of Z below 0, or
  221.         above 511 will NOT work.
  222.     - id: pos_y
  223.       type: s4
  224.       valid:
  225.         min: 0
  226.         max: 32768
  227.     - id: pos_z
  228.       type: s4
  229.       valid:
  230.        # min: 0
  231.         max: 511
  232.        
  233.   common_base_object_data_after_pos:
  234.     params:
  235.       - id: flags
  236.         type: object_flags
  237.        
  238.     seq:
  239.     - id: state
  240.       type: u2
  241.       doc: |
  242.        The current display or animation state for this object. This is the
  243.         same as the index set by the STATE command in the editor.
  244.      
  245.     - id: invent_num
  246.       type: s2
  247.       doc: |
  248.        The index in the parent objects inventory this object is at.
  249.         This is the 'slot number' the object is in in the inventory panel
  250.         if the object is in an inventory.
  251.        
  252.     - id: invent_index
  253.       type: s2
  254.       doc: |
  255.        This is the number of the object in the parent objects inventory list.
  256.        
  257.     - id: shadow_map_id
  258.       type: s4
  259.       doc: |
  260.        NOT USED
  261.    
  262.     - id: rot_x
  263.       type: u1
  264.       valid:
  265.         min: 0
  266.         max: 255
  267.       doc: |
  268.        0-255 rotatation angles for 3D objects. The RotZ value is the facing
  269.         angle of the object used by the FACE command.
  270.     - id: rot_y
  271.       type: u1
  272.       valid:
  273.         min: 0
  274.         max: 255
  275.     - id: rot_z
  276.       type: u1
  277.       valid:
  278.         min: 0
  279.         max: 255  
  280.        
  281.     - id: map_index
  282.       type: s4
  283.       doc: |
  284.        This is the object's unqiue id map index. Each object, when added
  285.         to a map, is given a uinique id generated by a random number generator
  286.         that uniquely identifies it in the game. This is used as the primary
  287.         object id in network game messages as well.
  288.      
  289.   velocity_object_data_block:
  290.     seq:
  291.     - id: vel_x
  292.       type: s4
  293.       doc: |
  294.        The velocity of the object in map units. THIS IS ONLY STORED IF
  295.         THE OF_MOBILE FLAG FOR THE OBJECT IS SET. SKIP THIS IF AN OBJECT
  296.         IS NOT MOBILE. This value is a fixed point 16.16 value.
  297.        
  298.         NOTE: I don't think the above note about "OF_MOBILE" flag is true.
  299.         I tried implementing it and it made things misalign further down
  300.         the struct (basically for all characters 12 bytes were "missing"
  301.         between pos and state, and that's exactly 3 ints from vec_xyz).
  302.         So regardless of of_immobile flag, we still observe 3 vec_*
  303.         parameters here. Also, there's no such thing as "OF_MOBILE" flag.
  304.     - id: vel_y
  305.       type: s4
  306.     - id: vel_z
  307.       type: s4
  308.      
  309.   object_data_block_for_character:
  310.     seq:
  311.     - id: complex_obj_ver
  312.       type: u1
  313.       valid:
  314.         eq: 1
  315.       doc: |
  316.         The version of the complex object system for this   character.
  317.         Complex objects are used to implement characters and players in
  318.         the game. This is always 1.
  319.        
  320.     - id: char_obj_ver
  321.       type: u1
  322.       doc: |
  323.        The character object version. This version number is supposed to be
  324.         always 4, but it isn't, not sure why.
  325.  
  326.     - id: base_obj_data
  327.       type: common_base_object_data
  328.      
  329.     - id: velocity_data
  330.       type: velocity_object_data_block
  331.      
  332.     - id: base_obj_data_after_pos
  333.       type: common_base_object_data_after_pos(base_obj_data.flags)
  334.        
  335.     - id: frame
  336.       type: s2
  337.       doc: |
  338.        Current animation frame this object is playing.
  339.     - id: frame_rate
  340.       type: s2
  341.       doc: |
  342.        NOT USED (always set to 1).
  343.        
  344.     - id: group
  345.       type: u1
  346.       doc: |
  347.        The group number of this object used in the editor with the GROUP
  348.         command and the grouping system.
  349.        
  350.     - id: object_data_stats
  351.       type: object_data_block_stats
  352.      
  353.     - id: action_code
  354.       type: u1
  355.       doc: |
  356.        Internal action id number. Use 1 when storing your own characters.
  357.    
  358.     - id: action_name
  359.       type: str_with_len
  360.       doc: |
  361.        Name of action character is currently performing. This is the same
  362.         as the state (or animation) name used in the editor. The default
  363.         string is "walk" for NPC's and "combat" for monsters. These action
  364.         names will put the character/monster in its neutral state.
  365.  
  366.     - id: last_health_ts
  367.       type: u4
  368.       doc: |
  369.        Timestamp of last health increase. This is used to update the
  370.         health for monsters which may have been unloaded for a certain
  371.         amount of game time.
  372.     - id: last_fatigue_ts
  373.       type: u4
  374.       doc: |
  375.        Timestamp of last fatigue increase.
  376.     - id: last_mana_ts
  377.       type: u4
  378.       doc: |
  379.        Timestamp of last mana increase.
  380.     - id: last_poison_ts
  381.       type: u4
  382.       doc: |
  383.        Timestamp of last poison damage
  384.        
  385.     - id: tel_x
  386.       type: s4
  387.       doc: |
  388.        Teleport X, Y, Z (don't use)
  389.     - id: tel_y
  390.       type: s4
  391.       doc: |
  392.        Teleport X, Y, Z (don't use)
  393.     - id: tel_z
  394.       type: s4
  395.       doc: |
  396.        Teleport X, Y, Z (don't use)
  397.     - id: tel_level
  398.       type: s4
  399.       doc: |
  400.        Teleport level (don't use)
  401.      
  402.   object_data_block_stats:
  403.     seq:
  404.     - id: num_stats
  405.       type: u1
  406.       doc: |
  407.        Object statistics are listed at this point in the BASE OBJECT DATA
  408.         portion of the object data. The object stats available for an object
  409.         are listed in the CLASS.DEF file in the OBJSTAT sections. The game
  410.         uses a four character code for each stat to match the stats in the
  411.         sector files to the stats in the game.
  412.  
  413.     - id: stats
  414.       type: object_stat
  415.       if: num_stats > 0
  416.       repeat: expr
  417.       repeat-expr: num_stats
  418.      
  419.   object_stat:
  420.     seq:
  421.       - id: stat_value
  422.         type: s4
  423.         doc: |
  424.          Stat value for this stat.  This may be the health, max health, etc
  425.        
  426.       - id: encrypted_id
  427.         type: u4
  428.         doc: |
  429.          This is the weakly encrypted StatID. Simply `and` this value with
  430.           0x7F7F7F7F and you will get the four character stat codes
  431.           listed in the CLASS.DEF file.
  432.    
  433.   object_flags:
  434.     seq:
  435.     - id: of_immobile
  436.       type: b1
  437.       doc: Not affected by gravity etc (the velocity will be stored if set)
  438.    
  439.     - id: of_editorlock
  440.       type: b1
  441.       doc: Object is locked down (can't move in editor)
  442.    
  443.     - id: of_light
  444.       type: b1
  445.       doc: Object generates light (light data record will be stored for obj)
  446.    
  447.     - id: of_moving
  448.       type: b1
  449.       doc: Object is a moving object (characters, exits, missiles, etc.)
  450.    
  451.     - id: of_animating
  452.       type: b1
  453.       doc: Has animating imagery (animator pointer is set)
  454.    
  455.     - id: of_ai
  456.       type: b1
  457.       doc: Object has A.I.
  458.    
  459.     - id: of_disabled
  460.       type: b1
  461.       doc: Object A.I. is disabled
  462.    
  463.     - id: of_invisible
  464.       type: b1
  465.       doc: Not visible in map pane during normal play
  466.    
  467.     - id: of_editor
  468.       type: b1
  469.       doc: Is editor only object
  470.    
  471.     - id: of_foreground
  472.       type: b1
  473.       doc: Makes a normally background object a foreground object
  474.    
  475.     - id: of_seldraw
  476.       type: b1
  477.       doc: Editor is currently manipulating object
  478.    
  479.     - id: of_reveal
  480.       type: b1
  481.       doc: Player needs to see behind object (Diablo style shutter draw)
  482.    
  483.     - id: of_kill
  484.       type: b1
  485.       doc: Suicidal (tells system to kill object next frame)
  486.    
  487.     - id: of_generated
  488.       type: b1
  489.       doc: Created by map generator. Replaced when MAPGEN used.
  490.    
  491.     - id: of_animate
  492.       type: b1
  493.       doc: Call the objects Animate() func AND create object animators
  494.    
  495.     - id: of_pulse
  496.       type: b1
  497.       doc: Call the object Pulse() function
  498.    
  499.     - id: of_weightless
  500.       type: b1
  501.       doc: Object can move, but is not affected by gravity
  502.    
  503.     - id: of_complex
  504.       type: b1
  505.       doc: Object is a complex object
  506.    
  507.     - id: of_notify
  508.       type: b1
  509.       doc: Notify object of a system change (see notify codes below)
  510.    
  511.     - id: of_nonmap
  512.       type: b1
  513.       doc: Not created, deleted, saved, or loaded by map (see below)
  514.    
  515.     - id: of_onexit
  516.       type: b1
  517.       doc: Object is currently on an exit (used to prevent exit loops)
  518.    
  519.     - id: of_pause
  520.       type: b1
  521.       doc: Script is paused
  522.    
  523.     - id: of_nowalk
  524.       type: b1
  525.       doc: Don't use walk map for this tile
  526.    
  527.     - id: of_paralize
  528.       type: b1
  529.       doc: Freeze the object in mid-animation
  530.    
  531.     - id: of_nocollision
  532.       type: b1
  533.       doc: Let the object go through boundaries
  534.    
  535.     - id: of_iced
  536.       type: b1
  537.       doc: Used to know when to end the iced effect
  538.    
  539.     - id: of_virgin
  540.       type: b1
  541.       doc: Never known the touch of a man (this object hasn't been modified in an actual game)
  542.    
  543.     - id: of_loading
  544.       type: b1
  545.       doc: Tells object constructors and ClearObject() function that this object is being streamed
  546.    
  547.     - id: of_shadow
  548.       type: b1
  549.       doc: The light for this object should cast shadows
  550.    
  551.     - id: of_background
  552.       type: b1
  553.       doc: Makes a normally foreground object a background object
  554.    
  555.     - id: of_inventory
  556.       type: b1
  557.       doc: This is an inventory object
  558.    
  559.     - id: of_calledpredel
  560.       type: b1
  561.       doc: We already called the PreDelete() function for this object
  562.  
  563. enums:
  564.   obj_class:
  565.     0: item
  566.     1: weapon
  567.     2: armor
  568.     3: talisman
  569.     4: food
  570.     5: container
  571.     6: lightsource
  572.     7: tool
  573.     8: money
  574.     9: tile
  575.     10: exit
  576.     11: player
  577.     12: character
  578.     13: trap
  579.     14: shadow
  580.     15: helper
  581.     16: key
  582.     17: invcontainer
  583.     18: poison
  584.     19: unused1
  585.     20: unused2
  586.     21: ammo
  587.     22: scroll
  588.     23: rangedweapon
  589.     24: unused3
  590.     25: effect
  591.     26: mapscroll
  592.  
  593.  
Add Comment
Please, Sign In to add comment