Jump to content

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


Recommended Posts

Hi!

I was wanting to play with the contract pack Bases and stations, but running into a an "issue" I'd like to fix. It uses parameter which is a requirement of a partmodule that has to be unlocked. However I am using the community tech tree and it pushes that one very far back, so I wondered if it would be possible to make an exception to this parameter if ctt is installed, i.e setting it to true or false?

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

Hi!

I was wanting to play with the contract pack Bases and stations, but running into a an "issue" I'd like to fix. It uses parameter which is a requirement of a partmodule that has to be unlocked. However I am using the community tech tree and it pushes that one very far back, so I wondered if it would be possible to make an exception to this parameter if ctt is installed, i.e setting it to true or false?

There's a whole bunch of ways you can go about this.

An easy solution would be to add a MM patch that changes the tech tree position of the part in question to your liking (or edit the part's cfg file directly).

Another is a MM patch to disable/change the parameter, or again a direct edit of the contract cfg file. 

You could also change the part requirement to a different part or add a different part as an alternative unlock, making the part requirement satisfy for any unlocked part. Of course, keep in mind if this would work with the rest of the contract, meaning can you actually fulfill it with said parts.

Link to post
Share on other sites
On 11/28/2020 at 10:48 AM, Zelda said:

Is there a way to use contract types generated by DATA_EXPAND nodes as requirements? If I try to add a CompleteContract requirement referencing a generated contract type like below, the contract throws a null ref exception. 

REQUIREMENT
    {
        name = CompleteContract
        type = CompleteContract
        
        contractType = [email protected]
        minCount = 1
    }

At first I thought this might be related to not being able to escape the "." but I found this works: 

 contractType = "CREIHomeWorldOrbitDish.Mun"

Using something like ternary logic to choose those same contract type strings based on @targetBody doesn't:

contractType = @targetBody == "Mun" ? "CREIHomeWorldOrbitDish.Mun" : "CREIHomeWorldOrbitDish.Minmus"

 

Circling back to this - does anyone have any ideas? I've searched a bunch and have never been able to find the answer. I'm stumped on how to use DATA_EXPAND in cascading contracts, which would be a lot easier than having to replicate contracts several times over. Any help is very appreciated! 

Link to post
Share on other sites
On 1/18/2021 at 10:32 AM, Zelda said:

Circling back to this - does anyone have any ideas? I've searched a bunch and have never been able to find the answer. I'm stumped on how to use DATA_EXPAND in cascading contracts, which would be a lot easier than having to replicate contracts several times over. Any help is very appreciated! 

@Zelda  I was trying to figure out the same thing and asked the same question recently.  I tried several ways to get my cascading contracts to work and identify the right contract name using the DATA_EXPAND but failed.  I did open a ticket on the github either requesting the feature to be added or see if there is something I missed...

Link to post
Share on other sites
56 minutes ago, HawkEngineer said:

@Zelda  I was trying to figure out the same thing and asked the same question recently.  I tried several ways to get my cascading contracts to work and identify the right contract name using the DATA_EXPAND but failed.  I did open a ticket on the github either requesting the feature to be added or see if there is something I missed...

Cool, thanks!

Link to post
Share on other sites
  • 2 weeks later...
On 1/18/2021 at 10:32 AM, Zelda said:

Any help is very appreciated! 

I recently converted my flight contracts rather than look for completed contracts as requirements to use the Persistent Data Store to record progress counters and then use requirement expressions to evaluate those variables to see whether a mission could be called or not. 

I reduced my files for airline flights from 139 separate contract files down to just 8 files and they generate well over 200 combinations of flight scenarios.

This method might prove useful to you.

Link to post
Share on other sites
21 minutes ago, Caerfinon said:

I recently converted my flight contracts rather than look for completed contracts as requirements to use the Persistent Data Store to record progress counters and then use requirement expressions to evaluate those variables to see whether a mission could be called or not. 

I reduced my files for airline flights from 139 separate contract files down to just 8 files and they generate well over 200 combinations of flight scenarios.

This method might prove useful to you.

That is brilliant. Thank you for the tip!

Link to post
Share on other sites

Is there a way to further troubleshoot which contracts are offered?  I have a contract which shows all the requirements met in mission control but it isn't being offered.  I removed any limits to the number of contracts and warp ahead in time without the contract being offered.  

 

Thanks for any help.

Link to post
Share on other sites
18 minutes ago, HawkEngineer said:

Is there a way to further troubleshoot which contracts are offered?  I have a contract which shows all the requirements met in mission control but it isn't being offered.  I removed any limits to the number of contracts and warp ahead in time without the contract being offered.  

 

Thanks for any help.

Unfortunately there's always a bit of black magic involved in contract generation. Sometimes it takes a LOT of iterations, refreshing, fast forward or declining other contracts before a specific contract is generated. From experience this is mostly true for contracts with random elements in them, such as the field research ones or similar.

Another thing you should keep in mind is contracts which depend on data nodes to specify certain targets, or even requirements. Those won't be mentioned anywhere as the cause, but if those fields aren't returning good values the contract also won't ever generate.

Link to post
Share on other sites
17 hours ago, Morphisor said:

Unfortunately there's always a bit of black magic involved in contract generation. Sometimes it takes a LOT of iterations, refreshing, fast forward or declining other contracts before a specific contract is generated. From experience this is mostly true for contracts with random elements in them, such as the field research ones or similar.

Another thing you should keep in mind is contracts which depend on data nodes to specify certain targets, or even requirements. Those won't be mentioned anywhere as the cause, but if those fields aren't returning good values the contract also won't ever generate.

After reading your post, I was able to turn-on VERBOSE logging and discovered that the contract was not being offered due to a failed uniqueness check.  I since updated the uniqueness check and it is now working....

Thanks for the information about checking the data nodes....

Link to post
Share on other sites

Hi @nightingale,

the other day I made a post in @linuxgurugamer's Rover Missions Contract Pack thread, he suggested I ask here:

   

On 2/10/2021 at 9:45 AM, VoidSquid said:

Several lines

[ERR 09:26:57.975] ContractConfigurator.ContractType: CONTRACT_TYPE 'RoverExplore': Error parsing hasScientist

[EXC 09:26:57.978] NullReferenceException: Object reference not set to an instance of an object

and some more after that.  

Contracts do work fine though, doesn't seem to be anything critical.

Maybe fixable with a simple edit of a cfg file / MM patch?

  

On 2/10/2021 at 3:18 PM, linuxgurugamer said:

maybe, but that's a CC error.  It shouldn't give a NullRef, can you post in that thread?

Any idea what's wrong, and how it can be fixed?

 

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

Any idea what's wrong, and how it can be fixed?

Do you have the Contract Configurator debug log for the RoverExplore Contract?

1 hour ago, VoidSquid said:

Error parsing hasScientist

This indicates a problem with this line in the Data Node;

hasScientist = @/targetVessel.Crew().Where(k => k.ExperienceTrait() == "Scientist").Count() > 0

The debug log may shed more light as to what the issue is.

Edit:

There was a similar issue in the Kerbal Academy thread;

And the suggested correction  to it was to change the expression

so the replacement line would be;

hasScientist = @/targetVessel.Crew().Where(k => k.ExperienceTrait() == ExperienceTrait("Scientist")).Count() > 0

You might try this and see if it fixes the issue.

Edited by Caerfinon
Link to post
Share on other sites
1 hour ago, Caerfinon said:

Do you have the Contract Configurator debug log for the RoverExplore Contract?

Yes. Two logs under \GameData\ContractConfigurator\log\RoverMissionsGroup

1 hour ago, Caerfinon said:

The debug log

Which log exactly, path? Player.log? KSP.log?

I'd prefer to upload any logs from one KSP session for consistency.

Link to post
Share on other sites

@VoidSquid I loaded up the contract pack in my test instance and got similar NullReferenceException: errors that you posted. 

I tried a lot of different combinations to try and correct the behaviour, however the issue seems to be that the ExperienceTrait Type that is being called to determine if a Scientist is present in the rover will always throw the exception under the following two conditions;

  1.  If there are no rovers deployed at all (because they can't have a Scientist onboard)
  2. If there is a rover deployed but there is no scientists as members of the crew

While these conditions are present, the RoverExplore contract will not be offered, and theNullReferenceException will repeat as the contract systems tries to determine if it should offer it.  

 As soon as rover and scientist are united in the field, the contract becomes available again and the theNullReferenceException errors stop.

For all intents and purposes the contract pact works as designed, but the error exceptions will be present as I stated.

I suspect an update to the ExperienceTraitParser will be required in Contract Configurator to remove the errors

 

 

Link to post
Share on other sites

No success, changing the respective line to:

16 hours ago, Caerfinon said:

hasScientist = @/targetVessel.Crew().Where(k => k.ExperienceTrait() == ExperienceTrait("Scientist")).Count() > 0

results in:

[ERR 11:03:44.207] ContractConfigurator.ContractType: CONTRACT_TYPE 'RoverExplore': Error parsing hasScientist

[EXC 11:03:44.211] NullReferenceException: Object reference not set to an instance of an object

and several lines more

Spoiler

    ContractConfigurator.ExpressionParser.ExperienceTraitParser.EQ (Experience.ExperienceTrait a, Experience.ExperienceTrait b) (at <ef0243a06f2841fe9bf57034a334902e>:0)
    ContractConfigurator.ExpressionParser.ExpressionParser`1[T].ApplyBooleanOperator (T lval, System.String op, T rval) (at <ef0243a06f2841fe9bf57034a334902e>:0)
    ContractConfigurator.ExpressionParser.ExpressionParser`1[T].ApplyOperator[TResult] (T lval, System.String op, T rval) (at <ef0243a06f2841fe9bf57034a334902e>:0)
    ContractConfigurator.ExpressionParser.ExpressionParser`1[T].ParseOperation[TResult] (T lval, System.String op) (at <ef0243a06f2841fe9bf57034a334902e>:0)
    ContractConfigurator.ExpressionParser.ExpressionParser`1[T].ParseStatement[TResult] (T lval) (at <ef0243a06f2841fe9bf57034a334902e>:0)
    ContractConfigurator.ExpressionParser.ExpressionParser`1[T].ParseStatementInner[TResult] () (at <ef0243a06f2841fe9bf57034a334902e>:0)
    System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at <ad04dee02e7e4a85a1299c7ee81c79f6>:0)
    Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation.
    System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at <ad04dee02e7e4a85a1299c7ee81c79f6>:0)
    System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) (at <ad04dee02e7e4a85a1299c7ee81c79f6>:0)
    ContractConfigurator.ExpressionParser.ExpressionParser`1[T].ParseStatement[TResult] () (at <ef0243a06f2841fe9bf57034a334902e>:0)
    ContractConfigurator.ExpressionParser.ListExpressionParser`1[T].ParseWhereMethod[TResult] (System.Collections.Generic.List`1[T] obj) (at <ef0243a06f2841fe9bf57034a334902e>:0)
    ContractConfigurator.ExpressionParser.ListExpressionParser`1[T].ParseMethod[TResult] (ContractConfigurator.ExpressionParser.BaseParser+Token token, System.Collections.Generic.List`1[T] obj, System.Boolean isFunction) (at <ef0243a06f2841fe9bf57034a334902e>:0)
    System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at <ad04dee02e7e4a85a1299c7ee81c79f6>:0)
    Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation.
    System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at <ad04dee02e7e4a85a1299c7ee81c79f6>:0)
    System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) (at <ad04dee02e7e4a85a1299c7ee81c79f6>:0)
    ContractConfigurator.ExpressionParser.ExpressionParser`1[T].ParseMethod[TResult] (ContractConfigurator.ExpressionParser.BaseParser+Token token, T obj, System.Boolean isFunction) (at <ef0243a06f2841fe9bf57034a334902e>:0)
    ContractConfigurator.ExpressionParser.ExpressionParser`1[T].CompleteIdentifierParsing (U value) (at <ef0243a06f2841fe9bf57034a334902e>:0)
    System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at <ad04dee02e7e4a85a1299c7ee81c79f6>:0)
    Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation.
    System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at <ad04dee02e7e4a85a1299c7ee81c79f6>:0)
    System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) (at <ad04dee02e7e4a85a1299c7ee81c79f6>:0)
    ContractConfigurator.ExpressionParser.ExpressionParser`1[T].ParseSpecialIdentifier (ContractConfigurator.ExpressionParser.BaseParser+Token token) (at <ef0243a06f2841fe9bf57034a334902e>:0)
    ContractConfigurator.ExpressionParser.ExpressionParser`1[T].ParseSimpleStatement[TResult] () (at <ef0243a06f2841fe9bf57034a334902e>:0)
    ContractConfigurator.ExpressionParser.ExpressionParser`1[T].ParseStatementInner[TResult] () (at <ef0243a06f2841fe9bf57034a334902e>:0)
    ContractConfigurator.ExpressionParser.ExpressionParser`1[T].ParseStatement[TResult] () (at <ef0243a06f2841fe9bf57034a334902e>:0)
    ContractConfigurator.ExpressionParser.ExpressionParser`1[T].ParseExpression (System.String key, System.String expression, ContractConfigurator.ExpressionParser.DataNode dataNode) (at <ef0243a06f2841fe9bf57034a334902e>:0)
    Rethrow as Exception: Error parsing statement.
    Error occurred near '*':
    @/targetVessel.Crew().Where(k => k.ExperienceTrait() == ExperienceTrait("Scientist")).Count() > 0
    ....................................................................................* <-- HERE
    ContractConfigurator.ExpressionParser.ExpressionParser`1[T].ParseExpression (System.String key, System.String expression, ContractConfigurator.ExpressionParser.DataNode dataNode) (at <ef0243a06f2841fe9bf57034a334902e>:0)
    ContractConfigurator.ExpressionParser.ExpressionParser`1[T].ExecuteExpression (System.String key, System.String expression, ContractConfigurator.ExpressionParser.DataNode dataNode) (at <ef0243a06f2841fe9bf57034a334902e>:0)
    ContractConfigurator.ConfigNodeUtil.ParseSingleValue[T] (System.String key, System.String stringValue, System.Boolean allowExpression) (at <ef0243a06f2841fe9bf57034a334902e>:0)
    ContractConfigurator.ConfigNodeUtil.ParseValue[T] (ConfigNode configNode, System.String key, System.Boolean allowExpression) (at <ef0243a06f2841fe9bf57034a334902e>:0)
    ContractConfigurator.ConfigNodeUtil.ParseValue[T] (ConfigNode configNode, System.String key, System.Action`1[T] setter, ContractConfigurator.IContractConfiguratorFactory obj, T defaultValue, System.Func`2[T,TResult] validation) (at <ef0243a06f2841fe9bf57034a334902e>:0)
    UnityEngine.DebugLogHandler:LogException(Exception, Object)
    ModuleManager.UnityLogHandle.InterceptLogHandler:LogException(Exception, Object)
    UnityEngine.Debug:LogException(Exception)
    ContractConfigurator.LoggingUtil:LogException(Exception)
    ContractConfigurator.ConfigNodeUtil:ParseValue(ConfigNode, String, Action`1, IContractConfiguratorFactory, Boolean, Func`2)
    ContractConfigurator.ConfigNodeUtil:ParseValue(ConfigNode, String, Action`1, IContractConfiguratorFactory, Func`2)
    ContractConfigurator.DeferredLoadUtil:ExecuteLoad(DeferredLoadObject`1)
    System.Reflection.MethodBase:Invoke(Object, Object[])
    ContractConfigurator.<UpdateNonDeterministicValuesIterator>d__31:MoveNext()
    System.Linq.ConcatIterator`1:MoveNext()
    ContractConfigurator.<GenerateContract>d__33:MoveNext()
    ContractConfigurator.<ContractEnumerator>d__32:MoveNext()
    ContractConfigurator.ContractPreLoader:Update()

 

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

No success, changing the respective line

Yes. It doesn't matter what the code is.  I tried many variations. The only "fix" right now is an active rover with a scientist as a crew member. 

Link to post
Share on other sites
38 minutes ago, VoidSquid said:

the CC

The CC's ExperienceTraitParser needs to have a routine to handle the null exception before trying to execute the lookup for a Kerbal that does not exist.

40 minutes ago, VoidSquid said:

the mod

You could conceivable work around the issue using some kind of  Expression Requirement that checked the persistent data store to see is a variable representing deployed rovers with scientists was available but  I'm thinking that would be a lot of work and in the end may not work consistently. 

Link to post
Share on other sites

I am working on a contract file that looks at a vessel resources and determines how much to add depending on available space.  When testing the contract, the current resource capacity and quantity is 0 for the target vessel.  Has anyone used these in contract and able to retrieve the resource values?

 

Spoiler

    DATA
    {
        type = Double
        requiredValue     = true
        rcap             = @/targetVessel1.ResourceCapacity(Monopropellant)
        rcur             = @/targetVessel1.ResourceQuantity(MonoPropellant)
        rspace             = @/rcap - @/rcur
        rpercent         = @rcur/@rcap
        //
        MonoAdd            = Round(@/rspace * 0.80)           // Increase to 80% of avaialable space
        MonoNew            = Round(@/rcur + @/MonoAdd)       // Determine the final amount on the station after the resupply mission
        //
        title             = Get current status on resource on the station and calculate amount to add to resupply
    }

 

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

Has anyone used these in contract and able to retrieve the resource values?

Check the Career Evolution contract pack for some good examples in it's Kerbal Space Program\GameData\ContractPacks\CEContracts\Contracts\10-SpaceStationsLS  directory. 

These contracts deal with determining life-support resources available on a vessel and the amount needed to resupply that vessel.  I find that looking at examples of other people's code gives me ideas of how to make mine work . 

 

 

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

Check the Career Evolution contract pack for some good examples in it's Kerbal Space Program\GameData\ContractPacks\CEContracts\Contracts\10-SpaceStationsLS  directory. 

These contracts deal with determining life-support resources available on a vessel and the amount needed to resupply that vessel.  I find that looking at examples of other people's code gives me ideas of how to make mine work . 

 

 

Thanks for the tip, I did review the CE Pack but I also noticed that there is an old Issue in the github tracker for Contract Configurator which indicates a problem with the getresource retrieval.  

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