Skip to content

Add native downrange capability to ReachState - #76

Open
defoma wants to merge 12 commits into
KSP-RO:masterfrom
defoma:master
Open

Add native downrange capability to ReachState#76
defoma wants to merge 12 commits into
KSP-RO:masterfrom
defoma:master

Conversation

@defoma

@defoma defoma commented Aug 26, 2026

Copy link
Copy Markdown

Inside ReachState, there are now minDownrange and maxDownrange for downrange contracts. The downrange contracts in RP-1 are provided by an old RP-0 plugin, and I want to have downrange contracts to be an option for those not necessarily using RP-1. These will be used for Sol-Contracts.

The zh-cn localization needs to be updated similarly to the en-us, but I don't speak that language, so I did not update it.

private bool CheckDownrange(Vessel vessel)
{
CelestialBody homeBody = FlightGlobals.GetHomeBody();
Vector3d surfaceNVector = homeBody.GetSurfaceNVector(SpaceCenter.Instance.Latitude, SpaceCenter.Instance.Longitude);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The space center's current location is not necessarily where the vessel was launched. (e.g. consider switching the KSC in the middle of flight.)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

This is how it is done in the said RP-0 plugin. I am new to C#, so if you could please recommend a better solution, that would be great.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Said RP-0 plugin (assuming you are referring to DownrangeDistanceVesselParam.cs sets a mark latitude and longitude on launch, and uses that as the starting position instead.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I bet the distance doesn't even start at 0 if you measure from space center origin. Then there's the issue that you can use other launch sites. I believe you can launch even from other celestial bodies!

Comment thread source/ContractConfigurator/Parameter/VesselParameter/ReachState.cs Outdated
@periodically-makes-puns

Copy link
Copy Markdown

I'd suggest removing the .csproj and .sln changes from the PR.

@siimav

siimav commented Aug 26, 2026

Copy link
Copy Markdown

It might be easier to expose the stock F3 distance travelled metric. KSPCF has a fix for it now and should thus be accurate. Although IDK how it behaves with scene or vessel switches.

@defoma

defoma commented Aug 26, 2026

Copy link
Copy Markdown
Author

It might be easier to expose the stock F3 distance travelled metric. KSPCF has a fix for it now and should thus be accurate. Although IDK how it behaves with scene or vessel switches.

The way I have implemented currently should be good enough.

@defoma

defoma commented Aug 26, 2026

Copy link
Copy Markdown
Author

I'd suggest removing the .csproj and .sln changes from the PR.

This is the first time I've made a PR. How do I remove changes?

(edit: figured it out; done)

Comment thread GameData/ContractConfigurator/Localization/en-us.cfg
@siimav

siimav commented Aug 26, 2026

Copy link
Copy Markdown

The way I have implemented currently should be good enough.

Sorry to be mean here but what is good enough for the closed RP-1 ecosystem might not be good enough for a general-purpose implementation that will be used across installs with who knows what kind of other mods or planet packs.

@defoma

defoma commented Aug 26, 2026

Copy link
Copy Markdown
Author

The way I have implemented currently should be good enough.

Sorry to be mean here but what is good enough for the closed RP-1 ecosystem might not be good enough for a general-purpose implementation that will be used across installs with who knows what kind of other mods or planet packs.

I mean, it's just math. You can check the math yourself. The [f3] screen has never been accurate for me, and the method I am using agrees with MechJeb's flight grapher window's downrange readout.

@periodically-makes-puns

Copy link
Copy Markdown

I did a quick test. Launching from Woomerang fulfills a 200km downrange condition while still on the launchpad. Something similar probably occurs if KSCSwitcher switches the KSC location while a vessel is in-flight.
image

@defoma

defoma commented Aug 28, 2026

Copy link
Copy Markdown
Author

Interesting. I'll see if I can figure out how to set up a mark placement system at launch, then.

@siimav

siimav commented Aug 28, 2026

Copy link
Copy Markdown

Seriously though. I think the stock distance travelled metric is a better fit for CC.

@defoma

defoma commented Aug 28, 2026

Copy link
Copy Markdown
Author

Alright, sure. I was having trouble adding a mark thing anyways (maybe I should learn how C# actually works before trying to mod, lol). What's the expression that returns that value in the [f3] screen?

@Clayell

Clayell commented Aug 29, 2026

Copy link
Copy Markdown

See KSPModdingLibs/KSPCommunityFixes#402. Probably FlightLogger.totalDistance (or groundDistance, test both)

The change hasn't actually been released yet, so maybe have this PR on draft until KSPCF has its next release.

@defoma

defoma commented Aug 29, 2026

Copy link
Copy Markdown
Author

Alright, it's now in the dev branch of my repository. Once the KSPCF fix releases, I'll push the dev branch here and we should be good to go

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