Modmodding Q&A Thread

A negative value is a fractional denominator where the numerator is 10, i.e. -100 means the building weight is multiplied by 10 / 100, in other words divided by ten. You can use this setting to prevent a building entirely, by setting it explicitly to 0.
 
How would one go about rotating a building? I'd like to change the direction a wonder is facing towards. Is there anything I can do in the XML or is the only option editing the model itself?
 
I don't know, I think it's better to ask in the general C&C forum.
 
Where can I increase the max number of players? I'd like to have more civs in the late game, but can only figure out how to adjust respawn dates. Thanks
 
Is there any information about creating a new civ for the current version of DOC?
Not that I know of. Some pointers:
  • Add the civilization in XML
  • Update CivilizationTypes in CvEnums.h and recompile
  • Update Consts.py with the new civilization
  • Civilizations.py: starting assets, AI preferences
  • Areas.py: core, birth, etc. areas
  • Modifiers.py: AI modifiers
  • AIParameters.py: more AI preferences
  • SettlerMaps.py and WarMaps.py
  • CityNameManager.py: city name map and rename dictionary
  • GreatPeople.py: great people names
  • HistoricalVictory.py: definition of victory goals
  • Scenarios/ directory: if you want the civilization to be present at the start of a scenario (i.e. no autoplay)
Not guaranteed to be exhaustive but that should cover the most important parts. Some of these are optional, e.g. you can create a civ that does not have great people or city names or uses those of an existing language.

Where can I increase the max number of players? I'd like to have more civs in the late game, but can only figure out how to adjust respawn dates. Thanks
It is this line in CvDefines.h:
C++:
#define MAX_CIV_PLAYERS                (32)
Change the value to your desired number of slots and recompile.
 
How do I convert the RGB values in CIV4ColorVals.xml
playercolor.png

to the color picker in paint.net?
colorpicker.png
 
Multiply by 255 and round to whole numbers.

COLOR_PLAYER_DAKR_BLUE_TEXT becomes:
R: 0.50 * 255 = 127.5 -> 128
G: 0.52 * 255 = 132.6 -> 133
B: 0.90 * 255 = 229.5 -> 230

From RGB to the colorvals is dividing by 255 and round to 2 decimals.
 
Last edited:
The colors listed for Polynesia and Korea in CIV4CivilizationsInfos.xml are PLAYERCOLOR_POLYNESIA and PLAYERCOLOR_KOREA. I can't find either of these colors in CIV4ColorVals.xml. Does anyone know where they are?
 
Be aware. ColorVals and PlayerColors are different things. In CIV4CivilizationsInfos.xml, the PLAYERCOLOR_XXX tags reference a PlayerColor. These can be found Civ4PlayerColorInfos.xml. (This file is in the same subfolder as Civ4ColorVals.xml)

From Civ4PlayerColorInfos.xml:
XML:
        <PlayerColorInfo>
            <Type>PLAYERCOLOR_POLYNESIA</Type> <!-- Polynesia -->
            <ColorTypePrimary>COLOR_PLAYER_ROSE</ColorTypePrimary>
            <ColorTypeSecondary>COLOR_PLAYER_WHITE</ColorTypeSecondary>
            <TextColorType>COLOR_PLAYER_ROSE_TEXT</TextColorType>
        </PlayerColorInfo>

As you can see, a PlayerColor consists of a primary, secondary and textcolor. Each of these colors can be found in ColorVals.xml.

Both ColorVals and PlayerColors have similar XML tags, so it is easy to mix them up.
 
There is a generalised pattern for this that is used by e.g. the Roman and Greek conquerors in AIWars.py, where you don't need to code anything but only need to specify the date, number of targeted cities etc. and the game will spawn appropriate units in a randomised interval around the date.
I'm looking to add new conqueror events. Is this advice from 2018 still relevant and the way to do it or has the code rewrite changed this in some way? I'm thinking of adding French conquerors for West Africa and Japanese conquerors for Korea and China.
 
It's still current. You can just look.
 
I'm looking to add new conqueror events. Is this advice from 2018 still relevant and the way to do it or has the code rewrite changed this in some way? I'm thinking of adding French conquerors for West Africa and Japanese conquerors for Korea and China.
I like these ideas. I would just add the Japanese conquerers to Korea, Taiwan, and Manchuria though. Having played a few Japanese games I've figured out there's a natural progress to their resource acquisition -> Korea for the coal, Manchuria for the oil.

Once Japan has Manchuria for oil and land unit production, they're pretty strong and can normally fight China on their own without scripted events to help.
 
What's the place to find information about chopping? Things such as how much :hammers: does it grant and which technologies you need in order to remove forests (if possible for each variant), jungles and rain forests. I was convinced I'd find something in CIV4TechInfos.xml and CIV4FeatureInfos.xml but no luck or there's something I'm overlooking. Or is this something that's not even found in the XML?
 
What's the place to find information about chopping? Things such as how much :hammers: does it grant and which technologies you need in order to remove forests (if possible for each variant), jungles and rain forests. I was convinced I'd find something in CIV4TechInfos.xml and CIV4FeatureInfos.xml but no luck or there's something I'm overlooking. Or is this something that's not even found in the XML?

XML/Units/Civ4Buildinfos.xml
 
I am (still working) on a modmodmod of DoC and am trying to implement a new terrain type: Wide River.

I was really hoping I could find a way to make ships be able to path through corners of the Wide River terrain type (but not Coast and Ocean), as shown below. Unfortunately, I may have reached a dead end. I traced the pathfinding code to this method:

CvDLLFAStarIFaceBase::GeneratePath()

CvDLLFAStarIFaceBase seems like inaccessible source code to me, as it only exists as a .h file with no .cpp implementation that I can find. I am not super familiar with how it works, but I know that there is some code that is untouchable to modders.

Does this seem like a reasonable conclusion? That if I could edit the CvDLLFAStarIFaceBase::GeneratePath() method, I would be able to shoe-horn in special logic for Wide River navigation, but it is not accessible?

I think that I could create my own implementation of GeneratePath() and replace all the calls to CvDLLFAStarIFaceBase::GeneratePath() with my own, and therefore have control over it. But that doesn't sound like a good idea.

Is there an easier way to do this that I am overcomplicating?

I also had the pipe dream of modifying the render engine to make the Wide River terrain's corners connect so the river would be graphically contiguous, but I'm pretty sure that's out of my depth/impossible.
 

Attachments

  • Wide River Example.png
    Wide River Example.png
    3.6 MB · Views: 60
I don't think you can modify the pathfinder implementation, like you say it is in the EXE. I know that AdvCiv has its own pathfinder that replaces the base game implementation which would be more open to modification.

I am not sure you need to edit the pathfinder itself though. While its implementation is in the EXE, it is relying on other methods in the DLL. I am not sure what the right one to modify is, but I would start with CvUnit::canEnter. There are multiple methods that control this, some also associated with CvPlot. Please give it a look, if you're still stuck I can look through it some more.

And yeah, don't expect to be able to modify the rendering in the way you would like.
 
The diagonal movement is possible. I don't remember what you needed to change, but I will look into it when I'm back home.

I did play with the rendering engine a bit myself. While it is possible to make make the river contiguous (by editing the heightmaps and textures), it is not possible to have both contiguous rivers and isthmus' on the same map.
See the posts I made about it.
 
The diagonal movement is possible. I don't remember what you needed to change, but I will look into it when I'm back home.

I did play with the rendering engine a bit myself. While it is possible to make make the river contiguous (by editing the heightmaps and textures), it is not possible to have both contiguous rivers and isthmus' on the same map.
See the posts I made about it.
Could a new terrain feature potentially hide the undesirable gaps between land tiles, or is that not possible/ugly?
 
Thanks for the help! I found the appropriate method, it's CvGameCoreUtils:: pathValid(). In it, there's a check for a DOMAIN_SEA unit moving from water to water, and it returns FALSE if a corner is not water. So, I just added in an additional check to see if the origin or destination terrain is Wide River. If anyone's curious, here is the new code segment that works:

C++:
    if (pSelectionGroup->getDomainType() == DOMAIN_SEA)
    {
        if (pFromPlot->isWater() && pToPlot->isWater())
        {
            if (!(GC.getMapINLINE().plotINLINE(parent->m_iX, node->m_iY)->isWater()) && !(GC.getMapINLINE().plotINLINE(node->m_iX, parent->m_iY)->isWater()))
            {
                // MacAurther: Wide River Terrain: Can move through corners
                if (!(pFromPlot->isWideRiver()) && !(pToPlot->isWideRiver()))
                {
                    return FALSE;
                }
            }
        }
    }

And yeah, I don't think I'll even bother trying to implement the graphical changes, but you had some good results, merijn!

1702988520310.png
 
Back
Top Bottom