Jump to content

[WIN] [SCRIPT] [EXTERNAL] PMCSE - Poor Man's Contract Science Eraser


Superfluous J

Recommended Posts

THIS DOES NOT WORK WITH FINE PRINT. YOU WILL CRY IF YOU TRY TO USE THESE TOGETHER

I don't know about the rest of you, but I'm getting sick of having more and more ways to get science, when the tech tree can already be unlocked without even leaving Kerbin's SOI.

I was hoping someone smart would have by now released a mod that would eliminate contract science gains, but so far that mod has not come forth. So I (read: someone not smart) came up with the next best thing: A little script that will - with the help of the SED utility - scrub your persistent.sfs file of science gains for you!

HOW TO SET UP

You have to do this one time, when you first set up the mod.

  1. Copy the below code into a batch file. I suggest pmcse.bat. I further suggest you put this in your path or on your desktop.
  2. Edit the "~~~~~~~~~~~~~" to be the path to your save file. You'll need to find out this path for yourself. It will probably be something similar to c:\ksp_win\saves\default (Leave off the last \ like I did there)
  3. Download and install sed for windows. This has to be in your path.
  4. Test it by running it (BACK UP YOUR PERSISTENT FILE FIRST). I suggest trying it with a brand new save. Take the first 4 contracts, exit your game, run the script, then go back in and see if the science gains are gone.

HOW TO USE

Once set up, you need to do a little work to make this work every time you take a contract or set of contracts that have science gains:

  1. Exit your save game (exit to main menu, not the game)
  2. Run the script.
  3. Re-enter the game and check your contracts. They should not have science listed anymore.

NOTE: This only works for Windows! I don't have a Mac and don't play on Linux. If someone wants to make something like this that works for those, I'll happily put their code in this post.

NOTE 2: This is probably not for the faint of heart when it comes to fiddling with batch files, paths, and installing programs on your computer. I can't make it much easier than it is.

NOTE 3: This works with all 0.24.* versions up to 0.24.2. It may not work in future versions but (unless someone writes a real mod for this) I'll do my best to maintain it so it does.

NOTE 4: Please someone make this into a real mod for the game :)


pushd ~~~~~~~~~~~
del persistent.001
ren persistent.sfs persistent.001
sed "s/\(values = [0-9.]*,[0-9.]*,[0-9.]*,[0-9.]*,[0-9.]*\),[0-9.]*,\([0-9.]*,[0-9.]*,[0-9.]*,[0-9.]*,[0-9.]*,[0-9.]*\)/\1,0,\2/g" persistent.001 > persistent.002
sed "s/\(^ values = [0-9.]*,[0-9.]*\),[0-9.]*,\([0-9.]*,[0-9.]*\)/\1,0,\2/g" persistent.002 > persistent.sfs
fc persistent.001 persistent.sfs
pause
popd

Edited by 5thHorseman
Link to comment
Share on other sites

You literally did this with sed, regex and all, in Windows... Now I feel like I need to write a plugin, but before I succumb to that I'm going to have to put you out of your misery.

Link to comment
Share on other sites

Is there a better way to do this in Windows?

No idea, I just know old-school Linux sysadmins and professional programmers who balk at the thought of trying to get sed to work.

Link to comment
Share on other sites

No idea, I just know old-school Linux sysadmins and professional programmers who balk at the thought of trying to get sed to work.

Ah. Well, it's not without its quirks (For example, it's more technically correct to use + than * but in my version of sed that simply does not work) but I've been using it for... jeez has it really been almost 2 decades now? Wow I feel old. Anyway. That long.

[nerd]I considered writing an awk script but this was easier and doesn't seem to cause any conflicts.[/nerd]

Edited by 5thHorseman
Link to comment
Share on other sites

  • 2 months later...

This is not even remotely tested :sticktongue:, but it might do what you're looking for. It only works for newly offered contracts. There is also a possibility that the values may revert, but I think they should only be set once. If it works I'll package up something and release it.


using UnityEngine;
using Contracts;

namespace ContractScienceKiller
{
[KSPAddon(KSPAddon.Startup.MainMenu, true)]
public class QuashContractScience : MonoBehaviour
{
private bool started;

private void Start()
{
if (!started)
{
GameEvents.Contract.onOffered.Add(onContractOffer);
DontDestroyOnLoad(this);
started = true;
}
}

private void onContractOffer(Contract c)
{
c.ScienceCompletion = 0;
foreach (ContractParameter cP in c.AllParameters)
cP.ScienceCompletion = 0;
}

}
}

Link to comment
Share on other sites

This is not even remotely tested :sticktongue:, but it might do what you're looking for. It only works for newly offered contracts. There is also a possibility that the values may revert, but I think they should only be set once. If it works I'll package up something and release it.

~SNIP~

I am willing to test this however I need 1 of 2 things:

1) A compiled dll

2) A guide (Is this up to date?) to compile it to a dll on linux (java guy here)

Link to comment
Share on other sites

Looks like the guide was still current:

o3Wicia.png

I had to change the code to:


using System;
namespace ContractScienceKiller
{
[KSPAddon(KSPAddon.Startup.MainMenu, true)]
public class QuashContractScience : UnityEngine.MonoBehaviour
{
private bool started;

private void Start()
{
if (!started)
{
GameEvents.Contract.onOffered.Add(onContractOffer);
DontDestroyOnLoad(this);
started = true;
}
}

private void onContractOffer(Contracts.Contract c)
{
c.ScienceCompletion = 0;
foreach (Contracts.ContractParameter cP in c.AllParameters)
cP.ScienceCompletion = 0;
}

}
}

One thing I noticed was the "Test TR-18A stack decoupler orbiting kerbin" was giving me 419rep points... that seems a tad on the high side ?

Link to comment
Share on other sites

It seems to work fine. I made a [thread=99664]release thread for it[/thread].

If there is any interest I could possibly make it more configurable, reducing science by a percentage for example, or maybe even make it save-specific.

Link to comment
Share on other sites

the tech tree can already be unlocked without even leaving Kerbin's SOI.

Uh, well(thanks to NASA) we've never really done much outside Earth's LEO, they kind of went up to the moon and didn't like what they saw, and never went back. Most of the stuff in the tech-tree is about at our level today. Therefore, the Kerbals do MORE than we did to get that stuff. It's depressing to realize how short we've traveled. Anyways, nice mod! Thanks for making it!

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