I wanted to make a change to one of my longstanding mods, in order to prevent the AI from producing a unit. I went about it the way I have tackled that problem in other mods - with a dummy building being created for human players via lua, where that building is the prereq for the unit. It is working perfectly fine for me (in a heavily modded vanilla game), but when I uploaded it to the workshop I immediately began receiving messages of how the change broke everyone else's game (players who are using R&F and GS).
Here is the code I added:
LUA
XML
Does anything stick out to those familiar with modding for the expansions?
Thanks in advance.
Here is the code I added:
LUA
Code:
local iBuilding = GameInfo.Buildings["BUILDING_EXPANSIONIST_UNLOCK"].Index;
function OnCityInitializedTC2(playerID, cityID, x, y)
local pPlayer = Players[playerID];
local pCity = pPlayer:GetCities():FindID(cityID);
local cityPlotIndex = Map.GetPlot(pCity:GetX(), pCity:GetY()):GetIndex();
local cityBuildings = pCity:GetBuildings();
local cityBuildQ = pCity:GetBuildQueue();
if pPlayer:IsHuman() then
if not cityBuildings:HasBuilding(iBuilding) then
cityBuildQ:CreateIncompleteBuilding(iBuilding, cityPlotIndex, 100);
end
elseif cityBuildings:HasBuilding(iBuilding) then
cityBuildings:RemoveBuilding(iBuilding);
end
end
Events.CityInitialized.Add(OnCityInitializedTC2);
XML
Code:
<GameInfo>
<Types>
<Row Type="BUILDING_EXPANSIONIST_UNLOCK" Kind="KIND_BUILDING" />
</Types>
<Buildings>
<Row BuildingType="BUILDING_EXPANSIONIST_UNLOCK" Name="Expansionist Unlock" Description="Allows human players to create the Expansionist unit." PrereqDistrict="DISTRICT_CITY_CENTER" Cost="1" AdvisorType="ADVISOR_GENERIC" Maintenance="0"/>
</Buildings>
<BuildingPrereqs>
<Row Building="BUILDING_EXPANSIONIST_UNLOCK" PrereqBuilding="BUILDING_EXPANSIONIST_UNLOCK"/>
</BuildingPrereqs>
<CivilopediaPageExcludes>
<Row SectionId="BUILDINGS" PageId="BUILDING_EXPANSIONIST_UNLOCK" />
</CivilopediaPageExcludes>
</GameInfo>
Does anything stick out to those familiar with modding for the expansions?
Thanks in advance.