Custom Object tutorial/Sounds and sprites
|Custom Object tutorial||[view]|
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 must always have a lump name of
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:
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 sound
An Object cannot play the same sound twice at the same time. For example, if an Object is playing
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 to
1, 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 flags
FLAGS = SF_NOMULTIPLESOUND|SF_OUTSIDESOUND|SF_X4AWAYSOUNDin the sound's SOC block. The functions of the flags are as follows:
||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 |
||SF_OUTSIDESOUND||The volume of the sound depends on how close the player is to an "outside area" (any sector with |
||SF_X4AWAYSOUND||The sound can be heard from four times the regular distance.*|
||SF_X8AWAYSOUND||The sound can be heard from eight times the regular distance.*|
||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 |
||SF_X2AWAYSOUND||The sound can be heard from two times the regular distance.*|
* You can combine the flags
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 must always have a lump name like
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:
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: full brightness, the sprite is not affected by lighting
TR_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.
|Custom Object tutorial||[view]|