Jump to content

Hacking your libraries: Creating rescources


Recommended Posts

Admit it, you've wanted at least one type of resource added to the game at one point.

However, it's not really difficult to add resources of your design into the game.

The basic resources of the game include:

Liquid fuel, Oxidizer, Solid fuel, Monopropellant, Xenon gas, Electric charge, and the Ablator.

The more complex resources are:

Ore, Intake air, and EVA propellant.

A quick look in the file named "ResourcesGeneric.cfg" will show all of these. Go ahead and open it up.

...Oh, you're too cool to do it, huh? Well I'm not moving on until you open it...

...Yeah, that's what I thought. Very well, moving swiftly on.

A look inside said file reveals all of this nonsense:

RESOURCE_DEFINITION{
name = LiquidFuel
density = 0.005
unitCost = 0.8
hsp = 2010
flowMode = STACK_PRIORITY_SEARCH
transfer = PUMP
isTweakable = true
}
RESOURCE_DEFINITION
{
name = Oxidizer
density = 0.005
unitCost = 0.18
hsp = 1551
flowMode = STACK_PRIORITY_SEARCH
transfer = PUMP
isTweakable = true
}
RESOURCE_DEFINITION
{
name = SolidFuel
density = 0.0075
unitCost = 0.6
hsp = 920
flowMode = NO_FLOW
transfer = NONE
isTweakable = true
}
RESOURCE_DEFINITION
{
name = MonoPropellant
density = 0.004
unitCost = 1.2
hsp = 3000
flowMode = STAGE_PRIORITY_FLOW
transfer = PUMP
isTweakable = true
}
RESOURCE_DEFINITION
{
name = XenonGas
density = 0.0001
unitCost = 4
hsp = 120
flowMode = STAGE_PRIORITY_FLOW
transfer = PUMP
isTweakable = true
}
RESOURCE_DEFINITION
{
name = ElectricCharge
density = 0
unitCost = 0
hsp = 0
flowMode = ALL_VESSEL
transfer = PUMP
isTweakable = true
}
RESOURCE_DEFINITION
{
name = IntakeAir
density = 0.005
unitCost = 0
hsp = 10
flowMode = ALL_VESSEL
transfer = PUMP
isTweakable = false
}
RESOURCE_DEFINITION
{
name = EVA Propellant
density = 0
unitCost = 0
hsp = 3000
flowMode = NO_FLOW
transfer = PUMP
isTweakable = false
}

RESOURCE_DEFINITION
{
name = Ore
density = 0.010
unitCost = 0.02
flowMode = ALL_VESSEL
transfer = PUMP
isTweakable = true
color = 1,0,1
}
RESOURCE_DEFINITION
{
name = Ablator
density = 0.001
hsp = 100
flowMode = NO_FLOW
transfer = NONE
isTweakable = True
unitCost = 0.5
}

Now calm down, it's not hard at all.

We're going to go over the basic and complex resources separately, and to not clog up space, I'll put each category into their own Spoiler tags.

Basic resource production is fairly easy. Here's a rundown on each conditional for the basic resources:

Name = [resource]

The name of your resource is very important. Whenever a part is configured to store a type of resource, the game searches for a resource of that

name in any folder named "resources" just after a data subsection folder, which is in the GameData folder. If your resource file is located outside of this

sector of data, it will not work.

Density = [X]

The density of your part is pretty self explanatory. It is the amount your part weighs per unit [represented in tons].

hsp = [X]

HSP is the specific heat of your resource, and is directly related to insulation. Specific heat is how much heat per resource density is required to raise the

temperature by a full 1 degrees Kelvin, or 1.8 Rankine.

FlowMode = [flow method]

The flow mode dictates how your resource will move about your vessel when requested by a part. There are 4 in total, and they are:

STACK_PRIORITY_SEARCH

Will tell a part to drain a resource from the first part on the stack, rather than evenly across each part on it at once. After that part is drained, it searches for the next one on the stack, and works toward the other end. This can be overridden by using Fuel lines, which automatically prioritizes the part it is first attached to [The giving end].

STAGE_PRIORITY_FLOW

Will tell a part to drain evenly from every part containing that resource connected to a stack. It will not transfer fuel across parts that are separated by

stages. This can also be overridden with fuel lines, by draining all the fuel from the first part it is connected to, it will continue draining evenly through every other part that isn't influenced by it.

ALL_VESSEL

Will tell a part to drain a resource from anywhere on the entire vessel.

NO_FLOW

Will prevent any automatic movement from one part to another.

Transfer = [transfer method]

The transfer method dictates whether or not you can move any resource from one part to another manually. If you want it to be able to move between

parts, then enter PUMP. If you want to it stay put, then enter NONE.

IsTweakable = [True/False]

This will determine if you will be able to edit the levels of your resource while building your craft.

UnitCost = [X]

How much money your part costs per unit of your resource.

That's the general gist of it all.

These parameters will define the physical characteristics of your resource [except unitCost]. You can mold them however you like, but just remember that no one likes an overpowered resource.

Complex resource production in itself isn't too difficult, but complex resources are not defined by their characteristics, but how

they're modeled in the game.

Ore is defined as a Global, Planetary, and Biome Resource. So, what are those exactly? They're not too dissimilar to each other, but here's what they are:

GLOBAL_RESOURCE

This will determine how it will be scattered around each planet, unless otherwise defined. Go ahead and open up the Ore.cfg. Actually, no, I'll do it for you

EDIT: For some reason, the editor has separated these two. I literally cannot force them together, even with a complete T.G.A revert, so I would appreciate if someone would help out with it [the one above is first]


ResourceName = Ore
ResourceType = 0

Distribution
{
PresenceChance = 100
MinAbundance = 1
MaxAbundance = 15
Variance = 50
Dispersal = 3
}
}

PLANETARY_RESOURCE
{
ResourceName = Ore
ResourceType = 0
PlanetName = Sun

Distribution
{
PresenceChance = 0
MinAbundance = 0
MaxAbundance = 0
Variance = 0
Dispersal = 0
}
}

PLANETARY_RESOURCE
{
ResourceName = Ore
ResourceType = 0
PlanetName = Jool

Distribution
{
PresenceChance = 0
MinAbundance = 0
MaxAbundance = 0
Variance = 0
Dispersal = 0
}
}

BIOME_RESOURCE
{
ResourceName = Ore
ResourceType = 0
PlanetName = Eve
BiomeName = Explodium Sea

Distribution
{
PresenceChance = 0
MinAbundance = 0
MaxAbundance = 0
Variance = 0
Dispersal = 0
}
}

BIOME_RESOURCE
{
ResourceName = Ore
ResourceType = 0
PlanetName = Kerbin
BiomeName = Water

Distribution
{
PresenceChance = 0
MinAbundance = 0
MaxAbundance = 0
Variance = 0
Dispersal = 0
}
}

BIOME_RESOURCE
{
ResourceName = Ore
ResourceType = 0
PlanetName = Laythe
BiomeName = The Sagen Sea

Distribution
{
PresenceChance = 0
MinAbundance = 0
MaxAbundance = 0
Variance = 0
Dispersal = 0
}
}

BIOME_RESOURCE
{
ResourceName = Ore
ResourceType = 0
PlanetName = Laythe
BiomeName = Crescent Bay

Distribution
{
PresenceChance = 0
MinAbundance = 0
MaxAbundance = 0
Variance = 0
Dispersal = 0
}
}
[FONT=Verdana]GLOBAL_RESOURCE[/FONT]{

Let's begin cracking this code.

As stated before, GLOBAL_RESOURCE affects each body in the Kerbol system.

Distribution will determine how the resources is laid out through every body. So, the subsections of Distribution include:

PrescenceChance = [X]

This will determine the probability that your resource will even appear at all. I recommend keeping this at 100, but you can change as you like.

MinAbundance = [X]

The lowest possible ratio of a resource deposit defined by an arbitrary unit of measurement depending on the planetary characteristics.

MaxAbundance = [X]

The highest possible ratio of a resource deposit defined by an arbitrary unit of measurement depending on the planetary characteristics.

Variance = [X]

I'm not exactly sure about this one to be honest, but I think it has something to do with the percentage of deviation based on the average ratio of the

amount of a resource any planet/moon/asteroid has. I recommend keeping this to 50.

Dispersal = [X]

I'm not really sure about this one either, but I think it's how varied your density of deposits differ from one another from deposit to deposit.

All you need are these few lines and you're good to go, but if you want the resource in question to behave differently on one or more planet than the rest of them, then you can override the GLOBAL RESOURCE with a PLANETARY RESOURCE.

Literally the only difference between the two is this line:

PlanetName = [name of body] This will let you modify the way your resource behaves for any one planet/moon. You can add as many as you like if you want every planet/moon to be different.

Intake air is a resource that can be found on any planet/moon with an atmosphere [but is limited to Kerbin and Laythe by the intakes themselves.] To create something like this, you'd have to get into far more advance modding [atmospheric pressures, dealings with the PQS, a whole bunch of math, and it's not nearly as easy]

I'm not exactly sure what you would need a fuel that acts like EVA fuel for... Just sayin'. Feel free to give me ideas.

Regardless, EVA fuel is a very unique resource. As long as a Kerbal is inside a capsule, it does not exist; only coming into existence when a Kerbal is on EVA,

or in the command chair. This would also require some pretty silly modding skills, so I'd stick to Ore if anything.

I do hope these were helpful in at least some way. Hopefully you'll go into your resource folder and put that brain to use if you desire to.

Here's the two first resources I've ever implemented myself, as example:


[FONT=Verdana]RESOURCE_DEFINITION
[/FONT]{
name = PressurizedAir
density = 0.0001
unitCost = 0.004
hsp = 3000
flowMode = STAGE_PRIORITY_FLOW
transfer = PUMP
isTweakable = true
}
RESOURCE_DEFINITION
{
name = LiquidHydrogen
density = 0.0000012
unitCost = 0
hsp = 120
flowMode = STAGE_PRIORITY_FLOW
transfer = PUMP
isTweakable = true
}

Edited by Xannari Ferrows
Still trying to merge those two.
Link to comment
Share on other sites

Also, if you're a modder you might want to check out the Community Resource Pack to see if what you want has already been made, whether you can use it, and possibly contribute if you're interested. This makes sure your mod what uses resources is compatible with the USI catalog, the Near Future packages, KSPI-E, and even Real Fuels.

Link to comment
Share on other sites

  • 3 months later...

Do you think you could provide some direction on atmospheric and exospheric resource development, I'm running into some issues getting these two types to work. They appear in-game when I scan a planet but I can't for the life of me get a collector to gather them, or even register their existence.

Link to comment
Share on other sites

Do you think you could provide some direction on atmospheric and exospheric resource development, I'm running into some issues getting these two types to work. They appear in-game when I scan a planet but I can't for the life of me get a collector to gather them, or even register their existence.

The coordinate systems use defined reference points and proximity measurements to determine how much of a resource you can get when it is externally harvested, and their existence is not defined by the parameters the resource definitions. You'll have to modify the coordinate definitions themselves, which to be honest, I have never attempted.

Link to comment
Share on other sites

Just a small clarification: hsp (specific heat) has defined units, it's in kilojoules per Kelvin-tonne. Or more explicitly, the number of kilojoules of heat required to change the temperature of one tonne of the resouce by one Kelvin. Density and insulation are not really relevant to this number, it's a physical property of the resource itself.

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