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
Message
Author
User avatar
Oberlus
Small Juggernaut
Posts: 741
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.

Advantages:
- 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: 12293
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.

Ophiuchus
Vacuum Dragon
Posts: 573
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.

User avatar
em3
Vacuum Dragon
Posts: 514
Joined: Sun Sep 25, 2011 2:51 pm

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

#4 Post by em3 » Wed Nov 14, 2018 5:08 pm

Geoff the Medio wrote:
Tue Aug 14, 2018 2:33 pm
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.
The keys imported from scripts could have a commonc prefix (like FOCS_ or SCRIPT_) or even be prefixed with the script name that contains them.
[...] for Man has earned his right to hold this planet against all comers, by virtue of occasionally producing someone totally batshit insane. - Randall Munroe, title text to xkcd #556

User avatar
Dilvish
AI Lead, Programmer
Posts: 4741
Joined: Sat Sep 22, 2012 6:25 pm

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

#5 Post by Dilvish » Thu Nov 15, 2018 9:34 am

Geoff the Medio wrote:
Tue Aug 14, 2018 2:33 pm
It probably wouldn't be difficult to add the ability to #include macros within the stringtable (treating the macros as stringtable entries)
I believe that's already possible, and is essentially the same thing I did when I added content_specific_parameters.txt and common_user_customizations.txt (at least it is my vague recollection I added those lol).
If I provided any code, scripts or other content here, it's released under GPL 2.0 and CC-BY-SA 3.0

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

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

#6 Post by Geoff the Medio » Thu Nov 15, 2018 10:15 am

Dilvish wrote:
Thu Nov 15, 2018 9:34 am
Geoff the Medio wrote:
Tue Aug 14, 2018 2:33 pm
It probably wouldn't be difficult to add the ability to #include macros within the stringtable (treating the macros as stringtable entries)
I believe that's already possible...
Appears so: https://github.com/freeorion/freeorion/ ... txt#L18769

Post Reply