City of Heroes' .def files are C language module definition resource files that contain object descriptions. These act as a data repository that the game engine uses to look up information to be used in making decisions within the game. They are compiled into .bin files to make them more efficient during runtime. These are the primary method of storing data in the City of Heroes engine outside of the SQL databases.
Structure of a .DEF File
- Comment - the parser ignores any lines that start with a double forward slash (//), as well as the remainder of a line that contains these characters
- Object Name - The name of the C object
- Object Opening Bracket - This denotes the beginning of the C object. Everything between this bracket and the matching closing bracket are considered attributes of the object.
- Attribute Name - The name of an attribute. This name has to be the first non-white-space thing on a line.
- Attribute Value(s) - One or more values for the attribute named. If there is more than one value, those values would be separated by at least one space. Other whitespace between them is ignored by the compiler. There may also be commas separating them as well as the white-space. It's not known at this time whether or not these commas are interpreted by the compiler.
- String Attribute Value - Strings may be also be represented as values within an object. These are denoted by double quotes ("). Spaces are allowed between the double quotes and are considered part of the string attribute.
- Sub-Object Name - Objects may contain one or more sub-objects, each with their own attributes. There is (as far as is known) no limit to the number of sub-objects that an object can contain, nor to the depth of the number of object levels that can be found inside of an object, as sub-objects could potentially contain objects of their own.
- Sub-Object Opening Bracket - This denotes the beginning of the C sub-object. Everything between this bracket and the matching closing bracket are considered attributes of the sub-object.
- Sub-Object Closing Bracket - This denotes the ending of the C sub-object. A new sub-object or attribute of the main object can be declared after this bracket.
- Object Closing Bracket - This denotes the ending of the C object. There may be a plethora of C objects inside of the same .DEF file.
Note: The compiler, just as a web browser, ignores extraneous white-space in the code. Thus, you can use whatever spacing you want to make a file human readable, and the compiler won't care, as it will ignore these.