DLL - Modular Faith and Gold Purchasing

JFD

Kathigitarkh
Joined
Oct 19, 2010
Messages
9,132
Location
The Kingdom of New Zealand
This is a three-fold request that I think is in serious need of accommodating.

The first is that faith purchases (of units or buildings, but hypothetically could apply to projects or - perhaps a stretch - tiles) are completely nonviable without tying them to the RequiresBelief tag; in that they ignore all other requirements (tech, civilization, terrain, policy, etc.). I brought this up in the main CP thread and Whoward indicated that this was to be fixed in the next release of his DLL, but I thought I'd reiterate it here for documentation.

The second is the hard-coded nature of Great People purchasing with faith. It would be preferable if the branch prerequisite was pushed out of the DLL (and possibly amended to require a certain policy - in the case of vanilla, the finisher policy) so that modders with designs on the social policy system don't have to jump through hoops to retain the mechanic, or to be forced to ditch it entirely when they released how high those hoops were.

Finally, I would ask that it be possible to give more modularity to controlling purchasing in general. Firaxis began this by allowing you to restrict units to "Purchase only [with Gold]." I would advocate that this be extended to buildings, as well as to be inclusive of faith. Finally, I believe the capacity to purchase in puppet cities should be exposed to Lua.
 
The first is that faith purchases (of units or buildings, but hypothetically could apply to projects or - perhaps a stretch - tiles) are completely nonviable without tying them to the RequiresBelief tag; in that they ignore all other requirements (tech, civilization, terrain, policy, etc.). I brought this up in the main CP thread and Whoward indicated that this was to be fixed in the next release of his DLL, but I thought I'd reiterate it here for documentation.
Should be fixed. The code rather foolishly contained ALL the conditions for buying buildings with faith within the IsUnlockedByBelief test. That's been corrected, so only the religion related conditions are within that test. All the others (tech, pre-req buildings, etc, etc including the CanConstruct event) are now outside of the IsUnlockedByBelief test

The second is the hard-coded nature of Great People purchasing with faith. It would be preferable if the branch prerequisite was pushed out of the DLL (and possibly amended to require a certain policy - in the case of vanilla, the finisher policy) so that modders with designs on the social policy system don't have to jump through hoops to retain the mechanic, or to be forced to ditch it entirely when they released how high those hoops were.
Gotta love Firaxis' "most moddable civ ever" ;)
Totally agree, now all I need to do is find the time. If anyone else takes this on, please sort out the hard-coding of the three ideologies at the same time :crazyeye:

Finally, I would ask that it be possible to give more modularity to controlling purchasing in general. Firaxis began this by allowing you to restrict units to "Purchase only [with Gold]." I would advocate that this be extended to buildings, as well as to be inclusive of faith.

See the Unified Prereqs thread - as I'm pretty sure that covers all possible combinations. If not, extra functionality should be requested on that thread

Finally, I believe the capacity to purchase in puppet cities should be exposed to Lua.

What have the Romans ever done for us ... Two finally's :D
Not sure I follow. Purchasing in Lua is done by deducting the gold/faith from the user and using SetNumReal/FreeBuilding() - both of which should work for any city (normal, puppet, resistance, whatever)
 
Not sure I follow. Purchasing in Lua is done by deducting the gold/faith from the user and using SetNumReal/FreeBuilding() - both of which should work for any city (normal, puppet, resistance, whatever)

Ah, I may be mistaking a UI limitation for a DLL limitation then; wherein Venice may purchase buildings and units in puppet cities through the tag "AbleToAnnexCityStates," which I presume enables the "purchase" button that is over-wise disabled, rather than enables the functionality of purchasing.

Should be fixed. The code rather foolishly contained ALL the conditions for buying buildings with faith within the IsUnlockedByBelief test. That's been corrected, so only the religion related conditions are within that test. All the others (tech, pre-req buildings, etc, etc including the CanConstruct event) are now outside of the IsUnlockedByBelief test

Finally, this is something I have long awaited :)
 
AbleToAnnexCityStates

IIRC is used to a) enable the purchase button in the UI and b) let the AI use it's standard logic for Venice's puppets
 
No. Not what I said, it uses the trait attribute to let it use it's standard city logic in the puppets - there are numerous occurrences of bTheVeniceException in the AI city code.
 
The second is the hard-coded nature of Great People purchasing with faith. It would be preferable if the branch prerequisite was pushed out of the DLL (and possibly amended to require a certain policy - in the case of vanilla, the finisher policy) so that modders with designs on the social policy system don't have to jump through hoops to retain the mechanic, or to be forced to ditch it entirely when they released how high those hoops were.

Edit: If you want to test this, they are in V53 of my DLL

Some hard-coded eras have been pushed out into the xml config files
Code:
<GameData>
  <PostDefines>
    <Row Name="RELIGION_LAST_FOUND_ERA">
      <Key>ERA_RENAISSANCE</Key>
      <Table>Eras</Table>
    </Row>
    <Row Name="RELIGION_GP_FAITH_PURCHASE_ERA">
      <Key>ERA_INDUSTRIAL</Key>
      <Table>Eras</Table>
    </Row>
    <Row Name="IDEOLOGY_START_ERA">
      <Key>ERA_INDUSTRIAL</Key>
      <Table>Eras</Table>
    </Row>
  </PostDefines>
</GameData>

and the hard-coding of great people purchased with faith has been pushed out into it's own table.

Code:
<GameData>
  <Table name="Policy_FaithPurchaseUnitClasses">
    <Column name="PolicyType" type="text" reference="Policies(Type)"/>
    <Column name="UnitClassType" type="text" reference="UnitClasses(Type)"/>
    <Column name="EraType" type="text" reference="Eras(Type)" default="NULL"/>
  </Table>

  <Policy_FaithPurchaseUnitClasses>
    <Row>
      <PolicyType>POLICY_AESTHETICS_FINISHER</PolicyType>
      <UnitClassType>UNITCLASS_WRITER</UnitClassType>
    </Row>
    <Row>
      <PolicyType>POLICY_AESTHETICS_FINISHER</PolicyType>
      <UnitClassType>UNITCLASS_ARTIST</UnitClassType>
    </Row>
    <Row>
      <PolicyType>POLICY_AESTHETICS_FINISHER</PolicyType>
      <UnitClassType>UNITCLASS_MUSICIAN</UnitClassType>
    </Row>
    <Row>
      <PolicyType>POLICY_RATIONALISM_FINISHER</PolicyType>
      <UnitClassType>UNITCLASS_SCIENTIST</UnitClassType>
    </Row>
    <Row>
      <PolicyType>POLICY_COMMERCE_FINISHER</PolicyType>
      <UnitClassType>UNITCLASS_MERCHANT</UnitClassType>
    </Row>
    <Row>
      <PolicyType>POLICY_TRADITION_FINISHER</PolicyType>
      <UnitClassType>UNITCLASS_ENGINEER</UnitClassType>
    </Row>
    <Row>
      <PolicyType>POLICY_HONOR_FINISHER</PolicyType>
      <UnitClassType>UNITCLASS_GREAT_GENERAL</UnitClassType>
    </Row>
    <Row>
      <PolicyType>POLICY_EXPLORATION_FINISHER</PolicyType>
      <UnitClassType>UNITCLASS_GREAT_ADMIRAL</UnitClassType>
    </Row>

    <!-- CSD -->
    <Row>
      <PolicyType>POLICY_PATRONAGE_FINISHER</PolicyType>
      <UnitClassType>UNITCLASS_GREAT_DIPLOMAT</UnitClassType>
    </Row>
  </Policy_FaithPurchaseUnitClasses>
</GameData>

The earliest era any GP can be faith purchased in is defined by RELIGION_GP_FAITH_PURCHASE_ERA, but individual GP classes can be pushed into later eras by specifying EraType, eg

Code:
    <Row>
      <PolicyType>POLICY_AESTHETICS_FINISHER</PolicyType>
      <UnitClassType>UNITCLASS_MUSICIAN</UnitClassType>
      <EraType>ERA_MODERN</EraType>
    </Row>

would limit Great Musicians to the modern era or later
 
I didn't even realise that ideologies were hardcoded in this way. :D

Neither did I - I was looking for where religion hard-codes the first era that GP can be faith purchased (which I knew was the industrial) and I found that one for ideologies!

Ideologies are a major hard-code pile of spaghetti. Not only are the "policy branch" names hard-coded but so is the assumption that there will always be three of them :(
 
Two questions about this feature:
  • Can we allow any UnitClassType to be available for faith purchase (i.e. also non-GP units)?
  • Can we control what the faith cost of the unit will be? For instance if I want Liberty to allow purchase of Settlers with faith and want the faith-cost of a settler to be 200, is this possible, or is it fixed at 1000 faith?
 
You should be able to do both of these with the standard pPlayer:CanTrain() and pCity:CanTrain() events and giving the unit a faith purchase cost - note there is already a fix to the "can only faith purchase with the a belief" issue. (The point of these changes is to un-hard-code the purchase of GP with faith at policy finishers.)

Incremental costs are not supported by the standard mechanism, eg you couldn't have a settler cost 200, 300, 500, 800 etc
 
Unit faith purchasing seems to be tied to having a religion, and cannot be unlocked with a Pantheon belief. Is there any way around this?
Yes and yes - by changing the requirement to "religious majority or a pantheon present in the city". It'll be in the next build.
 
I've discovered that purchasing items with gold/faith in puppets cities is not just a UI limitation, which has impeded my plans quite a bit. The production list is generated with the IsCanPurchase check, which evidently returns false if the city is a puppet, unless they are "TheVeniceException." I could work around this by creating my own IsCanPurchase function which allows for what I need, but that seems prone to problems (and wouldn't tell the AI they can purchase). So is there anyway something can be added to that check in the DLL that I could use to control purchasing in puppet cities. As this is something I need to work with on a city basis, it could be some kind of tag added to a building like: "AllowPuppetPurchases" or something. Unless this sort of thing can be handled as a Lua hook. Whatever's easiest, hopefully. It would be much appreciated. Thanks.
 
I've discovered that purchasing items with gold/faith in puppets cities is not just a UI limitation, which has impeded my plans quite a bit. The production list is generated with the IsCanPurchase check, which evidently returns false if the city is a puppet, unless they are "TheVeniceException." I could work around this by creating my own IsCanPurchase function which allows for what I need, but that seems prone to problems (and wouldn't tell the AI they can purchase). So is there anyway something can be added to that check in the DLL that I could use to control purchasing in puppet cities. As this is something I need to work with on a city basis, it could be some kind of tag added to a building like: "AllowPuppetPurchases" or something. Unless this sort of thing can be handled as a Lua hook. Whatever's easiest, hopefully. It would be much appreciated. Thanks.

Any info on this? I can't continue with my mod until I know whether this issue can be helped, and if it can't, well, that's going to be difficult to get around. Basically, I need some way to tell the IsCanPurchase function to skip puppets when I need.
 
Sorry, missed this post. I've got something that should do the trick, hopefully.

Edit: So here's the changes. You'll have two new rows to work with - one in units, and one in buildings. Each is a boolean of PuppetPurchaseOverride.

Code:
-- Allows for Building to be purchased in puppet city
ALTER TABLE Buildings ADD COLUMN 'PuppetPurchaseOverride' boolean default false;

-- Allows for Unit to be purchased in puppet city
ALTER TABLE Units ADD COLUMN 'PuppetPurchaseOverride' boolean default false;

I've added a modded ProductionPopup.lua file to the CP that makes this work.

I've uploaded a test version of the CP at the link below - let me know if you have any problems.

G
 
Back
Top Bottom