Other effects

There are some types of effects we haven't talked about yet.

Sound effects

Sound effects in Stonehearth are in .ogg format (to save in filesize).

We can play sounds in Lua (by running the effect they're in) or through Javascript (for example, when we buy something in a shop via the UI). For how to play music and ambient sounds, check this page.

Effects can also have a sound track besides light, animations, or particles. An example sound track for the effect JSON file looks like this:

  "sound": {
     "type": "sound_effect",
     "start_time": 150,
     "min_distance": 27,
     "falloff" : 5,
     "volume": 60,
     "track" : "stonehearth:sounds:death_poof"
  }

These are the fields for the effect file:

Playing sounds in the UI

This is the syntax for playing sounds in Javascript files:

  radiant.call('radiant:play_sound', {'track' : 'stonehearth:sounds:ui:start_menu:shop_buy'} )

We call the 'radiant:play_sound' function and pass an object that contains the URI of the track that we want to play.

Unit status effects

The bubbles that appear on top of hearthlings when they talk, or the heart that appears when a hearthling loses health are unit status effects.

unit_status_effects

They are achieved by attaching an image that always faces the camera to a bone from the hearthling's rig (or to a certain distance from the center of any entity).

This is an effect track for a unit status effect:

  "unit_status_effect": {
     "type": "unit_status_effect",
     "material": {
        "name": "materials/billboard.material.json",
        "samplers": [
           {
              "name": "albedoMap",
              "map": "materials/thoughts/health/dead/dead_.png",
              "numAnimationFrames": 25,
              "frameRate": 20
           }
        ]
     },
     "width": 2,
     "height": 3.4,
     "xOffset": 0,
     "yOffset": 1.6,
     "duration": 990,
     "bone": "head"
  }

We can see the following properties:

The following fields are only used in stonehearth/data/effects/thoughts/thought_bubble_base.json, but you can use them too for your effect if you want:

You can find more examples of unit status effects in stonehearth/data/effects, although the effects there are mixed. There's also some unit status effects that have an animation track, those are under the stonehearth/data/rigs folder, but finding them is harder.

Activity overlay effects

The toast that appears hovering above an entity when we mark it for harvesting, looting, etc. is an activity overlay effect.

activity_overlay_effects

This is mostly used for non-animated entities. Example of an activity overlay track:

  "activity_overlay_effect": {
     "type" : "activity_overlay_effect",
     "material" : {
        "name": "materials/overlay.material.json",
        "samplers" : [
           {
              "name" : "foregroundMap",
              "map": "materials/harvest_plant_overlay/harvest.png"
           },
           {
              "name" : "albedoMap",
              "map": "materials/thoughts/default_overlay.png"
           }
        ]
     },
     "y_offset" : -10
 }

These are the fields that we can find in an activity overlay effect track:

Trigger effects

In a previous section we talked about some syntax for the attach item track that can only be seen for the promote effect, and it's dependent on the AI action. The promote effect also has several "trigger_effect" tracks, which aren't used anywhere else in the code (likely because we can trigger and listen to events more easily from Lua). This effect has animation, sound and cubemitter tracks, besides several trigger effect tracks.

You'll rarely want to use this, since there might be easier/other ways to do this, but here's the example:

  "promote_trigger" : {
     "type": "trigger_effect",
     "start_frame": 145,
     "info": {
        "event": "change_outfit",
        "talisman": "{{talisman}}"
     }
  }

The properties are:

Creating other effects with SHED

We already mentioned one way to create effects with SHED. There's another option: go to the Effects Editor, find a similar effect than what you want to create in the 'Effects' tab. Right click on it, click on 'Clone', change the target mod to your mod and provide a replacement name.

cloning_effect_from_effects_tab

Then confirm, and the tree view will refresh to add your effect. Edit it since the replacement texts might be pointing to unexisting files and change the rest of properties to what you want to.

With this method you will need to add an alias for the effect separately, but you can do so in the Manifest view: right click in your mod's name, click on 'Add New Alias', select the file that was created, and then a popup will appear for you to edit the alias.

With the other method the alias will be generated when cloning the effect file, so it might be faster. You'll need to create any additional files separately, or reuse some from the stonehearth mod.