JDHalfrack
Chieftain
- Joined
- Mar 18, 2009
- Messages
- 35
I'm curious how you made the UB part work. Did you change the UB for the civilization? Depending on how you did it, it could be possible to allow the player to build any type of the ones they have available. You'd need to ensure they don't build 2 of the same class, but that's not hard.
You may be right. In order to do this, I created a function in the CVInfos file like this:
Code:
[COLOR="Green"]/**************************************************************************************************/
/** MOD: Trade Unique Buildings **/
/** Author: JDHalfrack **/
/** Created: 4/02/09 **/
/** Moddified: N/A **/
/** Code Effect: **/
/**************************************************************************************************/
/** CODE START **/[/COLOR]
void CvCivilizationInfo::setCivilizationBuilding(int iOriginalBuildingClass, int iNewBuilding)
{
FAssertMsg(iOriginalBuildingClass < GC.getNumBuildingClassInfos(), "Index out of bounds");
FAssertMsg(iOriginalBuildingClass > -1, "Index out of bounds");
FAssertMsg(iNewBuilding < GC.getNumBuildingInfos(), "Index out of bounds");
FAssertMsg(iNewBuilding > -1, "Index out of bounds");
m_piCivilizationBuildings[iOriginalBuildingClass] = iNewBuilding;
}
[COLOR="green"]/** CODE END **/
/**************************************************************************************************/[/COLOR]
Basically, the way I understand it, each building has a unique integer "ID" number associated to it. These ID numbers are created at the MOD loading time instead of being permanent because there are can be infinitely many buildings based on the user's specifications. However, these buildings must fall into a BuildingClassType.
The BuildingClassTypes are also assigned unique integer IDs at the MOD loading time because users can also create as many BuildingClasstypes as they desire.
The way the game works is that when the MOD loads, it creates an array called m_piCivilizationBuildings. This array contains GC.getNumBuildingClassInfos() elements. GC.getNumBuildingClassInfos() returns the number of different BuildingClassTypes.
So, let's say there are 20 different BuildingClassTypes: BUILDINGCLASS_PALACE, BUILDINGCLASS_WALLS, BUILDINGCLASS_BARRACKS, etc.... Now, when the MOD loads, it creates an array for each civilization that would contain 20 elements in it. Then, it finds the default building for each BuildingClassType. So, for BUILDINGCLASS_WALLS it would find "BUILDING_WALLS" instead of "BUILDING_CELTIC_DUN." Well, if BUILDINGCLASS_WALLS has been assigned the ID of "1" and BUILDING_WALLS has the unique ID of 12, and BUILDING_CELTIC_DUN has the unique ID of 13. The game assigns the value of 12 to m_piCivilizationBuildings[1]. Well, if you are the Celts, it wouldn't assign 12 to m_piCivilizationBuildings[1], instead it would assign 13.
So, the problem is that you can't really assign more than one building that uses the same BuildingClassType because it has to (and I mean it MUST) overwrite the previous value. The only way it may work is to dynamically create a new BuildingClassType when a trade is completed and increase the sixe of m_piCivilizationBuildings by one and assign the new building to it. But I really doubt that would work the way it sounds.
Anyway, does that all make sense?
JD