Talk:Mining/Skill

From Stardew Valley Wiki
Jump to: navigation, search
This talk page is for discussing Mining/Skill.
  • Sign and date your posts by typing four tildes (~~~~).
  • Put new text below old text.
  • Be polite.
  • Assume good faith.
  • Don't delete discussions.

Prospector and Geologist code

I assume that the wording that is not in brackets is taken directly from the game. I will try to be thorough in my breakdown. I don't know how you want to add the reference to the page, but here is the code. This code excerpt is from GameLocation::breakStone:

     if (((bool) ((NetFieldBase<bool, NetBool>) this.isOutdoors) || (bool) ((NetFieldBase<bool, NetBool>) this.treatAsOutdoors)) && howMuch == 0)
     {
       ...
       if (who.professions.Contains(21) && random.NextDouble() < 0.05 * (1.0 + num2))
         Game1.createObjectDebris(382, x, y, who.UniqueMultiplayerID, this);
       if (random.NextDouble() < 0.05 * (1.0 + num2))
       {
         random.Next(1, 3);
         random.NextDouble();
         double num3 = 0.1 * (1.0 + num2);
         Game1.createObjectDebris(382, x, y, who.UniqueMultiplayerID, this);
         ...

Profession 21 is prospector. is coal id. If the player has prospector, do a second roll for coal. The first if statement checks to see if the location is outdoors, and if "howMuch" is 0. HowMuch is set earlier based on the stone type and holds the amount of mining experience.

This code excerpt is from MineShaft::checkStoneForItem

       if (r.NextDouble() < 0.022 * (1.0 + num1) * (who.professions.Contains(22) ? 2.0 : 1.0))
       {
         int objectIndex = 535 + (this.getMineArea(-1) == 40 ? 1 : (this.getMineArea(-1) == 80 ? 2 : 0));
         if (this.getMineArea(-1) == 121)
           objectIndex = 749;
         if (who.professions.Contains(19) && r.NextDouble() < 0.5)
           Game1.createObjectDebris(objectIndex, x, y, who.UniqueMultiplayerID, (GameLocation) this);
         Game1.createObjectDebris(objectIndex, x, y, who.UniqueMultiplayerID, (GameLocation) this);
         who.gainExperience(5, 20 * this.getMineArea(-1));
       }
       if (this.mineLevel > 20 && r.NextDouble() < 0.005 * (1.0 + num1) * (who.professions.Contains(22) ? 2.0 : 1.0))
       {
         if (who.professions.Contains(19) && r.NextDouble() < 0.5)
           Game1.createObjectDebris(749, x, y, who.UniqueMultiplayerID, (GameLocation) this);
         Game1.createObjectDebris(749, x, y, who.UniqueMultiplayerID, (GameLocation) this);
         who.gainExperience(5, 40 * this.getMineArea(-1));
       }
       if (r.NextDouble() < 0.05 * (1.0 + num1) * num2)
       {
         r.Next(1, 3);
         r.NextDouble();
         double num4 = 0.1 * (1.0 + num1);
         if (r.NextDouble() < 0.25)
         {
           Game1.createObjectDebris(382, x, y, who.UniqueMultiplayerID, (GameLocation) this);
           Game1.multiplayer.broadcastSprites((GameLocation) this, new TemporaryAnimatedSprite(25, new Vector2((float) (64 * x), (float) (64 * y)), Color.White, 8, Game1.random.NextDouble() < 0.5, 80f, 0, -1, -1f, 128, 0));
         }
         else
           Game1.createObjectDebris(this.getOreIndexForLevel(this.mineLevel, r), x, y, who.UniqueMultiplayerID, (GameLocation) this);
         who.gainExperience(3, 5);

Profession 19 is Geologist. Profession 22 is Excavator. There is no check for Prospector(21) when coal(382) is spawned, therefore Prospector has no effect in the mines. Excavator(22) provides a 2x multiplier when checking if a geode is to spawn (535,537,539,749). Alongside the lines that spawn a geode is a check for Geologist(19) which gives a 50% chance of spawning a second

--BlaDe (talk) 01:34, 9 April 2019

This is going to take me some time to go through. My initial thoughts:
1 - When is this.treatAsOutdoors set to true?
2 - Have you taken Pickaxe::DoFunction into account?
3 - If Geologist can cause double geode drops, then what does Excavator do?
4 - We need to specify what "drop" means -- in most places on the wiki, it refers to monster drops, so if it means drops from breaking rocks, we need to somehow specify that
-- margotbean (talk) 17:16, 9 April 2019 (BST)
I had seen Pickaxe::DoFunction before, but thought it was a code version difference... Thanks for finding it for me.
Relevent section 
          if (!location.Name.StartsWith("UndergroundMine"))
          {
            if ((int) ((NetFieldBase<int, NetInt>) @object.parentSheetIndex) == 343 || (int) ((NetFieldBase<int, NetInt>) @object.parentSheetIndex) == 450)
            {
              Random random = new Random((int) Game1.stats.DaysPlayed + (int) Game1.uniqueIDForThisGame / 2 + num1 * 2000 + num2);
              if (random.NextDouble() < 0.035 && Game1.stats.DaysPlayed > 1U)
          .createObjectDebris(535 + (Game1.stats.DaysPlayed <= 60U || random.NextDouble() >= 0.2 ? (Game1.stats.DaysPlayed <= 120U || random.NextDouble() >= 0.2 ? 0 : 2) : 1), num1, num2, this.getLastFarmerToUse().UniqueMultiplayerID);
              if (random.NextDouble() < 0.035 * (who.professions.Contains(21) ? 2.0 : 1.0) && Game1.stats.DaysPlayed > 1U)
                Game1.createObjectDebris(382, num1, num2, this.getLastFarmerToUse().UniqueMultiplayerID);
              if (random.NextDouble() < 0.01 && Game1.stats.DaysPlayed > 1U)
                Game1.createObjectDebris(390, num1, num2, this.getLastFarmerToUse().UniqueMultiplayerID);
            }
            location.breakStone((int) ((NetFieldBase<int, NetInt>) @object.parentSheetIndex), num1, num2, who, new Random((int) Game1.stats.DaysPlayed + (int) Game1.uniqueIDForThisGame / 2 + num1 * 4000 + num2));
          }
          else
            Game1.mine.checkStoneForItems(@object.ParentSheetIndex, num1, num2, who);
There is a check for Prospector, and it double a chance of finding coal from 3.5% to 7%, but when not in the mines. I'm having trouble locating the stone types for 343 and 450, but this should be enough to show that this is excluding the mines. Also, only if you are not in the mines does the code call location.breakStone, the code for which is already posted. If you are in the mines then checkStoneForItems is called, again posted above.
Regarding difference between Geologist and Excavator, I did touch on that. Basically Excavator doubles the chance of finding a geode in the first place. If a geode is found, Geologist gives a 50% chance of finding a second
Regarding what sets treatAsOutdoors, this is in the map information, and the only location that has this set is the Mutant Bug Lair
Regarding terminology, my definition of drop would be anything that drops to the ground due to something being destroyed, so monster loot, stone from breaking rocks, wood from chopping down trees, salmon berries, cranberries, tree seeds, from breaking giant crops, gemstones, even bombing tiles. BlaDe (talk) 11:42, 11 April 2019 (BST)
So, this info is kind of a coup, in that Prospector doesn't do diddly-squat in the mines. I don't know if this has been my in-game experience, but we need to be sure that other code isn't affecting coal drops from monsters/rocks before making that declaration. Mining code is extraordinarily complex, and I don't have a version of the code that executes, so I can't set breakpoints or watch variables. In short, it's wickedly tricky.
The distinction between double drops and double chance of drop should be as explicit as possible. I'm thinking asterisk with a note below the table...
We also need to specify what drop we're talking about, as I said. It needs to be typed out explicitly on the page. ...As compact as possible.
FYI, you can find images of stones 343 and 450 here: Category:Rock images
--margotbean (talk) 19:37, 11 April 2019 (BST)
(since I can't post links: https://imgur.com/a/5W2gOyH) Snapshots tracking isOutdoors/treatAsOutdoors on farm/mine/quarry. Those snippets from Blade are the only two segments that check "Professions.contains(21)" in the 1.3.28 source, so it would appear that Prospector is only useful on the farm/quarry. It looks to operate by improving the base coal drop rate by 2x, as well as giving a separate roll to drop coal.
--Underscore (talk) 01:49, 12 April 2019 (BST)
Thanks for the images, I've added the link. It does appear that Prospector is useless in the mines, something I'm reluctant to admit, but if it's true, it must be added to the page (in all 12 languages, ugh!) ...And the other changes as well. margotbean (talk) 17:52, 12 April 2019 (BST)
Can you walk me through how you worked out how prospector applies to those dark grey rocks? I thought it was the lighter ones. BlaDe (talk) 20:41, 13 April 2019 (BST)
In GameLocation::BreakStone, the initial switch case on indexOfStone contains a case for 668 and 670 that sets howMuch to 3. Cross-referencing with the sprite sheet found at Content\Maps\SpringObjects.xnb gives the images for the dark grey rocks. margotbean (talk) 21:06, 13 April 2019 (BST)
I see the code, but prospector doesn't apply. These rocks have their own roll for coal, which isnt altered by anything. Later on in the same methid, the code that is affected by prospector only occurs if howmuch == 0. I don't believe these rocks are an exception BlaDe (talk) 05:43, 14 April 2019 (BST)
You might be right; I'll look at it when I have time to concentrate, will try tomorrow.  :) margotbean (talk) 08:05, 14 April 2019 (BST)
So, I see that you are right, I've removed the rocks from the page already. There may be more to add to the page (or to the Mining page itself) about those 2 gray rocks, and about the way Geologist/Prospector work, but I won't be analyzing that today, I'm afraid. margotbean (talk) 19:56, 14 April 2019 (BST)

1.4 Changes

Having a look at the changes around Prospector, the above is still true (though some of it is refactored). However there was some code added to MineShaft::checkStoneForItems that doubles the chance of coal in the mines.

Relevent section 
public void checkStoneForItems(int tileIndexOfStone, int x, int y, Farmer who)
    {
      if (who == null)
        who = Game1.player;
      double num1 = who.DailyLuck / 2.0 + (double) who.MiningLevel * 0.005 + (double) who.LuckLevel * 0.001;
      ...
      double num2 = tileIndexOfStone == 40 || tileIndexOfStone == 42 ? 1.2 : 0.8;
      ...
        if (r.NextDouble() < 0.05 * (1.0 + num1) * num2)
        {
          ...
          if (r.NextDouble() < 0.25 * (who.professions.Contains(21) ? 2.0 : 1.0))
          {
            Game1.createObjectDebris(382, x, y, who.UniqueMultiplayerID, (GameLocation) this); //Coal
            ...
          }
          Game1.createObjectDebris(this.getOreIndexForLevel(this.mineLevel, r), x, y, who.UniqueMultiplayerID, (GameLocation) this);
          who.gainExperience(3, 5);
        }
        else
        {
          ...
        }
      }
    }

Without prospector, a rock dropping ore has a 25% chance to also drop coal. With prospector this is doubled to 50% I'm putting this here so we can discuss the best way to communicate this. BlaDe (talk) 23:39, 3 May 2020 (UTC)

Since that's literally what the skill implies I think that's more of a topic for the coal or mining overview page - the skill works as described so no reason to get into the details of where exactly coal can drop in here with the skills. Raist (talk) 03:02, 4 May 2020 (UTC)
Yes, but it is not the only place it is used in code, and it has been used inconsistently. Though the main reason I have added it here is to have the context of the previous discussion. BlaDe (talk) 03:40, 4 May 2020 (UTC)
If I'm brutally honest, I'm leaning towards thinking that explaining it all is too complicated for the benefits it gives. If it can all be summed up by saying that Prospector doubles the chance of finding coal (in one way or another), then the description can stand on its own. If it's always a 25/50% chance, then that's worth saying, but it isn't because there's that extra drop chance. The 25/50 applies only to a rock that's dropped ore. This is not something the player can control, other than by mining rocks on a good luck day and hoping for the best.
So, your question is how do we explain that there is a specific % that Prospector applies to rocks that have dropped ore? We can...
  1. Remove the explanation entirely
  2. Add to the footnote
I've already stated that I'm leaning towards #1.
Here is what the footnote might look like if added to:
*Prospector adds a chance to find 1 extra piece of coal before the non-Prospector code for finding coal executes. It also doubles the chance of obtaining coal from a rock that's dropped ore from 25% to 50% (See GameLocation::breakStone in the game code.)
Thoughts? margotbean (talk) 17:47, 4 May 2020 (UTC)