Modding:Entity Behaviors: Difference between revisions

From Vintage Story Wiki
(Copy some of the behaviors from the entity properties page)
Line 140: Line 140:
* stepHeight = 0.6
* stepHeight = 0.6
| Universal
| Universal
|-
| [[Modding:Entity_Behavior_taskai|taskai]]
| Allows you to specify tasks.
|
* most entities
|
* aitasks
| server
|}
|}

Revision as of 01:37, 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
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
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