Skip to content

feat: smoke a water pipe with your own hands in VR - grab the mouthpiece, the hose follows, it bubbles at your mouth and you breathe out the smoke - #580

Open
BoroBongo wants to merge 16 commits into
feature/mob-animationsfrom
feature/vr-water-pipe
Open

BoroBongo wants to merge 16 commits into
feature/mob-animationsfrom
feature/vr-water-pipe

Conversation

@BoroBongo

Copy link
Copy Markdown
Contributor

What

The water pipes (G2 Khorinis, and pipes in mods with the same hose parts) can be smoked with your own hands in VR:

  • Grab. You grab the mouthpiece and the hose bends with your hand. The model's own 5 hose links bend with CCD IK (HoseIk). If you pull further than the hose is long (1.33 m), the mouthpiece slips out and swings back.
  • At the mouth. While the mouthpiece is at your mouth, the pipe bubbles and smokes at the bowl in its loop, the same way it does for a smoking NPC (MobAnimationService hero use, from feat: mobs play their own animations, sounds and particles while they are used - the smithy rings, sparks and steams #578).
  • Taken away. After at least 0.8 s at the mouth, the smoke is held for 1 s, then you hear the breath out (the joint's SMOKE_JOINT) and see a cloud of LIGHTSMOKE in front of your face.
  • Busy. A pipe a living NPC is smoking can't be grabbed (VobService.IsUsedByOtherNpc). Nothing else happens, like the original: the scripts give the hero nothing at a water pipe.

Technical:

  • New port. IVrBackend.AddHandle builds a grab handle on a sub-node; the XRI backend implements it (GothicGrabInteractable.SetUpAsHandle, a bridge with trigger colliders). VrInteractable.CanGrab lets the game refuse a grab.
  • New files. VRWaterPipe (VR adapter, added by VRMobInteraction to mobs whose model ends a FLEX hose in BIP01 FLEXEND) and HoseIk.
  • The mouth. VRMouthSmoking (the mouth's smoking session, split out of VRMouth) talks to the pipe through IVrMouthSmokable. Eating and joints are unchanged.

Stacked on #578 (mob animations).

Why

Playtest: the water pipes next to Abuyin in Khorinis did nothing in VR, while NPCs smoke them.

How to test manually

  • G2 Khorinis harbour pipe, by day: grab the mouthpiece and the hose bends. Pull past the hose's length: it slips out and swings back.
  • Mouthpiece at the mouth: continuous bubbling and smoke at the bowl. Take it away: 1 s later the breath out and a cloud. Under 0.8 s: nothing.
  • At night, while Canthar or Hakon smoke: the mouthpiece can't be grabbed.
  • Save while an NPC smokes, then load: the pipe can be grabbed.
  • Walk away or change worlds with the mouthpiece at the mouth, then smoke a joint: no exception.
  • Regression: eat, drink and smoke a joint at the mouth; use levers, doors, chests and the anvil.

Save/load

Nothing is saved. The hero's use writes no mob state, and the pipe is free after a load.

Known gaps / follow-ups

  • Follow-up: build the grab handle from a prefab ("VR Handle XRI", next to "VR Ledge Anchor XRI"), not from AddComponent calls in XriBackend.AddHandle. That way its setup is visible in the Inspector and testable in the Lab scene. Prefabs must be made through Unity MCP.
  • An NPC can sit down at the pipe while the hero smokes it. The two share one animation; an edge case, left as is.
  • ADR: Docs/adr/2026-11-26-vr-water-pipe.md

🤖 Generated with Claude Code

BoroBongo and others added 16 commits November 26, 2026 20:17
…ct's name, so more than a joint can share it (VRMouth) - no behaviour change

- ExhaleSmoke(pfxName, ...) puffs any particle effect; TryExhaleSmoke picks the first one of a Humans.mds animation (the joint's t_JOINT_S0_2_Stand: LIGHTSMOKE) and warns, like before, when it has none

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ws out its smoke after a drag (IVrMouthSmokable) - nothing implements it yet

- IVrMouthSmokable (next to VRMouth): something smoked without being used up names the Humans.mds animation of its smoke and hears when one of its parts touches or leaves the mouth
- VRMouth: on enter such a part is no food; when it says it is smoked now, the smoke of that animation is puffed out after the drag delay (_smokeStartDelay), spread over 3 s; taken away before the drag ended, no smoke comes
- trigger events only, nothing per frame

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…owards the hand, pulled too far it slips out and swings back; not while an NPC smokes it (VRWaterPipe)

- VRWaterPipe (Adapters/Vob): added by VRMobInteraction.Start to a mob whose model ends BIP01 FLEX0..FLEX4 in BIP01 FLEXEND (checked once per built mob, mods' pipes too); a trigger on the mouthpiece (layer VobItemNoWorldCollision: hands and VRMouth see it, the world doesn't) is a handle of its own
- while held, HoseIk (CCD over the 5 links, limited turns, no allocations) bends the hose to the hand in LateUpdate; further away than the hose's length + 0.15 m, the grab is let go; released, the links swing back in 0.3 s (to the pose of the pipe's own animation while MobAnimator moves them), then the component is disabled again
- busy: mob state > 0 or an NPC at it (VobService.GetOtherMobUsers), checked on hover and grab, never polled
- a hand closing at the mouthpiece that caught the pipe's own collider takes the mouthpiece a frame later (IVrRig.TryGrabIntoHand) - the pipe isn't used
- ports: IVrBackend.AddHandle (XRI: VrInteractable + GothicGrabInteractable held without moving, kinematic, near and one hand only + bridge with the grab trigger), VrInteractable.CanGrab (asked by GothicGrabInteractable.IsSelectableBy for a new grab)
- nothing saved; no prefab changed (components and collider added in code)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
… like for an NPC and you blow out smoke, nothing else happens (VRWaterPipe, MobAnimationService)

- VRWaterPipe is an IVrMouthSmokable: the held mouthpiece at the mouth starts the hero's use (MobAnimationService.StartHeroUse: S0 -> S1 and its loop, PIPE_BUBBLES, FIRE_SMOKE at BIP01 FIRE); after the drag delay VRMouth blows out HUMANS S_SMOKE_S1's LIGHTSMOKE
- away from the mouth, let go, slipped out or culled: StopHeroUse(mob) - a new overload that only stops the hero's use of this mob (not an anvil whose dialog opened meanwhile)
- VRMouth: a part coming in again without having left (its exit was missed while culled) starts over
- like the original: no item is used, no script runs, nothing is saved
- Docs/mobs.md: the water pipe; ADR 2026-11-26-vr-water-pipe

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…uth - a bigger grab, the mouth meets it where the hand holds it

Playtest: the 7 cm grab was nearly impossible to hit, and holding it to the mouth did nothing (no mouth trigger
event) - the hose's end fell short of the hand, so its trigger never reached the mouth. Grab radius 15 cm; while held
the trigger sits where the hand holds the mouthpiece; the hose IK takes 10 iterations per frame (was 4).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
… mouth, and the smoke comes out with a breath when it's taken away

Playtest: the smoke came out of the mouth too early, while still drawing. Now the pipe works in its loop (bubbles,
smoke at the bowl) as long as the mouthpiece is at the mouth; taken away after at least 0.8 s, a breath out
(Human_SnoreIn = Snore_BreathOut) and a cloud of LIGHTSMOKE in front of the face.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ing sound (SMOKE_JOINT), the snoring breath-out wasn't found

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…oad - busy means a living NPC uses it now, not the mob state

The mob state an NPC's use left comes back with a load (MobStatesSaveSection), but no NPC uses the pipe then and
ReleaseMob never resets it, so the mouthpiece stayed refused for good (review d24f2a9, gothic bug 1).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…Service.IsUsedByOtherNpc) - the VR water pipe asks it, no behaviour change

One rule for the next mob the hero takes hold of, independent of the mob kind (MobState > 0 also means switched or
open). Review d24f2a9, architecture finding 3.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
… smoking - the mouth forgets it without smoke instead of throwing on its destroyed collider

The mouth's state is cleared before anything else, and a smoked part (or its pipe) that is destroyed or deactivated
is let go without a breath out and without being told. Before, .name of the destroyed collider threw before the state
was cleared, and every later smoke at the mouth threw again (review d24f2a9, gothic bug 2 and issue 3).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…hout a hand) is let go a frame later, not inside the backend's grab event

Releasing inside XRI's select event breaks the interaction in progress (architecture.md "Inside Gothic-VR" 4) - now
deferred like the take-over already was (review d24f2a9, architecture finding 1).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
… it, even while the hand stays at it - its busy check is renewed twice a second while a hand tries to grab

The take-over and the refused grab's release remember the frame they were deferred in instead of a flag that culling
could leave set (OnDisable doesn't come while the component is idle); OnDisable only stops the hero's use. Removed the
dead _smokableExhale field and a stale constant comment in VRMouth (review d24f2a9, gothic issues 4 and 5).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…nd a smokable names its breath-out sound (IVrMouthSmokable.ExhaleSound) - no behaviour change

VRMouth keeps the triggers and the eating; VRMouthSmoking holds the smoked part, its drag and the breath out (sound
and smoke a second after a drag of at least 0.8 s). The water pipe's sound SMOKE_JOINT moved to VRWaterPipe (review
d24f2a9, architecture finding 4).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@BoroBongo

Copy link
Copy Markdown
Contributor Author

Review (architecture-reviewer + gothic-reviewer) on d24f2a9

Gothic: approve with fixes. Architecture: fits with concerns.

Fixed:

  • Busy after a load (bug). A mob state restored from a save kept the pipe busy forever. "Busy" now means a living NPC uses it (VobService.IsUsedByOtherNpc, in Core).
  • Stuck mouth (bug). A pipe culled with the mouthpiece at the mouth threw MissingReferenceException in VRMouth and blocked every later smoke. The mouth's state is now cleared safely, with Unity null checks.
  • Release timing. No ForceRelease inside the backend's Grabbed event; it happens one frame later.
  • Stale busy. The busy state refreshes every 0.5 s while a hand tries to grab. Dead field and stale comments removed; pending take-overs expire on their own.
  • Split. VRMouthSmoking is split out of VRMouth, and the pipe gives its own exhale sound (IVrMouthSmokable.ExhaleSound).

Kept: an NPC sitting down while the hero smokes (edge case). Follow-up: the handle from a prefab (see the PR text).

Played in the editor by the author:

  • grab and hose, slip-out;
  • bubbling loop at the mouth;
  • breath out 1 s after taking it away;
  • a beer and a joint at the mouth (no regression).

No exceptions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant