Kailric
Jack of All Trades
When you create a lot of new Professions the game can get confused about which Unit to display in the Professions Pedia, and so this little modcomp aims to fix that. The problem stems from the fact that Professions don't have a Graphic of their own but rather they must be attached to a unit. I'll explain how the Vanilla CVProfessionsPedia.py works below as well. But first I'll explain my additions:
DOWNLOAD V 0.3
I have added a few new tags to the XML that you can use to help sort out the professions. Both the CvProfessionsInfo.xml and the CvUnitInfos.xml have been modified as the following code shows:
Note the new Tags do not have to be present in the XML and so you have to add them in and I could not get the spaceing right in the below examples.
New Tags Explained:
<ArtTagUnitClass> What ever Unit you want to display the Profession simply add in the UnitClass between those tags or you can put "NONE" in between the tags to work as default.
The problem with this is it only works if the Unit has its own unique Class. So for example, for the Natives they are just unqiue units so they don't have a class of their own so this tag does no good for them.
<bNativesInvalid>0</bNativesInvalid>
<bEuropeInvalid>0</bEuropeInvalid>
<bColonialInvalid>0</bColonialInvalid>
The above tags work the same for both CvUnit and CvProfessions. And are used for example, if you create a Unit or Profession and do not want the Natives to use it simply add in the Tag for bNativesInvalid and set it to 1. Not only will the Natives not use the Unit or Professions in the Pedia but they will not use the Unit or Profession while in the game. This removes the need to edit the CvCivilizatioinInfos to allow or disallow Units and Professions.
I also added in a little Extra for the Fun of it. With this mod if you have a Veteran Unit or some kind of Elite unit like the Seasoned scout and a normal Unit Both units will be displayed in the Professions Pedia so you can see what your units will look like as either. See the Screen shots below:
Explanation of the Vanilla Python Code:
First it makes several checks to find a Unit Graphic suitable for the Profession. The code stops and selects the first unit that completes the check:
1. It checks to see if any Unit has the Profession as Default Profession
2. It checks if the Profession produces a Yield then it searches for a Unit that has the Highest bonus to that yield
3. It checks if there is a Combat change with this Profession if so it searches for the Unit with the most number of Free Promotions, by defualt this is the Veteran Unit.
4. If the Profession is Student it then searches for the Unit with the highest Student Weight, by defualt this is the Free Colonist.
If a Unit is found the Unit will aquire the Profession and that graphic will be displayed. If no unit is found no unit will be shown.
Example 1:
I created a new unit called Explorer. The Code runs through all the Civilizations starting with England. If it finds a Civilization that allows the Unit it choses that Civilization to select the Units from as you have to have a unit to attach to the displayed Profession. It this case it finds England. After it finds a Civilization it then runs through the list of that Civilizations Units checking for the one unit with the Highest number of Free Promotions, which in England's case will be the Veteran Unit. The code then gets a Veteran Unit from England and gives it the Explorer Profession.
Now you will have errors if Veteran Unit does not have an art file assigned for Explorer.
Example 2:
Ok, now we are Looking for a unit to display the "Mounted Brave" Profession. As before the code checks to see if there is a valid Civilization which will be the first Civilization it comes to that allows this profession namely, "CIVILIZATION_TUPI". If then runs through the list of all the Units that the Tupi's can have. In our above example if the Explorer had more Free Promotions than the UNIT_NATIVE (the only unit a native is allowed to have basically) or the Explorer is the last Unit it checks then the Explorer unit will be the Unit the Code selects. In this case it will cause an error cause the Explorer unit has no Mounted Brave profession art assigned to it.
In order to fix this you have to make it so that the Explorer either has Mounted Brave art assigned to it or you make it so the Natives can not use the Explorer.
If your New Profession is not displayed correctly under the default code, you can use this mod to fix that.
~Cheers
DOWNLOAD V 0.3
I have added a few new tags to the XML that you can use to help sort out the professions. Both the CvProfessionsInfo.xml and the CvUnitInfos.xml have been modified as the following code shows:
Note the new Tags do not have to be present in the XML and so you have to add them in and I could not get the spaceing right in the below examples.
Code:
<ProfessionInfo>
<Type>PROFESSION_FARMER</Type>
<Description>TXT_KEY_PROFESSION_FARMER</Description>
<Civilopedia>TXT_KEY_UNIT_FARMER_PEDIA</Civilopedia>
<Strategy>TXT_KEY_PROFESSION_FARMER_STRATEGY</Strategy>
<Help/>
[B]<bNativesInvalid>0</bNativesInvalid>[/B]
[B] <bEuropeInvalid>0</bEuropeInvalid>[/B]
[B] <bColonialInvalid>0</bColonialInvalid>[/B]
[B] <ArtTagUnitClass>NONE</ArtTagUnitClass>[/B]
<Combat>NONE</Combat>
Code:
<UnitInfo>
<Type>UNIT_COLONIST</Type>
<Class>UNITCLASS_COLONIST</Class>
<UniqueNames/>
<Special>NONE</Special>
<Capture>NONE</Capture>
<Combat>NONE</Combat>
<Domain>DOMAIN_LAND</Domain>
<DefaultUnitAI>UNITAI_COLONIST</DefaultUnit>
<DefaultProfession>PROFESSION_COLONIST</DefaultProfession>
[B] <bNativesInvalid>0</bNativesInvalid>[/B]
[B]<bEuropeInvalid>0</bEuropeInvalid>[/B]
[B]<bColonialInvalid>0</bColonialInvalid>[/B]
<Invisible>NONE</Invisible>
New Tags Explained:
<ArtTagUnitClass> What ever Unit you want to display the Profession simply add in the UnitClass between those tags or you can put "NONE" in between the tags to work as default.
The problem with this is it only works if the Unit has its own unique Class. So for example, for the Natives they are just unqiue units so they don't have a class of their own so this tag does no good for them.
<bNativesInvalid>0</bNativesInvalid>
<bEuropeInvalid>0</bEuropeInvalid>
<bColonialInvalid>0</bColonialInvalid>
The above tags work the same for both CvUnit and CvProfessions. And are used for example, if you create a Unit or Profession and do not want the Natives to use it simply add in the Tag for bNativesInvalid and set it to 1. Not only will the Natives not use the Unit or Professions in the Pedia but they will not use the Unit or Profession while in the game. This removes the need to edit the CvCivilizatioinInfos to allow or disallow Units and Professions.
I also added in a little Extra for the Fun of it. With this mod if you have a Veteran Unit or some kind of Elite unit like the Seasoned scout and a normal Unit Both units will be displayed in the Professions Pedia so you can see what your units will look like as either. See the Screen shots below:
Explanation of the Vanilla Python Code:
First it makes several checks to find a Unit Graphic suitable for the Profession. The code stops and selects the first unit that completes the check:
1. It checks to see if any Unit has the Profession as Default Profession
2. It checks if the Profession produces a Yield then it searches for a Unit that has the Highest bonus to that yield
3. It checks if there is a Combat change with this Profession if so it searches for the Unit with the most number of Free Promotions, by defualt this is the Veteran Unit.
4. If the Profession is Student it then searches for the Unit with the highest Student Weight, by defualt this is the Free Colonist.
If a Unit is found the Unit will aquire the Profession and that graphic will be displayed. If no unit is found no unit will be shown.
Example 1:
I created a new unit called Explorer. The Code runs through all the Civilizations starting with England. If it finds a Civilization that allows the Unit it choses that Civilization to select the Units from as you have to have a unit to attach to the displayed Profession. It this case it finds England. After it finds a Civilization it then runs through the list of that Civilizations Units checking for the one unit with the Highest number of Free Promotions, which in England's case will be the Veteran Unit. The code then gets a Veteran Unit from England and gives it the Explorer Profession.
Now you will have errors if Veteran Unit does not have an art file assigned for Explorer.
Example 2:
Ok, now we are Looking for a unit to display the "Mounted Brave" Profession. As before the code checks to see if there is a valid Civilization which will be the first Civilization it comes to that allows this profession namely, "CIVILIZATION_TUPI". If then runs through the list of all the Units that the Tupi's can have. In our above example if the Explorer had more Free Promotions than the UNIT_NATIVE (the only unit a native is allowed to have basically) or the Explorer is the last Unit it checks then the Explorer unit will be the Unit the Code selects. In this case it will cause an error cause the Explorer unit has no Mounted Brave profession art assigned to it.
In order to fix this you have to make it so that the Explorer either has Mounted Brave art assigned to it or you make it so the Natives can not use the Explorer.
If your New Profession is not displayed correctly under the default code, you can use this mod to fix that.
~Cheers