Sonic Object Configuration

From SRB2 Wiki
(Redirected from SOC)
Jump to: navigation, search
This article is about the SOC file system. For a tutorial on SOC creation, see Object Creation Tutorial.

A Sonic Object Configuration, abbreviated as SOC, is a type of text file for SRB2 that allows users to change several game settings in the source code without any programming knowledge. It can be created with the SRB2 SOC Editor. This allows for easy modification of the game and makes it flexible for the use of addon files.

There are three basic groups of SOC files that serve different purposes: Hence the name, the main feature of SOCs is the ability to control all Objects in the game, including their interaction with the environment and the sprites they display. With the use of a SOC file, new Objects can be created, and the behavior and appearance of existing Objects can be changed. The second group modifies several global settings that have to do with the appearance of the game, such as the unlockables system, cutscenes and level headers. These SOCs are generally found in level packs. The third group applies to character WADs, whose properties are defined through SOCs as well.

Contents

File System

SOCs are structured as simple text files in which any changes from or additions to the default game settings are specified as raw text. The text must follow a specific formatting, but its structure is rather simple: Each section has a header that defines what it does, and then each property is listed in its own line (sometimes written out in capitalized letters, but the values are not case-sensitive), followed by an equal sign and a variable (i.e., MusicSlot = 0 or MAPTHINGNUM = 100).

SOCs can be created with a text editor like Notepad, and are saved with the extension .soc. Alternatively, the SRB2 SOC Editor can be used, which provides a Graphical User Interface and supplies additional information on how to use many settings as well as their standard values in the source code.

One common method to load SOCs is to use the commands ADDFILE or RUNSOC in the console once SRB2 has been started. Another method is to add the SOC using the SRB2 Launcher. When loading a SOC file, the values found in the source code are overwritten with the custom ones, and the changes take effect as long as it is loaded. SOC files can also be integrated into WAD files as lumps, in which case they are automatically loaded with the WAD file. This allows for modifications with custom unlockable systems and global game settings. For more information on this method, see the MAINCFG section below.

Object Configuration

The Object configuration system is one of the three main parts of the SOC format. All Objects in the game can be controlled and modified with simple text files due this feature. This allows, within limitations, to alter the gameplay mechanics of SRB2 and to create new custom scenery and enemy Objects. However, many mechanics found in SRB2's default Objects cannot be replicated with SOCs, due to the rather inflexible implementation of the Object system, which relies heavily on hard-coded features that only work in the situation they were made for.

Hierarchy

The structure of the Object configuration system is best illustrated through a hierarchy. It consists of several distinct elements that build on top of each other to control the behavior of in-game Objects:

  • Objects: The main element of a SOC. All Objects that appear in the game, including the player itself, all Things and everything that is spawned by a Thing (such as missiles or shields), have their properties defined in SOCs. They essentially act as the control panel and the uppermost level of the hierarchy. Everything else has the ultimate purpose of defining the properties of some Object. There are 318 Objects in the game, each referred to by an identification number from 0 to 317, and 128 additional freeslots.
    • States: The different subsets of interaction with the environment. These are called when specific events happen to the Objects, and define what happens in certain situations. For example, all Objects go into their SpawnState upon loading a level, enemies go into their SeeState when seeing a player, and all Objects that can be destroyed go into their DeathState upon being destroyed. States only last a specific duration, then another state is called. There are 1792 Objects in the game, each referred to by an identification number from 0 to 1791, and 768 additional freeslots.
      • Actions: These define what the Objects do in any given state. There are several actions available to choose from, and some of them are modifiable with two variables.
      • Sprites: These define how the Objects look in any given state. There are 243 Sprite sets in the game, each referred to by an identification number from 0 to 242, and 128 additional freeslots.
    • Sounds: On the same level as the States, and acting in tandem with them. If a state is called, its sound is called along with it. Not all states have a sound, and not all sounds have a state, but they operate by the same principle. There are 297 Sounds in the game, each referred to by an identification number from 0 to 296, and 800 additional freeslots.
    • Flags: These define the general type of the Objects. They set the rules of how the Objects interact with their environment, i.e., what they are allowed to do and what is allowed to be done to them (such as being solid or intangible, visible or invisible, an enemy or a scenery object etc.). Flags can change they system after which states are called, for example, intangible objects do not have a DeathState.
    • Other attributes: Apart from the above attributes, Objects are assigned a Thing number that is used to place the Object on maps (you can also choose to supply none if the Object should only be spawned by other Objects). The dimensions are also defined here, but the shape of Objects is limited to a square box with an adjustable height. Other attributes include health points, speed, damage and several others, but the meaning of these is dependent of the flags chosen, and in some cases hardcoded only for specific Objects.

Format

Thing 1
MAPTHINGNUM = 100
SPAWNSTATE = 63
SPAWNHEALTH = 1
SEESTATE = 65
SEESOUND = 0
REACTIONTIME = 32
ATTACKSOUND = 0
PAINSTATE = 0
PAINCHANCE = 200
PAINSOUND = 0
MELEESTATE = 0
MISSILESTATE = 0
DEATHSTATE = 1641
DEATHSOUND = 119
XDEATHSTATE = 0
SPEED = 3
RADIUS = 1572864
HEIGHT = 2097152
MASS = 100
DAMAGE = 0
ACTIVESOUND = 0
RAISESTATE = 0
FLAGS = 16777221

This is a sample of an Object block that can be found inside a SOC. In consists of a header which assigns an identification number to the Object, and a list of values that define its properties. The list of properties must be in this order, although values with zero can be left out. As can be seen here, Objects, States, Sprites and Sounds are all given identification numbers for easy reference. While they all have regular names, the identification numbers must be listed in SOC files, and either the SRB2 SOC Editor or the corresponding list articles must be used to assign one to the other. The flags value is calculated by combining the individual values of each chosen flag. Again, the SOC Editor provides a Graphical Interface for easier reference. The other values in this block are purely mathematical and are not identification or reference numbers.

FRAME 65
SPRITENUMBER = 1
SPRITESUBNUMBER = 0
DURATION = 3
NEXT = 66
ACTION A_Chase
VAR1 = 0
VAR2 = 0

This is a corresponding sample of a State block that can be found inside a SOC. State and Object blocks are the two most commonly used blocks for SOC files, although in some cases Sound blocks might also be used. These two, however, are enough to create fully working Objects or modify the behavior of existing ones. This is the SeeState used by the Object referenced above. The sprite number is, again, an identification value that substitutes the real name of the sprite. The NEXT value references which state follows next. The action is the only part of a SOC that is actually referenced by name and not by an identification number. Var1 and Var2, which are not used here, as well as the duration, are numerical values.

Reference Articles

These articles list the available Objects, States, Sprites and Sounds in SRB2, for easy reference. These tables include the identification numbers, the real names, and descriptions for each elements.

MAINCFG

Main article: MAINCFG

The MAINCFG is a WAD file lump that contains SOCs. The MAINCFG is essentially the second big element of the SOC format, and is separate in purpose and function from the Object configuration. It serves as the control lump for the global game settings for any modification, and changes certain aspects of the game to better suit the addition of custom WAD files. This allows level packs in particular to work in their own environment and essentially as whole different game.

The MAINCFG is put into WAD files and once those WADs are loaded, the SOCs inside this lump are automatically run. You can import a SOC file using a lump editor like XWE. Once you import the SOC, you would rename the imported lump into MAINCFG. If the lump doesn't look right, you can rename the MAINCFG SOC to MAINCFG.TXT.

There are five big categories that the MAINCFG can be divided into:

  • MAINCFG Category - The main part of the MAINCFG. Here, global game settings are specified, such as the timers of various power-ups, the location of the Special Stages and the first Single Player stage, the name of the gamedata and save files, and the number and locations of emblems. This section must be part of the MAINCFG, and is required for modifications with custom save files and unlockables.
  • Unlockables - In this section, unlockables for the modification can be created. The level select or additional maps can be awarded if certain conditions are met. This section allows editors to choose what features are unlocked when certain conditions are met, and how the Secrets menu is displayed.
  • Cutscenes - SRB2 has support for custom cutscenes to be displayed either instead of the intro and credits or between maps. The properties and content of such cutscenes are stored in cutscene SOC blocks in the MAINCFG.
  • Level Headers - Custom maps are usually given level headers which define the name of the stage as well as certain settings associated with it, such as the gametype, the availability in the Level Select, and other miscellaneous features. Level Headers are required for maps unless they replace already existing stages, but even in these cases, they should be normally supplied. Level Headers are typically stored inside the MAINCFG, but can also be supplied in separate lumps.
  • Object Configurations - Any Object configurations, as explained above, can be stored in this lump if used in a large-scale modification. This allows, for example, for custom maps to have custom scenery or enemy Objects.

Character WADs

While playable character addons mainly consist of custom sprites, their functionality is controlled with two SOC lumps. The OBJCTCFG serves as a properties lump for them, defining their name and description in the character select menu. The abilities and stats of the character are defined in a different SOC lump called S_SKIN1. With this system, custom characters with different abilities and physics that the three main characters can be created. Apart from the abilities supplied in the main game, it is possible to create new abilities with the use of Object configurations. For a guide on this method, see the Custom Ability Tutorial.

External Links

Personal tools