Skip to content

fix: remove the concept of first step#3642

Merged
dudantas merged 10 commits into
mainfrom
lucas/fix-auto-walk
Jun 12, 2026
Merged

fix: remove the concept of first step#3642
dudantas merged 10 commits into
mainfrom
lucas/fix-auto-walk

Conversation

@lgrossi

@lgrossi lgrossi commented Aug 11, 2025

Copy link
Copy Markdown
Contributor

Auto walk should follow thinking constraints, including thinking time and ticks.

Currently, the first step of an auto walk action was treated differently. It ignored all constraints and were immediately executed.

While this create a good feeling of quick reactions, it felt unnatural that creatures were instantly reacting to changes.

Also, there was a bug where, for small paths (e.g. when following someone) every step taken was considered a first step.

To emulate more realistically the reaction time, and global behaviors, this commit removes the concept of first step, treating every step equally and respecting the thinking constraints of creatures behaviors.

Behaviour

Actual

Every auto walk starts instantly and do not respect turns.

Expected

Auto walk respects turns.

Type of change

Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested

Summon 3 creatures and lure them, the reaction should differ depending on when you execute your walk. The creature will take longer or shorter to follow you, depending on where in their thinking cycle the change happened.

Before the changes this would always happen immediately, no room for thinking to happen.

Summary by CodeRabbit

  • Refactor
    • Simplified creature auto-walk behavior and interfaces: immediate first-step execution removed and movement steps are now consistently scheduled, improving walk timing predictability and reliability for end users.

✏️ Tip: You can customize this high-level summary in your review settings.

lgrossi and others added 2 commits August 11, 2025 09:58
Auto walk should follow thinking constraints, including thinking time and ticks.

Currently, the first step of an auto walk action was treated differently. It ignored all constraints and were immediately executed.

While this create a good feeling of quick reactions, it felt unnatural that creatures were instantly reacting to changes.

Also, there was a bug where, for small paths (e.g. when following someone) every step taken was considered a first step.

To emulate more realistically the reaction time, and global behaviors, this commit removes the concept of first step, treating every step equally and respecting the thinking constraints of creatures behaviors
Comment thread src/creatures/creature.cpp Outdated
if (ticks == 1) {
onCreatureWalk();
safeCall([this] {
const int64_t ticks = getEventStepTicks();

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moving this inside just to make sure that ticks are calculated once the actual action is called.
Calculating it before safeCall would expose it to race conditions or delays in the scheduling.

E.g.: ticks before dispatching are 1500ms, the server is busy and the function took ~300ms to be executed, the step will be schedule with the original 1500ms and will end up being 300ms delayed.

While it is virtually the same - we don't expect huge delays on dispatching, and that the practical impacts are negligible, I believe that this is safer.

Comment thread src/creatures/creature.cpp
safeCall([this, ticks]() {
// Take first step right away, but still queue the next
if (ticks == 1) {
onCreatureWalk();

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing this will lead to slightly less responsive auto walking start.
We can re-think some quicker responsiveness for long walks in the future, without impacting short paths (e.g. a creature close following another).

@sonarqubecloud

Copy link
Copy Markdown

@dudantas dudantas changed the title fix: Remove the concept of first step fix: remove the concept of first step Sep 3, 2025
@gabrielew

Copy link
Copy Markdown
Contributor

At certain moments, I noticed that the player "stutters" while walking. It happened a few times, especially when the player is high-level.

@lgrossi

lgrossi commented Sep 4, 2025

Copy link
Copy Markdown
Contributor Author

At certain moments, I noticed that the player "stutters" while walking. It happened a few times, especially when the player is high-level.

Thanks a lot for testing it! Could you attach a short screen recording?
When you say stutter, is it:
• a small pause between steps (tiny delay),
• a quick directional snap before continuing,
• or something else?

Also, which level/speed and whether you were following closely vs. long path would help.

@gabrielew

gabrielew commented Sep 4, 2025

Copy link
Copy Markdown
Contributor

At certain moments, I noticed that the player "stutters" while walking. It happened a few times, especially when the player is high-level.

Thanks a lot for testing it! Could you attach a short screen recording? When you say stutter, is it: • a small pause between steps (tiny delay), • a quick directional snap before continuing, • or something else?

Also, which level/speed and whether you were following closely vs. long path would help.

At the beginning of the video, the EK is without haste spell (1621), and the second time he is using utani tempo hur (2940).

vocat EK: 1397
speed 1: 1621
speed 2: 2940

0904.mp4

In the video, you can clearly see it kind of "lags" the movement and stutters before moving to the next tile.

@roys82

roys82 commented Sep 4, 2025

Copy link
Copy Markdown

In my opinion, this isn't random. I noticed this effect when entering houses. I therefore think it triggers when you enter a PZ. I'm not sure why

@gabrielew

Copy link
Copy Markdown
Contributor

In my opinion, this isn't random. I noticed this effect when entering houses. I therefore think it triggers when you enter a PZ. I'm not sure why

When we enter a PZ, a bunch of things get triggered by the server, and even the minimap blinks.

@github-actions

github-actions Bot commented Oct 7, 2025

Copy link
Copy Markdown
Contributor

This PR is stale because it has been open 45 days with no activity.

@github-actions github-actions Bot added the Stale No activity label Oct 7, 2025
@coderabbitai

coderabbitai Bot commented Jan 23, 2026

Copy link
Copy Markdown

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 996e3643-527b-47a0-9a63-8374689a4966

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Method signatures simplified: addEventWalk() and getEventStepTicks() had their boolean parameters removed. Auto-walk scheduling no longer treats a "first step" specially; scheduling always defers to the event system and tick computation was simplified.

Changes

Cohort / File(s) Summary
Header: signature changes
src/creatures/creature.hpp
Removed optional boolean parameters: void addEventWalk(bool firstStep = false)void addEventWalk() and int64_t getEventStepTicks(bool onlyDelay = false)int64_t getEventStepTicks(). Update callers accordingly.
Implementation: scheduling & timing
src/creatures/creature.cpp
Reworked auto-walk flow: always schedules addEventWalk() after populating walk list; removed first-step immediate execution branch; getEventStepTicks() simplified to compute ticks from walk delay and last step cost; event lambda now captures creature via generic weak_ptr.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 I hopped along with simpler art,
No special first step to restart.
Events now queue in tidy line,
A cleaner pace, one tick at a time. 🌿

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title directly describes the main change in the changeset: removing the 'firstStep' parameter and related first-step special-case logic from auto-walk handling to enforce uniform thinking constraints.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch lucas/fix-auto-walk

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

coderabbitai[bot]

This comment was marked as outdated.

@sonarqubecloud

Copy link
Copy Markdown

@github-actions github-actions Bot removed the Stale No activity label Jan 24, 2026
@github-actions

Copy link
Copy Markdown
Contributor

This PR is stale because it has been open 45 days with no activity.

@github-actions github-actions Bot added the Stale No activity label Feb 23, 2026
@dudantas dudantas marked this pull request as draft May 7, 2026 18:04
@github-actions github-actions Bot removed the Stale No activity label May 14, 2026
@dudantas dudantas marked this pull request as ready for review June 11, 2026 15:05
Copilot AI review requested due to automatic review settings June 11, 2026 15:05

Copy link
Copy Markdown
Member

@gabrielew @roys82 thanks again for the reports and the video/details.

The branch has been updated with the latest main, and the walking change was adjusted so player-controlled movement keeps the responsive first step while creature AI/follow paths still respect the delayed scheduling.

Could you please test the latest PR head when you have a chance? The most useful checks would be:

  • high-speed player walking, especially around the EK speeds reported (1621 and 2940 with utani tempo hur);
  • entering/leaving PZ or house tiles;
  • normal creature follow behavior, to confirm it did not become instantly reactive again.

Any confirmation, video, or reproduction notes would help us decide whether this is ready.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR removes the “special first step” behavior from creature auto-walk scheduling so that movement steps obey the normal walk/thinking timing constraints, preventing instant AI reactions and fixing repeated “first step” behavior on short/recomputed paths.

Changes:

  • Introduces Creature::WalkStartPolicy to explicitly control first-step scheduling behavior (RespectDelay vs ImmediateWhenReady).
  • Updates Creature::startAutoWalk, addEventWalk, and getEventStepTicks to use the new policy and compute timing at scheduling time (inside safeCall).
  • Updates player movement entry points to pass an explicit start policy (preserving responsiveness for certain player inputs).

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
src/game/game.cpp Passes an explicit WalkStartPolicy when starting player autowalk/move actions.
src/creatures/creature.hpp Adds WalkStartPolicy and updates walk scheduling APIs/docs to remove the legacy “first step” flag.
src/creatures/creature.cpp Implements policy-based scheduling and moves tick calculation inside safeCall to avoid stale timing.

Comment thread src/creatures/creature.cpp Outdated
Comment thread src/creatures/creature.hpp Outdated
@sonarqubecloud

Copy link
Copy Markdown

@dudantas dudantas merged commit 36b7fd1 into main Jun 12, 2026
20 checks passed
@dudantas dudantas deleted the lucas/fix-auto-walk branch June 12, 2026 18:38
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.

6 participants