Changes

Jump to navigation Jump to search
no edit summary
Line 3: Line 3:  
[[File:Skull Cavern Gem.png|300px|thumb|right|Changing distribution of gemstone ore with level.]]
 
[[File:Skull Cavern Gem.png|300px|thumb|right|Changing distribution of gemstone ore with level.]]
 
[[File:Skull Cavern GemNodes.png|300px|thumb|right|Changing distribution of gem nodes with level and luck.]]
 
[[File:Skull Cavern GemNodes.png|300px|thumb|right|Changing distribution of gem nodes with level and luck.]]
Small minable stones and ores can appear as random stones throughout the level, or rarely as small clumps. These have different distributions<ref name="chooseStoneType" />.
+
Small minable stones and ores can appear as random stones throughout the level, or rarely as small clumps. These have different distributions<ref name="populateLevel" /><ref name="chooseStoneType" />.
On average there will be 0.66 small resource clumps on each level with neutral luck, and 0.97 for the largest possible luck. These clumps have a 25% chance to be a dark grey rock (stone ore), a 1.5% chance to be iridium, and a 73.5% chance to be gold.
+
On average there will be less than 0.67 small resource clumps on each level with neutral luck, and less than 1 for the largest possible luck. These clumps have a 25% chance to be a dark grey rock (stone ore), a 1.5% chance to be iridium, and a 73.5% chance to be gold.
    
The distribution for random stones is more complex and varies with depth and best understood in a few stages.
 
The distribution for random stones is more complex and varies with depth and best understood in a few stages.
Line 18: Line 18:     
Dark grey rocks,  start with their maximum chance at level 1 (9.73% for dark grey rocks, 0.005% for mystic stones, 0.059% for gem nodes for best chances), and drop proportionally as ores take their place.
 
Dark grey rocks,  start with their maximum chance at level 1 (9.73% for dark grey rocks, 0.005% for mystic stones, 0.059% for gem nodes for best chances), and drop proportionally as ores take their place.
 +
 +
 +
==Code Details==
 +
The main code for populating the level is found in the function <code>StardewValley.Locations.MineShaft::populateLevel</code>. In setting up to populate the level, it initially defines stoneChance as a random number (double) in the range [10,30), and gemStoneChance as 0.003. It then calls <code>StardewValley.Locations.MineShaft::adjustLevelChances</code>, which will perform a few checks including setting the chance to find stone to 0 for infested floors and dividing gem stone chance by 2<ref name="adjustChances" />.
 +
After this setup, it will then iterate through every square of the level, and if it passes a few checks it will add a stone selected using the function <code>StardewValley.Locations.MineShaft::chooseStoneType</code>, passing the gemstone chance from above and the magic numbers 0.001 and 5e-5 for gem nodes (internally chanceForPurpleStone) and mystic stones (internally chanceForMysticStone). In the same sweep, if it does not add a stone there is a chance for it to add a large resource clump, which are 2 possible variants of a 2 by 2 boulder.
 +
 +
After iterating through every square, and performing a few other tasks, it will attempt to add ore clumps using the function <code>StardewValley.Locations.MineShaft::tryToAddOreClumps</code>.
 +
 +
===Ore Clumps===
 +
In the <code>StardewValley.Locations.MineShaft::tryToAddOreClumps</code><ref name="oreClumps" /> function, a try will only be made if a random number is less than 0.55 plus the average daily luck. The maximum possible average daily luck is 0.1 from random luck and 0.025 from the special charm<ref name="dailyLuck" />. This means with neutral luck there is a 55% chance to try, and with the best possible luck there is a 67.5% chance.
 +
It will try once, and then generate a random number and keep going if that random number is less than 0.25 plus the average daily luck.
 +
This means there will be 1 chance, plus a 25% chance with neutral luck or a 37.5% chance with best possible luck.
 +
 +
This gives an expected value of 1.3 recurring or 1.6 attempts to generate a clump, which when combined with the base chance to try gives an expected amount of 0.67 or 1.
 +
 +
However, each try chooses a random tile on the map and will only place an ore clump there if the tile is free, resulting in less than these numbers.
 +
 +
To choose which type of ore to add it calls the function <code>StardewValley.Locations.MineShaft::getAppropriateOre</code><ref name="whichOre" />, which just before returning has a 25% chance (if it is not in hard mode) to set the ore to 668 or 670, which are the dark grey rocks (stone ore). Otherwise, the ore is set as 764, gold ore, with a 2% chance to set it to 765, iridium ore.
 +
This results in total chances of 25% for dark grey rocks, 1.5% chance for iridium ore, and 73.5% for gold.
 +
 +
===Random ore placement (chooseStoneType)===
 +
This will first go through the different areas, and for skull cavern, it will set the base stone type to 32, 38, 40 or 42 (equally), and then calculate several variables, in a few stages to give different definitions for different floor ranges
 +
chanceForOre is defined in 2 parts, including using a min to give 3 different regions:
 +
 +
<code>double chanceForOre = 0.02 + (double)skullCavernMineLevel * 0.0005;
 +
if (this.mineLevel >= 130) {
 +
chanceForOre += 0.01 * (double)((float)(Math.Min(100, skullCavernMineLevel) - 10) / 10f);
 +
}</code>
 +
 +
This ends up being defined as either <code>0.02 + skullCavernMineLevel * 0.0005 </code> for floors 1-10, <code>0.01 + skullCavernMineLevel * 0.0015</code> for levels 10 to 100, and <code>0.11 + skullCavernMineLevel * 0.0005</code> for levels 100 and up. This means the chance for ore will increase by 0.05% for each floor, except between levels 10 and 100 where it increases by 0.15% each floor.
    
==References==
 
==References==
 
<references>
 
<references>
 +
<ref name="populateLevel">See <samp>MineShaft::populateLevel</samp> in the game code.</ref>
 +
<ref name="adjustChances">See <samp>MineShaft::adjustLevelChances</samp> in the game code.</ref>
 +
<ref name="oreClumps">See <samp>MineShaft::tryToAddOreClumps</samp> in the game code.</ref>
 +
<ref name="dailyLuck">See <samp>FarmerTeam::AverageDailyLuck</samp> in the game code.</ref>
 +
<ref name="whichOre">See <samp>FarmerTeam::getAppropriateOre</samp> in the game code.</ref>
 
<ref name="chooseStoneType">See <samp>MineShaft::chooseStoneType</samp> in the game code.</ref>
 
<ref name="chooseStoneType">See <samp>MineShaft::chooseStoneType</samp> in the game code.</ref>
 
</references>
 
</references>
84

edits

Navigation menu