whoward69
DLL Minion
pPlot:SetOwner() requires (at least) two parameters - owning player AND owning city, so it should be plot:SetOwner(iPlayer, pCity:GetID())
-- PlantationMilitary
-- Author: Sasquatch
-- DateCreated: 7/17/2014 1:13:31 AM
--------------------------------------------------------------
local Yucaunit = "BUILDING_YUCAUNIT"
function FindYucatanPlantations(PlayerID)
local pPlayer = Players[PlayerID]
if pPlayer:GetCivilizationType() == GameInfoTypes.CIVILIZATION_YUCATAN then
for pCity in pPlayer:Cities() do
local pTeam = Teams[pPlayer:GetTeam()]
for pCityPlot = 0, pCity:GetNumCityPlots() - 1, 1 do
local pSpecificPlot = pCity:GetCityIndexPlot(pCityPlot)
if pSpecificPlot ~= nil then
if pSpecificPlot:GetOwner() == pCity:GetOwner() then
if pSpecificPlot:GetImprovementType() == GameInfoTypes.IMPROVEMENT_PLANTATION then
if pCity:IsWorkingPlot(pSpecificPlot) then
pCity:SetNumRealBuilding(GameInfoTypes["" .. Yucaunit .. ""], 1)
end
end
end
end
end
end
end
end
end
GameEvents.PlayerDoTurn.Add(FindYucatanPlantations)
-- CaliforniasGoldAge
-- Author: JFD + LeeS
-- DateCreated: 6/30/2014 3:49:26 PM
--------------------------------------------------------------
GameEvents.PlayerDoTurn.Add(function(iPlayer)
local pPlayer = Players[iPlayer];
if pPlayer:GetCivilizationType() == GameInfoTypes["CIVILIZATION_CALIFORNIA"] then
for pCity in pPlayer:Cities() do
if pPlayer:IsGoldenAge() then
if not pCity:IsHasBuilding(GameInfoTypes.BUILDING_CALIFORNIAGOLDAGE) then
pCity:SetNumRealBuilding(GameInfoTypes.BUILDING_CALIFORNIAGOLDAGE, 1);
end
else
if pCity:IsHasBuilding(GameInfoTypes.BUILDING_CALIFORNIAGOLDAGE) then
pCity:SetNumRealBuilding(GameInfoTypes.BUILDING_CALIFORNIAGOLDAGE, 0);
end
end
end
end
end
end)
pPlot:SetOwner() requires (at least) two parameters - owning player AND owning city, so it should be plot:SetOwner(iPlayer, pCity:GetID())
Can anyone tell me how to make a loop to check every unit in the tile?
local iNumUnits = pPlot:GetNumUnits();
local pUnit;
-- Loop through all Units
for i = 0, iNumUnits do
pUnit = pPlot:GetUnit(i);
if (pUnit:GetUnitType() == GameInfoTypes["UNIT_COLONIST"]) then
(...)
function OnCityFounded(iPlayer, iCityX, iCityY)
local pPlayer = Players[iPlayer];
if (pPlayer == nil) then return; end
local pPlot = Map.GetPlot(iCityX, iCityY);
if (pPlot == nil) then return; end
local pCity = pPlot:GetPlotCity();
if (pCity == nil) then return; end
local plot = pCity:GetNextBuyablePlot();
plot:SetOwner(pPlayer, pCity);
(...)
GameEvents.PlayerCityFounded.Add( OnCityFounded );
Would it be possible to have one building do this? Have a single special building output +16+2from unemployed citizens
Same as above, only tourism and happiness are of course much harder to work with than actual yields.+1or +1
from unemployed citizens
<Building_SpecialistYieldChanges>
<Row>
<BuildingType>BUILDING_XXX</BuildingType>
<SpecialistType>SPECIALIST_CITIZEN</SpecialistType>
<YieldType>YIELD_FOOD</YieldType>
<Yield>2</Yield>
</Row>
</Building_SpecialistYieldChanges>
UltimatePotato, +2 food from unemployed citizens should be easy. Use:
Ensure the player only has one copy of the building at a time (the effect is global across the player's empire).Spoiler :Code:<Building_SpecialistYieldChanges> <Row> <BuildingType>BUILDING_XXX</BuildingType> <SpecialistType>SPECIALIST_CITIZEN</SpecialistType> <YieldType>YIELD_FOOD</YieldType> <Yield>2</Yield> </Row> </Building_SpecialistYieldChanges>
As for happiness and tourism, that will be much trickier.
It should be simpler (though still impossible for meBuilding XXX
+equal to the number of citizens in this city
It should be simpler (though still impossible for meBuilding XXX
+equal to the number of citizens in this city
). What would the Lua file look like, and how would the building XML reference it. That's really all I need to get started.
<Building_YieldChangesPerPop>
<Row>
<BuildingType>BUILDING_XXX</BuildingType>
<YieldType>YIELD_PRODUCTION</YieldType>
<Yield>100</Yield>
</Row>
</Building_YieldChangesPerPop>
If you mean all population in the city, not just SPECIALIST_CITIZEN, it's very simple and doesn't require Lua at all - just use the Building_YieldChangesPerPop table:
Code:<Building_YieldChangesPerPop> <Row> <BuildingType>BUILDING_XXX</BuildingType> <YieldType>YIELD_PRODUCTION</YieldType> <Yield>100</Yield> </Row> </Building_YieldChangesPerPop>
(100 means 1 production per citizen, you can adjust this value to get fractional amounts)
Hello fellow modders. I'm at my wits end when it comes to Lua and won't be able to do any of this without help.
I'm trying to work around unemployed citizens, known as SPECIALIST_CITIZEN in XML files, and DEFAULT_SPECIALIST in the DLL. They are hard coded in the DLL and cannot receive updates to their yields. All we can do is count them and let buildings/dummies do the yielding. Here's what I'm after.
Would it be possible to have one building do this? Have a single special building output +16if there are 8 unemployed citizens, and go down to 14 as soon as you remove one of them? [Food]
local sCitizen = GameInfo.Specialists.SPECIALIST_CITIZEN.ID;
local bDummy = GameInfoTypes.BUILDING_WHATEVER;
GameEvents.PlayerDoTurn.Add(
function(iPlayer)
local pPlayer = Players[iPlayer];
if (pPlayer:IsAlive()) then
if (pPlayer:GetCivilizationType() == GameInfoTypes.WHATEVER) then -- or Whatever your trigger is
for pCity in pPlayer:Cities() do
local cCitizen = pCity:GetSpecialistCount(sCitizen);
pCity:SetNumRealBuilding(bDummy, cCitizen );
end
end
end
end)
I'm assuming this needs some Lua, but am really hoping that it doesn't need a DLL mod since it's for a one-civ mod: How to make a building give +1Culture for every mountain inside your territory? However this should not stack (so if I have two of this building, I will still get +1
Culture per mountain), so maybe a function to check if one of that kind of building exists, and if so then all mountains yield +1
Culture, then make mountains stop giving the bonus if for any reason there are none of that building in the empire?
Thanks
iCiv = GameInfoTypes.CIVILIZATION_YOURCIV
iDummy = GameInfoTypes.BUILDING_YOURDUMMYBUILDING
iFeature = GameInfoTypes.FEATURE_MOUNTAIN
function YieldFromFeature(iPlayer)
if iPlayer < GameDefines.MAX_MAJOR_CIVS then
local pPlayer = Players[iPlayer]
if pPlayer:GetCivilizationType() == iCiv then
for pCity in pPlayer:Cities() do
local iNumPlots = pCity:GetNumCityPlots();
local iNumBuildings = 0;
for iPlot = 0, iNumPlots - 1 do
local pPlot = pCity:GetCityIndexPlot(iPlot)
if pPlot and pPlot:GetOwner() == iPlayer and pPlot:GetFeatureType() == iFeature then
iNumBuildings = iNumBuildings + 1
end
end
pCity:SetNumRealBuilding(iDummy, iNumBuildings)
end
end
end
end
GameEvents.PlayerDoTurn.Add(YieldFromFeature)