Grab API
Interface ID 4, version 2.2 (2.1, ROCK 1.0.3, adds requestInventoryItemGrab; 2.2, ROCK 1.0.4, adds requestHeldInventoryStash and getHeldBodyTouch). A mod built against these headers needs ROCK 1.0.4 or newer; request minor 1 when you call neither. Mods built against 2.0 and 2.1 keep working. Include <ROCK/Grab.h>. Namespace rock::api::grab. Permissions: Read (1), Write (2). Grab and release commands, hand interaction state, hand reservations, held placement, default grab poses, guided held objects, reference and power-armor queries, and the grab event callback. The References interface (10) is retired; its queries are here.
Entry points
| Function | Permission | Thread | Purpose |
|---|---|---|---|
requestForceGrab | Write | Game | Queues a grab of a target body or reference into a hand. |
requestForceRelease | Write | Game | Queues a release, optionally with a velocity. |
requestThrownDrop | Write | Game | Queues a thrown drop with a velocity. |
requestPowerArmorGrab | Write | Game | Queues a grab of a power armor frame's hand point, within kMaxPowerArmorGrabDistanceGame (32). |
requestInventoryGrab | Write | Game | Queues putting an item of baseFormId from the player's inventory into the hand. |
getInteractionCommandResult | Read | Game | The outcome of a command; the latest kMaxCommandResults (64) are kept. |
cancelInteractionCommand | Write | Game | Cancels a queued command. |
getHandInteractionState | Read | Any, including F4SE tasks | A value copy of the hand's latest published state. |
getHandTargetDetails | Read | Game | The hand state plus the touched reference, collision layer, anchor, normal, mesh part and power armor point. |
acquireHandReservation | Write | Game | Reserves the offhand of a weapon. |
renewHandReservation | Write | Game | Renews the reservation lease. |
releaseHandReservation | Write | Game | Ends the reservation. |
getHandReservationState | Read | Game | The current reservation. |
getHeldPlacementState | Read | Game | Both hands' held loose objects and the physical right-stick click. |
submitHeldPlacementIntent | Write | Game | Reserves the click and optionally asks ROCK to place the held object. |
clearHeldPlacementIntent | Write | Game | Withdraws the intent; never thaws a completed placement. |
setDefaultGrabPoses | Write | Game | Right and left default poses for a base form. |
clearDefaultGrabPoses | Write | Game | Removes them; clearing an absent entry is Ok. |
setHeldObjectTarget | Write | Game | Guides the held loose reference toward a target pose for 1 or 2 frames. |
clearHeldObjectTarget | Write | Game | Returns the hand to ordinary grabbing. |
getHeldObjectPose | Read | Game | The solved body pose at the reference root. |
queryReferenceInteraction | Read | Game | Base form, activation block, open state and furniture use of a reference. |
queryPowerArmorTarget | Read | Game | The power armor frame, wearer and the two armor hand points. |
setEventCallback | Read | Game | Sets the owner's grab event callback. |
clearEventCallback | Read | Game | Removes it. |
getSample | Read | Any | Identity of the current publication. |
driveReleasedObject | Write | Game | Glides a loose reference no ROCK hand holds onto a world root, still dynamic and collidable; call every frame while gliding. Busy while a hand holds it. |
requestInventoryItemGrab | Write | Game | 2.1. Queues putting one item of baseFormId, from the stack uniqueId names, into the hand you name. |
requestHeldInventoryStash | Write | Game | 2.2. Queues putting the loose reference a hand holds into the player's inventory, as the shoulder stash does. |
getHeldBodyTouch | Read | Game | 2.2. Which parts of the player's body the held loose reference touches this frame. |
Commands
The seven request... functions queue a command (up to kMaxQueuedCommands, 32) and return its id; poll getInteractionCommandResult. Nonzero generation fields in a request must match ROCK's current ones; zero skips that guard. InteractionCommandResult reports state (Queued, Succeeded, Rejected, Cancelled), failure (InteractionFailure), stage (Accepted, Queued, Committed, Applied, Terminal) and the accepted, committed and applied frames.
requestInventoryGrab puts an aid item or a throwable from the player's inventory into a free hand ROCK picks (hand must be None). Since 2.2 it refuses a grenade or mine with FeatureDisabled while the player has Immersive Grenades off: equip the item instead, so the game throws it. requestInventoryItemGrab (2.1) puts one item into the hand you request (Right or Left); a busy or disabled hand is rejected with HandBusy or HandDisabled and never swapped for the other hand. uniqueId selects the stack by its ExtraUniqueID, the value TESContainerChangedEvent reports; 0 takes a stack with nothing worn, else a worn stack's spare copy. The copy the player wears (the equipped weapon, worn armor) is never taken; with only that copy owned the command is rejected with TargetUnavailable. Any playable item with a world model is accepted, armor included. The item is dropped at the hand and grabbed there; a grab that cannot complete returns it to the inventory. It is a ForceGrab command: getInteractionCommandResult reports the dropped reference as targetFormId. ROCK shows no notification for it; your mod presents the outcome.
requestHeldInventoryStash (2.2) puts the loose reference targetFormId, held by hand alone, into the player's inventory as ROCK's shoulder stash does: the hand lets go without throw velocity, Storage stash converters see the item first, and native activation runs its scripts. targetFormId is required. It is a ForceRelease command, rejected with HandNotHolding when the hand holds nothing, HeldObjectMismatch when it holds another reference, HandBusy when the other hand holds the same reference, and TargetUnavailable for what the shoulder stash refuses (a body, an actor, a non-playable item, an armed grenade). The equipped weapon and surface latches are never held objects, so they are never stashed. When native pickup refuses the item after the hand let go, the command is Rejected with TargetUnavailable and the reference stays in the world at the hand.
Held object touching the body
getHeldBodyTouch(owner, hand, touch) (2.2) reports which parts of the player's body the visual mesh of the loose reference hand holds touches this frame, with the overlap test ROCK's immersive aid uses against the player's body colliders. zoneMask has bit 1 << collision::BodyZoneKind set for each touched zone; the holding hand's own zone never counts. referenceFormId is the held reference, frameIndex the publication's Sample frame and gripSequence the hand's grip sequence, so a caller timing a press can tell a new grab from the same one. HandUnavailable while the hand holds no loose reference; TargetUnavailable while its mesh or the body colliders are not ready.
Hand state
Check HandInteractionFlag::Valid. phase is Idle, Touching, Selecting, Pulling, Catching, Holding, Releasing, StashCandidate or ConsumeCandidate. Primary and Offhand describe the hand's role for the primary weapon. FiringGrip, PartGrip, PartCarry and NativeWeaponCarry describe the equipped weapon the hand holds, of either slot, and targetFormId names it; the second weapon's hand reports FiringGrip | NativeWeaponCarry. The stateSequence, targetSequence, gripSequence and releaseSequence advance only when that part of the hand changes. Other flags: LooseObject, LooseWeapon, InputSuppressed, CollisionAvailable, TransitionSuppressed, HeldBodyListTruncated, TouchGrab, FixedSurfaceLatch, GlobalSurfaceLatch, SurfaceAnchorValid, MeshSurfaceAnchor, MeshFingerPose, MeshCollisionFallback, DynamicOtherHandContact, DynamicWeaponContact, DynamicWeaponPairSuppressed, RockGripActive, AttachOnly.
Hand reservation
Reserves one hand for 1 to kMaxReservationLeaseFrames (120) frames. ReloadReserved stops that hand from taking a support grip on the weapon in weaponSlot; ReloadPoseOverride and Normal are the other kinds. One owner at a time (OwnerConflict). The hand must be that weapon's offhand (HandUnavailable otherwise); the reservation applies only while that hand is the offhand. Slot 1 returns TargetUnavailable. Expiry, generation changes and owner loss end it; poll getHandReservationState (active 0).
Held placement
Read getHeldPlacementState and submit its unchanged frameToken and sample with submitHeldPlacementIntent in the same phase (Animation BeforeRock preferred). The intent expires on the next ROCK update; one owner per update (Busy for a competing owner). ReserveRightClick and ReserveLeftClick each cover that hand's whole press and release while it holds an eligible object; the other hand's click stays free. Anchor names a held reference in formId and needs the click of a hand holding it reserved: ROCK places it as a native fixed placement while that reservation continues and it still touches a fixed surface, validating the hands that hold it, its lifetime and its whole body set; only those hands let go. The equipped weapon's press stays with its bipod: TimeEquippedWeaponHold lets an add-on time that press, and AnchorEquippedWeapon (with TimeEquippedWeaponHold and FixedSurfaceContact, naming equippedWeapon.formId) moves the weapon from the player to a native fixed placement at its current pose. Bit 1 (one shared click reservation) is retired. Acceptance is not completion: lastRequestToken and lastResult (Pending, Anchored, Rejected) report it.
Default grab poses
DefaultGrabPoses holds a base form's right and left DefaultHandPose (flags Present/FingerValues/FingerJoints, translateGame, row-major rotate, fingerValues[5], fingerJointValues[15]), relative to the hand's grab authority proxy. They fill missing per-hand saved offsets for loose non-weapons and throwables; authored poses and firearm or melee attachment keep priority. One owner per base form, 64 forms in all; a competing owner gets OwnerConflict, CapacityFull never evicts. Nothing is written to disk.
Held object target
HeldObjectTarget guides the currently held loose reference toward rootWorld through ROCK's finite-force grab constraint; it stays dynamic and collidable. Supply the current sample (at most one frame old) and the hand's gripSequence; leaseFrames 1 or 2. One owner per hand; two-handed, fixed and loose-firearm holds are refused. connectedWeaponFormId and connectedWeaponGeneration, when nonzero, suppress only the collision of the weapon in connectedWeaponSlot with the object (socket insertion); slot 1 returns TargetUnavailable. HandUnavailable means the observed grab no longer owns that hand.
Events
setEventCallback calls the callback synchronously on the producing thread with one Event: kind (SelectionLocked, PullStarted, PullArrived, PullCatchAttempt, PullCatchSucceeded, GrabCommitted, HeldImpact, Released, TwoHandStarted, TwoHandStopped, StashCandidate, ConsumeCandidate, Stashed, Consumed, LootStarted, LootCompleted, SelectionUnlocked), frame, generations, hand, form, bodies, layer, position, velocity, mass, speed and an intensity hint. Calling ROCK inside the callback returns Busy; a faulting callback revokes its owner. Follow lasting state through getHandInteractionState and its sequences. EventKind 100-104, used only by the removed event streams, are retired.
Declarations
Complete public declarations: ROCK/Grab.h
#pragma once
#include "Abi.h"
#include "Touch.h"
#pragma pack(push, 8)
namespace rock::api::grab {
inline constexpr InterfaceId kInterfaceId = InterfaceId::Grab;
inline constexpr std::uint32_t kMajor = 2;
inline constexpr std::uint32_t kMinor = 2;
inline constexpr std::uint32_t kMaxQueuedCommands = 32;
inline constexpr std::uint32_t kMaxCommandResults = 64;
inline constexpr std::uint32_t kMaxReservationLeaseFrames = 120;
inline constexpr std::uint32_t kPowerArmorPointCount = 2;
inline constexpr float kMaxPowerArmorGrabDistanceGame = 32.0f;
inline constexpr std::uint32_t kNoBody = 0x7FFF'FFFF;
// 5 (External) is retired with external body registration; never reuse.
enum class BodyContactTargetKind : std::uint32_t
{
Unknown = 0,
Hand = 1,
Weapon = 2,
HeldObject = 3,
Body = 4,
WorldSurface = 6,
DynamicProp = 7,
Actor = 8,
QueryOnly = 9,
};
// ------------------------------------------------------------------
// Interaction commands
// ------------------------------------------------------------------
enum class InteractionCommandKind : std::uint32_t
{
Unknown = 0,
ForceGrab = 1,
ForceRelease = 2,
ThrownDrop = 3,
};
enum class InteractionCommandState : std::uint32_t
{
Unknown = 0,
Queued = 1,
Succeeded = 2,
Rejected = 3,
Cancelled = 4,
};
enum class InteractionFailure : std::uint32_t
{
None = 0,
ProviderNotReady = 1,
PhysicsWritesBlocked = 2,
OwnerNotRegistered = 3,
InvalidRequest = 4,
StaleWorldGeneration = 5,
StaleSkeletonGeneration = 6,
StaleProviderGeneration = 7,
TargetMissing = 8,
TargetUnavailable = 9,
TargetBodyMissing = 10,
TargetAlreadyOwned = 11,
HandInvalid = 12,
HandDisabled = 13,
HandBusy = 14,
HandNotHolding = 15,
HeldObjectMismatch = 16,
};
enum class CommandStage : std::uint32_t
{
Unknown = 0,
Accepted = 1,
Queued = 2,
Committed = 3,
Applied = 4,
Terminal = 5,
};
enum class ForceGrabFlag : std::uint32_t
{
None = 0,
UsePreferredGrabPointGame = 1u << 0,
};
enum class ForceReleaseFlag : std::uint32_t
{
None = 0,
ImmediateCollisionRestore = 1u << 0,
RequireMatchingTarget = 1u << 1,
UseVelocityHavok = 1u << 2,
};
enum class ThrownDropFlag : std::uint32_t
{
None = 0,
ImmediateCollisionRestore = 1u << 0,
RequireMatchingTarget = 1u << 1,
UseVelocityHavok = 1u << 2,
};
// The generation fields of a request guard it; zero skips that guard.
struct ForceGrabRequest
{
std::uint32_t size{ sizeof(ForceGrabRequest) };
std::uint32_t version{ 1 };
Hand hand{ Hand::None };
std::uint32_t flags{ 0 };
std::uint32_t targetFormId{ 0 };
std::uint32_t targetBodyId{ kNoBody };
std::uint32_t worldGeneration{ 0 };
std::uint32_t skeletonGeneration{ 0 };
std::uint32_t providerGeneration{ 0 };
float maxDistanceGame{ 0.0f };
float preferredGrabPointGame[3]{};
};
struct ForceReleaseRequest
{
std::uint32_t size{ sizeof(ForceReleaseRequest) };
std::uint32_t version{ 1 };
Hand hand{ Hand::None };
std::uint32_t flags{ 0 };
std::uint32_t targetFormId{ 0 };
std::uint32_t targetBodyId{ kNoBody };
std::uint32_t worldGeneration{ 0 };
std::uint32_t skeletonGeneration{ 0 };
std::uint32_t providerGeneration{ 0 };
float linearVelocityHavok[3]{};
float angularVelocityRadiansPerSecond[3]{};
};
struct ThrownDropRequest
{
std::uint32_t size{ sizeof(ThrownDropRequest) };
std::uint32_t version{ 1 };
Hand hand{ Hand::None };
std::uint32_t flags{ 0 };
std::uint32_t targetFormId{ 0 };
std::uint32_t targetBodyId{ kNoBody };
std::uint32_t worldGeneration{ 0 };
std::uint32_t skeletonGeneration{ 0 };
std::uint32_t providerGeneration{ 0 };
float linearVelocityHavok[3]{};
float angularVelocityRadiansPerSecond[3]{};
};
struct PowerArmorGrabRequest
{
std::uint32_t size{ sizeof(PowerArmorGrabRequest) };
std::uint32_t version{ 1 };
ReferenceKey target{};
Hand hand{ Hand::None };
PowerArmorPoint point{};
float maxDistanceGame{ 0.0f };
};
// Puts an item of baseFormId from the player's inventory into the hand.
// 2.2: a grenade or mine is refused with FeatureDisabled while the player
// has ROCK's Immersive Grenades off; equip it instead.
struct InventoryGrabRequest
{
std::uint32_t size{ sizeof(InventoryGrabRequest) };
std::uint32_t version{ 1 };
Hand hand{ Hand::None };
std::uint32_t baseFormId{ 0 };
std::uint32_t worldGeneration{ 0 };
std::uint32_t skeletonGeneration{ 0 };
std::uint32_t providerGeneration{ 0 };
};
/*
* 2.1. Puts one item of baseFormId from the player's inventory into hand
* (Right or Left; ROCK never picks another hand). uniqueId names the
* stack by its ExtraUniqueID, as TESContainerChangedEvent reports it; 0
* takes a stack with nothing worn, else a worn stack's spare copy. The copy
* the player wears (equipped weapon, worn armor) is never taken. Any
* playable item with a world model is accepted. A grab that cannot
* complete returns the item to the inventory.
*/
struct InventoryItemGrabRequest
{
std::uint32_t size{ sizeof(InventoryItemGrabRequest) };
std::uint32_t version{ 1 };
Hand hand{ Hand::None };
std::uint32_t baseFormId{ 0 };
std::uint32_t uniqueId{ 0 };
std::uint32_t worldGeneration{ 0 };
std::uint32_t skeletonGeneration{ 0 };
std::uint32_t providerGeneration{ 0 };
};
/*
* 2.2. Puts the loose reference targetFormId, held by hand alone, into the
* player's inventory the way ROCK's shoulder stash does: the hand lets go
* without throw velocity, Storage stash converters see it first, and
* native activation runs its scripts. targetFormId is required; the
* equipped weapon, a surface latch, a body and a reference both hands hold
* are refused.
*/
struct HeldInventoryStashRequest
{
std::uint32_t size{ sizeof(HeldInventoryStashRequest) };
std::uint32_t version{ 1 };
Hand hand{ Hand::None };
std::uint32_t targetFormId{ 0 };
std::uint32_t worldGeneration{ 0 };
std::uint32_t skeletonGeneration{ 0 };
std::uint32_t providerGeneration{ 0 };
};
/*
* 2.2. Which parts of the player's body the mesh of the loose reference
* hand holds touches this frame: the overlap test ROCK's immersive aid
* uses, between the held object's visual mesh and the player's body
* colliders. zoneMask has bit (1 << collision::BodyZoneKind) set for each
* touched zone; the holding hand's own zone never counts. frameIndex is
* the current publication's Sample frameIndex; gripSequence is the hand's
* HandInteractionState gripSequence.
*/
struct HeldBodyTouch
{
std::uint32_t size{ sizeof(HeldBodyTouch) };
std::uint32_t version{ 1 };
Hand hand{ Hand::None };
std::uint32_t referenceFormId{ 0 };
std::uint64_t frameIndex{ 0 };
std::uint64_t gripSequence{ 0 };
std::uint32_t zoneMask{ 0 };
std::uint32_t reserved{ 0 };
};
struct InteractionCommandResult
{
std::uint32_t size{ sizeof(InteractionCommandResult) };
std::uint32_t version{ 1 };
std::uint64_t ownerToken{ 0 };
std::uint64_t commandId{ 0 };
InteractionCommandKind kind{ InteractionCommandKind::Unknown };
InteractionCommandState state{ InteractionCommandState::Unknown };
InteractionFailure failure{ InteractionFailure::None };
Hand hand{ Hand::None };
std::uint32_t targetFormId{ 0 };
std::uint32_t targetBodyId{ kNoBody };
std::uint64_t frameIndex{ 0 };
std::uint32_t worldGeneration{ 0 };
std::uint32_t skeletonGeneration{ 0 };
std::uint32_t providerGeneration{ 0 };
CommandStage stage{ CommandStage::Unknown };
InteractionFailure failureStage{ InteractionFailure::None };
std::uint64_t acceptedFrame{ 0 };
std::uint64_t committedFrame{ 0 };
std::uint64_t appliedFrame{ 0 };
};
// ------------------------------------------------------------------
// Hand interaction state
// ------------------------------------------------------------------
enum class HandInteractionPhase : std::uint32_t
{
Idle = 0,
Touching = 1,
Selecting = 2,
Pulling = 3,
Catching = 4,
Holding = 5,
Releasing = 6,
StashCandidate = 7,
ConsumeCandidate = 8,
};
// Primary and Offhand describe the hand's role for the primary weapon.
// FiringGrip, PartGrip, PartCarry and NativeWeaponCarry describe the
// equipped weapon the hand holds, of either slot; targetFormId names it.
// The second weapon's hand reports FiringGrip | NativeWeaponCarry.
enum class HandInteractionFlag : std::uint32_t
{
None = 0,
Valid = 1u << 0,
Primary = 1u << 1,
Offhand = 1u << 2,
LooseObject = 1u << 3,
LooseWeapon = 1u << 4,
FiringGrip = 1u << 5,
PartGrip = 1u << 6,
PartCarry = 1u << 7,
InputSuppressed = 1u << 8,
CollisionAvailable = 1u << 9,
TransitionSuppressed = 1u << 10,
HeldBodyListTruncated = 1u << 11,
TouchGrab = 1u << 12,
FixedSurfaceLatch = 1u << 13,
GlobalSurfaceLatch = 1u << 14,
SurfaceAnchorValid = 1u << 15,
MeshSurfaceAnchor = 1u << 16,
MeshFingerPose = 1u << 17,
MeshCollisionFallback = 1u << 18,
DynamicOtherHandContact = 1u << 19,
DynamicWeaponContact = 1u << 20,
DynamicWeaponPairSuppressed = 1u << 21,
NativeWeaponCarry = 1u << 22,
RockGripActive = 1u << 23,
AttachOnly = 1u << 24,
};
// A value copy of the latest publication. The record carries its own
// frame, generations and per-hand sequences (state, target, grip,
// release), which advance only when that part of the hand changes.
struct HandInteractionState
{
std::uint32_t size{ sizeof(HandInteractionState) };
std::uint32_t version{ 1 };
std::uint64_t frameIndex{ 0 };
Hand hand{ Hand::None };
HandInteractionPhase phase{ HandInteractionPhase::Idle };
BodyContactTargetKind targetKind{ BodyContactTargetKind::Unknown };
std::uint32_t flags{ 0 };
std::uint64_t reservedTargetIdentity{ 0 };
std::uint32_t targetFormId{ 0 };
std::uint32_t primaryBodyId{ kNoBody };
std::uint32_t heldBodyCount{ 0 };
std::uint32_t heldBodyIds[8]{};
std::uint64_t stateSequence{ 0 };
std::uint64_t targetSequence{ 0 };
std::uint64_t gripSequence{ 0 };
std::uint64_t releaseSequence{ 0 };
std::uint32_t worldGeneration{ 0 };
std::uint32_t skeletonGeneration{ 0 };
std::uint32_t providerGeneration{ 0 };
std::uint32_t collisionGeneration{ 0 };
Point3 surfaceAnchorGame{};
touch::SurfaceGripMode surfaceGripMode{ touch::SurfaceGripMode::CollisionAnchor };
};
enum class TargetDetailFlag : std::uint32_t
{
Reference = 1u << 0,
Body = 1u << 1,
Anchor = 1u << 2,
Normal = 1u << 3,
MeshPart = 1u << 4,
ActivationBlocked = 1u << 5,
OpenState = 1u << 6,
FurnitureUse = 1u << 7,
PowerArmorClassification = 1u << 8,
PowerArmorFrame = 1u << 9,
PowerArmorActor = 1u << 10,
};
struct HandTargetDetails
{
std::uint32_t size{ sizeof(HandTargetDetails) };
std::uint32_t version{ 1 };
HandInteractionState handState{};
std::uint32_t referenceFormId{ 0 };
std::uint32_t referenceNativeHandle{ 0 };
std::uint32_t flags{ 0 };
std::uint32_t collisionLayer{ 0 };
Point3 anchorGame{};
Point3 normalGame{};
PowerArmorPoint powerArmorPoint{};
std::uint32_t sourceTriangleIndex{ 0xFFFF'FFFFu };
char collisionNodeName[64]{};
char meshPartName[64]{};
};
// ------------------------------------------------------------------
// Hand reservation
// ------------------------------------------------------------------
enum class HandReservationKind : std::uint32_t
{
Normal = 0,
// The hand may not take a support grip on the reserved weapon.
ReloadReserved = 1,
ReloadPoseOverride = 2,
};
/*
* One owner reserves one hand at a time. The reserved hand must be the
* offhand of the weapon in weaponSlot (HandUnavailable otherwise); while
* the roles change, the reservation applies only while its hand is that
* offhand. The lease runs 1 to kMaxReservationLeaseFrames frames from
* acquire or renew. Expiry, generation changes and owner loss end it;
* getHandReservationState then reports it inactive.
*/
struct HandReservationRequest
{
std::uint32_t size{ sizeof(HandReservationRequest) };
std::uint32_t version{ 1 };
std::uint32_t weaponSlot{ 0 };
Hand hand{ Hand::None };
HandReservationKind reservation{ HandReservationKind::Normal };
std::uint32_t leaseFrames{ 0 };
std::uint32_t worldGeneration{ 0 };
std::uint32_t skeletonGeneration{ 0 };
std::uint32_t providerGeneration{ 0 };
};
struct HandReservationState
{
std::uint32_t size{ sizeof(HandReservationState) };
std::uint32_t version{ 1 };
Hand hand{ Hand::None };
HandReservationKind reservation{ HandReservationKind::Normal };
std::uint64_t ownerToken{ 0 };
std::uint64_t expiresAfterFrame{ 0 };
std::uint32_t active{ 0 };
std::uint32_t remainingFrames{ 0 };
std::uint32_t worldGeneration{ 0 };
std::uint32_t skeletonGeneration{ 0 };
std::uint32_t providerGeneration{ 0 };
std::uint32_t weaponSlot{ 0 };
};
// ------------------------------------------------------------------
// Held placement (each hand's stick click places what that hand holds; the
// equipped weapon's is its firing hand's click)
// ------------------------------------------------------------------
enum class HeldPlacementFlag : std::uint32_t { LooseObject = 1, FixedSurfaceContact = 2, Weapon = 4 };
struct HeldPlacementHand
{
std::uint32_t formId{ 0 };
std::uint32_t flags{ 0 };
};
enum class PlacementResult : std::uint32_t { None, Pending, Anchored, Rejected };
// One hand's physical Axis0 click (32), sampled without consuming it.
struct HeldPlacementButton
{
std::uint32_t available{ 0 };
std::uint32_t held{ 0 };
std::uint32_t pressed{ 0 };
std::uint32_t ageMilliseconds{ 0 };
};
// right and left are what each hand holds, with Weapon when the held
// reference's base form is a weapon; rightButton and leftButton are those
// hands' clicks. A hand's click acts only for that hand. equippedWeapon is
// the primary equipped weapon's base form while it can be placed, with
// Weapon, and FixedSurfaceContact while it rests on or touches the fixed
// world; equippedWeaponHand is the hand whose click is the bipod's: the
// firing hand while both hands hold it, the hand holding it otherwise, and
// the last such hand while no hand does.
// It is empty, with Hand::None, with no such weapon, during an equip
// transition, while a weapon placement finishes, and while the bipod holds
// the weapon hands-free (ROCK's own click retires that one).
struct HeldPlacementState
{
std::uint32_t size{ sizeof(HeldPlacementState) };
std::uint32_t version{ 1 };
std::uint64_t frameToken{ 0 };
Sample sample{};
HeldPlacementHand right{};
HeldPlacementHand left{};
HeldPlacementButton rightButton{};
HeldPlacementButton leftButton{};
std::uint64_t lastRequestToken{ 0 };
PlacementResult lastResult{ PlacementResult::None };
std::uint32_t lastRequestFormId{ 0 };
HeldPlacementHand equippedWeapon{};
Hand equippedWeaponHand{ Hand::None };
};
// Bit 1 (one shared click reservation) is retired; never reuse it.
enum class PlacementIntentFlag : std::uint32_t {
Anchor = 2,
TimeEquippedWeaponHold = 4,
AnchorEquippedWeapon = 8,
ReserveRightClick = 16,
ReserveLeftClick = 32,
};
/*
* Read the state and submit its unchanged frameToken and sample in the
* same phase (Animation BeforeRock preferred). The intent expires on the
* next ROCK update; one owner per update (Busy for a competing owner).
* ReserveRightClick and ReserveLeftClick each cover that hand's whole press
* and release while the hand holds an eligible object; the other hand's
* click stays free. Anchor names a held reference in formId and needs the
* click of a hand holding it reserved: ROCK places it only while that
* reservation continues and it still touches a fixed surface. Acceptance
* is not completion: lastRequestToken and lastResult report the native
* placement. ROCK validates the hands that hold the reference, its
* lifetime and its whole body set, releases those hands' constraints and
* saves a native fixed placement; static parts stay static, and the other
* hand keeps what it holds. Pending work cancels on lost intent, owner or
* world. Clearing or unregistering never thaws a completed placement.
*
* The equipped weapon's press stays with its bipod, so never reserve
* equippedWeaponHand's click for that weapon. TimeEquippedWeaponHold says
* the add-on is timing the press: a press still latches the bipod at once,
* but a latched weapon unlatches when the button comes up instead of when
* it goes down, so a hold can place the pose it rests in.
* AnchorEquippedWeapon names equippedWeapon.formId in formId and needs
* TimeEquippedWeaponHold and FixedSurfaceContact, without Anchor or a
* reservation of equippedWeaponHand's click. ROCK lets go of the weapon and
* moves it from the player to a native fixed placement at its current pose,
* reported through the same lastRequestToken and lastResult;
* lastRequestFormId stays the base form. Once the weapon has left the
* player the placement no longer cancels.
*/
struct HeldPlacementIntent
{
std::uint32_t size{ sizeof(HeldPlacementIntent) };
std::uint32_t version{ 1 };
std::uint64_t frameToken{ 0 };
Sample sample{};
std::uint32_t formId{ 0 };
std::uint32_t flags{ 0 };
};
// ------------------------------------------------------------------
// Default grab poses per base form
// ------------------------------------------------------------------
enum class DefaultPoseFlag : std::uint32_t { Present = 1, FingerValues = 2, FingerJoints = 4 };
// Pose relative to the physical hand's grab authority proxy: game-unit
// translation, row-major proper orthonormal rotation, unit scale. Finger
// order thumb, index, middle, ring, pinky; joints proximal to distal.
// Thumb values accept [0,2], other fingers [0,1].
struct DefaultHandPose
{
std::uint32_t flags{ 0 };
float translateGame[3]{};
float rotate[9]{ 1, 0, 0, 0, 1, 0, 0, 0, 1 };
float fingerValues[5]{};
float fingerJointValues[15]{};
};
/*
* Default poses fill missing per-hand saved offsets on ROCK's saved-offset
* path (loose non-weapons and throwables); authored poses and firearm or
* melee attachment keep priority. Present is required for any hand flags;
* FingerJoints requires FingerValues; at least one hand must be present.
* One owner per base form, 64 forms in all; replacing the same owner's
* pair is atomic, a competing owner gets OwnerConflict, CapacityFull never
* evicts. Changes affect later grabs only. Nothing is written to disk;
* entries retire with their owner.
*/
struct DefaultGrabPoses
{
std::uint32_t size{ sizeof(DefaultGrabPoses) };
std::uint32_t version{ 1 };
std::uint32_t baseFormId{ 0 };
DefaultHandPose right{};
DefaultHandPose left{};
};
// ------------------------------------------------------------------
// Held object target
// ------------------------------------------------------------------
/*
* Guides the currently held loose reference through ROCK's finite-force
* grab constraint; it stays dynamic and collidable (no teleport, keyframe
* or hide). rootWorld is in game units with Ni basis rows; its scale must
* equal the reference's scale. Supply the current Grab sample (at most one
* frame old) and gripSequence. One owner per hand; leaseFrames 1 to 2.
* Release, a new grab, owner loss or expiry return the hand to ordinary
* grabbing. Two-handed, fixed and loose-firearm holds are refused.
* connectedWeaponFormId plus connectedWeaponGeneration, when nonzero, name
* the weapon in connectedWeaponSlot: while renewed only its collision
* pairs with this object are suppressed (insertion into a socket); zero
* both to restore.
*/
struct HeldObjectTarget
{
std::uint32_t size{ sizeof(HeldObjectTarget) };
std::uint32_t version{ 1 };
Hand hand{ Hand::None };
std::uint32_t referenceFormId{ 0 };
std::uint32_t leaseFrames{ 2 };
std::uint32_t connectedWeaponSlot{ 0 };
std::uint32_t connectedWeaponFormId{ 0 };
Transform rootWorld{};
Sample sample{};
std::uint64_t gripSequence{ 0 };
std::uint64_t connectedWeaponGeneration{ 0 };
};
// The solved rigid body pose reconstructed at the reference root, without
// render prediction.
struct HeldObjectPose
{
std::uint32_t size{ sizeof(HeldObjectPose) };
std::uint32_t version{ 1 };
Hand hand{ Hand::None };
std::uint32_t referenceFormId{ 0 };
std::uint32_t bodyId{ kNoBody };
Sample sample{};
std::uint64_t gripSequence{ 0 };
Transform rootWorld{};
};
/*
* Glides a loose reference no hand holds onto rootWorld (game units, Ni
* basis rows, the reference's own scale): each call sets this step's
* velocities of its dynamic bodies so the root closes the remaining gap
* with time constant approachSeconds (0.05 to 2). It stays dynamic and
* collidable; call every frame while gliding, stop calling to let it go.
* Progress reports the root's remaining distance and angle. Busy while a
* ROCK hand holds it; TargetInvalid when it has no dynamic body.
*/
struct ReleasedObjectDrive
{
std::uint32_t size{ sizeof(ReleasedObjectDrive) };
std::uint32_t version{ 1 };
ReferenceKey reference{};
std::uint32_t expectedBase{ 0 };
float approachSeconds{ 0.15f };
Transform rootWorld{};
};
struct ReleasedObjectProgress
{
std::uint32_t size{ sizeof(ReleasedObjectProgress) };
std::uint32_t version{ 1 };
float distanceGame{ 0.0f };
float angleRadians{ 0.0f };
};
// ------------------------------------------------------------------
// Reference queries
// ------------------------------------------------------------------
enum class NativeOpenState : std::uint32_t
{
NotApplicable = 0,
Open = 1,
Opening = 2,
Closed = 3,
Closing = 4,
};
struct ReferenceQuery
{
std::uint32_t size{ sizeof(ReferenceQuery) };
std::uint32_t version{ 1 };
std::uint32_t referenceFormId{ 0 };
std::uint32_t referenceNativeHandle{ 0 };
std::uint32_t worldGeneration{ 0 };
std::uint32_t skeletonGeneration{ 0 };
std::uint32_t providerGeneration{ 0 };
std::int32_t furnitureMarkerIndex{ 0 };
};
// frameIndex and worldGeneration are those at the time of the query.
struct ReferenceInteraction
{
std::uint32_t size{ sizeof(ReferenceInteraction) };
std::uint32_t version{ 1 };
std::uint32_t flags{ 0 };
std::uint32_t referenceFormId{ 0 };
std::uint32_t referenceNativeHandle{ 0 };
std::uint32_t baseFormId{ 0 };
std::uint32_t baseFormType{ 0 };
std::uint32_t activationBlocked{ 0 };
NativeOpenState openState{ NativeOpenState::NotApplicable };
std::uint32_t furnitureInUse{ 0 };
std::uint32_t furnitureInUseIncludingReservations{ 0 };
std::int32_t furnitureMarkerIndex{ 0 };
std::uint32_t worldGeneration{ 0 };
std::uint64_t frameIndex{ 0 };
};
struct PowerArmorPointPose
{
PowerArmorPoint point{};
std::uint32_t valid{ 0 };
Transform world{};
Transform frameLocal{};
};
struct PowerArmorTarget
{
std::uint32_t size{ sizeof(PowerArmorTarget) };
std::uint32_t version{ 1 };
ReferenceInteraction touchedReference{};
ReferenceInteraction frameReference{};
std::uint32_t flags{ 0 };
std::uint32_t actorFormId{ 0 };
PowerArmorPointPose points[kPowerArmorPointCount]{};
};
// ------------------------------------------------------------------
// Events
// ------------------------------------------------------------------
// 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;
// One grab event, passed to the event callback as it happens. Follow
// lasting state through HandInteractionState and its sequences.
struct Event
{
std::uint32_t size{ sizeof(Event) };
std::uint32_t kind{};
std::uint64_t frameIndex{};
std::uint32_t worldGeneration{};
std::uint32_t skeletonGeneration{};
std::uint32_t providerGeneration{};
Hand hand{ Hand::None };
std::uint32_t formId{};
std::uint32_t primaryBodyId{ kNoBody };
std::uint32_t secondaryBodyId{ kNoBody };
std::uint32_t collisionLayer{};
std::uint32_t flags{};
std::uint32_t sourceKind{};
float positionGame[3]{};
float velocityGame[3]{};
float mass{};
float speedGameUnitsPerSecond{};
float intensityHint{};
};
enum class EventKind : std::uint32_t
{
SelectionLocked = 1, PullStarted = 2, PullArrived = 3, PullCatchAttempt = 4, PullCatchSucceeded = 5,
GrabCommitted = 6, HeldImpact = 7, Released = 8, TwoHandStarted = 9, TwoHandStopped = 10,
StashCandidate = 11, ConsumeCandidate = 12, Stashed = 13, Consumed = 14, LootStarted = 15,
LootCompleted = 16, SelectionUnlocked = 17,
// 100-104 are retired; never reuse them.
};
// Synchronous observation on the producing thread. Calling ROCK inside
// the callback is forbidden.
using EventCallback = void(ROCK_CALL*)(const Event*, void*);
struct Api
{
static constexpr InterfaceId interfaceId = kInterfaceId;
static constexpr std::uint32_t majorVersion = kMajor;
static constexpr std::uint32_t minorVersion = kMinor;
// Game thread (Write). Commands queue; poll the outcome with
// getInteractionCommandResult.
Status(ROCK_CALL* requestForceGrab)(OwnerToken owner, const ForceGrabRequest* request, std::uint64_t* outCommandId) noexcept;
Status(ROCK_CALL* requestForceRelease)(OwnerToken owner, const ForceReleaseRequest* request, std::uint64_t* outCommandId) noexcept;
Status(ROCK_CALL* requestThrownDrop)(OwnerToken owner, const ThrownDropRequest* request, std::uint64_t* outCommandId) noexcept;
Status(ROCK_CALL* requestPowerArmorGrab)(OwnerToken owner, const PowerArmorGrabRequest* request, std::uint64_t* outCommandId) noexcept;
Status(ROCK_CALL* requestInventoryGrab)(OwnerToken owner, const InventoryGrabRequest* request, std::uint64_t* outCommandId) noexcept;
// Game thread; Read for the result, Write for cancel.
Status(ROCK_CALL* getInteractionCommandResult)(OwnerToken owner, std::uint64_t commandId, InteractionCommandResult* outResult) noexcept;
Status(ROCK_CALL* cancelInteractionCommand)(OwnerToken owner, std::uint64_t commandId) noexcept;
// Any thread (Read), including F4SE tasks: a value copy that grants no
// live pointer or write authority. Check Status and the Valid flag.
Status(ROCK_CALL* getHandInteractionState)(OwnerToken owner, Hand hand, HandInteractionState* outState) noexcept;
// Game thread (Read).
Status(ROCK_CALL* getHandTargetDetails)(OwnerToken owner, Hand hand, HandTargetDetails* outDetails) noexcept;
// Game thread; Write for acquire/renew/release, Read for the state.
Status(ROCK_CALL* acquireHandReservation)(OwnerToken owner, const HandReservationRequest* request) noexcept;
Status(ROCK_CALL* renewHandReservation)(OwnerToken owner, const HandReservationRequest* request) noexcept;
Status(ROCK_CALL* releaseHandReservation)(OwnerToken owner) noexcept;
Status(ROCK_CALL* getHandReservationState)(OwnerToken owner, HandReservationState* outState) noexcept;
// Game thread; Read for the state, Write for submit/clear.
Status(ROCK_CALL* getHeldPlacementState)(OwnerToken owner, HeldPlacementState* outState) noexcept;
Status(ROCK_CALL* submitHeldPlacementIntent)(OwnerToken owner, const HeldPlacementIntent* intent) noexcept;
Status(ROCK_CALL* clearHeldPlacementIntent)(OwnerToken owner) noexcept;
// Game thread (Write). Clear is idempotent when absent.
Status(ROCK_CALL* setDefaultGrabPoses)(OwnerToken owner, const DefaultGrabPoses* poses) noexcept;
Status(ROCK_CALL* clearDefaultGrabPoses)(OwnerToken owner, std::uint32_t baseFormId) noexcept;
// Game thread; Write for set/clear, Read for the pose. HandUnavailable
// means the observed grab no longer owns that hand.
Status(ROCK_CALL* setHeldObjectTarget)(OwnerToken owner, const HeldObjectTarget* target) noexcept;
Status(ROCK_CALL* clearHeldObjectTarget)(OwnerToken owner, Hand hand) noexcept;
Status(ROCK_CALL* getHeldObjectPose)(OwnerToken owner, Hand hand, HeldObjectPose* outPose) noexcept;
// Game thread (Read).
Status(ROCK_CALL* queryReferenceInteraction)(OwnerToken owner, const ReferenceQuery* query, ReferenceInteraction* outInteraction) noexcept;
Status(ROCK_CALL* queryPowerArmorTarget)(OwnerToken owner, const ReferenceQuery* query, PowerArmorTarget* outTarget) noexcept;
// Game thread (Read).
Status(ROCK_CALL* setEventCallback)(OwnerToken owner, EventCallback callback, void* userData) noexcept;
Status(ROCK_CALL* clearEventCallback)(OwnerToken owner) noexcept;
// Any thread. Identity of the current publication.
Status(ROCK_CALL* getSample)(OwnerToken owner, Sample* outSample) noexcept;
// Game thread (Write). outProgress may be null.
Status(ROCK_CALL* driveReleasedObject)(OwnerToken owner, const ReleasedObjectDrive* drive, ReleasedObjectProgress* outProgress) noexcept;
// 2.1. Game thread (Write). An InteractionCommandKind::ForceGrab command:
// poll it with getInteractionCommandResult.
Status(ROCK_CALL* requestInventoryItemGrab)(OwnerToken owner, const InventoryItemGrabRequest* request, std::uint64_t* outCommandId) noexcept;
// 2.2. Game thread (Write). An InteractionCommandKind::ForceRelease
// command: poll it with getInteractionCommandResult.
Status(ROCK_CALL* requestHeldInventoryStash)(OwnerToken owner, const HeldInventoryStashRequest* request, std::uint64_t* outCommandId) noexcept;
// 2.2. Game thread (Read). HandUnavailable while the hand holds no
// loose reference; TargetUnavailable while its mesh or the body
// colliders are not ready.
Status(ROCK_CALL* getHeldBodyTouch)(OwnerToken owner, Hand hand, HeldBodyTouch* outTouch) noexcept;
};
}
#pragma pack(pop)