Unique Unit Strength increase per era

Boyzilla

Chieftain
Joined
Aug 3, 2015
Messages
3
Location
United States
Dear, Fellow Modders

I am the mod maker of the recently DBZ Civilizations that made themselves known on the Steam Workshop. Anyhow, I got a couple of questions that I really need help with concerning a few elements of my Unique Units.

So, in my DBZ Earthlings Civilization, I had initially wanted the Great General replacement, the Z-fighters, have a starting Combat strength of 15, and then increase said strength for every time the Civilization would enter a new era.

Now, I had made the Great General be able to have combat and all, the AI successfully using it as a unit for defensive combat purposes with Great General caution. (As to avoid the AI simply charging the Z-fighter into the fray without seeing the consequences, though I can never give it a unique model, as I suck as modeling.)

While my substitute has it has 25 Strength atm, the Great General becomes pretty useless when reaching late-medieval Era. I know only a fair amount XML, but nothing about SQL. So I was wondering if its possible to increase a unique units combat strength with some sort of XML code for each new era that the civilization enters?

Thanks,
Boyzilla
 
Actually, Leugi's Cuban mod does something similar for the War General unique unit, via a combination of XML and Lua. It doesn't change the combat stats by era, but rather by technology.

I've taken this straight out of his mod (I hope he doesn't mind, as long as you credit him).

The lua file is:
Code:
print("The War General Lua loaded succesfully")


local WGeneralPromotion = GameInfo.UnitPromotions["PROMOTION_WAR_GENERAL"].ID
local WGLevel0 = GameInfo.UnitPromotions["PROMOTION_WAR_GENERAL_0"].ID
local WGLevel1 = GameInfo.UnitPromotions["PROMOTION_WAR_GENERAL_1"].ID
local WGLevel2 = GameInfo.UnitPromotions["PROMOTION_WAR_GENERAL_2"].ID
local WGLevel3 = GameInfo.UnitPromotions["PROMOTION_WAR_GENERAL_3"].ID
local WGLevel4 = GameInfo.UnitPromotions["PROMOTION_WAR_GENERAL_4"].ID
local WGLevel5 = GameInfo.UnitPromotions["PROMOTION_WAR_GENERAL_5"].ID
local WGLevel6 = GameInfo.UnitPromotions["PROMOTION_WAR_GENERAL_6"].ID
local WGLevel7 = GameInfo.UnitPromotions["PROMOTION_WAR_GENERAL_7"].ID
local WGLevel8 = GameInfo.UnitPromotions["PROMOTION_WAR_GENERAL_8"].ID
local WGLevel9 = GameInfo.UnitPromotions["PROMOTION_WAR_GENERAL_9"].ID

local WGLevel1Prereq = GameInfo.Technologies["TECH_BRONZE_WORKING"].ID
local WGLevel2Prereq = GameInfo.Technologies["TECH_IRON_WORKING"].ID
local WGLevel3Prereq = GameInfo.Technologies["TECH_STEEL"].ID
local WGLevel4Prereq = GameInfo.Technologies["TECH_GUNPOWDER"].ID
local WGLevel5Prereq = GameInfo.Technologies["TECH_RIFLING"].ID
local WGLevel6Prereq = GameInfo.Technologies["TECH_REPLACEABLE_PARTS"].ID
local WGLevel7Prereq = GameInfo.Technologies["TECH_PLASTIC"].ID
local WGLevel8Prereq = GameInfo.Technologies["TECH_MOBILE_TACTICS"].ID
local WGLevel9Prereq = GameInfo.Technologies["TECH_NANOTECHNOLOGY"].ID

local WGLevel0Combat = 8
local WGLevel1Combat = 11
local WGLevel2Combat = 14
local WGLevel3Combat = 21
local WGLevel4Combat = 24
local WGLevel5Combat = 34
local WGLevel6Combat = 50
local WGLevel7Combat = 70
local WGLevel8Combat = 90
local WGLevel9Combat = 100


function WarGeneral(iPlayer)
	for _, pPlayer in pairs(Players) do
	local teamID = pPlayer:GetTeam();
	local pTeam = Teams[teamID];
	if (pPlayer:IsAlive()) then
		for bgunit in pPlayer:Units() do
			if (bgunit:IsHasPromotion(WGeneralPromotion)) then
				bgunit:SetHasPromotion(WGLevel0, true);
				bgunit:SetBaseCombatStrength(WGLevel0Combat)
				if (pTeam:IsHasTech(WGLevel1Prereq)) then
						bgunit:SetHasPromotion(WGLevel0, false);
						bgunit:SetHasPromotion(WGLevel1, true);
						bgunit:SetBaseCombatStrength(WGLevel1Combat)
						--print ("A War General Level 1 is here!");	
				end				
				if (pTeam:IsHasTech(WGLevel2Prereq)) then
						bgunit:SetHasPromotion(WGLevel1, false);
						bgunit:SetHasPromotion(WGLevel2, true);
						bgunit:SetBaseCombatStrength(WGLevel2Combat)
						--print ("A War General Level 2 is here!");
				end
				if (pTeam:IsHasTech(WGLevel3Prereq)) then		
						bgunit:SetHasPromotion(WGLevel2, false);
						bgunit:SetHasPromotion(WGLevel3, true);
						bgunit:SetBaseCombatStrength(WGLevel3Combat)
						--print ("A War General Level 3 is here!");
				end
				if (pTeam:IsHasTech(WGLevel4Prereq)) then		
						bgunit:SetHasPromotion(WGLevel3, false);
						bgunit:SetHasPromotion(WGLevel4, true);
						bgunit:SetBaseCombatStrength(WGLevel4Combat)
						--print ("A War General Level 4 is here!");
				end
				if (pTeam:IsHasTech(WGLevel5Prereq)) then		
						bgunit:SetHasPromotion(WGLevel4, false);
						bgunit:SetHasPromotion(WGLevel5, true);
						bgunit:SetBaseCombatStrength(WGLevel5Combat)
						--print ("A War General Level 5 is here!");
				end
				if (pTeam:IsHasTech(WGLevel6Prereq)) then		
						bgunit:SetHasPromotion(WGLevel5, false);
						bgunit:SetHasPromotion(WGLevel6, true);
						bgunit:SetBaseCombatStrength(WGLevel6Combat)
						--print ("A War General Level 6 is here!");
				end
				if (pTeam:IsHasTech(WGLevel7Prereq)) then		
						bgunit:SetHasPromotion(WGLevel6, false);
						bgunit:SetHasPromotion(WGLevel7, true);
						bgunit:SetBaseCombatStrength(WGLevel7Combat)
						--print ("A War General Level 7 is here!");
				end
				if (pTeam:IsHasTech(WGLevel8Prereq)) then		
						bgunit:SetHasPromotion(WGLevel7, false);
						bgunit:SetHasPromotion(WGLevel8, true);
						bgunit:SetBaseCombatStrength(WGLevel8Combat)
						--print ("A War General Level 8 is here!");
				end
				if (pTeam:IsHasTech(WGLevel9Prereq)) then		
						bgunit:SetHasPromotion(WGLevel8, false);
						bgunit:SetHasPromotion(WGLevel9, true);
						bgunit:SetBaseCombatStrength(WGLevel9Combat)
						--print ("A War General Level 9 is here!");
				end
			end
		end
	end
	end
end
Events.SerialEventUnitCreated.Add(WarGeneral);
GameEvents.PlayerAdoptPolicy.Add(WarGeneral);
GameEvents.PlayerDoTurn.Add(WarGeneral);

and the XML is
Code:
<GameData>
	<UnitPromotions>

		<Replace>
			<Type>PROMOTION_WAR_GENERAL</Type>
			<Description>TXT_KEY_PROMOTION_WAR_GENERAL</Description>
			<Help>TXT_KEY_PROMOTION_WAR_GENERAL_HELP</Help>
			<Sound>AS2D_IF_LEVELUP</Sound>
			<CannotBeChosen>true</CannotBeChosen>
			<LostWithUpgrade>true</LostWithUpgrade>
			<PortraitIndex>13</PortraitIndex>
			<IconAtlas>PROMOTION_ATLAS</IconAtlas>
			<!-- Penalties for Generals-->
			<NoCapture>true</NoCapture>
			<CityAttack>-33</CityAttack>
			<ExperiencePercent>-300</ExperiencePercent>
			<IgnoreGreatGeneralBenefit>true</IgnoreGreatGeneralBenefit>
			<HPHealedIfDestroyEnemy>-10</HPHealedIfDestroyEnemy>
			<!-- Penalties for Generals-->
			<PediaType>PEDIA_ATTRIBUTES</PediaType>
			<PediaEntry>TXT_KEY_PROMOTION_WAR_GENERAL</PediaEntry>
		</Replace>
		
		
		<Replace>
			<Type>PROMOTION_WAR_GENERAL_0</Type>
			<Description>TXT_KEY_PROMOTION_WAR_GENERAL_0</Description>
			<Help>TXT_KEY_PROMOTION_WAR_GENERAL_0_HELP</Help>
			<Sound>AS2D_IF_LEVELUP</Sound>
			<CannotBeChosen>true</CannotBeChosen>
			<LostWithUpgrade>true</LostWithUpgrade>
			<PortraitIndex>44</PortraitIndex>
			<IconAtlas>PROMOTION_ATLAS</IconAtlas>
			<PediaType>PEDIA_ATTRIBUTES</PediaType>
			<PediaEntry>TXT_KEY_PROMOTION_WAR_GENERAL_0</PediaEntry>
		</Replace>

		<Replace>
			<Type>PROMOTION_WAR_GENERAL_1</Type>
			<Description>TXT_KEY_PROMOTION_WAR_GENERAL_1</Description>
			<Help>TXT_KEY_PROMOTION_WAR_GENERAL_1_HELP</Help>
			<Sound>AS2D_IF_LEVELUP</Sound>
			<CannotBeChosen>true</CannotBeChosen>
			<LostWithUpgrade>true</LostWithUpgrade>
			<PortraitIndex>45</PortraitIndex>
			<IconAtlas>PROMOTION_ATLAS</IconAtlas>
			<PediaType>PEDIA_ATTRIBUTES</PediaType>
			<PediaEntry>TXT_KEY_PROMOTION_WAR_GENERAL_1</PediaEntry>
		</Replace>

		<Replace>
			<Type>PROMOTION_WAR_GENERAL_2</Type>
			<Description>TXT_KEY_PROMOTION_WAR_GENERAL_2</Description>
			<Help>TXT_KEY_PROMOTION_WAR_GENERAL_2_HELP</Help>
			<Sound>AS2D_IF_LEVELUP</Sound>
			<CannotBeChosen>true</CannotBeChosen>
			<LostWithUpgrade>true</LostWithUpgrade>
			<PortraitIndex>46</PortraitIndex>
			<IconAtlas>PROMOTION_ATLAS</IconAtlas>
			<PediaType>PEDIA_ATTRIBUTES</PediaType>
			<PediaEntry>TXT_KEY_PROMOTION_WAR_GENERAL_2</PediaEntry>
		</Replace>

		<Replace>
			<Type>PROMOTION_WAR_GENERAL_3</Type>
			<Description>TXT_KEY_PROMOTION_WAR_GENERAL_3</Description>
			<Help>TXT_KEY_PROMOTION_WAR_GENERAL_3_HELP</Help>
			<Sound>AS2D_IF_LEVELUP</Sound>
			<CannotBeChosen>true</CannotBeChosen>
			<LostWithUpgrade>true</LostWithUpgrade>
			<PortraitIndex>19</PortraitIndex>
			<IconAtlas>PROMOTION_ATLAS</IconAtlas>
			<PediaType>PEDIA_ATTRIBUTES</PediaType>
			<PediaEntry>TXT_KEY_PROMOTION_WAR_GENERAL_3</PediaEntry>
		</Replace>

		<Replace>
			<Type>PROMOTION_WAR_GENERAL_4</Type>
			<Description>TXT_KEY_PROMOTION_WAR_GENERAL_4</Description>
			<Help>TXT_KEY_PROMOTION_WAR_GENERAL_4_HELP</Help>
			<Sound>AS2D_IF_LEVELUP</Sound>
			<CannotBeChosen>true</CannotBeChosen>
			<LostWithUpgrade>true</LostWithUpgrade>
			<PortraitIndex>20</PortraitIndex>
			<IconAtlas>PROMOTION_ATLAS</IconAtlas>
			<PediaType>PEDIA_ATTRIBUTES</PediaType>
			<PediaEntry>TXT_KEY_PROMOTION_WAR_GENERAL_4</PediaEntry>
		</Replace>

		<Replace>
			<Type>PROMOTION_WAR_GENERAL_5</Type>
			<Description>TXT_KEY_PROMOTION_WAR_GENERAL_5</Description>
			<Help>TXT_KEY_PROMOTION_WAR_GENERAL_5_HELP</Help>
			<Sound>AS2D_IF_LEVELUP</Sound>
			<CannotBeChosen>true</CannotBeChosen>
			<LostWithUpgrade>true</LostWithUpgrade>
			<PortraitIndex>21</PortraitIndex>
			<IconAtlas>PROMOTION_ATLAS</IconAtlas>
			<PediaType>PEDIA_ATTRIBUTES</PediaType>
			<PediaEntry>TXT_KEY_PROMOTION_WAR_GENERAL_5</PediaEntry>
		</Replace>

		<Replace>
			<Type>PROMOTION_WAR_GENERAL_6</Type>
			<Description>TXT_KEY_PROMOTION_WAR_GENERAL_6</Description>
			<Help>TXT_KEY_PROMOTION_WAR_GENERAL_6_HELP</Help>
			<Sound>AS2D_IF_LEVELUP</Sound>
			<CannotBeChosen>true</CannotBeChosen>
			<LostWithUpgrade>true</LostWithUpgrade>
			<PortraitIndex>16</PortraitIndex>
			<IconAtlas>PROMOTION_ATLAS</IconAtlas>
			<PediaType>PEDIA_ATTRIBUTES</PediaType>
			<PediaEntry>TXT_KEY_PROMOTION_WAR_GENERAL_6</PediaEntry>
		</Replace>

		<Replace>
			<Type>PROMOTION_WAR_GENERAL_7</Type>
			<Description>TXT_KEY_PROMOTION_WAR_GENERAL_7</Description>
			<Help>TXT_KEY_PROMOTION_WAR_GENERAL_7_HELP</Help>
			<Sound>AS2D_IF_LEVELUP</Sound>
			<CannotBeChosen>true</CannotBeChosen>
			<LostWithUpgrade>true</LostWithUpgrade>
			<PortraitIndex>17</PortraitIndex>
			<IconAtlas>PROMOTION_ATLAS</IconAtlas>
			<PediaType>PEDIA_ATTRIBUTES</PediaType>
			<PediaEntry>TXT_KEY_PROMOTION_WAR_GENERAL_7</PediaEntry>
		</Replace>

		<Replace>
			<Type>PROMOTION_WAR_GENERAL_8</Type>
			<Description>TXT_KEY_PROMOTION_WAR_GENERAL_8</Description>
			<Help>TXT_KEY_PROMOTION_WAR_GENERAL_8_HELP</Help>
			<Sound>AS2D_IF_LEVELUP</Sound>
			<CannotBeChosen>true</CannotBeChosen>
			<LostWithUpgrade>true</LostWithUpgrade>
			<PortraitIndex>18</PortraitIndex>
			<IconAtlas>PROMOTION_ATLAS</IconAtlas>
			<PediaType>PEDIA_ATTRIBUTES</PediaType>
			<PediaEntry>TXT_KEY_PROMOTION_WAR_GENERAL_8</PediaEntry>
		</Replace>

		<Replace>
			<Type>PROMOTION_WAR_GENERAL_9</Type>
			<Description>TXT_KEY_PROMOTION_WAR_GENERAL_9</Description>
			<Help>TXT_KEY_PROMOTION_WAR_GENERAL_9_HELP</Help>
			<Sound>AS2D_IF_LEVELUP</Sound>
			<CannotBeChosen>true</CannotBeChosen>
			<LostWithUpgrade>true</LostWithUpgrade>
			<PortraitIndex>23</PortraitIndex>
			<IconAtlas>PROMOTION_ATLAS</IconAtlas>
			<PediaType>PEDIA_ATTRIBUTES</PediaType>
			<PediaEntry>TXT_KEY_PROMOTION_WAR_GENERAL_9</PediaEntry>
		</Replace>
	</UnitPromotions>



	<!-- The following Improvement and Builds are to make the Tech Tree show the fancy Star things on techs that add a General Level-->
	<Improvements>
		<Replace>
			<Type>IMPROVEMENT_CUBA_FAKE_WARGENERAL</Type>
			<SpecificCivRequired>true</SpecificCivRequired>
			<CivilizationType>CIVILIZATION_LEUGI_CUBA</CivilizationType>
			<Description>TXT_KEY_IMPROVEMENT_CITY_RUINS</Description>
			<Civilopedia>TXT_KEY_IMPROVEMENT_CITY_RUINS_PEDIA</Civilopedia>
			<PortraitIndex>0</PortraitIndex>
			<IconAtlas>GENERIC_FUNC_ATLAS</IconAtlas>
		</Replace>
	</Improvements>
	<Builds>
		<Row>
			<Type>BUILD_CUBA_GENERAL_LVL1</Type>
			<PrereqTech>TECH_BRONZE_WORKING</PrereqTech>
			<Time>900</Time>
			<ImprovementType>IMPROVEMENT_CUBA_FAKE_WARGENERAL</ImprovementType>
			<Description>TXT_KEY_BUILD_CUBA_GENERAL_LEVEL_UP</Description>
			<HotKey>KB_A</HotKey>
			<OrderPriority>1</OrderPriority>
			<CtrlDown>1</CtrlDown>
			<IconIndex>0</IconIndex>
			<IconAtlas>GENERIC_FUNC_ATLAS</IconAtlas>
		</Row>
		<Row>
			<Type>BUILD_CUBA_GENERAL_LVL2</Type>
			<PrereqTech>TECH_IRON_WORKING</PrereqTech>
			<Time>900</Time>
			<ImprovementType>IMPROVEMENT_CUBA_FAKE_WARGENERAL</ImprovementType>
			<Description>TXT_KEY_BUILD_CUBA_GENERAL_LEVEL_UP</Description>
			<Help>TXT_KEY_BUILD_ROAD_HELP</Help>
			<Recommendation>TXT_KEY_BUILD_ROAD_REC</Recommendation>
			<HotKey>KB_A</HotKey>
			<OrderPriority>1</OrderPriority>
			<CtrlDown>1</CtrlDown>
			<IconIndex>0</IconIndex>
			<IconAtlas>GENERIC_FUNC_ATLAS</IconAtlas>
		</Row>
		<Row>
			<Type>BUILD_CUBA_GENERAL_LVL3</Type>
			<PrereqTech>TECH_STEEL</PrereqTech>
			<Time>900</Time>
			<ImprovementType>IMPROVEMENT_CUBA_FAKE_WARGENERAL</ImprovementType>
			<Description>TXT_KEY_BUILD_CUBA_GENERAL_LEVEL_UP</Description>
			<Help>TXT_KEY_BUILD_ROAD_HELP</Help>
			<Recommendation>TXT_KEY_BUILD_ROAD_REC</Recommendation>
			<HotKey>KB_A</HotKey>
			<OrderPriority>1</OrderPriority>
			<CtrlDown>1</CtrlDown>
			<IconIndex>0</IconIndex>
			<IconAtlas>GENERIC_FUNC_ATLAS</IconAtlas>
		</Row>
		<Row>
			<Type>BUILD_CUBA_GENERAL_LVL4</Type>
			<PrereqTech>TECH_GUNPOWDER</PrereqTech>
			<Time>900</Time>
			<ImprovementType>IMPROVEMENT_CUBA_FAKE_WARGENERAL</ImprovementType>
			<Description>TXT_KEY_BUILD_CUBA_GENERAL_LEVEL_UP</Description>
			<Help>TXT_KEY_BUILD_ROAD_HELP</Help>
			<Recommendation>TXT_KEY_BUILD_ROAD_REC</Recommendation>
			<HotKey>KB_A</HotKey>
			<OrderPriority>1</OrderPriority>
			<CtrlDown>1</CtrlDown>
			<IconIndex>0</IconIndex>
			<IconAtlas>GENERIC_FUNC_ATLAS</IconAtlas>
		</Row>
		<Row>
			<Type>BUILD_CUBA_GENERAL_LVL5</Type>
			<PrereqTech>TECH_RIFLING</PrereqTech>
			<Time>900</Time>
			<ImprovementType>IMPROVEMENT_CUBA_FAKE_WARGENERAL</ImprovementType>
			<Description>TXT_KEY_BUILD_CUBA_GENERAL_LEVEL_UP</Description>
			<Help>TXT_KEY_BUILD_ROAD_HELP</Help>
			<Recommendation>TXT_KEY_BUILD_ROAD_REC</Recommendation>
			<HotKey>KB_A</HotKey>
			<OrderPriority>1</OrderPriority>
			<CtrlDown>1</CtrlDown>
			<IconIndex>0</IconIndex>
			<IconAtlas>GENERIC_FUNC_ATLAS</IconAtlas>
		</Row>
		<Row>
			<Type>BUILD_CUBA_GENERAL_LVL6</Type>
			<PrereqTech>TECH_REPLACEABLE_PARTS</PrereqTech>
			<Time>900</Time>
			<ImprovementType>IMPROVEMENT_CUBA_FAKE_WARGENERAL</ImprovementType>
			<Description>TXT_KEY_BUILD_CUBA_GENERAL_LEVEL_UP</Description>
			<Help>TXT_KEY_BUILD_ROAD_HELP</Help>
			<Recommendation>TXT_KEY_BUILD_ROAD_REC</Recommendation>
			<HotKey>KB_A</HotKey>
			<OrderPriority>1</OrderPriority>
			<CtrlDown>1</CtrlDown>
			<IconIndex>0</IconIndex>
			<IconAtlas>GENERIC_FUNC_ATLAS</IconAtlas>
		</Row>
		<Row>
			<Type>BUILD_CUBA_GENERAL_LVL7</Type>
			<PrereqTech>TECH_PLASTIC</PrereqTech>
			<Time>900</Time>
			<ImprovementType>IMPROVEMENT_CUBA_FAKE_WARGENERAL</ImprovementType>
			<Description>TXT_KEY_BUILD_CUBA_GENERAL_LEVEL_UP</Description>
			<Help>TXT_KEY_BUILD_ROAD_HELP</Help>
			<Recommendation>TXT_KEY_BUILD_ROAD_REC</Recommendation>
			<HotKey>KB_A</HotKey>
			<OrderPriority>1</OrderPriority>
			<CtrlDown>1</CtrlDown>
			<IconIndex>0</IconIndex>
			<IconAtlas>GENERIC_FUNC_ATLAS</IconAtlas>
		</Row>
		<Row>
			<Type>BUILD_CUBA_GENERAL_LVL8</Type>
			<PrereqTech>TECH_MOBILE_TACTICS</PrereqTech>
			<Time>900</Time>
			<ImprovementType>IMPROVEMENT_CUBA_FAKE_WARGENERAL</ImprovementType>
			<Description>TXT_KEY_BUILD_CUBA_GENERAL_LEVEL_UP</Description>
			<Help>TXT_KEY_BUILD_ROAD_HELP</Help>
			<Recommendation>TXT_KEY_BUILD_ROAD_REC</Recommendation>
			<HotKey>KB_A</HotKey>
			<OrderPriority>1</OrderPriority>
			<CtrlDown>1</CtrlDown>
			<IconIndex>0</IconIndex>
			<IconAtlas>GENERIC_FUNC_ATLAS</IconAtlas>
		</Row>
		<Row>
			<Type>BUILD_CUBA_GENERAL_LVL9</Type>
			<PrereqTech>TECH_NANOTECHNOLOGY</PrereqTech>
			<Time>900</Time>
			<ImprovementType>IMPROVEMENT_CUBA_FAKE_WARGENERAL</ImprovementType>
			<Description>TXT_KEY_BUILD_CUBA_GENERAL_LEVEL_UP</Description>
			<Help>TXT_KEY_BUILD_ROAD_HELP</Help>
			<Recommendation>TXT_KEY_BUILD_ROAD_REC</Recommendation>
			<HotKey>KB_A</HotKey>
			<OrderPriority>1</OrderPriority>
			<CtrlDown>1</CtrlDown>
			<IconIndex>0</IconIndex>
			<IconAtlas>GENERIC_FUNC_ATLAS</IconAtlas>
		</Row>
	</Builds>
	<Language_en_US>

		<Replace Tag="TXT_KEY_BUILD_CUBA_GENERAL_LEVEL_UP">
			<Text>Increased Combat Strength of Revolucionarios</Text>
		</Replace>
		
		<Replace Tag="TXT_KEY_PROMOTION_WAR_GENERAL">
			<Text>War General</Text>
		</Replace>
		<Replace Tag="TXT_KEY_PROMOTION_WAR_GENERAL_HELP">
			<Text>This Great General may Attack and Defend itself, however it loses 10 HP for each unit killed and may not capture cities, also receives a penalty against cities.</Text>
		</Replace>


		<Replace Tag="TXT_KEY_PROMOTION_WAR_GENERAL_0">
			<Text>War General [COLOR_YIELD_GOLD]Level 1[ENDCOLOR]</Text>
		</Replace>
		<Replace Tag="TXT_KEY_PROMOTION_WAR_GENERAL_0_HELP">
			<Text>The unit gets the Combat Strength of Warriors.</Text>
		</Replace>
		
		<Replace Tag="TXT_KEY_PROMOTION_WAR_GENERAL_1">
			<Text>War General [COLOR_YIELD_GOLD]Level 2[ENDCOLOR]</Text>
		</Replace>
		<Replace Tag="TXT_KEY_PROMOTION_WAR_GENERAL_1_HELP">
			<Text>Combat Bonus Boost after learning the secrets of Bronze Working</Text>
		</Replace>

		<Replace Tag="TXT_KEY_PROMOTION_WAR_GENERAL_2">
			<Text>War General [COLOR_YIELD_GOLD]Level 3[ENDCOLOR]</Text>
		</Replace>
		<Replace Tag="TXT_KEY_PROMOTION_WAR_GENERAL_2_HELP">
			<Text>Combat Bonus Boost after learning the secrets of Iron Working</Text>
		</Replace>

		<Replace Tag="TXT_KEY_PROMOTION_WAR_GENERAL_3">
			<Text>War General [COLOR_YIELD_GOLD]Level 4[ENDCOLOR]</Text>
		</Replace>
		<Replace Tag="TXT_KEY_PROMOTION_WAR_GENERAL_3_HELP">
			<Text>Combat Bonus Boost after learning the secrets of Steel</Text>
		</Replace>


		<Replace Tag="TXT_KEY_PROMOTION_WAR_GENERAL_4">
			<Text>War General [COLOR_YIELD_GOLD]Level 5[ENDCOLOR]</Text>
		</Replace>
		<Replace Tag="TXT_KEY_PROMOTION_WAR_GENERAL_4_HELP">
			<Text>Combat Bonus Boost after learning the secrets of Gunpowder</Text>
		</Replace>

		<Replace Tag="TXT_KEY_PROMOTION_WAR_GENERAL_5">
			<Text>War General [COLOR_YIELD_GOLD]Level 6[ENDCOLOR]</Text>
		</Replace>
		<Replace Tag="TXT_KEY_PROMOTION_WAR_GENERAL_5_HELP">
			<Text>Combat Bonus Boost after learning the secrets of Rifling</Text>
		</Replace>


		<Replace Tag="TXT_KEY_PROMOTION_WAR_GENERAL_6">
			<Text>War General [COLOR_YIELD_GOLD]Level 7[ENDCOLOR]</Text>
		</Replace>
		<Replace Tag="TXT_KEY_PROMOTION_WAR_GENERAL_6_HELP">
			<Text>Combat Bonus Boost after learning the secrets of Replaceable Parts</Text>
		</Replace>

		<Replace Tag="TXT_KEY_PROMOTION_WAR_GENERAL_7">
			<Text>War General [COLOR_YIELD_GOLD]Level 8[ENDCOLOR]</Text>
		</Replace>
		<Replace Tag="TXT_KEY_PROMOTION_WAR_GENERAL_7_HELP">
			<Text>Combat Bonus Boost after learning the secrets of Plastics</Text>
		</Replace>

		<Replace Tag="TXT_KEY_PROMOTION_WAR_GENERAL_8">
			<Text>War General [COLOR_YIELD_GOLD]Level 9[ENDCOLOR]</Text>
		</Replace>
		<Replace Tag="TXT_KEY_PROMOTION_WAR_GENERAL_8_HELP">
			<Text>Combat Bonus Boost after learning the secrets of Mobile Tactics</Text>
		</Replace>


		<Replace Tag="TXT_KEY_PROMOTION_WAR_GENERAL_9">
			<Text>War General [COLOR_YIELD_GOLD]Elite[ENDCOLOR]</Text>
		</Replace>
		<Replace Tag="TXT_KEY_PROMOTION_WAR_GENERAL_9_HELP">
			<Text>Combat Bonus Boost after learning the secrets of Nanotechnology. This is the final level.</Text>
		</Replace>
	</Language_en_US>



I'm by no means versed in Lua, so if something doesn't work, I'm afraid I can't help much from this point on, but it seems like it would be fairly straightforward to modify most of it. As for getting the by era change, hopefully someone else can use this as a basis to get to what you need.
 
Direct Era-Change can be detected, so it should be possible to make a much simpler system that is interested basically only in whether the player who has advanced into a new era is Civilization_X, and then for Civilization_X whether or not they have any GreatGeneralReplacementUnits_Y, and if so, set their base combat strength to "Variable_A".

I've never used the Unit:SetBaseCombatStrength(int) method that Leugi is using, but I am assuming it is a permanent combat base-strength change. It would seem to be based on the way he is using it in his Cuba Mod. I can come up with some code tomorrow sometime if you can post a list of the base unit strength values for the eras. I would leave the unit's original strength in the XML as whatever it would be for the Ancient Era, and then change as needed for Classical, etc.

There is one fly in the ointment, however, in that the Eras for Vanilla are not the same as those for BNW & GnK
 
I do change Combat Strength directly, but y hcan do via Promotions if youd like.
Here is how I did in my Civilizations:

Code:
function [COLOR="Blue"]UpdateCS[/COLOR](eTeam, currEra)
	local pTeam = Teams[eTeam]
	local iPlayer = pTeam:GetLeaderID()
	local pPlayer = Players[iPlayer]
	if pPlayer:GetCivilizationType() == [COLOR="red"]YOUR_CIV_TYPE[/COLOR] then
		for pUnit in pPlayer:Units() do
			if pUnit:GetUnitType() == [COLOR="Red"]YOUR_UNIT_TYPE[/COLOR] then
				[B][COLOR="SeaGreen"]if currEra == 0 then
					pUnit:SetBaseCombatStrength(7)
				elseif currEra == 1 then
					pUnit:SetBaseCombatStrength(11)
				elseif currEra == 2 then
					pUnit:SetBaseCombatStrength(18)
				elseif currEra == 3 then
					pUnit:SetBaseCombatStrength(22)
				elseif currEra == 4 then
					pUnit:SetBaseCombatStrength(30)
				elseif currEra == 5 then
					pUnit:SetBaseCombatStrength(45)
				elseif currEra == 6 then
					pUnit:SetBaseCombatStrength(65)
				else
					pUnit:SetBaseCombatStrength(88)
				end[/COLOR][/B]
			end
		end
	end
end
GameEvents.TeamSetEra.Add([COLOR="blue"]UpdateCS[/COLOR])

This will fire upon reaching a new era and look for every of that unit type, updating it's Combat Strength directly.
You would also need basically the same code in case of the creation of the Unit; in my case, the skeletons are created via function, so I already have that ready:

Code:
function CreateSkeleton(pPlot, pPlayer)
	local pNewUnit = pPlayer:InitUnit(eUndeadSkeleton, pPlot:GetX(), pPlot:GetY())
	[B][COLOR="SeaGreen"]local currEra = pPlayer:GetCurrentEra()
	if currEra == 0 then
		pNewUnit:SetBaseCombatStrength(7)
	elseif currEra == 1 then
		pNewUnit:SetBaseCombatStrength(11)
	elseif currEra == 2 then
		pNewUnit:SetBaseCombatStrength(18)
	elseif currEra == 3 then
		pNewUnit:SetBaseCombatStrength(22)
	elseif currEra == 4 then
		pNewUnit:SetBaseCombatStrength(30)
	elseif currEra == 5 then
		pNewUnit:SetBaseCombatStrength(45)
	elseif currEra == 6 then
		pNewUnit:SetBaseCombatStrength(65)
	else
		pNewUnit:SetBaseCombatStrength(88)
	end[/COLOR][/B]
	if not pPlayer:IsHuman() then
		pNewUnit:JumpToNearestValidPlot()
	end
	return pNewUnit
end

If you're not using a specific command to invoke the unit, you will need some way to check when it is created (like GameEvents.UnitCreated), which would go something like this:

Code:
function GGInvoked(iPlayer, iUnitID, iUnitType, iPlotX, iPlotY) 
	local pPlayer = Players[iPlayer]
	local pUnit = pPlayer:GetUnitByID(iUnitID)
	if pPlayer:GetCivilizationType() == [COLOR="Red"]YOUR_CIV_TYPE[/COLOR] then
		if iUnitType == [COLOR="red"]YOUR_UNIT_TYPE[/COLOR] then
			local eTeam = pPlayer:GetTeam()
			[B][COLOR="SeaGreen"]local currEra = pPlayer:GetCurrentEra()
			if currEra == 0 then
				pUnit:SetBaseCombatStrength(7)
			elseif currEra == 1 then
				pUnit:SetBaseCombatStrength(11)
			elseif currEra == 2 then
				pUnit:SetBaseCombatStrength(18)
			elseif currEra == 3 then
				pUnit:SetBaseCombatStrength(22)
			elseif currEra == 4 then
				pUnit:SetBaseCombatStrength(30)
			elseif currEra == 5 then
				pUnit:SetBaseCombatStrength(45)
			elseif currEra == 6 then
				pUnit:SetBaseCombatStrength(65)
			else
				pUnit:SetBaseCombatStrength(88)
			end[/COLOR][/B]
		end
	end
end

The numbers stated in the SetBaseCombatStrength parenthesis are just for show. You choose the amount you want to set (not add, set).
 
Thank everybody for all the help, I think I can manage from the information you've given me on making the Z-fighter unique unit's ability possible. Again, thanks so much for the help!
 
Top Bottom