Change resource yield when tech is unlocked

Nocty1501

Chieftain
Joined
Jul 16, 2021
Messages
3
Hi,

I'm trying to figure out how to code a civ ability that would grant +1 hammer on all strategic resources once Industrialization is unlocked.

I'm terribly lost.

I have no idea what to hook into, since I need to both check whether the tech has been researched and also edit the plot's yields.

How do?

Update: I figured out how to check for the correct trait, tech, and resource on the tile, however I still have no idea what GameEvent I should hook into and how to edit the actual yields on the tile. The Plot object doesn't seem to have a SetYield() or any similar method.
 
Last edited:
It's not a Plot method. It's a Game method
Code:
Game.SetPlotExtraYield(iPlotX, iPlotY, eYieldType, iChange)
eYieldType has to be a GameInfoTypes ID number such as
Code:
GameInfoTypes.YIELD_FOOD
The problem with this approach is that it is both processing heavy and requires a lot of logic to keep the code from continuously adding more and more extra yield to the same plot while also accounting for plots grabbed by cities after the tech has been discovered, and for new city foundings / conquest as well as the loss of a city via conquest.

Generally what we do in these types of cases is add a dummy building to the game, and give appropriate player cities the correct dummy building via lua. Table Building_ResourceChanges is then used with the dummy building to make the adjustments in yield to the correct resources. Much less processing and does not result in runaway code-inflation of the plot yields.
 
Yeah, after looking around for a while I decided to implement it as a dummy building.

God, Civ 5's modding API is terrible.
 
Alright, after a few hours of work, I finally solved it!

I hooked into the CityCaptureComplete, TeamTechResearched, PlayerDoTurn, and PlayerCityFounded GameEvents and used a dummy building to provide the +1 production for all strategic resources.

Thank you to LeeS for the suggestion <3

Hopefully this little thread will be of some use to someone in the future.
 
Back
Top Bottom