Power Up Mod

The barracks gets promotions for each category separately. And it can't get drill for melee :)
Specifically the barracks can gain promotions for melee, archery and gunpowder units (you can edit this in the XML) - separately for each category. Other buildings might only gain promotions for a single category type.
The available promotions depend on the category, your techs, traits, their prereq promotions etc.
For example:
You can give your archery units drill I, and only then you can give them drill II, but if you have a protective leader - you can immediately give Drill II.
 
Hm.

I was thinking about making monasteries get promotions. For example, once a city with a Jewish Monastery trains 10 Jewish Missionaries, it can be promoted to Mission I, which is then recieved by all missionaries trained in the city.

Footnote: Mission I would give the missionaries increased effectiveness when spreading religion, per my Advanced Religion feature.
 
Maybe I could add 'UNITCOMBAT_MISSIONARY'?
 
Maybe I could add 'UNITCOMBAT_MISSIONARY'?

Yes, I was thinking the same thing. But there might be other implications for this - I think there are places in the code where it checks if a unit is a military unit by checking if its combat type is none.
 
Maybe some sort of boolean isMissionary tag in UnitInfos and a isMissionaryOnly tag in PromotionInfos? I could then modify CvUnit::canAcquirePromotion (Yes, this is the one that doesn't check for experiance) to allow units with isMissionary set to true to aquire only isMissionaryOnly promotions. What do you think?
 
Seems reasonable. But the current code gains promotions for each category, so you might still need to manually add a 'missionary category' to that code.
Can a non-military unit currently get promotions?

I did something remotely similar with 'building only' promotions, so it might help you for at least some of the code...
 
Hm, in one of your changes, you note:
Code:
// We use isPromotionValid() and not canAcquirePromotion() since this might cause pre-reqs problems,
						// as it depends on the order of the promotions.
						// Note that it might create issues with state religion depenent promotions, 
						// but since these don't exist in BTS, I think we're good.

*Cringe* Adding religion promotions is something I'm considering...

Ok, I don't really understand the code in addProductionExperience. How and where does it check for buildings having promotions?
 
It's in the same code I attached before.
I'll try breaking it down a little:

You will need to change this if missionaries are not getting a combat type of their own:
Code:
	// Conscript units are ignored for gained promotions
	if (!bConscript && pUnit->getUnitCombatType() != NO_UNITCOMBAT)
	{

This line updates the buildings experience, and checks whether the building can be further promoted:
Code:
		// Unit can be counted for gained promotions
		updatePromotionsGainingBuildingExperience(pUnit->getUnitCombatType());

If the unit can receive any promotions, go over all the promotable buildings and check if they exist:
Code:
		if (bUnitCanAcquirePromotionAny)
		{
			UnitCombatTypes eCombatType = pUnit->getUnitCombatType();
			
			PlayerPromotableBuildingsVector& promotableBuildings = GetOwnerBuildingsGainedPromotions();

			// Unit can receive gained promotions
			for (unsigned int iPromotableBuilding = 0; iPromotableBuilding < promotableBuildings.size(); ++iPromotableBuilding)
			{
				if (getNumBuilding(promotableBuildings[iPromotableBuilding].m_eBuilding) == 0)
					continue;

Check the gained promotions of the building for the specific unit's combat type. If there are gained promotions - go over them:
Code:
				BuildingCombatTypeGainedPromotions& kPromotions = promotableBuildings[iPromotableBuilding].m_aCombatTypes[(int)eCombatType];
				if (kPromotions.m_bCombatTypeGainsPromotion)
				{
					int nGainedPromotion = kPromotions.getNumGainedPromotions();

					for (int iGainedPromotion = 0; iGainedPromotion < nGainedPromotion; ++iGainedPromotion)
					{
						PromotionTypes ePromotion = kPromotions.m_aGainedPromotionsOrdered[iGainedPromotion];

If the unit can receive the specific promotion, set it for the unit.
If you want to add state religion dependent promotions, copy the check from canAcquirePromotion() to here:
Code:
						// We use isPromotionValid() and not canAcquirePromotion() since this might cause pre-reqs problems,
						// as it depends on the order of the promotions.
						// Note that it might create issues with state religion dependent promotions, 
						// but since these don't exist in BTS, I think we're good.
						if (pUnit->isPromotionValid(ePromotion))
							pUnit->setHasPromotion(ePromotion, true);
					}
				}
			}
		}
	}
 
At this point I am completely own my own thing. These building promotions rely too much on UnitCombat.
 
Oh, god. I'm just going do the same thing differently. In other words, I'm going to make a class CvBuilding, then destroy/assimilate all your code to work for me. Sorry, I just think it would be simpler, easier, and would offer more freedom.
 
I appreciate your understanding.
 
Note that the Python code might not be marked properly (it was my first mod...) so you should probably compare it to the original Python files to find the differences.
 
I thought the Python files I uploaded in post 13 were already BUG compatible... or were they?

I have them on my not-yet-connected-because-of-moving PC. I'll upload them after I have it set up.
 
Top Bottom