Critters and monsters

Monsters are created like any other living entity (critters, hearthlings...) but there are some extra files we'll want to create if we want to use them for encounters (raids, etc). We can find the existing populations under stonehearth/services/server/population/data.

How to create a mob

All the living entities in stonehearth have the stonehearth/mixins/mob.json mixin, either directly or via other mixins. This mixin adds some basic properties like mob/render flags, the AI component, a basic attribute/expendable resource (health), and some essential entity_data that they're going to need.

Their JSON file is of "type" : "entity". Monsters have the monster.json mixin, which has way less components and data than the base_human.json mixin used by hearthlings. Animals use the critter.json mixin instead. You can reuse these mixins for your custom entities. The monster mixin has some basic components like postures, a sight sensor, the job component, and some extra attributes and AI packs so that they can fight.

You can add whatever else you need your entities to have, just like when creating placeable objects and the like, such as the model_variants component, etc. Mind that copying an existing enemy might involve many files and take a while to fix the things that don't work, so take it easy.

Finally, make sure to add an alias for your entities in your manifest. For instance:

  "aliases" : {
     "monsters:vampires:vampire": "file(entities/monsters/vampires/vampire)",
     "monsters:vampires:vampire_female": "file(entities/monsters/vampires/vampire_female)"
  }

AI and animations

You can see how to set up the rig of your entities in the art guide. Depending on the AI actions that your critter / monster can do, you'll need different animations. If the game tries to run an AI action but can't find its related effect or animation files, an error will pop up, so that you know where is the problem.

For starters, your entities will need to have at least an idle_breath.json effect, and a run.json effect, so that they can look alive when standing and running. In the entity data you might see this section for some mobs, listing effects:

  "stonehearth:idle_effects": {
     "effects": [
        {
           "name": "idle_breathe",
           "weight": 5
        },
        {
           "name": "idle_look_around",
           "weight": 2
        },
        {
           "name": "idle_sway",
           "weight": 2
        },
        {
           "name": "emote_count",
           "weight": 0.25
        }
     ]
  }

These are effects that will be played based on a weight when the entity is idle.

If you reuse an existing rig, you will have all of its existing animations available right away. For custom rigs, it may take a while to figure out which animations do you need based on the AI actions that they can do. You can check the Lua files of the AI actions (under stonehearth/ai) from the AI packs that your entity uses and search for execute('stonehearth:run_effect'. Alternatively, copy the effects and animations of an existing monster/critter, and update them little by little.

Setting up the population file

We have to create a population file like we did to implement a new kingdom. However, we won't need as many fields since we won't be showing information about the population in the UI.

These are the fields that we'll usually have for monster populations:

icon Don't forget to add an alias for your population in your manifest! For instance:

  "aliases" : {
     "kingdoms:vampires": "file(services/server/population/data/vampire_population.json)"
  }

About monster tuning files

We can tune the attributes and other properties of a monster depending on the game difficulty and the net worth of the player's town.

This is done via monster_tuning files. You can find them under stonehearth/data/monster_tuning. These files are then used in campaigns to scale raid encounters depending on different factors.

You can compare the monster_tuning files in SHED, either look at them individually in the Manifest tab, or go to the Entity Stats Browser and select the Killable Entities tab.