1. We have added a Gift Upgrades feature that allows you to gift an account upgrade to another member, just in time for the holiday season. You can see the gift option when going to the Account Upgrades screen, or on any user profile screen.
    Dismiss Notice

Power Up Mod

Discussion in 'Civ4 - Mod Components' started by Asaf, Sep 20, 2010.

  1. Asaf

    Asaf Sleep Deprived

    Joined:
    Mar 22, 2010
    Messages:
    1,326
    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.
     
  2. Voyhkah

    Voyhkah Political Activist

    Joined:
    Apr 25, 2009
    Messages:
    1,444
    Location:
    Earth
    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.
     
  3. Asaf

    Asaf Sleep Deprived

    Joined:
    Mar 22, 2010
    Messages:
    1,326
    I think missionaries currently don't have a combat type, so you'd need to make some modifications.
     
  4. Voyhkah

    Voyhkah Political Activist

    Joined:
    Apr 25, 2009
    Messages:
    1,444
    Location:
    Earth
    Maybe I could add 'UNITCOMBAT_MISSIONARY'?
     
  5. Asaf

    Asaf Sleep Deprived

    Joined:
    Mar 22, 2010
    Messages:
    1,326
    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.
     
  6. Voyhkah

    Voyhkah Political Activist

    Joined:
    Apr 25, 2009
    Messages:
    1,444
    Location:
    Earth
    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?
     
  7. Asaf

    Asaf Sleep Deprived

    Joined:
    Mar 22, 2010
    Messages:
    1,326
    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...
     
  8. Voyhkah

    Voyhkah Political Activist

    Joined:
    Apr 25, 2009
    Messages:
    1,444
    Location:
    Earth
    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?
     
  9. Asaf

    Asaf Sleep Deprived

    Joined:
    Mar 22, 2010
    Messages:
    1,326
    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);
    					}
    				}
    			}
    		}
    	}
    
     
  10. Voyhkah

    Voyhkah Political Activist

    Joined:
    Apr 25, 2009
    Messages:
    1,444
    Location:
    Earth
    At this point I am completely own my own thing. These building promotions rely too much on UnitCombat.
     
  11. Voyhkah

    Voyhkah Political Activist

    Joined:
    Apr 25, 2009
    Messages:
    1,444
    Location:
    Earth
    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.
     
  12. Asaf

    Asaf Sleep Deprived

    Joined:
    Mar 22, 2010
    Messages:
    1,326
    Whatever works for you :)
     
  13. Voyhkah

    Voyhkah Political Activist

    Joined:
    Apr 25, 2009
    Messages:
    1,444
    Location:
    Earth
    I appreciate your understanding.
     
  14. Arian

    Arian No more ghostbusting!!

    Joined:
    May 10, 2008
    Messages:
    2,088
    Location:
    The Netherlands
    Is this modcomp finished?
     
  15. Asaf

    Asaf Sleep Deprived

    Joined:
    Mar 22, 2010
    Messages:
    1,326
    Is it working? Yes. Do I intend to continue working on it? Not really.
    So yes, it's finished.
     
  16. Arian

    Arian No more ghostbusting!!

    Joined:
    May 10, 2008
    Messages:
    2,088
    Location:
    The Netherlands
    OK, thanks. I see you included all source files. I assume only source files dated 20/9/2010 are relevant (the ones containing 'Added for Power Up Mod') ?
    Anyway very nice mod :goodjob:
     
  17. Asaf

    Asaf Sleep Deprived

    Joined:
    Mar 22, 2010
    Messages:
    1,326
    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.
     
  18. Arian

    Arian No more ghostbusting!!

    Joined:
    May 10, 2008
    Messages:
    2,088
    Location:
    The Netherlands
    OK. In post 13 you've attached 'assets' which seems to be marked properly :)
     
  19. Arian

    Arian No more ghostbusting!!

    Joined:
    May 10, 2008
    Messages:
    2,088
    Location:
    The Netherlands
    @Asaf: are you gonna make a BUG-compatible of this mod? Would be nice :)
     
  20. Asaf

    Asaf Sleep Deprived

    Joined:
    Mar 22, 2010
    Messages:
    1,326
    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.
     

Share This Page