Mining enhancement: fleet focus fire
About
Want to start your own mining company? Want your fleet to participate in mining directives provided by your Flagship? Do you want fighters to automatically return to your carriers to deposit mined resources? Look no further...
This pull request only changes game mechanics. It is safe for all save games based on continuous. You can also safely go back to continuous if you decide to stop playing this pull request.
Video Demo
I recorded a video of this pull request in action
- Youtube introduction https://youtu.be/wV9MiB1c-qU
- Small discord video clip showing a Roost mining and boxwings retrieving flotsam
How to play
Keyboard shortcut "V" toggles harvest mode for your fleet. If you have an asteroid scanner "V" key will target the nearest asteroid. This works regardless of hostiles in the system.
- Equip an asteroid scanner on your flagship.
- Press V or left click on an asteroid to select an asteroid.
- Press F to focus your fleet on destroying the asteroid.
Alternate game play
- Equip an asteroid scanner on your flagship.
- Right click on any asteroid and watch your fleet chase after it to destroy it.
"R" key still works the way it did before for backwards compatibility. If no hostiles in the system R will target an asteroid. Otherwise it defaults to targeting hostiles.
Download
You can launch this game in ESLauncher2 or you can download directly to play. The following instructions are direct download.
- Go to the checks tab.
- Click on Artifacts in the upper right.
- Download the artifact for your platform.
Screenshot of download
Developer information (Click to expand)
Background
samrocketman really likes to mine and has extensively played mining-only playthroughs.
I notice it doesn't scale well with other types of income as the game progresses. There's no expectation that all income types should perfectly scale throughout the game however currently mining only scales well early game up to a net worth of about 7m credits and only in one system does it even scale that well: Orbona. At most a player can get about 3m credits in one mining session within Orbona but that takes at minimum around 15-30 minutes depending on how efficient the player is at focusing on mining.
Location of Orbona relative to Rutilicus, the starting system (Click to expand)

Mining is limited in systems so it does not scale forever. However, my goal is to help balance it against other income types early to mid game in human space.
Related issues
- https://github.com/endless-sky/endless-sky/pull/6644
- https://github.com/endless-sky/endless-sky/issues/4100 this PR enables fleet to chase flotsam (dumped cargo) with V shortcut.
- https://github.com/endless-sky/endless-sky/issues/5803 this will be resolved
- https://github.com/endless-sky/endless-sky/issues/5802 this will be resolved
Feature
This change introduces a small mining enhancement. Extend Fleet: Fight my target command so that it also works on asteroids and other minable types.
Status
- [x] Fleet target asteroid.
- [x] Fleet follow asteroid.
- [x] Fleet attack asteroid.
- [x] Right-clicking asteroid will cause fleet to chase and attack.
Changes added based on review feedback
- [x] Fleet retrieves asteroid flotsam.
- [x] Tutorial introducing fleet mining.
- [x] "V" keyboard shortcut targets nearest asteroid or harvest order or both depending on context.
- [x] Fighters transfer cargo to carrier when docked/recalled (unless carrier is full).
- [x] Fighters return to carrier periodically to deposit resources when fighter cargo is full. This occurs without the carrier recalling fighters. Fighters prioritize combat over returning to carrier.
Note: after asking about unit testing
AI.cppI learned that currently it is not possible. I removed adding unit tests to the requirements of this PR.
Picture of play tester enjoying mining with the fleet

So basically, this would allow us to order our fighters & escorts to shoot at an asteroid if we have one selected? Sounds like a good addition. Mining carriers should definitely be a thing. I don't think this will cause any problems with balance, either.
So basically, this would allow us to order our fighters & escorts to shoot at an asteroid if we have one selected? Sounds like a good addition. Mining carriers should definitely be a thing. I don't think this will cause any problems with balance, either.
Yes and the feature is now finished. I'll look at implementing fleet DoMining in another pull request once this smaller mining addition is added to the master branch.
This pull request implements phase 1 I discussed in discord
- Phase 1: Enhance Fleet: focus fire so that it works on asteroids.
- Phase 2: add a fleet command to mine/gather all resources in the current system the player is located.
Zoura gave me feedback after play testing that the fleet should chase flotsam and when mining. I pushed 126afb71f21f40e60175c707410344ad862a6eaa to address the feedback.
Boxwing review
This change makes boxwings and fligher fleets a little more interesting for mining.
I used a bactrian with 3 boxwings.
- Deploy boxwings.
- Select an asteroid and push F (or right click on asteroid).
- The boxwings will hover around the asteroid (chase it in
MININGmode but they have no weapons). - When your capital ship breaks up the asteroids the boxwings will then chase the flotsam for you. Boxwings transition from MINING to HARVEST when the asteroid breaks up.
Alternate boxwing gameplay
You can have a fleet mixed with fighers and boxwings (multiple roosts).
- Target an asteroid with F (or right click).
- The both boxwings and fighters will surround the targeted asteroid.
- Fighters destroy the asteroid and boxwings will harvest the flotsam.
So after some play on a fresh file, I have some feedback. I'll try to avoid criticisms of the game itself in this review, but unfortunately, part of this PR belonging to a larger game means that some of the base game's baggage weighs on the implementation of the PR itself. That said, just be patient with me.
The PR itself is great. Obviously, getting escorts to use Miner AI instead of Brawler AI would be preferable, but seeing as this is a PR in likely early-ish stages, it's forgiveable. Being able to use fighters as mining buddies is awesome, and in my opinion makes carriers much more viable, as they allow you to have many ships available to go catch asteroids and their subsequent debris. I can see a player getting significant enjoyment out of roleplaying a start-up mining corporation that uses fighters instead of full-sized escorts; it'd be fun!
That all said, though, mining still feels like a bit of an afterthought, though this is starting to border on "problem with the base game" territory. Better support for fighter customization to allow for better small mining escorts, as well as more readily available and good cheap carrier options at the start of the game (currently, your only options for a civilian carrier at the start of the game are the Aerie and Mule, and those are each very expensive for a starting player. Not to mention, the only civilian fighter at the start of the game is the Dagger. Only the Dagger).
Overall, my critique of the game itself aside, this is a really fun PR to mess around with and I hope that, with some refinement, it finds it way into the game to create more engaging and less tedious mining gameplay a possiblity for everyone. I'll be watching this closely.
Play testing review by Beortrix within discord.
Just tried it out. Works perfectly as far as I can see it. Significant improvement in time and energy spent mining, especially with a fleet. Still not automatic, but a great improvement.
Also mild complaint regarding targetting but thats just a case that we need more keybinds for more stuff
Fleet mining tutorial renders
If you leave a planet with escorts and your flagship has asteroid scanning available, then a 2-part tutorial will launch.
Tutorial renders (click to expand)
Part 1: explanation

Part 2: shortcuts

New Tutorial Renders
The following tutorial displays when a player has more than one ship and asteroid scanning available.
| Page 1 | Page 2 |
|---|---|
![]() |
![]() |
:heavy_check_mark: Ready for review or merge
- [x] All feedback addressed.
- [x] Additional features requested have been added.
Kezethun says
Feedback 1) have you looked at transferring resources from the collector drones to their carrier?
Feedback 2) i just tried it the other day after Lake and co talked about mining with drones and pirates, and found out it works poorly. For some reason dumping drone cargo while they are docked in the carrier just deletes the cargo instead of leaving it floating in space
Feedback 3) from my very limited testing, it seems to work well and makes mining a lot more fun. The dumping problem is still present too
I'll address each feedback.
- Automatically transferring cargo from fighter/drone to parent when docking is planned as a future enhancement. This pull request is not going to have any new features added.
- Their poor experience with dumping cargo (and the cargo basically being deleted) is potentially a bug in the core game. I'll confirm this and open an issue if confirmed.
- Glad the fleet mining is working well. I'll verify the cargo dumping and open a fix for that separately.
I'll verify the cargo dumping and open a fix for that separately.
I have verified this is a bug in continuous outside of my pull request.
I have filed https://github.com/endless-sky/endless-sky/issues/6727 for the fighter dump cargo issue.
Cool feature! But slight question. Wouldn't this make the game "too easy" as pointed in one of my issues?
@ZombieChibiXD
Cool feature! But slight question. Wouldn't this make the game "too easy" as pointed in one of my issues?
First off, thanks :-)
Can you please point me to the issue you're referring where it was pointed out to be too easy? I would like to read your issue to understand the context then.
Some additional context for you: I have been discussing mining enhancements over the course of a few months. Here's a highlight of the conversations.
- Mining does not scale well past around 180 in-game days. At most this is about a fleet net worth of roughly 5 million.
- The most lucrative system mentioned in my original description at the top of this PR is Orbana. Without this pull request it takes a little over 30 minutes double time to mine with a Behemoth gaining about 2m credits (including bribes). Even longer if you opt for a faster ship with less cargo. With this change it takes about 3 minutes in double time.
- Other forms of income far surpass mining. Passenger ferrying can scale to a couple million (under 1 minute). Ship capturing about 40 million (about 1min). Cargo runs have hypothetically infinite scale. My largest cargo fleet is over 1.3 megatons and makes about 150m per jump for a total of about 1 billion credits (under 30s).
- Fleets are able to target ships and attack but fleets cannot target an asteroid even though the player could for ships. This kind of makes targeting a little less intuitive.
- The amount of resources in a single system is limited.
- This change requires a player to continue to be an active participant while mining. You cannot afk mine (though personally I am in favor of auto mining escorts this change is not that).
- Early game mining is the same experience. No easier with this PR. By the time you have a fleet other forms of income are competitive with fleet mining. However, fleet mining is also viable and enjoyable I think after playing this PR for about 40 hours myself.
@tehhowch I ended up reverting your suggested changes due to compilation errors. https://github.com/endless-sky/endless-sky/runs/6050918510?check_suite_focus=true
I'm going to try to manually implement your suggestions and keep the ones which work.
Edit: pushed https://github.com/endless-sky/endless-sky/pull/6669/commits/6801ecbeef551f22395b8c2e79dff6a5008c9b7d
Resolved conflicts
- Verified SHIFT+J still works for new fleet jumping command.
- Verified V, F, and R still works with this mining pull request.
@tehhowch this PR is ready for review again. I've addressed all comments with either replies or code changes.
At risk of interrupting code oriented discussion, I'll throw in some player feedback.
While not quite automatic, the mining aspect of this PR has made mining actually doable for me (an inept pilot), so kudos for that.
On the harvesting side, it makes picking up flotsam from fights easier which is a low-key alternative to boarding and capturing albeit with a much lower payout. I do find that the escorts/fighters are rather short sighted, and flotsam from fast moving asteroids has a tendency to go outside of their collection range. Would it be possible to increase this range, either by default or as a factor of some scanner value of the escort/fighter?
@Maddremor said:
I do find that the escorts/fighters are rather short sighted
In my experience it is not so much that they're short sighted. I have seen them run across the map. But their viewing angle is limited.
Can you confirm for me that if you turn your ship so that your escorts can "see" in front the flotsam that they pick up from a reasonable range? If so then I would increase their "viewing angle". I think the actual pickup range is pretty far (like a 10,000 unit range). In the mean time I'll look through the code to see what I can do.
Can confirm that it's about viewing angle. Is there a reason why viewing angle should be restricted? It works fine if the escort is firing at the asteroid to then pick up the flotsam, but in the case where you have a ships collecting flotsam they didn't mine you have to spin around with your ship to make them sweep their FoV over the goods.
Addressed some feedback from @tehhowch
To Do later
- [x] Use a preference for cargo transfer.
- [x] Move escort order/behavior logic in with the rest of the escort order/behavior logic instead of using FindTargetAsteroid.
TODOs complete.
@tehhowch all feedback has been addressed.

By default off; I enabled it for my playthrough.
@Maddremor
Can confirm that it's about viewing angle. Is there a reason why viewing angle should be restricted?
After looking at the code I can't seem to find a bit about viewing angles but there is a time limit. If it takes a certain amount of time to retrieve the flotsam then it will not be attempted. It is worth looking at possibly extending this in a follow up pull request once this one is merged.
When I address it I could make it a function of distance or time to retrieve.
@Maddremor after some discussion with @quyykk in discord starting here https://discord.com/channels/251118043411775489/285540320823869441/977929128118480936 and my own opinion that viewing angle feels weird specifically for player ships in harvest mode I am going to implement this fix within this PR and not a separate PR.
After refactoring into FollowOrders the change no longer behaved like prior play testing. After play testing, a bug was discovered where ships would chase flotsam and ignore other orders. I have fixed this by pushing 01b07d3093097c9edcc21aa5545682288a02c107. All escorts and fighters tested now behave properly similar to before the FollowOrders refactor.
A play tester has reported some positive and critical feedback pull requests #6669 and #6726. https://discord.com/channels/251118043411775489/266345072554016768/979036337883709590 ; I'll share this in both places.
matthew.najmon says:
@samrocketman I've been running your fleet-mining fork for a while now, and I've got some feedback on it.
The changes to mining are definitely an improvement. It's still nowhere near as efficient a money-making method as mercantile snowball, capping, or even jobs-board farming (I'm on a run where I'm intentionally only building my fleet around mining, with no ship-design decisions made around anything but mining, and it's still more efficient at all stages to carry cargo in a mining fleet, or to farm the jobs board in a mining fleet, than to mine in a mining fleet, and past a certain point in the game, it also becomes more efficient to loot/cap with a mining fleet than to mine with it). However, it is now feasible to engage in mining, and even fun in small doses (I mostly do it while doing things like waiting for ramscoop, where previously I'd have spent that time just leaving the game run and doing something else, so that's a distinct plus for the game as a whole). It's also a lot more feasible to use fighters and even drones in combat, with the less suicidal AI for them (though I still have to be very careful about when I deploy them, lest they get slaughtered even with the improved AI).
However, the biggest pre-existing issue with using fighters and drones in any way, whether for combat or mining, or even just capping them to take back and sell, is not only not fixed here, but is made worse: the bay-selection problem.
The game currently uses a frankly mind-bogglingly stupid approach to carried ships selecting a bay to recall back into. With vanilla, this ends up causing carried ships, especially newly captured ones (but can happen with others in some cases) to spend unreasonable amounts of time trying and repeatedly failing to enter an already-full bay, before finally finding one of the many empty bays on other ships and going there instead.
With this fork, this is even worse, in three ways. First, they don't seem to ever snap out of it and find the empty bay. Second, they somehow can now stall out even without a full bay to be trying and failing to enter. As I type this, I've got a fleet sitting in Kor Ak'Mari that's been there for more than a half-hour IRL time. I've got 7 non-carried ships (flag and 6 escorts) all with one fighter bay each, and 3 fighters in the system (one of which is a Petrel that was purchased long ago and came with me, and the other two are locally-capped korath chasers), and all 3 fighters are still repeatedly trying and failing to dock, even though every non-fighter ship present has an empty bay for them to dock in.
The third way it's been made worse here is that the autopilot now disrupts my control of my own flagship while the fighters are trying and failing to dock with it, resulting in an effect very similar to being extremely low on crew (I checked my crew several times before figuring out what was really happening), and meaning I can't even fly around effectively while they're trying and failing to dock.
The refueling changes, having the drones help with that, is definitely a major improvement
The critical feedback was addressed in #6866 where matthew.najmon reports all of their negative issues were resolved.
been playing this pr a bit, and it's nice to have. my one complaint is the thing i was looking for that brought me to this PR, which it almost addresses, is i wanted a way of cycling through nearby mineable asteroids regardless of the existence of hostiles on the map.
ideally, i would like to be able to cycle for the asteroids i want to get while leaving any pirates to my escorts or the other locals. yes, it can be worked around with the mouse, but i'm playing on a laptop and finding that more cumbersome than just being able to cycle targets would be. plus having my fleet seem to sometimes change its behavior subtly (or at least declaring that it is) while i'm just trying to target things isn't ideal.
i understand my goal isn't what the PR is for; clearly it's intended primarily on getting the fleet to target asteroids, but i came by way of this PR from #5802 where it's claimed the PR implements the feature i actually want. it only almost does.
it's still good work, though, and a solid step in the right direction from a ux standpoint in my eyes.
I got feedback in discord.
matthew.najmon said
@samrocketman in the escort-mining stuff, if I hit V without an asteroid nearby, it switches whether my fleet is "preparing to harvest", but I don't notice any difference in what they're doing (they still do harvest any asteroid I focus them on, and still don't harvest ones I don't). what does this "preparing to harvest" mode do?
I explained the shortcut and asked them to review the current tutorials. Harvest mode was definitely a gap.
I added a harvest tutorial 31f598381211a8eb1de8da771a98aecb650d8d32 which triggers on player having escorts.
Here's a screenshot of the tutorial

@esotericist I can take a look at this. I agree this would be a good idea. I think it might be good to implement this similar to #6346 but for asteroids.


