Hey,
I have added the Tipi as a UI for the Shoshone in my mod. It can only be build on flat plains and yields +1 Food as well as a random yield of +1 Culture, +1 Faith or +1 Gold. I have created 4 Tipi variants, one that can be built and three others that are randomly placed on top of the build Tipi when it is completed. Code follows:
This seems to work nice but I have one problem. I don't want the Tipi's to be built adjacent to each other, so I flagged them with <NoTwoAdjacent>true</NoTwoAdjacent>, but since the base Tipi is now replaced with a "culture, faith or gold" Tipi, it is still possible to build a new base Tipi adjacent to an existing Tipi, and I cant figure out how to prevent that. Hope you follow me there
Picture: http://s24.postimg.org/sa9ze6m79/Untitled.jpg
Is there any good solution or workaround for this? Also, since I am very new at Lua, if you see anything that I might have missed in the code, please let me know.
I have added the Tipi as a UI for the Shoshone in my mod. It can only be build on flat plains and yields +1 Food as well as a random yield of +1 Culture, +1 Faith or +1 Gold. I have created 4 Tipi variants, one that can be built and three others that are randomly placed on top of the build Tipi when it is completed. Code follows:
Code:
function TipiRandomYield(iPlayer, iX, iY, iImprovement)
local pPlayer = Players[iPlayer]
if (pPlayer:IsAlive()) then
if (pPlayer:GetCivilizationType() == GameInfoTypes["CIVILIZATION_SHOSHONE"]) then
print("The Shoshone built something!")
if iImprovement == GameInfoTypes["IMPROVEMENT_SHOSHONE_TIPI_BASE"] then
print("The Shoshone built a Tipi!")
local pPlot = Map.GetPlot(iX, iY)
local iRND = JFD_GetRandom(1, 3)
pPlot:SetImprovementType(-1)
if iRND == 1 then
pPlot:SetImprovementType(GameInfoTypes["IMPROVEMENT_SHOSHONE_TIPI_CULTURE"])
print("A culture Tipi!")
end
if iRND == 2 then
pPlot:SetImprovementType(GameInfoTypes["IMPROVEMENT_SHOSHONE_TIPI_FAITH"])
print("A faith Tipi!")
end
if iRND == 3 then
pPlot:SetImprovementType(GameInfoTypes["IMPROVEMENT_SHOSHONE_TIPI_GOLD"])
print("A gold Tipi!")
end
end
end
end
end
GameEvents.BuildFinished.Add(TipiRandomYield)
This seems to work nice but I have one problem. I don't want the Tipi's to be built adjacent to each other, so I flagged them with <NoTwoAdjacent>true</NoTwoAdjacent>, but since the base Tipi is now replaced with a "culture, faith or gold" Tipi, it is still possible to build a new base Tipi adjacent to an existing Tipi, and I cant figure out how to prevent that. Hope you follow me there
Picture: http://s24.postimg.org/sa9ze6m79/Untitled.jpg
Is there any good solution or workaround for this? Also, since I am very new at Lua, if you see anything that I might have missed in the code, please let me know.