Craig_Sutter
Deity
So the idea is to count the plots in a city area with a particular unique improvement... and then place multiple dummy buildings to give +experience to units built in the city with the unique improvements. As an example, 6 IMPROVEMENT_TRELLEBORG in a city radius would lead to 6 dummy buildings each giving +2% experience.
I would just like to check the code logic as my use of item counts is sometimes suspect
. Are the points where trelleborgplots = 0 and trelleborgplots = trelleborgplots+1 are placed the correct positions so the plot iteration is being done correctly for each city?
My other question is whether or not experience stacks with these multiple dummies... I think yes, but just want to check.
Thank-you for your indulgence.
I would just like to check the code logic as my use of item counts is sometimes suspect

My other question is whether or not experience stacks with these multiple dummies... I think yes, but just want to check.
Code:
-- coding for Danish Trelleborg Improvement.
function TrellborgBuilding(iPlayer)
local pPlayer = Players[iPlayer]
if pPlayer:GetCivilizationType() == GameInfoTypes.CIVILIZATION_DENMARK then
for city in pPlayer:Cities() do
local trelleborgplots = 0
for i = 0, city:GetNumCityPlots() - 1, 1 do
local plot = city:GetCityIndexPlot(i)
if plot and (plot:GetOwner() == iPlayer) then
if plot:GetImprovementType() == GameInfoTypes.IMPROVEMENT_TRELLEBORG then
if not plot:IsImprovementPillaged() then
trelleborgplots = trelleborgplots+1
end
end
end
city:SetNumRealBuilding(GameInfoTypes["BUILDING_TRELLEBORG"], trelleborgplots)
end
end
end
end
GameEvents.PlayerDoTurn.Add(TrellborgBuilding)
Thank-you for your indulgence.