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

Changes

Jump to: navigation, search

Talk:Pig

3,191 bytes added, 19:15, 25 October 2020
Truffles on Pathing?
This entry is a reminder to myself to look further, but perhaps someone else already has noticed something related.(?) [[User:Butterbur|Butterbur]] ([[User talk:Butterbur|talk]]) 16:29, 25 October 2020 (UTC)
:The basic answer is that pathing (plus grass, tilled dirt, etc.) prevents pigs from digging for truffles, but it's irrelevant when deciding where a dug-up truffle is placed -- and a truffle is never placed in the tile where it was dug up.
:There are two separate location-related checks when trying to spawn a truffle, which handle terrain features completely differently.
:* First question: is the pig standing in a location where it can dig for truffles?
::* Digging is cancelled if the pig is on a tile containing any terrain feature or object.
::* Specifics: <tt>FarmAnimal::behavior</tt> has a check that looks at each of the four corners of the pig's bounding box; if just one corner is on a terrain feature/object tile, truffle-spawning is cancelled.
:* Second question: where should a dug-up truffle be placed?
::* The code effectively spirals outwards from the pig's location. The truffle is placed in the first valid tile that is found. Multiple criteria are relevant here, including:
:::* A tile is invalid if it contains any object.
:::* A tile is invalid if any farm animal, monster, or player is standing in it (specifically, if any corner of the character bounding box is in the tile).
:::* Terrain features only make a tile invalid if:
:::** The terrain feature makes the tile impassable (e.g., bushes, trees, stumps, equipment)
:::** On tilled soil, if the tile contains a seed or crop.
::* Specifics: <tt>FarmAnimal::findTruffle</tt> calls <tt>Utility::spawnObjectAround</tt>, which tests a requested tile, then keeps testing all tiles adjacent to any previously-tested tile (resulting a spiral-type pattern). The tests require a tile to be non-water and not fail <tt>GameLocation::isTileOccupiedForPlacement</tt>. The truffle is spawned in the first valid tile that is found. Up to 100 tiles will be tested (creating a diamond-shape region up to 7 tiles away in every direction), otherwise truffle-spawning fails (theoretically reducing the truffle-production rate, but probably only in unusual cases).
::* <tt>GameLocation::isTileOccupiedForPlacement</tt> is the same basic test used when you try to place items such as torches and equipment. (As always, details get muddy, with a host of special conditions for various items, covered in <tt>Object.canBePlacedHere</tt>, but the default/fallback test is <tt>GameLocation::isTileOccupiedForPlacement</tt>).
:One key implication is that the truffle ''always'' appears at least one tile away from where it was dug up. At least if you assume the truffle is dug up on one of the tiles where the pig is standing (which is what is implied by check #1). The fact that the pig is standing there makes truffle placement impossible, based on the any-farm-animal test in check #2.
:In general, clutter could force truffles to appear outside the fence (or any location accessible to the player but not the pig). Or if many farm animals are clustered near the pig, the truffle might be forced to spawn far away -- even though the enclosure looks relatively uncluttered when you later go to collect the truffles. [[User:Nebulous Maestress|Nebulous Maestress]] ([[User talk:Nebulous Maestress|talk]]) 19:13, 25 October 2020 (UTC)
3,556
edits

Navigation menu