Civitar
Adventurer
So, Colonialist Legacies' Australia update is supposed to come out tomorrow or later today and... it's not working.
The trouble is the UA, which should be the following:
Settlers found puppeted cities that generate +1 Tourism. +1 Tourism per outgoing sea trade route. Cities that generate +2 Tourism or more expand at double speed.
But, the new puppet cities are not getting their tourism. Here is the code for the entire UA, if anyone can spot the trouble I'd be very grateful.
The dummy buildings are defined like this:
And if it matters to anyone, there is a file that defines three new columns also in the mod (though it often crashes the mod, for some reason):
I noticed when playtesting a while back that the founded puppet cities got a Floating Gardens, but I haven't noticed that since...
If anyone can resolve these issues as well as the frequent crashes caused by the New Database Columns code, Henry Parkes thanks you.
The trouble is the UA, which should be the following:
Settlers found puppeted cities that generate +1 Tourism. +1 Tourism per outgoing sea trade route. Cities that generate +2 Tourism or more expand at double speed.
But, the new puppet cities are not getting their tourism. Here is the code for the entire UA, if anyone can spot the trouble I'd be very grateful.
Code:
--------------------
--Colonialist Legacies' Australia
--Boundless Plains To Share
--Civitar, Neirai, bane_
--------------------
print("Loaded CL_AustraliaBoundlessPlainsToShare.lua.");
local iAussieCiv = GameInfoTypes.CIVILIZATION_CL_AUSTRALIA;
local iAussiePuppetTourismBuilding = GameInfoTypes.BUILDING_CL_AUSTRALIA_PUPPET_TOURISM; --hidden building, gives +1 Tourism
local iAussieTradeTourismBuilding = GameInfoTypes.BUILDING_CL_AUSTRALIA_TRADE_TOURISM; --ditto
--Founded cities are puppets and generate +1 Tourism
function CL_AussieFoundPuppetCities(iPlayer, iCityX, iCityY)
print("A city has been founded at " .. iCityX .. ", " .. iCityY .. ".");
local pPlayer = Players[iPlayer];
if pPlayer:IsAlive() and pPlayer:GetCivilizationType() == iAussieCiv then
print("The city was founded by Australia!");
local pPlot = Map.GetPlot(iCityX, iCityY);
local pCity = pPlot:GetPlotCity();
if not pCity:IsCapital() then
print("The city is not Australia's capital! So...");
pCity:SetPuppet(true);
print("It is a puppet.");
pCity:SetNumRealBuilding(iAussiePuppetTourismBuilding, 1);
print("And it generates +1 Tourism.");
end
end
end
function CL_AussiePuppetCheck(iPlayer)
print("Checking Australian cities for puppet status...");
local pPlayer = Players[iPlayer];
if pPlayer:IsAlive() and pPlayer:GetCivilizationType() == iAussieCiv then
for pCity in pPlayer:Cities() do
print("Found an Australian city! Is it a puppet?");
if not pCity:IsPuppet() then
print("It's not a puppet. So it shouldn't have a Tourism bonus from being a puppet.");
pCity:SetNumRealBuilding(iAussiePuppetTourismBuilding, 0);
print("It has no Tourism bonus from being a puppet.");
end
end
end
end
--+1 Tourism per sea-based Trade Route
function CL_GetNumOutgoingSeaTradeRoutes(pPlayer, pCity)
print("Checking the number of outgoing sea trade routes in this city...");
local TradeRoutes = pPlayer:GetTradeRoutes();
local iNumOutgoingSeaTradeRoutes = 0;
for k, v in pairs(TradeRoutes) do
if v.FromCity == pPlayer:GetCityByID(pCity) then
if v.Domain == GameInfoTypes.DOMAIN_SEA then
iNumOutgoingSeaTradeRoutes = iNumOutgoingSeaTradeRoutes + 1;
end
end
end
return iNumOutgoingSeaTradeRoutes;
end
function CL_AussieTourismFromSeaTrade(iPlayer)
print("Checking Australian cities for potential trade benefits to Tourism...");
local pPlayer = Players[iPlayer];
if pPlayer:IsAlive() and pPlayer:GetCivilizationType() == iAussieCiv then
for pCity in pPlayer:Cities() do
local iNumOutgoingSeaTradeRoutes = CL_GetNumOutgoingSeaTradeRoutes(pPlayer, pCity);
print("This city has " .. iNumOutgoingSeaTradeRoutes .. " outgoing sea trade routes.");
if iNumOutgoingSeaTradeRoutes > 0 then
pCity:SetNumRealBuilding(iAussieTradeTourismBuilding, iNumOutgoingSeaTradeRoutes);
print("This city now gets +" .. iNumOutgoingSeaTradeRoutes .. " Tourism from outgoing sea trade routes.");
end
end
end
end
--Cities with +2 Tourism expand 100% faster
function CL_AussieCityExpandWithTourism(iPlayer)
print("Checking Australian cities for potential expansion benefits from tourism...");
local pPlayer = Players[iPlayer];
if pPlayer:IsAlive() and pPlayer:GetCivilizationType() == iAussieCiv then
for pCity in pPlayer:Cities() do
if pCity:GetBaseTourism() >= 2 then
print("This city generates 2 or more Tourism per turn! It gets expansion bonuses.");
local iCultureStored = pCity:GetJONSCultureStored();
local iCityCultureOutput = pCity:GetJONSCulturePerTurn();
pCity:SetJONSCultureStored(iCultureStored + iCityCultureOutput);
print("City expansion rate doubled.");
end
end
end
end
GameEvents.PlayerCityFounded.Add(CL_AussieFoundPuppetCities);
GameEvents.PlayerDoTurn.Add(CL_AussiePuppetCheck);
GameEvents.PlayerDoTurn.Add(CL_AussieTourismFromSeaTrade);
GameEvents.PlayerDoTurn.Add(CL_AussieCityExpandWithTourism);
Code:
/*-**************-*\
Colonialist Legacies' Australia
Buildings
Civitar
\*-**************-*/
INSERT INTO BuildingClasses (Type, DefaultBuilding, NoLimit) VALUES
('BUILDINGCLASS_CL_AUSTRALIA_PUPPET_TOURISM', 'BUILDING_CL_AUSTRALIA_PUPPET_TOURISM', 1),
('BUILDINGCLASS_CL_AUSTRALIA_TRADE_TOURISM', 'BUILDING_CL_AUSTRALIA_TRADE_TOURISM', 1),
('BUILDINGCLASS_CL_AUSTRALIA_PM_TOURISM', 'BUILDING_CL_AUSTRALIA_PM_TOURISM', 1);
INSERT INTO Buildings (Type, BuildingClass, Cost, GreatWorkCount, TechEnhancedTourism, EnhancedYieldTech, NeverCapture, ShowInPedia) VALUES
('BUILDING_CL_AUSTRALIA_PUPPET_TOURISM', 'BUILDINGCLASS_CL_AUSTRALIA_PUPPET_TOURISM', -1, -1, 1, 'TECH_AGRICULTURE', 1, 0),
('BUILDING_CL_AUSTRALIA_TRADE_TOURISM', 'BUILDINGCLASS_CL_AUSTRALIA_TRADE_TOURISM', -1, -1, 1, 'TECH_AGRICULTURE', 1, 0),
('BUILDING_CL_AUSTRALIA_PM_TOURISM', 'BUILDINGCLASS_CL_AUSTRALIA_PM_TOURISM', -1, -1, 1, 'TECH_AGRICULTURE', 1, 0);
Code:
/*-**************-*\
Colonialist Legacies' Australia
New Database Columns
Civitar
\*-**************-*/
ALTER TABLE UnitPromotions ADD COLUMN 'ShowInPedia' INTEGER DEFAULT 1;
ALTER TABLE UnitPromotions ADD COLUMN 'ShowInUnitPanel' INTEGER DEFAULT 1;
ALTER TABLE Buildings ADD COLUMN 'ShowInPedia' INTEGER DEFAULT 1;
I noticed when playtesting a while back that the founded puppet cities got a Floating Gardens, but I haven't noticed that since...
If anyone can resolve these issues as well as the frequent crashes caused by the New Database Columns code, Henry Parkes thanks you.
