From e3a15c7e9e240394eac974d7d7f256985a7e41dd Mon Sep 17 00:00:00 2001 From: Wu Zhuoran Date: Fri, 19 Apr 2024 00:51:19 -0700 Subject: [PATCH] Fix #22 Missing Dialog when setting checker as NPC (#23) --- AnimalSitter/AnimalSitter.cs | 89 ++++++++++++++++++++++++++++---- AnimalSitter/AnimalSitter.csproj | 2 +- AnimalSitter/manifest.json | 2 +- README.md | 29 ++++++----- 4 files changed, 97 insertions(+), 25 deletions(-) diff --git a/AnimalSitter/AnimalSitter.cs b/AnimalSitter/AnimalSitter.cs index 21e4f0c..91ef6a2 100644 --- a/AnimalSitter/AnimalSitter.cs +++ b/AnimalSitter/AnimalSitter.cs @@ -328,7 +328,6 @@ private void IterateOverAnimals() this.AddItemToInventory(toAdd, farmer); stats.TrufflesHarvested++; - this.isFirstTimeTruffle = false; } } else @@ -349,6 +348,7 @@ private void IterateOverAnimals() } } + this.isFirstTimeTruffle = false; this.HarvestTruffles(stats); this.HarvestCoops(stats); @@ -593,16 +593,45 @@ private void ShowMessage(int numActions, int totalCost, bool doesPlayerHaveEnoug if (character != null) { //this.isCheckerCharacter = true; - string portrait = ""; + // string portrait = ""; if (character.Name.Equals("Shane")) { - portrait = "$8"; + // portrait = "$8"; + message += this.GetRandomMessage(messageStoreName: "greeting", low: 1, high: 7); + message += this.GetRandomMessage(messageStoreName: "Shane", low: 1, high: 2); + } + else if (character.Name.Equals("Haley")) + { + // portrait = "$8"; + message += this.GetRandomMessage(messageStoreName: "greeting", low: 1, high: 7); + message += this.GetRandomMessage(messageStoreName: "Haley", low: 1, high: 2); + } + else if (character.Name.Equals("Alex")) + { + // portrait = "$8"; + message += this.GetRandomMessage(messageStoreName: "greeting", low: 1, high: 7); + message += this.GetRandomMessage(messageStoreName: "Alex", low: 1, high: 2); + } + else if (character.Name.Equals("Leah")) + { + // portrait = "$8"; + message += this.GetRandomMessage(messageStoreName: "greeting", low: 1, high: 7); + message += this.GetRandomMessage(messageStoreName: "Leah", low: 1, high: 2); + } + else if (character.Name.Equals("Marnie")) + { + // portrait = "$8"; + message += this.GetRandomMessage(messageStoreName: "greeting", low: 1, high: 7); + message += this.GetRandomMessage(messageStoreName: "Marnie", low: 1, high: 2); + } + else + { + // message += this.DialogueManager.PerformReplacement(this.DialogueManager.GetRandomMessage("greeting"), stats, this.Config); + // message += this.DialogueManager.PerformReplacement(this.DialogueManager.GetMessageAt(5, "Xdialog"), stats, this.Config); + message += this.GetRandomMessage(messageStoreName: "greeting", low: 1, high: 7); + message += I18n.Dialog_Xdialog5(); } - // message += this.DialogueManager.PerformReplacement(this.DialogueManager.GetRandomMessage("greeting"), stats, this.Config); - // message += this.DialogueManager.PerformReplacement(this.DialogueManager.GetMessageAt(5, "Xdialog"), stats, this.Config); - message += I18n.Dialog_Greeting1(name: Game1.player.Name); - message += I18n.Dialog_Xdialog5(); if (this.CostPerAnimal > 0) { @@ -625,9 +654,9 @@ private void ShowMessage(int numActions, int totalCost, bool doesPlayerHaveEnoug // message += this.DialogueManager.PerformReplacement(this.DialogueManager.GetRandomMessage("smalltalk"), stats, this.Config); message += this.GetRandomMessage(messageStoreName: "smalltalk", low: 1, high: 14); - message += portrait + "#$e#"; + // message += portrait + "#$e#"; - character.CurrentDialogue.Push(new Dialogue(character, message)); + character.CurrentDialogue.Push(new Dialogue(character, "", message)); Game1.drawDialogue(character); } else @@ -719,6 +748,48 @@ private string GetRandomMessage(string messageStoreName, int low=1, int high=4) _ => I18n.Dialog_Smalltalk1(), }; } + else if (messageStoreName == "Shane") + { + return rand switch + { + 1 => I18n.Dialog_Shane1(), + 2 => I18n.Dialog_Shane2(), + _ => I18n.Dialog_Shane1(), + }; + } + else if (messageStoreName == "Haley") + { + return rand switch + { + 1 => I18n.Dialog_Haley1(), + 2 => I18n.Dialog_Haley2(), + _ => I18n.Dialog_Haley1(), + }; + } + else if (messageStoreName == "Alex") + { + return rand switch + { + 1 => I18n.Dialog_Alex1(), + _ => I18n.Dialog_Alex1(), + }; + } + else if (messageStoreName == "Leah") + { + return rand switch + { + 1 => I18n.Dialog_Leah1(), + _ => I18n.Dialog_Leah1(), + }; + } + else if (messageStoreName == "Marnie") + { + return rand switch + { + 1 => I18n.Dialog_Marnie1(), + _ => I18n.Dialog_Marnie1(), + }; + } else { return "...$h#$e#"; diff --git a/AnimalSitter/AnimalSitter.csproj b/AnimalSitter/AnimalSitter.csproj index 1f3a260..91873f1 100644 --- a/AnimalSitter/AnimalSitter.csproj +++ b/AnimalSitter/AnimalSitter.csproj @@ -3,7 +3,7 @@ AnimalSitter AnimalSitter - 2.2.2 + 2.2.3 net6.0 AnyCPU AnyCPU diff --git a/AnimalSitter/manifest.json b/AnimalSitter/manifest.json index a44579e..f5d029c 100644 --- a/AnimalSitter/manifest.json +++ b/AnimalSitter/manifest.json @@ -1,7 +1,7 @@ { "Name": "Animal Sitter LTS", "Author": "oliver", - "Version": "2.2.2", + "Version": "2.2.3", "Description": "Long Term Support Mod Version for Animal Sitter Mod. Let someone else pet all those pesky animals!", "UniqueID": "oliver.AnimalSitterLTS", "EntryDll": "AnimalSitter.dll", diff --git a/README.md b/README.md index b9682bb..7a0addc 100644 --- a/README.md +++ b/README.md @@ -75,9 +75,9 @@ Here's the default configuration: The first specifies the item ID and the chest coordinates, this knows to check for a chest on the farm at that location. The second specifies an item id, a chest location, and a building. This will look for a chest at (7,4) in the FarmHouse (which in the starting house is the spot next to the fireplace). -### Customization +### Customization on Dialogs -The `dialog.xnb` file will allow you to customize the dialog to your liking. I've also included the dialog.yaml source file, but the mod will read it from the XNB file. If you don't know how to do it, google "how to unpack and repack stardew valley mods". +Now our mod support [SMAPI-ModTranslationClassBuilder](https://github.com/Pathoschild/SMAPI-ModTranslationClassBuilder) Framework. So all the strings used in mod will stored in [i18n/default.json](AnimalSitter/i18n/default.json). If you want to add more Dialog or Strings, you need to modify strings inside `default.json` or yoru specific `language.json` file. The dialogue elements are arranged in a name_index format. If the name starts with a capital 'X', that means those messages need to stay roughly in that order and in the same format for the dialog to make sense. The number is important. @@ -87,26 +87,27 @@ Also you'll see that I added a few names down at the bottom,"Shane_1", "Shane_2" Most of the notation that existing SDV dialogs use will work(for example @ is replaced by the name of the farmer). There's also notation added to use values from this mod in the dialog, they are (along with a description) -**%%animalsPet%%** - The number of animals that were petted. -**%%trufflesHarvested%%** - The number of truffles that were harvested. -**%%productsHarvested%%** - The number of other animal products that were harvested (I promise to allow more granular tracking in the future). -**%%aged%%** - The number of animals that were aged to maturity. -**%%fed%%** - The number of animals that were fed. -**%%maxHappiness%%** - The number of animals who had their happiness maxed. -**%%maxFriendship%%** - The number animals that had their friendship toward the farmer maxed out. -**%%numActions%%** - The total number of actions performed. -**%%totalCost%%** - The total costs for all animals. -**%%spouse%%** - The farmer's spouse's name (if married), the value of whoChecks otherwise. +**{{animalsPet}}** - The number of animals that were petted. +**{{trufflesHarvested}}** - The number of truffles that were harvested. +**{{productsHarvested}}** - The number of other animal products that were harvested (I promise to allow more granular tracking in the future). +**{{aged}}** - The number of animals that were aged to maturity. +**{{fed}}** - The number of animals that were fed. +**{{maxHappiness}}** - The number of animals who had their happiness maxed. +**{{maxFriendship}}** - The number animals that had their friendship toward the farmer maxed out. +**{{numActions}}** - The total number of actions performed. +**{{totalCost}}** - The total costs for all animals. +**{{spouse}}** - The farmer's spouse's name (if married), the value of whoChecks otherwise. The dialog groups in the file, and a quick explanation of when each are used: **Xdialog** - Some specific dialogs used when the spouse or non-character check the pots. **greeting** - Greetings the checker will use when addressing the farmer. **unfinishedmoney** - Comments the character checker will make when they weren't able to finish on account of no money. -**freebies** - Comments the character checker will make when allowFreebies is true, and the cost of services was more than the farmer has on hand. (Not really used in this mod yet) **unfinishedinventory** - Comments the character checker will make when they weren't able to finish on account of not having anywhere to deliver the goods. (Not really used in this mod yet) **smalltalk & character names** - Comments that are thrown in at the end of most conversations. +Note: If you add more strings, the mod need to be updated to show those new messages. If you want to contribute, feel free to edit and submit Pull Request to [i18n/default.json](https://github.com/WuZhuoran/Stardew_AnimalSitter/blob/main/AnimalSitter/i18n/default.json). I will update the mod ASAP. + ## Credit * Original [Mod](https://www.nexusmods.com/stardewvalley/mods/581) and [Code](https://github.com/jdusbabek/stardewvalley) from [John Dusbabek](https://github.com/jdusbabek) @@ -117,7 +118,7 @@ The dialog groups in the file, and a quick explanation of when each are used: This project will maintain Open Source [here](https://github.com/WuZhuoran/Stardew_AnimalSitter). -For i18n and translation support. Just Add your languages in `i18n` folders. +For i18n and translation support. Just Add your languages in `i18n` folders or Add more strings to `default.json` file. We appreciate all contributions. Feel Free to raise any issues or pull requests.