Move tech/building values to a single macro file

Creation, discussion, and balancing of game content such as techs, buildings, ship parts.

Moderator: Committer

Post Reply
User avatar
Small Juggernaut
Posts: 704
Joined: Mon Apr 10, 2017 4:25 pm

Move tech/building values to a single macro file

#1 Post by Oberlus » Tue Aug 14, 2018 6:53 am

The effects of buildings and non-theoretical techs are scripted in their respective building or tech FOCS file, with some values (user-defined constants) included from extern files and some others only defined in the own file. E.g., the boost from Algorithmic Elegance is calculated as Target.Population * 0.5 * [[RESEARCH_PER_POP]], where 0.5 is defined only in that file and RESEARCH_PER_POP is included from /scripting/common/base_prod.macros.

I've been fiddling with research/production techs/buildings to mitigate the snowball effect. The changes in a (say) tech file will not be reflected on the pedia (documentation) unless you also edit the corresponding descriptions on all the stringtable files (one for each language), and to be sure to cover everything related to a given meter you have to review many files in different folders.

I'm suggesting here to move all those 0.5, 1, 2.5, etc. constant values used in the tech/building files to a macro file in the common folder to be referenced from stringtables (can this be done?) and FOCS files.

- Group all values relevant to a given meter (e.g. research) in a single file, which eases any rebalancing and is less prone to buggy omissions.
- Immediate updating of documentation when some values are changed for rebalance.

If developers see this as an improvement, and since this only implies FOCS changes, I could try to make a PR for this (after proper discussion/guidance).

User avatar
Geoff the Medio
Programming, Design, Admin
Posts: 12268
Joined: Wed Oct 08, 2003 1:33 am
Location: Munich

Re: Move tech/building values to a single macro file

#2 Post by Geoff the Medio » Tue Aug 14, 2018 2:33 pm

Oberlus wrote:
Tue Aug 14, 2018 6:53 am
I'm suggesting here [that scripted constants] be referenced from stringtables (can this be done?)
I don't think so. You can look up stringtable entries in a FOCS script, and there are tag substitutions in some strings that can make links to objects or content or substitute the name of an in-game object (eg. [[metertype METER_STEALTH]]), and there are the numbered substitutions which match up with substitutions in the C++ code (like %18%), and strings can include macros to other stingtable keys. But there is no way to access a scripting macro from within a stringtable entry directly. It probably wouldn't be difficult to add the ability to #include macros within the stringtable (treating the macros as stringtable entries), which might be enough to do what you want, but the feature doesn't currently exist. It might get tricky to do this though, as you'd need to be sure that there are no duplicate macros included from different macro files, and that none of the string keys conflict with macro keys.

Vacuum Dragon
Posts: 544
Joined: Tue Sep 30, 2014 10:01 am

Re: Move tech/building values to a single macro file

#3 Post by Ophiuchus » Thu Aug 16, 2018 7:37 pm

From a maintainability standpoint: it would be good to have base values used in FOCS defined in single place for all three of the following uses, so they are always in sync: AI, encyclopedia, and of course FOCS
Any code or patches in anything posted here is released under the CC and GPL licences in use for the FO project.

Post Reply