Sid Meier's Civilization: Beyond Earth

Sid Meier's Civilization: Beyond Earth

Not enough ratings
Policies grant buildings & perks [snippet for mod makers] (RT)
   
Award
Favorite
Favorited
Unfavorite
File Size
Posted
24.926 KB
25 Oct, 2015 @ 6:34pm
1 Change Note ( view )
You need DLC to use this item.

Subscribe to download
Policies grant buildings & perks [snippet for mod makers] (RT)

In 1 collection by Machiavelli
Machiavelli's snippets for mod makers
5 items
Description
For mod makers. The UI changes in this snippet will only work if you use both the Buildings and Perks code. Even if you only need one, incorporate both into your mod.

What it does
This mod contains code that defines six new XML tables. By adding entries to these tables mod makers can have Virtues (aka Policies) grant buildings in cities. It also has a table that allows Virtues to grant playerPerks. If an end-user is playing with multiple mods that use this snippet it will work properly.

Policy_PGB_FreeBuildingClass: <PolicyType, BuildingClass, Help>
The building will be granted to every city. The Help string will be added to the tooltip for the Virtue.

Policy_PGB_FreeBuildingClassCapital: <PolicyType, BuildingClass, Help>
The building will be granted to only the capital. If the capital moves (due to conquest) the building automatically moves.

Policy_PGB_FreeBuildingClassWater: <PolicyType, BuildingClassType, Help>
The building will be granted to cities founded on the water.

Policy_PGB_FreeBuildingClassLand: <PolicyType, BuildingClassType, Help>
The building will be granted to cities founded on land.

Policy_PGB_FreeBuildingClassCoastal: <PolicyType, BuildingClassType, Help>
The building will be granted to cities founded on coasts.

Policy_PGB_FreeBuildingClassRiver: <PolicyType, BuildingClassType, Help>
The building will be granted to cities founded on rivers.

Policy_PGP_FreePerk: <PolicyType, FreePlayerPerk>
The player will be given the perk. The perk's help text will be added to the tooltip for the Virtue.

Compatibility
This code is compatible with Rising Tide.

How to incorporate into your mod
Copy the "Policies grant buildings" directory and "Policies grant Perks" directory to your mod. Have the XML files update the database (via the Action tab) and set the LUA file as an "InGameUIAddin" (via the Content tab).

Make sure the XML files from this snippet that create the table update the database before any files attempt to add entries into the tables for this snippet.

InfoTooltipInclude.lua will need to be added via "InGameUIAddin" and have VFS set to true. It will replace the existing InfoTooltipInclude.lua. Without it the help text will not get added to the Virtue tooltip (but buildings and perks will still be granted).

How to use
Add entries to one of the six tables: Policy_PGB_FreeBuildingClass, Policy_PGB_FreeBuildingClassCapital, Policy_PGB_FreeBuildingClassLand, Policy_PGB_FreeBuildingClassWater, Policy_PGB_FreeBuildingClassCoastal and Policy_PGB_FreeBuildingClassRiver.

These buildings should have: cost=-1, ConquestProbability=0

Or add entries to: Policy_PGP_FreePerk

The perk's help text will be shown in the tooltip UI for the Virtue.

How it works
A collection of functions detect when a player adopts a policy, founds a city or conquers a city. When one of those things happen the code fires off an event for the new city (or every city a player owns when they acquire a policy) asking all the tables to add to a list of buildings that will be given to the city. Each table listens for that event and adds its own buildings to the list. Once the list is complete the code adds the buildings to the city or cities.

Limitations
Synergy bonus Virtues (the depth or breadth kickers) may not work if they are granting Buildings or Perks. If this is a problem I can enhance the detection logic to make them work correctly.

How to add new tables
By using the LUA in Policy_PGB_FreeBuildingClassCoastal.lua as a starting point you can (with minimal lua) easily add support for additional tables. Tables you add in this way will work correctly even if an end-user is playing with another mod that uses this snippet but does not include your table. If you have any questions on how to add support for another table contact me and I'll help you out.

CivFanatics Thread[forums.civfanatics.com]
CivFanatics Download[forums.civfanatics.com]
3 Comments
eristik 13 Dec, 2015 @ 1:36am 
thanks for replying. i think for balance it should be that the tech unlocks a new building which then grants the perk in that city, but i guess the AllowSpecialistsFreeFood = true is a factionwide setting, so it would have to be granted as a tech perk. i've got many mods installed so i wanted to manually edit this in somewhere; i'll have to start poking around now. :)
Machiavelli  [author] 12 Dec, 2015 @ 6:20am 
It wouldn't be very hard to make a snippet that had techs grant buildings. But I don't want to promise that I'll have time to do that in the near term.

But some of the things you want to do should be possible already with only XML. For example, to make a tech that makes specialists not eat food have the tech grant a perk (Technology_FreePlayerPerks) table and the perk needs to have AllowSpecialstsFreeFood = true. You won't require a building middle man.

To make a Wonder grant a building in every city you can try FreeBuilding in the building table. If that doesn't work than have the building grant a perk (FreePlayerPerk in the buildings table) and have the perk have FreeBuilding.
eristik 12 Dec, 2015 @ 2:01am 
i'm curious if you can make a snippet that allows you to add a building or wonder to a tech; sorry, but i can't find anything similar to this in forums or workshop. basically my goal would be to add a wonder that grants buildings to each city and scales to # of cities, or just a building to Mind Uploading that makes specialists not eat food, similar to the diplomatic agreement. i'm not sure where to begin with this though. thanks in advance for any input.