godarklight / DarkMultiPlayer

DarkMultiPlayer - A multiplayer mod for Kerbal Space Program
MIT License
280 stars 120 forks source link

Fix stranded kerbals not being spawned #382

Closed Xinayder closed 7 years ago

Xinayder commented 7 years ago

Fixes #381. The issue was that the scenario type was invalid, and the body was also invalid. I also added a check for if the contract is for rescuing kerbals only. We need to handle compounds and parts later.

81ninja commented 7 years ago

I think I now have a little more insight into this.

Now that your fix spawns Kerbals for Offered contracts, the derelict (a crewed part - any of the command pods/cockpits) does appear while ingame when the contract is accepted. A kerbal inside a vessel is generated and placed in orbit.

The vessel, however, doesn't get saved to the server, so when you restart the game it's gone (and gets recreated as a kerbal in EVA). I think this is because in single player mode the Kerbal is actually added to the roster (while in DMP it isn't).

Other considerations:

I wasn't able to tell where the orbit parameters come from- I think a random seed, but I've seen contracts for orbits and for low orbits so it may be known beforehand. After some save file editing I was able to tell that the value recoveryLocation = 1 means Low Orbit and recoveryLocation = 2 means Orbit. The rest I think is random but from experience and some math it means

            double maxAltitude = minAltitude + contractBody.Radius * 0.5;

is creating orbits too high over Kerbin (up to 370 km) for those "novice" rescue contracts.

It should be a maximum of minAltitude + 180000 for LKO, since the game considers orbits up to 250km altitude as low. But how does that apply to other planets/bodies, and can that number be pulled from a method like the minimum altitude is?

About the values field, I was able to tell that

values = Array.ConvertAll(contractNode.GetValue("values").Split(','), double.Parse);
//double ? = values[0]; (I think this is contract expiry Time)
double ? = values[1];  (deadline?)
double advanceBonus     = values[2];
double completionBonus  = values[3];
double failurePenalty   = values[4];
//double ? = values[5]; (usually 0 - science Bonus?)
double repBonus         = values[6];
double repPenalty       = values[7];
//double ? = values[8]; (contract deadline?)
double minmaxLifeTime         = values[9];
//double ? = values[10]; (usually 0 - no idea)

This is the (partial) answer to //It's not supposed to be infinite, but you're crazy if you think I'm going to decipher the values field of the rescue node. :laughing:

Xinayder commented 7 years ago

EDIT: okay, I've finally found a way to send the vessel updates to the server, so that the contract vessels are saved. However, the only problem we now have is that when you disconnect and reconnect, the contract is marked as finished/terminated/cancelled. I've also fixed the orbits of the contracts, so now you're able to have low and high orbit contracts.