Modding:Entity Behaviors: Difference between revisions

From Vintage Story Wiki
(→‎All Behaviors: copy more behaviors)
(One intermediate revision by the same user not shown)
Line 104: Line 104:
* most entities
* most entities
|
|
* stepHeight = 0.6
stepHeight = 0.6
| Universal
| Universal
|-
| [[Modding:Entity_Behavior_despawn|despawn]]
| The entity will despawn under given circumstances.
|
* most entities
|
minPlayerDistance<br/>
belowLightLevel<br/>
minSeconds = 30<br/>
| Server
|-
| [[Modding:Entity_Behavior_grow|grow]]
| The entity will grow and eventually turn into one of its adults.
|
* pig-wild-piglet
* most baby animals
|
hoursToGrow = 96<br/>
adultEntityCodes = []<br/>
| Server
|-
|-
| [[Modding:Entity_Behavior_health|health]]
| [[Modding:Entity_Behavior_health|health]]
Line 113: Line 133:
* most entities
* most entities
|  
|  
* currenthealth = 20
currenthealth = 20<br/>
* maxhealth = 20
maxhealth = 20<br/>
* basemaxhealth = 20
basemaxhealth = 20<br/>
| Server
| Server
|-
|-
Line 123: Line 143:
* player
* player
|  
|  
* currentsaturation = 1200
currentsaturation = 1200
* maxsaturation = 1200
maxsaturation = 1200
* saturationlossdelay = 60 * 24
saturationlossdelay = 60 * 24
* currentfruitLevel = 0
currentfruitLevel = 0
* currentvegetableLevel = 0
currentvegetableLevel = 0
* currentgrainLevel = 0
currentgrainLevel = 0
* currentproteinLevel = 0
currentproteinLevel = 0
* currentdairyLevel = 0
currentdairyLevel = 0
| Server
|-
| [[Modding:Entity_Behavior_interpolateposition|interpolateposition]]
| Interpolates entity position and rotate. Smooths out the animations. It's a visual effect, therefore not available on server side.
|
* most entities
|
| Client
|-
| [[Modding:Entity_Behavior_multiply|multiply]]
| A pack of wolves for example grows in size over time (new babies are born).
|
* wolf-female
* most female animals
|
pregnancyDays = 3.0<br/>
spawnEntityCode<br/>
requiresNearbyEntityCode<br/>
requiresNearbyEntityRange = 5<br/>
multiplyCooldownDaysMin = 6<br/>
multiplyCooldownDaysMax = 12<br/>
portionsEatenForMultiply = 3<br/>
spawnQuantityMin = 1<br/>
spawnQuantityMax = 2<br/>
requiresFood = true
| Server
| Server
|-
|-
Line 138: Line 183:
* player
* player
|  
|  
* stepHeight = 0.6
stepHeight = 0.6
| Universal
| Universal
|-
|-
Line 146: Line 191:
* most entities
* most entities
|  
|  
* aitasks
aitasks
| server
| server
|}
|}

Revision as of 03:19, 6 October 2024

Using Entity Behaviors

Inside the entity json file, entity behaviors can be added to the client section, server section, or both. For example, here is the controlledphysics behavior from deer.json, added to both the client and server sections. This shows the pre-1.20 style of including the behavior on both sides. Note that the properties are added directly to the behavior object, instead of in a properties object like with blocks and items. Also note that the builtin entity behavior names are all lower case, unlike block and collectible behaviors.

	client: {
        ...
		behaviors: [
            ...
			{
                code: "controlledphysics",
                "stepHeightByType": {
		    		"deer-pampas-*": 2.1251,
	    			"deer-pudu-*": 2.1251,
    				"deer-redbrocket-*": 2.1251,
				    "*": 3.1251
			    } 
            },
            ...
		],
        ...
	},
	server: {
        ...
		behaviors: [
            ...
			{
                code: "controlledphysics",
                "stepHeightByType": {
		    		"deer-pampas-*": 2.1251,
	    			"deer-pudu-*": 2.1251,
    				"deer-redbrocket-*": 2.1251,
				    "*": 3.1251
			    } 
            },
            ...
		],
        ...
	},

In 1.20, the behaviorConfigs section was added. For behaviors that added to both sections, the properties may be specified in the behaviorConfigs section to avoid duplicating the properties in both the client and server section. Here is the above example using behaviorConfigs.

	behaviorConfigs: {
		"controlledphysics": { 
			"stepHeightByType": {
				"deer-pampas-*": 2.1251,
				"deer-pudu-*": 2.1251,
				"deer-redbrocket-*": 2.1251,
				"*": 3.1251
			}
		},
        ...
	},
	client: {
        ...
		behaviors: [
            ...
			{ code: "controlledphysics" },
            ...
		],
        ...
	},
	server: {
        ...
		behaviors: [
            ...
			{ code: "controlledphysics" },
            ...
		],
        ...
	},

All Behaviors

Here is a table containing all the entity behaviors of the base game. Of course mods can, and are encouraged to add new behaviors.

Behavior Name Explanation Example entities Properties Side
breathe The entity will need to breathe and therefore suffocate in other blocks (for example sand).
  • player
  • most animals
Server
collectitems The entity collections items laying around on the ground.
  • player
  • bot
  • racoon
Server
controlledphysics Add physics to the entity.
  • most entities

stepHeight = 0.6

Universal
despawn The entity will despawn under given circumstances.
  • most entities

minPlayerDistance
belowLightLevel
minSeconds = 30

Server
grow The entity will grow and eventually turn into one of its adults.
  • pig-wild-piglet
  • most baby animals

hoursToGrow = 96
adultEntityCodes = []

Server
health Applies custom health to the entity. Means the entity can be hurt as well.
  • bear
  • most entities

currenthealth = 20
maxhealth = 20
basemaxhealth = 20

Server
hunger Adds saturation and hunger, the entity needs to eat in order to stay alive.
  • player

currentsaturation = 1200 maxsaturation = 1200 saturationlossdelay = 60 * 24 currentfruitLevel = 0 currentvegetableLevel = 0 currentgrainLevel = 0 currentproteinLevel = 0 currentdairyLevel = 0

Server
interpolateposition Interpolates entity position and rotate. Smooths out the animations. It's a visual effect, therefore not available on server side.
  • most entities
Client
multiply A pack of wolves for example grows in size over time (new babies are born).
  • wolf-female
  • most female animals

pregnancyDays = 3.0
spawnEntityCode
requiresNearbyEntityCode
requiresNearbyEntityRange = 5
multiplyCooldownDaysMin = 6
multiplyCooldownDaysMax = 12
portionsEatenForMultiply = 3
spawnQuantityMin = 1
spawnQuantityMax = 2
requiresFood = true

Server
playerphysics Makes an entity controllable by a player. Because this inherits from controlledphysics, do not add both to an entity.
  • player

stepHeight = 0.6

Universal
taskai Allows you to specify tasks.
  • most entities

aitasks

server