Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Record path then take it (again and again). #74433

Open
Brambor opened this issue Jun 10, 2024 · 7 comments
Open

Record path then take it (again and again). #74433

Brambor opened this issue Jun 10, 2024 · 7 comments
Assignees
Labels
Quality of Life QoL: degree to which players are comfortable, and able to enjoy CDDA <Suggestion / Discussion> Talk it out before implementing

Comments

@Brambor
Copy link
Contributor

Brambor commented Jun 10, 2024

Is your feature request related to a problem? Please describe.

TL;DR: I want to record the perfect path from a mine entrance to the bottom, then take it.

Long version:
I want to take the path I took last time and I want to spend as little IRL time as possible. I know the path by heart. Just follow the rails on the right and step aside when pit ahead. I would like to input this path once and let the game travel me to the end. Failing that, I am punished by falling into a pit because I don't want to tediously press the keys, I am bored doing it the 10th time. Realistically, my character would remember. I would remember IRL if I might fall into a pit. But I have 0 adrenaline sitting behind a keyboard pressing keys. It is a game. Let me do the fun stuff. Not the travel to stuff.

Existing solutions.

  • Map travel to. It sometimes doesn't go through forests. It doesn't work with the mines at all. It makes you go to the middle of an overmap tile which is suboptimal.
  • Look around travel to. You can only go to where you can see.
  • Then there is auto-move Auto travel mode. It avoids puddles and such but is sometimes flat-out weird. Sometimes when the tile to the right is clear, you press right and the character goes down. It also is not good for spirals. Mines (the two I found) are spirals.

Solution you would like.

Record a path:

  1. Open a menu, and press "Start recording".
    • This makes a new vector and puts the starting position in.
  2. Player moves. (repeatable)
    • Add the destination tripoint to the end of the vector.
    • Must work for stairs etc. (across multiple z-levels).
  3. Open a menu, and press "End and save recording".
    • Save the vector somewhere.

Walk the path:

  1. Open a menu and press "Walk the path".
    • Check that the player is on a tile that corresponds to exactly one tripoint that is the start or the end of a path.
    • If so, travel to the other end. This is an activity, so SAFEMODE etc. works. Hauling also works, I want to use this with hauling.

Starting the auto walk: I imagine this like with auto hauling: the player presses \ to open a menu and \ again to haul all items under their feet. Just like that, I want a double press to start walking.

You could make four points in front of your base, each of them leading you all the way to a different place. Or maybe make a decision at each crossroads. Both would work.

I said player, I meant Character. Let's implement it for the Character right away. It might be useful later.

Quality of life.

When recording a new path: Going back to a tripoint you were already on, delete the loop you made.

image

Example path. Green is the final path from start to end. Red are the deleted loops. Pink is near a path that was already taken and it is in the final path.

The loop is deleted the moment you step to a tripoint you already were on.

Activated with a checkbox in the menu (on by default).

An example when you don't want to delete a loop: you are grabbing a vehicle and you need to turn it around.

Possible optimizations.

Don't store each tripoint. We can skip straight lines or other such easy things.

Or don't store tripoints at all. Just directions (example path: north, north, up a z level, south-west). Which is 10 bits instead of whatever the size of a tripoint is (I assume 3 x 32 bits).

Currently I implemented a vector of tripoints. To find a loop, we don't need to search the whole vector. The character in one step can (at maximum) increase/decrease z level by 1, or go diagonally. Look at one point at index i, count the distance from the new point dist = abs(z1-z2) + max(abs(x1-x2), abs(y1-y2)). The new point cannot be at indexes i-dist+1, ..., i+dist-1. So skip those in loop checking. In case of straight path, this makes search closer to O(1) than to O(n).

Describe alternatives you have considered.

Walk the path step 1.

  • The player is shown what paths they are standing on (be it the start, end, or the middle). The player can select one of the paths and the direction they wish to move in.
    • Useful for interrupts too.

Additional context

No response

@Brambor Brambor added <Suggestion / Discussion> Talk it out before implementing Quality of Life QoL: degree to which players are comfortable, and able to enjoy CDDA labels Jun 10, 2024
@Brambor
Copy link
Contributor Author

Brambor commented Jun 10, 2024

I really need to do something else.... but....

@Brambor
Copy link
Contributor Author

Brambor commented Jun 10, 2024

There more discussion of this on Discord: https://discord.com/channels/598523535169945603/598529174302490644/1249842203056930826

@dominic-dimico
Copy link

This would be wonderful. Yes! The ability to create a path using intermediate points that you walk through. The old AD&D CRPGs like Baldur's Gate had pathsetting features like this, where you'd right-click in a sequence and your character would walk in optimal sub-paths to all those points.

You know, this reminds me. Vim has a feature where it records keystrokes into macros. You can play the exact keystrokes back by invoking the macro. If you were implement it this way, you wouldn't have to rely on pathfinding; but you would be at the mercy of your own macro definitions, if you know what I mean. Not only walking, but also other repetitive activities could be handled this way. Just a thought.

@Brambor
Copy link
Contributor Author

Brambor commented Jun 16, 2024

My current local implementation records the tripoints you step on specifically. I don't want to get into the weeds of key recording. I want it simple and bug-resistant. This also allows for some QoL optimizations that you couldn't get with plain key recording (the loop detection).

I hope to make a PR today (at least a draft).

@Brambor Brambor self-assigned this Jun 16, 2024
@Brambor
Copy link
Contributor Author

Brambor commented Jun 16, 2024

I am not implementing any visuals to the path. This PR displays NPC path on overmap, maybe I could steel from it:

@Brambor
Copy link
Contributor Author

Brambor commented Jun 17, 2024

If anyone has suggestions for keybinding to open the menu, I am all ears!
Locally I am doing it with CTRL+M which cannot be pushed.

@Brambor
Copy link
Contributor Author

Brambor commented Jun 17, 2024

This is how it currently looks btw. (WIP):
image

@Brambor Brambor mentioned this issue Jun 17, 2024
16 tasks
@CLIDragon CLIDragon mentioned this issue Sep 2, 2024
10 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Quality of Life QoL: degree to which players are comfortable, and able to enjoy CDDA <Suggestion / Discussion> Talk it out before implementing
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants