← 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

An attach hub New

A rail point is a few centimetres wide, sits next to other points, and mounted devices bring their own point on top of it.

In plain wordsSmall interaction points on a weapon are hard to hit and sit next to each other. A hub at the middle with a target switch avoids aiming at all.

The problem

Every slot of the weapon had its own interaction point with an attach action for the compatible items. In practice: the points are 4–9 cm apart, the mounted device has its own point at the same place, and the points jump from one to the next while you aim. The vanilla attach action does not help: it fills the first suitable slot, whatever you look at.

The hub

One point, the default context in the middle of the weapon, offers everything:

Target action: next slot with a candidate→Attach actions of the target slot only→Server attaches into that slot
Example code – free to useMyGun_Hub.c
class MyGun_HubAttachAction : SCR_InspectionUserAction
{
	[Attribute("", desc: "Slot this action fills")]
	protected string m_sSlotName;

	[Attribute("0")]
	protected int m_iCandidate;

	override bool CanBeShownScript(IEntity user)
	{
		if (MyGun_Target.Get(GetOwner(), user) != m_sSlotName)
			return false;				// only the target slot shows its actions

		return super.CanBeShownScript(user);
	}
}
NoteThe nearby-context display skips every context without an action. So the rail points disappeared on their own once they had no action left – that was wanted.

Candidates

For a slot: the user's items, minus the ones already on a weapon, minus the ones AttachmentSlotComponent.CanSetAttachment() rejects, minus the ones the inventory cannot move (CanMoveItemToStorage or, for a replace, CanSwapItemStorages), and each prefab only once. Cache the scan for about 300 ms: the UI asks every frame.

Detach

Attachments move back to the inventory with FindStorageForItem() and TryMoveItemToStorage(). Third-party devices bring their own Detach action; the hub only covers the parts that have none.