← 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

A press check on a tap New

The safety key is a hold. You can add a tap to it without a new key binding – gamepad included.

In plain wordsA hold of the safety key is already the safety. A tap can be something else: read the vanilla input value and decide after a short delay.

The problem

The vanilla safety action CharacterWeaponManualSafety is a hold action (Left Shift + V; gamepad: left stick click + d-pad left, hold-once filter). A new input action of your own never received a value in tests. The vanilla action did.

Read the vanilla value

Poll the action value every 50 ms. During a hold it ramps from 0 to 1 over about a quarter of a second. A tap peaks well below that and drops back.

Example code – free to useMyGun_Tap.c
protected void Poll()
{
	float v = GetGame().GetInputManager().GetActionValue("CharacterWeaponManualSafety");
	if (v > m_fPeak)
		m_fPeak = v;

	if (v == 0 && m_fPeak > 0)
	{
		// released: a tap peaks low, a hold climbs to the end
		if (m_fPeak < TAP_MAX)
			m_bTapped = true;

		m_fPeak = 0;
	}
}
Pitfall: the hold fires tooA tap also starts the safety toggle for a moment. Decide about 250 ms later whether the fire mode really changed: if it did, it was a hold; if not, it was a tap.

Play the animation on both sides

Show it to other players

An item is owned by the server, so a weapon cannot send a remote call itself. Put the call on the character controller instead:

Example code – free to useMyGun_Controller.c
modded class SCR_CharacterControllerComponent
{
	[RplRpc(RplChannel.Reliable, RplRcver.Server)]
	protected void RpcMyCheckToServer() { RpcMyCheckBroadcast(); }

	[RplRpc(RplChannel.Reliable, RplRcver.Broadcast)]
	protected void RpcMyCheckBroadcast() { PlayCheckHere(); }
}

The owner's client asks the server; the server broadcasts; every client plays the animation on its copy.