Recommended Posts

Contract Configurator - A config-file based solution for creating new contracts!

How it Works

Contract Configurator exposes various hooks into KSP's contract system through a standard config file syntax. This means that modders using Contract Configurator can create new contracts without writing any code. The config file format has 5 basic sections:

Parameters - These are mappings to the stock ContractParameter classes which specify what the player has to do to complete the contract.

Requirements - This is what is required before the contract will show up. Most of the ProgressTracking information is supported, along with a few other things.

Behaviours - These are behaviours that are applied at the contract level. A behaviour can create additional objects related to the contract (such as spawning Kerbals), be used to store persistent data or any number of other things.

Data nodes - These define new data for use within the contract using Contract Configurator's powerful expression language.

And if the provided parameters and requirements aren't enough, Contract Configurator is extensible. New parameters and requirements can be added in as little as a dozen lines of code.

Fixed issue with contract generation process starting up before the stock contract system was done loading. This would cause contracts to be offered that weren't supposed to be offered, which could cause other issues (like a contract that can be accepted but is then removed, or an active contract that gets removed unexpectedly). Thanks to everyone who's been very patient on this nasty & hard to track down bug.

New Mission Control layout. Now all contracts that are eligible are available all the time (players are no longer at the mercy of the RNG to get the contracts they want). Also, can view the details of what contracts are *not yet* available, and what it takes to make them available.

New contract art (special thanks to Enceos)!

Contract generation overhaul. Overhaul to the contract generation system for massive performance improvements. Contracts are no longer generated in-flight (no garbage, no stutters).

Added title and related attributes for REQUIREMENT nodes.

Added title and related attributes for DATA nodes.

Added sortKey for CONTRACT_TYPE and CONTRACT_GROUP nodes.

New List.SelectUnique() method for selecting unique values (replaces selecting a random value and hoping that it hasn't been used before).

New DATA_EXPAND node allows a CONTRACT_TYPE to be duplicated across a list of values (eg. duplicated for each Celestial Body).

New CelestialBody.Index() method to get the global index of a body (for sorting).

More warnings to steer contract authors towards more performant and more player-friendly ways of writing contracts.

Fixed problem with loading pqsCity and targetBody out of order in WaypointGenerator (thanks severedsolo).

Version Checking

This mod includes version checking using MiniAVC. If you opt-in, it will use the internet to check whether there is a new version available. Data is only read from the internet and no personal information is sent. For a more comprehensive version checking experience, please download the KSP-AVC Plugin.

Recommended Mods

The following is a list of mods that enhance some of the things Contract Configurator does:

Waypoint Manager - this will help with any contract using the stock waypoint system by drawing the waypoints in the flight view. Makes hitting targets more accurately much easier!

Field Research@nightingale- Contracts to do science! Receive contracts for performing a variety of experiments under different situations. Use it to drive the science in your space program, or use it to collect every last bit of science.

Tourism Plus@nightingale- Better tourism! A richer tourism experience than stock. Take tourists to space and to visit the stations and bases that you've already created. Build new tourist attractions like the space casino mega-project.

Kerbin Side GAP@Keniamin- Inspired by GAP and Kerbin-SideJobs, provides contracts for air shuttles between various Kerbin-Side bases.

SETI-Contracts@Yemo - The SETI-Contracts offer a rebalanced contract progression designed for unmanned starts, though they work with tech trees offering manned starts as well, like the stock tech tree.

Mission Based R&D@klefenz - Overhauls the R&D system of career mode by neutralizing the science points and unlocking tech nodes as a reward for completing missions. (No longer available to download as old kerbal-stuff link no longer valid)

Maritime Mission Pack@Whitecat106 - A series of missions set at sea for a better use of Kerbin's vast oceans! Includes missions above and under water! (Modder advised leaving the KSP modding scene and now unsupported)

Kerbin-SideJobs@AlphaAsh - Contracts for Kerbin-Side! Ferry passengers and cargo between different Kerbin-Side bases. Also has missions of a campaign relating to ancient anomalies, with espionage and intrigue (in spaaaaaace)! (No longer supported - newKerbin-Side continuedmod maintainer@Ger_space might look into it in future)

The K-Files@severedsolo - The first story based contract pack. The truth is out there! (Modder advised this is now unsupported due to lack of time)

Initial Contracts (SETI)@Yemo- InitialContracts replaces the buggy/annoying stock starting contracts with 3 similar ones, which can be completed by manned and unmanned craft. Thus the mods contracts are especially useful for TechTrees which start unmanned and may be redistributed with them If you like what you see, then check out SETI-Contracts for the full deal! (Seems that support for this pack has dropped as last release was for KSP1.1.2)

Banking@Arachnidek- Adds a bank to the game. The bank﻿gives you money and after 2 weeks it takes it back with some interest. (Built for KSP 0.90, unsupported since then)

Rules for Getting a Contract Pack Listed

A contract pack is an add-on and falls under Squad's forums rules for add-on posting. All rules in that posting must be followed, but this licensing one in particular should be pointed out (emphasis mine):

Licenses
All add-ons that are posted on the services maintained by Squad that serve the KSP Community (such as this forum and Curse) must be accompanied by a license that regulates what other users can do with the copyrighted material. This license must be made available in both the download file and in the location the user downloads from (such as a forum post or a Curse listing).

If the contract pack modifies, enhances or uses another mod, be respectful of the licenses of those mods. If the maintainer of a mod used by a contract pack requests that a contract pack be removed or modified, please work with them to make the Contract Pack comply with their wishes and vision for their mod. Remember that the contract pack wouldn't be possible without the original author's mod.

I, nightingale, have the final say on what is listed. I do not generally want to be the one telling people what they can and cannot do, so I will list most contract packs so long as the comply with the above two rules.

Recommendations for Contract Packs

Have your contract pack install into a subdirectory under GameData/ContractPacks/. Contract Configurator does not require this directory structure, but this keeps it cleaner for the end user.

If adding your contract pack onCKAN, a name of the form "Contract Pack: <name of contract pack>" is recommended. This keeps the listings of all contract packs together, and allows the player to easily compare and decide which contract packs they are interested in.

Try to be original. If your contract pack has significant overlap with an existing contract pack, consider contacting the author and working with them to enhance the contract pack.

Share this post

Link to post

Share on other sites

Your doing the work of the gods. This will lead to a whole lot of contract mods and that is a good thing. Would it be possible to add something that can disable the standard contracts, so that if you make for example a pack of contracts that resemble the Space Race, you won't have the stock contracts messing up the contracts menu.

Share this post

Link to post

Share on other sites

First, VesselSpawner - which would spawn a ship at specified orbit, just like Kerbals from rescue contracts (I'm not talking about surface spawn now, just orbit). The vessel itself comes from Ships folder (i.e. it's possible to spawn, say, Aeris 3 at LKO, or any of your designs, or a design which comes with contract pack). It cannot be controlled until docked with.

Second, completion (or failure) of another contract as a requirement of spawning of the next contract. You can see why it's needed - with it, it would be possible to set up a full-blown, non-linear, story-driven campaign.

Share this post

Link to post

Share on other sites

It needs a duration parameter to accommodate and reward those using life support mods. (ie remain in orbit for 10 days)

OR...

Requirements for specific resources can ape a duration requirement (ie must have at least 5 Oxygen onboard").

With the original mission controller mod we could write contracts that would chain requirements. That made storytelling possible. Go here then go there ... rather than Squad's dwarf-fortress approach allowing only procedurally generated contracts.

Share this post

Link to post

Share on other sites

Thanks all for the really positive feedback. I'm happy that my first mod has been so well received!

Great job!

Is it possible to add two things?

First, VesselSpawner - which would spawn a ship at specified orbit, just like Kerbals from rescue contracts (I'm not talking about surface spawn now, just orbit). The vessel itself comes from Ships folder (i.e. it's possible to spawn, say, Aeris 3 at LKO, or any of your designs, or a design which comes with contract pack). It cannot be controlled until docked with.

Good idea, I think it should be workable. Let me start with the Kerbal version (ie. like the rescue contract) and work my way there. I'm thinking it would be an optional section that can be added to the RecoverKerbal to generate the Kerbal (it doesn't right now because that logic in stock sits in the Contract and not the ContractParameter (I'm currently only providing a wrapper to generate the ContractParameter). I'm thinking you'd be able to specify the attributes of the orbit (using the same values HyperEdit uses such as apoapsis, periapsis, inclination, etc.). Unless of course, you're happy just with circular equatorial orbits at 100km...

Once I get that going, the I don't think ship version shouldn't be a huge jump.

Second, completion (or failure) of another contract as a requirement of spawning of the next contract. You can see why it's needed - with it, it would be possible to set up a full-blown, non-linear, story-driven campaign.

The requirement having another one complete is already there, that's the CompleteContract requirement:

// Requirement for having a certain number of contracts completed of the given type. REQUIREMENT { name = CompleteContract1 type = CompleteContract

// The type of contract being checked. This can either be a ContractConfigurator contract // type or a standard contract type (class). contractType = SimpleTestContract

// The minimum number of times the given contract type must have been completed before // the requirement is met. // Default = 1 minCount = 1

// The maximum number of times the given contract type can be completed before the // requirement will no longer be met. // Default = Infinite maxCount = 5 }

I'll maybe enhance this (or create a different one) to allow for requiring that a contract be failed.

You correctly guessed where I'm going with this - the mod that I wanted to build was one that had a tree of progression based one-time contracts, but I realized they didn't fit nicely in with the way the Squad contract system works. Most of my goals around ContractConfigurator are to set the stage for this future mod.

Your doing the work of the gods. This will lead to a whole lot of contract mods and that is a good thing. Would it be possible to add something that can disable the standard contracts, so that if you make for example a pack of contracts that resemble the Space Race, you won't have the stock contracts messing up the contracts menu.

Awesome. Any plans for an end-user version? I'd love a way to block certain contracts from being generated in the first place

Yup, definitely plans for building a mod using ContractConfigurator. I'd considered for that mod that I might disable the stock contracts (or some of them), but decided to just leave it. Since there's interest I'll look into ways to disable contracts via ContractConfigurator configuration - it looks like the list of valid contract types is public in the Squad code, so I should be able to modify it (just need to figure out the right time to do it).

While we're asking things, the one thing I saw lacking in that is the ReturnFrom parameter. It also would be nice to have some generic parameters, like HasCrew, HasPower, etc.

(The reason for these is it would be nice to make a "crewed orbit" mission, i.e. return a kerbal safely from orbit.)

For the first release I didn't write any parameters - just wrappers to the stock ones. The next major goal will be supporting Fine Print parameters (since they will be stock soon enough anyway). After that I'll looks at interesting/generic parameters/requirements. The ones you've mentioned all seem reasonable, I'll add them to the backlog.

It needs a duration parameter to accommodate and reward those using life support mods. (ie remain in orbit for 10 days)

OR...

Requirements for specific resources can ape a duration requirement (ie must have at least 5 Oxygen onboard").

I like it, that's a good idea. I'll have to play around with it a little bit to make sure it can be done as a standalone duration parameter. I'm thinking it will be a wrapper like this:

// Example - orbit the Mun for 10 daysPARAMETER{ // Parameter is completed when all child parameters have been completed for the specified duration type=Duration duration=10 days

As to your alternate suggestion I'd also like to be able to make this fit in with resource/mining mods - so Parameters like "have x amount of resource y" on a vessel are definitely in the pipeline. So in the end I'll probably implement both of these suggestions.

With the original mission controller mod we could write contracts that would chain requirements. That made storytelling possible. Go here then go there ... rather than Squad's dwarf-fortress approach allowing only procedurally generated contracts.

And that's the exact type of mod I'd like to make easy for people to write.

Link to post

Share on other sites

"Now, as you've surely deduced already from all this, this is why we're here".

Nice please add the Ability to modify the amount of research fom contracts

Do you mean modify the amount of research from other contracts (ie. stock ones)? I'll be honest, that's starting to get outside the intended scope of ContractConfigurator (which is providing an easy option for creating new contracts). Or did I misunderstand your request?

Share this post

Link to post

Share on other sites

I've got a couple of my old mission packs for lying around. But they all involve duration and/or resource requirements.

I did a bunch to simulate the realities if interplanetary flight. A sub-mission requirement such as ((in orbit = Sun) and (liquidfuel = 0) for (time=50 days)) forces the player to rely on xenon or monoprop, simulating the reality of boiloff without getting into realfuels-type plugins.

Testing missions would also benefit from a duration requirement. Run a test between 10k and 12k is easy. Staying between 10k and 12k for 5 minutes is a much much harder task.

Share this post

Link to post

Share on other sites

It's an achievement - KSPAchievements.ReturnFrom (Flight | FlyBy | Orbit | SubOrbit | Surface). A lot of the achievements seem to have a mirrored ContractParameter, but not this one. But given that there's an achievement, that means that there's the right hooks to make writing a parameter for it pretty easy (I hope).

I would highly suggest waiting a bit for dealing with FP, as we don't know how much has changed for 0.90.

That's probably good advice. Some of the FP parameters are so perfect in their simplicity that I can see them changing (ie. PartNameParameter - it's simply "have part x on the vessel"), but others may not fit well in current stock KSP (ie. ResourceExtractionParameter - there's currently no way to extract resources in stock). At the same time, there's stuff like ResourcePossessionParameter - which exactly matches up with the parameter that Sandworm suggested. I guess it depends on how hard it is - writing a ParameterFactory wrapper can be as quick as 5-10 minutes - and that's for the Squad ones where I have to make some guesses based on methods/members - having full access to the code makes the FP ones *easy*.

Arsonide, I'm sure you're under NDA, but if the FP parameters are going into stock relatively untouched, please cough or blink twice.

Share this post

Link to post

Share on other sites

Nice please add the Ability to modify the amount of research fom contracts

I know there's a mod (ZeroScienceContracts) which zeros out science for people who think science from contracts is cheaty.

Do you mean modify the amount of research from other contracts (ie. stock ones)? I'll be honest, that's starting to get outside the intended scope of ContractConfigurator (which is providing an easy option for creating new contracts). Or did I misunderstand your request?

I know the question is a bit out-of-scope, but in the process of writing the mod, have you found a way to get a reference to each contract as it is offered? I'm trying to do blanket editing of contracts, and what ZeroScience does won't work for me*.

*ZeroScience zeroes out the science on all contracts each time the list changes, whereas what I'm doing needs to be a one-time multiplier of funds. I've tried adding a dummy parameter to mark ones I've already visited, and it caused odd behavior with the scripted contracts: I think the parameter list is part of how KSP recognizes those scripted contracts.

Share this post

Link to post

Share on other sites

I've just look at the archive, why not adding the 2nd post content inside ? (License didn't help that's much ).

I just wanted to keep the first post clean/short (it'll grow with the changelog). Also keeping the "documentation" in one post seemed sensible.

I've got a couple of my old mission packs for lying around. But they all involve duration and/or resource requirements.

I did a bunch to simulate the realities if interplanetary flight. A sub-mission requirement such as ((in orbit = Sun) and (liquidfuel = 0) for (time=50 days)) forces the player to rely on xenon or monoprop, simulating the reality of boiloff without getting into realfuels-type plugins.

Testing missions would also benefit from a duration requirement. Run a test between 10k and 12k is easy. Staying between 10k and 12k for 5 minutes is a much much harder task.

If I wasn't convinced before, I am now. Expect the Duration parameter in the next release.

Share this post

Link to post

Share on other sites

I know the question is a bit out-of-scope, but in the process of writing the mod, have you found a way to get a reference to each contract as it is offered? I'm trying to do blanket editing of contracts, and what ZeroScience does won't work for me*.

*ZeroScience zeroes out the science on all contracts each time the list changes, whereas what I'm doing needs to be a one-time multiplier of funds. I've tried adding a dummy parameter to mark ones I've already visited, and it caused odd behavior with the scripted contracts: I think the parameter list is part of how KSP recognizes those scripted contracts.

Nope, haven't found a way - mainly since I wasn't looking for it. ContractConfigurator works by having a single new Contract sub-class "ConfiguredContract". All contracts specified in the config file are of that class - the additional information is mostly captured in the ContractType class.

You're right though - the contract system does interesting things with parameters - when I was testing a contract with no parameters it caused an exception in a sorting method. Presumably, something about parameters (I have no idea what) affects how they are sorted in the window.

I'd suggest calling GetHashString() on each Contract instance and recording in your own class (perhaps with a Dictionary) which ones have been handled. I don't pretend to completely understand how GetHashString() is used by the contract system - but the implication is it needs to be unique for each contract instance. I can also see Contract.ContractID - which I have to assume also uniquely identifies a contract instance (but if so, why have GetHashString()??)

Share this post

Link to post

Share on other sites

I'd love to see parameters for Orbital Period, Eccentricity, Inclination, and other orbital parameters (Arg. of Periapsis, Long. of AN, AP Height, PE Height, or just Semi-Major and Semi-Minor Axes). It'd be really cool if there were some pre-defined orbits as well using the celestial body's parameters (so it'd work with RSS and 6.4x kerbin). "Tundra" orbits, Polar orbits, Keostationary, Keosynchronus, etc etc...

Maybe I'll play with the code and see what I can do...

Share this post

Link to post

Share on other sites

I'd suggest calling GetHashString() on each Contract instance and recording in your own class (perhaps with a Dictionary) which ones have been handled. I don't pretend to completely understand how GetHashString() is used by the contract system - but the implication is it needs to be unique for each contract instance. I can also see Contract.ContractID - which I have to assume also uniquely identifies a contract instance (but if so, why have GetHashString()??)

Thanks for the help: the dictionary idea is promising. GetHashString() won't work: it keeps on changing when the scene changes. More testing is required, but I think Contract.ContractID is going to work better.

EDIT: Contract.ContractID does seem to be unique, and persistent between reloading the game. Now to figure out where to steal some code for keeping a dictionary persistent for a save game, probably from KAC.