How would I implement the following UA?
Lords of Ulthuan: +1Food from Coast tiles. +5
Culture from Mountain tiles.
function LordsofUlthuanPlotCheck(iPlayer)
local pPlayer = Players[iPlayer]
if pPlayer:GetCivilizationType() == GameInfoTypes["CIVILIZATION_LORDS_OF_ULTHUAN"] and pPlayer:IsAlive() then
for pCity in pPlayer:Cities() do
iNumMountains = 0
iNumCoast = 0
for cityPlot = 0, pCity:GetNumCityPlots()-1, 1 do
local plot = pCity:GetCityIndexPlot(cityPlot)
if plot then
if plot:IsMountain() and plot:GetOwner() == iPlayer then
iNumMountains = iNumMountains + 1
end
if plot:IsCoastalLand() and plot:GetOwner() == iPlayer then
iNumCoast = iNumCoast + 1
end
end
end
pCity:SetNumRealBuilding(GameInfoTypes["BUILDING_ULTHUAN_MOUNTAIN_BONUS"], iNumMountains)
pCity:SetNumRealBuilding(GameInfoTypes["BUILDING_ULTHUAN_COAST_BONUS"], iNumCoast)
end
end
end
GameEvents.PlayerDoTurn.Add(LordsofUlthuanPlotCheck)
So the gains are actually done through the dummy buildings at the bottom, then?
Wouldn't that just give a flat amount of culture for each city that has a mountain in its territory or food for a city that is coastal?
I really want to give the bonus to each tile, so each mountain tile gives 5 culture and each coast tile gives an extra 1 food.
Thanks for being willing to help!
<BuildingClasses>
<Row>
<Type>BUILDINGCLASS_ULTHUAN_MOUNTAIN_BONUS</Type>
<DefaultBuilding>BUILDING_ULTHUAN_MOUNTAIN_BONUS</DefaultBuilding>
<Description>TXT_KEY_BUILDING_ULTHUAN_MOUNTAIN_BONUS</Description>
<NoLimit>true</NoLimit>
</Row>
<Row>
<Type>BUILDINGCLASS_ULTHUAN_COAST_BONUS</Type>
<DefaultBuilding>BUILDING_ULTHUAN_COAST_BONUS</DefaultBuilding>
<Description>TXT_KEY_BUILDING_ULTHUAN_COAST_BONUS</Description>
<NoLimit>true</NoLimit>
</Row>
</BuildingClasses>
Awesome! Thanks a ton, Bouncymischa.
The yields won't display on the map though will they?
(Not that it matters, but if possible I'd prefer to have "extra yields" actually display on the tile they're supposedly coming from)
UA: Fortress Island
For every 25 Combat Strength a city has, a city produces 1 Culture. Immediately enter a Golden Age if a Peace Treaty is signed between yourself and another Civilization.
I did something similar for my Moriya Shrine civilization. I didn't have the exact code handy to reference, but working off some code LastSword posted in another thread I'm hoping this would do the trick?
Code:function LordsofUlthuanPlotCheck(iPlayer) local pPlayer = Players[iPlayer] if pPlayer:GetCivilizationType() == GameInfoTypes["CIVILIZATION_LORDS_OF_ULTHUAN"] and pPlayer:IsAlive() then for pCity in pPlayer:Cities() do iNumMountains = 0 iNumCoast = 0 for cityPlot = 0, pCity:GetNumCityPlots()-1, 1 do local plot = pCity:GetCityIndexPlot(cityPlot) if plot then if plot:IsMountain() and plot:GetOwner() == iPlayer then iNumMountains = iNumMountains + 1 end if plot:IsCoastalLand() and plot:GetOwner() == iPlayer then iNumCoast = iNumCoast + 1 end end end pCity:SetNumRealBuilding(GameInfoTypes["BUILDING_ULTHUAN_MOUNTAIN_BONUS"], iNumMountains) pCity:SetNumRealBuilding(GameInfoTypes["BUILDING_ULTHUAN_COAST_BONUS"], iNumCoast) end end end GameEvents.PlayerDoTurn.Add(LordsofUlthuanPlotCheck)
You'd want to chance "CIVILIZATION_LORDS_OF_ULTHUAN" to whichever tag you actually used for the civ, though.
It wouldn't really be necessary to iterate through all the plots looking for coastal ones, or adding multiple dummy buildings for that matter if the definition of "coastal" is considered by Civitar as being equivalent to "is a sea plot as defined by the buildings table <Building_SeaPlotYieldChanges>". If this is acceptable, then all that is necessary is to add a dummy building to each city, where the dummy building has this as part of its code:Awesome! Thanks a ton, Bouncymischa.
The yields won't display on the map though will they?
(Not that it matters, but if possible I'd prefer to have "extra yields" actually display on the tile they're supposedly coming from)
<Building_SeaPlotYieldChanges>
<Row>
<BuildingType>BUILDING_COASTAL_FOOD_DUMMY</BuildingType>
<YieldType>YIELD_FOOD</YieldType>
<Yield>1</Yield>
</Row>
</Building_SeaPlotYieldChanges>
and DoTurn wayyyy too often.
function OnPlayerDoTurn(iPlayer)
-- Defend against executing the code on subsequent game sessions (ie after load game)
local bReallyFirstTime = IsThisNotALoadingSavedGame()
if (bReallyFirstTime) then
-- Do something once
end
-- Now remove the listener
GameEvents.PlayerDoTurn.Remove(OnPlayerDoTurn)
end
GameEvents.PlayerDoTurn.Add(OnPlayerDoTurn)
local TeamID = pPlayer:GetTeam();
[B]local pTeam = Teams[TeamID];[/B]
function MeetAndGreet(iThisPlayer, iThatPlayer)
local pThisPlayer = Players[iThisPlayer]
local pThisTeam = Teams[pThisPlayer:GetTeam()]
local pThatPlayer = Players[iThatPlayer]
if (pThisTeam:IsHasMet(pThatPlayer:GetTeam()) then
-- do stuff
end
end
[124752.018] Runtime Error: --path--.lua:84: attempt to index local 'pDeadUnit' (a nil value)
At Morpheus: It looks like BarbarianCombatBonus is only available for Policies and Difficulties, so you would have to do one of the following:
A: Duplicate the Difficulties and increase the BarbCB, and change the Diff via Lua dependent on Civ once in game, however this will be global for your units.
2: Make an unattainable Policy and grant it for free to the relevant civ via Lua, again global.
C: Make a DLL mod to add a functioning effects for a BarbCombBonus column in the Promotions table, then add said column via sql to the table. This would achieve what you seem to be talking about but may be more work than you are looking for.
-note: shouldn't be all that hard honestly, but will be if you don't know C++. Seeing how BarbCombBouns exists, it would only require small changes to unitCombat and adding the ties for reading a db value. (and promotion effects, but that can be easily scrap copy/pasted)