Jump to content

0.90 Modding Facilities and their Upgrades


Recommended Posts

Hello,

I m interested in modding the facility restrictions (eg VAB 30parts, launch pad 18t) as well as the facility upgrade paths and unlocks.

Can anyone point me to the files containing those information?

Thank you very much!

Link to comment
Share on other sites

Hm, thats bad.

Nearing release they add major features/gameplay restrictions and make them not moddable.

Modding made this good game great, this looks like a strategic turn in the wrong direction.

Link to comment
Share on other sites

You currently can not. All you can do is change the cost.

Not 100% sure on this.

The limits are handled by the "GameVariables" object. Specificly, GameVariables.instance.GetCraftMassLimit and GameVariables.instance.GetCraftSizeLimit.

Now, changing functions on a "life" object is not possible, as far as I know. However, you could replace GameVariables.instance with an new overloaded object that has a different implementation of the above functions.

This might work:


[KSPAddon(KSPAddon.Startup.MainMenu, false)]
class MyGameVariables : GameVariables
{
void Awake()
{
GameVariables.Instance = this;
}

public int GetPartCountLimit(float f)
{
return 100;
}
public float GetCraftMassLimit(float editorNormLevel)
{
return 50.0f;
}
public Vector3 GetCraftSizeLimit(float editorNormLevel)
{
return new Vector3(100, 100, 100);
}
}

Link to comment
Share on other sites

You're right I probably shouldn't have made such a hard and fast statement. There are always possibilities. My intention was to simply re-state what had been said in the "What's new in 0.90" thread by Sarbian:

Building upgrade related stuff

First get a building current level : ScenarioUpgradeableFacilities.GetFacilityLevel(Spa ceCenterFacility.VehicleAssemblyBuilding)

Then get use those to get the various active restriction. Finding which SpaceCenterFacility level each of those use is left as an exercise to the reader.

public int GetPartCountLimit(float editorNormLevel)

public bool UnlockedFuelTransfer(float editorNormLevel)

public bool UnlockedActionGroupsStock(float editorNormLevel)

public bool UnlockedActionGroupsCustom(float editorNormLevel)

public float GetCraftMassLimit(float editorNormLevel)

public Vector3 GetCraftSizeLimit(float editorNormLevel)

public int GetActiveStrategyLimit(float adminNormLevel)

public float GetStrategyCommitRange(float adminNormLevel)

public float GetStrategyLevelLimit(float adminNormLevel)

public int GetActiveContractsLimit(float mCtrlNormLevel)

public float GetContractLevelLimit(float mCtrlNormLevel)

public bool UnlockedFlightPlanning(float mCtrlNormLevel)

public int GetActiveCrewLimit(float astroComplexNormLevel)

public float GetCrewLevelLimit(float astroComplexNormLevel)

public bool UnlockedEVA(float astroComplexNormLevel)

public bool UnlockedEVAFlags(float astroComplexNormLevel)

public bool UnlockedEVAClamber(float astroComplexNormLevel)

public bool EVAIsPossible(bool evaUnlocked, Vessel v)

public string GetEVALockedReason(Vessel v)

public GameVariables.OrbitDisplayMode GetOrbitDisplayMode(float tsNormLevel)

public int GetTrackedObjectLimit(float tsNormLevel)

public int GetPatchesAheadLimit(float tsNormLevel)

public bool UnlockedSpaceObjectDiscovery(float tsNormLevel)

public UntrackedObjectClass MinTrackedObjectSize(float tsNormLevel)

public float GetScienceCostLimit(float RnDnormLevel)

public float GetDataToScienceRatio(float RnDnormLevel)

public float GetExperimentLevel(float RnDnormLevel)

A warning : none of those limits are configurable.

Link to comment
Share on other sites

Not 100% sure on this.

The limits are handled by the "GameVariables" object. Specificly, GameVariables.instance.GetCraftMassLimit and GameVariables.instance.GetCraftSizeLimit.

Now, changing functions on a "life" object is not possible, as far as I know. However, you could replace GameVariables.instance with an new overloaded object that has a different implementation of the above functions.

I thought the above idea had some merit, so I decided to give it a try, but unfortunately given that none of the methods are virtual, the base functions are still called. For reference, here is the code I attempted this with:


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using UnityEngine;

using BTSM;

class BTSMGameVariables : GameVariables
{
public BTSMGameVariables( GameVariables originalVariables ) : base()
{
contractDestinationWeight = originalVariables.contractDestinationWeight;
contractFundsAdvanceFactor = originalVariables.contractFundsAdvanceFactor;
contractFundsCompletionFactor = originalVariables.contractFundsCompletionFactor;
contractFundsFailureFactor = originalVariables.contractFundsFailureFactor;
contractPrestigeExceptional = originalVariables.contractPrestigeExceptional;
contractPrestigeSignificant = originalVariables.contractPrestigeSignificant;
contractPrestigeTrivial = originalVariables.contractPrestigeTrivial;
contractReputationCompletionFactor = originalVariables.contractReputationCompletionFactor;
contractReputationFailureFactor = originalVariables.contractReputationFailureFactor;
contractScienceCompletionFactor = originalVariables.contractScienceCompletionFactor;
mentalityDeadlineExceptional = originalVariables.mentalityDeadlineExceptional;
mentalityDeadlineSignificant = originalVariables.mentalityDeadlineSignificant;
mentalityDeadlineTrivial = originalVariables.mentalityDeadlineTrivial;
mentalityExpiryExceptional = originalVariables.mentalityExpiryExceptional;
mentalityExpirySignificant = originalVariables.mentalityExpirySignificant;
mentalityExpiryTrivial = originalVariables.mentalityExpiryTrivial;
mentalityFundsExceptional = originalVariables.mentalityFundsExceptional;
mentalityFundsSignificant = originalVariables.mentalityFundsSignificant;
mentalityFundsTrivial = originalVariables.mentalityFundsTrivial;
mentalityReputationExceptional = originalVariables.mentalityReputationExceptional;
mentalityReputationSignificant = originalVariables.mentalityReputationSignificant;
mentalityReputationTrivial = originalVariables.mentalityReputationTrivial;
mentalityScienceExceptional = originalVariables.mentalityScienceExceptional;
mentalityScienceSignificant = originalVariables.mentalityScienceSignificant;
mentalityScienceTrivial = originalVariables.mentalityScienceTrivial;
partRecoveryValueFactor = originalVariables.partRecoveryValueFactor;
reputationAddition = originalVariables.reputationAddition;
reputationKerbalDeath = originalVariables.reputationKerbalDeath;
reputationKerbalRecovery = originalVariables.reputationKerbalRecovery;
reputationSubtraction = originalVariables.reputationSubtraction;
resourceRecoveryValueFactor = originalVariables.resourceRecoveryValueFactor;
}

static public void OverrideStockGameVariablesIfNecessary()
{
if ( GameVariables.Instance != null )
{
if ( !( GameVariables.Instance is BTSMGameVariables ) )
{
// FCTEST
Debug.Log( "BTSMGameVariables: Replacing stock GameVariables" );

GameVariables.Instance = new BTSMGameVariables( GameVariables.Instance );
}
}
}

public float GetCraftMassLimit( float editorNormLevel )
{
float fMassLimit = BTSMUtils.GetLaunchCapacityBasedOnResearchUnlocks();

// FCTEST
Debug.Log( "BTSMGameVariables GetCraftMassLimit() returning: " + fMassLimit );

return fMassLimit;
}
}

I'm instantiating through OverrideStockGameVariablesIfNecessary() from a separate monobehavior which is called whenever the space center is loaded to check if my class needs to override the stock one, and while it is properly instantiated and set, the debug output within GetCraftMassLimit() is never hit, and mass limits remain at stock levels (I already had mass limiting functionality in my mod pre-0.9, so BTSMUtils.GetLaunchCapacityBasedOnResearchUnlocks() is just a pre-existing function I already had written).

I've also tried declaring GetCraftMassLimit() as override, virtual and new on different occasions, to no avail.

Unless someone knows a trick to force overrides on non-virtual functions like this in C#, it doesn't look like this will work.

Edited by FlowerChild
Link to comment
Share on other sites

Hi Flowerchild,

did you tried adding the new keyword?

Yup, as I mentioned above:

I've also tried declaring GetCraftMassLimit() as override, virtual and new on different occasions, to no avail.

As far as I know, the new operator only hides the base class function if you're calling an instance of the child class directly. If you're calling it through a reference to the base class (which in this case, that's precisely what the GameVariables.Instance is), the original base class function will be called.

Basically, the new keyword doesn't respect polymorphism, and I checked multiple online sources to see if there was a way around that (I'm primarily a C++ programmer so I'm often times unaware of the subtleties of C# syntax), and from the many discussions I found about that particular issue, there doesn't appear to be.

Link to comment
Share on other sites

  • 8 months later...

Cool! I posted on here because I had just noticed it myself and this was the only result from google that had any relevance. For one of the mods some of the work that I'm doing for BROKE, I might end up messing with some GameVariables (probably the crew hiring cost if anything). The only problem that I noticed with GameVariables though is everyone stepping on each other's toes. I was trying to figure out if there was any agreed upon process to prevent or minimize that. (Otherwise I could spin up some quick code to try to make everything play as nice as possible.)

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