Sign in to follow this  
okder

[1.3.0] Fair Lab

Recommended Posts

this mod solves problem of cheat-unlimited science from lab(s) (each stock lab(accompanied with 2 scientist and rover with instruments) gives you 3000 science from minmus each 3 years, which in turn makes even Duna visit meaningless)

this goal is accomplished by

1. removing data concept from lab.

2. all bonus science from lab goes to corresponding research, so many labs can't give unlimited science on same subject (science bonus currently 100% of original science and limited by lab location and scientists levels and stupidity, 110% for kspie, needs testing)

Features:

1. lab can send science(both collected, and bonus) without losses, but only if scientific subject already studied at lab at least up to 5% (bonus) by scientist on same celestial body, where it was obtained(last part required only if you want send research bonus itself). You can resend it as many times as you want (using button "Fair Transmit Science"), in case link was lost, or send updates if you collected(combined)/researched more.

2. lab bonus science can be viewed inside science archives ("from Lab" entries), after it was transmitted from lab.

3. lab can combine several experiments made by same equipment type in same conditions into one experiment, similar way of how its done in ksp,

to use that feature you need to dock science lab and experiments with scientific data (at least two made in same location, and same type, but launched in different launches), and press button "FairCollectScience", it will copy data from experiments inside lab and combine them (if possible), you can do docking in sequence(same time not needed), and you could use instruments in same vessel as lab(as one source, you still need other(s)), but if you move data from experiment equipment, you would lose ability to combine it later(you still could study it inside lab but without ability to combine later with other experiment).

this complex way is necessary to prevent cheating (multiple data scan by same equipment), and also because ksp don't mark scientific data with launch id, when created, so it can only identified from equipment it was created (while data still there).

 

Science bonus depends both on current lab position (you would get 50% of max bonus if you within soi of celestial body, where scientific data is acquired, and up to 100% if situation and biome also matched) and (mutliplied by) cumulative level and smartness (1-stupidity) of scientists (formula is pow(level13*(1-stupidity1)+level23*(1-stupidity2),1/3) )/5 ), i.e. one level five scientist with stupidity 0, could give 100% science bonus, science processing speed also depends on lab location, and scientists levels.

binary https://drive.google.com/open?id=0B0rgcOJPK_8XZ1JJMldFXzhXd0E 1.2.2

https://drive.google.com/file/d/0B0rgcOJPK_8XUVFIem1jMjgybkk 1.3.0

(just extract inside ksp data folder, and resolve conflict ModuleManager if exist (leave only latest ) )

source https://drive.google.com/open?id=0B0rgcOJPK_8XZHJTT2ljNF9qUWM

img.jpg

on screenshot in processed queue first percentage is how much science did you collected (combined) on subject, second percentage is how much researched, second maximum (bonus) depends on first one, as soon as it reaches 5% you could send both to ksc.

Fair toggle prepare(send) only allows study only up to 5.1% just to be able to send original experiment data to ksc without losses (using Fair Transmit Science).

updated, initial compatibility with ksp interstellar extended added.

 

in archives FairLab science can be seen such way (for example)

OpU3VJG.jpg

P.S. i hope SQUAD would include that mod inside ksp.

normal gui planned...

don't forget lab in offline state while you leaving your vessel (i.e. you would think lab is working, but it is not) lab do auto shutdowns on resources absent, usually if you have a lot of research you could leave lab without supervision even longer than original one (as there is no data limit), but you should consider to move it from one biome to another, just to get maximum bonus.

debug logging (enable) option is not saved, so each time you switch to vessel if you expect to see some bug you should enable it (and send logs (after bug occurs) here)

science container functionality inside lab is fully enabled, but it is not linked to Fair lab code, so it will NOT allow combine scientific data, use FairCollectScience for that.

 

Edited by okder

Share this post


Link to post
Share on other sites

Interesting concept. I agree the stock method of Lab just begs to be exploited, which in my view is a bad design. They should have at least limited the number of times you can use data to generate science.  When confronted they reason that it is not broken because the player has to get the science lab to a remote location. This might be valid for inexperienced players but for experienced player this isn't a challenge at all.

Edited by FreeThinker

Share this post


Link to post
Share on other sites
6 minutes ago, okder said:

@FreeThinker i trying to make patch for kspie labs, and question appears it is supposed to use 0.1 Megajoules while function?

 

 
 
 

Yes, but it's kind of arbitrary, the idea was to make spamming science labs a lot more challenging. The justification is that the kspi science lab, is an advanced lab contained some very power hungry equipment like super computers and high power laser analysis.

Edited by FreeThinker

Share this post


Link to post
Share on other sites

@FreeThinker

currently set follow settings for basic lab (Large_Crewed_Lab)
	{
		name = ModuleFairLab
		CrewsRequired = 1
		ScientistBonus = 0.25
		SciencePerYear = 200
		MaxBonusMult = 1
		RESOURCE
		{
			name = ElectricCharge
			rate = 5
		}

	}
for kspie scienceModule (initial lab no upgrade)
	{
		name = ModuleFairLab
		CrewsRequired = 2
		ScientistBonus = 0.3
		SciencePerYear = 250
		MaxBonusMult = 1.05
		RESOURCE
		{
			name = Megajoules
			amount = 0.1
		}
	}
for kspie scienceModuleAdvanced
	{
		name = ModuleFairLab
		CrewsRequired = 2
		ScientistBonus = 0.35
		SciencePerYear = 300
		MaxBonusMult = 1.1 //will give 110% bonus if scientists are good enough
		RESOURCE
		{
			name = Megajoules
			amount = 0.1
		}
	}

 

Share this post


Link to post
Share on other sites
25 minutes ago, okder said:

@FreeThinker


currently set follow settings for basic lab (Large_Crewed_Lab)
	{
		name = ModuleFairLab
		CrewsRequired = 1
		ScientistBonus = 0.25
		SciencePerYear = 200
		MaxBonusMult = 1
		RESOURCE
		{
			name = ElectricCharge
			rate = 5
		}

	}
for kspie scienceModule (initial lab no upgrade)
	{
		name = ModuleFairLab
		CrewsRequired = 2
		ScientistBonus = 0.3
		SciencePerYear = 250
		MaxBonusMult = 1.05
		RESOURCE
		{
			name = Megajoules
			amount = 0.1
		}
	}
for kspie scienceModuleAdvanced
	{
		name = ModuleFairLab
		CrewsRequired = 2
		ScientistBonus = 0.35
		SciencePerYear = 300
		MaxBonusMult = 1.1 //will give 110% bonus if scientists are good enough
		RESOURCE
		{
			name = Megajoules
			amount = 0.1
		}
	}

 

 

Oh wait, the Advanced KSPI Lab was just a placeholder, the actually unlocking of functionality was done by code which verified unlocked tech nodes. Therefore this would not work.

Share this post


Link to post
Share on other sites
20 minutes ago, FreeThinker said:

Oh wait, the Advanced KSPI Lab was just a placeholder, the actually unlocking of functionality was done by code which verified unlocked tech nodes. Therefore this would not work.

it looks working at least in sandbox (there are other problems with science, and my plugins fails, so now i fixing those fails)

hmm you right something works wrong, but i will publish anyway (last entry seems did not applied in sandbox for some reason)

i.e. for your lab works only second (middle) entry.

Edited by okder

Share this post


Link to post
Share on other sites
4 minutes ago, okder said:

it looks working at least in sandbox (there are other problems with science, and my plugins fails, so now i fixing those fails)

 

 
 

Well, the placeholder shouldn't actually be buildable, this is more of a shortcoming (bug) of the part menu. This part should have been removed some time ago

Edited by FreeThinker

Share this post


Link to post
Share on other sites

@FreeThinker , i did posted updated version(same links,google drive version manager works), if you did not see i updated previous post, i.e. you right it does not work fully as expected, so i need your advice how to make ModuleManager process it right.

 

Edited by okder

Share this post


Link to post
Share on other sites
1 hour ago, okder said:

@FreeThinker , i did posted updated version(same links,google drive version manager works), if you did not see i updated previous post, i.e. you right it does not work fully as expected, so i need your advice how to make ModuleManager process it right.

 

 
 
 
 
 

Although it would be best if your mod integrated some upgrade feature which verifies unlock tech nodes similarly how it is done in KSPI), the easiest method would be to use MM script to clone/derive the KSPI science lab and override its config and part modules. The following MM should work

+PART[scienceModule]
{
	@name = fairScienceModule
	@TechRequired = tech

	@MODULE[ModuleFairLab]
	{
		// desired changes
	}
}

Edit: fixed MM

Edited by FreeThinker

Share this post


Link to post
Share on other sites

i don't understand what do change "+" instead of "@", again

@PART[scienceModule]:NEEDS[WarpPlugin]:AFTER[WarpPlugin]:FOR[FairLab]

seems works properly, but

@PART[scienceModuleAdvanced]:NEEDS[WarpPlugin]:AFTER[WarpPlugin]:FOR[FairLab]

is not

(can be easily checked with DumpLog, and last line there(in KSP.log) FairLabFinQueueLen .... maxBonus 1.05 , but for scienceModuleAdvanced maxBonus should be 1.1)

Edited by okder

Share this post


Link to post
Share on other sites

the ''+" instead of a "@" will make you create a new part bested on another part, but I forgot to mention you also need to change the name.

I fixed the MM script to clarify

Edited by FreeThinker

Share this post


Link to post
Share on other sites
1 hour ago, FreeThinker said:

the ''+" instead of a "@" will make you create a new part bested on another part, but I forgot to mention you also need to change the name.

I fixed the MM script to clarify

the idea is to patch scienceModuleAdvanced i.e. advanced version of kspie lab (which is available when all tech researched),

how creation of new part will accomplish that?

 

Share this post


Link to post
Share on other sites
On 18-1-2017 at 2:36 PM, okder said:

the idea is to patch scienceModuleAdvanced i.e. advanced version of kspie lab (which is available when all tech researched),

how creation of new part will accomplish that?

 

 
 
 

Well as this gives you the easy way to get access to a part with improved research potential. You could call it the Reseach Lab Mark 2. The best solution would require your mod to check if a tech node is unlocked and adjust some of it key performances

Edited by FreeThinker

Share this post


Link to post
Share on other sites

I like the idea, but I am having trouble understanding the limits in this.  I think we need to rewrite the rules in your first post to be clearer.

For example I don't understand this at all:

1. lab can send science without losses, provided subject already studied to at least 5% (bonus) by scientist on same celestial body, where it was obtained.

Share this post


Link to post
Share on other sites
10 minutes ago, Liquid5n0w said:

1. lab can send science without losses, provided subject already studied to at least 5% (bonus) by scientist on same celestial body, where it was obtained.

i did rewrite it see original post.

some clarification about why 5% required in real life.

scientist put together data and so determines where it was possible some equipment malfunction(data loss), and put additional markers to guarantee that data could be transmitted/re transmitted later without losses, you still able to send data old way (with transmission losses, and without making copy, actually new lab do copy anyway, you just can't extract that copy without study it first)

Share this post


Link to post
Share on other sites

updated: fixed init exception (when loading "old" save), fixed saving/loading limiter for "prepare(send) only"

 

 

Share this post


Link to post
Share on other sites

@okder Look for the method PluginHelper.HasTechRequirementOrEmpty in KSPI-E code

 

       public static bool HasTechRequirementOrEmpty(string techName)
        {
            return techName == String.Empty || PluginHelper.upgradeAvailable(techName);
        }

        public static bool HasTechRequirementAndNotEmpty(string techName)
        {
            return techName != String.Empty && PluginHelper.upgradeAvailable(techName);
        }

        public static bool hasTech(string techid)
        {
            if (String.IsNullOrEmpty(techid))
                return false;

            if (ResearchAndDevelopment.Instance == null)
                return HasTechFromSaveFile(techid);

            var techstate = ResearchAndDevelopment.Instance.GetTechState(techid);
            if (techstate != null)
            {
                var available = techstate.state == RDTech.State.Available;
                if (available)
                    UnityEngine.Debug.Log("[KSPI] - found techid " + techid + " available");
                else
                    UnityEngine.Debug.Log("[KSPI] - found techid " + techid + " unavailable");
                return available;
            }
            else
            {
                UnityEngine.Debug.Log("[KSPI] - did not find techid " + techid);
                return false;
            }
        }

        private static HashSet<string> researchedTechs;

        public static void LoadSaveFile()
        {
            researchedTechs = new HashSet<string>();

            string persistentfile = KSPUtil.ApplicationRootPath + "saves/" + HighLogic.SaveFolder + "/persistent.sfs";
            //UnityEngine.Debug.Log("[KSPI] - Loading ConfigNode " + persistentfile);
            ConfigNode config = ConfigNode.Load(persistentfile);
            ConfigNode gameconf = config.GetNode("GAME");
            ConfigNode[] scenarios = gameconf.GetNodes("SCENARIO");

            foreach (ConfigNode scenario in scenarios)
            {
                if (scenario.GetValue("name") == "ResearchAndDevelopment")
                {
                    ConfigNode[] techs = scenario.GetNodes("Tech");
                    foreach (ConfigNode technode in techs)
                    {
                        var technodename = technode.GetValue("id");
                        researchedTechs.Add(technodename);
                    }
                }
            }
        }

        public static bool HasTechFromSaveFile(string techid)
        {
            if (researchedTechs == null)
                LoadSaveFile();

            bool found = researchedTechs.Contains(techid);
            if (found)
                UnityEngine.Debug.Log("[KSPI] - found techid " + techid + " in saved hash");
            else
                UnityEngine.Debug.Log("[KSPI] - we did not find techid " + techid + " in saved hash");

            return found;
        }

        public static bool upgradeAvailable(string techid)
        {
            if (String.IsNullOrEmpty(techid))
                return false;

            if (HighLogic.CurrentGame != null)
            {
                if (PluginHelper.TechnologyIsInUse)
                    return PluginHelper.hasTech(techid);
                else
                    return true;
            }
            return false;
        }

 

Edited by FreeThinker

Share this post


Link to post
Share on other sites

@FreeThinker that does not care about retrofit interface, i.e. it will work without retrofit, i would probably try to read isupgraded field from FNPlugin.ScienceModule but that would be slow  (reflections) so i would do it only once at OnStartFinished, i.e. reload would be required after retrofit.

            PartModule m = part.Modules["ScienceModule"];
            if (m == null)
                return false;
            return m.Fields.GetValue<bool>("isupgraded");

 

Edited by okder

Share this post


Link to post
Share on other sites
2 hours ago, FreeThinker said:

I don't understand how this would be useful.

i can't do slow check for upgrade was made (for that particular lab) each frame, i  am doing it now on OnStartFinished , but that's not cover time-span after retrofit was done, and before next load occurs, but i can do it additionally on event VesselWasModified  , you could choose other event of course if you wish.

alternatively i could use GameEvents.OnScienceChanged and check next frame after it occurred, it would be small overhead however, and hack (because you charge science as currency for retrofit, if you would change that this behavior should be also changed)

Edited by okder

Share this post


Link to post
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.

Sign in to follow this