Electricity mod/Resource requiring Buildings?

I apologize if it seems that I've hijacked your thread KnelRivendar. It wasn't my intent to do so, I am just intrigued by the idea as it is something that I want to do as well.

I was looking through the XML and found the CIV5Trades.xml file in XML\GameInfo. It seems to me on initial examination that this is where you would add a new trade type called TRADE_ELECTRICTY or maybe TRADE_MEGAWATTS. In UI\Ingame\WorldView I found TradeLogic.lua which seems to handle the creation of a Deal instance. I am still learning how LUA works but it seems to me that you would create something like bElectricityTradeAllowed or bMegawattTradeAllowed modeled after the code for lump sum gold deals, bGoldTradeAllowed. For a GPT like trade, it looks like you would create something along the lines of bEPTAllowed or bMPTAllowed for electricity per turn or megawatts per turn, modeled after bGPTAllowed. You would also need some new functions in that same file modeled after PocketGoldHandler, ChangeGoldAmount, PocketGoldPerTurnHandler, TableGoldPerTurnHandler, and ChangeGoldPerTurnAmount.

To create the electricity yield, you would need a new yield type in the XML\Terrain\CIV5Yields.xml file called something like YIELD_ELECTRICITY or YIELD_MEGAWATT which would be added to the river tile terrain with a hydro plant. Solar plants could be modified to do the same thing for all desert tiles, which would make desert tiles really useful since they would help power generation in your post industrial age empire. The coal power plant would need a coal resource and the nuclear plant would need a uranium resource available in the city in order to build them initially. They would be modeled after the monastery but they would use the available coal to modify the electricity / megawatt yield so that if the coal is pillaged or is switched to being worked by another city, it no longer modifies the yield. I am not sure if this is the way the monastery works though. It probably needs to be tested.

If you wanted to, you could probably have a power plant improvement instead which would increase the yield for that resource type when you improve the tile. You would build hydro plants along the river, solar plants in the desert, nuclear plants on uranium, and coal plants on coal. Then you could build a power grid or substation or something like that in the city which would act like a market by increasing the electricity yield of the city by a certain percentage. In theory, you would have some cities that were literally powerhouses for your empire just like financial cities are now.

At this point my thoughts are still speculation but I still believe this is doable in XML/LUA. Of course, I'm not the one doing it yet, :lol:. I will try to tackle it myself at some point if you haven't beaten me to it. If I do, this is probably the approach I would try to take assuming I didn't run into a lot of issues.
 
I apologize if it seems that I've hijacked your thread KnelRivendar. It wasn't my intent to do so, I am just intrigued by the idea as it is something that I want to do as well.

I was looking through the XML and found the CIV5Trades.xml file in XML\GameInfo. It seems to me on initial examination that this is where you would add a new trade type called TRADE_ELECTRICTY or maybe TRADE_MEGAWATTS. In UI\Ingame\WorldView I found TradeLogic.lua which seems to handle the creation of a Deal instance. I am still learning how LUA works but it seems to me that you would create something like bElectricityTradeAllowed or bMegawattTradeAllowed modeled after the code for lump sum gold deals, bGoldTradeAllowed. For a GPT like trade, it looks like you would create something along the lines of bEPTAllowed or bMPTAllowed for electricity per turn or megawatts per turn, modeled after bGPTAllowed. You would also need some new functions in that same file modeled after PocketGoldHandler, ChangeGoldAmount, PocketGoldPerTurnHandler, TableGoldPerTurnHandler, and ChangeGoldPerTurnAmount.

To create the electricity yield, you would need a new yield type in the XML\Terrain\CIV5Yields.xml file called something like YIELD_ELECTRICITY or YIELD_MEGAWATT which would be added to the river tile terrain with a hydro plant. Solar plants could be modified to do the same thing for all desert tiles, which would make desert tiles really useful since they would help power generation in your post industrial age empire. The coal power plant would need a coal resource and the nuclear plant would need a uranium resource available in the city in order to build them initially. They would be modeled after the monastery but they would use the available coal to modify the electricity / megawatt yield so that if the coal is pillaged or is switched to being worked by another city, it no longer modifies the yield. I am not sure if this is the way the monastery works though. It probably needs to be tested.

If you wanted to, you could probably have a power plant improvement instead which would increase the yield for that resource type when you improve the tile. You would build hydro plants along the river, solar plants in the desert, nuclear plants on uranium, and coal plants on coal. Then you could build a power grid or substation or something like that in the city which would act like a market by increasing the electricity yield of the city by a certain percentage. In theory, you would have some cities that were literally powerhouses for your empire just like financial cities are now.

At this point my thoughts are still speculation but I still believe this is doable in XML/LUA. Of course, I'm not the one doing it yet, :lol:. I will try to tackle it myself at some point if you haven't beaten me to it. If I do, this is probably the approach I would try to take assuming I didn't run into a lot of issues.

One thing I forgot to look into was how to handle maintenance. I think it would be nice if you could have all of your other buildings require gold AND power. This would simulate the need for money to cover operating costs (already simulated) as well as the need for power as KnelRivendar has already suggested. Looking over ww2commander's example code, I see the possiblity for using something similar as a base for all other buildings where they would each require money and power as resources and then output happiness, culture, etc. I am not sure if that would be quite the same as his code since it is based on resources instead of yields but I think the concept would be similar. I will have to look into how the game handles maintenance though and see if there is a little bit more direct way to just copy the gold maintenance system and modify it for a power system. I'm just not sure if you would be able to require more than one type of maintenance. If you can, then I could see the potential for expanding this concept to require something like manpower / labor / personnel to run the building. Something like that could also be used to determine whether or not your units are able to continue, i.e. not enough people enlisting in the military so they get disbanded, similar to unit maintenance. I think this would be similar to the R.E.D. mod but I have not played that yet, just read through the way it handles reinforcements / healing.
 
I agree wholeheartedly that Electricity must be in the game somehow. It could be done in a similar way than in Civ 4, that factories etc. get a bonus if electricity is available. OR more realistically it could be a resource provided by a building such as a power plant like this;

NOTE: I would love to do leveled buildings like illustrated ahead.

- Small coal plant: Requires 2 units of Coal, Provides 2 units of Electricity (electricity production can be boosted with tech making it more efficient, getting more power out of 1 unit of coal etc.). Pollutes, unhealthiness (city growth malus) and pollution (risk of polluting squares like in civ 2).

- Medium Coal Plant: Requires 5 Coal, Provides 5 Electricity

- Large Coal Plant: Requires 10 Coal, Provides 10 Electricity

The buildings would upgrade to the next level when built.

To use electricity you would build buildings like factories like this:

-Small Factory: Requires 1 Electricity +5 production +10% prod.

-Medium Factory: 2 El. +10 production +25% prod.

- Large Factory: 5 El. +20 production +50% prod.

I would be very interested in including this feature in my Civilization Universalis mod, so if you want to co-operate in making mods let me know. You would get full credit for your contributions needless to say.

Cheers!
 
Back
Top Bottom