Entity spawning

From Vintage Story Wiki

This page was last verified for Vintage Story version 1.19.8.


UnderCon icon.png

This page is under construction.
This page is being created, or is in the process of extensive expansion or major restructuring. Until this notice is removed, please do not translate this page. Expect the content of this page to change significantly.


Entities such as wolves and butterflies have fairly complex conditions for when and where to spawn.

WorldGen spawn conditions[1]

Entity data

Each entity has spawn conditions detailed in a document you can access on your computer. By default, the files are installed to %AppData%\Roaming\Vintagestory\assets\survival\entities. The file type is .json and Notepad++ is one example of a free program that can read and edit this file type.

JSON

JSON is a text format for storing and transporting data. While it's not necessary to study JSON to glean useful information from .json files, it may be beneficial to outline a few basic terms to be used throughout this article.

JSON syntax is derived from JavaScript object notation syntax. The JSON syntax is a subset of the JavaScript syntax. Basic rules:

  • Data is in name/value pairs
  • Data is separated by commas
  • Curly braces {} hold objects
  • Square brackets [] hold arrays

A name/value pair consists of a field name (in double quotes), followed by a colon, followed by a value. Example: "name":"John". This might not matter much when reading, but any edits must be careful about punctuation.

The musk ox entity belongs[2] to the same biological "family"[3] as goats, and its characteristics are defined in the goat.json file.

Within goat.json we can see 11 species of goat defined, as distinct "types." Later, when the file assigns properties "ByType" it will be to one or more of these 11 types. Asterisks serve as wildcards: *-adult-* refers to an adult of any species in this file, while *-muskox-* refers to an ox of any age/gender.

	"variantgroups": [
		{ "code": "type", "states": ["angora", "ibexalp", "ibexnub", "markhor", "mountain", "muskox", "nubian", "sirohi", "takingold", "turdag", "valais" ] },
		{ "code": "gender", "states": ["male", "female"] },
		{ "code": "age", "states": ["adult", "baby"] }
	],

Ctrl+F lets you search within a document for a specific word. A search within goat.json for "spawnconditions" yields a fairly lengthy entry with two main sections: "worldgen" and "runtime".

  • Worldgen: creatures spawn as you explore the undiscovered areas of the map
  • Runtime: creatures spawn in your vicinity (loaded chunks) and may have a check of distance to player

If you scroll down within goat.json, there's a "spawnconditionsByType" entry that breaks down the climate preferences for each species.

"goat-muskox-*-adult": {
	"climate": {
		"minTemp": -30,
		"maxTemp": -10,
		"minRain": 0.0,
		"maxRain": 0.8,
		"minForestOrShrubs": 0.0,
		"maxForest": 0.4,
		"maxShrubs": 0.8,
		"minY": 0.9,
		"maxY": 1.2					
	},
	"worldgen": {
		"triesPerChunk": { "avg": 0.003, "var": 0 }
	},
	"runtime": {
		"maxQuantityByGroup": { "code": "goat-*", "maxQuantity": 4 }
	}
},

Climate conditions

Using the command /wgen pos climate in the chat box will display the climate characteristics at that position.

Temperature

The minTemp and maxTemp for an entity's spawn conditions refer to annual average temperature. With C the player can view the current temperature, but that's not particularly useful for determining whether a location is a valid spawn for a particular entity. Instead, check /wgen pos climate.

"goat-muskox-*-adult": {

...

"minTemp": -30, "maxTemp": -10,

},

Musk ox can spawn in areas where the annual average temperature is no lower than -30°C but no higher than -10°C (and where other spawn conditions are met). Comparing with the table below, they can't be found in default Temperate climates.

Climate band average temperatures
Starting climate Annual average
Hot 28 to 32°C
Warm 19 to 23 °C
Temperate 6 to 14 °C
Cool -5 to 1 °C
Icy -15 to -10°C

Rainfall

The minRain and maxRain for an entity's spawn conditions refer to annual average precipitation. With C the player can view the average rainfall of a location, but with a descriptive term that's not particularly useful for determining whether a location is a valid spawn for a particular entity. Instead, check /wgen pos climate.

"goat-muskox-*-adult": {

...

"minRain": 0.0, "maxRain": 0.8,

},

Musk ox can spawn in areas where the annual average rainfall is no lower than 0 but no higher than 0.8 (and where other spawn conditions are met).

Character panel average rainfall
Character panel descriptor Annual average rainfall
Almost all the time 0.90 - 1.0
Very Common 0.70 - 0.90
Common 0.45 - 0.70
Uncommon 0.30 - 0.45
Rarely 0.15 - 0.30
Very Rare 0 - 0.15

Forestation

Forestation parameters are a regional average. "It doesn't mean that a deer for example has to spawn in a place where there are trees overhead. More like, deer will spawn in places where trees are more likely." --radfast

"goat-muskox-*-adult": {

...

"minForestOrShrubs": 0.0, "maxForest": 0.4,

},

Musk ox can spawn in areas where the average "forestation" is no lower than 0 but no higher than 0.4 (and where other spawn conditions are met).

Shrub

"goat-muskox-*-adult": {

...

"minForestOrShrubs": 0.0, "maxShrubs": 0.8,

},

Musk ox can spawn in areas where the average "shrub" level is no lower than 0 but no higher than 0.8 (and where other spawn conditions are met).

Elevation

Value Significance
1.0 to 2.0 from sea level (1.0) to the top of the world (2.0)
0.0 to 1.0 from the bottom of the world (0.0) to sea level (1.0)
"goat-muskox-*-adult": {

...

"minY": 0.9, "maxY": 1.2

},

Musk ox can spawn in areas of elevation no lower than 0.9 but no higher than 1.2 (and where other spawn conditions are met). 0.9 in a default world of height 256 would be Y 99 (110 x 0.9 = 99); 1.2 would be Y 132 (110 x 0.9 = 132). In a world with different height than default, multiply 0.9 and 1.2 by the new world height to find the Y levels for musk ox in that world.

To view your Y level, activate the coordinate HUD in the Settings menu, or with hotkey Ctrl + V.

triesPerChunk & chance

If triesPerChunk is set to 0.1 it means, on average, it will only try to spawn the entity once every 10 chunks. Runtime runs every 0.5 seconds on loaded chunks. If chance is set to 0.001, it means 0.001 is the chance it will try to spawn the entity, every 0.5 seconds.

"goat-muskox-*-adult": {

...

"triesPerChunk": { "avg": 0.003, "var": 0 }

...

"chance": 0.005,

},

When new chunks generate (where their spawn conditions are met), musk ox will attempt to spawn approximately 3 times per 1000 chunks. Thereafter, every 0.5 seconds there's the possibility of spawning another, with an average quantity of 5 musk ox per 100 seconds until the maxQuantity for the chunk has been reached.


Preventing spawns

Light

Daylight doesn't deter hares spawning, but "block light" such as lanterns and torches deter hares if bright enough:

					maxLightLevel: 8,
					lightLevelType: "onlyBlockLight",

InsideBlockCodes

Hares can spawn insideBlockCodes: ["tallgrass-*", "snowlayer-1"], so to prevent hares spawning inside a fenced area, eliminate grass (the 3D sort that grows back when trimmed) and snow on full blocks. Grass on tilled farmland does not pose the same danger.

RequireSolidGround

Hares should not be able to spawn on farmland because tilled soil is not a full block of solid ground.

Sequence

When a new chunk is discovered and begins to load, creatures are among one of the last features to be added. 93.GenCreatures.cs shows relevant details and some plain-English commentary.

Musk ox get 0.003 triesPerChunk. Bears will be significantly more common (0.015 triesPerChunk), and wolves even more so (0.07 triesPerChunk).

The file serverconfig.json includes a line that affects how many entities will spawn if there are multiple players sharing a world: "SpawnCapPlayerScaling": 0.5,

History

Notes

  • Bees are particles, not entities. Their spawn details can be found elsewhere.
  • Grasshoppers and cicadas are probably particles.
  • "Very occasionally there can be land below sea level which doesn't have water in it, e.g. cave entrances, and we still want plants and creatures to generate down there otherwise it might look weird, bare earth / no nature as soon as a cave goes below sea level. There can also be dried lake beds in deserts I think." --radfast
  • This comment appears in most entity files: "Make them spawn avoid from block light so they don't spawn inside farmland"

See also

References

  1. https://github.com/anegostudios/vsapi/blob/cad83424ee89915ef206d0b23845af0a4ef72348/Common/Entity/SpawnConditions.cs#L196
  2. "The Bovidae comprise the biological family of cloven-hoofed, ruminant mammals that includes cattle, yaks, bison, buffalo, antelopes (including goat-antelopes), sheep and goats." From Wikipedia
  3. Wikipedia


Wiki Navigation
Vintage Story Guides[[::Category:Guides| ]]Frequently Asked Questions Soundtrack Versions Controls
Game systems Crafting Knapping Clay forming Smithing Cooking Temperature Hunger Mining Temporal stability Mechanical power Trading Farming Animal husbandry
World World generation Biomes Weather Temporal storms
Items Tools Weapons Armor Clothing Bags Materials Food
Blocks Terrain Plants Decorative Lighting Functional Ore
Entities Hostile entities Animals NPCs Players
Miscellaneous List of client commands List of server commands Creative Starter Guide Bot System WorldEdit Cinematic Camera Adjustable FPS Video Recording ServerBlockTicking