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

New hyperdrive algorithms and internal hyperfuel tanks #6026

Merged
merged 15 commits into from
Jan 28, 2025

Conversation

sturnclaw
Copy link
Member

@sturnclaw sturnclaw commented Jan 17, 2025

Redesigns the hyperdrive fuel use and duration-per-distance-travelled equations to implement the redesign we've discussed and accepted.

This PR also converts hyperdrives to use an internal fuel reservoir rather than pulling directly from the cargo bay, and allows transferring fuel between the main tank and the hyperdrive reservoir. This enables fractional fuel usage in jumps - no longer will jumps of differing lengths use the same amount of fuel!

image

As part of this effort, about 50% of the capabilities of the planned fuel management UI were implemented; the fuel management will be left at this level until we get further time (after the upcoming release) to implement the full management interface.

image

This PR fully implements all five sizes of hyperdrives in both military and civilian variants. Values have been assigned that "should" give decent jump ranges across the ship masses of that size, but a rigorous balance pass has not been done in interest of time.

Military drives have not been tested yet, but should function fine - I'd welcome any and all testers willing to give this branch a spin!

TODO:

  • ShipBuilder should fill hyperdrive tanks on spawn.
  • SAR mission needs to be able to interact with new hyperdrive tanks.
  • Military fuel needs to be handled correctly.

Fixes #5914.
Fixes #6025.

- The new hyperdrive algorithm is designed for fractional fuel use and to provide more nuanced gameplay instead of always choosing the closest system to hyperjump to.
- New in this algorithm, it is now more fuel efficient to make a single long jump than many shorter jumps, even when travelling the same distance.
- Overall, maximum hyperspace range increases slightly for heavily-laden ships, and travel duration reduces from 2-3 weeks at maximum range to approximately 1 week for a maximum range jump.
- Updated both civilian and military hyperdrives to match new ship slot sizes.
- HullConfig no longer provides default slots for most types; it's assumed the ship pipeline has matured enough that ships will have manually-authored slots for all types.
- Sensor slots are left automatically-defined until a further pass on sensor gameplay has been done.
- Added validation messages for ships missing common slot types.
@syonfox
Copy link

syonfox commented Jan 19, 2025

It appears you can still jump with no fuel in the hyper drive tank the button is not disabled from the flight screen. and when you jump it may make some number negative internally or something

image
image

And the button works but the drive acts funky after sometimes.

@Bodasey
Copy link

Bodasey commented Jan 19, 2025

found here, may be also broken in master? Or do i something wrong here? I am not familiar with rescue missions...

Screenshot_20250119_131836
Screenshot_20250119_131857

more reports to come...

@Bodasey
Copy link

Bodasey commented Jan 19, 2025

As far, the additional hyperdrive fuel tank works as intended, but i think it is a rather complicated way to fix #5914.

As you can move fuel as you want to, you get, as a player, de facto one single, but now bigger fuel tank than in the original ship design.

Thoughts:

  • The hyperdrive machine should get the fuel directly from the existing fuel tank.
  • Hydrogen in the cargo space is bottled, while it is not in the fuel tank. (or tank = one big bottle)
  • Scooped fuel should also go into the tank (and then may be bottled in the cargo space)
  • There are no tanks for military fuel and its radioactive waste (thrusters stop when waste tank is full)
  • Rockets also need oxygen as fuel, why don't we?
  • Interplanetary flights by autopilot always end with 1/4 fuel left in the tank, can't this be controlled?

@Bodasey
Copy link

Bodasey commented Jan 20, 2025

I have completed a need hydrogen rescue mission in the master branch - works there.

@Miner34dev
Copy link

Rockets also need oxygen as fuel, why don't we?

Ion/Fusion thrusters don't need oxygen.

@sturnclaw
Copy link
Member Author

As far, the additional hyperdrive fuel tank works as intended, but i think it is a rather complicated way to fix #5914.

It is indeed a complicated way to fix 5914, however it was never intended primarily as a fix for that issue. Hyperdrive-internal fuel reservoir and fractional fuel usage has been a planned feature for multiple months, and the fix for the hyperdrive exploit is actually completely unrelated to this new feature.

There are no tanks for military fuel and its radioactive waste

This is an oversight in the current implementation, and the inability to fuel the drive with military fuel will be fixed before merge. Thanks for catching this one!

As for the rest of the thoughts on hyperdrive implementation, most of those are either orthogonal to this specific PR or something we've already addressed during the design phase for this specific feature (i.e. pulling hyperfuel from the ship's main fuel tank).

@syonfox
Copy link

syonfox commented Jan 23, 2025

https://youtu.be/YrW7xvnbYjo

Looks like you fixed it. There may be a small secondary bug of the fuel calculations not being rerun when you switch to the galaxy map.

And I'm curious if that solves the "dispersing button" but will test further and see if I run into it again.

@syonfox
Copy link

syonfox commented Jan 23, 2025

Ok with new code i still got this bug.

https://youtu.be/jPoh2t4RuEY

Looks like sometimes with no fuel in cargo bay the button is disabled.

@sturnclaw
Copy link
Member Author

I'm unable to reproduce either of those bugs with the most recent code. When testing, always make sure to start a new save - there's no guarantee that old saves from the same branch are still compatible (and/or don't contain subtle bugs due to changes in the code).

@sturnclaw
Copy link
Member Author

found here, may be also broken in master? Or do i something wrong here? I am not familiar with rescue missions...

This bug is not endemic to this particular branch. The SAR mission was written when all ships had physically improbable cargo holds that were a significant fraction of the fuel tank size; when that was changed with the equipment refactor, some stranded ships don't have enough cargo space to transfer all fuel to the target's cargo hold before refueling the fuel tank. I've fixed the issue in a commit on this branch.

With the latest batch of commits, this branch should be ready for merge. I'll give it a last round of testing, rebase what I can, and if nothing crops up I'm pulling the trigger.

- If a ship starts without atmospheric shielding, the atmo_shield_cap property will be unset.
- Instead of pulling hyperspace fuel from the cargo hold, pull it from the hyperdrive's internal tank.
- This allows for fractional fuel usage in hyperspace jumps, resolving a longstanding pain point with attempting to optimize hyperspace jumps.
- It's also a stepping stone towards further ship gameplay mechanics.
- Allow setting fuel on a drive that is not yet installed
- Fix hyperdrives not removing their fuel mass when removed
- Correctly handle fractional fuel amounts when creating byproduct
- Notify event listeners when fuel state changed
- Add transfer widget in 03-econ-trade to move fuel between main tank and hyperdrive tank.
- Fuel purchase interface in lobby buys directly to hyperdrive; it no longer purchases to the cargo hold.
- Spare hyperfuel in cargo hold must be purchased through the commodity screen.
- Updates to the sector map to render fuel as a fractional value.
- Now correctly reads fuel from the hyperdrive's internal tankage, in addition to excess fuel in cargo hold.
- Update hyperjump planner when hyperdrive fuel state changes.
- The 'apply' function modifies a prospective piece of equipment before it is added to a ship.
- Military drives will now only spawn on the targets of Assassination and Combat missions, as well as any other missions which spawn a GenericMercenary ship.
- Primarily useful for testing purposes, but also for players who don't feel like using the console to fix their broken hyperdrive...
- Rename module to Player Debug rather than RPG and update icon to player head.
- Ensure ships are selected that have room for at least 1t of fuel.
- Refuel target ship with each ton of fuel rather than waiting until all fuel has been transferred.
- Instead of putting hyperdrive fuel in the cargo hold, put the fuel in the hyperdrive.
- Rename and cleanup hyperdrive-related methods to simplify the logic.
@sturnclaw sturnclaw force-pushed the hyperdrive-fuel-tank branch from 863096a to 3860737 Compare January 27, 2025 23:59
@sturnclaw sturnclaw merged commit 312098f into pioneerspacesim:master Jan 28, 2025
@sturnclaw sturnclaw deleted the hyperdrive-fuel-tank branch January 28, 2025 00:00
@syonfox
Copy link

syonfox commented Jan 28, 2025

Nice work!

I had an idea to implement a fuel computer just made a branch but might need some work on the language. Will make a pull quickly before bed.

@syonfox
Copy link

syonfox commented Jan 28, 2025

I'm unable to reproduce either of those bugs with the most recent code. When testing, always make sure to start a new save - there's no guarantee that old saves from the same branch are still compatible (and/or don't contain subtle bugs due to changes in the code).

I haven't seen it again in a new save file so might be fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Hyperdrives don't match ship hyperdrive slot scaling Hyperfuel ussage can be avoided.
4 participants