LUA to Make Tile Improvement Modify Yields of Adjacent Tiles/Improvments

crimsontrojan

Chieftain
Joined
Aug 13, 2014
Messages
6
[*] Short of it: Can someone help me create a script that detects an improvement and then improves the yield of adjacent farms (i.e., a different improvement)?

[*] Best exemplar I can find: http://forums.civfanatics.com/archive/index.php/t-408262.html

So, I'm thinking you add an xml table that includes:

  1. "augmenting" improvement
  2. "augmented" improvement
  3. yield Type
  4. yield Amount

And then have the Lua hook into the table... this is where I get lost.

Ultimate goal is to have Fiefdoms that make the local farmers work harder and cough up gold... :king:
 
You can detect when an improvement completes with the following event:

GameEvents.BuildFinished(playerID, iX, iY, eImprovement)

I don't know what the next steps you would need to do would be because I'm not sure what effect you're trying to implement.
 
You can detect when an improvement completes with the following event:

GameEvents.BuildFinished(playerID, iX, iY, eImprovement)

I don't think this would work because I want the yields for adjacent farms to be increased as long as the Fiefdom (the new modded improvement) is there, potentially forever; triggering on creation won't handle that, right?

I don't know what the next steps you would need to do would be because I'm not sure what effect you're trying to implement.

Sorry I was unclear.

I want an effect that is similar to a Moai, except instead of adding culture when adjacent to other Moais, the Fiefdom will improve the gold and food yields from adjacent farms.

Starting from the link I posted:

-- define extra yields for farms, this part is shaky
local ImprovementIDsToYieldTable = {}

for pImprovementYieldChange in GameInfo.Improvement_YieldChange() do
ImprovementIDsToYieldTable[GameInfo.Improvements[pImprovementYieldChange.ImprovementType].ID] = pImprovementYieldChange.Yield
end

-- loop through all plots, check for applicable improvements, and change them
for iPlot = 0, Map.GetNumPlots() - 1 do
local pPlot = Map.GetPlotByIndex(iPlot)

local impType = pPlot:GetImprovementType()

if ImprovementIDsToYieldTable[impType] ~= nil then

-- How do I detect the farms and then add yields to them?
 
Back
Top Bottom