Jump to content

Splitting science into types


Recommended Posts

I've set my sights on what I suspect is a rather ambitious project, and I'm hoping someone can point me in the right direction to get started. I've got some hobbyist-level coding experience and in the past I've created a few new parts for KSP, but I've never been this deep "under the hood" before.

The core function of the mod is to split the generic Science resource into 4 new categories. Experiment results will be converted into varying amounts of points in these sub categories (which categories get the points depends on the experiment), then different combinations of these points will be required to unlock different tech nodes. A more thorough explanation of the idea has been posted here, though some of the fancier features will of course wait until I get the basic framework handled.

Breaking it down, I'd appreciate any suggestions or links to code examples from other mods that would be relevant to the following tasks:

  • Add new persistent career-wide resource types like funds, reputation, and science.
  • Intervene in the process of experiment results being recovered/transmitted and converted into the science resource so that the points can be distributed to the new kinds of science points; this would need to be sensitive to the type of results so the distribution of the points can be modified based on the source.
  • Modify the cost of unlocking research nodes to require the new kinds of science points.

Thanks in advance!

Link to comment
Share on other sites

That seems interesting but hard ... you should ask sarbian :D

Sarbian... Sarbian... Sarbian!

...nope, nothing.

Seriously though, I don't feel entitled to directly pester one of the masters when I'm just a fledgling who's probably aiming way too high. The reddit crowd liked my idea, but I've gotten zero feedback from the post I made about it here, so I'm not as optimistic that it's worth the effort anyway. Nevertheless, I'll keep poking at things on my own and see where I get. :)

Link to comment
Share on other sites

Yeah, I did not want to reply since the scope is large, is not answered in a couple of sentences and outside the part of the game I know best. The idea by itself is good but it require to override so much stock mechanics...

Storing the resource state is the easiest : You use a ScenarioModule with your logic and values.

The science part require a replacement of a quite a few modules to handle research and transmission of multiple type of value ( ModuleScienceExperiment & ModuleScienceContainer as a bare minimum and I guess a few more).

The techTree may be the more complex part and have no idea if it can be done without redoing the whole screen yourself.

Link to comment
Share on other sites

I've looked much at the

TechManager mod's code when was studying science and tech tree related stuff.

I don't think your goal is that impossible. You could hook to GameEvents.OnScienceReceived (haven't used it but the name sounds interesting, right?) You can also replace R&D's research button handler:

yourTechTree.controller.researchButton.SetInputDelegate(new EZInputDelegate(yourResearchButtonHandler));

and distribute your custom science as you wish.

Edited by Ser
Link to comment
Share on other sites

After putting some more thought into it I realized that some of the science stuff could be worked around by not directly interfering with the generic science collection. The plan is to keep the same science values with all experiments, just split those points among the categories (in different proportions depending on the experiment), so the stock science points would be equal to the sum of all the new categories and could still be consumed when a tech node is unlocked.

If I just monitor for the transmission/recovery of experiments (maybe just by tracking changes to the science archives?) then I can trigger the addition of the points to the category totals. I'm betting if I look at Kerbal Construction Time's delayed research feature I can figure out how to control research node unlocking to also require the designated amounts of subcategory points.

Since mobile lab research doesn't return its science as a result of a particular experiment (does it?) that would be a trickier one to deal with. An easy solution would be regularly comparing the stock science totals to the category totals, then adding equally to all category totals until their sum matches stock points again. If I could capture and maintain a list of experiments that are added to labs as data I could at least create some sort of weighted distribution ratio to be used in those checks.

The part I have the least idea how to approach is presenting the relevant information in a useful way. For experiments maybe I could use something like Module Manager to automatically add "Experiment yields X% Chemistry, Y% Physics." to the results description? Indicating the category point requirements on the research screen is even trickier, though I could perhaps use the same approach to insert the requirements in the node description.

In my imagination there would be little icons for the categories that show up where the stock science requirement appears now, but I'm betting that would involve hacking that whole interface, as suggested.

- - - Updated - - -

You could hook to GameEvents.OnScienceReceived (haven't used it but the name is interesting, right?)

That certainly sounds like what I'm looking for when it comes to capturing returned results...

You also can replace R&D's research button handler:

yourTechTree.controller.researchButton.SetInputDelegate(new EZInputDelegate(yourResearchButtonHandler));

and distribute your custom science as you wish.

And that definitely looks like another solution. Thank you!

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...