Adding jobs

We can create our own jobs / classes and alter the existing promotion tree to suit our preferences.

Creating a new job

These are generic steps for creating a new job:

  1. Copy an existing job from the stonehearth mod. Preferably one that is most close in functionality to what you're creating. The existing jobs are inside the stonehearth/jobs directory.

  2. Rename the files as usual.

  3. Add an alias for your custom job in your manifest, pointing to the JSON file that contains the description of the job.

  4. Add an alias in the "controllers" section of your manifest, pointing to the Lua file of your job. E.g.:

    "controllers": {
       "class:lamplighter": "file(jobs/lamplighter/lamplighter.lua)"
    }
    
  5. Add a mixinto to "stonehearth:jobs:index" to add your custom job to the list of available jobs.

  6. Start by editing the talisman. Change the model as appropiate and edit the corresponding JSON files to point to those of your custom job.

  7. Edit the job description JSON file. The data inside this file will vary depending on the job type (crafting / combat / etc). You'll need to add more aliases to your manifest, at least for the talisman, outfit, and tool / weapon.

  8. Edit the rest of the models, UI and JSON files (the outfit, tool, workshop skin, etc.). These files may vary depending on the job type. There may also be Lua files involved, make sure to rename text as needed.

The talisman

Each job in stonehearth (except for Worker, which is the base job) makes use of an item we call talisman in order to unlock the job and promote the hearthling. Once promoted, the talisman is consumed and it's replaced by an equippable version of it (an actual tool / weapon), which the hearthling makes use of when they're doing their job or when they're fighting.

Normally we name the related files with the job name plus the name of the tool itself, for example farmer_hoe.json, farmer_hoe_talisman.json, farmer_hoe_iconic.json.

Job description

These are the common fields that we can have for all jobs in their description JSON file:

About job perks

The way job perks from the job_description.json file work is:

icon You'll also see that many jobs at level 6 will get a title instead of / in addition to perks, which allows us to know that they're at the maximum level in the UI. This title is outside of the "perks" array. Nowadays it's not needed, all hearthlings will get a title that will be shown in the character sheet and will change as they level up (Apprentice, Journeyman, Master).

On top of the perks, hearthlings will gain +10 health points every time they level up. These will carry on after promoting / demoting. Job experience is reset when you promote / demote a hearthling, to encourage specialization.

About job progression

In the job component inside the base_human.json mixin we can find info that is common for all jobs:

  "stonehearth:job": {
     "starting_level_title": "i18n(stonehearth:stonehearth_mixins.base_human.job.starting_level_title)",
     "mid_level_title": "i18n(stonehearth:stonehearth_mixins.base_human.job.mid_level_title)",
     "max_level_title": "i18n(stonehearth:stonehearth_mixins.base_human.job.max_level_title)",
     "default_level_title": "i18n(stonehearth:stonehearth_mixins.base_human.job.default_level_title)",
     "default_level_announcement": "i18n(stonehearth:stonehearth_mixins.base_human.job.default_level_announcement)",
     "default_promote_announcement": "i18n(stonehearth:stonehearth_mixins.base_human.job.default_promote_announcement)",
     "xp_equation_for_next_level": "curr_level * 115 + 135",
     "levels_between_attribute_increase": 10,
     "level_up_data": {
        "level_up_perk_description": "i18n(stonehearth:stonehearth_mixins.base_human.job.level_up_perk_description)",
        "level_up_perk_icon": "/stonehearth/data/images/race/human_HP_on_level.png"
     }
  }

We can customize these fields via mixintos. For example, we have the titles based on level (Apprentice, Journeyman, Master), and the equation that is used to calculate the amount of experience required to get to the next level. Mind that not all of these fields are in use nowadays.

Creating other types of jobs

You can create other types of jobs as long as they inherit from base_job.lua. For example, in the game we have the producers (farmer, trapper and shepherd) whose job is based on using zones.

But you don't need to use zones if you don't want to. Just with custom AI should be enough. For instance, in the vanilla game, some crafters have other responsibilities (the herbalist heals, the cook farms, the engineer repairs turrets), they're not exclusively dedicated to crafting. And workers aren't a combat nor a crafting job.