This wiki is a read-only version of the Stardew Valley Wiki. The official editable wiki maintained by ConcernedApe can be found at stardewvalleywiki.com
User talk:Nanobot
From Stardew Valley Wiki
This is Nanobot's talk page, where you can send messages and comments to Nanobot. | |
---|---|
|
|
Lightning Rod
Hello Nanobot! Can you please give a code reference for the "chance to intercept" info you added to the Lightning Rod page? The name of the class and method/function would be great. Thank you! margotbean (talk) 19:51, 24 January 2020 (UTC)
- Sure, it's Utility.performLightningUpdate().
- The function first rolls a random number to decide whether this is an actual lightning strike. If it is, the next thing it does is build a list of all lightning rods on the farm. If there's more than zero, it does the following twice: Pick a random lightning rod from the list, check if it's holding something (such as if it's busy processing a strike), and if it isn't, strike the lightning rod and return. Unless it returns in one of these two attempts, it will then move on to the logic for striking a feature on the farm.
- The chance that a single intercept attempt will fail is
number of busy lightning rods / total number of lightning rods
. The chance of it failing both attempts is then(number of busy lightning rods / total number of lightning rods)²
, which means the chance that it doesn't fail overall is1 - (number of busy lightning rods / total number of lightning rods)²
- Nanobot (talk) 00:27, 26 January 2020 (UTC)
- Thank you thank you thank you!!! margotbean (talk) 15:51, 26 January 2020 (UTC)