local Decisions_SacrificeTheMightiest = {}
Decisions_SacrificeTheMightiest.Name = "TXT_KEY_DECISIONS_MASSAGETAE_SACRIFICE_THE_MIGHTIEST"
Decisions_SacrificeTheMightiest.Desc = "TXT_KEY_DECISIONS_MASSAGETAE_SACRIFICE_THE_MIGHTIEST_DESC"
HookDecisionCivilizationIcon(Decisions_SacrificeTheMightiest, "CIVILIZATION_MASSAGETAE")
Decisions_SacrificeTheMightiest.CanFunc = (
function(pPlayer)
if (pPlayer:GetCivilizationType() ~= GameInfoTypes["CIVILIZATION_MASSAGETAE"]) then return false, false end
if pPlayer:GetCapitalCity() then
local era = load(pPlayer, "Decisions_SacrificeTheMightiest")
local currentEra = pPlayer:GetCurrentEra()
if era ~= nil then
if era < currentEra then
save(pPlayer, "Decisions_SacrificeTheMightiest", nil)
else
Decisions_SacrificeTheMightiest.Desc = Locale.ConvertTextKey("TXT_KEY_DECISIONS_MASSAGETAE_SACRIFICE_THE_MIGHTIEST_ENACTED")
return false, false, true
end
end
local unitLevel = 0
local hasUnit = false
local plot = pPlayer:GetCapitalCity():Plot()
for iVal = 0,(plot:GetNumUnits() - 1) do
local unit = plot:GetUnit(iVal)
if unit:GetUnitType() == GameInfoTypes["UNIT_GREAT_GENERAL"] then
unitLevel = 5
hasUnit = true
break
elseif unit and unit:GetUnitCombatType() == GameInfoTypes["UNITCOMBAT_MOUNTED"] then
unitLevel = unit:GetLevel()
if unitLevel > 5 then
unitLevel = 5
end
hasUnit = true
break
end
end
local iFaith = pPlayer:GetFaithPerTurnFromCities() * unitLevel
local iCulture = pPlayer:GetJONSCulturePerTurnFromCities() * unitLevel
Decisions_SacrificeTheMightiest.Desc = Locale.ConvertTextKey("TXT_KEY_DECISIONS_MASSAGETAE_SACRIFICE_THE_MIGHTIEST_DESC", iFaith, iCulture)
if hasUnit == true then
return true, true
else
return true, false
end
end
[COLOR="Red"])[/COLOR]
Decisions_SacrificeTheMightiest.DoFunc = (
function(pPlayer)
local unitLevel = 0
local plot = pPlayer:GetCapitalCity():Plot()
local killUnit
for iVal = 0,(plot:GetNumUnits() - 1) do
local unit = plot:GetUnit(iVal)
if unit:GetUnitType() == GameInfoTypes["UNIT_GREAT_GENERAL"] then
unitLevel = 5
killUnit = unit
break
elseif unit and unit:GetUnitCombatType() == GameInfoTypes["UNITCOMBAT_MOUNTED"] then
unitLevel = unit:GetLevel()
if unitLevel > 5 then
unitLevel = 5
end
killUnit = unit
break
end
end
local iFaith = pPlayer:GetFaithPerTurnFromCities() * unitLevel
local iCulture = pPlayer:GetJONSCulturePerTurnFromCities() * unitLevel
pPlayer:ChangeFaith(iFaith)
pPlayer:ChangeJONSCulture(iCulture)
for loopPlot in PlotAreaSweepIterator(plot, 1, SECTOR_NORTH, DIRECTION_CLOCKWISE, DIRECTION_OUTWARDS, CENTRE_INCLUDE) do
local otherUnit = loopPlot:GetUnit()
if otherUnit then
if unitLevel == 1 then
otherUnit:ChangeExperience(5)
elseif unitLevel == 2 then
otherUnit:ChangeExperience(10)
elseif unitLevel == 3 then
otherUnit:ChangeExperience(15)
elseif unitLevel == 4 then
otherUnit:ChangeExperience(20)
elseif unitLevel == 5 then
otherUnit:ChangeExperience(25)
end
end
end;
killUnit:Kill(true)
save(pPlayer, "Decisions_SacrificeTheMightiest", pPlayer:GetCurrentEra())
end
)
Decisions_AddCivilisationSpecific(GameInfoTypes["CIVILIZATION_MASSAGETAE"], "Decisions_SacrificeTheMightiest", Decisions_SacrificeTheMightiest)