Deducting research points?

Pazyryk

Deity
Joined
Jun 13, 2008
Messages
3,584
I need a mechanism that can deduct a given number of research points from a civ's total. I've been trying to do this by deducting points from a civ's current researching tech (a teamTechs function). The problem with this is that it is too late: the civ will pop a new tech before my function has a chance to deduct research points (I guess I could then retroactively take the tech away, but that's messy).

Anyone have any suggestions for me?
 
It depends on what exactly you're deducting for, or more specifically, whether it's something that's liable to change from one turn to the next. For instance, if you want to make a civ research more slowly when it's ahead in techs, don't deduct research points each turn; instead, create a no-cost hidden building that gives a -10% research penalty, then use Lua to give that building to all cities owned by whichever player is in the lead. And since you can declare a <NoLimit> flag in the building class, you can stack this building if you want it to be -50% for whoever's in first, -40% for whoever's in second, and so on. Or, if you don't like percentiles, you can make it a -5 research per turn sort of thing, but that obviously is going to have era-dependence issues. You can either do this on a city-by-city basis, or create a National Wonder that has an empire-wide research penalty, and place it in the capital. That Wonder option is a much better solution, usually, since it doesn't require a city-by-city check, but has a few other issues depending on whether the player has turned on things like the "limit one national wonder per city" flag. (Wonders also often have notifications.)
This hidden building mechanism avoids the already-complete issue you noted, and it also makes the "turns until complete" readout more accurate, since that'll now take into account the reduced research rate. The only real downside, besides the obvious need for a turn-by-turn check and reallocation, is that the city UI will show this penalty under the "from Buildings" line of the research popup, and if you haven't modded CityView like I have, it'll show up in your buildings-in-city list.

It's also possible to use Policies to slow down research in a similar way, although that really only works if your mod uses a "placeholder" hidden Policy, like mine do. Getting a hidden policy to work takes a LOT more work than a hidden building, but if you have the choice it's actually a better solution since there are no issues if a city gets captured.
 
Yeah, I know how to change percent yield (empire wide or city). I already have hidden policies out the wazoo. However, it would be much more desirable from an aesthetic point of view if I could deduct research points rather than percent. And best if I could do this from the total after all cities contribute with their modifiers intact.
 
Well, deducting linearly instead of as a percentile isn't tough, since that's just a different table for the hidden building. But if you want to do this without the city UI being affected, and only do it after all cities have contributed? Then I'd say it can't be done, barring the DLL of course.

I mean, sure, you could invert the situation (increase the costs of all techs, and give extra beakers to everyone OTHER than the civ you want to penalize); that'd solve your completion issue. But the UI for that would be really messy, since all of the completion times would go out the window (meaning edits to TopPanel and TechTree to fix).
 
I may go with percent. The annoying thing is that the "game rule" that is driving this is in the form "deduct x total research points". I guess what I can do is look at total base research from all cities, then calculate the percent deduction that would achieve x total points penalty. It's annoying because I want the UI to show total research before deduction and then the deduction (in points, not percent). But I can do that by heavy editing of the top panel.
 
But I can do that by heavy editing of the top panel.

It won't take THAT much editing. The only thing you really lack is an easy Lua function for accessing your new value. As long as you have any kind of persistent data storage within your mod, this isn't too difficult to deal with. I had very similar issues with Happiness in my own mod, as I'd added happiness-producing Specialists and wanted a separate line for them instead of being lumped into Building or Other, although at least there it was easy to calculate on the fly how much Happiness you had from that source (just by counting them up on the spot).

Honestly, the bigger problem is that if, internally, your yield modifier (or my Happiness) is being handled through a building-based placeholder, then you'll potentially cause problems when someone ELSE's mods are being used alongside yours. Sure, I may know that not all of the building-generated Happiness is actually from buildings, and I changed TopPanel to reflect that, but anyone else using that Lua access function would see a different value than they were expecting.
 
Back
Top Bottom