Modding Help Changing Birthday Dialogue

Discussion in 'Mods' started by bugmenever, Nov 7, 2016.

  1. bugmenever

    bugmenever Phantasmal Quasar

    Is it possible to edit the default dialogue given upon giving a birthday gift? Possibly even turn it into editable, unique strings (like the .XNB ones in the Dialogue folder)?
    I can locate where the "code" I want to change is by using a .NET decompiler; I can fiddle around in VB and generate a SMAPI compatible mod without much hassle...the only thing I can't do is get my string changes to show up. Perhaps this is more of a C# help question, but if anyone has any tips it's much appreciated.

    Here's the part of code in question, straight from StardewValley.NPC.
    Code:
    public void receiveGift(Object o, Farmer giver, bool updateGiftLimitInfo = true, float friendshipChangeMultiplier = 1f, bool showResponse = true)
        {
          string str1;
          Game1.NPCGiftTastes.TryGetValue(this.name, out str1);
          string[] strArray = str1.Split('/');
          float num = 1f;
          switch (o.quality)
          {
            case 1:
              num = 1.1f;
              break;
            case 2:
              num = 1.25f;
              break;
            case 4:
              num = 1.5f;
              break;
          }
          if ((this.birthday_Season == null || !Game1.currentSeason.Equals(this.birthday_Season) ? 0 : (Game1.dayOfMonth == this.birthday_Day ? 1 : 0)) != 0)
          {
            friendshipChangeMultiplier = 8f;
            string str2 = this.manners == 2 ? "You remembered my birthday? I'm impressed. Thanks.$h" : "A birthday gift? That's very kind of you! I love it.$h";
            if (Game1.random.NextDouble() < 0.5)
              str2 = this.manners == 2 ? "Oh, is it my birthday today? I guess it is. Thanks. This is nice.$h" : "You remembered my birthday! Thank you. This is great.$h";
            string str3 = this.manners == 2 ? "It's my birthday and you give me this? Is this some kind of joke?$s" : "Oh... It's for my birthday? ... Thanks.$s";
            strArray[0] = str2;
            strArray[2] = str2;
            strArray[4] = str3;
            strArray[6] = str3;
            strArray[8] = this.manners == 2 ? "For my birthday? Thanks." : "Oh, a birthday gift! Thank you.";
          }
          if (str1 == null)
            return;
          ++Game1.stats.GiftsGiven;
          Game1.playSound("give_gift");
          if (updateGiftLimitInfo)
            giver.friendships[this.name][3] = 1;
          int tasteForThisItem = this.getGiftTasteForThisItem((Item) o);
          switch (giver.facingDirection)
          {
            case 0:
              ((FarmerSprite) giver.Sprite).animateBackwardsOnce(80, 50f);
              break;
            case 1:
              ((FarmerSprite) giver.Sprite).animateBackwardsOnce(72, 50f);
              break;
            case 2:
              ((FarmerSprite) giver.Sprite).animateBackwardsOnce(64, 50f);
              break;
            case 3:
              ((FarmerSprite) giver.Sprite).animateBackwardsOnce(88, 50f);
              break;
          }
          if (updateGiftLimitInfo)
            ++giver.friendships[this.name][1];
          List<string> stringList = new List<string>();
          int index = 0;
          while (index < 8)
          {
            stringList.Add(strArray[index]);
            index += 2;
          }
          if (tasteForThisItem == 0)
          {
            if (this.name.Contains("Dwarf"))
            {
              if (showResponse)
                Game1.drawDialogue(this, giver.canUnderstandDwarves ? stringList[0] : StardewValley.Dialogue.convertToDwarvish(stringList[0]));
            }
            else if (showResponse)
              Game1.drawDialogue(this, stringList[0] + "$h");
            giver.changeFriendship((int) (80.0 * (double) friendshipChangeMultiplier * (double) num), this);
            this.doEmote(20, true);
            this.faceTowardFarmerForPeriod(15000, 4, false, giver);
          }
          else if (tasteForThisItem == 6)
          {
            if (this.name.Contains("Dwarf"))
            {
              if (showResponse)
                Game1.drawDialogue(this, giver.canUnderstandDwarves ? stringList[3] : StardewValley.Dialogue.convertToDwarvish(stringList[3]));
            }
            else if (showResponse)
              Game1.drawDialogue(this, stringList[3] + "$s");
            giver.changeFriendship((int) (-40.0 * (double) friendshipChangeMultiplier), this);
            this.faceTowardFarmerForPeriod(15000, 4, true, giver);
            this.doEmote(12, true);
          }
          else if (tasteForThisItem == 2)
          {
            if (this.name.Contains("Dwarf"))
            {
              if (showResponse)
                Game1.drawDialogue(this, giver.canUnderstandDwarves ? stringList[1] : StardewValley.Dialogue.convertToDwarvish(stringList[1]));
            }
            else if (showResponse)
              Game1.drawDialogue(this, stringList[1] + "$h");
            giver.changeFriendship((int) (45.0 * (double) friendshipChangeMultiplier * (double) num), this);
            this.faceTowardFarmerForPeriod(7000, 3, true, giver);
          }
          else if (tasteForThisItem == 4)
          {
            if (this.name.Contains("Dwarf"))
            {
              if (showResponse)
                Game1.drawDialogue(this, giver.canUnderstandDwarves ? stringList[2] : StardewValley.Dialogue.convertToDwarvish(stringList[2]));
            }
            else if (showResponse)
              Game1.drawDialogue(this, stringList[2] + "$s");
            giver.changeFriendship((int) (-20.0 * (double) friendshipChangeMultiplier), this);
          }
          else
          {
            if (this.name.Contains("Dwarf"))
            {
              if (showResponse)
                Game1.drawDialogue(this, giver.canUnderstandDwarves ? stringList[2] : StardewValley.Dialogue.convertToDwarvish(stringList[2]));
            }
            else if (showResponse)
              Game1.drawDialogue(this, strArray[8]);
            giver.changeFriendship((int) (20.0 * (double) friendshipChangeMultiplier), this);
          }
        }
    
    Here's just an example of what I want the game to portray (and with less friendship bonus - 8x is too high for me.)
    Code:
    public void receiveGift(Object o, Farmer giver, bool updateGiftLimitInfo = true, float friendshipChangeMultiplier = 1f, bool showResponse = true)
        {
          string str1;
          Game1.NPCGiftTastes.TryGetValue(this.name, out str1);
          string[] strArray = str1.Split('/');
          float num = 1f;
          switch (o.quality)
          {
            case 1:
              num = 1.1f;
              break;
            case 2:
              num = 1.25f;
              break;
            case 4:
              num = 1.5f;
              break;
          }
          if ((this.birthday_Season == null || !Game1.currentSeason.Equals(this.birthday_Season) ? 0 : (Game1.dayOfMonth == this.birthday_Day ? 1 : 0)) != 0)
          {
            friendshipChangeMultiplier = 5f;
            string str2 = this.manners == 2 ? "You remembered my birthday? Wow! Thank you!$h" : "@, a birthday gift? I love it!$h";
            if (Game1.random.NextDouble() < 0.5)
              str2 = this.manners == 2 ? "A gift? You shouldn't have. Thank you.$h" : "You remembered my birthday? Thank you! This is amazing.$h";
            string str3 = this.manners == 2 ? "It's my birthday and you give me this? Is this some kind of joke?$a" : "Oh... It's a birthday gift? ... Thanks?$s";
            strArray[0] = str2;
            strArray[2] = str2;
            strArray[4] = str3;
            strArray[6] = str3;
            strArray[8] = this.manners == 2 ? "A gift? Thanks!" : "Oh, a birthday gift! Thank you.";
          }
          if (str1 == null)
            return;
          ++Game1.stats.GiftsGiven;
          Game1.playSound("give_gift");
          if (updateGiftLimitInfo)
            giver.friendships[this.name][3] = 1;
          int tasteForThisItem = this.getGiftTasteForThisItem((Item) o);
          switch (giver.facingDirection)
          {
            case 0:
              ((FarmerSprite) giver.Sprite).animateBackwardsOnce(80, 50f);
              break;
            case 1:
              ((FarmerSprite) giver.Sprite).animateBackwardsOnce(72, 50f);
              break;
            case 2:
              ((FarmerSprite) giver.Sprite).animateBackwardsOnce(64, 50f);
              break;
            case 3:
              ((FarmerSprite) giver.Sprite).animateBackwardsOnce(88, 50f);
              break;
          }
          if (updateGiftLimitInfo)
            ++giver.friendships[this.name][1];
          List<string> stringList = new List<string>();
          int index = 0;
          while (index < 8)
          {
            stringList.Add(strArray[index]);
            index += 2;
          }
          if (tasteForThisItem == 0)
          {
            if (this.name.Contains("Dwarf"))
            {
              if (showResponse)
                Game1.drawDialogue(this, giver.canUnderstandDwarves ? stringList[0] : StardewValley.Dialogue.convertToDwarvish(stringList[0]));
            }
            else if (showResponse)
              Game1.drawDialogue(this, stringList[0] + "$h");
            giver.changeFriendship((int) (80.0 * (double) friendshipChangeMultiplier * (double) num), this);
            this.doEmote(20, true);
            this.faceTowardFarmerForPeriod(15000, 4, false, giver);
          }
          else if (tasteForThisItem == 6)
          {
            if (this.name.Contains("Dwarf"))
            {
              if (showResponse)
                Game1.drawDialogue(this, giver.canUnderstandDwarves ? stringList[3] : StardewValley.Dialogue.convertToDwarvish(stringList[3]));
            }
            else if (showResponse)
              Game1.drawDialogue(this, stringList[3] + "$s");
            giver.changeFriendship((int) (-40.0 * (double) friendshipChangeMultiplier), this);
            this.faceTowardFarmerForPeriod(15000, 4, true, giver);
            this.doEmote(12, true);
          }
          else if (tasteForThisItem == 2)
          {
            if (this.name.Contains("Dwarf"))
            {
              if (showResponse)
                Game1.drawDialogue(this, giver.canUnderstandDwarves ? stringList[1] : StardewValley.Dialogue.convertToDwarvish(stringList[1]));
            }
            else if (showResponse)
              Game1.drawDialogue(this, stringList[1] + "$h");
            giver.changeFriendship((int) (45.0 * (double) friendshipChangeMultiplier * (double) num), this);
            this.faceTowardFarmerForPeriod(7000, 3, true, giver);
          }
          else if (tasteForThisItem == 4)
          {
            if (this.name.Contains("Dwarf"))
            {
              if (showResponse)
                Game1.drawDialogue(this, giver.canUnderstandDwarves ? stringList[2] : StardewValley.Dialogue.convertToDwarvish(stringList[2]));
            }
            else if (showResponse)
              Game1.drawDialogue(this, stringList[2] + "$s");
            giver.changeFriendship((int) (-20.0 * (double) friendshipChangeMultiplier), this);
          }
          else
          {
            if (this.name.Contains("Dwarf"))
            {
              if (showResponse)
                Game1.drawDialogue(this, giver.canUnderstandDwarves ? stringList[2] : StardewValley.Dialogue.convertToDwarvish(stringList[2]));
            }
            else if (showResponse)
              Game1.drawDialogue(this, strArray[8]);
            giver.changeFriendship((int) (20.0 * (double) friendshipChangeMultiplier), this);
          }
        }
    
     

    Share This Page