Universal Animation Scripts - Aoldri/anomaly-addon-deps GitHub Wiki

A Guide to Transition Animations

Assumptions

  • You have made animations for STALKER: Anomaly
  • You have an understanding of which animations flow into which
  • You have an understanding of the animation names, as they’re defined in config files

Context

What I call ‘Transition Animations’ may be better termed ‘Intermediate Animations’ or ‘Animated Interpolation’, depending on what you actually use it for. This script allows the injection of an animation between a currently-playing animation, and a to-be played animation.

For example, instead of using the in-game interpolation to handle the transition between walking and sprinting for a gun, an animation can be used to smoothly move the gun between the two poses. This effect can be seen in STALKER: Gunslinger, for smoothly animating the transition between idling and aiming.

An application of this script can be seen in my MP412 Reanimation.

Using the Script

Transitions are defined in config files, in the hud section of the item and are expressed in two forms: Pattern and Strict.

Pattern

This form uses a pattern to match animation names to create transitions between the initial animation and the target animation. Be warned that this is not Regex, but rather Lua’s brand of pattern matching.

I suggest using online editors for testing your patterns before applying them in-game.

While this is a somewhat confusing process, this reduces the number of transitions that need to be manually defined and is more intuitive when you consider the common format of the animation names.

The key must be prefixed with ts_pattern_ and given a unique suffix as an id. The value is a list, providing: the initial animation, the target animation, the transition animation, and the priority.

When it comes to selecting the right animation to use in a transition, there is a possibility of multiple patterns fitting the same transition. To resolve this, we use their priority. Transitions with lower priority are selected over those with higher priority. In the case of transitions with the same priority, it picks whatever the sorting algorithm decides to put at the top.

Example:

ts_pattern_walk2sprint = .+, anm_idle_sprint, anm_walk2sprint, 1

This creates a transition animation in between any animation and sprinting, with a priority of 1 (highest priority).

Strict

This form specifies the initial animation, the target animation, and the transition animation to interpose between them. This is useful for when you want to make transitions that override those defined in Patterns, as these take priority. Note that this establishes a 1:1 relation, and any subsequent transition with the same parameters will override the previous one.

The key must be prefixed with ‘ts_strict_’ and given a unique suffix as an id. The value is a list of the animation name in order of: the initial animation, the target animation, and the transition animation.

Example:

ts_strict_sprint2aim = anm_idle_sprint, anm_idle_aim, anm_sprint2walk

This creates a transition animation in between sprinting and aiming.

Comments

This script does its best to avoid any loops that may arise from the creation of these patterns, by not selecting transitions that fit any of the following conditions: Initial animation is the same as the transition animation Target animation is the same as the transition animation Initial animation is the same as the target animation

This script should now distinguish between empty and non-empty states, as well as other variants defined in the Features section.

Addendum: The fact that this script intercepts and plays a different animation in response to a starting-target animation pair means that the next animation can change after completing the transition animation. For example, a player could go from walk to sprint, triggering the walk2sprint animation. Then, during the walk2sprint animation, go back to walking. This would cause the next animation to be walk, instead of sprint. Thus, these kinds of sequences should be considered if you intend on creating these interpolation animations (e.g. you would have to capture walk2sprint -> walk for the sprint2walk transition).

Universal Animation Script(s)

Name is still WIP.

Assumptions

  • You have made animations for STALKER: Anomaly
  • You have an understanding of the animation names, as they’re defined in config files

Context

A few reanimation mods have been developed for Anomaly 1.5.2 that specifically make use of the unique callbacks to change the animation based on a variety of factors. This script should help to facilitate the use of these features without having to dig into code, as well as reduce the number of unique scripts that functionally do the same thing.

Features

Mapping Sounds to Animations

By default, the engine will conflate sounds for groups of animations together (see shoot sounds / melee attack sounds) and simply not play sounds at all during some animations since sounds are hardcoded to certain animations.

This script will dynamically check if a sound exists for the about-to-be-played animation, and play it - based on the name of the animation. Note that the original sound will still be played, and should be muted unless you intentionally want the overlap.

To use, define a sound in the weapon’s LTX in the following format:

scripted_snd_<anm_name, without ‘anm’> = <path to sound>, <never cancel>

never cancel should be set as true if you want the sound to not cut out when a new animation is played, otherwise leave it empty (this is useful for shoot sounds)

Example, for a light attack anm_attack :

scripted_snd_attack = weapons\axe\knife_1, true
snd_shoot = $no_sound
snd_shoot1 = $no_sound
snd_shoot2 = $no_sound

Using _empty Variants of Animations

By default, many animations already have _empty variants. However since this is hardcoded in engine, there are times where this is not the case. At the moment, we can see this for the shotgun reloads (anm_open, anm_add_cartridge), and misfires (anm_reload_misfire).

This script will dynamically check if an _empty variant exists for each animation, and switch to it if it exists and the weapon is empty.

To use, just write _empty variants of animations like you would for any other animation in the config file.

Example:

anm_reload_misfire_empty = aoldri_mprex_misfire_noammo, misfire_noammo

Pumping for Empty Reloads with Shotguns

By default, the end animation of shotguns is the same for both partial and empty reloads resulting in pump actions being pumped during partial reloads.

This script allows for a _pump variant of the anm_close animation, to be played only at the end of empty reloads.

Example:

anm_close_pump = mp133_reload_end_pump, reload_end_pump

Variant Animations

Variant animations are different variations of the same animation that are selected at random. For example, a melee attack could have 3 variations of swinging motions. Traditionally you would define these in the .omf file, which means you couldn’t make custom noises for each motion and different motions would have unsynced sounds.

This script allows for variant animations to be defined in the config and select them at random.

To use, define variant animations in the script, and suffix the name of the animation with ‘_variantX’ (according to the Table of Priorities), where X is some incrementing number up to the number of variants you want.

Example:

anm_attack              	= axe_light_hands
anm_attack_variant1         = axe_light_hands1
anm_attack_variant2         = axe_light_hands2

Note that each of the animations defined above have an equal chance of being played, when the anm_attack animation is played.

Jammed Variants

Weapons can misfire, requiring the player to ‘unjam’ the gun before it can fire again. This variant allows this “jammed” state to be shown visually by changing the animation if the weapon is jammed. An example might be a stovepipe malfunction on a handgun.

WPO Integration: Weapon Parts Overhaul implements a variety of jam types, for which animations can be made for. Currently, these are Misfires, Failures to Eject, and Double Feed.

  • Misfires work like the usual unjams in which the malfunction isn’t visible, and the initial pose uses the idle animation.
  • Failure to Eject works like this script’s jammed variants in which the malfunction is visible, with its own variant of the idle animation.
  • Double Feed works similar to Failure to Eject, but require the removal of the magazine before clearing.

To use, append _jammed to the name of animation, according to the Table of Priorities.

WPO Integration:

  • Use anm_reload_misfire for Misfires
  • Append _jammed for Failure to Eject
  • Append _superjammed for Double Feed

Example:

; Jammed Variants
anm_idle_jammed = foo_glock_jammed, jammed

; Unjams
anm_reload_misfire = foo_glock_unjam, unjam
anm_reload_misfire_jammed = foo_glock_unjam_fte, unjam_fte
anm_reload_misfire_superjammed = foo_glock_unjam_df, unjam_df

Grenade Launchers and Alt Aim

Guns can have grenade launchers, and often have some kind of grip alongside them (and therefore prompting this new variant). Actually using this grenade launcher can require another new hand pose. These variants are already covered in the vanilla system, and is included in this script for new animations like transitions.

Guns without grenade launchers can instead use a “alt aim”, where the gun is differently posed from ADS or hipfire. This is often used for scoped guns to provide an alternate pose for close quarters combat (or pistols to hold sideways for some reason).

To use:

  • Append _g for guns with GLs and in GL mode;
  • Append _w_gl for guns with GLs and not in GL mode;
  • Append _alt for guns without GLs and in alt aim mode

Example:

Aiming Down Sights (ADS) You right click and you aim down sights. This is here for completeness and for anyone who wants ADS-specific animations, like reloads or something. This is also useful in conjunction with other states, like alt.

To use: Append _aim to the animation name

Example:

anm_reload_aim = bar_mosin_reload_ads, reload_ads

Shotgun Unjams

In vanilla, shotguns do not use unjam animations. Don’t ask me why, it’s probably an oversight. This effectively ‘enables’ those animations to be used, if they exist.

To use: just create an unjam animation in config called anm_reload_misfire, like you would for any other type of gun.

Motion Mark: Clear Jam

Normally, the jam state is only cleared at the end of the unjam animation. This allows you to specify a point in the animation in which the jam is cleared.

To use: Use OMF Editor to add a motion mark at the desired point, and name it clear_jam.

Table of Priorities

This is the order in which suffixes are appended onto the animation name.

Priority Suffix
1 empty
2 alt / g / w_gl
3 aim
4 jammed / super_jammed
5 pump
6 variant

For example, if the animation anm_reload is valid for aim and jammed, the resulting animation would be anm_reload_aim_jammed.

Note that these suffixes are independent of the vanilla system. Those are hardcoded in the engine, which is why you might come across a different order like anm_idle_aim_empty.