How to make a certain playlist or song play whenever a certain faction is chosen in multiplayer

The place to post your WML questions and answers.

Moderator: Forum Moderators

Forum rules
  • Please use [code] BBCode tags in your posts for embedding WML snippets.
  • To keep your code readable so that others can easily help you, make sure to indent it following our conventions.
Post Reply
User avatar
Bilbo_Sacket
Posts: 35
Joined: February 28th, 2021, 4:27 am

How to make a certain playlist or song play whenever a certain faction is chosen in multiplayer

Post by Bilbo_Sacket »

I am making an era, and I want any faction participating in a multiplayer's theme song to be added to the playlist for that scenario. But I don't want any default, or core songs to be butting in. Meaning a scenario that has only my songs in it, and only the ones belonging to the factions, chosen for the scenario. However, I don't want to change core data permanently to do it, just while someone is playing my mod on it.
I would appreciate some help, on this somewhat formidable problem thank you.
User avatar
Lord-Knightmare
Discord Moderator
Posts: 2340
Joined: May 24th, 2010, 5:26 pm
Location: Somewhere in the depths of Irdya, gathering my army to eventually destroy the known world.
Contact:

Re: How to make a certain playlist or song play whenever a certain faction is chosen in multiplayer

Post by Lord-Knightmare »

Here's what I would do:
  • Give all leaders of your factions a faction-specific dummy ability. This is not needed if the leaders are all of the same race.
  • Code a Start event.
  • Filter by race/dummy-ability
  • use your {REPLACE_SCENARIO_MUSIC music.ogg} and then multiple {APPEND_MUSIC music.ogg}, to set up your playlist
  • Enjoy.
Creator of "War of Legends"
Creator of the Isle of Mists survival scenario.
Maintainer of Forward They Cried
User:Knyghtmare | My Medium
User avatar
Bilbo_Sacket
Posts: 35
Joined: February 28th, 2021, 4:27 am

Re: How to make a certain playlist or song play whenever a certain faction is chosen in multiplayer

Post by Bilbo_Sacket »

Thank you very much I will try that.
User avatar
Bilbo_Sacket
Posts: 35
Joined: February 28th, 2021, 4:27 am

Re: How to make a certain playlist or song play whenever a certain faction is chosen in multiplayer

Post by Bilbo_Sacket »

Okay so I did or tried what you told me. But there is a problem, and I don't totally understand it. anyway would you please check my code to see if I got anything wrong, because so far what I tried hasn't worked.

Code: Select all

#textdomain wesnoth- MUSIC

#define ABILITY_MUSIC
   [dummy]
      id=music
      name=_ "music"
      description=_ "This ability adds faction specific music to gameplay"
   [/dummy]
   [event]
      name=start
      [filter]
         race=human
      [/filter]
      {REPLACE_SCENARIO_MUSIC loyalists.ogg}
       
       {APPEND_MUSIC loyalists.ogg}
       [filter]
          race=orc
       [/filter]
       {REPLACE_SCENARIO_MUSIC northerners.ogg}
       
       {APPEND_MUSIC loyalists.ogg}
   [/event]
#enddef
I could not think of any other ways to do it from what you told me.
User avatar
MoonyDragon
Posts: 149
Joined: November 29th, 2017, 5:46 pm

Re: How to make a certain playlist or song play whenever a certain faction is chosen in multiplayer

Post by MoonyDragon »

A [store_side] check for the individual factions is more elegant than anything with dummy abilities. Throw in a [switch] to assign music to each faction, and the code below is ready to be put inside your [era] tag. Enjoy!

Code: Select all

[event]
    name=start

    {REPLACE_SCENARIO_MUSIC silence.ogg}

    [store_side]
        variable=sides
    [/store_side]

    [for]
        array=sides

        [do]
            [switch]
                variable=sides[$i].faction

                [case]
                    value="Northerners"
                    {APPEND_MUSIC northerners.ogg}
                [/case]

                [case]
                    value="Loyalists"
                    {APPEND_MUSIC loyalists.ogg}
                [/case]

                [case]
                    value="Rebels"
                    {APPEND_MUSIC elvish-theme.ogg}
                [/case]

                [case]
                    value="Knalgan Alliance"
                    {APPEND_MUSIC knalgan_theme.ogg}
                [/case]

                [case]
                    value="Undead"
                    {APPEND_MUSIC the_dangerous_symphony.ogg}
                [/case]

                [case]
                    value="Drakes"
                    {APPEND_MUSIC frantic.ogg}
                [/case]

                [else]
                    {APPEND_MUSIC defeat.ogg}
                [/else]
            [/switch]
        [/do]
    [/for]

    [clear_variable]
        name=sides
    [/clear_variable]
[/event]
Default L0 Era - Level 1 leaders with level 0 recruits!
User avatar
Bilbo_Sacket
Posts: 35
Joined: February 28th, 2021, 4:27 am

Re: How to make a certain playlist or song play whenever a certain faction is chosen in multiplayer

Post by Bilbo_Sacket »

Thank you so much. I have been working on this for months and now something finally works you have my deepest gratitude for your help.
Post Reply