Fourth Yield

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)
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).
 
Thanks everyone :)

@keldath - as Valkrionn said, to use it for anything you still have to add code for whatever logic you need. This mod comp handles the rendering, which was problematic by default.
I originally intended (and I might still) use it for a 'supply lines' mod - by adding a 'used food' yield, so the player can see both the normal food yield of a tile, and how much of it is used.

I only have one request: If anyone uses it - please let me know. I'm curious ;)
 
hey,

well, i always wanted a forth yield.

using your idea for supply lines is very good,
but i can offer something good, that was tried before without success - fuel mod.
using the forth yield can be as fuel out put - say oil gives you 1 fuel, that is needed for unit movement, maybe even make an accumulation for this oil and units like tanks and such can consume this yield - like food being consumed by a city or something. maybe each fuel yield can be accumulated like gold, youll have a meter, and from that youll have movement costs for the units with a specific tag or something, youll have to keep a decent level of fuel to fuel all your units.
i dunno thats what comes to my mind,
but anyhow - if you plan on using this for supply lines - ill be the first to use it with my 2 mods.
but the problem is that i cant write sdk, only merge them.

hope you or anyone else use this cool thing to do something, im eager to have it.
 
Thanks everyone :)

@keldath - as Valkrionn said, to use it for anything you still have to add code for whatever logic you need. This mod comp handles the rendering, which was problematic by default.
I originally intended (and I might still) use it for a 'supply lines' mod - by adding a 'used food' yield, so the player can see both the normal food yield of a tile, and how much of it is used.

I only have one request: If anyone uses it - please let me know. I'm curious ;)

We'll be using it as Mana in RifE; May be stored (like Gold), used to cast spells, create summons, so on. :goodjob:

Would have worked as a commerce as well, but given that we wanted most of it to come from mana nodes on the map, a yield is better. ;)
 
hey,

well, i always wanted a forth yield.

using your idea for supply lines is very good,
but i can offer something good, that was tried before without success - fuel mod.
using the forth yield can be as fuel out put - say oil gives you 1 fuel, that is needed for unit movement, maybe even make an accumulation for this oil and units like tanks and such can consume this yield - like food being consumed by a city or something. maybe each fuel yield can be accumulated like gold, youll have a meter, and from that youll have movement costs for the units with a specific tag or something, youll have to keep a decent level of fuel to fuel all your units.
i dunno thats what comes to my mind,
but anyhow - if you plan on using this for supply lines - ill be the first to use it with my 2 mods.
but the problem is that i cant write sdk, only merge them.

hope you or anyone else use this cool thing to do something, im eager to have it.

I don't know if and when I'll return to the supply lines mod (I already have some of the code which I started writing before I came across the render issue). I need a little break, but I might go back to it.
Your fuel idea sounds quite similar actually - only with fuel instead of food (and probably some other differences).

We'll be using it as Mana in RifE; May be stored (like Gold), used to cast spells, create summons, so on. :goodjob:

Would have worked as a commerce as well, but given that we wanted most of it to come from mana nodes on the map, a yield is better. ;)

Great to hear!
Let me know if there are any problems.

Mana was one of the ideas that came to mind when I made this :)
 
"Bob and John, you guys go to harvest the corn. Jerry and Tommy : Try to find some rocks or planks of wood we can use for houses, and Jenny : maybe you can set up a bit of trade. The rest of you guys are on Bubble Gum duty. Remember : Chew, chew, bubble. Chew, chew, bubble." :D
 
"Bob and John, you guys go to harvest the corn. Jerry and Tommy : Try to find some rocks or planks of wood we can use for houses, and Jenny : maybe you can set up a bit of trade. The rest of you guys are on Bubble Gum duty. Remember : Chew, chew, bubble. Chew, chew, bubble." :D

:rotfl:
:lmao: :lmao: :lmao:
:clap:
 
Another interesting application would be manpower.
This could be used to make recruiting and reinforcement of units more realistic.
 
That is an excellent idea Rod.

Asaf, great work!! :goodjob: Thanks a million for sorting this out!

And vincentz, that was damn funny. :lol:
 
Thanks William!

@Rod - so you mean like rural population count? interesting. It could also affect other things, such as gold income (under certain civics) etc.
 
asaf can you apply your method to display more then 4 yields?

in MoM we have a high number of additional yields, although usually no more then 1 or 2 of them are applied to any tile, so the game has to display only 4 or in rare cases 5 yields of the possible 12.


it would be a rare occasion for the game to have 5 yields per tile (the only one i can think of is a mana shrine on a river grass tile with trees: gives food + production + gold + mana + spell research), normal would be 3 or 4, but the possible pool is rather large.
 
Making the changes for 5 yields should not be difficult (although I could be missing something). But unfortunately I don't really have the time for it.
If you or anyone else is interested in making the required modifications for that, I'd be glad to help with advice if needed.

It might already work once you update the enum and texture files AFAIK :dunno:

EDIT: You'd have to play with the parameters a bit to fit all symbols into the tile (I had some problems for city tiles and worked plots because the icons are rendered larger).
 
and the issue that the game has to render 4 (in rare cases 5) yields out of a total pool of ~12 different yields, is that possible?

edit: i am just asking, if you deem it possible
 
Actually when I think about it you'd need to edit the other art files:
vertical_symbols.dds is now 64x2048, which supports 32 slots. Since you need 5 for each yield (12x5=60) you'll need to resize it again to 64x4096, and make changes to the coordinates in the nif files.
(In addition to adding these to the enum, the XML, font files and of course add the art itself to vertical_symbols.dds).

You'll also need to change the value of s_fSymbolYieldTextureHeight in CvPlot.cpp to 1.0f/64.0f, instead of 32.

As long as you can't have more than 5 (or maybe 6) yields in a single plot, I think that should be enough.
 
Top Bottom