Hi!
I'm working to include support for Sukritact's Events and Decisions in my Sikh Empire civ but I'm running into some problems with how to implement my design.
The decision I have in mind is:
I have been able to make a decision that detects whether you:
- play as Sikh
- have 600 gold
- have 2 magistrates
- have researched Architecture
And if that's true you can enact it upon which the game will:
- take 600 gold away from you
- take 2 magistrates away from you
But the decision is still missing the main point which I just can't work out how to add. I want the game to go through all of the player's cities to see if they have a BUILDING_GURDWARA in a city they founded themselves (mostly to avoid puppets). Then I want it to pick one of those cities, and when the decision is enacted build the BUILDING_GURRA_HARMANDIR world wonder in the chosen city.
Basically, I want to add 'one city founded by the player, with Gurdwara' to the CanFunc function and add 'Build Harmandir Sahib wonder in one of the cities with a Gurdwara' to the DoFunc function.
How would I accomplish that? Is it even possible? I tried to find something similar among the civ specific decisions provided in E&D itself but the only ones I found built the building in the capital city.
(I do not want the player to be able to choose which city with a Gurdwara to build it in, I want it to be random and for there to only be one decision in the list. I already tried a method where I got one decision for each possible city using tTempDecisions.)
-------------------------------------------------------------------------------------------------
And if what I'm looking to achieve is possible, would it be possible to refine the way the function chooses city like this?
1 Go through all cities. Then:
2 If a city has a Gurdwara and all three of Writer's Guild, Artist's Guild and Musicians Guild: pick that city. Else:
3 If a city has a Gurdwara and two of the three Guilds: pick that city. Else:
4 Pick a city that has a Gurdwara and one of the three Guilds. Else:
5 Pick any city that has a Gurdwara.
So, if there are Guilds the wonder will preferrably be placed in those cities but Guilds are no requirement to enact the decision.
I'm working to include support for Sukritact's Events and Decisions in my Sikh Empire civ but I'm running into some problems with how to implement my design.
The decision I have in mind is:
Restrictions/Requirements:
- Player is Sikh
- Must have researched Architecture
- Must have built Gurdwara (unique Temple replacement) in at least one city founded by the player
Costs:
- 600 gold
- 2 magistrates
Rewards:
- Harmandir Sahib (world wonder) is built in a city founded by the player which has a Gurdwara
I have been able to make a decision that detects whether you:
- play as Sikh
- have 600 gold
- have 2 magistrates
- have researched Architecture
And if that's true you can enact it upon which the game will:
- take 600 gold away from you
- take 2 magistrates away from you
Code:
-- SikhEmpire_Decisions
-- Author: Almgren
-- DateCreated: 6/7/2015 4:37:10 PM
--------------------------------------------------------------
local Decisions_GurraSikhHarmandir = {}
Decisions_GurraSikhHarmandir.Name = "TXT_KEY_DECISIONS_GURRASIKHHARMANDIR"
Decisions_GurraSikhHarmandir.Desc = "TXT_KEY_DECISIONS_GURRASIKHHARMANDIR_DESC"
HookDecisionCivilizationIcon(Decisions_GurraSikhHarmandir, "CIVILIZATION_GURRA_SIKH")
Decisions_GurraSikhHarmandir.CanFunc = (
function(pPlayer)
if (pPlayer:GetCivilizationType() ~= GameInfoTypes.CIVILIZATION_GURRA_SIKH) then
return false, false
end
if load(pPlayer, "Decisions_GurraSikhHarmandir") == true then
Decisions_GurraSikhHarmandir.Desc = Locale.ConvertTextKey("TXT_KEY_DECISIONS_GURRASIKHHARMANDIR_ENACTED_DESC")
return false, false, true
end
local iCost = math.ceil(600 * iMod)
Decisions_GurraSikhHarmandir.Desc = Locale.ConvertTextKey("TXT_KEY_DECISIONS_GURRASIKHHARMANDIR_DESC", iCost)
if (pPlayer:GetGold() < iCost) then return true, false end
if (pPlayer:GetNumResourceAvailable(iMagistrate, false) < 2) then return true, false end
if not(Teams[pPlayer:GetTeam()]:IsHasTech(GameInfoTypes.TECH_ARCHITECTURE)) then return true, false end
return true, true
end
)
Decisions_GurraSikhHarmandir.DoFunc = (
function(pPlayer)
local iCost = math.ceil(600) * iMod
pPlayer:ChangeGold(-iCost)
pPlayer:ChangeNumResourceTotal(iMagistrate, -2)
save(pPlayer, "Decisions_GurraSikhHarmandir", true)
end
)
Decisions_AddCivilisationSpecific(GameInfoTypes.CIVILIZATION_GURRA_SIKH, "Decisions_GurraSikhHarmandir", Decisions_GurraSikhHarmandir)
But the decision is still missing the main point which I just can't work out how to add. I want the game to go through all of the player's cities to see if they have a BUILDING_GURDWARA in a city they founded themselves (mostly to avoid puppets). Then I want it to pick one of those cities, and when the decision is enacted build the BUILDING_GURRA_HARMANDIR world wonder in the chosen city.
Basically, I want to add 'one city founded by the player, with Gurdwara' to the CanFunc function and add 'Build Harmandir Sahib wonder in one of the cities with a Gurdwara' to the DoFunc function.
How would I accomplish that? Is it even possible? I tried to find something similar among the civ specific decisions provided in E&D itself but the only ones I found built the building in the capital city.
(I do not want the player to be able to choose which city with a Gurdwara to build it in, I want it to be random and for there to only be one decision in the list. I already tried a method where I got one decision for each possible city using tTempDecisions.)
-------------------------------------------------------------------------------------------------
And if what I'm looking to achieve is possible, would it be possible to refine the way the function chooses city like this?
1 Go through all cities. Then:
2 If a city has a Gurdwara and all three of Writer's Guild, Artist's Guild and Musicians Guild: pick that city. Else:
3 If a city has a Gurdwara and two of the three Guilds: pick that city. Else:
4 Pick a city that has a Gurdwara and one of the three Guilds. Else:
5 Pick any city that has a Gurdwara.
So, if there are Guilds the wonder will preferrably be placed in those cities but Guilds are no requirement to enact the decision.