effect · sound_effect
Definition
- Supported scope:
any - Supported target:
none
Description
Plays sound effect
sound_effectanynonePlays sound effect
Hands-on notes are AI-generated and checked against the vanilla command vocabulary — treat them as a starting point, not authoritative reference. The definition above is the game's own documentation.
sound_effect is commonly used to play audio cues when events trigger, enhancing immersion—for example, explosion sounds during war declaration events or notification chimes in hidden effects when technology research completes. It applies to any scenario requiring audio feedback for the player, such as decision triggers, focus completions, and other critical moments.
country_event = {
id = my_mod.1
title = my_mod.1.t
desc = my_mod.1.d
option = {
name = my_mod.1.a
sound_effect = "event:/SFX/Events/military/declaration_of_war"
add_war_support = 0.10
}
}
[hidden_effect](/wiki/effect/hidden_effect): Wrapping sound_effect inside hidden_effect allows silent audio playback without generating unnecessary tooltips for the player, preventing audio trigger conditions from appearing in the event log.[custom_effect_tooltip](/wiki/effect/custom_effect_tooltip): When audio trigger logic is complex, pair it with custom_effect_tooltip to display readable descriptive text to the player, compensating for the lack of UI feedback that sound_effect itself produces.[if](/wiki/effect/if): Use conditional if blocks to control audio playback only under specific circumstances—for example, triggering sound effects only for human players and avoiding meaningless audio calls when AI executes the code.[play_song](/wiki/effect/play_song): Both are audio commands; sound_effect handles short, one-time sound effects while play_song switches background music. They are often used together to create a complete audio atmosphere.sound_effect value must be a sound event path already defined in the game (typically starting with event:/). Directly using filenames or custom paths will fail silently without errors. Beginners should prioritize referencing path conventions from vanilla event scripts for reuse.sound_effect in batch scope loops like every_country, each scope switch attempts to trigger the sound. Although audio from AI countries is inaudible, it still causes unnecessary overhead. Use [is_ai](/wiki/trigger/is_ai) (i.e., if = { limit = { NOT = { is_ai = yes } } }) to restrict execution to human players only.