Sid Meier's Civilization: Beyond Earth

Sid Meier's Civilization: Beyond Earth

评价数不足
Policies grant perks & buildings [snippet for mod makers] (vanilla)
   
奖励
收藏
已收藏
取消收藏
文件大小
发表于
更新日期
20.973 KB
2014 年 12 月 14 日 上午 8:46
2015 年 2 月 1 日 上午 8:36
2 项改动说明 ( 查看 )

订阅以下载
Policies grant perks & buildings [snippet for mod makers] (vanilla)

在 Machiavelli 的 1 个合集中
Machiavelli's snippets for mod makers
5 件物品
描述
For mod makers. This version of this snippet is only for vanilla Beyond Earth. If you want the Rising Tide version of this snippet go to: here.

What it does
This mod contains code that defines four new XML tables. By adding entries to these tables mod makers can have Virtues (aka Policies) grant buildings in cities. 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_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 vanilla Beyond Earth. If you want the Rising Tide version of this snippet go to: here.

How to incorporate into your mod
Copy the "Policies grant buildings" directory and all its contents to your mod. Have the XML file 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 four tables: Policy_PGB_FreeBuildingClass, Policy_PGB_FreeBuildingClassCapital, 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]
33 条留言
Machiavelli  [作者] 2015 年 10 月 25 日 下午 6:59 
I've updated this snippet for Rising Tide and put it on the workshop. There are links to the Rising Tide version at the top of this workshop page.

Gokudo, the problem you are seeing is a mistake on my part. I copied InfoTooltipInclude.lua from another of my mods when I was putting together this snippet. Those missing strings are stuff my other mod uses that the snippet does not need. The Rising Tide version does not have that mistake. You can fix the issue by deleting three lines from InfoTooltipInclude.lua (search for "nh_" to find them, they are all next to each other. I'll see about updating this version of the snippet to fix that shortly.
Gokudo31 2015 年 10 月 25 日 下午 12:20 
I get : TXT_KEY_NH_POLICY_EFFECT_BUILDING_PURCHASE_COST_MODIFIER
Gokudo31 2015 年 10 月 25 日 下午 12:11 
ok thx dude. May you explain me why the infotooltips doesn't seem to work with the building cost reduction in the policy.xml ?
Machiavelli  [作者] 2015 年 10 月 24 日 上午 7:28 
The InfoTooltipInclude.lua assumes you are using both the Policies Grant Buildings and the Policies Grant PlayerPerks. If you're only using one it will not work correctly. I should have put that information above in an explicit location.

I've completed regression testing and have found some areas where I will need to change the code for Rising Tide. I'm probably going to mark this workshop entry as the base game version and put up another entry that will be for Rising Tide. I'll have some time to work on it this weekend so hopefully it will be done before Monday.
Gokudo31 2015 年 10 月 22 日 下午 9:55 
I've got an issue where I cant display the virtue menu once I've activated InfoTooltipInclude.lua vfs = true. I only use the Policy_PGP_Freeperk( InfoTooltipInclude, Policy_GP_Freeperk lua and xml). Is there any kind of dependancy between InfoTooltipInclude and The building part of your mod ?
Machiavelli  [作者] 2015 年 10 月 21 日 下午 5:33 
Gokudo, I haven't completed regression testing yet. But so far the code seems fine in its current form. I have not been able to reproduce the crash Galgus described. You can probably continue to use the code as is for your Rising Tide mods.
Gokudo31 2015 年 10 月 21 日 下午 4:32 
excuse my presumptuousness, but is there any ETA ?
Machiavelli  [作者] 2015 年 10 月 9 日 下午 6:51 
I haven't updated this snippet for Rising Tide yet so it may not work correctly until then.
Galgus 2015 年 10 月 9 日 下午 6:07 
With additional testing, I believe that policies granting perks is the source of the crash, conflicting with the new trait system.