Custom Object tutorial/Sounds and sprites (2024)

Table of Contents
Sounds Sprites References
Custom Object tutorial[view]

Chapter 1: Basic knowledgeChapter 2: File structureChapter 3: Syntax issues and conventionsChapter 4: Creating an enemyChapter 5: Sounds and spritesChapter 6: Advanced techniques

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:

Freeslotsfx_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_examplPriority = 0Singular = 0Flags = 0
  • Sound sfx_exampl: The first line is the header that indicates we are about to modify the settings of the sound sfx_exampl.
Note
An Object cannot play the same sound twice at the same time. For example, if an Object is playing sfx_alarm and then attempts to play the same sound again without letting the previous playback finish, the sound is interrupted and then restarted.
  • 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 SF_NOMULTIPLESOUND, SF_OUTSIDESOUND and SF_X4AWAYSOUND, write FLAGS = SF_NOMULTIPLESOUND|SF_OUTSIDESOUND|SF_X4AWAYSOUND in the sound's SOC block. The functions of the flags are as follows:
DecimalHexadecimalFlag nameDescription
10x01SF_TOTALLYSINGLE(unused)
20x02SF_NOMULTIPLESOUNDThe 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.
40x04SF_OUTSIDESOUNDThe 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.
80x08SF_X4AWAYSOUNDThe sound can be heard from four times the regular distance.*
160x10SF_X8AWAYSOUNDThe sound can be heard from eight times the regular distance.*
320x20SF_NOINTERRUPTThe 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.
640x40SF_X2AWAYSOUNDThe 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:

FreeslotSPR_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 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.

The actions A_ChangeColorRelative and A_ChangeColorAbsolute are capable of shifting the colors of a sprite according to their number inside the SRB2 palette.

Custom Object tutorial[view]

Chapter 1: Basic knowledgeChapter 2: File structureChapter 3: Syntax issues and conventionsChapter 4: Creating an enemyChapter 5: Sounds and spritesChapter 6: Advanced techniques

Retrieved from ""

Custom Object tutorial/Sounds and sprites (2024)

References

Top Articles
Latest Posts
Article information

Author: Carlyn Walter

Last Updated:

Views: 6136

Rating: 5 / 5 (70 voted)

Reviews: 93% of readers found this page helpful

Author information

Name: Carlyn Walter

Birthday: 1996-01-03

Address: Suite 452 40815 Denyse Extensions, Sengermouth, OR 42374

Phone: +8501809515404

Job: Manufacturing Technician

Hobby: Table tennis, Archery, Vacation, Metal detecting, Yo-yoing, Crocheting, Creative writing

Introduction: My name is Carlyn Walter, I am a lively, glamorous, healthy, clean, powerful, calm, combative person who loves writing and wants to share my knowledge and understanding with you.