Hallo,
Can someone explain to me how the I_SoundPlaying condition works.
I don't understand the Parameters <sound event tag>.
Thanks.
Can someone explain to me how the I_SoundPlaying condition works.
Hallo,
Can someone explain to me how the I_SoundPlaying condition works.
I don't understand the Parameters <sound event tag>.
Thanks.
Can someone explain to me how the I_SoundPlaying condition works.
If I recall correctly, this condition can only be used to check if a scripted sound event with a specified tag is playing. It can't check other sounds. The tags are defined as part of the play_sound_event command as in:
Edit: This is wrong, I was thinking of the stop_sound_event command which only accepts <tag> and can thus only be used to stop scripted audio.Code:play_sound_event your_event tag = your_tag
Last edited by Callistonian; April 14, 2024 at 12:23 AM.
The following works:
play_sound_event STRAT_PRISONERS_EXECUTED_GUNPOWDER 2
The tag is the third file to be played.
This doesn't work:
monitor_conditions I_SoundPlaying STRAT_PRISONERS_EXECUTED_GUNPOWDER 2
descr_sound_generic.txt:
event STRAT_PRISONERS_EXECUTED_GUNPOWDER volume 0 streamed
folder data/sounds/SFX/interface/campaign
prisoner_execution_musket.mp3 - tag 0
prisoner_group_execution_guillotine_01.mp3 - tag 1
prisoner_group_execution_guillotine_02.mp3 - tag 2
prisoner_group_execution_hanging_01.mp3 - tag 3
prisoner_group_execution_horse_01.mp3 - tag 4
end
play_sound_event STRAT_PRISONERS_EXECUTED_GUNPOWDER 2
The sound is played "prisoner_group_execution_guillotine_02.mp3".
The condition I_SoundPlaying doesn't work or my entries are incorret.Code:declare_counter SoundTest set_counter SoundTest 0 monitor_event MultiTurnMove FactionType hre play_sound_event STRAT_PRISONERS_EXECUTED_GUNPOWDER 2 set_counter SoundTest 1 end_monitor monitor_conditions I_CompareCounter SoundTest = 1 and I_SoundPlaying STRAT_PRISONERS_EXECUTED_GUNPOWDER 2 set_counter SoundTest 2 end_monitor
Thanks for explaining the tag principle here.
My thoughts here are that the tag number is not required in the second monitor as the test is for the sound event, not the particular mp3 files being played.
I'll run a simple test myself with Hastings_Tutorial_General_1 from descr_sounds_narration. And then another one with Rocket_Launcher_Fire from descr_sounds_generic.
Edit: Well, that didn't work, eg the second historic_event didn't fire
Will test if default sound events (like clicking on a character) will work.Code:monitor_event FactionTurnStart FactionIsLocal play_sound_event Hastings_Tutorial_General_1 wait 1.0 historic_event FIRST_WINDMILL end_monitor monitor_conditions I_SoundPlaying Hastings_Tutorial_General_1 historic_event EARTHQUAKE_IN_ALEPPO end_monitor
Edit: success!! I used the STRAT_BUILD_WATCHTOWER event from descr_sounds_generic and while it didn't work with the initial scripted sound it did when building a watch tower. The second historic_event fired - and kept on firing......
For some reason a terminate_monitor line will be required.
Note: the sound event takes place when selecting the tower from the building choices.Code:monitor_event FactionTurnStart FactionIsLocal play_sound_event STRAT_BUILD_WATCHTOWER wait 1.0 historic_event FIRST_WINDMILL end_monitor monitor_conditions I_SoundPlaying STRAT_BUILD_WATCHTOWER historic_event EARTHQUAKE_IN_ALEPPO terminate_monitor end_monitor
I will add these observations to my 'non functioning' thread.
The I_SoundPlaying condition certainly does return true for sounds triggered and tagged with the play_sound_event command. In fact, this was the basis of all pre-Lua custom character selection audio scripts.Originally Posted by Gigantus
The terminate_monitor line isn't required for the I_SoundPlaying condition to work, it's just that you used monitor_conditions so, of course, the effects will fire continuously while the conditions are met.
I don't think there is anything 'non functioning' about this condition.
@Woddel - Look more closely at the documentation for the play_sound_event command. I've copied the Docudemons entry below and then an example audio event from descr_sounds_generic.txt below that with the corresponding objects color coded.
Code:Parameters: <event id> [<index>] [tag = <something>]Example call from campaign_script.txt:Code:event STRAT_PRISONERS_EXECUTED_GUNPOWDER volume 0 streamed folder data/sounds/SFX/interface/campaign prisoner_execution_musket.mp3 ;audio file at index 0 prisoner_group_execution_guillotine_01.mp3 ;audio file at index 1 prisoner_group_execution_guillotine_02.mp3 ;audio file at index 2 prisoner_group_execution_hanging_01.mp3 ;audio file at index 3 prisoner_group_execution_horse_01.mp3 ;audio file at index 4 end
In the last bit of code, I'm demonstrating that the I_SoundPlaying condition apparently accepts both what the Docudemons calls an <event id> as well as a tag which comes from a play_sound_event command. (EDIT: This is incorrect. I_SoundPlaying only appears to accept tag for audio created with the play_sound_event command, the condition will accept <event id> for all other audio events). I assume the reason for this is because tags are meant to function as a class of event ids. E.g., you can class multiple events under the same tag:Code:play_sound_event STRAT_PRISONERS_EXECUTED_GUNPOWDER 2 tag = our_custom_tag if I_SoundPlaying our_custom_tag ;do something end_if if I_SoundPlaying STRAT_PRISONERS_EXECUTED_GUNPOWDER ;this actually returns false ;do something end_if
Unfortunately, this final command, stop_sound_event, only accepts the parameter <tag>, i.e. audio which has been scripted to occur as in the example above.Code:play_sound_event your_first_event tag = custom_sound_class play_sound_event your_second_event tag = custom_sound_class if I_SoundPlaying custom_sound_class stop_sound_event custom_sound_class end_if
Last edited by Callistonian; April 17, 2024 at 02:09 AM.
So the reason why our custom sound monitors were not working was because we did not use a tag?
Let me try again:
Nope, that only gave me the windmill. This one however worked:Code:monitor_event FactionTurnStart FactionIsLocal play_sound_event Hastings_Tutorial_General_1 tag = testing_sound historic_event FIRST_WINDMILL end_monitor monitor_event TrueCondition if I_SoundPlaying testing_sound historic_event EARTHQUAKE_IN_ALEPPO end_if end_monitor
Does that mean I am forced to use monitor_conditions to test for I_SoundPlaying, else it has to be within the same monitor?Code:monitor_event FactionTurnStart FactionIsLocal play_sound_event Hastings_Tutorial_General_1 tag = testing_sound historic_event FIRST_WINDMILL if I_SoundPlaying testing_sound historic_event EARTHQUAKE_IN_ALEPPO end_if end_monitor
Unlike the 'EventCounter' event to test for the immediate change of an event counter there is no 'SoundPlayed' equivalent.
Based on the above I have changed the entry in the 'non functional' thread to this:
"Will return 'true' only while sound is playing, eg when testing in the monitor that triggers the sound or using monitor_conditions. The latter needs terminating (terminate_monitor, stop_sound_event) to avoid multiple firing. See here."
I have also added an entry for stop_sound_event:
"Does not accept event id, uses tag instead. See at the bottom here.
No, the reason your first example above doesn't work is because this extremely optimistic bit of code...
... doesn't do anything. I just tested, half expecting it to spam historic_events at me every time any event happened, but it does nothing. This, however, does work as expected:Code:monitor_event TrueCondition
This does not work:Code:monitor_event FactionTurnStart FactionIsLocal historic_event aztecs_contacted play_sound_event Hastings_Tutorial_General_1 tag = testing_sound end_monitor monitor_conditions I_SoundPlaying testing_sound historic_event america_discovered terminate_monitor end_monitor
However, if we swap in an event that's easier to test like STRAT_BUILD_WATCHTOWER, the second historic event will fire when you go to build the watchtower normally, as you observed before. This behavior doesn't appear to depending on which sounds file the event was defined in or what type of audio files or parameters it uses.Code:monitor_event FactionTurnStart FactionIsLocal historic_event aztecs_contacted play_sound_event Hastings_Tutorial_General_1 end_monitor monitor_conditions I_SoundPlaying Hastings_Tutorial_General_1 historic_event america_discovered terminate_monitor end_monitor
My only guess is that the I_SoundPlaying condition cannot find an <event id> for sounds created with the play_sound_event command, whereas it does find this for 'naturally occurring' sounds. In that case, our only recourse for using I_SoundPlaying with scripted audio is to test by tag.
Code:play_sound_event event_name tag = event_tag if I_SoundPlaying event_name ;false [...] if I_soundPlaying event_tag ;true [...]
Last edited by Callistonian; April 17, 2024 at 02:02 AM.
OK. I wanted to use I_SoundPlaying over an animation evt-file.
If it only works via play_sound_event, my question is unnecessary.
Example:
event SOUND SM_ANIM_BATTLE 14 14
event SOUND ANIM_SWOOSH 14 14
Thanks for the support.
I_SoundPlaying works for sound events defined in the sounds text files as well as scripted sounds from play_sound_event. I don't know if it works for events in .evt files.