Mezzzzz
Chieftain
Hello,
LastSword's Haida civilization unique building has a feature I'd like to re-use. See snippet below;
Currently : A city where the UB is built will yield an additional culture point every time a GP appears.
What I'd like: A city where the UB is built will yield an additional culture point every time a GP is consumed.
LastSword's Haida civilization unique building has a feature I'd like to re-use. See snippet below;
Spoiler :
Code:
--Totem Pole
HaidaGPCount = {}
HaiPolOn = false;
for i = 0, 70 do
HaidaGPCount[i] = 0;
end
Events.SerialEventUnitCreated.Add(function(player, unit, hexVec, unitType)
if not HaiPolOn then
if Players[player]:GetCivilizationType() == GameInfoTypes.CIVILIZATION_HAIDA_MOD_LS then
local bUnit = Players[player]:GetUnitByID(unit);
if bUnit:IsGreatPerson() then
HaidaGPCount[player] = HaidaGPCount[player] + 1;
end
end
end
end)
Events.SerialEventUnitDestroyed.Add(function(player, unit)
if( Players[player]:GetCivilizationType() == GameInfoTypes.CIVILIZATION_HAIDA_MOD_LS) then
HaidaGPCount[player] = 0;
for iUnit in Players[player]:Units() do
if iUnit:IsGreatPerson() then
HaidaGPCount[player] = HaidaGPCount[player] + 1;
end
end
end
end)
Events.SerialEventDawnOfManHide.Add(function(civID)
HaiPolOn = true;
end)
Events.SerialEventUnitCreated.Add(function(player, unit, hexVec, unitType)
if HaiPolOn then
if Players[player]:GetCivilizationType() == GameInfoTypes.CIVILIZATION_HAIDA_MOD_LS then
if Players[player]:GetUnitByID(unit) ~= nil then
local bUnit = Players[player]:GetUnitByID(unit);
if bUnit:IsGreatPerson() then
HaidaGreatePeople(player, bUnit)
end
end
end
end
end)
function HaidaGreatePeople(player, bUnit)
HaidaHelpCount = 0;
for iUnit in Players[player]:Units() do
if iUnit:IsGreatPerson() then
HaidaHelpCount = HaidaHelpCount + 1;
end
end
if HaidaHelpCount > HaidaGPCount[player] then
HaidaGPCount[player] = HaidaGPCount[player] + 1;
local bPlot = bUnit:GetPlot();
helpHaidaDist = 9999;
for HaiCity in Players[player]:Cities() do
local iPlot = HaiCity:Plot();
local DistanceHelp = Map.PlotDistance(iPlot:GetX(), iPlot:GetY(), bPlot:GetX(), bPlot:GetY());
if ( helpHaidaDist > DistanceHelp ) then
helpHaidaDist = DistanceHelp;
haiCityHelp = HaiCity;
end
end
if ( haiCityHelp:IsHasBuilding(GameInfoTypes.BUILDING_TOTEM_POLE) ) then
local ChangeTotem = 1 + haiCityHelp:GetBuildingYieldChange(GameInfoTypes.BUILDINGCLASS_MONUMENT, GameInfoTypes.YIELD_CULTURE);
haiCityHelp:SetBuildingYieldChange(GameInfoTypes.BUILDINGCLASS_MONUMENT, GameInfoTypes.YIELD_CULTURE, ChangeTotem);
haiCityHelp:ChangeJONSCulturePerTurnFromBuildings(1);
end
end
end
--Totem Pole lost city
GameEvents.CityCaptureComplete.Add(function(iOldOwner, bIsCapital, iX, iY, iNewOwner, iPop, bConquest)
if ( Players[iOldOwner]:GetCivilizationType() == GameInfoTypes.CIVILIZATION_HAIDA_MOD_LS) then
local kplot = Map.GetPlot(iX, iY);
local kCity = kplot:GetPlotCity();
local ChangeTotem = -1 * kCity:GetBuildingYieldChange(GameInfoTypes.BUILDINGCLASS_MONUMENT, GameInfoTypes.YIELD_CULTURE);
kCity:ChangeJONSCulturePerTurnFromBuildings(ChangeTotem);
kCity:SetBuildingYieldChange(GameInfoTypes.BUILDINGCLASS_MONUMENT, GameInfoTypes.YIELD_CULTURE, 0);
end
end)
What I'd like: A city where the UB is built will yield an additional culture point every time a GP is consumed.