Jump to content

How does Science work?


Recommended Posts

Hi all. I've got some ideas for a mod to change the way science data is collected/stored/converted into science points (briefly, instead of experiments that run once and store data, you have sensors that collect data continuously, comms antennas send it back continuously, and it asymptotically approaches max science for that biome/situation/data type situation), but I'm running into a bit of a block in that the various science classes aren't terribly well-documented, at least as far as I can see. Does anyone know what the 'science lifecycle' is? My current understanding is something like this:

- Vessels have a ModuleScienceExperiment and optionally a ModuleDataTransmitter and some ModuleScienceContainers. (Do EVAs have a ModuleScienceExperiment? Crew capsules definitely do.)

- At some point in flight, DeployExperiment() or DeployAction(KSPActionParam) get called. That triggers any relevant animation and creates a ScienceData. ScienceData is created as a number of mits, with an id that points into the science subject table and provides the data-per-mit information. Also stores the reduction for transmission and the boosted-by-lab state per-sciencedata. The ModuleScienceExperiment keeps that ScienceData in an internal array. Relevant: ScienceUtil is used to get experimental biome/situation. What does GetTransmitterScore do?

- If comms: ModuleDataTransmitter::StartTransmission() or TransmitData() get called, do something to increment science at home, and call ModuleScienceExperiment::DumpData()

- If collected by Kerbal: ModuleScienceExperiment::CollectDataExternalEvent() gets called, does something?

- If moved into ModuleScienceContainer: Don't know. Presumably AddData() gets called on the modulesciencecontainer or something? Which object is responsible for this? When is this used? Presumably EVA Kerbals returning to a command pod or the like trigger this.

- If recovered: ScienceData in modules is transformed into science points somehow.

Essentially I'm interested in how the conversion to science points happens and how I can do it myself - essentially, implementing MyModuleScienceExperiment that does things completely differently. I'm not sure there's a clean way to implement what I'm thinking of doing on top of the current mechanics - maybe have a ModuleScienceExperiment that every FixedUpdate() makes ScienceData at very small data sizes and then SendEvent(StartTransmitting()), but that's pretty ugly. I'm not sure I can safely 'merge' ScienceData objects.

Any thoughts?

Edited by jamespicone
Emoticons!
Link to comment
Share on other sites

I've done some more work on this and asked around a lot in the #kspmodding channel on EsperNet, the central class here is ResearchAndDevelopment. In particular, ResearchAndDevelopment.GetExperimentSubject, GetExperiment, GetScienceValue, and SubmitScienceData. I've now got my mod at the point where it can generate pseudo-ScienceData and when the vessel is recovered it gets collected. Buuuuuttttt.... the Research and Development archives don't update properly, science doesn't update properly, and in general it's not quite functioning right.

Code is here: https://code.google.com/p/ssaad/source/browse/ . I'm doing the following to update science during vessel recovery:


public void handleRecoveryProcessing(ProtoVessel pv, MissionRecoveryDialog d, float f) {
foreach (JMPScienceSubject s in scienceData.Keys) {
float sci = ResearchAndDevelopment.GetScienceValue(scienceData[s], s.subject);
ResearchAndDevelopment.Instance.SubmitScienceData(scienceData[s], s.subject);

d.AddDataWidget(new MissionRecoveryDialog.ScienceSubjectWidget(s.subject, scienceData[s], sci));
}

scienceData.Clear();
capacityUsed = 0;
part.RequestResource("DataStorage", -capacity);

GameEvents.onVesselRecoveryProcessing.Remove(handleRecoveryProcessing);
}

The MissionRecoveryDialog is displaying 0.0 for science earned (which I can fix by adding to MissionRecoveryDialog.scienceEarned, but that doesn't seem like the right way to do things), and while the subjects are showing up in the research and development archives, they're displaying as having 0 science done on them and the bar is completely empty. I also get full value of any additional missions hitting the same science subject. Anyone have any ideas why that's happening and how I can fix it? I've tried playing around with the fields of ScienceSubject during recovery processing and that doesn't seem to be helping any.

Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...