Changes

Jump to navigation Jump to search
add custom location contexts + weather, fix link
Line 1,035: Line 1,035:  
* spawning them on [[Modding:Maps|map tiles]] by adding <samp>Paths</samp> index 34 to the <samp>Paths</samp> layer, with a <samp>TreeType</samp> tile property with the tree ID;
 
* spawning them on [[Modding:Maps|map tiles]] by adding <samp>Paths</samp> index 34 to the <samp>Paths</samp> layer, with a <samp>TreeType</samp> tile property with the tree ID;
 
* or giving the player a seed item in the usual ways (e.g. from [[#Custom shops|a shop]], [[Modding:Mail data|mail letter]], etc).
 
* or giving the player a seed item in the usual ways (e.g. from [[#Custom shops|a shop]], [[Modding:Mail data|mail letter]], etc).
 +
 +
===Custom location contexts===
 +
The game previously had two hardcoded location context enumms: <samp>Default</samp> (for the valley) and <samp>Island</samp> (for [[Ginger Island]]). These have been replaced with location context models which define the location context settings, and supports custom contexts defined by mods. The context for a location is set via the existing <samp>LocationContext</samp> [[Modding:Maps|map property]].
 +
 +
Custom contexts can be created by editing the new <samp>Data\LocationContexts</samp> asset. This consists of a string → model lookup, where the key is the unique context ID, and the value is a model with these fields:
 +
{| class="wikitable"
 +
|-
 +
! field
 +
! effect
 +
|-
 +
| <samp>Name</samp>
 +
| The unique ID for the location context. This should match the asset key.
 +
|-
 +
| <samp>DefaultValidPlantableLocations</samp>
 +
| ''(Optional)'' The internal names of the locations where crops can be planted and grown by default.
 +
|-
 +
| <samp>WeatherConditions</samp>
 +
| ''(Optional)'' The weather logic to apply for locations in this context (ignored if <samp>CopyWeatherFromLocation</samp> is set). Defaults to always sunny. If multiple are specified, the first matching weather is applied.
 +
 +
This consists of a list of models with these fields:
 +
{| class="wikitable"
 +
|-
 +
! field
 +
! effect
 +
|-
 +
| <samp>Weather</samp>
 +
| The [[#Custom weather|weather ID]] to set.
 +
|-
 +
| <samp>Condition</samp>
 +
| ''(Optional)'' A [[#Game state queries|game state query]] which indicates whether to apply the weather. Defaults to always applied.
 +
|}
 +
|-
 +
| <samp>CopyWeatherFromLocation</samp>
 +
| ''(Optional)'' The <samp>Name</samp> (i.e. unique ID) of the location context from which to inherit weather.
 +
|}
 +
 +
===Custom weather===
 +
You can now change the weather algorithm by editing [[#Custom location contexts|location context data]], and (with a C# mod) implement custom weathers.
 +
 +
Fields like <samp>Game1.weather</samp> and <samp>Game1.weatherForTomorrow</samp> are now strings to support custom mod weather IDs. The change for vanilla weather has no effect on Content Patcher packs, since the new weather IDs match the ones Content Patcher was using before (i.e. <samp>Sun</samp>, <samp>Rain</samp>, <samp>Snow</samp>, <samp>Storm</samp>, and <samp>Wind</samp>). C# mods may also see a <samp>Festival</samp> weather, while Content Patcher packs will see <samp>Sun</samp> for it. The constants like <samp>Game1.weather_sunny</samp> have the new string values (with new constants like <samp>Game1.legacy_weather_sunny</samp> for the legacy values).
 +
 +
The base game will treat an invalid weather as sunny. C# mods can implement custom weather effects using [[Modding:Modder Guide/APIs/Events|normal SMAPI events]] like <samp>UpdateTicked</samp>, or by [[Modding:Modder Guide/APIs/Harmony|patching]] methods like <samp>Game1.ApplyWeatherForNewDay</samp> and <samp>Game1.populateDebrisWeatherArray</samp>.
    
===String event IDs===
 
===String event IDs===
Line 1,445: Line 1,487:     
* When referencing numeric IDs, you usually just need to convert them into a string (like <code>Game1.player.hasBuff("1590166")</code> or <code>Game1.player.eventsSeen.Contains("1590166")</code>).
 
* When referencing numeric IDs, you usually just need to convert them into a string (like <code>Game1.player.hasBuff("1590166")</code> or <code>Game1.player.eventsSeen.Contains("1590166")</code>).
* When creating buffs, see [[#buff overhaul|buff overhaul]] for how to create buffs now.
+
* When creating buffs, see [[#Buff overhaul|buff overhaul]] for how to create buffs now.
    
===Building and animal changes===
 
===Building and animal changes===
translators
8,447

edits

Navigation menu