Results 1 to 14 of 14

Thread: Condition I_SoundPlaying

  1. #1

    Default Condition I_SoundPlaying

    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.

  2. #2

    Default Re: Condition I_SoundPlaying

    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:

    Code:
    play_sound_event your_event tag = your_tag
    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.
    Last edited by Callistonian; April 14, 2024 at 12:23 AM.

  3. #3
    Gigantus's Avatar I am not special - I am a limited edition.
    Patrician took an arrow to the knee spy of the council

    Join Date
    Aug 2006
    Location
    Goa - India
    Posts
    53,133
    Blog Entries
    35

    Default Re: Condition I_SoundPlaying

    I suppose those are the sounds defined in descr_sounds_narration? Example for 'choose the heir' in EBII:
    Code:
    event Successor_1
       folder data/sounds/SFX/Events
       successor.mp3
    end










  4. #4

    Default Re: Condition I_SoundPlaying

    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

  5. #5
    Gigantus's Avatar I am not special - I am a limited edition.
    Patrician took an arrow to the knee spy of the council

    Join Date
    Aug 2006
    Location
    Goa - India
    Posts
    53,133
    Blog Entries
    35

    Default Re: Condition I_SoundPlaying

    Not sure what the number 2 is - but I don't think it has any impact - in fact it may be the reason why the monitor doesn't work.










  6. #6

    Default Re: Condition I_SoundPlaying

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

    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
    The condition I_SoundPlaying doesn't work or my entries are incorret.

  7. #7
    Gigantus's Avatar I am not special - I am a limited edition.
    Patrician took an arrow to the knee spy of the council

    Join Date
    Aug 2006
    Location
    Goa - India
    Posts
    53,133
    Blog Entries
    35

    Default Re: Condition I_SoundPlaying

    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
    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
    Will test if default sound events (like clicking on a character) will work.

    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.
    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
    Note: the sound event takes place when selecting the tower from the building choices.

    I will add these observations to my 'non functioning' thread.
    Last edited by Gigantus; April 13, 2024 at 10:17 PM.










  8. #8

    Default Re: Condition I_SoundPlaying

    Quote Originally Posted by Gigantus
    I_SoundPlaying - does not test sound events triggered via the play_sound_event command, requires terminating to prevent looping of commands.
    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.

    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>]
    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
    Example call from campaign_script.txt:

    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
    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 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
    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.
    Last edited by Callistonian; April 17, 2024 at 02:09 AM.

  9. #9
    Gigantus's Avatar I am not special - I am a limited edition.
    Patrician took an arrow to the knee spy of the council

    Join Date
    Aug 2006
    Location
    Goa - India
    Posts
    53,133
    Blog Entries
    35

    Default Re: Condition I_SoundPlaying

    So the reason why our custom sound monitors were not working was because we did not use a tag?

    Let me try again:

    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
    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
    
        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?
    Unlike the 'EventCounter' event to test for the immediate change of an event counter there is no 'SoundPlayed' equivalent.










  10. #10
    Gigantus's Avatar I am not special - I am a limited edition.
    Patrician took an arrow to the knee spy of the council

    Join Date
    Aug 2006
    Location
    Goa - India
    Posts
    53,133
    Blog Entries
    35

    Default Re: Condition I_SoundPlaying

    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.










  11. #11

    Default Re: Condition I_SoundPlaying

    Quote Originally Posted by Gigantus View Post
    So the reason why our custom sound monitors were not working was because we did not use a tag?
    No, the reason your first example above doesn't work is because this extremely optimistic bit of code...

    Code:
    monitor_event TrueCondition
    ... 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 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
    This does not work:

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

    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.

  12. #12
    Gigantus's Avatar I am not special - I am a limited edition.
    Patrician took an arrow to the knee spy of the council

    Join Date
    Aug 2006
    Location
    Goa - India
    Posts
    53,133
    Blog Entries
    35

    Default Re: Condition I_SoundPlaying

    Thanks for summarizing - I do agree with your thoughts that scripted sound events don't have or generate a event id and hence a tag is required to test for it.










  13. #13

    Default Re: Condition I_SoundPlaying

    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.

  14. #14

    Default Re: Condition I_SoundPlaying

    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •