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

Stuff Goon People Talked about wanting #578

Merged
merged 22 commits into from
Nov 24, 2023

Conversation

dwasint
Copy link
Collaborator

@dwasint dwasint commented Nov 18, 2023

About The Pull Request

Why It's Good For The Game

Changelog

🆑
change: You can now drag clothing items over slots to quick replace that item
addition: There is now a shuttle vote that happens at 60 minutes and repeats every 20 after that.
/:cl:

dwasint and others added 2 commits November 19, 2023 20:11
The on_finish_callbacks list in `/datum/move_loop/has_target/jps` was
not initialized. Usually, when you add something to an uninitialized
list, it gets initialized and the item gets added to it. However, the
`CALLBACK` wrapper is around `new /datum/callback`, this fails.

This meant on_finish_callback was not a list, therefore at the end of
pathfinding, its contents could not be iterated and invoked. This PR
fixes this problem by initializing the list.

Closes #79383
Blob minions rally and punch again.

:cl:
fix: Basic mobs using JPS can move again
/:cl:
@KonKonBreezeFox
Copy link

there seems to be a major problem... shuttle can be called at any time, even at the start of the round
image

dwasint and others added 5 commits November 22, 2023 14:06
Implements /datum/pathfind/sssp, which generates /datum/path_map

/datum/path_maps allow us to very efficently generate paths to any turf
they contain from their central point.

We're effectively running the single source shortest paths algorithm.
We expand from the center turf, adding turfs as they're found, and then
processing them in order of addition.
As we go, we remember what turf "found" us first. Reversing this chain
gives us the shortest possible path from the center turf to any turf in
its range (or the inverse).

This isn't all that useful on its own, outside of a few niche cases
(Like if we wanted to get the farthest reachable turf from the center)
but if we could reuse the map more then once, we'd be able to swarm
to/from a point very easily.

Reuse is a bit troublesome, reqiures a timeout system and a way to
compare different movables trying to get paths.
I've implemented it tho. I've refactored CanAStarPass to take a datum,
/datum/can_pass_info. This is built from a movable and a list of access,
and copies all the properties that would impact pathfinding over onto
itself.

There is one case where we don't do this, pathing over openspace
requires checking if we'd fall through the openspace, and the proc for
that takes an atom.
So instead we use the weakref to the owner that we hold onto, and hold
copies of all the values that would impact the check on the datum.

When someone requests a swarmed path their pass info is compared with
the pass info of all other path_maps centered on their target turf. If
it matches and their requested timeout isn't too short, we just reuse
the map.

Timeout is a tricky thing because the longer a map exists the more out
of date it gets.
I've added a few age defines that let you modulate your level of risk
here. We default to only allowing maps that are currently
being generated, or finished generating in our tick.
Hopefully this prevents falling into trouble, but consumers will need to
allow "failed" movements.

As a part of this datumized pass info, I've refactored pathfinding to
use access lists, rather then id cards directly. This also avoids some
dumbass harddel oppertunities, and prevents an idcard from changing mid
path.

Did a few things to the zPass procs, they took args that they did NOT
need, and I thought it'd be better to yeet em.

If you'd all like I could undo the caching/can_pass_info stuff if you'd
all like. I think it's useful generally because it avoids stuff changing
mid pathfind attempt, but if it's too clunky I could nuke it.

Oh also I added optional args to jps that constricts how it handles
diagonals. I've used this to fix bot paths.

Much of this is redundant currently. I'm adding it because it could have
saved hugglebippers, and because I get the feeling it'll be useful for
"grouping" mobs like bees and such.
We're doing more basic mob work currently and I want to provide extra
tools for that work.

https://github.com/tgstation/tgstation/assets/58055496/66aca1f9-c6e7-4173-9c38-c40516d6d853

🆑
add: Adds swarmed pathfinding, trading accuracy for potential
optimization of used correctly
fix: Bots will no longer take diagonal paths, preventing weirdo looking
path visuals
refactor: Refactored bits of pathfinding code, hopefully easier to add
new pathfinding strategies now
/🆑
## About The Pull Request

The on_finish_callbacks list in `/datum/move_loop/has_target/jps` was
not initialized. Usually, when you add something to an uninitialized
list, it gets initialized and the item gets added to it. However, the
`CALLBACK` wrapper is around `new /datum/callback`, this fails.

This meant on_finish_callback was not a list, therefore at the end of
pathfinding, its contents could not be iterated and invoked. This PR
fixes this problem by initializing the list.

## Why It's Good For The Game

Closes #79383
Blob minions rally and punch again. 

## Changelog

:cl:
fix: Basic mobs using JPS can move again
/:cl:
@dwasint dwasint merged commit 81cb095 into Monkestation:master Nov 24, 2023
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.

4 participants