Jump to content

[WIP] ATC - Alternative Tree Configurator (released)


SirJodelstein

Recommended Posts

Allright ladies and gentleman, time to bust out something potentially awesome. After a long time waiting and hoping someone or Squad would finally build a TreeLoader replacement, I decided to tackle the issue myself.

ATC - Alternative Tree Configurator

This is a plugin to modify the stock tech tree and assign parts to the nodes without writing huge ModuleManager scripts

fnhPmwx.png


MODIFY_NODE
{
gameObjectName = node2_stability
title = New Fancy Technology
description = this is what we should research soon
scienceCost = 100
icon = COMPOSITES
anyParentUnlocks = false

posX = 2000
posY = 1500

REQUIRES
{
tech = node0_start
}

PARTS
{
part = probeCoreSphere
part = tailfin
//etc etc, just list each part with the name from its cfg-file
}
}

... And changing the science-value factors and altitude thresholds for each celestial body


BODY_SCIENCE_PARAMS
{
celestialBody = Kerbin

LandedDataValue = 0.2
SplashedDataValue = 0.2
FlyingLowDataValue = 0.7
FlyingHighDataValue = 0.7
InSpaceLowDataValue= 1
InSpaceHighDataValue= 1

flyingAltitudeThreshold= 20000
spaceAltitudeThreshold= 500000
}

Why? Because its a TreeLoader alternative. One that does not use an online backend for file distribution, so Techtree-Modders can simply distribute a cfg-file with their release. Maybe one day it will become obsolete when/if Squad does something like this in stock, but for now I'd like to be able to mod the techtree without having to write code.

Done

- Change parameters and part assignments to tech nodes

- change position and dependencies of tech nodes

- change celestial body science multipliers and thresholds

- multiple tree configs can be used simultaneously - just add multiple "TechTree = xyz.cfg" lines to your settings file. Later edits overwrite previous ones.

Release

Not yet.

However, the code has been released (MIT License), please read this release post

Ideas pile / TODO / Issues (roughly sorted by priority)

- option to add new nodes in a similar syntax

- gui to select a techtree (maybe even per savegame)

- option/button/shortcut to reload the tree

- option to specify custom icons

- a tool that outputs such a tree-cfg-file (ingame-tool or external program) would be very nice to have.

Its not yet in a presentable state, but its getting there. If you want to help, now is the time to step up. There will be quite a lot of code to write, debug and refactor, and I would really like to turn this into a group-maintained plugin via GitHub. The workload for the current feature list is currently way more than I am willing to do completely on my own. Also, any feedback and discussion is welcome.

Edited by SirJodelstein
released
Link to comment
Share on other sites

I just added this:


BODY_SCIENCE_PARAMS
{
celestialBody = Kerbin

LandedDataValue = 0.2
SplashedDataValue = 0.2
FlyingLowDataValue = 0.7
FlyingHighDataValue = 0.7
InSpaceLowDataValue= 1
InSpaceHighDataValue= 1

flyingAltitudeThreshold= 20000
spaceAltitudeThreshold= 500000
}

next up: learn how the dependency arrows are drawn => invent "NEW_NODE" and create option to change node dependencies.

Link to comment
Share on other sites

I like the looks of this.

It'd also be great to have a modified/replacement version of TreeEdit so that it would spit out a config file for your ATC to read instead of a TreeLoader config. But that's probably outside the scope of your plans for this, isn't it?

Link to comment
Share on other sites

I like the looks of this.

It'd also be great to have a modified/replacement version of TreeEdit so that it would spit out a config file for your ATC to read instead of a TreeLoader config. But that's probably outside the scope of your plans for this, isn't it?

Editing/Modifying Treeedit is not possible due to copyright reasons. I deliberately chose a different format to prevent any potential issues with r4m0n, i don't want him complaining about me using stuff he created.

A rebuilt-from-scratch editor replacement is on my wishlist (see OP), but not very high. I first want to get the parsing part done before thinking about tools to actually create those files. In the meantime, I think it would should not be too hard to build an external converter tool/script to convert Treeloader configs to the ATC format. Even a conversion by hand shouldn't be that much work. But yeah, thats beyond what I really want to do - if someone wants to have a go, just speak up.

Link to comment
Share on other sites

Interesting :)

I was just wondering something about contracts and the science tree

Even if it's surely too soon for you to answer this, maybe it could become an additionnal possibility of your plugin :)

would it be possible to allow the unlocking of a science node only after you sucessfully finished a specific part testing contract (not necessarily a random one)

Link to comment
Share on other sites

Oh yeah! That took way longer than it should have. Drawing those arrows correctly is tricky. But its done now:

fnhPmwx.png

Node repositioning and changing node dependencies: done :)


MODIFY_NODE
{
gameObjectName = node1_basicRocketry

//original position: Node node1_basicRocketry at (-1901.2, 896.6, -1.0)
posX = -1901.2
posY = 1050
}

MODIFY_NODE
{
gameObjectName = node2_stability
//Test - change parent node to node0 (original parent was node1)
REQUIRES
{
tech = node0_start
}
}

Next: New nodes. Shouldn't be that much of a stretch now.

Then: code cleanup and first test release.

Link to comment
Share on other sites

Just repeating for the thread what I PM'd you:

A treeloader/edit replacement without the server lookup would be good but you'll have the same hassle that treeloader does. The contracts code does no error checking, when it whips up a random part test contract it assumes that any part will exist, be loaded and have an assigned tech node. So any edited tree with empty nodes or optional part packs is going to run into problems.

I was thinking of adding settings so that if a node is empty, it gets populated with defined single part. If a part is not loaded (ie they don't have that pack installed) remove the part from the tree and if a part has no tech node (meaning it's defined node doesn't exist in the custom tree) assign it to a default bucket tech node.

I'll have a look at your WIP and may be able to help. If nothing else I'll keep you up to date with anything I find.

You only have to worry about part assignments in career mode obviously. Science sandbox and normal sandbox don't run the contract code so they don't hit the same problems.

Link to comment
Share on other sites

A treeloader/edit replacement without the server lookup would be good but you'll have the same hassle that treeloader does. The contracts code does no error checking, when it whips up a random part test contract it assumes that any part will exist, be loaded and have an assigned tech node. So any edited tree with empty nodes or optional part packs is going to run into problems.

Is it possible to fix this problem by suppressing that contract type and adding a replacement contract for part testing that's more robust?

Link to comment
Share on other sites

Is it possible to fix this problem by suppressing that contract type and adding a replacement contract for part testing that's more robust?

Good question, as far as I know the answer is no though. The methods in the stack trace are mostly 'Protected' meaning it would be hard to override them with something else - go look at the Assembly-csharp references in Mono, you want Contracts.Templates -> PartTest(). That gets invoked, presumably with some randomly selected tgtPart, possibly done by calling Generate()?

Link to comment
Share on other sites

Having replaced the part test contract with my own for other reasons, yes, removing it and overriding it with your own is definitely possible. Feel free to check out the BTSM code for it, or my posts on the subject here:

http://forum.kerbalspaceprogram.com/threads/86588-Contract-Modding-Information-for-Mod-Authors?p=1317690&viewfull=1#post1317690

In my case, I'm removing the stock part tests and replacing them with my own child class of the stock part test contracts so I can filter out specific ones through my own code, but replacing them entirely is perfectly feasible as well, as I am doing that for other stock contracts like the "Explore Body" ones already.

Also, if I am understanding the above problem correctly, I suspect you could get around it with a ModuleManager script that removes the part module associated with part test contracts from all parts. Parts don't get assigned such contracts without that module, and while I think that would effectively remove part test contracts from the game, it should also solve your issue in a very simple manner (maybe).

Nice job on getting the node dependencies working SirJodelstein. That alone is worth its weight in gold :)

Edited by FlowerChild
Link to comment
Share on other sites

One thing that really turned me off TreeLoader was that you could only load one mods tree. At least as far as I could tell. Any plans on having this act more like MM with multiple tree cfgs. It would be extremely usefull if multiple mods wanted to add new nodes. I'm specifically thinking of something like the new b9 parts and intersteller, where both can easily make use of custom nodes.

I know there would be the problem of mods conflicting with stock part movement. Maybe add a plugin cfg with a var for prefering earlier or later part placement?

Link to comment
Share on other sites

It would be extremely usefull if multiple mods wanted to add new nodes. [...]

Loading from multiple configfiles sounds definitely useful, and is a simple extension I've just added in (later entries just overwrite earlier entries, order is configured via settings-file)

.... but at the moment, i am seriosly considering cutting the "new node" function entirely. Up to "modify existing nodes" (including dependendy changes), the code is readable and well-structured. But adding new nodes? Oh dear, now it gets ugly. There is no way to to extend the tree without going through extreme hoops (SQUAD, why does RDTechTee have "GetTreeNodes()" function but no "AddTreeNode(RDNode)" function??! And how do i setup a new RDNode/RDTech at all? Why does RDNode have a non-null prefab but GameObject.Instatiate(rdNode.prefab) cause an exception?). Really, the API there is extremely convoluted (RDNode.WarmUp(RDTech), RDNode.Setup(), RDController.RegisterNode(RDNode)), and i am getting frustrated. And since I am doing this in my free time for fun, there is only a certain amount of frustration I want to take (and hours I want to sink into this) before I give up and say "actually, I'd rather play the game instead". Unfortunately, this limit is almost reached :(

SQUAD, please give us a function that creates a new dummy RDNode so that we can fill in the necessary fields (title, science cost, parts, parents/childs etc). Or just create 200 more invisible dummy-RDNodes in the AssetBase.RnDTechTree...

Edited by SirJodelstein
Link to comment
Share on other sites

Having replaced the part test contract with my own for other reasons, yes, removing it and overriding it with your own is definitely possible. Feel free to check out the BTSM code for it, or my posts on the subject here:

http://forum.kerbalspaceprogram.com/threads/86588-Contract-Modding-Information-for-Mod-Authors?p=1317690&viewfull=1#post1317690

In my case, I'm removing the stock part tests and replacing them with my own child class of the stock part test contracts so I can filter out specific ones through my own code, but replacing them entirely is perfectly feasible as well, as I am doing that for other stock contracts like the "Explore Body" ones already.

Also, if I am understanding the above problem correctly, I suspect you could get around it with a ModuleManager script that removes the part module associated with part test contracts from all parts. Parts don't get assigned such contracts without that module, and while I think that would effectively remove part test contracts from the game, it should also solve your issue in a very simple manner (maybe).

Nice job on getting the node dependencies working SirJodelstein. That alone is worth its weight in gold :)

Ok, good to know thanks. I quit fiddling with it for a few days as it was just doing my head in. Taking them out completely shouldn't be necessary though, I'll have to see how next week is for free time.

Link to comment
Share on other sites

Loading from multiple configfiles sounds definitely useful, and is a simple extension I've just added in (later entries just overwrite earlier entries, order is configured via settings-file)

.... but at the moment, i am seriosly considering cutting the "new node" function entirely. Up to "modify existing nodes" (including dependendy changes), the code is readable and well-structured. But adding new nodes? Oh dear, now it gets ugly. There is no way to to extend the tree without going through extreme hoops (SQUAD, why does RDTechTee have "GetTreeNodes()" function but no "AddTreeNode(RDNode)" function??! And how do i setup a new RDNode/RDTech at all? Why does RDNode have a non-null prefab but GameObject.Instatiate(rdNode.prefab) cause an exception?). Really, the API there is extremely convoluted (RDNode.WarmUp(RDTech), RDNode.Setup(), RDController.RegisterNode(RDNode)), and i am getting frustrated. And since I am doing this in my free time for fun, there is only a certain amount of frustration I want to take (and hours I want to sink into this) before I give up and say "actually, I'd rather play the game instead". Unfortunately, this limit is almost reached :(

SQUAD, please give us a function that creates a new dummy RDNode so that we can fill in the necessary fields (title, science cost, parts, parents/childs etc). Or just create 200 more invisible dummy-RDNodes in the AssetBase.RnDTechTree...

maybe we should organize a collective letter writing campaign? no new nodes would be just fine for some realism mods, rebalance mods, better than starting manned, and bargain rockets, but it would be useless for the sci fi futuristic mods that rely on treeloader like Near Future or Interstellar.

Alternately the "don't decomplie rules" only apply to the forum and curse correct? or is it something that's baked into the EULA? If it the former then perhaps one should just do what is necessary and distribute through other unofficial channels?

Edited by passinglurker
Link to comment
Share on other sites

.... but at the moment, i am seriosly considering cutting the "new node" function entirely. Up to "modify existing nodes" (including dependendy changes), the code is readable and well-structured. But adding new nodes? Oh dear, now it gets ugly. There is no way to to extend the tree without going through extreme hoops (SQUAD, why does RDTechTee have "GetTreeNodes()" function but no "AddTreeNode(RDNode)" function??! And how do i setup a new RDNode/RDTech at all? Why does RDNode have a non-null prefab but GameObject.Instatiate(rdNode.prefab) cause an exception?). Really, the API there is extremely convoluted (RDNode.WarmUp(RDTech), RDNode.Setup(), RDController.RegisterNode(RDNode)), and i am getting frustrated. And since I am doing this in my free time for fun, there is only a certain amount of frustration I want to take (and hours I want to sink into this) before I give up and say "actually, I'd rather play the game instead". Unfortunately, this limit is almost reached :(

Well, as I understand it, there isn't a mod API for doing this kind of thing, and it's not something that Squad ever planned for us to be able to do.

I'm honestly impressed you managed to get the ability to move nodes and add parents in as the times I've poked at that code (and I've done so on several occasions), I never figured out a reasonable method to get that done, and I very much would have liked to be able to do so. That alone would make a HUGE difference for what I could do with BTSM.

Anyways man, I know that modding KSP can be extremely frustrating at times given how difficult it can be to do what seems like an extremely simple task, but I just wanted to reiterate that you've already done some amazing things here and I can't wait to get my hands on it :)

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...