Skip to content

feat(sitauto): improve wall-aware seated look flow with delayed post-sit orientation#4155

Open
boscv wants to merge 4 commits intoOpenKore:masterfrom
boscv:sitAuto_look_from_wall
Open

feat(sitauto): improve wall-aware seated look flow with delayed post-sit orientation#4155
boscv wants to merge 4 commits intoOpenKore:masterfrom
boscv:sitAuto_look_from_wall

Conversation

@boscv
Copy link
Contributor

@boscv boscv commented Mar 3, 2026

Rework sitAuto wall-aware look behavior to make direction selection deterministic
by distance and more natural after sitting.

Before

  • sitAuto_look_from_wall did not reliably prioritize the nearest wall as a
    reference for orientation.
  • Direction outcomes could look inconsistent in practice, especially with small
    wall setups.
  • Orientation changes could feel abrupt depending on body/head mapping.

After

  • sitAuto_look_from_wall is treated as a search range around the character.
  • Non-walkable cells in range are scanned, nearest wall distance is prioritized,
    and ties are resolved randomly among equally near candidates.
  • Facing is computed as the opposite direction of the selected wall.
  • Seated orientation now applies a natural pose:
    • body is offset by one side step
    • head is set relatively so gaze still points away from the wall
  • If no wall is found in range, behavior falls back to sitAuto_look.
  • Added support for sitAuto_look_delay to postpone orientation after ACTION_SIT.

Fallbacks and safety

  • If no wall is found in range, fallback to sitAuto_look.
  • If delay is invalid/negative, normalize delay to 0.
  • Preserve non-blocking behavior by scheduling look time and dispatching later.

PS: Besides the position being changed, it will not be seen on client XKore modes (yet),
but can be checked on console using this command:

eval message "Body=$char->{look}{body} Head=$char->{look}{head}\n", "info";

- add wall-aware sit look selection using nearest non-walkable cells in range
- apply natural seated orientation (body offset + relative head direction)
- defer look until after ACTION_SIT and support sitAuto_look_delay scheduling
- keep sitAuto_look fallback when no wall is found
@Henrybk
Copy link
Contributor

Henrybk commented Mar 4, 2026

Maybe the get closestWalls could be its own sub in Utils ou Field? It could be used in many other places in the code (eg. runFromTarget, which right now doesn't use nearest wall logic and can get trapped)

@boscv
Copy link
Contributor Author

boscv commented Mar 4, 2026

Maybe the get closestWalls could be its own sub in Utils ou Field? It could be used in many other places in the code (eg. runFromTarget, which right now doesn't use nearest wall logic and can get trapped)

CAN DO! That's a great ideia

@boscv boscv marked this pull request as draft March 5, 2026 17:02
boscv added 3 commits March 6, 2026 16:31
Refactor sit auto-look behavior to reuse generic look helpers and correct
wall-relative orientation.

- Simplify AI::sit look planning:
  - build a default look plan from sitAuto_look + sitAuto_look_delay
  - optionally apply wall-relative orientation when sitAuto_look_from_wall is enabled
- Reuse Misc helpers for wall search and natural partial-turn direction:
  - getClosestWalls(from_pos, wall_range, [field_obj])
  - getNaturalLookDirections(from_pos, to_pos, [current_body])
- Keep lookAtPositionNaturally behavior intact by delegating to
  getNaturalLookDirections and executing look only when needed.
- Export new helper utilities from Misc for reuse in other flows.
@boscv boscv marked this pull request as ready for review March 6, 2026 22:12
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.

2 participants