Difference between revisions of "Talk:Luck"

From Stardew Valley Wiki
Jump to navigation Jump to search
Line 38: Line 38:
 
So it seems there are only 200 different possible luck values. Making the chance of a true neutral event 1/200 rather than effectively 0 (if it were Random.NextDouble).
 
So it seems there are only 200 different possible luck values. Making the chance of a true neutral event 1/200 rather than effectively 0 (if it were Random.NextDouble).
  
Also, there is little explanation on luck buffs? No code references either, making that section entirely useless.
+
Also, there is little explanation on luck buffs? No code references either, making that section entirely useless. [[User:Anikyte|Anikyte]] ([[User talk:Anikyte|talk]]) 21:36, 20 May 2022
 +
:The page doesn't say the chance of a true neutral event is 0, but the fortune teller does say "it's rare". You are free to write up an explanation of how luck is calculated, though I would put the first draft here on the talk page or in your user space. Be sure to cite that code reference by class and method. If you can find the code reference for food buffs, please feel free to add it to the page. And please remember to sign your comments with four tildes <nowiki>~~~~</nowiki>. Thanks, [[User:Margotbean|margotbean]] ([[User talk:Margotbean|talk]]) 18:22, 21 May 2022 (UTC)

Revision as of 18:22, 21 May 2022

This talk page is for discussing Luck.
  • Sign and date your posts by typing four tildes (~~~~).
  • Put new text below old text.
  • Be polite.
  • Assume good faith.
  • Don't delete discussions.

Luck Value

Would love further explanation of how much "+1 Luck" stat modifies the Luck value. It's a bit confusing how the buffs correlate to the specific Luck value, eg. does +1 Luck equate to the next tier on the Fortune Telling show? Zonesville (talk) 17:32, 18 May 2021 (UTC)

This talk page could be useful: Talk:Luck. Horizon98 (talk) 18:00, 18 May 2021 (UTC)
Oh man what a rookie mistake, I didn't know which wiki I was on. Appreciate the link, feel free to delete! Zonesville (talk) 14:07, 18 May 2021 (UTC)

Play Luck not took into account on dayUpdate?

I'm not an advanced expert about the game code, but I don't get why player luck would not be taken into account in FarmAnimal::dayUpdate (which is called by AnimalHouse::DayUpdate and Farm::DayUpdate, which are called by Game1::_newDayAfterFade in foreach (GameLocation location2 in locations))

Extract of FarmAnimal::dayUpdate code:

float num3 = ((&.op_Implicit((&)(object)happiness) > 200) ? ((float)(int)&.op_Implicit((&)(object)happiness) * 1.5f) : ((float)((&.op_Implicit((&)(object)happiness) <= 100) ? (&.op_Implicit((&)(object)happiness) - 100) : 0)));
if (((&)(object)type).get_Value().Equals("Duck") && random.NextDouble() < (double)((float)&.op_Implicit((&)(object)friendshipTowardFarmer) + num3) / 4750.0 + Game1.player.team.AverageDailyLuck() + Game1.player.team.AverageLuckLevel() * 0.01)
{
	num2 = &.op_Implicit((&)(object)deluxeProduceIndex);
}
else if (((&)(object)type).get_Value().Equals("Rabbit") && random.NextDouble() < (double)((float)&.op_Implicit((&)(object)friendshipTowardFarmer) + num3) / 5000.0 + Game1.player.team.AverageDailyLuck() + Game1.player.team.AverageLuckLevel() * 0.02)
{
	num2 = &.op_Implicit((&)(object)deluxeProduceIndex);
}

(NetFieldBase specifications replaced with & for readability)

Game1.player.team.AverageLuckLevel() appears on both formula. Why and more importantly how would it be neutralized?

FarmerTeam::AverageLuckLevel just compute the average LuckLevel of Game1.getOnlineFarmers() and Farmer::LuckLevel is just a get/set (get is luckLevel + addedLuckLevel, the first being as a skill and the second one obtained from buffs).

-- Charly (talk) 21:34, 15 November 2021 (UTC)

Because no luck buffs are active when the player sleeps, which is when the code executes. margotbean (talk) 21:38, 15 November 2021 (UTC)
Fair point, player.dayupdate() calling Farmer::ClearBuffs happens before locations update in Game1::_newDayAfterFade. -- Charly (talk) 21:46, 15 November 2021 (UTC)

I feel there should more detail on how luck is calculated

This line of code appears to be responsible for determining the days luck:

   Game1.player.team.sharedDailyLuck.Value = Math.Min(0.100000001490116, (double) Game1.random.Next(-100, 101) / 1000.0); 

So it seems there are only 200 different possible luck values. Making the chance of a true neutral event 1/200 rather than effectively 0 (if it were Random.NextDouble).

Also, there is little explanation on luck buffs? No code references either, making that section entirely useless. Anikyte (talk) 21:36, 20 May 2022

The page doesn't say the chance of a true neutral event is 0, but the fortune teller does say "it's rare". You are free to write up an explanation of how luck is calculated, though I would put the first draft here on the talk page or in your user space. Be sure to cite that code reference by class and method. If you can find the code reference for food buffs, please feel free to add it to the page. And please remember to sign your comments with four tildes ~~~~. Thanks, margotbean (talk) 18:22, 21 May 2022 (UTC)