Jump to content

Creating a Tech Tree Mod


MuriloMoreira

Recommended Posts

Well, I'm trying to create a mod to change the game's stock tech tree, but I just realized it's not that simple, I don't understand how I can change the tech tree without messing with the original, I tried to see some other mods for understand how it works but so far I don't understand how it works, the mods use the Module Manager and the Community Tech Tree, the question is, what do these two mods do? I don't understand what they're there for, how can I start messing with this type of mod?

(OBS : It's my first time trying to make a mod, so wait some stupid things.)

Link to comment
Share on other sites

Start by taking a look at the stock tech tree cfg file in GameData/Squad/Resources/TechTree.cfg.  Each node is a specific technology:

	RDNode
	{
		id = start
		title = #autoLOC_501020 //#autoLOC_501020 = Start
		description = #autoLOC_501021 //#autoLOC_501021 = The technology we started out with.
		cost = 0
		hideEmpty = False
		nodeName = node0_start
		anyToUnlock = False
		icon = RDicon_start
		pos = -2568,1199,0
		scale = 0.6
	}
	RDNode
	{
		id = basicRocketry
		title = #autoLOC_501022 //#autoLOC_501022 = Basic Rocketry
		description = #autoLOC_501023 //#autoLOC_501023 = How hard can Rocket Science be anyway?
		cost = 5
		hideEmpty = False
		nodeName = node1_basicRocketry
		anyToUnlock = False
		icon = RDicon_rocketry-basic
		pos = -2385,1257,0
		scale = 0.6
		Parent
		{
			parentID = start
			lineFrom = RIGHT
			lineTo = LEFT
		}
	}
...

From here you can do one of three things:  Change the node, remove the node, add a new node.  Notice the second node points backwards to its parent.  If you want to make a simple change for example you could make your entire tech tree more expensive (it's a dumb example but it shows how this stuff works).  You would create a ModuleManager script (MM is pretty much required for any mods that change game mechanics)

@TechTree
{
	@RDNode,*
	{
		@cost *= 2
	}
}

@TechTree
{
	@RDNode[survivability]
	{
		%cost = 5
	}
}

ModuleManager scripts are a pretty big subject but the basic idea in this example is:

  • Look for the thing called TechTree
  • Look at all the things called RDNode (that's the comma + star part)
  • Multiply the cost in each of these by 2
  • Look into the TechTree again
  • Look for the RDNode called 'survivability'
  • Set its cost to 5, removing the previous change.

Creating a new node is a bit more complicated.  You need to place it somewhere on a grid (the pos =... line), make sure it points to it's parent, make sure any children point to it, give it an icon, a cost, etc.  You can use examples you find as a template.

Once you change the tech tree itself you may then need to change the tech node the parts use.  It would look something like:

@PART[bluedog_Centaur_Avionics]
{
	%TechRequired = nasa_tech_4
}

This takes a Bluedog part and places it into a hypothetical 'NASA' tech tree branch you created so NASA and Soviet (Tantares) parts are researched separately.

Link to comment
Share on other sites

BEHOLD THE POWER OF MODULE MANAGER! 

I kind of liked the idea idea of a Soviet, US split tree and I was bored, so I did just that with a single page of MM scripts.  The script takes the stock tree, makes two copies (US and SOVIET) and mirrors them ,then rotates the stock tree so it sits on top (i.e. west is the US, east is the USSR, and on top is the stock tree).  It then looks for Bluedog and Tantares parts and moves them to the new trees. 

The only piece that's missing is that I would like for unlocking either the US or SOVIET node automatically unlocks the stock node.  The frustrating thing is I can do it, but it creates a spagettified mess in the R&D building since I can't figure out how to hide the lines going from parent to child (probably needs a DLL to handle this).   This isn't really a full mod and is quite brittle.  Using anything but the stock tech tree is likely overflow the canvas space and probably create overlaps between the branches.

Anyway, you can see how you can manipulate the TechTree using MM.

Spoiler
@TechTree
{
	//sets the orgin to 0,0 to make it easier to manipulate
	@RDNode,*
	{
		@pos[0] += 2568
		@pos[1] -= 1199
	}
	//copies all the nodes except the start node, makes them russian!
	+RDNode:HAS[~id[start]]
	{
		@id ^= :(.)$:$0_soviet:
		@title ^= :(.)$:$0 - SOVIET:
		@nodeName ^= :(.)$:$0_soviet:
		@Parent:HAS[~parentID[start]]
		{
			@parentID ^= :(.)$:$0_soviet:
		}
	}
	//copies all the nodes except the ruskies and the start, mirrors them and make them yankees
	+RDNode:HAS[~id[start],~id[*_soviet]]
	{
		@id ^= :(.)$:$0_us:
		@title ^= :(.)$:$0 - US:
		@nodeName ^= :(.)$:$0_us:
		@pos[0] *= -1
		@Parent,*
		{
			%lineFrom = LEFT
			%lineTo = RIGHT
		}
		@Parent:HAS[~parentID[start]]
		{
			@parentID ^= :(.)$:$0_us:
		}
	}
	//rotates the stock nodes by 90deg
	@RDNode:HAS[~id[start],~id[*_us],~id[*_soviet]]
	{
		pos0 = #$pos[0]$
		pos1 = #$pos[1]$
		@pos[0] = #$pos1$
		@pos[0] *= -1.2
		@pos[1] = #$pos0$
		@pos[1] *= 0.8
		-pos0 = del
		-pos1 = del

		//This section will automatically unlock stock nodes when either of the cold
		//war nodes are selected.  But the cost is a spagettified mess of lines since
		//I don't know how to hide parent/child lines.  Probably needs to be done
		//via a DLL
		//%anyToUnlock = True
		//%cost = 0
		//!Parent,* {}
		//Parent
		//{
		//	parentID = #$../id$
		//	@parentID ^= :(.)$:$0_us:
		//}
		//Parent
		//{
		//	parentID = #$../id$
		//	@parentID ^= :(.)$:$0_soviet:
		//}
		
		@Parent,*
		{
			%lineFrom = TOP
			%lineTo = BOTTOM
		}

	}
}

//repositions everthing back to the center of the canvas
@TechTree
{
	@RDNode,*
	{
		@pos[0] -= 1900
		@pos[1] += 600
	}
}

//puts parts where they belong!
@PART[bluedog_*]:HAS[~TechRequired[start]]
{
	@TechRequired ^= :(.)$:$0_us:
}
@PART[*]:HAS[#manufacturer[Tantares*],~TechRequired[start]]
{
	@TechRequired ^= :(.)$:$0_soviet:
}

 

 

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