Machiavelli24
Mod creator
- Joined
- May 9, 2012
- Messages
- 818
I have a handful of reusable snippets that can be used to implement a wide range off effects. In the past I've provided these haphazardly to other mod makers who have asked but I wanted to present them in a more central location. None of these snippets require a modified DLL.
Workshop location of the whole collection.
Unit Created Event (Vanilla, G&K, BNW)
Workshop
CivFanatics Download
This mod contains code that defines a lua event that fires off when a unit is created. The event does not fire when a unit is upgraded. The lua event provides the information you need to get the owning player object and the unit object.
Building Created Event (Vanilla, G&K, BNW)
Workshop
CivFanatics Download
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.
Policies grant buildings (Vanilla, G&K, BNW)
Workshop
CivFanatics Download
This mod contains code that defines three new XML tables. By adding entries to these tables mod makers can have Social Policies grant buildings in cities.
Policy_PGB_FreeBuildingClass: <PolicyType, BuildingClass>
The building will be granted to every city.
Policy_PGB_FreeBuildingClassCapital: <PolicyType, BuildingClass>
The building will be granted to only the capital. If the capital moves (due to conquest) the building automatically moves.
Policy_PGB_FreeBuildingClassCityStates: <PolicyType, BuildingClassType>
The building will be granted to captured city-states.
Religion snippets (G&K, BNW)
Workshop
CivFanatics Download
This mod contains code that defines two lua events and a new XML table:
LuaEvents.CityAdoptsReligionEvent(iOwner, iX, iY, eOldReligion, eNewReligion, bFirstConversion)
A LUA event that fires when a city adopts a religion.
LuaEvents.ReligionFoundedEvent(founderID, iX, iY, eOldReligion, eNewReligion)
A LUA event that fires when a religion is founded.
Belief_FounderFreeBuildingClassCapital: <BeliefType, BuildingClassType>
A table that will grant the building to the player's capital if they have the founder belief. If their capital moves (due to conquest) than the building automatically moves.
Each snippet depend on the snippets above it. Meaning you must use "CityAdoptsReligionEvent" for either of the other snippets to work. And you must be using "ReligionFoundedEvent" for the Belief_FounderFreeBuildingClassCapital table to work.
Religions grant buildings (G&K, BNW)
Workshop
CivFanatics Download
This mod contains code that defines a new XML tables. By adding entries to these tables mod makers can have Religions (not beliefs) grant buildings in cities.
Religion_FreeBuildingClass: <ReligionType, BuildingClass>
When this religion becomes the majority in a city, the city will be granted this building. If the religion stops being the majority the building is removed.
Buildings require empire resources (Vanilla, G&K, BNW)
Workshop
CivFanatics Download
This mod contains code that defines two new XML tables. By adding entries to these tables mod makers can have Buildings that can only be built if the player has access to resources somewhere in their empire. Unlike the "Building_LocalResource" tables the resources do not have to be within the city's limits. Unlike "Building_ResourceQuantityRequirements" the resource is not consumed.
Workshop location of the whole collection.
Unit Created Event (Vanilla, G&K, BNW)
Workshop
CivFanatics Download
This mod contains code that defines a lua event that fires off when a unit is created. The event does not fire when a unit is upgraded. The lua event provides the information you need to get the owning player object and the unit object.
Building Created Event (Vanilla, G&K, BNW)
Workshop
CivFanatics Download
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.
Policies grant buildings (Vanilla, G&K, BNW)
Workshop
CivFanatics Download
This mod contains code that defines three new XML tables. By adding entries to these tables mod makers can have Social Policies grant buildings in cities.
Policy_PGB_FreeBuildingClass: <PolicyType, BuildingClass>
The building will be granted to every city.
Policy_PGB_FreeBuildingClassCapital: <PolicyType, BuildingClass>
The building will be granted to only the capital. If the capital moves (due to conquest) the building automatically moves.
Policy_PGB_FreeBuildingClassCityStates: <PolicyType, BuildingClassType>
The building will be granted to captured city-states.
Religion snippets (G&K, BNW)
Workshop
CivFanatics Download
This mod contains code that defines two lua events and a new XML table:
LuaEvents.CityAdoptsReligionEvent(iOwner, iX, iY, eOldReligion, eNewReligion, bFirstConversion)
A LUA event that fires when a city adopts a religion.
LuaEvents.ReligionFoundedEvent(founderID, iX, iY, eOldReligion, eNewReligion)
A LUA event that fires when a religion is founded.
Belief_FounderFreeBuildingClassCapital: <BeliefType, BuildingClassType>
A table that will grant the building to the player's capital if they have the founder belief. If their capital moves (due to conquest) than the building automatically moves.
Each snippet depend on the snippets above it. Meaning you must use "CityAdoptsReligionEvent" for either of the other snippets to work. And you must be using "ReligionFoundedEvent" for the Belief_FounderFreeBuildingClassCapital table to work.
Religions grant buildings (G&K, BNW)
Workshop
CivFanatics Download
This mod contains code that defines a new XML tables. By adding entries to these tables mod makers can have Religions (not beliefs) grant buildings in cities.
Religion_FreeBuildingClass: <ReligionType, BuildingClass>
When this religion becomes the majority in a city, the city will be granted this building. If the religion stops being the majority the building is removed.
Buildings require empire resources (Vanilla, G&K, BNW)
Workshop
CivFanatics Download
This mod contains code that defines two new XML tables. By adding entries to these tables mod makers can have Buildings that can only be built if the player has access to resources somewhere in their empire. Unlike the "Building_LocalResource" tables the resources do not have to be within the city's limits. Unlike "Building_ResourceQuantityRequirements" the resource is not consumed.