Resource icon

Removable Districts 1.1.3

When I download version 1.1.1 I get a 2.69kb .rar file that 7zip and winrar don't recognize as a valid archive. Is the file link broken or am I doing something wrong?
I reuploaded it in zip archive. The mod is also on steam workshop.
 
Thanks for sharing this mod :)

I like to reduce the cost of this removal projects.
I found some settings and I wonder if this is correct:

RemovableDistricts.sql
----------------------------------------------------------------------
'Removes the district with all its buildings.',
80,
'COST_PROGRESSION_GAME_PROGRESS',
200,
-- 'TECH_ENGINEERING',
-----------------------------------------------------------------------

Is 80 the production cost needed?
What is 200?

Some thoughts on this would be great :)
 
Few years ago I made this mod also work for districts that where not fully built yet. The only downside is, that these projects currently are always available.
If someone is interested, change line 27 from "DistrictType" to NULL (will remove PrereqDistrict) and use this lua (replace whole current lua code):
Spoiler :
Code:
print ("REMOVABLE  DISTRICTS  LOADED");

local function OnProjectCompleted(playerID, cityID, projectIndex, buildingIndex, locX, locY, bCanceled)
   local pPlayer = Players[playerID];
   local sProjectTypeCompleted = GameInfo.Projects[projectIndex].ProjectType;
    -- print("project "..sProjectTypeCompleted.." completed "..playerID.." projectIndex:"..tostring(projectIndex).." buildingIndex:"..tostring(buildingIndex).." bCanceled:"..tostring(bCanceled))

   if pPlayer:IsHuman() and string.find(sProjectTypeCompleted, "PROJECT_REMOVE_DISTRICT_") then
       local sCivType = PlayerConfigurations[playerID]:GetCivilizationTypeName();
       local pCity = pPlayer:GetCities():FindID( cityID );
       local pCityDistricts :table   = pCity:GetDistricts();
        local sDistrictName = ""
        local count = 0; -- first loop is "DISTRICT"
        local pPlot;
        local x, y;
        for n in string.gmatch(sProjectTypeCompleted.."_", "(.-)_") do
            if count>2 then
                if count==3 then
                    sDistrictName = sDistrictName..n
                else
                    sDistrictName = sDistrictName.."_"..n
                end
            end
            count = count+1;
        end
       local sDistrictType = "DISTRICT_"..sDistrictName --GameInfo.Projects[projectIndex].PrereqDistrict; -- removed PrereqDistrict to allow removing it if you only placed the construction site
       local iDistrictID = GameInfo.Districts[sDistrictType].Index;

       for row in GameInfo.RD_civType_uniqueDistrictType() do
           if row.CivType == sCivType and row.ReplacedDistrictType == sDistrictType then
               iDistrictID = GameInfo.Districts[row.UniqueDistrictType].Index;
               break;
           end
       end
    
        local pCityDistricts = pCity:GetDistricts();
        if pCityDistricts:HasDistrict( iDistrictID ) then
            local buildQueue = pCity:GetBuildQueue()
            pCityDistricts:RemoveDistrict(iDistrictID); -- does not remove construction site
            buildQueue:RemoveDistrict(iDistrictID); -- removes construction site
        end
   elseif not pPlayer:IsHuman() and string.find(sProjectTypeCompleted, "PROJECT_REMOVE_DISTRICT_") then
       print("error: An AI build the remove district project! Write code to disable it for AI!");
   end
end

Events.CityProjectCompleted.Add(OnProjectCompleted);


local function OnnProductionChanged(playerID, cityID, productionID, objectID, bCanceled) -- since PrereqDistrict is removed, prevent players from doing a project without having the district placed
    if productionID==3 then -- it is a project
        local sProjectType = GameInfo.Projects[objectID];
        if sProjectType ~= nil then
            productionName = sProjectType.ProjectType;
            if string.find(productionName, "PROJECT_REMOVE_DISTRICT_") then
                local pPlayer = Players[playerID];
                local sCivType = PlayerConfigurations[playerID]:GetCivilizationTypeName();
                local pCity = pPlayer:GetCities():FindID( cityID );
                local pCityDistricts :table   = pCity:GetDistricts();
                local sDistrictName = ""
                local count = 0; -- first loop is "DISTRICT"
                for n in string.gmatch(productionName.."_", "(.-)_") do
                    if count>2 then
                        if count==3 then
                            sDistrictName = sDistrictName..n
                        else
                            sDistrictName = sDistrictName.."_"..n
                        end
                    end
                    count = count+1;
                end
                local sDistrictType = "DISTRICT_"..sDistrictName --GameInfo.Projects[projectIndex].PrereqDistrict; -- removed PrereqDistrict to allow removing it if you only placed the construction site
                local iDistrictID = GameInfo.Districts[sDistrictType].Index;

                for row in GameInfo.RD_civType_uniqueDistrictType() do
                    if row.CivType == sCivType and row.ReplacedDistrictType == sDistrictType then
                        -- print(row.UniqueDistrictType .." unique ");
                        iDistrictID = GameInfo.Districts[row.UniqueDistrictType].Index;
                        break;
                    end
                end
            
                local pCityDistricts = pCity:GetDistricts();
                local buildQueue = pCity:GetBuildQueue();
                if not pCityDistricts:HasDistrict( iDistrictID ) then
                    buildQueue:FinishProgress();
                else -- if there is already a construction site or finished
                    local pDistrict = pCityDistricts:GetDistrict(iDistrictID)
                    if pDistrict~=nil and not pDistrict:IsComplete() then -- if it is still under construction, allow instant removal. otherwise continue production with normal production costs to remove
                        buildQueue:FinishProgress();
                    end
                end
            end
        end
    end
    -- print("production changed "..playerID..", productionID: "..tostring(productionID).." objectID:"..tostring(objectID).." bCanceled:"..tostring(bCanceled));
end
Events.CityProductionChanged.Add(OnnProductionChanged);
Since I removed the "PrereqDistrict", to allow doing the project before the district is build, I used string.gmatch to find the proper district name instead.
And beware:
I wrote this code end 2018 for the base game of Civ6. No clue if it still works or also works for new districts.

@ Taa The 80 is the cost, in case you still wonder :D
 
Been playing it again a bit lately... Still works, mostly. Neither qqq's nor Serp's versions seem able to remove the Water Park district, or Canals. Not sure why it's not being picked up. Even putting in the NULL to remove the pre-req, it's not on the list of possible projects.
 
Last edited:
Back
Top Bottom