Sid Meier's Civilization V

Sid Meier's Civilization V

评价数不足
Building Created Event [snippet for mod makers]
   
奖励
收藏
已收藏
取消收藏
文件大小
发表于
更新日期
4.180 KB
2014 年 6 月 26 日 下午 6:08
2014 年 8 月 30 日 下午 5:12
4 项改动说明 ( 查看 )

订阅以下载
Building Created Event [snippet for mod makers]

在 Machiavelli 的 1 个合集中
Machiavelli's snippets for mod makers
6 件物品
描述
For mod makers.

What it does
This mod contains code that defines a lua event that fires off when a building is created. The event does not fire for buildings with 0 or less hammer cost unless they have a faithCost greater than zero and are enabledByBelief. The lua event provides the information you need to get the city object and the buildingclass.

If an end-user is playing with multiple mods that use this snippet it will work properly.

Compatibility
This code is compatible with Vanilla, Gods & Kings and Brave New World.

How to incorporate into your mod
The building created event will only work correctly if you are also using the unit created event snippet. A copy of the unit created event code is included in this mod.

Copy the "unit created" 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).

Copy the "building created" directory and all its contents to your mod. Have the XML and SQL files update the database (via the Action tab) and set the LUA file as an "InGameUIAddin" (via the Content tab).

How to use
Add your functions to the "LuaEvents.BuildingCreatedEvent" event.

How it works
This code creates a new unit class for every building class. These units are named "UNIT_BCE_BUILDINGCLASS_TEMPLE", "UNIT_BCE_BUILDINGCLASS_MONUMENT" etc (BCE = Building Created Event). It then has every building provide 1 free copy of the unit class for it. The unit created snippet is used to detect when a "buildingClass" unit is created and immediately delete the unit and fire off the event.

The end user should never ever see a "buildingClass" unit. They serve no purpose other than to be detected and deleted immediately.

CivFanatics Download[forums.civfanatics.com]
5 条留言
UncivilizedGuy 2014 年 9 月 5 日 下午 5:05 
Thanks for responding. Makes more sense now.
Machiavelli  [作者] 2014 年 9 月 5 日 上午 4:56 
Say you want to give a civilization you are creating the trait "+1 Population when a city builds a National or World Wonder." You can write some code that hooks into this event and tests if the created building was a Wonder, if so, give the city +1 Pop.
UncivilizedGuy 2014 年 9 月 4 日 下午 9:05 
Could you possiblly give me a scenario of where and when I would use this code? I've read your description a few times but I'm still not clear.
Machiavelli  [作者] 2014 年 8 月 30 日 上午 8:47 
Just as an fyi, I plan on releasing a small update for this snippet at some point this weekend. The update includes giving the "blank building units" a base movement so end users can manually delete them (as a fail safe if for some reason they aren't deleted automatically) and adding some code that be default will do nothing but end users can enable. The code would be something that look each turn for "blank building units" and deletes them. The optional code would be something users could enable as a fail safe if the units aren't deleted automatically.
ultima9 2014 年 8 月 30 日 上午 2:30 
Interesting. Thanks for sharing!