Guides/12

Weapon animations

Give a Fallout 4 weapon new animations, conditional variants and a model that changes with the state of the weapon, with a .bhv file.

esx behavior builds Fallout 4 behavior graphs natively. It does not use the Creation Kit, the Havok SDK or a compatibility runtime. You write one .bhv file that describes the behavior of one weapon. esx finds the graphs, folders, events and records in the game data, and makes everything else. You can replace each of its choices in the same file.

A .bhv file controls animation only: clips, playback speed, event-driven clip selection and the parts of the weapon model that show and hide. The weapon record and its data (damage, capacity, ammo, parts, recipe) are in your plugin. Make them with the record, batch or rhai commands.

Section What you get
A mod source The weapon plays your clips, with the speed that you set.
Variants A different clip when a condition is true, for example a reload clip for each count of loaded rounds.
The graph of the weapon model A part of the model changes with the state of the weapon. A revolver shows the rounds in its cylinder, and a shot hides one round.
Loops One line writes many states or variants.

What you need

  • Finished animation clips (.hkx) for the Fallout 4 skeleton. esx does not convert or export animations.
  • The plugin with your weapon record (the records plugin). The editor ID of the record is the weapon name in the .bhv file.
  • An installed Fallout 4. esx reads the vanilla graphs from Fallout4 - Animations.ba2 and the records from the load order of the records plugin.

Folder layout

MyGun/
  mygun.bhv
  mygun.lock                  # written by the first build
  animations/
    first_person/
      WPNReload.hkx
      WPNReload1.hkx
    third_person/
      WPNReload.hkx
      WPNReload1.hkx

esx looks for animations/ next to the .bhv file, not in the current directory.

In a project folder, put the source of each weapon in behavior/<name>/ and run esx build. The build makes the records plugin, builds each source on it, packs the archives and checks the release. One .bhv file is one weapon. A mod with several weapons has several .bhv files. See Several weapons in one mod.

A mod source

mod MyGun {
  plugin "MyGun.esp"
  prefix MyGun                       # starts the generated graph, variable and folder names
}

weapon MyGunWeapon like Anims44 {
  races HumanRace, PowerArmorRace    # the default
  reload {
    speed reloadSpeedMult * 1.5      # or: speed 1.5
    when ammo == 1 play WPNReload1   # the first matching line plays
    when empty play WPNReloadEmpty
  }
  equip { when IsMoving == 1 play WPNEquipWalk }
}

like Anims44 names the vanilla animation keyword to copy. The weapon gets the subgraph rules, graphs and folders of that keyword. Without other lines, the weapon moves like the vanilla .44 revolver.

Each block in the weapon block changes one action:

  • speed binds the playback speed of the action’s clips to an expression.
  • when CONDITION play CLIP adds a variant. The game plays CLIP instead of the vanilla clip when the condition is true.

Build

esx build runs the behavior build for a project folder. The commands below are the manual route for one source.

esx behavior explain reload --like Anims44
esx behavior clips mygun.bhv --plugin MyGun.esp
esx behavior build mygun.bhv --plugin MyGun.esp -o build/main

explain shows the graphs, states and clips that a vanilla action uses, and the free variant events. clips shows, for each view, the folder that supplies each animation name, and the names that no folder has. build writes a new directory with a copy of the plugin and a Meshes tree. esx writes the directory only when the full build succeeds. -o is necessary, unless you give --dry-run.

To write into a directory that exists, add --overwrite:

esx behavior build mygun.bhv --plugin MyGun.esp -o build/main --overwrite

esx then adds the new files and keeps each file that is identical. esx does not replace a file. If a file would change, the build stops, writes nothing, and lists the paths. Delete those files, or use a new directory.

Pack the Meshes files into an archive:

(cd build/main && find Meshes -type f) > build/files.txt
esx archive pack build/main --file-list build/files.txt -o "build/MyGun - Main.ba2"

Install MyGun.esp and MyGun - Main.ba2 in Data.

build also writes behavior.lock.json into the output directory. This file lists each file of the build with its SHA-256. After you pack, verify reads each file from the archives and from the Data folder that you give, and compares the hashes:

esx behavior verify build/main/behavior.lock.json --archive "build/MyGun - Main.ba2" --data build/release --fail-on-missing

The report has the counts ok, missing and mismatched, and one item for each file. With --fail-on-missing, a file that is missing or that has other bytes gives exit code 7. Without --archive and --data, verify reads the folder of the lock file. This checks the build directory.

The first build writes mygun.lock with the hash of each vanilla graph. A later build stops when the game files change. Check the source, then build with --update-lock. The lock file is next to the source. To keep it in a different location, give --lock PATH to check, plan, expand, clips and build:

esx behavior build build/source/mygun.bhv --lock mygun.lock --plugin MyGun.esp -o build/main

esx behavior expand mygun.bhv --plugin MyGun.esp prints the graph-level source that esx makes. Read it to see each choice.

Variants

A when … play line copies each state that the action enters, puts the new clip in the copy, and adds an IDLE record that selects the copy. esx tests the lines in order, and the first matching line plays.

Condition Meaning
ammo == 5 GetLoadedAmmoCount == 5. Also !=, <, <=, >, >=.
empty ammo == 0
partial ammo > 0
IsSneaking == 1 Any condition function.
HasPerk(Gunslinger01) == 1 Parameters: a number, a value name, or the editor ID of a record.
Target.GetIsID(Player) == 0 Run on Subject (the default), Target, CombatTarget or LinkedReference.

Join conditions with and and or. As in the Creation Kit, or joins a condition to the next one before and applies: a or b and c means (a or b) and c.

GetLoadedAmmoCount counts the round that the weapon fires. The first shot from a full six-round cylinder has ammo == 6. For a reload, the count is the rounds before the reload.

A variant needs an event that no other part of the game uses. esx takes a free event for you. To name the event, add send EVENT to the line. Each variant needs its own event: two lines that send one event stop the build (EVENT_REUSED).

Carrier events

The IDLE record of a variant sends an event, and the event starts the copied state. The game gives an event to a weapon graph only when the root graph of the view declares the name of the event. A new name does not get to the weapon graph. Thus esx uses names that the vanilla root graphs declare and that no other part of the game uses: no vanilla weapon graph, IDLE record, clip annotation, Papyrus script or Fallout4.exe text. These names are the carrier events.

The first-person names are testCam, testBigBoy, BodyCameraEnte, PCapEnter, PCapExit, to_PoseE and nine more. They are remains of test content in the game. A carrier name has no meaning for your weapon. For example, testBigBoy does not start a test. It only carries the selection of one variant.

In the build report, each event of lowering.variants has a carrier value:

Value Meaning
"carrier": true esx chose the event from the free vanilla events.
"carrier": false You named the event with send.

A lowering.notes line lists the carrier events of the build. esx behavior explain reload --like Anims44 lists the free events of each perspective before you build. Name an event with send when a weapon has more variants than free events, or when you want a specified name. The root graph of each view that uses the variant must declare the name (EVENT_NOT_IN_ROOT), and the weapon graph must not use it (EVENT_DECLARED).

Actions

These actions are built in:

Action Record Event Clips that a variant replaces
reload ActionReload reloadStart WPNReload
bolt ActionBoltCharge boltChargeStart WPNBoltCharge, WPNBoltChargeSighted
fire ActionFireSingle attackStart WPNFireSingleReady (and A, B), WPNFireSingleSighted
melee ActionMelee meleeAttackGun WPNMelee
equip ActionDraw weapEquip WPNEquip
unequip ActionSheath unEquip WPNUnEquip
throw ActionThrow grenadeThrowStart WPNGrenadeThrow

A variant plays one clip for all the action’s clips, or one clip for each, in order:

bolt { when empty play WPNBoltLast, WPNBoltLastSighted }

Declare other actions with an action block. Run explain with the same values first:

action fireauto {
  record ActionFireAuto            # the action record whose IDLE tree selects it
  event attackStartAuto            # the event that its default IDLE sends
  clip WPNFireAutoReady            # the clips that a variant replaces
}
esx behavior explain fireauto --like AnimsSubmachineGun --event attackStartAuto --clip WPNFireAutoReady

A block with the name of a built-in action changes only the fields that it gives:

Field Effect
state MACHINE STATE [in GRAPH] Copy only this state. Use it when esx does not find the state that you want.
speed VARIABLE The vanilla variable that binds the clips’ playback speed. A speed line in the weapon block needs it.
alias off Do not copy the other routes of the action’s event (a restart, a nested route).
idles root The first-person IDLE tree of the action is in the root graph (as for throw).

Third person

Put third-person clips with the same names in animations/third_person/. esx then changes the third-person graphs too. A view with no folders of its own keeps the vanilla animation, and a note in the build report says so:

reload: power_armor_third_person, third_person keep the vanilla animation for WPNReload1 (their folders do not have the clips)

When a view has folders of its own but not a variant’s clip, the view also keeps the vanilla animation, and esx gives a VARIANT_VIEW_SKIPPED warning. A misspelled file name is the usual cause.

When you have clips for some views only, say so with a views line in the action block:

reload {
  views first_person, power_armor_first_person
  when ammo == 5 play WPNReload1
}

The other views keep the vanilla animation. esx then gives a note for them, and no warning. Each view in the line must have the clips of each variant. Views that share a graph must be in the line together: with Anims44, first_person and power_armor_first_person share one graph. The line applies to the variants only. A speed line still applies to each view.

Some actions have no third-person state in a template. With Anims44, bolt and melee keep the vanilla animation in third person.

First person and third person use different events. esx takes up to 15 free first-person events and 9 free third-person events for each weapon. explain lists them. For more variants, name the events with send.

Animation names and folders

The game finds a clip by its file name. A clip node in a graph asks for a name, for example WPNReload. The game plays the first WPNReload.hkx in the folder list of the view. Letter case does not matter.

So each file must have the vanilla name that the template’s graph asks for: WPNEquip, WPNReload, WPNFireSingleReady and so on. A file with another name plays only when a when … play NAME line asks for it.

The folder list of a view has three parts, in this order:

  1. animations/<view>/ next to the .bhv file. esx mounts it at Actors\<prefix>\<weapon>\<View>.

  2. The folders in the animations block of the weapon:

    animations {
      first_person "Actors/MyStudio/MyGun/FirstPerson"
      third_person "Actors/MyStudio/MyGun/ThirdPerson"
    }
  3. The vanilla folders of the like keyword.

A view can take single clips from a folder, without the other files of that folder. Start the line with the view, then write clip, the clip names, from and the folder:

animations {
  first_person "Actors/MyStudio/MyGun/FirstPerson"
  first_person clip WPNIdleSighted, WPNFireSingleSighted from "Actors/MyStudio/MyGun/FirstPerson/SightsGlow"
}

esx copies each file into the folder of part 1. Thus a single clip has precedence over each listed folder. You do not have to copy the file into animations/<view>/. A clip must have one source only. A clip line and a file in animations/<view>/ with the same name stop the build.

A listed folder is relative to Meshes. Its clips come from the game data, or from a directory that you give with --asset-dir DIR. That directory has the same layout as Data, for example DIR/Meshes/Actors/MyStudio/MyGun/FirstPerson/WPNReload.hkx.

The views are first_person, third_person, power_armor_first_person and power_armor_third_person. Power-armor first person also searches the first-person folders, as the vanilla weapons do.

Clips from another mod

The Data folder of another mod can have the clips that your source names, with its own graphs and other files. --asset-dir of behavior build accepts finished clips only, so you cannot give that folder directly. plugin collect-assets with --behavior makes a folder that you can give:

esx --data '/path/to/Fallout 4/Data' plugin collect-assets build/MyGun.esp \
  --asset-dir input/donor-mod --behavior mygun.bhv \
  --exclude-archive 'Fallout4 - *' --exclude-archive 'DLC*.ba2' -o build/inputs
esx behavior build mygun.bhv --plugin build/MyGun.esp --asset-dir build/inputs -o build/main

The command collects the assets of the plugin records, and these clips of the source:

  • the clips in each listed folder, and in the subfolders that the template uses for actor types, for example Player;
  • the files of the clip NAME from lines;
  • the clips in animations/<view>/ next to the source.

It does not collect the graphs, the AnimTextData files or the other folders of that mod. The manifest of the report lists each file with its source path and, after the copy, its SHA-256. With --dry-run, esx copies nothing and gives the hash of the source clips only.

Collection is not permission. A file of another mod stays the work of its author. Make sure that you have the permission for each source in the manifest before you distribute a copy.

The graph of the weapon model

A weapon model has its own behavior graph, apart from the graphs of the actor. The vanilla Gauss rifle and the Laser musket use such a graph for their lights and their digits. An effect block in a weapon block is that graph for your weapon: one state machine whose states show and hide parts of the model.

weapon MyGun like Anims10mm {
  effect {
    state Ready   { show StatusLight }
    state Empty   { hide StatusLight }
    start Ready
    on ReloadComplete from any -> Ready
    on equip when ammo == 0 -> Empty
  }
}
Statement Meaning
state NAME A state of the graph. One state is active at a time.
state NAME { … } A state with the things that it does when it becomes active: show, hide, send. With on_exit in front, the state does the thing when it stops: on_exit hide StatusLight.
show NAME, NAME Show a node or a shape of the weapon model by its name. Quote a name with : or a space. The graph sends the event UncullBone with the name.
hide NAME, NAME Hide a node or a shape. The graph sends CullBone with the name.
send EVENT "payload" Send an event. The payload is optional.
generator CLASS "name" { member = value } The generator of the state, for example a BGSGamebryoSequenceGenerator that plays a controller sequence of the mesh. Default: a pose that changes nothing.
start NAME The state in which the graph starts. Default: the first state. The graph starts again at each equip. A holster and a draw keep the state.
on EVENT from STATE -> STATE A change of state when the graph gets the event. from any is each state.
on ACTION when CONDITION -> STATE A change of state when an action of the weapon starts and the condition is true. The action is equip, fire, reload or another action. The condition has the form of a variant: ammo == 3, empty, IsSneaking == 1, with and and or.

The graph gets each event that goes to the graphs of its actor, in first person and in third person. So an on EVENT line can name an event of a clip: WeaponFire of the fire clip, ReloadComplete of the reload clip, weaponDraw, weaponSheathe. It can also name an event of your mod that no graph of the game has. The console sends such an event with player.sae MyModEvent, and a Papyrus script or a game test can send it too.

An on ACTION when line is for a fact that no event has, for example the count of loaded rounds at a draw. The build makes an IDLE record below the action that tests the condition and sends an event of its own. The graphs of the actor treat that event as the event of the action, so the action plays as before.

The build writes the graph as an effect project of 3 files in Meshes/Effects/EffectBehaviors/<prefix><weapon>FXHKB/. esx behavior expand prints it as a graph-level effect block.

The graph, step by step

The graph is a small machine in the weapon model. The machine is in one state at a time. Each state says which parts of the model you see, and the events of the game move the machine from one state to the next. This block is a weapon with 2 rounds, whose model has the nodes Round1 and Round2:

weapon MyGun like Anims44 {
  effect {
    state Rounds2 { show Round1, Round2 }
    state Rounds1 { show Round1  hide Round2 }
    state Rounds0 { hide Round1, Round2 }
    start Rounds2
    on WeaponFire from Rounds2 -> Rounds1
    on WeaponFire from Rounds1 -> Rounds0
    on ReloadComplete from any -> Rounds2
    on equip when ammo == 1 -> Rounds1
    on equip when ammo == 0 -> Rounds0
  }
}
  1. The states. A state line is one look of the model. When the machine goes into Rounds1, the game shows Round1 and hides Round2. Write one state for each look that you want.
  2. The start state. start Rounds2 says where the machine starts. The game starts the machine again at each equip of the weapon. A holster and a draw keep the state.
  3. A shot. The fire clip of the player sends the event WeaponFire, and the machine of the weapon gets each event of the player. on WeaponFire from Rounds2 -> Rounds1 says: if the machine is in Rounds2 and this event comes, go to Rounds1. So each shot hides one round.
  4. A reload. The reload clip sends ReloadComplete at the moment the game refills the weapon. from any is each state, so the end of a reload shows the two rounds.
  5. A draw with fewer rounds. After a new equip the machine is in Rounds2, but the weapon can have 1 round, and no event of the game says the count. For the line on equip when ammo == 1 -> Rounds1, esx makes a record that the game tests at each draw. If the weapon has 1 round, the record sends an event of its own, and the machine goes to Rounds1. The draw clip plays as before. The full count needs no such line, because the machine is in Rounds2 already.
You do this The machine does this
Equip the weapon It starts in Rounds2.
Fire It gets WeaponFire, goes to Rounds1 and hides Round2.
Holster, then draw The record of the draw finds 1 round, and the machine goes to Rounds1.
Reload It gets ReloadComplete, goes to Rounds2 and shows the two rounds.

A weapon with 6 rounds has 7 states and many lines. A loop writes them: see the example with 6 rounds.

The game takes the behavior graph of the model that the weapon record names (Model\MODL). A graph link in a part mesh, for example a receiver or a barrel, does nothing. Give that model the key behavior_graph in its mesh job file:

behavior_graph = "Effects/EffectBehaviors/MyModMyGunFXHKB/MyModMyGunFX.hkx"

For a mesh that you do not make from a model file, set the path of its block with esx nif set MESH.nif 'blocks/N/BSBehaviorGraphExtraData/Behavior Graph File' PATH -o OUT.nif. esx nif show gives the block number.

The build report has the path in lowering.effect.project. behavior build gives the warning EFFECT_NOT_LINKED when it can read the model of the weapon record and the model names a different graph or no graph. esx build runs the behavior step before the assets step, so it cannot check a mesh that the same build makes.

Loops

for NAME in A..B { … } writes its block one time for each whole number from A to B. The two ends are in the range. Inside the block, {NAME} in a quoted text is the number, and the bare word NAME is the number too. {NAME+1}, {NAME-1} and {6-NAME} add and subtract, and {NAME:03} writes 3 digits. A range end can be a variable of an outer loop, also with +1 or -1. A range whose end is below its start gives no pass.

for k in 1..6 { on WeaponFire from "Rounds{k}" -> "Rounds{k-1}" }

This line is the same as six on WeaponFire lines, from Rounds1 -> Rounds0 to Rounds6 -> Rounds5. A loop works at each place of a source, also in an action block: for k in 1..5 { when ammo == k play "WPNReload{6-k}" } is five variants, from WPNReload5 with 1 round to WPNReload1 with 5 rounds.

Example: a model that shows its loaded rounds

The model has one node or one shape for each round, and the game shows as many of them as the weapon has rounds. This is the effect block of a revolver with 6 rounds, whose model has the nodes Round1 to Round6:

weapon MyRevolver like Anims44 {
  effect {
    for k in 0..6 {
      state "Rounds{k}" {
        for n in 1..k   { show "Round{n}" }
        for n in k+1..6 { hide "Round{n}" }
      }
    }
    start Rounds6
    for k in 1..6 { on WeaponFire from "Rounds{k}" -> "Rounds{k-1}" }
    on ReloadComplete from any -> Rounds6
    for k in 0..5 { on equip when ammo == k -> "Rounds{k}" }
  }
}
Lines What they do
The first loop 7 states, Rounds0 to Rounds6. The state Rounds3 shows Round1 to Round3 and hides Round4 to Round6.
start Rounds6 A weapon is full at a new equip.
on WeaponFire A shot goes to the state with one round less. The fire clip sends the event.
on ReloadComplete The end of a reload goes to the full state. The reload clip sends the event.
on equip when ammo == k A draw with fewer rounds than 6 goes to the state of that count. Only an IDLE record knows the count. The full count needs no line: the graph is in Rounds6 after a reload and at a new equip.

Add for k in 0..6 { on "MyModAmmo{k}" from any -> "Rounds{k}" } for a name that sets each count from the console or from a game test.

examples/fo4-ammo-display/ in the repository is this project: a copy of the .44 pistol with a row of six blocks above the gun. A game test showed 6, 4 and 1 blocks in first person and 2 blocks in third person.

Nodes that the clips also hide

A clip annotation CullBone.NAME or UncullBone.NAME hides or shows the node NAME of the weapon model. If the clips of your weapon do this for a node that the effect block also shows and hides, the two work against each other: the next clip shows the node again. Then name the shape below that node in show and hide. The event of a clip changes the node only, and the event of the effect block changes the object that it names, so a part is visible when the two are visible.

Limits of the action lines

The graph of a weapon model gets the events of the two views. So the event that the build makes for an on ACTION when line must be a root event that no vanilla graph uses. The vanilla root graphs have 10 such names, and each view can use 6 of them.

  • An effect block has at most 6 on ACTION when lines. More lines stop the build with CARRIER_EVENTS. A state that an event of a clip also reaches needs no such line.
  • equip is the draw from the holster. An equip while a different weapon is drawn uses a different action, so an on equip when line does not run then. The graph is in its start state after such a weapon change.
  • The first IDLE record whose conditions are true gets the action. A vanilla record that comes before the new records keeps its place: in third person, a draw while the player sneaks sends no event of an on equip when line. A variant of the same action also comes first.
  • A source with on ACTION when lines keeps the 10 names for them. Its variants take the other free names first.
  • For the example above: a reload with too few rounds in the inventory goes to Rounds6, because ReloadComplete does not say how many rounds the weapon got. The next draw corrects the state.

The build report

Use --format json to read the report. For a mod source, it has these parts:

Part Content
lowering.variants For each variant: the condition, the clips, and the event that selects it in each graph. clip_files lists the file that supplies each clip, the views that use it, its duration and its annotations.
lowering.notes The speed bindings, the views that keep the vanilla animation, the single clips of each view, and the carrier events.
lowering.selected_clips For each single clip: the view, the source file, and the path of the copy in the build.
lowering.effect For an effect block: the project file of the graph (project), its state machine (machine), the states (states, start), each event of the graph with its source (events: state, transition or action), and each IDLE record of an on ACTION when line with the event that it sends and the state that the graph enters (records).
effects Each effect project of the build: the template, the output and its 3 files.
warnings Probable mistakes, for example VARIANT_VIEW_SKIPPED and CLIP_ANNOTATION_MISSING. Text mode prints them on stderr.
attachment Messages of the IDLE step.

behavior check and behavior build read each variant clip. You do not have to run behavior clip-info on each file.

Warning Meaning
VARIANT_VIEW_SKIPPED A view has animation folders of its own, but no folder has the clip of a variant. The view keeps the vanilla animation, and the build continues. If the clip must play in that view, correct the file name: the file is NAME.hkx in animations/<view>/ or in a listed folder of the view. If you have no clip for that view, add a views line to the action block. esx then gives a note and no warning.
CLIP_ANNOTATION_MISSING A variant clip of a reload action has no ReloadComplete annotation. The clip plays, but the game does not refill the magazine. esx compares the name without letter case.
CLIP_UNREADABLE A variant clip file is not a clip that esx can read. The report has the reason in clip_files[].error.
SOUND_NOT_FOUND A clip has a SoundPlay.<editor ID> annotation, and no sound record with that editor ID is in the plugin or its masters. The game plays no sound there. The warning gives up to 3 sound records with the nearest names (sounds[].nearest), for example WPNPistolFortyFourReloadCharge for WPNPistol44magReloadCharge. Add the sound record, or rename the annotation with a sounds block.
EFFECT_NOT_LINKED The source has an effect block, and the model of the weapon record names a different behavior graph or no graph. The game then does not run the graph of the block. Set behavior_graph in the mesh job file of that model. The check runs when the build can read the model: from an --asset-dir folder or from the game.
WEAPON_BOLT_ACTION The weapon record has the Bolt Action flag, which it usually keeps from the vanilla weapon that you copied. The game then plays the bolt clips after each shot. The mod has its own fire clips but not each bolt clip, so a vanilla bolt clip plays on your weapon. Clear the flag in the weapon record, or add the clip that the warning names.

The attachment messages list the vanilla IDLE records that the game tests before your variants. Such a record keeps its priority. For example, in third person, RaiderSneakEquip (IsSneaking == 1) comes before the equip variants. So an equip variant with IsSneaking == 1 does not play in third person. Use another condition.

Read a behavior mod of another author

Two commands read a graph file that another tool made. They need no source file.

esx hkx diff TheirGunBehavior.hkx
esx hkx events TheirGunBehavior.hkx --event reloadStart

hkx diff finds the vanilla graph that the file comes from, and lists the added, removed and changed nodes, events and variables. Nodes are matched by name, so the object numbers of the two files do not have to agree. Use --base FILE to name the base graph yourself.

hkx events lists what uses each event in the graph. waits is a transition that the event starts. sends is a notify event or a clip trigger. The unused list has the events that no part of the graph uses. Such an event can still have a sender outside the graph: an IDLE record, a clip annotation, a Papyrus script or another graph.

Graph-level control

A mod source can also contain graph-level statements. They change the graph copies after esx makes its changes:

variables { EquipSpeed: float = 1.2 }
graph GunBehavior { in clip(WPNEquip) { bind playbackSpeed = EquipSpeed } }
graph WeaponBehavior { in clip(WPNEquip) { set cropStartAmountLocalTime = 0.1 } }
select ActionSighted for GunBehavior { when IsSneaking == 1 send testBigBoy }

A graph ID is the file name of a template graph without the extension. explain lists the IDs for each view. set works on these clip members: animationName, playbackSpeed, cropStartAmountLocalTime, cropEndAmountLocalTime, startTime and enforcedDuration.

An effect project

An effect block of a graph-level source builds the graph of a weapon model or of an object: a copy of a vanilla effect project in a new folder, with your statements applied to its behavior graph. The build needs no clip and no plugin. The effect block of a weapon block makes such a block, and esx behavior expand prints it.

behavior MyMod { plugin "MyMod.esp" }

effect display {
  base vanilla "Effects\EffectBehaviors\GaussRifleWeaponFXHKB\GaussRifleWeaponFX.hkx"
  output "Effects\EffectBehaviors\MyModFXHKB\MyModFX.hkx"
  new_root AmmoDisplay
  event UncullBone
  event CullBone
  event WeaponFire
  event ReloadComplete
  in AmmoDisplay {
    state Rounds1
    on_enter Rounds1 send UncullBone "Round1"
    state Rounds0
    on_enter Rounds0 send CullBone "Round1"
    start Rounds1
    on WeaponFire from Rounds1 -> Rounds0
    on ReloadComplete from any -> Rounds1
  }
}
esx --archive 'Fallout4 - Animations.ba2' behavior build display.bhv -o build/display

base and output are the project files. The build writes 3 files: the project file, Characters/Character.hkx and Behaviors/Behavior.hkx. The first two are copies of the template.

Statement Meaning
new_root NAME The graph gets a new, empty state machine NAME as its root. Each node, event and variable of the template goes out of the copy. The block then declares each event and each state.
state NAME A new state. It moves nothing. state NAME { generator CLASS "name" { member = value } } gives the state a generator of that class, for example a BGSGamebryoSequenceGenerator that plays a controller sequence of the mesh.
on_enter STATE send EVENT "payload" The event that the state sends when it becomes active. on_exit is the event when it stops. The payload is optional. CullBone and UncullBone with the name of a node or a shape hide and show it.
start STATE The state in which the machine starts. Default: the first state.
on EVENT from STATE -> STATE A new transition with no blend time. from any makes it a transition from each state. With like OTHER, the transition is a copy of the transition on OTHER.
set MEMBER = VALUE In an in NODE { } block of an effect graph, set works on each text and number member, for example pSequence of a sequence generator.

Without new_root, the statements change the graph of the template, as they change a graph of the actor.

Not ready

  • The third-person holster has no complete game test. In the tests, the vanilla third-person holster also played no animation.
  • The power-armor views have no game test.
  • You cannot put your variants in front of a vanilla IDLE record that the game tests first.
  • esx does not make synchronized animation pairs, or stance and speed tables.
  • A model that shows its count as digits is not ready. esx reads no controller sequence of a mesh and makes none. The Gauss rifle shows its digits with such a sequence.
  • An effect block with more than 6 on ACTION when lines, and a line for a weapon change with a drawn weapon. See Limits of the action lines.