City Center requirements for building?

g.bromios

Chieftain
Joined
Sep 24, 2007
Messages
11
Pretty new to civ6 modding, sorry if I'm missing something obvious. The "New Building" template in modbuddy has gotten me like 99% of the way there, but I'm just missing one thing:

I'm trying to add a new city center building that's only allowed if the city was built on, say, a desert or desert hills. The only equivalent behavior I can think of is the WATER_MILL, which uses the attribute
Code:
RequiresAdjacentRiver="true"
, and I'm assuming that there won't be an equivalent attribute for desert...

Is what I'm trying to accomplish possible?
 
Last edited:
Looked around a bit and found that I was right in guessing it more complicated than just a single attribute on the Building row :p


I will try implementing this using a dummy building and report back...
 
update: it worked, good times. I think there may be some way to use a modifier + effect to grant the dummy building, but I found it much more straightforward to add a lua script:

Code:
function MP_OnCityBuilt(playerId, cityId, x, y)
  print('CALLED ON CITY BUILT', playerId, cityId)
  local player = Players[playerId]
  local city = player:GetCities():FindID(cityId)
  local plot = city:GetPlot()
  -- if the city is on desert and has freshwater access, build the dummy
  if shouldAddDummy(city, plot, nil) then buildDummy(city, plot) end
end

function MP_OnDistBuilt(playerId, dType, x, y)
  local player = Players[playerId]
  local plot = Map.GetPlot(x, y)
  local dist = player:GetDistricts():FindID(plot:GetDistrictID())
  local city = dist:GetCity()
  plot = city:GetPlot() -- x, y is the district
  -- if the district is an aqueduct or bath and the city is on desert, build the dummy
  if shouldAddDummy(city, plot, dist) then buildDummy(city, plot) end
end

GameEvents.CityBuilt.Add(MP_OnCityBuilt)
GameEvents.OnDistrictConstructed.Add(MP_OnDistBuilt)

the other code's pretty ugly from debugging, but this seems to work well
 
Top Bottom