Jump to content

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


nightingale

Recommended Posts

I've never nested one vessel parameter group inside another. But I have used the Type Any parameter to nest multiple Vessel Parameter groups as separate solutions to completing the contract requirements     

PARAMETER
{
    name = Any
    type = Any
	
	PARAMETER
	{
        name = VesselParameterGroup1
        type = VesselParameterGroup
		...
	}
	PARAMETER
	{
        name = VesselParameterGroup2
        type = VesselParameterGroup
		...
	}
	PARAMETER
	{
        name = VesselParameterGroup3
        type = VesselParameterGroup
		...
	}
}

 

Link to comment
Share on other sites

11 hours ago, Caerfinon said:

I've never nested one vessel parameter group inside another. But I have used the Type Any parameter to nest multiple Vessel Parameter groups as separate solutions to completing the contract requirements     

PARAMETER
{
    name = Any
    type = Any
	
	PARAMETER
	{
        name = VesselParameterGroup1
        type = VesselParameterGroup
		...
	}
	PARAMETER
	{
        name = VesselParameterGroup2
        type = VesselParameterGroup
		...
	}
	PARAMETER
	{
        name = VesselParameterGroup3
        type = VesselParameterGroup
		...
	}
}

 

Reviewing the doc, it looks like what I want is the type = ALL since I'm wanting all the child parameters/groups to have completed.

Thanks for getting me moving again.
 

 

Edited by Ooglak Kerman
Link to comment
Share on other sites

  • 3 weeks later...

I have been playing around with contract configurator to make some new contract lately and have encountered a pop-up exception in game which suggested me to post the error here.

the exception is 

Exception occured while loading contract 'KerbalAcademy.KerbalAcademy_PilotingTraining':
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.InvalidCastException: Invalid cast from 'System.String' to 'System.Collections.Generic.List`1[[ContractConfigurator.Kerbal, ContractConfigurator, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]'.
  at System.Convert.DefaultToType (System.IConvertible value, System.Type targetType, System.IFormatProvider provider) [0x00269] in <9577ac7a62ef43179789031239ba8798>:0 
  at System.String.System.IConvertible.ToType (System.Type type, System.IFormatProvider provider) [0x00000] in <9577ac7a62ef43179789031239ba8798>:0 
  at System.Convert.ChangeType (System.Object value, System.Type conversionType, System.IFormatProvider provider) [0x0021b] in <9577ac7a62ef43179789031239ba8798>:0 
  at System.Convert.ChangeType (System.Object value, System.Type conversionType) [0x0000c] in <9577ac7a62ef43179789031239ba8798>:0 
  at ContractConfigurator.ConfigNodeUtil.ParseSingleValue[T] (System.String key, System.String stringValue, System.Boolean allowExpression) [0x006a0] in <20a3a039060941bfb465629683bb64bf>:0 
  at (wrapper managed-to-native) System.Reflection.MonoMethod.InternalInvoke(System.Reflection.MonoMethod,object,object[],System.Exception&)
  at System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00032] in <9577ac7a62ef43179789031239ba8798>:0 
   --- End of inner exception stack trace ---
  at System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00048] in <9577ac7a62ef43179789031239ba8798>:0 
  at System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) [0x00000] in <9577ac7a62ef43179789031239ba8798>:0 
  at ContractConfigurator.ConfiguredContract.OnLoad (ConfigNode node) [0x00233] in <20a3a039060941bfb465629683bb64bf>:0 

and the exact contract is:

CONTRACT_TYPE
{
    name = KerbalAcademy_PilotingTraining
    title = Kerbal Academy: Pilot Training Program
    group = KerbalAcademy
    description = It seems that a group of pilots is ready to improve their piloting skills. Take them to @targetVessel, along with 2 mentors to train them, then bring them back home.
    genericDescription = Put a gourp of pilots throught the training Program.
    synopsis = Complete the training course.
    completedMessage = Congratulations, we now have more experienced pilots on our team
    agent = Kerbal Academy
    notes = The parameters must be completed in order.
    minExpiry = 1
    maxExpiry = 7
    maxSimultaneous = 1
    cancellable = true
    declinable = true
    prestige = Significant
    targetBody = HomeWorld()
    rewardScience = 0.0
    rewardReputation = 10
    rewardFunds = 0
    failureReputation = 0
    failureFunds = 0
    advanceFunds = -50000 - @crew_size * 20000

    DATA
    {
        type = List<Kerbal>
        uniquenessCheck = CONTRACT_ACTIVE
        all_candidates = AllKerbals().Where(m => m.ExperienceTrait() == Pilot && m.ExperienceLevel()<= 2 && m.Type() == Crew && m.RosterStatus() == Available)
        trainee_list = @all_candidates.Random(@crew_size)
        title = Must have a group of Kerbals who qualify for the basic program.
    }

    DATA
    {
        type = int
        selectionIndex = Random(0, @validOTFs.Count() - 1)
        crew_size = @is_random_crewsize ? 2 : Random(3, 6)
    }

    DATA
    {
        type = double
        expAward = 8
    }

    DATA
    {
        type = bool     
        is_random_crewsize = 6 < @all_candidates.Count()
    }

    DATA
    {
        type = List<VesselIdentifier>
        requiredValue = false
        validOTFs = $KerbalAcademy_OrbitalTraingFacility.Where(vi => Vessel(vi).IsOrbiting() && Vessel(vi).EmptyCrewSpace() >= 8)
    }

    DATA
    {
        type = Vessel
        uniquenessCheck = CONTRACT_ACTIVE
        title = Must have an Orbital Training Facility with sufficient empty space
        targetVessel = @validOTFs.ElementAt(@selectionIndex)
    }

    BEHAVIOUR
    {
        name = AwardExperience
        type = AwardExperience
        kerbal = @/trainee_list
        experience = @/expAward
    }

    
    PARAMETER
    {	
        name = HasTrainee
        type = HasCrew
        kerbal = @/trainee_list
    }

    PARAMETER
    {
        name = HasMentor
        type = HasCrew
        trait = Pilot
        title = Must have an experienced Pilot on board
        minExperience = 4
    }

    PARAMETER
    {
        name = HasCommander
        type = HasCrew
        trait = Commander
        title = Must have a commander to oversee the training
        minExperience = 2
    }

    PARAMETER
    {
        name = DockwithStation
        type = Docking
        vessel = @/targetVessel
        title = Dock with @/targetVessel
        completeInSequence = true
    }

    PARAMETER
    {
        name = Duration
        type = Duration
        duration = 15d
        preWaitText = Waiting for the Crew.
        waitingText = Crew at the station
        completionText = Mission accomplished! Bring the crew back home.
        completeInSequence = true
    }

    PARAMETER
    {
        name = RecoverKerbal
        type = RecoverKerbal
        completeInSequence = true
        kerbal = @/trainee_list
    }

    REQUIREMENT
    {
        name = check_crew_count
        type = Expression
        expression = @/all_candidates.Count() > 1
        title = Must enough crew
    }
 
}

Anyone know what could be the problem?

Link to comment
Share on other sites

  • 2 weeks later...

I've used aircraft contracts and this one seemed interesting: stay above a requested altitude for a given time.

Yet the timer starts when the flight starts, and the mark gets checked by just waiting, not even flying.

To fix this, i've tried changing the contract code to this:

	//Contract Goals
	PARAMETER
	{
		name = VesselParameterGroup
		type = All
		title = fly up to 1,000m 
		
		vessel = @/craft
		
		PARAMETER
		{
			name = ReachState
			type = ReachState
			
			targetBody = Kerbin
			situation = FLYING
			minAltitude = 1000

			hideChildren = true
			hidden = true
			
			PARAMETER
			{
				name = VesselParameterGroup
				type = VesselParameterGroup
				title = Hold for 3min

				PARAMETER
				{
					name = Duration
					type = Duration
					
					duration = 180s
					preWaitText = and hold for: 
					waitingText = and hold for: 
					completionText = You did it!
				}		
			}
		}
		completeInSequence = true
		disableOnStateChange = true
		hideChildren = false
	}

What I did is I included the "hold for 3min" requirement inside the ReachState part. Yet the timer still starts even before the altitude is reached.

How would you solve that ? What syntax should I use ?

Link to comment
Share on other sites

1 hour ago, leroidangleterre said:

How would you solve that ? What syntax should I use ?

I think the problem is the position of the disableOnStateChange field - it applies to the vessel (so switching vessels would disable it) rather than the vessel state (so changes in altitude would affect it).

Try this (untested):

Spoiler
PARAMETER
{
	name = VesselGroup
	type = VesselParameterGroup
	title = Fly above 1000m for 3 minutes.
	
	PARAMETER
	{
		name = Has Crew
		type = HasCrew
		minCrew = 1
		title = Have at least 1 crewmember on board
	}

	PARAMETER
	{
		name = holdAltitude
		type = ReachState
		minAltitude = 1000
		situation = FLYING
		
		disableOnStateChange = true
		
		PARAMETER
		{
			name = Duration
			type = Duration
			duration = 3m
			preWaitText = Reach 1000m.
			waitingText = Hold above 1000m for 3 minutes.
			completedText = You did it!
		}
	}
}

 

 

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