C++/Lua Request Thread

Here is the portion of the code that will add +1 population to the player's capital every time an enemy combat unit is killed by the player within the player's territory:
Spoiler :
Code:
local iRequiredCivilizationID = GameInfoTypes.CIVILIZATION_RUSSIA
local tRequiredPlayerID = { ["NONE"] = " no player has been identified as the civilization" }
for PlayerID = 0, GameDefines.MAX_MAJOR_CIVS - 1 do
	if Players[PlayerID]:GetCivilizationType() == iRequiredCivilizationID then
		if tRequiredPlayerID["NONE"] then
			tRequiredPlayerID = {}
		end
		tRequiredPlayerID[PlayerID] = PlayerID
	end
end
function EnemyKilledInPlayerTerritory(iOwner, iUnit, iUnitType, iX, iY, bDelay, iKiller)
	local iRequiredPlayerID = "NONE"
	if tRequiredPlayerID[iKiller] then
		iRequiredPlayerID = tRequiredPlayerID[iKiller]
	else
		return
	end
	if bDelay then
		if iKiller ~= iOwner then
			local pPlot = Map.GetPlot(iX, iY)
			if pPlot:GetOwner() == iRequiredPlayerID then
				local pKilledUnit = Players[iOwner]:GetUnitByID(iUnit)
				if pKilledUnit:IsCombatUnit() then
					local pPlayer = Players[iRequiredPlayerID]
					local pUnitOwner = Players[iOwner]
					if Teams[pPlayer:GetTeam()]:IsAtWar(pUnitOwner:GetTeam()) then
						local pCapitalCity = pPlayer:GetCapitalCity()
						pCapitalCity:ChangePopulation(1, true)
					end
				end
			end
		end
	end
end
GameEvents.UnitPrekill.Add(EnemyKilledInPlayerTerritory)
You'll have to change CIVILIZATION_RUSSIA to the correct name for your civ. I tested using Russia and killed off a Barb in my territory: everything seemed to work properly.
The unit 'killing' event requires that:
  1. The killed unit has to be a combat unit. UnitPreKill fires for anything: Workers, Great People, Combat Units, Missionaries, etc. Thus the requirement for a combat unit.
  2. The killer has to be your civ. So if an ally kills an enemy in your territory nothing will happen. Otherwise the logic of the code is too much a :hammer2: and after a couple aborted attempts to think it through.... :wallbash: :faint:
  3. The two players actually have to be at war. (Barbs are always seen as being at war with 'regular' players). This extra requirement is an insurance policy against any 'oddball' conditions introduced by other mods, such as attrition systems or what have you.
I'm not certain why the dynamic policy system would be needed. CapitalUnhappinessMod is a table that's already defined in XML; it's used in the Monarchy policy, under the Tradition branch.
  • CapitalUnhappinessMod is a column within table Policies.
  • While any dummy policy can include the column with a value specification, such as:
    Code:
    <CapitalUnhappinessMod>-10</CapitalUnhappinessMod>
    You cannot give multiple copies of the same dummy policy to the same player. So if you wanted an additional "-Y%" unhappiness in the capital every time an enemy unit is killed within the player's territory, multiple dummy policies are required. So for a total of "10 * -Y%" (ie, 10 enemy units were killed), you would need a total of 10 dummy policies to accomplish this, each with a different XML name for the individual policy, and each having <CapitalUnhappinessMod>-Y%</CapitalUnhappinessMod> within the definition of the dummy policy.
  • Or you need ten different policies each with an increased setting for <CapitalUnhappinessMod>: one would for example have "-10", the next "-20", the next "-30", etc. And then you have to swap-out the policy with the lower setting for the policy with the next higher setting. Essentially this is what the Dynamic Policy System will do.
  • It really depends on what you want
 
To be honest, from what I recall that describes the Soul Society in a nutshell -- I really only collected the first Soul Society arc from Bleach, so my memories of it are a city with massive slums surrounding it, filled with the souls of people who have nothing to do.

Yeah, that's actually pretty accurate; There's the small inner region for the nobility, walled off from the rest of the city, which is flooded with billions of impoverished citizens.

I couldn't tell if your "unhappiness from citizens in the capital is halved" is always on, or not. If it's always on and just part of the UA, then the code is relatively easy -- here's the code is used in the Forest of Magic to give Marisa a yield from her Mushroom tiles:

Code:
function InitMarisa(player)
	print ("Marisa Mushroom Magic Lua activated")
	for playerID, player in pairs(Players) do
		local player = Players[playerID];
		if player:GetCivilizationType() == GameInfoTypes["CIVILIZATION_TH_FOREST_OF_MAGIC"] then
			if not player:HasPolicy(GameInfoTypes["POLICY_FOM_MUSHROOMS_1"]) then
				player:SetNumFreePolicies(1)
				player:SetNumFreePolicies(0)
				player:SetHasPolicy(GameInfoTypes["POLICY_FOM_MUSHROOMS_1"], true)	
			end
		end
	end 
end
Events.SequenceGameInitComplete.Add(InitMarisa)

Perfect! Testing shows that it's working beautifully; thank you!

Here is the portion of the code that will add +1 population to the player's capital every time an enemy combat unit is killed by the player within the player's territory:
Spoiler :
Code:
local iRequiredCivilizationID = GameInfoTypes.CIVILIZATION_RUSSIA
local tRequiredPlayerID = { ["NONE"] = " no player has been identified as the civilization" }
for PlayerID = 0, GameDefines.MAX_MAJOR_CIVS - 1 do
	if Players[PlayerID]:GetCivilizationType() == iRequiredCivilizationID then
		if tRequiredPlayerID["NONE"] then
			tRequiredPlayerID = {}
		end
		tRequiredPlayerID[PlayerID] = PlayerID
	end
end
function EnemyKilledInPlayerTerritory(iOwner, iUnit, iUnitType, iX, iY, bDelay, iKiller)
	local iRequiredPlayerID = "NONE"
	if tRequiredPlayerID[iKiller] then
		iRequiredPlayerID = tRequiredPlayerID[iKiller]
	else
		return
	end
	if bDelay then
		if iKiller ~= iOwner then
			local pPlot = Map.GetPlot(iX, iY)
			if pPlot:GetOwner() == iRequiredPlayerID then
				local pKilledUnit = Players[iOwner]:GetUnitByID(iUnit)
				if pKilledUnit:IsCombatUnit() then
					local pPlayer = Players[iRequiredPlayerID]
					local pUnitOwner = Players[iOwner]
					if Teams[pPlayer:GetTeam()]:IsAtWar(pUnitOwner:GetTeam()) then
						local pCapitalCity = pPlayer:GetCapitalCity()
						pCapitalCity:ChangePopulation(1, true)
					end
				end
			end
		end
	end
end
GameEvents.UnitPrekill.Add(EnemyKilledInPlayerTerritory)
You'll have to change CIVILIZATION_RUSSIA to the correct name for your civ. I tested using Russia and killed off a Barb in my territory: everything seemed to work properly.
The unit 'killing' event requires that:
  1. The killed unit has to be a combat unit. UnitPreKill fires for anything: Workers, Great People, Combat Units, Missionaries, etc. Thus the requirement for a combat unit.
  2. The killer has to be your civ. So if an ally kills an enemy in your territory nothing will happen. Otherwise the logic of the code is too much a :hammer2: and after a couple aborted attempts to think it through.... :wallbash: :faint:
  3. The two players actually have to be at war. (Barbs are always seen as being at war with 'regular' players). This extra requirement is an insurance policy against any 'oddball' conditions introduced by other mods, such as attrition systems or what have you.

Thank you so much! With this, the mod is now complete! I'll make sure the civ's pedia entry has all of those restrictions laid out clearly, since it'd be a tad tough to squeeze them into the text for the trait.

CapitalUnhappinessMod is a column within table Policies.
...er... I knew that... I was just, um... testing to make sure you did, yes, that's what that was! *cough*
 
I have a quick question here.

Is it possible to detect that a City is a captured City-State?
I'm trying to have a Unique Ability where your units have a Combat Bonus when you attack captured City-States.

(I asked this earlier in a separate thread, but no one answered, so I decided to ask here to get an answer.)
 
I have a quick question here.

Is it possible to detect that a City is a captured City-State?
I'm trying to have a Unique Ability where your units have a Combat Bonus when you attack captured City-States.

(I asked this earlier in a separate thread, but no one answered, so I decided to ask here to get an answer.)
City:GetOriginalOwner()
Players[City:GetOriginalOwner()]:IsMinorCiv() would tell you whether the original owner of 'City' was a City-State.

The problem is that there really is no good combat hook to tie into to know when your units are about to attack such a city.
 
City:GetOriginalOwner()
Players[City:GetOriginalOwner()]:IsMinorCiv() would tell you whether the original owner of 'City' was a City-State.

The problem is that there really is no good combat hook to tie into to know when your units are about to attack such a city.

So it sounds like that not even a promotion with iPromotion = GameInfoTypes type of local won't work then.

I guess I gotta think of a new ability then.

Thanks for the help.

EDIT: I have a new idea for a UA: It is possible to have connected cities to generate Great Engineers faster or gain Great Engineers points once connected? Also, would I need to use Lua to have Great Engineers to perform Trade Missions?
 
So it sounds like that not even a promotion with iPromotion = GameInfoTypes type of local won't work then.

I guess I gotta think of a new ability then.

Thanks for the help.

EDIT: I have a new idea for a UA: It is possible to have connected cities to generate Great Engineers faster or gain Great Engineers points once connected? Also, would I need to use Lua to have Great Engineers to perform Trade Missions?
I have not tested the following, and you will have to change CIVILIZATION_YOUR_CIV_NAME and PROMOTION_YOUR_PROMOTION_NAME to the correct XML names for the civilization and the promotion you are going to use:
Spoiler :
Code:
local iRequiredCiv = GameInfoTypes.CIVILIZATION_YOUR_CIV_NAME
local iPromoExtraStrength = GameInfoTypes.PROMOTION_YOUR_PROMOTION_NAME

function GetPlayersAtWarWith(iOurTeamID)
	local tPlayersAtWarWith = {}
	for iTeam = 0, GameDefines.MAX_CIV_TEAMS - 1 do
		if iTeam ~= iOurTeamID then
			local pTheirTeam = Teams[iTeam]
			if not pTheirTeam:IsBarbarian() and not pTheirTeam:IsMinorCiv() and pTheirTeam:IsAlive() then
				if Teams[iOurTeamID]:IsAtWar(iTeam) then
					for PlayerID = 0, GameDefines.MAX_MAJOR_CIVS - 1, 1 do
						local pPlayer = Players[PlayerID]
						if (pPlayer ~= nil) then
							if (pPlayer:GetTeam() == iTeam) and pPlayer:IsAlive() then
								tPlayersAtWarWith[PlayerID] = PlayerID
							end
						end
					end
				end
			end
		end
	end
	return tPlayersAtWarWith
end
function GetConqueredCityStates(tPlayersAtWarWith)
	local ConqueredCityStates = "NONE"
	for k,v in pairs(tPlayersAtWarWith) do
		for pCity in Players[v]:Cities() do
			if Players[pCity:GetOriginalOwner()]:IsMinorCiv() then
				if ConqueredCityStates == "NONE" then
					ConqueredCityStates = {}
				end
				table.insert(ConqueredCityStates, pCity)
			end
		end
	end
	return ConqueredCityStates
end
function ExtraStrengthCityStateLiberate(iPlayer)
	local pPlayer = Players[iPlayer]
	if pPlayer:GetCivilizationType() == iRequiredCiv then
		local iOurTeamID = pPlayer:GetTeam()
		local bIsAtWar = (Teams[iOurTeamID]:GetAtWarCount(true) > 0)
		for pUnit in pPlayer:Units() do
			if pUnit:IsCombatUnit() then
				local bUnitShouldHavePromotion = false
				if bIsAtWar then
					local tPlayersAtWarWith = GetPlayersAtWarWith(iOurTeamID)
					local tCitiesToBeLiberated = GetConqueredCityStates(tPlayersAtWarWith)
					if tCitiesToBeLiberated ~= "NONE" then
						local pUnitPlot = pUnit:GetPlot()
						local iTileOwnerID = pUnitPlot:GetOwner()
						if tPlayersAtWarWith[iTileOwnerID] then
							for pCity in Players[iTileOwnerID]:Cities() do
								local bCityIsInConqueredList = false
								for k,v in pairs(tCitiesToBeLiberated) do
									if pCity == v then
										bCityIsInConqueredList = true
										break
									end
								end
								if bCityIsInConqueredList and (Map.PlotDistance(pUnitPlot:GetX(), pUnitPlot:GetY(), pCity:GetX(), pCity:GetY()) <= 3) then
									bUnitShouldHavePromotion = true
								end
							end
						end
					end
				end
				pUnit:SetHasPromotion(iPromoExtraStrength, bUnitShouldHavePromotion)
			end
		end
	end
end
GameEvents.PlayerDoTurn.Add(ExtraStrengthCityStateLiberate)
If I have no goofs in the code, at the beginning of the player's turn, combat units that are:
  • In territory of a civ with which the player is at war
  • Are combat units
  • Within 3 tiles of a city state that was conquered by the civ with which the player is at war
Will get the promotion specified. They will keep the promotion for the length of that turn.

On the next turn, units that no longer qualify will have the promotion removed.

If I did make a goof somewhere and the code does not seem to work correctly, it would probably be better to start a new thread asking for me to look at the code again and explaining what you are seeing happening (or not happening). You should also attach the entire mod (whoward69's zip your mods and attach tutorial) in the 1st post of such a thread as well as a copy of the lua.log file (see whoward69's enable error logging tutorial)

The code needs to be placed within an lua file in your mod, and the lua file needs to be set up as an InGameUIAddin in Modbuddy (whoward69's what ModBuddy setting for what file types tutorial Post #3 of that tutorial) and the "Import Into VFS" attribute of the file should be left as "false".

--------------------------------------------------------------------------------------------

The problem with trying to dynamically assign the promotion just before the unit attacks a qualifying city is that there are no reliable event 'hooks' provided by Firaxis that a mod-maker can use to 'hang' their lua code on. This is true of just about any sort of combat-type-event you can think of -- Firaxis simply never gave us much of anything to use, and what they did provide requires the human player to be able to 'witness' the action involved in order for the event to fire off to an lua script reliably.
 
I have not tested the following, and you will have to change CIVILIZATION_YOUR_CIV_NAME and PROMOTION_YOUR_PROMOTION_NAME to the correct XML names for the civilization and the promotion you are going to use:
Spoiler :
Code:
local iRequiredCiv = GameInfoTypes.CIVILIZATION_YOUR_CIV_NAME
local iPromoExtraStrength = GameInfoTypes.PROMOTION_YOUR_PROMOTION_NAME

function GetPlayersAtWarWith(iOurTeamID)
	local tPlayersAtWarWith = {}
	for iTeam = 0, GameDefines.MAX_CIV_TEAMS - 1 do
		if iTeam ~= iOurTeamID then
			local pTheirTeam = Teams[iTeam]
			if not pTheirTeam:IsBarbarian() and not pTheirTeam:IsMinorCiv() and pTheirTeam:IsAlive() then
				if Teams[iOurTeamID]:IsAtWar(iTeam) then
					for PlayerID = 0, GameDefines.MAX_MAJOR_CIVS - 1, 1 do
						local pPlayer = Players[PlayerID]
						if (pPlayer ~= nil) then
							if (pPlayer:GetTeam() == iTeam) and pPlayer:IsAlive() then
								tPlayersAtWarWith[PlayerID] = PlayerID
							end
						end
					end
				end
			end
		end
	end
	return tPlayersAtWarWith
end
function GetConqueredCityStates(tPlayersAtWarWith)
	local ConqueredCityStates = "NONE"
	for k,v in pairs(tPlayersAtWarWith) do
		for pCity in Players[v]:Cities() do
			if Players[pCity:GetOriginalOwner()]:IsMinorCiv() then
				if ConqueredCityStates == "NONE" then
					ConqueredCityStates = {}
				end
				table.insert(ConqueredCityStates, pCity)
			end
		end
	end
	return ConqueredCityStates
end
function ExtraStrengthCityStateLiberate(iPlayer)
	local pPlayer = Players[iPlayer]
	if pPlayer:GetCivilizationType() == iRequiredCiv then
		local iOurTeamID = pPlayer:GetTeam()
		local bIsAtWar = (Teams[iOurTeamID]:GetAtWarCount(true) > 0)
		for pUnit in pPlayer:Units() do
			if pUnit:IsCombatUnit() then
				local bUnitShouldHavePromotion = false
				if bIsAtWar then
					local tPlayersAtWarWith = GetPlayersAtWarWith(iOurTeamID)
					local tCitiesToBeLiberated = GetConqueredCityStates(tPlayersAtWarWith)
					if tCitiesToBeLiberated ~= "NONE" then
						local pUnitPlot = pUnit:GetPlot()
						local iTileOwnerID = pUnitPlot:GetOwner()
						if tPlayersAtWarWith[iTileOwnerID] then
							for pCity in Players[iTileOwnerID]:Cities() do
								local bCityIsInConqueredList = false
								for k,v in pairs(tCitiesToBeLiberated) do
									if pCity == v then
										bCityIsInConqueredList = true
										break
									end
								end
								if bCityIsInConqueredList and (Map.PlotDistance(pUnitPlot:GetX(), pUnitPlot:GetY(), pCity:GetX(), pCity:GetY()) <= 3) then
									bUnitShouldHavePromotion = true
								end
							end
						end
					end
				end
				pUnit:SetHasPromotion(iPromoExtraStrength, bUnitShouldHavePromotion)
			end
		end
	end
end
GameEvents.PlayerDoTurn.Add(ExtraStrengthCityStateLiberate)
If I have no goofs in the code, at the beginning of the player's turn, combat units that are:
  • In territory of a civ with which the player is at war
  • Are combat units
  • Within 3 tiles of a city state that was conquered by the civ with which the player is at war
Will get the promotion specified. They will keep the promotion for the length of that turn.

On the next turn, units that no longer qualify will have the promotion removed.

If I did make a goof somewhere and the code does not seem to work correctly, it would probably be better to start a new thread asking for me to look at the code again and explaining what you are seeing happening (or not happening). You should also attach the entire mod (whoward69's zip your mods and attach tutorial) in the 1st post of such a thread as well as a copy of the lua.log file (see whoward69's enable error logging tutorial)

The code needs to be placed within an lua file in your mod, and the lua file needs to be set up as an InGameUIAddin in Modbuddy (whoward69's what ModBuddy setting for what file types tutorial Post #3 of that tutorial) and the "Import Into VFS" attribute of the file should be left as "false".

--------------------------------------------------------------------------------------------

The problem with trying to dynamically assign the promotion just before the unit attacks a qualifying city is that there are no reliable event 'hooks' provided by Firaxis that a mod-maker can use to 'hang' their lua code on. This is true of just about any sort of combat-type-event you can think of -- Firaxis simply never gave us much of anything to use, and what they did provide requires the human player to be able to 'witness' the action involved in order for the event to fire off to an lua script reliably.

Good news, LeeS. I tried the code and it works! The units gain the promotion correctly.

Thank you!
 
Basically, I'm trying to do an Event (from E&D) that has two options trigger as soon as you enter a specific era. Any help?
 
I'm trying to create a custom trait for my upcoming civ, which grants culture equal to 1/3 or 1/2 of the cost of your next policy when you conquer a city, possible through the <Freebuildingonconquest> function. I've already worked out how to create an invisible building that spawns when a city is conquered, and grants a lump sum of culture, the problem is its always the amount and I would like it to scale with culture cost.

Could anyone offer help or advice?
 
Well, uh, that's quite strong.

Anyway, here's the code for it.

Code:
function CultureFromConquest(oldOwnerID, isCapital, cityX, cityY, newOwnerID, iPop, bConquest)
	local player = Players[newOwnerID]
	if (player:GetCivilizationType() == GameInfoTypes["CIVILIZATION_YOUR_CIV_HERE"] and player:IsEverAlive()) then
		if oldOwnerID ~= newOwnerID then
			local nextPolicyCost = (player:GetNextPolicyCost()*50/100)
			player:ChangeJONSCulture(nextPolicyCost)
		end
	end
end

GameEvents.CityCaptureComplete.Add(CultureFromConquest)
 
Thank you so much, and yeah I've got to mess around with the strength. I've asked around here and on Reddit and everyone seems to think its either totally useless or worse than Poland. So I'm not really sure.

Oh, and is there anyway to make sure this only works the first time you capture that specific city, I forgot to mention that in the original post.
 
>Worse than Poland.

That's... not saying a lot, actually, almost everything is worse than Poland.
 
Worse as stronger and arguably more over powered. I comes down to the fact that if their are a lot of cities to conquer you might get more free policies than Poland, but if their aren't you might not get much of anything.
 
Consider the AI, and that a mere 2 Cities nets you a Policy. A war against Hiawatha and you can fill Rationalism in a matter of turns.
 
Thank you so much, and yeah I've got to mess around with the strength. I've asked around here and on Reddit and everyone seems to think its either totally useless or worse than Poland. So I'm not really sure.

Oh, and is there anyway to make sure this only works the first time you capture that specific city, I forgot to mention that in the original post.
I'd probably use a dummy building that has <ConquestProb>100</ConquestProb> as part of its definition under table <Buildings> so that the dummy always survives the city being captured and place it into a city that the civilization captures. If the city already has the building, then Civilization-X has previously captured the city at least one time, and no culture would be added. If the city does not have the dummy building, then the culture is added and the dummy building is added to the city.
 
I'm working on a custom Trait that would give either 2-3 Golden Age Points or Culture (Preferably Golden Age Points) per number of tiles gained from capturing a city, Kinda like JFD's Tojo where he gains science based on coastal tile captured.

Any help or advice is greatly appreciated.
 
I'm working on a custom Trait that would give either 2-3 Golden Age Points or Culture (Preferably Golden Age Points) per number of tiles gained from capturing a city, Kinda like JFD's Tojo where he gains science based on coastal tile captured.

Any help or advice is greatly appreciated.
You will have to alter the required civilization-name to match with what you are using, and adjust the other variables as desired. The golden age points will only be added as a result of city conquest. Currently as the variables are set the plot of the captured city itself is not included in the 'count' of golden age points. There is also a multiplier in the five variables defined for extra-more golden age points when the captured city was a player's capital city.

  • You should not set variable iCapturedCapitalCityMultiplier to any value less than '1'.
  • You should not really change the value for variable iPlotOwnershipDurationMax -- this is meant to minimize 'double-counting' of plots near the captured city which were already accounted for in previous city-captures and to exclude plots that were already a part of the player's empire (ie, nasty AI forward settle cities having their 'plots' overlapping the ones you already owned). You can still get double-counting of plots if you capture two or more closely-placed enemy cities on the same turn, but to try to remove that possibility is a bit more code and probably a fair bit of processing-time hog or lagginess when a player captures a city. It would probably also require adding at least a PlayerDoTurn event to 'store' all the plots owned by a player, if not also a "player bought a plot" event and a PlayerCityFounded event.

Code:
local iRequiredCivilization = GameInfoTypes.CIVILIZATION_RUSSIA
local iGoldenAgePointsPerCapturedCityTile = 1
local iPlotOwnershipDurationMax = 1
local iCapturedCapitalCityMultiplier = 2
local bExcludeCapturedCityPlot = true

------------------------------------------------------------
---- IsCivInPlay borrowed from William Howard
------------------------------------------------------------

function IsCivInPlay(iCivType)
  for iSlot = 0, GameDefines.MAX_MAJOR_CIVS-1, 1 do
    local iSlotStatus = PreGame.GetSlotStatus(iSlot)
    if (iSlotStatus == SlotStatus.SS_TAKEN or iSlotStatus == SlotStatus.SS_COMPUTER) then
      if (PreGame.GetCivilization(iSlot) == iCivType) then
        return true
      end
    end
  end
  
  return false
end

--------------------------------------------------------------------------------------------------------------------------
--GoldenAgePointsFromCityCapture
----------------------------------------------------------------------------------------------------------------------------

function GoldenAgePointsFromCityCapture(oldPlayerID, bCityWasCapital, plotX, plotY, newPlayerID, iPop, bConquest)
	local pPlayer = Players[newPlayerID]
	if (pPlayer:GetCivilizationType() == iRequiredCivilization) and bConquest then
		local pCity = Map.GetPlot(plotX, plotY):GetPlotCity()
		local iExtraGoldenAgePointsToAdd = 0
		local iPointsPerCapturedTile = iGoldenAgePointsPerCapturedCityTile * (bCityWasCapital and iCapturedCapitalCityMultiplier or 1)
		local iNumPlots = pCity:GetNumCityPlots()
		for i = 0, iNumPlots - 1 do
			local pPlot = pCity:GetCityIndexPlot(i)
			local iPlotowner = pPlot:GetOwner()
			if (iPlotowner ~= -1) and (iPlotowner == newPlayerID) then
				--get plot ownership duration
				if not pPlot:IsCity() then
					--the plot does NOT have a city on it
					if pPlot:GetOwnershipDuration() <= iPlotOwnershipDurationMax then
						iExtraGoldenAgePointsToAdd = iExtraGoldenAgePointsToAdd + iPointsPerCapturedTile
					end
				else
					--the plot has a city on it
					if (pPlot:GetPlotCity() == pCity) and not bExcludeCapturedCityPlot then
						iExtraGoldenAgePointsToAdd = iExtraGoldenAgePointsToAdd + iPointsPerCapturedTile
					end
				end
			end
		end
		pPlayer:ChangeGoldenAgeProgressMeter(iExtraGoldenAgePointsToAdd)
		print("Total Golden Age Points Added Was: " .. iExtraGoldenAgePointsToAdd)
	end
end

if (IsCivInPlay(iRequiredCivilization)) then
	GameEvents.CityCaptureComplete.Add(GoldenAgePointsFromCityCapture)
end
 
Hi, I was wondering if someone could rig up a Lua code for me that does something like this as a Civilization Trait:

"For each Major Civilization you are at war with, gain a 5% Combat Bonus" (which can stack indefinitely; allowing up to 105% if playing against 21 players). The idea, I figure is the opposite of Sweden's UA, but is slightly less useful, and can drop HARD with fewer Civs in play.

If possible, I'd like a second version of the trait where instead you receive +1 Happiness for each Major Civ you are at war with, but you also receive +1 additional Happiness for each Major Civ you are at war with that you have more happiness than (Allowing up to 42 possible Happiness from DOWs).

If anyone's willing to rig that up for me, that'd be super!
 
hello, i was trying to get a civilisation with the following traits:
-unhappieness per city and per popolution reduced (already done)
-cant declare war (only can be attacked), e.g. removing the "declare war" from the diplomacy-menu and from the popup if you send units in other terretory
-no trade routes
so i tried to copy-paste a bit with various civs and mods, but nothing would work in that case. if somebody would be able to code this, i'd be happy ... thanks already
here, take a :c5goldenage:
 
Back
Top Bottom