Modding:Location data: Difference between revisions
imported>Margotbean zh link |
imported>VulpesLucida |
||
| Line 38: | Line 38: | ||
* The value is a model with the fields listed below. | * The value is a model with the fields listed below. | ||
=== | ===基本信息=== | ||
{| class="wikitable" | {| class="wikitable" | ||
|- | |- | ||
! | ! 字段 | ||
! | ! 效果 | ||
|- | |- | ||
| <samp>DisplayName</samp> | | <samp>DisplayName</samp> | ||
| '' | | '''(可选,但强烈建议)''' 用于显示翻译后地点名的[[模组:模板字符串|模板字符串]]。此字段用在原版或模组需要显示地点名称的场合。 | ||
|- | |- | ||
| <samp>DefaultArrivalTile</samp> | | <samp>DefaultArrivalTile</samp> | ||
| '' | | '''(可选,但强烈建议)''' 玩家通过未指定地块位置的传送到达该地点后,默认到达的地块位置。默认为none,也就是通常会把玩家放在(0, 0)。 | ||
|- | |- | ||
| <samp>CreateOnLoad</samp> | | <samp>CreateOnLoad</samp> | ||
| '' | | '''(可选)''' 若设置,则加载存档使用此数据文件时会自动创建地点。 | ||
此字段为包含如下字段的数据模型: | |||
{| class="wikitable" | {| class="wikitable" | ||
|- | |- | ||
! | ! 字段 | ||
! | ! 效果 | ||
|- | |- | ||
| <samp>MapPath</samp> | | <samp>MapPath</samp> | ||
| | | 该地点使用的地图素材名称。 | ||
|- | |- | ||
| <samp>AlwaysActive</samp> | | <samp>AlwaysActive</samp> | ||
| '' | | '''(可选)''' 该地点是否在多人游戏中向农场帮手保持同步,无论他们是否在此地点。任何允许建造联机小屋的地点'''必须'''开启此字段以防崩溃。 | ||
|- | |- | ||
| <samp>Type</samp> | | <samp>Type</samp> | ||
| '' | | '''(可选)''' 待创建的C#地点类的全名。必须为原版类型的名称以防存档时崩溃。由于类名过多,不在此一一列出,但最常用的类型为<samp>StardewValley.GameLocation</samp> (默认值)和<samp>StardewValley.Locations.DecoratableLocation</samp>。 | ||
|} | |} | ||
|- | |- | ||
| <samp>CanPlantHere</samp> | | <samp>CanPlantHere</samp> | ||
| '' | | '''(可选)''' 作物和树木在默认情形下是否能够种植和生长于此。除非相应的种植规则字段重写此字段,否则默认使用此字段。农场默认为true,其他位置默认为false。 | ||
|- | |- | ||
| <samp>ExcludeFromNpcPathfinding</samp> | | <samp>ExcludeFromNpcPathfinding</samp> | ||
| '' | | '''(可选)''' 村民在不同地点间寻路时是否忽略此地点。默认为false。 | ||
|} | |} | ||
Revision as of 11:36, 29 October 2024
This page explains how to create and edit in-game locations.
Terminology
A few terms may be used interchangeably or have different meanings depending on the context. In the context of Stardew Valley:
- A location is part of the game code and save data. It manages the in-game area and everything inside it (including non-map entities like players). The location is read/written to the save file, and is only loaded when loading the save file.
- A map is an asset which describes the tile layout, tilesheets, and map/tile properties for the in-game area. The map is reloaded each time you load a save, and each time a mod changes the map.
- A world map is the image shown for a world region in the in-game menu.
In other words, a location (part of the game code) references the map (loaded from the Content folder):
┌─────────────────────────────────┐ │ Location │ │ - objects │ │ - furniture │ │ - crops │ │ - bushes and trees │ │ - NPCs and players │ │ - etc │ │ │ │ ┌─────────────────────────┐ │ │ │ Map asset │ │ │ │ - tile layout │ │ │ │ - map/tile properties │ │ │ │ - tilesheets │ │ │ └─────────────────────────┘ │ └─────────────────────────────────┘
Data format
You can add or edit locations by editing the Data/Locations asset.
This consists of a string → model lookup, where...
- The key is the unique string ID of the location (i.e. "internal name"), which will also be used as the location's Name (not DisplayName) field. (The farm will use Farm_
<type key>for a vanilla farm type, or Farm_<type ID>for a custom farm type, or Farm_Standard if no type-specific entry was found.) - The value is a model with the fields listed below.
基本信息
| 字段 | 效果 | ||||||||
|---|---|---|---|---|---|---|---|---|---|
| DisplayName | (可选,但强烈建议) 用于显示翻译后地点名的模板字符串。此字段用在原版或模组需要显示地点名称的场合。 | ||||||||
| DefaultArrivalTile | (可选,但强烈建议) 玩家通过未指定地块位置的传送到达该地点后,默认到达的地块位置。默认为none,也就是通常会把玩家放在(0, 0)。 | ||||||||
| CreateOnLoad | (可选) 若设置,则加载存档使用此数据文件时会自动创建地点。
此字段为包含如下字段的数据模型:
| ||||||||
| CanPlantHere | (可选) 作物和树木在默认情形下是否能够种植和生长于此。除非相应的种植规则字段重写此字段,否则默认使用此字段。农场默认为true,其他位置默认为false。 | ||||||||
| ExcludeFromNpcPathfinding | (可选) 村民在不同地点间寻路时是否忽略此地点。默认为false。 |
Contents
| field | effect | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| ArtifactSpots | (Optional) The items that can be found when digging artifact spots in this location.
An artifact spot is selected by combining this field with the equivalent field on the Default entry, sorting by Precedence value, and then choosing the first entry whose fields match. (Artifact spot drops can also be listed in Data/Objects's Miscellaneous field; those are applied by the RANDOM_ARTIFACT_FOR_DIG_SPOT entry in DefaultArtifactSpots.) This consists of a list of models with these fields:
For example, a location with this field will drop 2-4 pufferfish with a 50% chance on summer days: "ArtifactSpots": [
{
"Condition": "LOCATION_SEASON Here summer",
"ItemId": "(O)128",
"MinStack": 2,
"MaxStack": 4
}
]
| ||||||||||||||||||||||||||||||||||||||||||||||||||||
| FishAreas | (Optional) The distinct fishing areas within the location. These can be referenced by fish via FishAreaId, and determine which fish are collected by crab pots.
This consists of a string → model lookup, where the key is the fish area ID and the value consists of a list of models with these fields:
| ||||||||||||||||||||||||||||||||||||||||||||||||||||
| Fish | (Optional) The fish that can be caught in the location.
A fish is selected by combining this field with the equivalent field on the Default entry, sorting by Precedence value (and randomly shuffling entries with the same precedence), and then choosing the first entry whose fields match. Note: the produced item ID is saved to recreate the fish later. Any item info that's not based on the item ID is ignored (like stack size, quality, flavored variants like Blueberry Wine vs Wine, and the is-recipe flag). This consists of a list of models with these fields:
| ||||||||||||||||||||||||||||||||||||||||||||||||||||
| Forage | (Optional) The forage that can spawn in the location.
Notes:
This consists of a list of models with these fields:
| ||||||||||||||||||||||||||||||||||||||||||||||||||||
| MinDailyWeeds MaxDailyWeeds |
(Optional) The minimum and maximum number of weeds to spawn in a day, if applicable. Default 1 and 5 respectively. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| FirstDayWeedMultiplier | (Optional) On the first day of each year, a multiplier to apply to the number of daily weeds spawned. Default 15. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| MinDailyForageSpawn MaxDailyForageSpawn |
(Optional) The minimum and maximum number of forage to try spawning in one day, if applicable and the location has fewer than MaxSpawnedForageAtOnce forage. Default 1 and 4 respectively. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| MaxSpawnedForageAtOnce | (Optional) The maximum number of spawned forage that can be present at once on the map before they stop spawning. Default 6. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| ChanceForClay | (Optional) The probability that digging a tile will produce clay, as a value between 0 (never) and 1 (always). |
Music
| field | effect | ||||||||
|---|---|---|---|---|---|---|---|---|---|
| Music | (Optional) The music to play when the player enters the location (subject to the other fields like MusicContext).
The first matching entry is used. If none match, falls back to MusicDefault. This consists of a list of models with these fields:
| ||||||||
| MusicDefault | (Optional) The music to play if none of the options in Music matched. If this is null, falls back to the Music map property (if set). | ||||||||
| MusicContext | (Optional) The music context for this location. The recommended values are Default or SubLocation. Default Default.
Setting SubLocation has two effects:
| ||||||||
| MusicIgnoredInRain | (Optional) Whether the location music is ignored when it's raining in this location. Default false. | ||||||||
| MusicIgnoredInSpring MusicIgnoredInSummer MusicIgnoredInFall MusicIgnoredInWinter |
(Optional) Whether the location music is ignored in the given season. Default false. | ||||||||
| MusicIgnoredInFallDebris | (Optional) Whether the location music is ignored in fall during windy weather. Default false. | ||||||||
| MusicIsTownTheme | (Optional) Whether to use the same behavior as Pelican Town's music: it will start playing after the day music has finished, and will continue playing while the player travels through indoor areas, but will stop when entering another outdoor area that isn't marked with the same Music and MusicIsTownTheme values. Default false. |
Advanced
| field | effect |
|---|---|
| CustomFields | (Optional) The custom fields for this entry. |
| FormerLocationNames | (Optional) The former location names which may appear in save data. See Can I rename a location? in the FAQs for more info. |
Default entry
The Data/Locations asset has a location with the key Default. The ArtifactSpots, Fish, and Forage fields for this entry are added to every other location's equivalent fields, so this lets you add artifact spots / fish / forage in all locations.
FAQs
How do I get to a custom location in-game?
Adding a location to Data/Locations only adds the location to the game. Don't forget to give players some way to reach it, usually by adding warps from another map using EditMap in a Content Patcher content pack.
For a quick test, you can run the debug warp console command to warp directly into it.
<location name>
Can I make the location conditional?
There's many ways you can decide when players have access. For example, you can use EditMap in a Content Patcher content pack to add warps conditionally or to add some form of roadblock that must be cleared (e.g. a landslide).
Note: don't make the existence of the location itself conditional, just make it unreachable. Removing the location will permanently delete everything inside it.
Can I rename a location?
Renaming a location will permanently lose player changes made for the old name if you're not careful.
You can avoid that by setting the FormerLocationNames field in Data/Locations. If a location in save data has a name which (a) matches one of the FormerLocationNames and (b) doesn't match the name of a loaded location, its data will be loaded into the location which specified the FormerLocationNames field instead.
For example:
"FormerLocationNames": [ "Custom_SomeOldName" ]
Legacy names can have any format, but they must be globally unique. They can't match the Name or FormerLocationNames of any other location in Data/Locations (whether vanilla or custom).
Location names
In-game locations like the farm or beach are represented by the GameLocation class (or a subclass), and are identified by a unique name.
Here are some of the vanilla locations:
| Name | Class | Description |
|---|---|---|
| Farm | StardewValley.Farm | The outdoor area of the Pelican Town farm. |
| FarmHouse | StardewValley.Locations.FarmHouse | The interior of the farm house. |
| FarmCave | StardewValley.Locations.FarmCave | The bats/mushroom cave on the farm. |
| Town | StardewValley.Locations.Town | The outdoor area of Pelican Town. |
| JoshHouse | StardewValley.GameLocation | Alex/George/Evelyn's house. (Josh was the old name for the Alex character.) |
| HaleyHouse | StardewValley.GameLocation | Haley/Emily's house. |
| SamHouse | StardewValley.GameLocation | Sam/Jodi/Kent/Vincent's house. |
| Blacksmith | StardewValley.GameLocation | Clint's blacksmith shop. |
| ManorHouse | StardewValley.Locations.ManorHouse | Mayor Lewis' house. |
| SeedShop | StardewValley.Locations.SeedShop | Pierre's general store (also Caroline/Abigail's house and church) |
| Saloon | StardewValley.GameLocation | The Stardrop Saloon (and Gus' house) |
| Trailer | StardewValley.GameLocation | Pam/Penny's trailer. |
| Hospital | StardewValley.GameLocation | Harvey's clinic. |
| HarveyRoom | StardewValley.GameLocation | Harvey's room upstairs from the clinic. |
| Beach | StardewValley.Locations.Beach | The beach south of Pelican Town. |
| ElliottHouse | StardewValley.GameLocation | Elliott's cabin on the beach. |
| Mountain | StardewValley.Locations.Mountain | The outdoor mountain area where the Carpenter, Linus' tent, and Adventurer's Guild are. |
| ScienceHouse | StardewValley.GameLocation | The Carpenter's Shop. |
| SebastianRoom | StardewValley.GameLocation | Sebastian's room in the basement of the carpenter house. |
| Tent | StardewValley.GameLocation | Linus' tent. |
| Forest | StardewValley.Locations.Forest | Cindersap forest south of the farm. |
| WizardHouse | StardewValley.Locations.WizardHouse | The wizard/Rasmodius's tower |
| AnimalShop | StardewValley.GameLocation | Marnie's Ranch |
| LeahHouse | StardewValley.GameLocation | Leah's Cottage. |
| BusStop | StardewValley.Locations.BusStop | The bus stop area between the farm and Pelican Town. |
| Mine | StardewValley.Locations.Mine | The first room of the mines, where the dwarf's shop is. |
| Sewer | StardewValley.Locations.Sewer | The sewers where Krobus' shop is. |
| BugLand | StardewValley.Locations.BugLand | The mutant bug lair in the sewers. |
| Desert | StardewValley.Locations.Desert | Calico Desert where Sandy's Oasis shop and the skull cavern are. |
| Club | StardewValley.Locations.Club | Mr. Qi's casino in Sandy's Oasis shop. |
| SandyHouse | StardewValley.GameLocation | The Oasis, Sandy's shop in Calico Desert. |
| ArchaeologyHouse | StardewValley.Locations.LibraryMuseum | The Museum in Pelican Town, south of the Blacksmith. |
| WizardHouseBasement | StardewValley.GameLocation | The basement of the Wizard's Tower |
| AdventureGuild | StardewValley.Locations.AdventureGuild | The Adventurer's Guild, home of Marlon and Gil. |
| Woods | StardewValley.Locations.Woods | The secret woods in Cindersap forest blocked by a large log. |
| Railroad | StardewValley.Locations.Railroad | The railroad north of the mountains, where the spa is located. |
| WitchSwamp | StardewValley.GameLocation | The swamp area where the Witch's Hut is. |
| WitchHut | StardewValley.GameLocation | The interior of the Witch's Hut. |
| WitchWarpCave | StardewValley.GameLocation | The cave accessible at the top right of the railroad, which warps to the Witch's swamp. |
| Summit | StardewValley.Locations.Summit | The summit north of the railroad. |
| FishShop | StardewValley.Locations.FishShop | Willy's shop. |
| BathHouse_Entry | StardewValley.GameLocation | The entrance room in the spa, leading to the men's and women's locker rooms. |
| BathHouse_MensLocker | StardewValley.GameLocation | The men's locker room in the spa. |
| BathHouse_WomensLocker | StardewValley.GameLocation | The women's locker room in the spa. |
| BathHouse_Pool | StardewValley.Locations.BathHousePool | The bathhouse pool in the spa. |
| CommunityCenter | StardewValley.Locations.CommunityCenter | The inside of the Community Center. |
| JojaMart | StardewValley.Locations.JojaMart | The inside of Pelican Town's JojaMart. |
| Greenhouse | StardewValley.GameLocation | The Greenhouse on the player's farm. |
| SkullCave | StardewValley.GameLocation | The entrance of the Skull Cavern in Calico desert. |
| Backwoods | StardewValley.GameLocation | The backwoods area north of the farm/west of the bus stop, leading to the bus tunnel or to the mountains. |
| Tunnel | StardewValley.GameLocation | The dark bus tunnel to the west of the bus stop. |
| Trailer_Big | StardewValley.GameLocation | The inside of Pam/Penny's house after the Community Upgrade. |
| Cellar | StardewValley.Locations.Cellar | |
| Cellar2 | StardewValley.Locations.Cellar | |
| Cellar3 | StardewValley.Locations.Cellar | |
| Cellar4 | StardewValley.Locations.Cellar | |
| BeachNightMarket | StardewValley.Locations.BeachNightMarket | The beach south of Pelican Town during the Night Market. |
| MermaidHouse | StardewValley.Locations.MermaidHouse | The interior of the mermaid boat at the Night Market. |
| Submarine | StardewValley.Locations.Submarine | The interior of the fishing submarine during the Night Market. |
| AbandonedJojaMart | StardewValley.Locations.AbandonedJojaMart | The small interior of the abandoned JojaMart where the Missing Bundle is. |
| MovieTheater | StardewValley.Locations.MovieTheater | The interior of the Movie Theater that replaces JojaMart. |
| Sunroom | StardewValley.GameLocation | Caroline's sunroom inside Pierre's General Store. |
| BoatTunnel | StardewValley.Locations.BoatTunnel | Where Willy's Boat is, in back of the fish shop. |
| IslandSouth | StardewValley.Locations.IslandSouth | Ginger Island, the docks where the player first lands and where the beach resort is. |
| IslandSouthEast | StardewValley.Locations.IslandSouthEast | Ginger Island, where the mermaid and pirate cove are. |
| IslandSouthEastCave | StardewValley.Locations.IslandSouthEastCave | The pirate cove. |
| IslandEast | StardewValley.Locations.IslandEast | Ginger Island jungle, where Leo's hut is. |
| IslandWest | StardewValley.Locations.IslandWest | Ginger Island, Island West, where the farm and Birdie's Shack are. |
| IslandNorth | StardewValley.Locations.IslandNorth | Ginger Island, Island North, where the volcano and Professor Snail's tent are. |
| IslandHut | StardewValley.Locations.IslandHut | The interior of Leo's hut on Ginger Island. |
| IslandWestCave1 | StardewValley.Locations.IslandWestCave1 | The Ginger Island cave where the colored crystals puzzle can be found. |
| IslandNorthCave1 | StardewValley.Locations.IslandLocation | The mushroom cave on Ginger Island where Professor Snail is initially blocked in by a boulder. |
| IslandFieldOffice | StardewValley.Locations.IslandFieldOffice | The interior of Professor Snail's Island Field Office tent. |
| IslandFarmHouse | StardewValley.Locations.IslandFarmHouse | The interior of the farm house on Ginger Island. |
| CaptainRoom | StardewValley.Locations.IslandLocation | The interior of the shipwreck on Ginger Island West. |
| IslandShrine | StardewValley.Locations.IslandShrine | The area East of the jungle on Ginger Island. |
| IslandFarmCave | StardewValley.Locations.IslandFarmCave | The interior of Gourmand Frog's cave on Ginger Island. |
| Caldera | StardewValley.Locations.Caldera | The volcano caldera on Ginger Island at the end of the volcano dungeon. |
| LeoTreeHouse | StardewValley.GameLocation | Leo's tree house home. |
| QiNutRoom | StardewValley.Locations.IslandLocation | Mr. Qi's Walnut Room |