Thanks for all your help. I've got this below working.
function CultureVictory (playerID, cityID, buildingID)
local virtue = 0
local wonderInfo = GameInfo.Buildings["BUILDING_RELIC"]
local wonderID = wonderInfo.ID
local player = Players[playerID]
if playerID == 0 then
virtue = player:GetNumPolicies()
end
if virtue < 3 and buildingID == wonderID then
return false
else
return true
end
end
GameEvents.CityCanConstruct.Add(CultureVictory)
I'm now trying to apply it to the Exodus Gate Project, and I'm having trouble getting it working. I've realized applying it to a project is a bit different, and I've taken a look at the quest lua file, and tried to adapt it but it is not working. This is what I've got.
function CultureVictory (playerID, cityID, projectID)
local virtue = 25
local wonderInfo = GameInfo.Projects["PROJECT_PURITY_GATE"]
local wonderID = wonderInfo.ID
local player = Players[playerID]
local team = Teams[player:GetTeam()]
if playerID == 0 then
virtue = player:GetNumPolicies()
end
if virtue < 25 then
team:SetQuestProjectAllowed(wonderID, false)
else
team:SetQuestProjectAllowed(wonderID, true)
end
end
Of course if this is a pain to get to work for a project, I can just create a new building, make that a prerequisite building for the victory project (which is in the project table already) and then apply the virtue requirement to that building. However, I would like to avoid that if possible, just applying it to the victory project would be cleaner.
EDIT: Nevermind, I got it working. I just had to change the gameevent for the project to CityCanCreate instead of CityCanConstruct