Wow, that was actually something I had completely forgotten about the CP DLL. I mostly began using it for the Unified Yields aspect, which makes traits, policies, beliefs, buildings, etc. so much easier to work with. I totally let it slip my mind that it added new Lua hooks as well! There's obviously a lot of investigation I need to do to find out exactly what new limits the CP DLL allows me to get to. Thanks, that neatly solves my problem!
I've got another question, simply while I'm thinking of it. I actually solved the basic question on my own, but I'm asking it in the pursuit of an answer to a related issue that it creates:
Say I want a building that, for every 4 you own, City-State Influence decays slower. Easy enough: use Lua to track the amount you have, grant dummy Policies that lower CS Influence decay whenever you reach certain thresholds. The issue this creates, however, is related to the fact that you can also dip down below thresholds after reaching them (say you have 5 of this building and lose two of them; now you have 3 and technically this means you shouldn't get the bonus policy anymore). Because of this, it means the Policies need to be granted and taken away depending on the thresholds, and the problem comes in with the taking away part.
I know that taking away a Policy without putting one in its place completely breaks the Social Policy cost calculation, so I just remove the CS Influence policy and give the player a placeholder policy until they reach that threshold again, whereupon I remove the placeholder and give them the proper policy again. Again, it seems like it would work in theory, but I remember hearing that if you fiddle around with Policies too much, especially with the SetNumFreePolicies(1)/SetNumFreePolicies(0) trick, it causes problems with Policies as well.
I seem to remember hearing that doing it too many times can cause some problems, and obviously, in this circumstance, adding and taking away Policies as necessary might have unforeseen consequences in and of itself.
So, my question is this: what exactly are the repercussions with granting too many "dummy" free Policies through Lua (through the SetNumFreePolicies trick described above)? Are there any, or am I completely mistaken about the risks of doing so? Can I do it as many times I want safely, or do I need to keep a close eye on how many I'm giving? Is this entire issue not actually an issue, and I've just been misinformed?
It's not a pressing question related to how to solve something, and far more related to what my limits are (since that's a useful thing to know)! I just thought I would inquire while I had the chance, since I'd prefer to find out sooner rather than later if my solution might cause some gamebreaking Policy-related crash of all that is good in the world once I granted one too many free dummy Policies.