Jump to content

[1.10.1+] Contract Configurator [v1.30.5] [2020-10-05]


nightingale

Recommended Posts

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

EHE5dYd.png

kmskTMK.png CZWV3ul.png xmwqOxH.png

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:

  1. Contract Summary - This contains all the summary text, expiry/deadline dates, and reward information.
  2. Parameters - These are mappings to the stock ContractParameter classes which specify what the player has to do to complete the contract.
  3. 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.
  4. 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.
  5. 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.

Download

Contract Configurator can be downloaded from GitHub.

Source

The full source and test configuration is available on GitHub.

Documentation

The user guide is hosted on the GitHub wiki.

Change Log

  Reveal hidden contents

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!

License

Contract Configurator is licensed under the MIT License.

RemoteTech integration (CC_RemoteTech.dll) is licensed under GNU GPL v2.0.

 

btn_donate_SM.gif Like what you see? Consider donating to the coffee fund! It will not go directly to supporting this or other mods under my care, but it may keep my motivation up!

 

Edited by nightingale
Link to comment
Share on other sites

Listing of Contract Packs

This is a list of all mods that provide contracts packs built on Contract Configurator. If you have something you'd like added to this list, PM me or post in this thread.

[Active]

Retired/Unsupported Contract Packs

Contract packs that have fallen out of support or simply don't work in newer versions of KSP/Contract Configurator.

  • 5dim Military @odin_spain - Some changes to how vessels spawn in Contract Configurator broke the spawning in this contract pack, and odin_spain seems to have disappeared.
  • SCANsat Lite @severedsolo- This contract pack has been integrated into SCANsat itself.
  • Sprite Missions @linuxgurugamerSadly the sprite doesn't work in 1.x aero, so this contract pack is no longer supported.
  • Kerbal Aircraft Builders @maculatorContracts focused on building aircraft. (Absorbed into Giving Aircraft a Purpose (GAP))
  • SCANsat Contract Pack @DBT85 - Alternative to the contracts (also built using Contract Configurator) that come with SCANsat.(Now packaged with ScanSat)
  • Rover Contracts by Whyren! @Whyren Here is an Opportunity to seize the Spirit of rovers! Have I piqued your Curiosity? YuTu can send manned and unmanned rovers across the system and run them for years beyond their intended life span until the wheels crumble! (Taken over by @linuxgurugamer and folded into Rover Missions Redux)
  • 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 - new Kerbin-Side continued mod maintainer @Ger_space might look into it in future)
  • Kerbin on Fire Military Contract Pack @VolwenMilitary missions for BDArmory that occur within 120km of KSC. Includes aerial combat missions! (Thread locked and no download link as kerbal-stuff link is invalid)
  • 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)
  • Historic Missions  @Whitecat106 - Historic missions following manned (human) space flight. This contract pack contains over 600 contracts with detailed backgrounds on the real missions. (Unsupported now, but 'Rebuilt' by @Frylovespi as History of Spaceflight )
  • Clever Sats @severedsolo - More in-depth replacement of the stock satellite contracts.(Modder moved on from contract modding)
  • Base Construction @CosmoBroConstruct and maintain planetary bases! (Mod was folded into Kerbin Bases and Stations )
  • Banking @ArachnidekAdds 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

  1. 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):
      SQUAD said:
    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).
  2. 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.
  3. 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

  1. 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.
  2. If adding your contract pack on CKAN, 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.
  3. 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.
  4. Be creative! The possibilities for contract packs are endless.
Edited by nightingale
Link to comment
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.

Edited by CaptRobau
Link to comment
Share on other sites

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.

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.

Link to comment
Share on other sites

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

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

Link to comment
Share on other sites

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

  biohazard15 said:
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... :wink:

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

  biohazard15 said:
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.

  CaptRobau said:
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.
  Eleven said:
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).

  NathanKell said:
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.

  Sandworm said:
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 days
PARAMETER
{
// Parameter is completed when all child parameters have been completed for the specified duration
type=Duration
duration=10 days

PARAMETER
{
type=ReachSituation
situation=Orbit
disableOnStateChange=false
}
PARAMETER
{
type=ReachDestination
targetBody=Mun
disableOnStateChange=false
}
}

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.

  Sandworm said:
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 comment
Share on other sites

  Overjay said:
I'd like a contract, saying "We want you to do a thing"

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

  FreeThinker said:
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?

Link to comment
Share on other sites

Yeah, as an old Mission Controller dev I recognized the approach straight away (so is Sandworm, so that's not surprising. :D ).

ReturnFrom is a stock Param, though, I thought? The other stuff not so much...I would highly suggest waiting a bit for dealing with FP, as we don't know how much has changed for 0.90.

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

Link to comment
Share on other sites

  NathanKell said:
ReturnFrom is a stock Param, though, I thought?

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

  NathanKell said:
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. :sticktongue:

Link to comment
Share on other sites

  FreeThinker said:
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.

  nightingale said:
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.

Link to comment
Share on other sites

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

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.

  Sandworm said:
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.

Link to comment
Share on other sites

  Starman4308 said:
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()??)

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

Link to comment
Share on other sites

  nightingale said:
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.

Edited by Starman4308
Link to comment
Share on other sites

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