Jump to content

[1.4] StageRecovery - Recover Funds+ from Dropped Stages - v1.8.0 (March 11, 2018)


magico13

Recommended Posts

Haven't run into this yet, but it will really mess things up. I always put enough chutes on each stage and put them on the same stage as the seperation so they are triggered in case they are still in range. I also put the pressure to ~.5-.6 and alt to 500-1000 depending on if it is something like an SRB that will drop soon after launch or a stage that might make it to space. Had always worked in the past.

Link to comment
Share on other sites

Hi, magico13. Still don't get it: are the refunding values for the recovered stages somehow compatible with KSP's stock recovery?

I'm not 100% sure what you're asking, but I'll try to answer it anyway. If I don't actually answer your question, let me know and I'll try again :P

If you recover things manually (by clicking the recover button in flight or in the tracking station) then Stage Recovery doesn't do anything at all regarding those vessels. So if you drop a stage (stage == vessel == parts you dropped) with parachutes and it lands before you leave physics range (22.5km) then you have to recover the stage manually and Stage Recovery does nothing. When Stage Recovery comes into play is when you leave physics range while the stage is still in flight and hasn't landed yet. When that happens KSP totally deletes the craft; killing any Kerbals inside, destroying all the science on board, and treating the whole thing as "crashed", meaning you would get 0 funds back. Stage Recovery intercepts that process and calculates whether the stage would land safely. If it calculates that it should land at a slow enough speed, then it recovers all the Kerbals and science, calculates the total value of all the parts on the stage and then returns a fraction of that value back to you. The fraction is determined by how far away the stage is from KSC (same as with Stock) and how fast it would land. If it would land slower than 6 m/s, you get 100% (without range penalties). If it would land at 12 m/s or more then you get 0%. If it would land between 6 m/s and 12 m/s, you get an amount following a quadratic polynomial (the closer to 6m/s, the more you get back).

The values for the funds you get back are entirely compatible with the stock recovery, because they're equal to or less than what you'd get if you recovered the parts manually. They're usually less, since you can't get 100% (98% is the maximum, since I don't check for "landed at the launchpad or runway" like Stock does) and there are penalties for speed. Stock recovery and Stage Recovery should absolutely never interact with each other, so you'll never get a "double recovery".

Link to comment
Share on other sites

magico13, so the settings for return values are fully synthetic and don't rely on stock values in any way? So are they "equal to or less than what you'd get if you recovered the parts manually" just because the settings were accurately chosen to match stock recovery?

Link to comment
Share on other sites

Ser, the values are stock values minus the % loss by distance and speed landed. If somehow you had landed that craft while piloting it, when you click 'recover vessel' you would get the same back that is calculated by stage recovery. It doesn't cheat the system in any way. The only thing it does is not delete crafts/parts once they leave physics range and instead checks if that craft/part would have been recoverable and if so recovers it for you. Hope this better explains everything.

Link to comment
Share on other sites

I understand that. In general my question is on where do the calculations come from? Ok, let's suppose Stage Recovery detects that a vessel needs to be recovered. What happens next? Does it get the values returned by KSP for that location and apply the speed modifier or use it's own formula taking the range and speed?

Edited by Ser
Link to comment
Share on other sites

It asks KSP for the surface speed of the vessel and the location, and users that location to determine the great circle distance from the KSC. The percent returned for distance uses the same formula stock does, with one exception that it has a maximum distance that's dependent on the Tracking Station level (stock doesn't do that). Level 1 TS = 1/4 Kerbin circumference as max distance. Level 2 TS = 3/8. Level 3 = 1/2 (same as stock).

Funds are calculated by looping through the parts and asking for their costs, then applying the distance and speed modifiers.

If you want the most detailed explanation, I'd suggest going straight to the source. It will tell you exactly where everything comes from, and most of it is commented.

https://github.com/magico13/StageRecovery/blob/master/StageRecovery/RecoveryItem.cs

E: I'd like to also mention that I'd love to just ask KSP what the percent from distance should be, but they decided that needed to be private for some reason so I literally can't (not entirely true. There are apparently ways to call private functions outside of their class, but I don't know them)

Edited by magico13
Link to comment
Share on other sites

Now it's crystal clear. Thanks.

Just in case it might be useful, I could suggest the following way to get the stock calculations: use something like Trajectories to predict where it's going to land. Than move the vessel there and land it. Than call the stock function to recover the vessel, subtracting your penalties from player's funds after that.

Link to comment
Share on other sites

Now it's crystal clear. Thanks.

Just in case it might be useful, I could suggest the following way to get the stock calculations: use something like Trajectories to predict where it's going to land. Than move the vessel there and land it. Than call the stock function to recover the vessel, subtracting your penalties from player's funds after that.

Not as trivial to do as it sounds, unfortunately. Trajectories' API only lets you run calculations on the active vessel, which eliminates that. I could set the state of the vessel to landed and change it's altitude+speed, then call the stock recover function, though. I wouldn't need the PQS system loaded for that to work. I might actually play around with that. The only issue is that by the point that StageRecovery is seeing the vessel, KSP is already in the process of deleting it, and I don't know that I can stop it. I might be able to do things when the vessel is unloaded, but that's when KSP starts the deletion process and by the time my code runs it might have started already.

Also, then I lose a lot of freedom. My own recovery method allows me to do anything I want to with it, and I don't have to fight with KSP's recovery mechanism to get things how I need them to be. I might mess around with that anyway, just to see what I can do with it.

Link to comment
Share on other sites

  • 3 weeks later...
Does this support winged recovery?

Not exactly. Gliders won't work, for instance. And StageRecovery doesn't compute the distance any differently.

If you've got enough engines to have a TWR >1 and enough fuel it'll get recovered through the powered recovery process. You can lower the TWR needed in the settings if you're recovering a lot of planes.

In the old aero it probably wouldn't be too hard to estimate the lift for a vessel, but with the new aero it's more difficult. For gliders and such, you may want to look into FMRS.

Link to comment
Share on other sites

Hi!

Is it possible to make a plane recovery? I see it this way: almost same requirements as for power recovery, but there is no need for TVR>1, then if dv is big enough for the craft to reach KSC, recovery would be 100%.

If detecting wings is the same thing as detecting parachutes, then the only problem would be to differentiate the rocket and plane recovery. To simplify this let's say, that for planes recovery ratio is always 100%. I judge by my own crafts obviously, but they have plenty dv per usual.

So this is a humble request. Please, please, please!

Link to comment
Share on other sites

IF I add it, I'll have to try to come up with a rough wing surface to mass ratio requirement (probably, I need to look into what goes into having a high glide ratio) and scale the amount of "glide" the craft can do. So if you have a high "glide" then your distance from KSC will be reduced by a lot, but if you have a low one (like rocket boosters) then the distance from KSC won't be reduced at all. I may or may not try to add a "flight" element that takes fuel and makes that max distance larger, since I don't necessarily want StageRecovery to replace actual flying.

I've opened issue #20 on GitHub for this.

Link to comment
Share on other sites

IF I add it, I'll have to try to come up with a rough wing surface to mass ratio requirement (probably, I need to look into what goes into having a high glide ratio) and scale the amount of "glide" the craft can do. So if you have a high "glide" then your distance from KSC will be reduced by a lot, but if you have a low one (like rocket boosters) then the distance from KSC won't be reduced at all. I may or may not try to add a "flight" element that takes fuel and makes that max distance larger, since I don't necessarily want StageRecovery to replace actual flying.

Maybe trajectories mod has some code that could help you with this? That one doesn't care for thrust, but I think it has some lift estimation stuff in it, for both FAR and stock. I'm not really much of a spaceplane user, but hopefully that's helpful.

Link to comment
Share on other sites

Maybe trajectories mod has some code that could help you with this? That one doesn't care for thrust, but I think it has some lift estimation stuff in it, for both FAR and stock. I'm not really much of a spaceplane user, but hopefully that's helpful.

Trajectories can't handle wings in Stock aero last I checked, but I might take a look there. Since SR doesn't usually worry too much about being exactly precise, even an estimate is good enough for me, so I'll probably end up looking into a paper or two on the subject.

Link to comment
Share on other sites

Trajectories can't handle wings in Stock aero last I checked, but I might take a look there.

Ah, you're right  I was convinced it started supporting them, but now you see how little I actually use planes. I guess making the feature FAR-only would make it even less useful for me, but eh, at least some people would use it ;-)

Link to comment
Share on other sites

Maybe trajectories mod has some code that could help you with this? That one doesn't care for thrust, but I think it has some lift estimation stuff in it, for both FAR and stock. I'm not really much of a spaceplane user, but hopefully that's helpful.

IIRC, When using Trajectories with FAR, all the drag calculations are calculated by FAR.

Link to comment
Share on other sites

I've always wished that the StageRecovery toolbar square opened when you hovered over it like Kerbal Construction time's square does. It would make things slightly more useful, but infinitely cooler.

It's really hard to see in this gif (sorry) but you can see that most of the other square on the toolbar open briefly when you hover over them but StageRecovery does not (the square second from the left).

ezgif-2753199448.gif

- EDIT Gif doesn't work - the text above is probably clear enough XD

Would this be something you would like to add possibly Magico?

Edited by Avera9eJoe
Link to comment
Share on other sites

I've always wished that the StageRecovery toolbar square opened when you hovered over it like Kerbal Construction time's square does.

Your gif doesn't seem to be working, but I'm pretty sure I know what you're talking about. It'd be pretty easy to make the window appear on hover, then disappear when you move the mouse away (unless you clicked it, in which case it would stay open).

I'll have a dev build with that momentarily.

Edit: Haven't tested yet, but the latest build from here should display the window in flight when you hover over the button. Only during flight though.

http://magico13.net:8080/job/StageRecovery%20Development/

Edit2: Limited testing shows that it's working as intended. Only minor hiccup is when you click to close the window, it flashes once as the window is hidden one frame and opened again in the next one, but that's not a big deal.

Edited by magico13
Link to comment
Share on other sites

Your gif doesn't seem to be working, but I'm pretty sure I know what you're talking about. It'd be pretty easy to make the window appear on hover, then disappear when you move the mouse away (unless you clicked it, in which case it would stay open).

I'll have a dev build with that momentarily.

Edit: Haven't tested yet, but the latest build from here should display the window in flight when you hover over the button. Only during flight though.

http://magico13.net:8080/job/StageRecovery%20Development/

Edit2: Limited testing shows that it's working as intended. Only minor hiccup is when you click to close the window, it flashes once as the window is hidden one frame and opened again in the next one, but that's not a big deal.

Amazing! I shall check it out now ;). The site that hosted my gif must have expired. I'll put a note :P. I look forwards to starting my hardcore career stream ;)

Edited by Avera9eJoe
Link to comment
Share on other sites

  • 1 month later...

In my first career play through using SR I have Mun and Minmus biomes half-explored, a few planetary flybys complete, and a mid-7-figure bankroll piled up and racking up cash from contracts seems almost too easy...

Has anyone looked at adjusting game balance to compensate for the SR cash back effect?

Link to comment
Share on other sites

In my first career play through using SR I have Mun and Minmus biomes half-explored, a few planetary flybys complete, and a mid-7-figure bankroll piled up and racking up cash from contracts seems almost too easy...

Has anyone looked at adjusting game balance to compensate for the SR cash back effect?

I play with reduced fund rewards, to compensate. Right now I'm playing with the rewards at 0.7 using Kscale2 (double sized universe), but 0.5 with the stock size might work better. It'll reduce your rewards from all contracts, making money harder but you are still rewarded for high recoverability. The other thing I'd suggest would be lowering the max speed for recoverable stages, making it more difficult to get those upper stages back.

Link to comment
Share on other sites

lowering the max speed for recoverable stages, making it more difficult to get those upper stages back.

Lowering the minimum cutoff might even be better, since the curve favors the low end much more, which would result in far more partial recoveries. Lowering the high cutoff is probably a good idea too.

Alternatively, set personal limits. I don't try to recover everything, only expensive liquid fueled stages, and only things that are dropped while still in the atmosphere (so nothing that helps with the circularization burn). This means I still lose a large amount of money each launch (those second stages are pretty expensive), but can recuperate about 10k or so from recovering the liquid fueled 1.25m boosters.

Link to comment
Share on other sites

Lowering the minimum cutoff might even be better, since the curve favors the low end much more, which would result in far more partial recoveries. Lowering the high cutoff is probably a good idea too.

Ah, now I realize I was unclear. I actually meant the "DR_Velocity" cutoff, to destroy things from supposed heating when moving to fast/reentering, as is the case for upper stages. Personal limits are always a great option. There are so many ways to game KSP's career mode (repeatable get science from space temperature reports, etc.) that you need personal limits sometimes.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...