for i=0,7 do
flag.define("DivinedPowerEventOngoing"..i,false)
flag.define("BureaucratCityEventOngoing"..i,false)
end
for i=0,7 do
counter.define("DivinedPowerCityLocationID"..i,-1)
counter.define("BureaucratCityLocation"..i,-1)
end
-- PT I
local StandardizedRites = civ.ui.loadImage("Images/standardizedrites.bmp")
if tribe:hasTech(techAliases.StandardizedRites) then
gen.justOnce("SRReceivedBy"..tostring(tribe.id),function()
local choice = nil
if tribe.isHuman then
local dialog = civ.ui.createDialog()
dialog.title = "Select a Local Leader"
dialog.width = 500
dialog:addImage(StandardizedRites)
local multiLineText = "Advisors come to you, bringing two prominent individuals from local tribes: one bureaucrat and one priest.\n^\n^'These leaders seek greater status in your realm. What would you have us do?'\n^\n^"
text.addMultiLineTextToDialog(multiLineText,dialog)
dialog:addOption("Select the bureaucrat to lead a city", 1)
dialog:addOption("Select the priest to lead a city", 2)
dialog:addOption("Put them to death. This is not a democracy!",3)
choice = dialog:show()
else
choice = math.random(1,3)
end
if choice == 1 then
local chosenCity2 = nil
if tribe.isHuman then
local menuTable = {}
local offset = 3
for city in civ.iterateCities() do
if city.owner == civ.getCurrentTribe() then
menuTable[offset+city.id] = city.name
end
end
local bureaucratChoice = text.menu(menuTable,"Select a city for the bureaucrat to lead","A Competent Bureaucrat")
if bureaucratChoice >= offset then
chosenCity2 = civ.getCity(bureaucratChoice-offset)
end
else
local aiChoiceList = {}
local index = 1
for city in civ.iterateCities() do
if city.owner == tribe then
aiChoiceList[index] = city.id
index = index + 1
end
end
if index > 1 then
local aiChoice = aiChoiceList[math.random(1,index-1)]
chosenCity2 = civ.getCity(aiChoice)
end
end
if civ.isCity(chosenCity2) then
chosenCity2:addImprovement(improvementAliases.Improvement16)
flag.setTrue("BureaucratCityEventOngoing"..tribe.id)
counter.setValue("BureaucratCityLocation"..tribe.id,gen.getTileID(chosenCity2.location))
if tribe.isHuman then
civ.ui.text("Your decision to place a competent bureaucrat in power of "..chosenCity2.name.." has made the people there more productive.")
end
end
elseif choice == 2 then
local chosenCity1 = nil
if tribe.isHuman then
local menuTable = {}
local offset = 3
for city in civ.iterateCities() do
if city.owner == civ.getCurrentTribe() then
menuTable[offset+city.id] = city.name
end
end
local priestChoice = text.menu(menuTable,"Select a city for the priest to lead","An Inspiring Priest")
if priestChoice >= offset then
chosenCity1 = civ.getCity(priestChoice-offset)
end
else
local aiChoiceList = {}
local index = 1
for city in civ.iterateCities() do
if city.owner == tribe then
aiChoiceList[index] = city.id
index = index + 1
end
end
if index > 1 then
local aiChoice = aiChoiceList[math.random(1,index-1)]
chosenCity1 = civ.getCity(aiChoice)
end
end
if civ.isCity(chosenCity1) then
chosenCity1:addImprovement(improvementAliases.Tournament)
flag.setTrue("PriestMayor")
if tribe.isHuman then
civ.ui.text("Your decision to place an inspiring priest in power of "..chosenCity1.name.." has made the people there happier!")
end
end
elseif choice == 3 then
gen.createUnit(unitAliases.EliteGuard,civ.getCurrentTribe(),{0,0},{count = 2, randomize = false, scatter = false, inCapital = true, veteran = true, homeCity = nil, overrideCanEnter = false, overrideDomain = false, overrideDefender = false})
flag.setTrue("KilledMayors")
if tribe.isHuman then
civ.ui.text("Elite Guard units have been placed in your capital to prevent charlatans from seeking power in the future.")
end
end
end)
end
-- PT II
discreteEvents.onCityProcessed(function (city)
local tribeID = city.owner.id
if not flag.value("BureaucratCityEventOngoing"..tribeID) then
return
end
if flag.value("BureaucratCityEventOngoing"..tribeID) and math.random() < 0.90 then
local choice = nil
local chosenCity2 = gen.getTileFromID(counter.value("BureaucratCityLocation"..tribeID)).city
if tribe.isHuman then
local dialog = civ.ui.createDialog()
dialog.title = "A Local Leader Grows Restless"
dialog.width = 500
local multiLineText = "The leader of "..chosenCity2.name..", a prominent bureaucrat who you previously selected, has come to you with terms. 'Give me more gold for my services, or I shall take them elsewhere!'"
text.addMultiLineTextToDialog(multiLineText,dialog)
if tribe.money >= 100 then
dialog:addOption("Pay this local leader. They have done a fine job. (-100 gold)", 1)
end
dialog:addOption("We cannot afford these terms. Send them on their way.", 2)
if math.random() < 0.50 then
dialog:addOption("This leader enjoys a comfortable lifestyle. Threaten them, and see what happens.", 3)
end
dialog:addOption("It is time to send a message to other chieftains. Find me a spike for this 'leader's' head.",4)
choice = dialog:show()
else
choice = math.random(1,4)
if tribe.money < 100 then
choice = 1
end
end
if choice == 1 then
tribe.money = math.max(0,tribe.money - 100)
flag.setTrue("BureaucratCityEventOngoing"..tribeID)
if tribe.isHuman then
civ.ui.text("Your payment has satiated the leader of "..chosenCity2.name..".")
end
elseif choice == 2 then
chosenCity2:removeImprovement(improvementAliases.Improvement16)
flag.setFalse("BureaucratCityEventOngoing"..tribeID)
if tribe.isHuman then
civ.ui.text("Dissatisfied, this leader has chosen to leave "..chosenCity2.name.." for greener pastures.")
end
elseif choice == 3 then
tribe.money = math.max(0,tribe.money + 100)
if tribe.isHuman then
civ.ui.text("Embarrassed by their demands, this leader has not only opted to stay, but has also given tribute to your realm.")
end
elseif choice == 4 then
chosenCity2:removeImprovement(improvementAliases.Improvement16)
flag.setFalse("BureaucratCityEventOngoing"..tribeID)
tribe.money = math.max(0,tribe.money + 1000)
if tribe.isHuman then
civ.ui.text("Troops have raided the estate of this leader, taking in countless treasures, along with their head. This bureaucrat had grown fat on the riches of their constituents. Good riddance!")
end
end
end
end)