Hi Dertuek!! Great to read from you and thanks for those helpful notes.
10 years ago... I feel old
Sure. I will just change the TXT_KEY_BUILD_TURM text, that should do it too:
Oh yeah, of course! Why I wanted to make it complicated
hm... I do not swap things, I replace them. For livestock it would fit, but for grain... that's why I just replace it and kill the unit to keep it easy.
what would be better? to swap it but only for livestock?
but then there are some more help texts necessary....
I just wanted to understand first but I finally understood it like just a "replace" (I read swap from a translation from German).
There are few things to say.
1/ When my wagon is loaded with livestock/grain, anywhere I go on my own territory, the cultivation button is displayed, greyed and the help text says "Only an empty wagon can load goods.". In my opinion, I should see that only when my wagon is over a collectable resource. So it would mean in
CvMainInterface.py, at line
2472, check if there is a resource on the plot.
Python:
elif ePlotBonus != -1 and pPlot.getOwner() == iUnitOwner:
instead of just:
Python:
elif pPlot.getOwner() == iUnitOwner:
2/ The replace doesn't work, at least not everytime. For a simple reason. The normal
Cultivation function is called. And this function checks the grain/livestock limit of the city (1 for Settlement, 2 for village, 3 for city, ...).
In my case, I wanted to replace my
sheep by a most wanted
cow. But my city was a village so I was limited to 2 grain/livestock and I had already in the city's radius, the
sheep... but also some
oat. So the limit was reached. The cultivation button was displayed but when I clicked on it, nothing happened. For what I understand, I should able to replace a resource by another one whatever this limit, no?
Here is how I changed that:
In
CvMainInterface.py, I changed iData2 value for the 2 cultivation (738) buttons:
- at line
2475: 738, 738 => 738, 1
- at line
2487: 738, 738 => 738, 0
(meaning 1 = replace, 0 = normal cultivation)
At line
7325, I passed the iData2 to the modNetMessage (last argument... -1 => iData2)
Python:
# iData2: 1 = replace enabled, 0 = replace disabled
CyMessageControl().sendModNetMessage(738, iOwner, iUnitID, iIsCity, iData2)
In
CvEventManager.py, at line
1760, I passed a new argument to the doCultivateBonus function:
Python:
PAE_Cultivation.doCultivateBonus(pPlot, pUnit, eBonus, iData5==1)
And finally, in
PAE_cultivation.py, I added a new argument to
doCultivateBonus:
Python:
def doCultivateBonus(pPlot, pUnit, eBonus, replace=False):
And at line
293, I inhibited the check in the case of the "replace".
Python:
bCanCultivate = replace or _isBonusCultivationChance(iPlayer, pPlot, eBonus, bOnlyVisible, None)