← Home SEEBIE90 DOCS
Download PDF
The KRISS Vector mod is published under the Backblast Studios licenseExample code on this site is free to useBug reports: Backblast Studios DiscordLicense

KRISS Vector

One weapon, two magazine kinds New

Stick and drum need different hands. Two weapons would split the loadout and the arsenal. One weapon and a variable keeps one weapon.

In plain wordsThe reload hand animation depends on the magazine. The character graph cannot see which one it is, so a script sets a spare variable the weapon graph reads.

The problem

A reload animation is chosen in the animation graph of the weapon, which is injected into the graph of the character. The graph sees the command (CMD_Weapon_Reload), the stance and the weapon state – but not which magazine is in the weapon or is about to go in. A drum needs the hand under the magazine, a stick needs it around the magazine.

PitfallThe obvious fix is a second weapon with its own graph. It works and costs everything else: two prefabs for the loadout, two arsenal entries, the player drops one weapon to switch magazine kind. Avoid it.

The trick: a spare variable

The character graph declares many variables. Some are never read by the vanilla graphs. A script component can set such a variable by name, and the weapon graph can read it, as long as the weapon's own graph template declares the same name.

Script: which magazine?→Set a spare bool on the character graph→Weapon graph: choose the animation slot→Hand animation
Example code – free to useMyGun_MagKind.c
class MyGun_MagKindComponent : ScriptComponent
{
	protected TAnimGraphVariable m_Var;
	protected CharacterAnimationComponent m_Anim;

	// the spare variable: never read by the vanilla graphs
	protected static const string VARIABLE = "Trigger01";

	protected void Update(bool drum)
	{
		if (!m_Anim || m_Var < 0)
			return;

		m_Anim.SetSharedVariableBool(m_Var, drum, true);
	}

	protected void Bind(CharacterAnimationComponent anim)
	{
		m_Anim = anim;
		m_Var = anim.BindVariableBool(VARIABLE);	// returns -1 when the graph has no such variable
	}
}

The component runs on the machine that owns the character; the animation system replicates the variable with the rest of the character graph.

Which magazine?

NoteSet the value on a change, and refresh it about once a second. A weapon switch or a respawn of the graph would otherwise lose it.

The weapon graph

In the graph, the reload states have twin versions that differ in the animation set slots (stick or drum). A start condition on the variable picks the twin when a reload begins.

Pitfall: the sorted tableRows of the animation set table must be sorted case-insensitively. An unsorted table does not compile into a graph: the log says Animation graph is invalid and the weapon has no animation at all.