Modding:Basic Entity/ru: Difference between revisions

From Vintage Story Wiki
(Created page with "=== Общее ===")
No edit summary
Tag: Manual revert
 
(15 intermediate revisions by 3 users not shown)
Line 2: Line 2:


{{GameVersion|uknown}}
{{GameVersion|uknown}}
<languages/>Мы настоятельно рекомендуем сначала прочитать руководство [[Getting Started with Advanced Modding/ru|Начало работы]]. В этом руководстве будут рассмотрены основы добавления объекта в игру с использованием файлов JSON. Существует полный список всех свойств, которые можно определить в файле json [[Entity Json Properties/ru|здесь]].
<languages/>Мы настоятельно рекомендуем сначала прочитать про [[Modding:Asset_System/ru#Домены|домены]]. В этом руководстве будут рассмотрены основы добавления объекта в игру с использованием файлов JSON. Существует полный список всех свойств, которые можно определить в файле json {{ll|Modding:Entity Json Properties|здесь}}.


= Маленькая фигурка =
= Маленькая фигурка =
Line 12: Line 12:
=== Общее ===
=== Общее ===


So first of all we have to create the entity type file <code>assets/figure/entities/land/littlefigure.json</code>. Now we go through all the properties:
Итак, прежде всего нам нужно создать файл типа сущности <code>assets/figure/entities/land/littlefigure.json</code>. Теперь проходим по всем свойствам:


<code>code</code>: The unique identifier for your entity. A prefix of your mod id will be added automatically. Our case its <code>figure:littlefigure</code>.
<code>code</code>: Уникальный идентификатор вашего объекта. Префикс идентификатора вашего мода будет добавлен автоматически. В нашем случае это <code>figure:littlefigure</code>.


<code>class</code>: The class of the entity, it can be used to program special features for it. We don't need it at the moment, so we set it to <code>EntityAgent</code>.
<code>class</code>: класс объекта, который можно использовать для программирования специальных функций. В данный момент он нам не нужен, поэтому мы установили его в <code>EntityAgent</code>.


<code>hitboxSize</code>: The size of the hitbox.
<code>hitboxSize</code>: размер хитбокса.


<syntaxhighlight lang="json">
<syntaxhighlight lang="json">
Line 27: Line 27:
</syntaxhighlight>
</syntaxhighlight>


<code>deadHitboxSize</code>: The size of the hitbox when the entity has died.
<code>deadHitboxSize</code>: размер хитбокса после смерти объекта.
<syntaxhighlight lang="json">
<syntaxhighlight lang="json">
   "deadHitboxSize": {
   "deadHitboxSize": {
Line 35: Line 35:
</syntaxhighlight>
</syntaxhighlight>


<code>eyeHeight</code>: The height of the eyes, which is <code>0.4</code> for the little figure.
<code>eyeHeight</code>: высота глаз, которая составляет <code>0,4</code> для маленькой фигурки.


<code>drops</code>: A list of items to be dropped (can also include chances). We leave it empty for now: <code>[]</code>.
<code>drops</code>: список выпадающих предметов (также может включать шансы). Пока оставляем его пустым: <code>[]</code>.


<code>sounds</code>: Set the sounds for the entity
<code>sounds</code>: Установить звуки для объекта
<syntaxhighlight lang="json">
<syntaxhighlight lang="json">
     "hurt": "creature/figure-hurt",
     "hurt": "creature/figure-hurt",
Line 46: Line 46:
</syntaxhighlight>
</syntaxhighlight>


=== Client ===
=== Клиент ===


The client type has different properties for client and server. This will cover the client side (rendering, shape, texture)
Тип клиента имеет разные свойства для клиента и сервера. Это будет охватывать клиентскую сторону (рендеринг, форма, текстура)


(please note that // comments are actually not a valid json syntax, so if you want to use this json code in your projects, you'd have to remove these first)
(обратите внимание, что // комментарии на самом деле не являются допустимым синтаксисом json, поэтому, если вы хотите использовать этот код json в своих проектах, вам придется сначала удалить их)
<syntaxhighlight lang="c#">
<syntaxhighlight lang="c#">
   "client": {
   "client": {

Latest revision as of 12:13, 5 December 2023


Эта страница проверялась в последний раз для версии Vintage Story uknown.

Other languages:

Мы настоятельно рекомендуем сначала прочитать про домены. В этом руководстве будут рассмотрены основы добавления объекта в игру с использованием файлов JSON. Существует полный список всех свойств, которые можно определить в файле json здесь .

Маленькая фигурка

Идея состоит в том, чтобы создать маленькую пассивную фигурку из дерева. Модификация нашего мода будет figure.

Тип сущности

Общее

Итак, прежде всего нам нужно создать файл типа сущности assets/figure/entities/land/littlefigure.json. Теперь проходим по всем свойствам:

code: Уникальный идентификатор вашего объекта. Префикс идентификатора вашего мода будет добавлен автоматически. В нашем случае это figure:littlefigure.

class: класс объекта, который можно использовать для программирования специальных функций. В данный момент он нам не нужен, поэтому мы установили его в EntityAgent.

hitboxSize: размер хитбокса.

  "hitboxSize": {
    "x": 0.4,
    "y": 0.5
  },

deadHitboxSize: размер хитбокса после смерти объекта.

  "deadHitboxSize": {
    "x": 0.4,
    "y": 0.5
  },

eyeHeight: высота глаз, которая составляет 0,4 для маленькой фигурки.

drops: список выпадающих предметов (также может включать шансы). Пока оставляем его пустым: [].

sounds: Установить звуки для объекта

    "hurt": "creature/figure-hurt",
    "death": "creature/figure-death",
    "idle": "creature/figure-idle"

Клиент

Тип клиента имеет разные свойства для клиента и сервера. Это будет охватывать клиентскую сторону (рендеринг, форма, текстура)

(обратите внимание, что // комментарии на самом деле не являются допустимым синтаксисом json, поэтому, если вы хотите использовать этот код json в своих проектах, вам придется сначала удалить их)

  "client": {
    "renderer": "Shape", // How the entity will be rendered, "Shape" is the right one in almost all cases.
    "shape": { "base": "entity/land/littlefigure" }, // a path to our shape
    "texture": { "base": "game:block/wood/planks/birch1" }, // the figure should have the texture of birch wood. Therefore the prefix "game" is needed
    "behaviors": [
      { "code": "repulseagents" },
      {
        "code": "controlledphysics", // Adds physics to the entity
        "stepHeight": 0.2
      },
      {
        "code": "floatupwhenstuck", // Fixes corpse get stuck in ground
        "onlyWhenDead": true
      },
      { "code": "interpolateposition" } // Smooths out movement of entity
    ],
    "animations": [ // Animations which have to be implemented by the shape as well
      {
        "code": "hurt",
        "animation": "hurt",
        "animationSpeed": 2.2,
        "weight": 10,
        "blendMode": "AddAverage"
      },
      {
        "code": "die",
        "animation": "die",
        "animationSpeed": 1.25,
        "weight": 10,
        "blendMode": "AddAverage"
      }
    ]
  },

Server

The server side handles the "brain" of the entity.

  "server": {
    "behaviors": [
      { "code": "repulseagents" },
      {
        "code": "controlledphysics", // Adds physic interaction
        "stepHeight": 0.2
      },
      {
        "code": "health", // Adds a health bar to the entity
        "currenthealth": 4,
        "maxhealth": 4
      },
      {
        "code": "deaddecay", // Makes the dead entity stay for one hour
        "hoursToDecay": 1
      },
      {
        "code": "floatupwhenstuck", // Fixes corpse get stuck in ground
        "onlyWhenDead": true
      },
      {
        "code": "despawn", // Makes the entity despawn if there is no player within 48 blocks
        "minPlayerDistance": 48,
        "minSeconds": 5
      },
      {
        "code": "emotionstates", // Adds different emotion states
        "states": [
          {
            "code": "fleeondamage", // After the entity is hit it will try to flee for 10 seconds
            "duration": 10,
            "chance": 0.2,
            "slot": 0,
            "priority": 1,
            "accumType": "max"
          }
        ]
      },
      {
        "code": "taskai", // Handles what the entity does, a task will be processed one at a time
        "aitasks": [
          {
            "code": "idle", // the figure will stand still and think
            "priority": 1.2,
            "priorityForCancel": 1.35,
            "minduration": 4000,
            "maxduration": 6000,
            "chance": 0.001,
            "initialMinCoolDown": 2000,
            "initialMaxCoolDown": 150000,
            "mincooldown": 300000,
            "maxcooldown": 10000000,
            "animation": "think",
            "animationSpeed": 1.25
          },
          {
            "code": "wander", // The entity will walk around
            "priority": 1.0,
            "movespeed": 0.008,
            "animationSpeed": 1.6,
            "animation": "run",
            "preferredLightLevel": 15
          },
          {
            "code": "lookaround", // The entity will look around
            "priority": 0.5
          }
        ]
      }
    ]
  },

Result

If we put everything together it should look like this:

{
  "code": "littlefigure",
  "class": "EntityAgent",
  "hitboxSize": {
    "x": 0.4,
    "y": 0.5
  },
  "deadHitboxSize": {
    "x": 0.4,
    "y": 0.5
  },
  "eyeHeight": 0.4,
  "drops": [],
  "client": {
    "renderer": "Shape",
    "shape": { "base": "entity/land/littlefigure" },
    "texture": { "base": "game:block/wood/planks/birch1" },
    "behaviors": [
      { "code": "repulseagents" },
      {
        "code": "controlledphysics",
        "stepHeight": 0.2
      },
      {
        "code": "floatupwhenstuck",
        "onlyWhenDead": true
      },
      { "code": "interpolateposition" }
    ],
    "animations": [
      {
        "code": "hurt",
        "animation": "hurt",
        "animationSpeed": 2.2,
        "weight": 10,
        "blendMode": "AddAverage"
      },
      {
        "code": "die",
        "animation": "die",
        "animationSpeed": 1.25,
        "weight": 10,
        "blendMode": "AddAverage"
      }
    ]
  },
  "server": {
    "behaviors": [
      { "code": "repulseagents" },
      {
        "code": "controlledphysics",
        "stepHeight": 0.2
      },
      {
        "code": "health",
        "currenthealth": 4,
        "maxhealth": 4
      },
      {
        "code": "deaddecay",
        "hoursToDecay": 1
      },
      {
        "code": "floatupwhenstuck",
        "onlyWhenDead": true
      },
      {
        "code": "despawn",
        "minPlayerDistance": 48,
        "minSeconds": 5
      },
      {
        "code": "emotionstates",
        "states": [
          {
            "code": "fleeondamage",
            "duration": 10,
            "chance": 0.2,
            "slot": 0,
            "priority": 1,
            "accumType": "max"
          }
        ]
      },
      {
        "code": "taskai",
        "aitasks": [
          {
            "code": "idle",
            "priority": 1.2,
            "priorityForCancel": 1.35,
            "minduration": 4000,
            "maxduration": 6000,
            "chance": 0.001,
            "initialMinCoolDown": 2000,
            "initialMaxCoolDown": 150000,
            "mincooldown": 300000,
            "maxcooldown": 10000000,
            "animation": "think",
            "animationSpeed": 1.25
          },
          {
            "code": "wander",
            "priority": 1.0,
            "movespeed": 0.008,
            "animationSpeed": 1.6,
            "animation": "run",
            "preferredLightLevel": 15
          },
          {
            "code": "lookaround",
            "priority": 0.5
          }
        ]
      }
    ]
  },
  "sounds": {
    "hurt": "creature/figure-hurt",
    "death": "creature/figure-death",
    "idle": "creature/figure-idle"
  }
}

Shape

If you want to know how to create the shape for the entity I suggest you checkout VS Model Creator.

Item

In order to spawn the entity we can create an item to do so:

{
  "code": "creature",
  "class": "ItemCreature",
  "maxstacksize": 64,
  "variantgroups": [
    {
      "code": "type",
      "states": [ "littlefigure" ]
    }
  ],
  "shape": {
    "base": "figure:entity/land/littlefigure"
  },
  "texture": { "base": "game:block/wood/planks/birch1" },
  "creativeinventory": {
    "general": [ "*" ],
    "items": [ "*" ],
    "creatures": [ "*" ]
  },
  "materialDensity": 600,
  "guiTransform": {
    "rotation": {
      "x": 0,
      "y": -90,
      "z": -180
    },
    "origin": {
      "x": 0.5,
      "y": 0.15,
      "z": 0.5
    },
    "scale": 6
  },
  "fpHandTransform": {
    "rotation": {
      "x": 0,
      "y": -90,
      "z": 0
    },
    "origin": {
      "x": 0.5,
      "y": 0.15,
      "z": 0.5
    },
    "scale": 6
  },
  "groundTransform": {
    "translation": {
      "x": 0,
      "y": 0.15,
      "z": 0
    },
    "rotation": {
      "x": 0,
      "y": -90,
      "z": 0
    },
    "origin": {
      "x": 0.5,
      "y": 0.15,
      "z": 0.5
    },
    "scale": 6
  }
}

Testing/ Distribution

Download Figure v1.0.0 for VintageStory 1.8


Icon Sign.png

Wondering where some links have gone?
The modding navbox is going through some changes! Check out Navigation Box Updates for more info and help finding specific pages.

Modding
Modding Introduction Getting Started Пакет тем
Content Modding Content Mods Developing a Content Mod Basic Tutorials Intermediate Tutorials Advanced Tutorials Content Mod Concepts
Code Modding Code Mods Setting up your Development Environment
Property Overview ItemEntityBlockBlock BehaviorsBlock ClassesBlock EntitiesBlock Entity BehaviorsWorld properties
Workflows & Infrastructure Modding Efficiency TipsMod-engine compatibilityMod ExtensibilityVS Engine
Additional Resources Community Resources Modding API Updates Programming Languages List of server commandsList of client commandsClient startup parametersServer startup parameters
Example ModsAPI DocsGitHub Repository