Skip to main content

Weapon API

Interface ID 6, version 2.1 (2.1, ROCK 1.0.4, adds setCounterPresentation; request minor 0 when you do not call it). Mods built against 2.0 keep working. Include <ROCK/Weapon.h>. Namespace rock::api::weapon. Permissions: Read (1), Write (2). Equipped weapons by weapon slot: state and hand assignment, grip, classification, emitters, composition, authored grip, scope sight, the handling authority lease, inventory equips, draws and unequips. isEquipPickup replaces the pre-release EquipPickup.h header.

Weapon slots​

A weapon slot is the native equipment index (kMaxWeaponSlots = 2): 0 is the first equipped weapon, 1 the second. A slot never implies a hand: which hand fires or supports a weapon is in its WeaponState. A slot at or above kMaxWeaponSlots returns InvalidArgument. Both slots serve getWeaponState, getGrip, getClassification, copyEmitters, getInteractionKey, setChamberMarker and unequipWeapon; composition, authored grip and scope sight serve slot 0 only and return TargetUnavailable for slot 1. Weapon slots lists every interface.

Entry points​

FunctionPermissionThreadPurpose
getWeaponStateReadGameThe slot's weapon, lifecycle flags, equip transition, firing and support hands, handling flags and ammo counter.
getGripReadGameThe solved weapon world transform, each hand's grip in weapon space and the projectile origin and direction.
getClassificationReadGameSize class, keyword flags and their provenance (slot 0).
copyEmittersReadGameFlashlights, lasers and reticles, up to kMaxEmitters (32).
getCompositionStateReadGameInstalled mods summary (slot 0).
copyCompositionEntriesReadGameInstalled mods and their attach points, up to kMaxCompositionEntries (64) (slot 0).
getAuthoredGripPoseReadGameThe authored hand and finger poses ROCK selected (slot 0).
getScopeSightStateReadGameScope availability, activation source, anchor and sight bounds in weapon space (slot 0).
setHandlingAuthorityWriteGameOverrides ROCK's weapon handling tuning for 1 to kMaxHandlingLeaseFrames (120) frames.
clearHandlingAuthorityWriteGameEnds the owner's lease.
getHandlingAuthorityReadGameThe active lease.
captureInventoryWeaponReadGameAn inventory weapon stack, captured immediately before an equip.
requestInventoryEquipWriteGameEquips an inventory weapon into a hand.
getInventoryEquipResultReadGameThe result of an equip; the latest 64 terminal results are kept.
cancelInventoryEquipWriteGameCancels an equip before the native equip; AlreadyCommitted afterwards.
isEquipPickupReadAnyWhether ROCK is acquiring exactly this reference and count for an equip.
getSampleReadAnyIdentity of the current publication.
unequipWeaponWriteGameReturns the slot's weapon to the inventory, synchronously.
getFiringAimWorldReadGameWhere a firearm held by a hand sits this frame.
setWarmInventoryWeaponsWriteGameKeeps up to kMaxWarmInventoryWeapons (8, across owners) inventory firearms ready to equip.
requestInventoryDrawWriteGamerequestInventoryEquip for a weapon the consumer already shows in the hand (a holster draw).
setAutomaticReloadBlockedWriteGameWhile held, an empty slot-1 weapon dry-fires on its trigger instead of starting ROCK's automatic reload; its reload button still reloads. One owner at a time.
setChamberMarkerWriteGameDraws an Empty or Chambered cartridge beside the slot's ammo counter for a renewed lease of 1 to kMaxChamberMarkerLeaseFrames; None clears it. One owner per slot.
getInteractionKeyReadGameThe weapon's key from the moment it is drawn (0 with no weapon), for WeaponParts sources, drives, targets and grab points, setReloadGesture and setSupportTrigger before its colliders exist.
setInventoryDrawPoseWriteGameFor the owner's pending requestInventoryDraw whose stand-in is not at the aim yet: report where the stand-in is shown, every frame; the reveal continues from a pose sent within the last kMaxDrawPoseAgeFrames (3) frames. RequestNotFound once revealed.
setCounterPresentationWriteGame2.1. Takes the slot's ammo counter for a mod that owns that weapon's ammunition: its numbers, label, chamber cartridge and colour, or hides it. One owner per slot.

Weapon state​

firingHand is the hand with the firing role (HandlingStateFlag::FiringGripHeld says whether it holds the grip now); supportHand is the hand on the support grip, or None. Both are None without a weapon. With WeaponStateFlag::AmmoKnown, loadedRounds and reserveRounds are the slot's ammo counter: the native HUD rule for that slot, except that reserve excludes rounds loaded in the other slot's weapon when both use the same uncharged ammo. UserWeaponOffset marks a weapon the player resized or re-gripped with their own FRIK weapon offset file: ROCK seats and scales it from that file and gives it dynamic support grabs only, so animation authored for ROCK's grip does not fit its hands. A finished equip transition advances terminalSequence.

getGrip for slot 1 publishes the placed weapon's world transform and its own projectile origin and direction, without hand grips, and returns TargetUnavailable while no second weapon is placed in a hand. Emitter transforms are in the frame of that slot's weaponWorld.

Handling authority​

One owner at a time (OwnerConflict for another). A lost lease shows up as a failed renew. ROCK's firing-grip handoff and reattach zone is a quarter sector on each side of the grip, swept from straight out to straight down the grip, with firingGripReattachRadiusGameUnits as its radius. HandlingFeature::FiringGripCylinderZone replaces it with one cylinder per side along the weapon's lateral axis, the same reach long, for as long as the lease holds. Other features: FiringGripOwnership, PrimaryDetach, AmbidextrousHandoff, GripZoneEquip, GripZoneHoverHaptics, FiringGripProximitySupport. The request also carries the left firing aim trim and the equip visual bridge timing.

Inventory equip​

  1. captureInventoryWeapon(owner, baseFormId, stackIndex, item) immediately before the request. stackKey and instanceKey are comparison witnesses only.
  2. requestInventoryEquip(owner, request, commandId) equips into request.hand. The weapon lands in the slot ROCK's equip rule picks: the slot whose weapon that hand fires or carries is replaced (the old weapon returns to the inventory and outgoingFormId names it), else the first free slot, else the slot whose weapon no hand fires. A weapon the other hand holds stays equipped. A hand busy with anything else (a held object, a pending grab) is refused with HandBusy. One switch may be outstanding; RequestQueued is admission, not success.
  3. getInventoryEquipResult(owner, commandId, result): state (Queued, Switching, Succeeded, Failed, Cancelled), failure (EquipFailure), flags (IncomingEquipAccepted, IncomingGripAcquired, IncomingPresented) and weaponSlot, the slot the weapon went to. Inspect flags even when the switch fails.
  4. cancelInventoryEquip(owner, commandId) before the native equip.

requestInventoryDraw is the same request for a weapon your mod shows in the hand at getFiringAimWorld until ROCK reveals it: when ROCK seats the firearm, the weapon continues from that aim pose and the hand from its tracked pose, and both ease into the grip instead of snapping. Results and polling are those of requestInventoryEquip.

getFiringAimWorld(owner, hand, world) applies ROCK's fixed controller-to-weapon aim basis to that hand's filtered controller (left: mirrored, with the left aim trim). It is the same for every firearm and does not depend on what is equipped. Scale is 1. TargetUnavailable while the controller frame is unknown.

setWarmInventoryWeapons(owner, items, count) replaces the owner's set of captureInventoryWeapon records kept ready (count 0 clears). ROCK keeps each firearm's native animation subgraph loaded in the background, so its first equip after a game load does not wait about half a second on the engine. Other weapon types need no warming. The set is dropped when the owner unregisters or physics shuts down: send it again when the sample's world, skeleton or provider generation changes. TargetUnavailable (nothing changed) when an item no longer matches its stack.

Counter presentation​

setCounterPresentation(owner, slot, presentation, leaseFrames) (2.1) takes the slot's ammo counter for a mod that owns that weapon's ammunition, for example one that keeps its own magazines. presentation.fields (CounterField) names what it replaces, in every counter style:

FieldReplaces
LoadedThe loaded count with loadedRounds
ReserveThe reserve count with reserveRounds
LabelThe caliber label with label (UTF-8, terminated inside its 32 bytes; empty shows none)
ChamberEvery chamber marker of the slot, another owner's setChamberMarker included, with chamber
ColorThe style's digit colour with color (0 to 1 per channel)
HiddenShows no counter for the weapon

Fields it leaves out keep ROCK's values. The lease is 1 to kMaxCounterPresentationLeaseFrames frames, renewed each frame, so the counter returns to ROCK's values by itself when the owner stops; null or fields 0 clears it. One owner per slot (OwnerConflict until the holder clears it or its lease runs out). InvalidSize or UnsupportedVersion for a record of another size or version; InvalidArgument for unknown fields, an unterminated label, a colour outside 0 to 1 or a lease out of range.

Unequip​

unequipWeapon(owner, slot, expectedFormId) returns the weapon in slot to the inventory from its own hand. The other slot's weapon stays in its hand; when slot 0 empties, a slot-1 weapon moves to slot 0 in the same hand on the next frame. Read the hand's slot from Hands getRoles (or a slot's firingHand) first. expectedFormId must name the slot's weapon (TargetInvalid otherwise); an empty slot returns TargetUnavailable, an equip switch in progress Busy, a blocking menu NotReady. InternalError means the native unequip did not empty the slot.

Equip pickup​

isEquipPickup(owner, referenceFormId, count, matches) is for a native pickup interceptor: matches is 1 only while ROCK acquires exactly that reference and count for an equip, on the acquiring thread. It is intent, not a promise that the equip succeeds.

Records and values​

RecordFields
WeaponStatesample, weaponSlot, flags (WeaponStateFlag), weaponFormId, firingHand, supportHand, handlingFlags (HandlingStateFlag), weaponGenerationKey, transitionSequence, terminalSequence, transitionSource, terminalSource (TransitionSource), terminalResult (TransitionResult), transitionWeaponFormId, terminalWeaponFormId, loadedRounds, reserveRounds
GripweaponSlot, flags (GripFlag), weaponGenerationKey, weaponFormId, weaponWorld, rightHandInWeapon, leftHandInWeapon, muzzleOriginGame, muzzleDirectionGame
ClassificationweaponSlot, valid, keywordFlags (64-bit KeywordFlag), sizeClass (Melee, Pistol, Rifle, Heavy), source (None, Keyword, WeaponData, EquipSlot), weaponFormId, confidence, weaponGenerationKey, provenanceFlags
Emitterkind (Flashlight, Laser, Reticle), source (EffectGeometry, AddOnNode), flags, active, visible, addOnNodeValue, omodFormId, attachPointFormId, weaponGenerationKey, weaponLocalTransform, forwardWeaponLocal, sourceName[64]
CompositionStateweaponSlot, weaponFormId, weaponGenerationKey, compositionSignature, semanticCoverageMask, missingCoverageMask, publicationSequence, entryCount
CompositionEntryomodFormId, attachPointFormId, stableIndex, flags (Active, Disabled, AttachPointResolved, SemanticEvidenceMatched), semanticCoverageMask
AuthoredGripPoseweaponSlot, weaponFormId, weaponGenerationKey, variantKey, captureSequence, source (LiveEquippedGraph, NativeIdlePreharvest, RuntimeCanonical), flags, finger masks, each hand's transform in weapon space and 15 finger transforms, generations
ScopeSightStatesample, weaponSlot, flags (ScopeSightFlag), weaponGenerationKey, weaponFormId, activationSource (NativeGeometry, RockGeometry, ManualInput), nativeScopeOverlayIndex, anchorWeaponLocal, sightBoundsWeaponLocal, sightBodyCount, sightBodyId, omodFormId, attachPointFormId
HandlingRequest, HandlingAuthorityrequest: features, leaseFrames, tuning values, left firing aim trim, equip visual bridge timing, generations; authority: active, features, owner, expiresAfterFrame
InventoryWeaponbaseFormId, stackIndex, count, stackKey, instanceKey, frameIndex, generations
EquipRequest, EquipResultrequest: hand, item; result: commandId, transferSequence, state, failure, flags, hand, incomingFormId, outgoingFormId, weaponSlot, generations

WeaponStateFlag: Valid, IdentityPending, DrawPending, BridgePresented, NativeRenderable, HandPoseHandoffComplete, RecoveryExhausted, TransitionActive, WeaponPresent, WeaponDrawn, PresentationKnown, WeaponEquipped, AmmoKnown, UserWeaponOffset, SecondaryReloadActive, BipodRightInputReserved, BipodLeftInputReserved; bit 12 (one bipod reservation without its hand) is retired and never reused. HandlingStateFlag: FiringGripHeld, ManualOwnership, PartCarry, LeftFiringAvailable. TransitionSource: Unknown, ObservedEquip, HeldTriggerEquip, HeldGripZoneEquip, MenuExit, WorkbenchExit. TransitionResult: None, Completed, WeaponUnequipped, IdentityLost, ExpectedIdentityTimeout, NativeAnimationHandoff, WeaponNoLongerDrawn, RecoveryExhausted, ProviderLost, Shutdown. GripFlag: Valid, WeaponTransformOwned, WeaponWorldValid, RightHandInWeaponValid, LeftHandInWeaponValid, MuzzleWorldValid. EquipFailure: None, LifecycleLost, OwnerLost, HandUnavailable, HandBusy, InventoryChanged, InfrastructureUnavailable, NativeEquipFailed (8), GripOrPresentationFailed, CancelledBeforeCommit, EquippedWeaponChanged, MenuBlocked.

Retired and never reused: TransitionResult 10 (shoulder sheath), GripFlag bits 1 and 2 (two-hand grip and left firing hand; the hands are in WeaponState), EquipFailure 7 (OutgoingTransferFailed), EquipResultFlag bits 0 and 1.

Declarations​

Complete public declarations: ROCK/Weapon.h
ROCK/Weapon.h
#pragma once
#include "Abi.h"

// Equipped weapons, addressed by weapon slot (see kMaxWeaponSlots): state and
// hand assignment, grip, classification, emitters, composition, authored grip,
// scope sight, the handling authority lease and inventory equips.
#pragma pack(push, 8)
namespace rock::api::weapon {
inline constexpr InterfaceId kInterfaceId = InterfaceId::Weapon;
inline constexpr std::uint32_t kMajor = 2;
inline constexpr std::uint32_t kMinor = 1;
inline constexpr std::uint32_t kMaxEmitters = 32;
inline constexpr std::uint32_t kMaxCompositionEntries = 64;
inline constexpr std::uint32_t kMaxHandlingLeaseFrames = 120;
inline constexpr std::uint32_t kFingerLocalTransformCount = 15;

// ------------------------------------------------------------------
// Weapon state
// ------------------------------------------------------------------

enum class WeaponStateFlag : std::uint32_t
{
None = 0,
Valid = 1u << 0,
IdentityPending = 1u << 1,
DrawPending = 1u << 2,
BridgePresented = 1u << 3,
NativeRenderable = 1u << 4,
HandPoseHandoffComplete = 1u << 5,
RecoveryExhausted = 1u << 6,
TransitionActive = 1u << 7,
// The weapon is in the hand. On slot 1, ROCK has placed it: this frame or,
// for a reader before this frame's placement (frame callbacks), the last.
WeaponPresent = 1u << 8,
WeaponDrawn = 1u << 9,
PresentationKnown = 1u << 10,
WeaponEquipped = 1u << 11,
// 12 retired (one bipod reservation without its hand); never reuse.
// loadedRounds and reserveRounds hold the weapon's ammo counter.
AmmoKnown = 1u << 13,
// The weapon is seated and scaled from a FRIK weapon offset (saved by
// the player or shipped with FRIK). Animation authored for ROCK's
// grip of this weapon does not fit its hands.
UserWeaponOffset = 1u << 14,
// Slot 1 only: ROCK's private graph of this weapon is in its reload.
// Slot 0's reload is the player's own graph.
SecondaryReloadActive = 1u << 15,
// Slot 0: the bipod takes that hand's stick click while the weapon
// touches a fixed surface or rests latched on one. Its hand is the
// firing hand while both hands hold the weapon, the hand holding it
// otherwise, and the last such hand while it stands hands-free. The
// other hand's click stays free.
BipodRightInputReserved = 1u << 16,
BipodLeftInputReserved = 1u << 17,
};

enum class HandlingStateFlag : std::uint32_t
{
None = 0,
// A hand holds the weapon's firing grip.
FiringGripHeld = 1u << 0,
// Grips follow the hands' own grab ownership.
ManualOwnership = 1u << 1,
// The firing hand carries the weapon by a part, vacating the firing grip.
PartCarry = 1u << 2,
// The left hand can take the firing grip.
LeftFiringAvailable = 1u << 3,
};

enum class TransitionSource : std::uint32_t
{
Unknown = 0,
ObservedEquip = 1,
HeldTriggerEquip = 2,
HeldGripZoneEquip = 3,
MenuExit = 4,
WorkbenchExit = 5,
};

enum class TransitionResult : std::uint32_t
{
None = 0,
Completed = 1,
WeaponUnequipped = 2,
IdentityLost = 3,
ExpectedIdentityTimeout = 4,
NativeAnimationHandoff = 5,
WeaponNoLongerDrawn = 6,
RecoveryExhausted = 7,
ProviderLost = 8,
Shutdown = 9,
// 10 retired (shoulder sheath removed); never reuse.
};

/*
* One weapon slot. firingHand is the hand assigned the weapon's firing
* role (FiringGripHeld says whether it holds the grip now); supportHand
* holds its support grip, or None. Both are None without a weapon. The
* transition fields follow the slot's latest equip transition and its
* last terminal result.
*/
struct WeaponState
{
std::uint32_t size{ sizeof(WeaponState) };
std::uint32_t version{ 1 };
Sample sample{};
std::uint32_t weaponSlot{ 0 };
std::uint32_t flags{ 0 };
std::uint32_t weaponFormId{ 0 };
Hand firingHand{ Hand::None };
Hand supportHand{ Hand::None };
std::uint32_t handlingFlags{ 0 };
std::uint64_t weaponGenerationKey{ 0 };
std::uint64_t transitionSequence{ 0 };
std::uint64_t terminalSequence{ 0 };
TransitionSource transitionSource{ TransitionSource::Unknown };
TransitionResult terminalResult{ TransitionResult::None };
TransitionSource terminalSource{ TransitionSource::Unknown };
std::uint32_t transitionWeaponFormId{ 0 };
std::uint32_t terminalWeaponFormId{ 0 };
// The native counter's rule for this slot; reserve excludes rounds
// loaded in the other slot's weapon. Valid with AmmoKnown.
std::uint32_t loadedRounds{ 0 };
std::uint32_t reserveRounds{ 0 };
};

// ------------------------------------------------------------------
// Grip
// ------------------------------------------------------------------

// Bits 1 (two-hand grip) and 2 (left firing hand) are retired: the hands
// are in WeaponState. Never reuse.
enum class GripFlag : std::uint32_t
{
None = 0,
Valid = 1u << 0,
WeaponTransformOwned = 1u << 3,
WeaponWorldValid = 1u << 4,
RightHandInWeaponValid = 1u << 5,
LeftHandInWeaponValid = 1u << 6,
MuzzleWorldValid = 1u << 7,
};

// The weapon's solved world transform, each hand's grip in weapon space and
// the projectile origin.
struct Grip
{
std::uint32_t size{ sizeof(Grip) };
std::uint32_t version{ 1 };
std::uint32_t weaponSlot{ 0 };
std::uint32_t flags{ 0 };
std::uint64_t weaponGenerationKey{ 0 };
std::uint32_t weaponFormId{ 0 };
Transform weaponWorld{};
Transform rightHandInWeapon{};
Transform leftHandInWeapon{};
Point3 muzzleOriginGame{};
Point3 muzzleDirectionGame{};
};

// ------------------------------------------------------------------
// Classification
// ------------------------------------------------------------------

enum class SizeClass : std::uint32_t
{
Melee = 0,
Pistol = 1,
Rifle = 2,
Heavy = 3,
};

enum class ClassificationSource : std::uint32_t
{
None = 0,
Keyword = 1,
WeaponData = 2,
EquipSlot = 3,
};

enum class KeywordFlag : std::uint64_t
{
None = 0,
Pistol = 1ull << 0,
Rifle = 1ull << 1,
Shotgun = 1ull << 2,
AssaultRifle = 1ull << 3,
Sniper = 1ull << 4,
GaussRifle = 1ull << 5,
LaserMusket = 1ull << 6,
HeavyGun = 1ull << 7,
HandToHand = 1ull << 8,
Melee1H = 1ull << 9,
Melee2H = 1ull << 10,
Unarmed = 1ull << 11,
Minigun = 1ull << 12,
Fatman = 1ull << 13,
MissileLauncher = 1ull << 14,
GatlingLaser = 1ull << 15,
Flamer = 1ull << 16,
Cryolater = 1ull << 17,
JunkJet = 1ull << 18,
RailwayRifle = 1ull << 19,
Broadsider = 1ull << 20,
Syringer = 1ull << 21,
FlareGun = 1ull << 22,
GammaGun = 1ull << 23,
AlienBlaster = 1ull << 24,
Ripper = 1ull << 25,
Shishkebab = 1ull << 26,
Laser = 1ull << 27,
Plasma = 1ull << 28,
Ballistic = 1ull << 29,
Thrown = 1ull << 30,
Grenade = 1ull << 31,
Mine = 1ull << 32,
Explosive = 1ull << 33,
Automatic = 1ull << 34,
};

enum class ClassificationProvenanceFlag : std::uint32_t
{
None = 0,
KeywordEvidence = 1u << 0,
EffectiveInstanceKeywordEvidence = 1u << 1,
WeaponDataEvidence = 1u << 2,
EquipSlotEvidence = 1u << 3,
GenerationBound = 1u << 4,
};

struct Classification
{
std::uint32_t size{ sizeof(Classification) };
std::uint32_t version{ 1 };
std::uint32_t weaponSlot{ 0 };
std::uint32_t valid{ 0 };
std::uint64_t keywordFlags{ 0 };
SizeClass sizeClass{ SizeClass::Rifle };
ClassificationSource source{ ClassificationSource::None };
std::uint32_t weaponFormId{ 0 };
float confidence{ 0.0f };
std::uint64_t weaponGenerationKey{ 0 };
std::uint32_t provenanceFlags{ 0 };
};

// ------------------------------------------------------------------
// Emitters
// ------------------------------------------------------------------

enum class EmitterKind : std::uint32_t
{
Unknown = 0,
Flashlight = 1,
Laser = 2,
Reticle = 3,
};

enum class EmitterSource : std::uint32_t
{
Unknown = 0,
EffectGeometry = 1,
AddOnNode = 2,
};

enum class EmitterFlag : std::uint32_t
{
None = 0,
TransformValid = 1u << 0,
DirectionValid = 1u << 1,
EffectStateKnown = 1u << 2,
HasAddOnNodeValue = 1u << 3,
HasOmod = 1u << 4,
HasAttachPoint = 1u << 5,
};

struct Emitter
{
std::uint32_t size{ sizeof(Emitter) };
std::uint32_t version{ 1 };
EmitterKind kind{ EmitterKind::Unknown };
EmitterSource source{ EmitterSource::Unknown };
std::uint32_t flags{ 0 };
std::uint32_t active{ 0 };
std::uint32_t visible{ 0 };
std::uint32_t addOnNodeValue{ 0 };
std::uint32_t omodFormId{ 0 };
std::uint32_t attachPointFormId{ 0 };
std::uint64_t weaponGenerationKey{ 0 };
Transform weaponLocalTransform{};
Point3 forwardWeaponLocal{};
char sourceName[64]{};
};

// ------------------------------------------------------------------
// Composition
// ------------------------------------------------------------------

enum class CompositionFlag : std::uint32_t
{
None = 0,
Active = 1u << 0,
Disabled = 1u << 1,
AttachPointResolved = 1u << 2,
SemanticEvidenceMatched = 1u << 3,
};

struct CompositionState
{
std::uint32_t size{ sizeof(CompositionState) };
std::uint32_t version{ 1 };
std::uint32_t weaponSlot{ 0 };
std::uint32_t weaponFormId{ 0 };
std::uint64_t weaponGenerationKey{ 0 };
std::uint64_t compositionSignature{ 0 };
std::uint64_t semanticCoverageMask{ 0 };
std::uint64_t missingCoverageMask{ 0 };
std::uint64_t publicationSequence{ 0 };
std::uint32_t entryCount{ 0 };
};

// One installed mod (OMOD) and the attach point it occupies.
struct CompositionEntry
{
std::uint32_t size{ sizeof(CompositionEntry) };
std::uint32_t version{ 1 };
std::uint32_t omodFormId{ 0 };
std::uint32_t attachPointFormId{ 0 };
std::uint32_t stableIndex{ 0 };
std::uint32_t flags{ 0 };
std::uint64_t semanticCoverageMask{ 0 };
};

// ------------------------------------------------------------------
// Authored grip
// ------------------------------------------------------------------

enum class AuthoredGripSource : std::uint32_t
{
Unknown = 0,
LiveEquippedGraph = 1,
NativeIdlePreharvest = 2,
RuntimeCanonical = 3,
};

enum class AuthoredGripPoseFlag : std::uint32_t
{
None = 0,
Valid = 1u << 0,
RightHandValid = 1u << 1,
LeftHandValid = 1u << 2,
RightFingersValid = 1u << 3,
LeftFingersValid = 1u << 4,
};

// The authored hand and finger poses ROCK selected for the weapon. The
// generations are those at capture.
struct AuthoredGripPose
{
std::uint32_t size{ sizeof(AuthoredGripPose) };
std::uint32_t version{ 1 };
std::uint32_t weaponSlot{ 0 };
std::uint32_t weaponFormId{ 0 };
std::uint64_t weaponGenerationKey{ 0 };
std::uint64_t variantKey{ 0 };
std::uint64_t captureSequence{ 0 };
AuthoredGripSource source{ AuthoredGripSource::Unknown };
std::uint32_t flags{ 0 };
std::uint16_t rightFingerLocalTransformMask{ 0 };
std::uint16_t leftFingerLocalTransformMask{ 0 };
Transform rightHandInWeapon{};
Transform leftHandInWeapon{};
Transform rightFingerLocalTransforms[kFingerLocalTransformCount]{};
Transform leftFingerLocalTransforms[kFingerLocalTransformCount]{};
std::uint32_t worldGeneration{ 0 };
std::uint32_t skeletonGeneration{ 0 };
std::uint32_t providerGeneration{ 0 };
};

// ------------------------------------------------------------------
// Scope sight
// ------------------------------------------------------------------

enum class ScopeActivationSource : std::uint32_t
{
None = 0,
NativeGeometry = 1,
RockGeometry = 2,
ManualInput = 3,
};

enum class ScopeSightFlag : std::uint32_t
{
None = 0,
Available = 1u << 0,
Active = 1u << 1,
MenuOpen = 1u << 2,
AnchorValid = 1u << 3,
BoundsValid = 1u << 4,
NativeOverlayValid = 1u << 5,
ManualDirectTransitionRequired = 1u << 6,
};

struct ScopeSightState
{
std::uint32_t size{ sizeof(ScopeSightState) };
std::uint32_t version{ 1 };
Sample sample{};
std::uint32_t weaponSlot{ 0 };
std::uint32_t flags{ 0 };
std::uint64_t weaponGenerationKey{ 0 };
std::uint32_t weaponFormId{ 0 };
ScopeActivationSource activationSource{ ScopeActivationSource::None };
std::uint32_t nativeScopeOverlayIndex{ 0 };
Point3 anchorWeaponLocal{};
Bounds3 sightBoundsWeaponLocal{};
std::uint32_t sightBodyCount{ 0 };
std::uint32_t sightBodyId{ 0x7FFF'FFFF };
std::uint32_t omodFormId{ 0 };
std::uint32_t attachPointFormId{ 0 };
};

// ------------------------------------------------------------------
// Handling authority
// ------------------------------------------------------------------

enum class HandlingFeature : std::uint32_t
{
None = 0,
FiringGripOwnership = 1u << 0,
PrimaryDetach = 1u << 1,
AmbidextrousHandoff = 1u << 2,
GripZoneEquip = 1u << 3,
GripZoneHoverHaptics = 1u << 4,
FiringGripProximitySupport = 1u << 5,
// The firing-grip zone becomes one cylinder per side along the
// weapon's lateral axis instead of ROCK's default quarter sector.
FiringGripCylinderZone = 1u << 6,
};

// One owner at a time overrides ROCK's weapon handling tuning for
// 1..kMaxHandlingLeaseFrames frames; renew to keep it.
struct HandlingRequest
{
std::uint32_t size{ sizeof(HandlingRequest) };
std::uint32_t version{ 1 };
std::uint32_t features{ 0 };
std::uint32_t leaseFrames{ 0 };
float gripZoneEquipRadiusGameUnits{ 3.0f };
float gripZoneEquipSettleSeconds{ 0.15f };
float firingGripReattachRadiusGameUnits{ 3.0f };
float gripZoneHoverHapticIntensity{ 0.75f };
float firingGripProximitySupportRadiusGameUnits{ 6.0f };
float weaponGripHapticDurationSeconds{ 0.10f };
float firingGripAttachHapticIntensity{ 0.85f };
float firingGripDetachHapticIntensity{ 0.30f };
float supportGripHapticIntensity{ 0.50f };
float leftFiringAimYawDegrees{ 0.0f };
float leftFiringAimPitchDegrees{ 0.0f };
float leftFiringAimOffsetGameUnits[3]{};
float equipVisualBridgeTimeoutSeconds{ 2.0f };
float equipVisualBridgeBlendSeconds{ 0.15f };
std::uint32_t worldGeneration{ 0 };
std::uint32_t skeletonGeneration{ 0 };
std::uint32_t providerGeneration{ 0 };
};

struct HandlingAuthority
{
std::uint32_t size{ sizeof(HandlingAuthority) };
std::uint32_t version{ 1 };
std::uint32_t active{ 0 };
std::uint32_t features{ 0 };
OwnerToken owner{ 0 };
std::uint64_t expiresAfterFrame{ 0 };
};

// ------------------------------------------------------------------
// Inventory equip
// ------------------------------------------------------------------

// An inventory weapon stack captured on the frame owner immediately before
// use. The keys are opaque comparison witnesses, never pointers or saved
// identities; stackIndex is the native inventory stack index.
struct InventoryWeapon
{
std::uint32_t size{ sizeof(InventoryWeapon) };
std::uint32_t version{ 1 };
std::uint32_t baseFormId{ 0 };
std::uint32_t stackIndex{ 0 };
std::uint32_t count{ 0 };
std::uint64_t stackKey{ 0 };
std::uint64_t instanceKey{ 0 };
std::uint64_t frameIndex{ 0 };
std::uint32_t worldGeneration{ 0 };
std::uint32_t skeletonGeneration{ 0 };
std::uint32_t providerGeneration{ 0 };
};

// setWarmInventoryWeapons: every owner's sets together.
inline constexpr std::uint32_t kMaxWarmInventoryWeapons = 8;

struct EquipRequest
{
std::uint32_t size{ sizeof(EquipRequest) };
std::uint32_t version{ 1 };
Hand hand{ Hand::None };
InventoryWeapon item{};
};

enum class EquipState : std::uint32_t
{
Unknown = 0,
Queued = 1,
Switching = 2,
Succeeded = 3,
Failed = 4,
Cancelled = 5,
};

enum class EquipFailure : std::uint32_t
{
None = 0,
LifecycleLost = 1,
OwnerLost = 2,
HandUnavailable = 3,
HandBusy = 4,
InventoryChanged = 5,
InfrastructureUnavailable = 6,
// 7 (OutgoingTransferFailed) is retired. Never reuse.
NativeEquipFailed = 8,
GripOrPresentationFailed = 9,
CancelledBeforeCommit = 10,
EquippedWeaponChanged = 11,
MenuBlocked = 12,
};

// Bits 0 and 1 (outgoing removed/retained) are retired. Never reuse.
enum class EquipResultFlag : std::uint32_t
{
IncomingEquipAccepted = 1u << 2,
IncomingGripAcquired = 1u << 3,
IncomingPresented = 1u << 4,
};

struct EquipResult
{
std::uint32_t size{ sizeof(EquipResult) };
std::uint32_t version{ 1 };
std::uint64_t commandId{ 0 };
std::uint64_t transferSequence{ 0 };
EquipState state{ EquipState::Unknown };
EquipFailure failure{ EquipFailure::None };
std::uint32_t flags{ 0 };
Hand hand{ Hand::None };
std::uint32_t incomingFormId{ 0 };
std::uint32_t outgoingFormId{ 0 };
// The weapon slot the incoming weapon was equipped into.
std::uint32_t weaponSlot{ 0 };
std::uint32_t worldGeneration{ 0 };
std::uint32_t skeletonGeneration{ 0 };
std::uint32_t providerGeneration{ 0 };
};

// What a consumer that tracks a weapon's chamber says it holds. ROCK draws
// it as a cartridge beside that weapon's ammo counter, in every counter style.
enum class ChamberMarker : std::uint32_t
{
None = 0,
// Hollow and dim: no round in the chamber.
Empty = 1,
// Solid: a round in the chamber.
Chambered = 2,
};
inline constexpr std::uint32_t kMaxChamberMarkerLeaseFrames = 4;

// 2.1. The fields of a weapon's ammo counter a counter presentation
// replaces. Fields it leaves out keep ROCK's values.
enum class CounterField : std::uint32_t
{
None = 0,
// loadedRounds replaces the slot's loaded count.
Loaded = 1u << 0,
// reserveRounds replaces the slot's reserve count.
Reserve = 1u << 1,
// label replaces the caliber label; an empty label shows none.
Label = 1u << 2,
// chamber replaces every chamber marker, including another owner's.
Chamber = 1u << 3,
// color replaces the counter style's digit colour.
Color = 1u << 4,
// The weapon shows no ammo counter.
Hidden = 1u << 5,
};
inline constexpr std::uint32_t kKnownCounterFields = 0x3F;
inline constexpr std::uint32_t kMaxCounterPresentationLeaseFrames = 4;
inline constexpr std::uint32_t kCounterLabelCapacity = 32;

/*
* 2.1. What a consumer that owns a weapon's ammunition shows on that
* weapon's ammo counter, in every counter style. fields (CounterField)
* names what it replaces. label is UTF-8, terminated inside the array.
* color is 0 to 1 per channel.
*/
struct CounterPresentation
{
std::uint32_t size{ sizeof(CounterPresentation) };
std::uint32_t version{ 1 };
std::uint32_t fields{ 0 };
std::uint32_t loadedRounds{ 0 };
std::uint32_t reserveRounds{ 0 };
ChamberMarker chamber{ ChamberMarker::None };
float color[3]{ 1.0f, 1.0f, 1.0f };
char label[kCounterLabelCapacity]{};
};
// setInventoryDrawPose: how old a reported pose may be when ROCK reveals
// the weapon.
inline constexpr std::uint32_t kMaxDrawPoseAgeFrames = 3;

// Permission bits are local to this interface major. Discovery grants none.
enum class Permission : std::uint32_t { Read = 1, Write = 2 };
inline constexpr std::uint32_t kSupportedPermissions = 3;

/*
* Per-weapon calls take weaponSlot < kMaxWeaponSlots (InvalidArgument
* otherwise). A slot ROCK does not publish yet returns TargetUnavailable.
* Slot 1 serves weapon state, grip, classification and emitters.
* Game thread unless noted.
*/
struct Api
{
static constexpr InterfaceId interfaceId = kInterfaceId;
static constexpr std::uint32_t majorVersion = kMajor;
static constexpr std::uint32_t minorVersion = kMinor;
// Read.
Status(ROCK_CALL* getWeaponState)(OwnerToken owner, std::uint32_t weaponSlot, WeaponState* outState) noexcept;
Status(ROCK_CALL* getGrip)(OwnerToken owner, std::uint32_t weaponSlot, Grip* outGrip) noexcept;
Status(ROCK_CALL* getClassification)(OwnerToken owner, std::uint32_t weaponSlot, Classification* outClassification) noexcept;
// Read. outCount is the weapon's emitter count; min(capacity, count)
// records are copied.
Status(ROCK_CALL* copyEmitters)(OwnerToken owner, std::uint32_t weaponSlot, Emitter* outEmitters, std::uint32_t capacity, std::uint32_t* outCount) noexcept;
Status(ROCK_CALL* getCompositionState)(OwnerToken owner, std::uint32_t weaponSlot, CompositionState* outState) noexcept;
Status(ROCK_CALL* copyCompositionEntries)(OwnerToken owner, std::uint32_t weaponSlot, CompositionEntry* outEntries, std::uint32_t capacity, std::uint32_t* outCount) noexcept;
Status(ROCK_CALL* getAuthoredGripPose)(OwnerToken owner, std::uint32_t weaponSlot, AuthoredGripPose* outPose) noexcept;
Status(ROCK_CALL* getScopeSightState)(OwnerToken owner, std::uint32_t weaponSlot, ScopeSightState* outState) noexcept;
// Write to set or clear the owner's lease (OwnerConflict while another
// owner holds it); Read for the current authority.
Status(ROCK_CALL* setHandlingAuthority)(OwnerToken owner, const HandlingRequest* request) noexcept;
Status(ROCK_CALL* clearHandlingAuthority)(OwnerToken owner) noexcept;
Status(ROCK_CALL* getHandlingAuthority)(OwnerToken owner, HandlingAuthority* outAuthority) noexcept;
// Read. Capture immediately before requestInventoryEquip.
Status(ROCK_CALL* captureInventoryWeapon)(OwnerToken owner, std::uint32_t baseFormId, std::uint32_t stackIndex, InventoryWeapon* outItem) noexcept;
// Write. Equips into the requested physical hand, replacing the weapon
// that hand fires or carries (it returns to the inventory); a weapon
// the other hand holds stays there. A destination busy with anything
// else is refused. One switch may be outstanding; RequestQueued is
// admission, not success.
Status(ROCK_CALL* requestInventoryEquip)(OwnerToken owner, const EquipRequest* request, std::uint64_t* outCommandId) noexcept;
// Read. The latest 64 terminal results are kept; inspect flags even
// when the switch fails.
Status(ROCK_CALL* getInventoryEquipResult)(OwnerToken owner, std::uint64_t commandId, EquipResult* outResult) noexcept;
// Write. Accepted only before the outgoing removal or native equip;
// AlreadyCommitted afterwards, and ROCK finishes the cleanup.
Status(ROCK_CALL* cancelInventoryEquip)(OwnerToken owner, std::uint64_t commandId) noexcept;
// Read, any thread; for a native pickup interceptor. outMatches is 1
// only while ROCK acquires exactly this reference and count for an
// equip, on the acquiring thread. It is intent, not a promise that
// the equip succeeds.
Status(ROCK_CALL* isEquipPickup)(OwnerToken owner, std::uint32_t referenceFormId, std::uint32_t count, std::uint32_t* outMatches) noexcept;
// Any thread.
Status(ROCK_CALL* getSample)(OwnerToken owner, Sample* outSample) noexcept;
// Write. Returns the weapon in weaponSlot to the inventory from its own
// hand, synchronously; the other slot's weapon stays in its hand (a
// slot-1 weapon then moves to slot 0). expectedFormId must name the
// slot's weapon (TargetInvalid otherwise); an empty slot returns
// TargetUnavailable and Busy waits for an equip switch to finish.
Status(ROCK_CALL* unequipWeapon)(OwnerToken owner, std::uint32_t weaponSlot, std::uint32_t expectedFormId) noexcept;
// Read. Where a firearm held by hand sits this frame: ROCK's fixed
// controller-to-weapon aim basis on that hand's filtered controller,
// the same for every firearm and independent of what is equipped.
// Scale is 1. TargetUnavailable while the controller frame is unknown.
Status(ROCK_CALL* getFiringAimWorld)(OwnerToken owner, Hand hand, Transform* outWorld) noexcept;
// Write. Replaces this owner's set of inventory weapons kept ready to
// equip: ROCK keeps each firearm's native animation subgraph loaded,
// so requestInventoryEquip of it does not wait on the engine's
// first-use load (about half a second per weapon after a game load).
// items are captureInventoryWeapon records; count 0 clears the set.
// Other weapon types are accepted and need no warming. ROCK loads one
// weapon at a time in the background, reloads after a race or
// power-armor change, and drops the set when the owner unregisters
// or physics shuts down: send it again when the Sample's world,
// skeleton or provider generation changes. TargetUnavailable (nothing changed) when an item no longer
// matches its inventory stack; CapacityFull above
// kMaxWarmInventoryWeapons across owners. Game thread.
Status(ROCK_CALL* setWarmInventoryWeapons)(OwnerToken owner, const InventoryWeapon* items, std::uint32_t count) noexcept;
// Write. requestInventoryEquip for a weapon the consumer shows in
// the hand at getFiringAimWorld until ROCK reveals it (a holster
// draw): when ROCK seats the firearm in that hand, the weapon
// continues from that pose and the hand from its tracked pose, and
// both ease into the grip instead of snapping. A consumer whose
// stand-in is elsewhere reports it with setInventoryDrawPose. Results
// as requestInventoryEquip.
Status(ROCK_CALL* requestInventoryDraw)(OwnerToken owner, const EquipRequest* request, std::uint64_t* outCommandId) noexcept;
// Write. While an owner holds the block (blocked nonzero), an empty
// slot-1 weapon dry-fires on its trigger instead of starting a reload;
// its reload button still reloads. One owner at a time (OwnerConflict
// otherwise); it ends with 0 or the owner's loss. The game's own
// automatic reload call sites are not ROCK's and stay untouched.
Status(ROCK_CALL* setAutomaticReloadBlocked)(OwnerToken owner, std::uint32_t blocked) noexcept;
// Write. Shows marker beside the ammo counter of the weapon in
// weaponSlot for 1 to kMaxChamberMarkerLeaseFrames frames; renew it
// each frame. It ends with the lease, so it goes away by itself when
// the owner stops. None clears it. One owner per slot (OwnerConflict
// otherwise, until the holder clears it or its lease runs out).
Status(ROCK_CALL* setChamberMarker)(OwnerToken owner, std::uint32_t weaponSlot, ChamberMarker marker, std::uint32_t leaseFrames) noexcept;
// Read. The key for the weapon's sources, drives, part targets, grab points
// and input gestures, 0 with no weapon. WeaponState's generation key names the
// weapon's colliders, so it is 0 until they are built, about a second after an
// equip; this one works from the moment the weapon is drawn, and it changes to
// the generation key when they arrive. On that change source keys stay valid
// and what you registered follows; name the new key from then on.
Status(ROCK_CALL* getInteractionKey)(OwnerToken owner, std::uint32_t weaponSlot, std::uint64_t* outKey) noexcept;
// Write. For the owner's requestInventoryDraw command whose firearm
// ROCK has not revealed yet: where the consumer shows the weapon this
// frame (world units; scale is ignored). Send it every frame while the
// stand-in is shown. The reveal then continues from the latest pose
// sent within the last kMaxDrawPoseAgeFrames frames, carried with the
// hand, instead of from the firing aim, so a stand-in still on its way
// from a holster hands over without a jump. RequestNotFound once ROCK
// has revealed the weapon, for melee and for any other command;
// TargetUnavailable while the hand's controller frame is unknown.
Status(ROCK_CALL* setInventoryDrawPose)(OwnerToken owner, std::uint64_t commandId, const Transform* weaponWorld) noexcept;
// 2.1. Write. Takes the ammo counter of the weapon in weaponSlot for 1
// to kMaxCounterPresentationLeaseFrames frames; renew it each frame. It
// ends with the lease, so the counter returns to ROCK's values by
// itself when the owner stops. Null or fields 0 clears it. One owner
// per slot (OwnerConflict otherwise, until the holder clears it or its
// lease runs out). A presentation with Chamber wins over every
// setChamberMarker lease of that slot.
Status(ROCK_CALL* setCounterPresentation)(OwnerToken owner, std::uint32_t weaponSlot, const CounterPresentation* presentation, std::uint32_t leaseFrames) noexcept;
};
}
#pragma pack(pop)