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
    Power Up Mod
    (version 0.1)

    Download here.

    The Power Up Mod allows some buildings to gain experience for units of specific categories created in their city, and translate this experience to promotions which will be given to units of this category trained in this city from this point on.

    For example:
    The city of Rome builds a barracks. After the barracks is built, each melee unit you train in Rome (and therefore - in this barracks) gives more experience to the commanders, teachers and trainers in this barracks.
    Once Rome trains 5 melee units (which can be of different types, e.g. warriors, spearmen, axemen), a promotion opens up for the barracks for melee units.
    The player can then promote the barracks to any of the available promotions (depending on traits, civics, techs, other free promotions in this city etc.). This promotion costs gold.
    Once the building was promoted, any melee unit trained in Rome will automatically receive this promotion.

    I also added two new promotions: Mentor I and Mentor II.
    These promotions are special because they cannot be given to units, only to buildings. Each of these promotions, when gained by a building, gives a production bonus modifier for training units of the relevant category in the building's city. This promotion is not given to the units trained in the city.

    Some screen shots:
    Spoiler :













    Readme file:
    Spoiler :

    Note:
    =====
    Currently the Custom Assets are disabled for this Mod, since it is not compatible with BUG.
    Hopefully this will be resolved in future versions.

    Introduction:
    =============
    The Power Up Mod allows some buildings to gain experience for units of specific categories created in their city, and translate this experience to promotions which will be given to units of this category trained in this city.

    For example:
    The city of Rome builds a barracks. After the barracks is built, each melee unit you train in Rome (and therefore - in this barracks) gives more experience to the commanders, teachers and trainers in this barracks.
    Once Rome trains 5 melee units (which can be of different types, e.g. warriors, spearmen, axemen), a promotion opens up for the barracks for melee units.
    The player can then promote the barracks to any of the available promotions (depending on traits, civics, techs, other free promotions in this city etc.). This promotion costs gold.
    Once the building was promoted, any melee unit trained in Rome will automatically receive this promotion.

    In the game this property is defined as "the barracks gains promotions for melee units". It also gains promotions for archery and gunpowder units, but you need to train those as well to gain the experience required.

    Installation:
    =============
    Open the zip into your BTS's Mods folder. You will then have the Power Up Mod in the 'Load a Mod' menu.

    How to use it in game:
    ======================
    You can see whether a building gains promotions for a unit category either in the Civilopedia or in the building's tool tip.

    When the building gains experience, you can see it in the building's tool tip when hovering over it in the buildings list in the city screen.

    When a building has gained enough experience to gain a promotion, it will be marked in the buildings list in the city screen with a '+' sign next to it, and in a different color. You can than click on it to promote it.

    If more than one category can gain promotions (e.g., melee and archery) you will get a popup in which you can choose the unit category to promote. You will also get this dialog if you don't have enough gold to promote the building. Too expensive unit categories will be disabled in the popup.

    Once you select a category for which you have enough gold, a popup will appear in which you can choose the promotion. Selecting a promotion will add this promotion to the building. You can see the promotions the building has in the tool tip when hovering over it in the city's buildings list. The promotions the building has will be added to units of the correct category which will be trained in this city.

    Two new promotions have been added: Mentor I and Mentor II. These promotions are special because they cannot be given to units, only to buildings. Each of these promotions, when gained by a building, gives a production bonus modifier for training units if the relevant category in the building's city. This promotion is not given to the units trained in the city.

    A few notes:
    ============
    * The number of units required to gain each promotion for a building per unit category is: 5, 15, 30, 50, 80, 120, 200. After that each level adds 100 to the number of required units.

    * This number is affected by the charismatic trait. As in units XP, the required number of units for a charismatic leader is 25% less (4, 12, ...).

    * The cost in gold for each promotion level per building per unit category is <number of required units> x 5. It means that charismatic leaders also get a discount here.

    * More than one building may gain promotions for a specific unit category (e.g., both barracks and walls gain promotions for archery units). When both are built in a city, a trained unit only adds to the experience of one building - the one closest to the next promotion. The numbers of units and gold cost required for a new promotion is counted separately for each building, so you can get 2 promotions for just 10 units and 50 gold. The promotions themselves, however, are shared between the building. So you can gain Combat I in one building, and then Combat II in the 2nd building, and a trained unit will get both.

    * If a city with buildings which gain promotions switches hands to another civ - either because it was taken by force or gifted - the promotions can still be salvaged. However, you better hurry up, since the experience each buliding has gained decays and will be completely wiped in 40 turns (because of rounding down issues, it could be less). Promotions will also disappear in the opposite order they were gained if the building remaining experience is not enough to gain them in the first place.

    * If a building was destroyed when the city was lost, its promotions are not lost. When the city is recaptured, the remaining experience and promotions (after the decay) can be restored by re-building the building. You can see the current status in the building's tool tip in the build buttons in the city screen.

    * An obsolete building does not gain expereience or new promotions. The old gained promotions are still valid, though (assuming you can still train the matching unit category!).

    Full list of promotions-gaining buildings:
    ==========================================
    * Barracks / Ikhanda - Melee units, Archery units, Gunpowder units
    * Walls / Dun - Archery units
    * Stable / Ger - Mounted units
    * Castle / Citadel - Siege units
    * Dry Dock - Naval units
    * Airport - Air units
    * Factory / Assembly plant - Armored units

    Notes to Modders:
    =================
    * To change which buildings gain promotions for which unit categories, look at CIV4BuildingInfos.xml. Look for the UnitCombatGainPromotionsList tag to see samples. Note that the position of this node matters! it must come after DomainProductionModifiers.

    * Although I didn't do it, unique buildings can gain promotions even if their common counter-part does not.

    * To control the number of units required for gaining a promotion or its cost in gold, check out CvGameUtils.py, in the methods getNumUnitsNeededForBuildingPromotion() and getGoldCostForBuildingPromotion().

    * To control the decay rate of buildings in conquered cities, look at GlobalDefines.xml. The variable 'POWER_UP_BUILDING_PROMOTIONS_DECAY_TURNS' can be either negative (no decay at all), 0 (immediate full reset of buildings experience and promotions) or positive.

    * For any other stuff - look at the SDK source code. Look for the 'Power Up Mod' comment (hopefully I didn't miss anything).

    TODO:
    =====
    * Add a BUG-compatible version
    * Improve AI: A smarter choice of building promotions (currently chooses randomly)

    Credits:
    ========
    DannyDaemonic - the fast Makefile (1.0). Downloaded from: http://forums.civfanatics.com/showthread.php?t=370861
     
  2. keldath

    keldath LivE LonG AnD PrOsPeR

    Joined:
    Dec 20, 2005
    Messages:
    6,297
    Location:
    israel
    very nice,

    &#1493;&#1502;&#1490;&#1504;&#1497;&#1489;!
     
  3. The_J

    The_J Say No 2 Net Validations Retired Moderator Supporter

    Joined:
    Oct 22, 2008
    Messages:
    30,807
    Location:
    Germany / Netherlands
    Oh, that's cool :goodjob:.
    Might maybe be imbalanced, but well, that doesn't decrease the coolness :D.
     
  4. smeagolheart

    smeagolheart Monarch

    Joined:
    Sep 4, 2007
    Messages:
    924
    Location:
    Phoenix, AZ
    sounds like modding your Civ into Age of Empires or Warcraft. The RTS games like that often had these upgradeable buildings.
     
  5. Asaf

    Asaf Sleep Deprived

    Joined:
    Mar 22, 2010
    Messages:
    1,326
    Thanks, &#1493;&#1514;&#1493;&#1491;&#1492;.
    I intend to (sometime in the future) improve the AI to make it a bit more balanced, but it's mainly fun :)
     
  6. Kid R

    Kid R Chieftain

    Joined:
    Jan 26, 2009
    Messages:
    1,482
    Excellent! Very elegantly done, and the upgrade costs and trigger points seem to be well measured. I'll play my next few games with it turned on and see how it goes :goodjob:
     
  7. Voyhkah

    Voyhkah Political Activist

    Joined:
    Apr 25, 2009
    Messages:
    1,444
    Location:
    Earth
    I am TOTALLY using this! Do you mind if I make a few changes of my own in my mod?
     
  8. Asaf

    Asaf Sleep Deprived

    Joined:
    Mar 22, 2010
    Messages:
    1,326
    No problem. What kind of changes?
     
  9. Voyhkah

    Voyhkah Political Activist

    Joined:
    Apr 25, 2009
    Messages:
    1,444
    Location:
    Earth
    You said that building promotions could only effect the production speeds of units. I might change that, give promotions to units based on building promotions. I am also reworking the promotions, making all new ones. Maybe some other stuff. Don't worry, I'll credit you!
     
  10. Asaf

    Asaf Sleep Deprived

    Joined:
    Mar 22, 2010
    Messages:
    1,326
    Ummm, thanks, but the main idea is already that building promotions give promotions to units...
    There are 2 promotions which instead increase the production speed, but generally it does give promotions to units.
     
  11. Voyhkah

    Voyhkah Political Activist

    Joined:
    Apr 25, 2009
    Messages:
    1,444
    Location:
    Earth
    Oh, I thought you sad that they all increased production speed. Sorry 'bout that...
     
  12. Voyhkah

    Voyhkah Political Activist

    Joined:
    Apr 25, 2009
    Messages:
    1,444
    Location:
    Earth
    I am trying to merge Power Up with World of Pokiphlanon, but the python file CvMainInterface.py is giving me trouble. I am using BUG in my mod, so I'm trying to merge the Power Up file with the BUG file. Only thing is, you're changes aren't marked. Where are they?
     
  13. Asaf

    Asaf Sleep Deprived

    Joined:
    Mar 22, 2010
    Messages:
    1,326
    I already merged it with BUG, only I never uploaded it...

    Attached are the updated Python files (with comments ;) ), and I also moved the text XML to its own file.

    I also suggest reducing the Mentor-1 to +25% production (instead of +50%). I did it locally, but didn't upload it. Your choice.

    Let me know if it works.
     

    Attached Files:

  14. Voyhkah

    Voyhkah Political Activist

    Joined:
    Apr 25, 2009
    Messages:
    1,444
    Location:
    Earth
    I can't find the code for building promotions giving promotions to units.
     
  15. Asaf

    Asaf Sleep Deprived

    Joined:
    Mar 22, 2010
    Messages:
    1,326
    Yeah... I know I didn't mark the code properly in these files (it was my first mod. I've improved since!)

    Anyway - take a look at CvCity::addProductionExperience():
    Spoiler :

    Code:
    	////////////////////////////
    	// Added for Power Up Mod //
    	////////////////////////////
    	// Conscript units are ignored for gained promotions
    	if (!bConscript && pUnit->getUnitCombatType() != NO_UNITCOMBAT)
    	{
    		// Unit can be counted for gained promotions
    		updatePromotionsGainingBuildingExperience(pUnit->getUnitCombatType());
    
    		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;
    
    				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];
    
    						// 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.
    [B]						if (pUnit->isPromotionValid(ePromotion))
    							pUnit->setHasPromotion(ePromotion, true);
    [/B]					}
    				}
    			}
    		}
    	}
    
     
  16. Voyhkah

    Voyhkah Political Activist

    Joined:
    Apr 25, 2009
    Messages:
    1,444
    Location:
    Earth
    It is marked.

    But there's no XML tag for building promotions giving promotions to units.
     
  17. Asaf

    Asaf Sleep Deprived

    Joined:
    Mar 22, 2010
    Messages:
    1,326
    The buildings don't give specific promotions to units. The player 'buys' them and chooses them as it upgrades the building when the building gains enough 'experience' for the unit category (combat type).
     
  18. Voyhkah

    Voyhkah Political Activist

    Joined:
    Apr 25, 2009
    Messages:
    1,444
    Location:
    Earth
    I didn't understand that.
     
  19. Asaf

    Asaf Sleep Deprived

    Joined:
    Mar 22, 2010
    Messages:
    1,326
    Read the example in the opening post, and let me know what's not clear.
     
  20. Voyhkah

    Voyhkah Political Activist

    Joined:
    Apr 25, 2009
    Messages:
    1,444
    Location:
    Earth
    Aaaahhhhh!! I understand now! You give the buildings unit promotions, then the units get the promotions. But what if you gave the barracks the Drill promotion? Melee units can't normally get drill. What would happen?
     

Share This Page