Modding Help Is it possible to randomise dialogue lines for the same in-game day using Content Patcher?

Discussion in 'Mods' started by MangoBengalCat, Apr 19, 2020.

  1. MangoBengalCat

    MangoBengalCat Space Hobo

    I want to create a complex character mod for the game where I want to add more than 600 lines of dialogue for every single character and expand all events and schedules.

    I have read a lot of tutorials about Content Patcher and Dialogue Modding, but I haven't seen one example that randomises a dialogue line for the same day. Example:

    - You have a spouse and inside the JSON file you have the following code:

    {
    "Action": "EditData",
    "Target": "Characters/Dialogue/MarriageDialogueAbigail",
    "Entries":
    {
    "summer_14": "Bla bla bla"
    }
    }

    Is there any way of creating multiple lines for the same day and have a random one selected?, like:
    {
    "summer_14~0": "Bla bla 0",
    "summer_14~1": "Bla bla 1",
    "summer_14~2": "Bla bla 2",
    }

    If I take a look at the schedule coding, you can select a random dialogue (but just for schedule event, not general interaction) from a certain file like this:

    \"Strings\\schedules\\Abigail:marriage_{{Random:dialogue1, dialogue2}}\"

    where

    {
    "Action": "EditData",
    "Target": "Strings/schedules/Abigail",
    "Entries":
    {
    "marriage_dialogue1": "bla bla 1",
    "marriage_dialogue2": "bla bla 2"}
    },

    I have tried the same for casual dialogue (non schedule event triggered) and it seems like the game is not coded to support random lines from other files or anything like it. I have found a workaround but it seems really hackish. I have created several JSON files that each have different dialogue from the same day (summer_14) and then used the {{Random}} operator inside "FromFile" field like:


    {
    "Action": "EditData",
    "Target": "Characters/Dialogue/MarriageDialogueAbigail",
    "FromFile": "assets/Abigail/DialogueCycle{{Random:1, 2, 3}}.json",
    },

    So now, at every launch of the game, it picks a random file from DialogueCycle1, DialogueCycle2, DialogueCycle3 and displays only the dialogue for summer_14 from the respective file. Even if the random here surprisingly works, this seems rather hackish and has a disadvantage that as long as you keep the game open, it will only retrieve the dialogue lines from the randomly selected file and not any other file as long as you don't RESTART the game (I guess the one of the three files gets randomly selected at runtime).

    I have also found a second way but it's worse. It surprisingly works if you add the {{Random}} operator inside the dialogue line itself like this:

    {
    "Entries":
    {
    "summer_19": "{{Random: Bla bla 1, Bla bla 2, Bla bla 3}}",
    },
    }
    and it will display one of the three bla bla-s, but the biggest downside of this is the fact that the comma character itself ( , ) is the separator between the three dialogue options, thus you cannot use a comma inside your dialogue text otherwise it will be splitted into another dialogue option :D.

    So, instead of doing this, is it even possible to have a random generation as simple as this:

    "summer_14~0": "Bla bla 0",
    "summer_14~1": "Bla bla 1",
    "summer_14~2": "Bla bla 2"
    ? What have you found so far?

    Thanks.
     
    • MangoBengalCat

      MangoBengalCat Space Hobo

      Somebody on Reddit suggested me to create a custom Dialogue Parser in C# but I have never coded in this language and I'd rather not learn another programming language just for one small functionality if this can be done solely from the JSON file and have the game parse it with its default methods.
       
      • Kiwin

        Kiwin Orbital Explorer

        upload_2021-3-18_12-27-51.png
        I found this on the modding Dialogue of the Stardew Valley wiki. I hope this helps a bit, even if it's not exactly what you're looking for.
         
        • Kiwin

          Kiwin Orbital Explorer

          Oh wait! Also, if you've tried using "summer_19": "{{Random: Bla bla 1, Bla bla 2, Bla bla 3}}", you can add |inputSeparator=+ at the end of it, so instead of using commas, you'll use the plus sign (or whatever symbol you would rather use) instead.
          For example:
          "summer_19": "{{Random: Bla bla 1 + Bla bla 2 + Bla bla 3|inputSeparator=+}}",
          Hope this helps!
           

          Share This Page