Custom Object tutorial/Sounds and sprites
Of course you can implement custom sounds and sprites that your Objects make use of, too. This article only shows how to implement these into a SOC, not how to make them. Read the Sprite and Custom character tutorial/Sprites articles for learning how to put sprites inside a WAD or PK3 file, and the sound and music tutorial for custom sounds.
Sounds
Sounds must always have a lump name of DSXXXXXX
, where XXXXXX
can be chosen freely. The sound name as used in the SOC is then sfx_XXXXXX
. Like with Objects and states, new sounds have to be declared in the freeslot block if you want to use them in your SOC, like this:
Freeslot sfx_exampl
Sounds also have their own parameter block, which can be used to set some playback options. This block is rarely necessary because the default settings are usually sufficient, but it looks like this:
Sound sfx_exampl Priority = 0 Singular = 0 Flags = 0
Sound sfx_exampl
: The first line is the header that indicates we are about to modify the settings of the soundsfx_exampl
.
Priority
: This decides which sounds to play when all sound channels are in use. Sounds with a higher priority value are favored over sounds with a lower priority value.Singular
: If this is set to1
, the sound can be played only once at a time on any sound channel, no matter which Object started the sound. If an attempt is made to play this sound while another instance of it is still playing, the one already playing will be interrupted and then restarted.Flags
: These flags are used for special playback settings. To set several flags at once, perform the bitwise OR operation (|) on them. For example, to set the flagsSF_NOMULTIPLESOUND
,SF_OUTSIDESOUND
andSF_X4AWAYSOUND
, writeFLAGS = SF_NOMULTIPLESOUND|SF_OUTSIDESOUND|SF_X4AWAYSOUND
in the sound's SOC block. The functions of the flags are as follows:
Decimal | Hexadecimal | Flag name | Description |
---|---|---|---|
1 | 0x01
|
SF_TOTALLYSINGLE | (unused) |
2 | 0x02
|
SF_NOMULTIPLESOUND | The sound can only be played once at a time on any sound channel, no matter which Object started the sound. Attempting to play the sound more than once at the same time has no effect and the one already playing is not interrupted. This overrides the Singular parameter.
|
4 | 0x04
|
SF_OUTSIDESOUND | The volume of the sound depends on how close the player is to an "outside area" (any sector with F_SKY1 as its ceiling flat). The closer the player is, the louder the volume. This is used by the rain sound, for example.
|
8 | 0x08
|
SF_X4AWAYSOUND | The sound can be heard from four times the regular distance.* |
16 | 0x10
|
SF_X8AWAYSOUND | The sound can be heard from eight times the regular distance.* |
32 | 0x20
|
SF_NOINTERRUPT | The sound does not interrupt other sounds; if it is attempted to be played in a situation where it would be interrupting another sound, it is not played. This does not work in combination with the Singular parameter, use the SF_NOMULTIPLESOUND flag instead.
|
64 | 0x40
|
SF_X2AWAYSOUND | The sound can be heard from two times the regular distance.* |
* You can combine the flags SF_X2AWAYSOUND
, SF_X4AWAYSOUND
and SF_X8AWAYSOUND
to further increase the hearing distance. For example, combining all three flags makes the distance increase equal to 2 × 4 × 8 = 64.
Sprites
Sprites must always have a lump name like XXXXYZ
, where XXXX
is the sprite set name, Y
is the frame and Z
is the rotation. The sprites themselves are created similarly to those of a custom character, and the same abridged system can be used for symmetrical sprites. Like with Objects and states, new sprites have to be declared in the freeslot block if you want to use them in your SOC, like this:
Freeslot SPR_EXMP
You can then reference the sprite set with SpriteName = EXMP
in a state block. Additionally, certain flags can be added to the SpriteFrame
parameter that control the sprite's translucency and brightness settings. As usual, combine these flags with the bitwise OR operator (|), e.g. FF_FULLBRIGHT|TR_TRANS10|A
.
FF_FULLBRIGHT
: full brightness, the sprite is not affected by lightingTR_TRANS10
: 10% translucent (90% opaque)TR_TRANS20
: 20% translucent (80% opaque)TR_TRANS30
: 30% translucent (70% opaque)TR_TRANS40
: 40% translucent (60% opaque)TR_TRANS50
: 50% translucent (50% opaque)TR_TRANS60
: 60% translucent (40% opaque)TR_TRANS70
: 70% translucent (30% opaque)TR_TRANS80
: 80% translucent (20% opaque)TR_TRANS90
: 90% translucent (10% opaque)
It is important that you keep in mind that the number of states you need does not only depend on the number of actions you want to use but also the number of frames you are going to use. Take the Crawlas for example. All they do is constantly execute A_Chase
. According to this information you might think you could only use one state that keeps looping to represent their aggressive behavior. In fact, they are using six states. This is because their chains keep rolling so that they appear to be some kind of tank. This animation needs six frames and therefore six states.
The actions A_ChangeColorRelative
and A_ChangeColorAbsolute
are capable of shifting the colors of a sprite according to their number inside the SRB2 palette.