Asaf
Sleep Deprived
- Joined
- Mar 22, 2010
- Messages
- 1,326
Fourth Yield (version 0.1)
Download here
This mod component allows the addition of a fourth yield to the game, with full render capabilities for the yield symbols in the 3D map.
(Some history, feel free to skip)
My original attempts at adding a 4th yield came across some problems.
And apparently I wasn't the first to encounter these problems.
At first I tried implementing a much (much) more complicated solution, which almost worked, but had its problems in the end.
And then I came up with a much simpler solution, which is given here.
(Sorry for the history lesson but it really took me a long time to reach this solution)
So, the 3 problems this mod component solves are:
1. The game cannot render more then 3 yield types per tile, even if 4 are defined for this tile. This limit is hard-coded in the EXE (but that doesn't mean it cannot be changed there - as a matter of fact my original solution did just that
).
2. In order to add a 4th yield, the vertical_symbols.dds file has to be resized from 64x1024 (which is enough for 16 symbols, 15 taken by 3 yields) to 64x2048. The render of yields in the game uses 1/16 of this texture even though it now needs to use 1/32 of it.
The result can be seen here (the food with the red X was the new yield):
3. When a tile has 5 or more of a single yield, it creates another layer of yield symbols above the first one (so it can render the extra yields). For the yields which only appear in the first layer (because they yield less than 6), the texture coordinates used for the 'empty' yield are the texture coordinates which come after the 3 yields in the texture - in our case it's the 1st symbol for the new yield, which caused many tiles on the map to display this yield.
The result can be seen here (this time I use the new yield art, the bubble gum which was created by my wife while she waited for me to stop modding and come to bed):
The solution:
1. In CvPlot I created extra symbols when there were 4 yields displayed in the tile, such that one symbol holds 3 yields, and another holds the 4th. I then added a new member to the plot so various methods will return an adjusted result (e.g. the X position of the tile is modified for these symbols).
2. I edited the symbols_X.nif files and adjusted their UV coordinates. These files are in Assets\Art\Interface\Symbols and there are 3 of them (symbols_2.nif, symbols_3.nif, symbols_1.nif).
3. I found the position in the symbol where the relevant coordinates are held, and in the cases where it's needed - I override the value with another value which actually point to an empty position in the texture.
And this is how it looks:
Instructions to modders: how to use
This mod component can't really be played on its own, since you still need to add meaning (and code!) to the new yield.
For now I created a dummy yield - YIELD_WEIRD - which does nothing but being displayed.
To actually use an extra yield you first need to merge the C++ code from this mod component (I only included the files I changed, and all changes are marked with 'Fourth Yield').
Then, you need to do the following (these steps already appear in several places in these forums. I didn't invent them):
1. Add the new yield to CIV4YieldInfos.xml (a sample comes with this mod).
2. Add the new yield to the enum in CvEnums.h (order must match to the one in the XML!). I've already added YIELD_WEIRD - feel free to rename it to whatever seems right to you. You then need to add it to CvDllTranslator.cpp and to CyEnumsInterface.cpp (see the sample in this mod).
3. Add the new yield's icon to the game font's files (GameFont.tga, GameFont_75.tga). Again, This mod comopnent comes with a sample.
4. Add the new yield's graphics to a resized vertical_symbols.dds. This mod already comes with a resized file (in Assets\Art\Interface\Symbols). Note that each symbol is 64x64, so make sure your art goes to the correct coordinates.
5. Add code to use this new yield for whatever it is you want it to do.
Extra comments
There are some issues with positioning the 4th yield correctly in a tile, especially in hills and city tiles. I played with the parameters a bit, but feel free to play with them some more to get better results (everything is in CvPlot.cpp).
Download here
This mod component allows the addition of a fourth yield to the game, with full render capabilities for the yield symbols in the 3D map.
(Some history, feel free to skip)
Spoiler :
My original attempts at adding a 4th yield came across some problems.
And apparently I wasn't the first to encounter these problems.
At first I tried implementing a much (much) more complicated solution, which almost worked, but had its problems in the end.
And then I came up with a much simpler solution, which is given here.
(Sorry for the history lesson but it really took me a long time to reach this solution)
So, the 3 problems this mod component solves are:
1. The game cannot render more then 3 yield types per tile, even if 4 are defined for this tile. This limit is hard-coded in the EXE (but that doesn't mean it cannot be changed there - as a matter of fact my original solution did just that

2. In order to add a 4th yield, the vertical_symbols.dds file has to be resized from 64x1024 (which is enough for 16 symbols, 15 taken by 3 yields) to 64x2048. The render of yields in the game uses 1/16 of this texture even though it now needs to use 1/32 of it.
The result can be seen here (the food with the red X was the new yield):
Spoiler :

3. When a tile has 5 or more of a single yield, it creates another layer of yield symbols above the first one (so it can render the extra yields). For the yields which only appear in the first layer (because they yield less than 6), the texture coordinates used for the 'empty' yield are the texture coordinates which come after the 3 yields in the texture - in our case it's the 1st symbol for the new yield, which caused many tiles on the map to display this yield.
The result can be seen here (this time I use the new yield art, the bubble gum which was created by my wife while she waited for me to stop modding and come to bed):
Spoiler :

The solution:
1. In CvPlot I created extra symbols when there were 4 yields displayed in the tile, such that one symbol holds 3 yields, and another holds the 4th. I then added a new member to the plot so various methods will return an adjusted result (e.g. the X position of the tile is modified for these symbols).
2. I edited the symbols_X.nif files and adjusted their UV coordinates. These files are in Assets\Art\Interface\Symbols and there are 3 of them (symbols_2.nif, symbols_3.nif, symbols_1.nif).
3. I found the position in the symbol where the relevant coordinates are held, and in the cases where it's needed - I override the value with another value which actually point to an empty position in the texture.
And this is how it looks:
Spoiler :

Spoiler :

Instructions to modders: how to use
This mod component can't really be played on its own, since you still need to add meaning (and code!) to the new yield.
For now I created a dummy yield - YIELD_WEIRD - which does nothing but being displayed.
To actually use an extra yield you first need to merge the C++ code from this mod component (I only included the files I changed, and all changes are marked with 'Fourth Yield').
Then, you need to do the following (these steps already appear in several places in these forums. I didn't invent them):
1. Add the new yield to CIV4YieldInfos.xml (a sample comes with this mod).
2. Add the new yield to the enum in CvEnums.h (order must match to the one in the XML!). I've already added YIELD_WEIRD - feel free to rename it to whatever seems right to you. You then need to add it to CvDllTranslator.cpp and to CyEnumsInterface.cpp (see the sample in this mod).
3. Add the new yield's icon to the game font's files (GameFont.tga, GameFont_75.tga). Again, This mod comopnent comes with a sample.
4. Add the new yield's graphics to a resized vertical_symbols.dds. This mod already comes with a resized file (in Assets\Art\Interface\Symbols). Note that each symbol is 64x64, so make sure your art goes to the correct coordinates.
5. Add code to use this new yield for whatever it is you want it to do.
Extra comments
There are some issues with positioning the 4th yield correctly in a tile, especially in hills and city tiles. I played with the parameters a bit, but feel free to play with them some more to get better results (everything is in CvPlot.cpp).