Sundew Farms Research Division Presents: Animal Mechanics

Discussion in 'General Discussion' started by SunTide, Oct 26, 2016.

  1. ChaosAzeroth

    ChaosAzeroth Existential Complex

    I wonder if the removal of the butchery stuff somehow could have broken other parts of the code and that's why things are so jacked up.
    From my ((very limited I admit)) understanding of code, seemingly unrelated bits can be broken by changing/removing bits.
      Declension likes this.
    • SunTide

      SunTide Scruffy Nerf-Herder

      When CA was a young boy, he was mercilessly tormented by a mean-spirited dairy cow. The Byzantine mechanics for animals in Stardew Valley are actually his unconscious coping mechanism for working through the trauma.

      Please. I need this. Don't take it away from me.
      • Shiverwarp

        Shiverwarp Starship Captain

        I posted this thread in the subreddit, just for a bit more visibility. It's a pretty important game mechanics thing, hopefully CA will find/see it.
        • Shiverwarp

          Shiverwarp Starship Captain

          One last question for StarPeanut: You stated that the heater in winter causes the Happiness decay for staying awake past 6PM to change into an increase, could you elaborate on that? Are you saying it will increase up to 150, if it were below? Or are you saying we could reach 255 by staying up late during winter?
            Last edited: Oct 26, 2016
          • SunTide

            SunTide Scruffy Nerf-Herder

            I can answer that. If happiness is below 150 (or 59% as displayed by LookUpAnything), then there is no effect, i.e. happiness doesn't change at all. If happiness is over 150, then you actually gain about 10 points (2%) every 10 minutes, until you hit the cap. So in the winter, you gain happiness by going to bed late, assuming you have a heater.

            A few other odds and ends:

            -The 150 point minimum corresponds to a 59% happiness display. If you start from 100%, you will hit this at 9:40 PM (measured directly, not calculated)
            -Petting a cow gives an 8% bonus to happiness, which is roughly 16 points.

            Absolutely nothing makes sense. The threshold effect is completely bonkers. Being "fine" is much, much worse than being "sad." Animals only sleep when you go to sleep, regardless of their animations. Animals hate being kept up late, unless you have a heater and it's winter, then they love it, unless they are already unhappy, in which case it makes no difference. The wrap around bug makes petting animals extremely traumatizing to them unless you have deep knowledge about the game code. Ph'nglui mglw'nafh Cthulhu R'lyeh wgah'nagl fhtagn

            Farm-animal-related childhood trauma. Calling it now.
              ChaosAzeroth likes this.
            • nevyn21

              nevyn21 Cosmic Narwhal

              I knew the animal system was a little wonky but I didn't think it was this bad. Thanks Starpeanut and Suntide for looking under the hood. Maybe we'll see improvements.
              • UnsureSherlock

                UnsureSherlock Orbital Explorer

                This shouldn't be too difficult of a problem to solve at all. The problem is that the happiness value of an animal is most likely store in a single byte, which is an unsigned variable ranging from 0-255. In C#, when you exceed the max value it rolls back over to the minimum.

                The two ways of solving this issue are:
                A. Putting in checks on happiness modifiers to make sure that if the amount trying to be added to the byte would make the byte's value exceed 255, then simply set the value to 255 and allow no more increments.
                B. Increase the max value by changing the variable type to a ushort, but validation would need to be done on this since the max value of a ushort is 65535, and would most likely be exploited to get animals to full hearts in one day (somehow).

                Posted this same explanation, only there I included a visual example:

                EDIT: Just tested this by swapping the code around so the variable is a ushort. I have my own decompiled version using dotpeek/ILSpy, obviously I can't distribute the source with the changes (plus it's borked in weird ways), but it seems to work just fine in terms of animal happiness.
                  Last edited: Oct 27, 2016
                  nevyn21 likes this.
                • SunTide

                  SunTide Scruffy Nerf-Herder

                  I've been trying to divine what CA's original intentions might have been. The wrap around issue is obviously a bug. There's no way that was on purpose. The rest is not so clear.

                  The bizarro-blackjack rules for happiness are probably not working as intended. "Sad" is neutral, "fine" is negative, and "really happy" can either be extremely negative or slightly positive. I suspect that he wanted 200 happiness to be the tipping point between good and bad, but accidentally made it a sign switch instead of a balancing point. Maybe the intended modifier to animal score was (Happiness - 200) * 2 , which would make more sense. It would also mean that the positive effects of high happiness would be pretty weak, but that's probably okay.

                  The happiness decay for staying up past 6:00 makes no sense, but might actually be a deliberate design choice. Then again, maybe not. I want to believe that the penalty was intended to be applied to animals when the animals themselves stay up past 6:00. That would mean that you take a penalty for poorly designed farms that make it hard for your animals to get back home in a timely manner. It would also mean that you don't have to take a wildly disproportionate penalty for a truely minor improvement to animal goods.

                  The heater effect also makes no sense, and was probably intended to cancel the effects of the cold, not sign-switch them.

                  I don't know what can and can't be modded in SDV, but if someone made a mod that included these changes, I would consider it to be a must have.
                    ChaosAzeroth and nevyn21 like this.
                  • Shiverwarp

                    Shiverwarp Starship Captain

                    SunTide, could you reconfirm that animals lose 10 points of Friendship/Hearts during the winter without a heater? I'm updating the wiki with the new information and would like to be sure.

                    EDIT: After a bunch of testing your results about what affects friendship appear to be wrong.

                    Petting my cow or chicken results in an increase of 15 friendship points.

                    Not petting the cow results in a -8 friendship at the end of the day CORRECTION: Looked into the code afterward for these, all the rest are correct but not petting is variable based on: (10 - (friendship/ 200)) So the higher your initial friendship, the less you'll lose for not petting them. (Variable between 10 to 5 points)

                    Not feeding the cow and not petting the cow results in a -28 friendship at the end of the day

                    Having NO heater in winter, No petting, and no feeding results in -28.

                    Having no heater, but being pet and fed the previous day results in no change at the end of the day.

                    I also tested being left outside (Obviously non-winter) and not being pet, which also led to a -28 result at the end of the day.

                    Eating grass outside, as you confirmed in the beginning of the thread, DOES increase friendship by 8 points.

                    I updated the wiki to reflect my new findings.
                      Last edited: Oct 29, 2016
                      nevyn21 likes this.
                    • nevyn21

                      nevyn21 Cosmic Narwhal

                      I just read the wiki update to the animals section. Nice work and thanks again!
                      • Shiverwarp

                        Shiverwarp Starship Captain

                        No worries. Also added information about Animal Attacks that I figured out.
                        • nevyn21

                          nevyn21 Cosmic Narwhal

                          I have a question about eating times. When do animals eat fodder in the barn versus waiting and eating grass outside. Is there a specific time I need to open my barn doors or can I hold them until a certain time. It would help me to know when to pet them or not. With auto-feeders I can't tell when they eat in the barn and unless I get lucky and see them eat grass I don't know if I should pet them or not outside.
                          • SunTide

                            SunTide Scruffy Nerf-Herder

                            It doesn't matter much because eating fodder has a much smaller effect on happiness than grass. The problem with grass is that it maxes out happiness, so even a small gain triggers the wrap around bug. Fodder doesn't have this problem. Unless you are going to bed at 6:00, your fodder-fed animals basically start out mildly depressed every day, and petting only helps.
                            • nevyn21

                              nevyn21 Cosmic Narwhal

                              It matters if I hold them back a few hours for pettings before letting them out to eat grass and they eat fodder instead. If let them out without petting them, their friendship takes a hit and if I pet them after eating grass I'm screwed.

                              It may not help to know all that much but I'm curious. :) Does the game just remove the fodder and give them the fodder-fed bonus when I go to sleep if they haven't eaten that day or is there a set time it gives then the fodder bonus and they won't eat grass afterwards?
                              • StarPeanut

                                StarPeanut 2.7182818284590...

                                Yes. Fodder is only consumed when you go to sleep.
                                • Shiverwarp

                                  Shiverwarp Starship Captain

                                  Yup, as StarPeanut says, if an animal hasn't eaten by the time you go to sleep, and they aren't trapped outside, they'll eat one instance of Hay. If they were fed either Hay or Grass they'll gain 10 to 16 happiness.
                                  • nevyn21

                                    nevyn21 Cosmic Narwhal

                                    Ok, thanks. :) You guys have been great. Sorry if I'm being a pain.
                                    • nevyn21

                                      nevyn21 Cosmic Narwhal

                                      I ran a little experiment today with save scumming and the results are interesting compared against what we know.

                                      The experiment: Copying my save file I repeated the same day 4 times and recorded the results for how different actions resulted on Day 2.

                                      Day 1 Spring 17th:

                                      Weather: Sunny Luck: Mildy Perturbed Forecast: Sunny
                                      General Mood of flock: Really Happy
                                      Iridium Wool: 10 Silver Wool: 5
                                      Gold Wool: 8 Wool: 0
                                      Producton: 23/60

                                      Day 2 Spring 18th
                                      : Flock Petted and Sheared/Barn closed by 6, Player in bed by 7pm

                                      Weather: Sunny Luck: ??? Forecast: Rain
                                      General Mood of flock:Sad/Fine
                                      Iridium Wool: 4 Silver Wool: 0
                                      Gold Wool: 0 Wool: 0
                                      Producton: 4/60 :(

                                      Day 2 Spring 18th: Flock only Sheared/Barn closed by 6, Player in bed by 7pm

                                      Weather: Sunny Luck: Good Humor Forecast: Rain
                                      General Mood of flock:Sad/Fine/Really Happy
                                      Iridium Wool: 0 Silver Wool: 1
                                      Gold Wool: 1 Wool: 0
                                      Producton: 2/60 :(

                                      Day 2 Spring 18th: Flock Petted and Sheared/Barn closed by 6, Player in bed by 11pm

                                      Weather: Sunny Luck: Midly Perturbed Forecast: Sunny
                                      General Mood of flock: Really Happy
                                      Iridium Wool: 15 Silver Wool: 5
                                      Gold Wool: 5 Wool: 0
                                      Producton: 25/60 :)

                                      Day 2 Spring 18th: Flock Sheared only/Barn closed by 6, Player in bed by 11pm

                                      Weather: Sunny Luck: Very Happy Forecast: Rain
                                      General Mood of flock:Really Happy
                                      Iridium Wool: 4 Silver Wool: 6
                                      Gold Wool: 15 Wool: 2
                                      Producton: 27/60 :)

                                      Despite producng two more wool with Case 4 over Case 3, Case 3 is still the better one money wise. Case 1 and 2 were complete failures.
                                        Last edited: Oct 30, 2016
                                      • Shiverwarp

                                        Shiverwarp Starship Captain

                                        So you're saying those are the actions you performed on day one, before sleeping and going into day 2?

                                        The only things that can PREVENT creation of any product at all are not eating anything, or having a Mood value below 70 (There's still a chance they will still produce, but the lower the mood, the lower the chance) And of course, if the animal is still a baby it can't produce.

                                        So basically staying up past 6PM will only result in a reduction to product quality, but not whether they create a product or not. The "player staying awake" reduction can only happen if they are already above 150 mood.

                                        I've been updating the wiki pretty regularly the past few days with the knowledge from looking at the code, so you can get more info there:
                                        • nevyn21

                                          nevyn21 Cosmic Narwhal

                                          Correct, all action performed on day 1 and results sampled on following day. All animals grazed and ate grass (I'm assuming. I left the farms for the mines each day on each play). I'm going to run with Case 3 for the remainder 5 days and record results.

                                          Share This Page