Table of Contents

Class EntityBehaviorMultiply

Namespace
Vintagestory.GameContent
Assembly
VSEssentials.dll

Allows an entity to get pregnant and give birth.
Uses the "multiply" code Open in GitHub

[DocumentAsJson]
[AddDocumentationProperty("spawnEntityCode", "Used instead of spawnEntityCodes if the latter is not defined", "System.String", "Optional", "", false)]
public class EntityBehaviorMultiply : EntityBehaviorMultiplyBase
Inheritance
EntityBehaviorMultiply
Inherited Members

Examples

"behaviors": [
 {
     "code": "multiply",
     "enabledByType": {
         "*-female": true,
         "*": false
     },
     "spawnEntityCodes": [{ "code": "sheep-{type}-baby-male" }, { "code": "sheep-{type}-baby-female" }],
     "requiresNearbyEntityCode": "sheep-bighorn-adult-male",
     "requiresNearbyEntityRange": 10,
     "spawnQuantityMin": 1,
     "spawnQuantityMax": 1,
     "pregnancyDays": 20,
     "multiplyCooldownDaysMin": 4,
     "multiplyCooldownDaysMax": 11,
     "portionsEatenForMultiply": 10
 },
],

Fields

SpawnEntityCodes (Required)

The entity codes used to spawn the offspring

[DocumentAsJson("Required", "", false)]
protected AssetLocation[]? SpawnEntityCodes

Field Value

AssetLocation[]

CrowdingDistanceChecks (Optional) (Default: [4, 8])

Check these distances to see if there are too many entities nearby. All these checks must pass or the conditions are considered crowded. For example, [4, 8] will check for entities 4 blocks away and 8 blocks away, taxicab distance. The first check fails if there are more than (4 * 2)^2 / SquareMetersPerEntity animals nearby.

[DocumentAsJson("Optional", "[4, 8]", false)]
[JsonProperty]
public float[] CrowdingDistanceChecks { get; set; }

Field Value

float[]

CrowdingTags (Optional) (Default: ["animal"])

Entities with any of these tags count towards the density.

[DocumentAsJson("Optional", "[\"animal\"]", false)]
public TagSetFast CrowdingTags

Field Value

TagSetFast

MiscarriageChance (Optional) (Default: 0)

Fraction of embryos considered non-viable, randomly determined (a second check after gene viability)

[DocumentAsJson("Optional", "0", false)]
[JsonProperty]
protected double MiscarriageChance

Field Value

double

MiscarriageCooldown (Optional) (Default: 0.5)

After a miscarriage (either random or genetic), wait this long as a fraction of the normal multiply cooldown before being ready to mate again

[DocumentAsJson("Optional", "0.5", false)]
[JsonProperty]
protected double MiscarriageCooldown

Field Value

double

PregnancyDays (Optional) (Default: 3)

How long the pregnancy should last in in-game days.

[DocumentAsJson("Optional", "3", false)]
[JsonProperty]
public double PregnancyDays

Field Value

double

PregnancyLengthVariation (Optional) (Default: 0.04)

Pregnancy length will vary by plus or minus this fraction of the total length

[DocumentAsJson("Optional", "0.04", false)]
[JsonProperty]
protected double PregnancyLengthVariation

Field Value

double

requiresNearbyEntityCode (Optional)

Specifies an entity required for this entity to be able to get pregnant. Will only set if plural version is not set.

[DocumentAsJson("Optional", "", false)]
[JsonProperty]
private AssetLocation requiresNearbyEntityCode { set; }

Field Value

AssetLocation

RequiresNearbyEntityCodes (Optional)

Specifies an list of entities required nearby for this entity to be able to get pregnant. Only one needs to match.

[DocumentAsJson("Optional", "", false)]
[JsonProperty]
public AssetLocation[]? RequiresNearbyEntityCodes

Field Value

AssetLocation[]

RequiresNearbyEntityRange (Optional) (Default: 5)

Specifies the range within which the entity with code defined in RequiresNearbyEntityCode should be located in order for this entity to be able to get pregnant

[DocumentAsJson("Optional", "5", false)]
[JsonProperty]
public float RequiresNearbyEntityRange

Field Value

float

spawnEntityCode (Optional)

Used instead of spawnEntityCodes if the latter is not defined

Field Value

String

SpawnQuantityChance (Optional) (Default: 0.5)

For each offspring between the min and the max, this is the chance of spawning. This makes the litter size a bell curve instead of a uniform.

[DocumentAsJson("Optional", "0.5", false)]
[JsonProperty]
public float SpawnQuantityChance

Field Value

float

SpawnQuantityMax (Optional) (Default: 2)

How many offspring should be spawned at maximum

[DocumentAsJson("Optional", "2", false)]
[JsonProperty]
public float SpawnQuantityMax

Field Value

float

SpawnQuantityMin (Optional) (Default: 1)

How many offspring should be spawned at minimum

[DocumentAsJson("Optional", "1", false)]
[JsonProperty]
public float SpawnQuantityMin

Field Value

float

SquareMetersPerEntity (Optional) (Default: 8)

At what density do they stop breeding

[DocumentAsJson("Optional", "8", false)]
[JsonProperty]
public float SquareMetersPerEntity { get; set; }

Field Value

float

ViabilityCheckDelay (Optional) (Default: 0.125)

Wait this long (as a fraction of the total pregnancy length) before discarding non-viable embryos

[DocumentAsJson("Optional", "0.125", false)]
[JsonProperty]
protected double ViabilityCheckDelay

Field Value

double