--------------------------------------------------------------
-- UA: Négritude - +2 Griot points are earned for your capital when your units kill, or are killed. Get 25 culture for each enemy killed. Embarked units pay just one movement to disembark to land.
-- UU: Gendarmerie - Replaces Infantry. When garrisoned in a city, the city's spy stealing rate reduced 10%, has +5 defence and generates +2 culture.
-- UU: Griot - Replaces Great Musician. Slower. When in a 3-tile radius of your city's territory, the city produces +1 happiness, +3 culture and +10% tourism. Only 1 set of effects per city. (For the AI, this simply happens 40% of the time regardless)
----------------------------------------------------------------------------------------------------------------------------
-- GLOBAL VARIABLES
----------------------------------------------------------------------------------------------------------------------------
local senegalID = GameInfoTypes["CIVILIZATION_SENEGAL"]
local specialistGriotID = GameInfoTypes["SPECIALIST_MUSICIAN"]
local gendarmerieID = GameInfoTypes["UNIT_GENDARMERIE"]
local griotID = GameInfoTypes["UNIT_GRIOT"]
local gendarmerieDummyBuildingID = GameInfoTypes["BUILDING_GENDARMERIE_DUMMY"]
local griotDummyBuildingID = GameInfoTypes["BUILDING_GRIOT_DUMMY"]
local musiciansGuildID = GameInfoTypes["BUILDING_MUSICIANS_GUILD"]
local broadwayID = GameInfoTypes["BUIDLING_BROADWAY"]
local libertyBranchID = PolicyBranchTypes["POLICY_BRANCH_LIBERTY"]
----------------------------------------------------------------------------------------------------------------------------
---- WilliamHoward's IsCivInPlay
----------------------------------------------------------------------------------------------------------------------------
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
----------------------------------------------------------------------------------------------------------------------------
-- UA: NÉGRITUDE
----------------------------------------------------------------------------------------------------------------------------
function GriotPointsWhenUnitDie(iPlayer, iKilledPlayer, iKilledUnit)
local pKillingPlayer = Players[iPlayer]
local pKilledPlayer = Players[iKilledPlayer]
if (pKillingPlayer:GetCivilizationType() == senegalID) or (pKilledPlayer:GetCivilizationType() == senegalID) then
local griotPoints = 2
local griotCity = pKillingPlayer:GetCapitalCity()
if (pKillingPlayer:GetCivilizationType() ~= senegalID) then
griotCity = pKilledPlayer:GetCapitalCity()
end
griotCity:ChangeSpecialistGreatPersonProgressTimes100(specialistGriotID, griotPoints*100)
if pKillingPlayer:IsHuman() then
Events.GameplayAlertMessage("Your unit has killed an enemy! Your capital gains 2 [ICON_GREAT_PEOPLE] Great Griot Points!")
elseif pKilledPlayer:IsHuman() then
Events.GameplayAlertMessage("Your unit was killed by an enemy. Your capital gains 2 [ICON_GREAT_PEOPLE] Great Griot Points!")
end
end
end
if (IsCivInPlay(senegalID) == true) then
local pPlayer = Players[iPlayer]
if (pPlayer:GetCivilizationType() == senegalID) then
for pCity in pPlayer:Cities() do
if (pCity:IsHasBuilding(musiciansGuildID) == true) or if (pCity:IsHasBuilding(broadwayID) == true) or if (pPlayer:IsPolicyBranchFinished(libertyBranchID) == true) then
GameEvents.UnitKilledInCombat.Add(GriotPointsWhenUnitDie)
end
end
end
end
----------------------------------------------------------------------------------------------------------------------------
-- UU Boosts (Gendarmerie boosted by city garrison and Griot boosted by city limits)
----------------------------------------------------------------------------------------------------------------------------
function UUBoosts(iPlayer)
local pPlayer = Players[iPlayer]
if (pPlayer:GetCivilizationType() == senegalID) then
local tUnitsAlreadyProcessed = {}
for pCity in pPlayer:Cities() do
pCity:SetNumRealBuilding(griotDummyBuildingID, 0)
pCity:SetNumRealBuilding(gendarmerieDummyBuildingID, 0)
local pCityPlot = pCity:Plot()
if pCityPlot:IsUnit() then -- Gendarmerie Boost
for i = 0, (pCityPlot:GetNumUnits() - 1) do
local pUnit = pCityPlot:GetUnit(i)
if pUnit then
if (pUnit:GetUnitType() == gendarmerieID) and (pUnit:GetOwner() == iPlayer) then
pCity:SetNumRealBuilding(gendarmerieDummyBuildingID, 1)
end
end
end
end
if (pPlayer:IsHuman() == true) then --------------------------------- Griot Boost if Player is Human
for iPlot = 0, pCity:GetNumCityPlots() - 1, 1 do
local pCityTerritoryPlot = pCity:GetCityIndexPlot(iPlot)
if (pCityTerritoryPlot:GetOwner() == iPlayer) then
if pCityTerritoryPlot:IsUnit() then
for iUnit = 0, (pCityTerritoryPlot:GetNumUnits() - 1) do
local pUnit = pCityTerritoryPlot:GetUnit(iUnit)
if pUnit then
if (pUnit:GetUnitType() == griotID) and (pUnit:GetOwner() == iPlayer) then
local iUnitID = pUnit:GetID()
if not tUnitsAlreadyProcessed[iUnitID] then
--if the unit's ID# has not already been added as a "key" in the table, add the dummy building
--then add the unit's ID# as a "Key" in the table with a value of text "processed"
pCity:SetNumRealBuilding(griotDummyBuildingID, 1)
tUnitsAlreadyProcessed[iUnitID] = "processed"
end
end
end
end
end
end
end
end
if (pPlayer:IsHuman() == false) then --------------------------------- Griot Boost if Player is not Human
if (pCity:IsHasBuilding(musiciansGuildID) == true) or if (pCity:IsHasBuilding(broadwayID) == true) or if (pPlayer:IsPolicyBranchFinished(libertyBranchID) == true) then
if math.random( 0 , 100) <= 40 then
pCity:SetNumRealBuilding(griotDummyBuildingID, 1)
end
for iPlot = 0, pCity:GetNumCityPlots() - 1, 1 do
local pCityTerritoryPlot = pCity:GetCityIndexPlot(iPlot)
if (pCityTerritoryPlot:GetOwner() == iPlayer) then
if pCityTerritoryPlot:IsUnit() then
for iUnit = 0, (pCityTerritoryPlot:GetNumUnits() - 1) do
local pUnit = pCityTerritoryPlot:GetUnit(iUnit)
if pUnit then
if (pUnit:GetUnitType() == griotID) and (pUnit:GetOwner() == iPlayer) then
local iUnitID = pUnit:GetID()
if not tUnitsAlreadyProcessed[iUnitID] then
--if the unit's ID# has not already been added as a "key" in the table, add the dummy building
--then add the unit's ID# as a "Key" in the table with a value of text "processed"
pCity:SetNumRealBuilding(griotDummyBuildingID, 1)
tUnitsAlreadyProcessed[iUnitID] = "processed"
end
end
end
end
end
end
end
end
end
end
end
GameEvents.PlayerDoTurn.Add(UUBoosts)