Changing the way topics are researched

Hmm, well, I’m not sure how complicated this would be to implement on your end, but it would be nice if there was a more straightforward way to change what topics are available for research.

I’m half-way through a small mod that changes topic discovery so that every time you research a topic, you get a chance of making related topics available for research (so, for example, there’s a 10% chance that Fantasy will become available for research after you research Medieval). The problem is, there are two separate functions that construct topic selection UIs, one for the research window and one for the game creation window, and one of them’s anonymous so I can’t just hook it. (The publisher contracts also need to know what topics are available, and that function is also anonymous, if I remember correctly.)

What I’m doing is changing general.getTopicOrder() and Research.TOPICS_VISIBLE to get around this, but it’s a pretty hacky solution. I’m not sure exactly what you could do on your end that wouldn’t be inconvenient. If it was me, I’d probably make an array, like “Research.Topics,” storing all the topics along with a status for each, “Researched,” “Discovered,” or “Hidden.” That’s probably an hour or two of work, though, to re-arrange the functions I mentioned above and change the saving/loading and mod loading code.

(BTW, you closed that other thread before I got a chance to thank you, so thanks for that event key!)

It should be fairly straight forward to expose an anonymous method. Can you tell me which one is giving you trouble?

The function that creates publisher contracts calls a function, p, which selects a topic for the contract. It’s one of only four uses of .getTopicOrder(), which should make it easy to look up. (Looks like I was misremembering about there being separate UIs for picking a topic for research and for use in a game; they both use UI.pickTopicClick().)

To be honest, though, I might still go with my hacky solution even if I could hook both functions. I’m somewhat worried about incompatibility with other mods that change topic selection or publisher contracts. Expansion Pack, for example, changes pickTopicClick() to allow searching for a topic, so my mod wouldn’t be compatible with it. Changing getTopicOrder() and TOPICS_VISIBLE would allow me to maintain compatibility.

It’d be a lot easier if I could just say something like Research.Topics[discoveredTopic].status = “Discovered”, but if it’d turn out to be a pain for you don’t worry about it.

let me see what I can do.

@kane_t I think I might just rewrite this to expose a method that you can use to centrally decide what topics are available for research. Something like

General.getTopicsAvailableForResearch = function (company) {
	var topicsAvailableForResearch=[];
	var topics = General.getTopicOrder(company);
	for (var i = 0; i < topics.length; i++) {
		var topic = topics[i];
		var isAvailable = company.topics.indexOf(topic) != -1;
		var isInResearch = GameManager.currentResearches.filter(function (f) { return f.topicId === topic.id; }).length > 0;
		if (!isAvailable && !isInResearch) {
			if (topicsAvailableForResearch.length < Research.TOPICS_VISIBLE) {
				topicsAvailableForResearch.push(topic);
			}
		}
	}
	return topicsAvailableForResearch;
};

which are then used in the selection UI and contract picker. To add your own logic you can then simply hijack that method.

Granted, this will mean that the Expansion Pack would need to adjust its code to be compatible but I think it’s worth the trouble.

General.getTopicsAvailableForResearch() will be available in the workshop update.

Great! That’s pretty ideal for my purposes, yeah. Thanks!