Modmodding Q&A Thread

merijn_v1

Black Belt
Joined
Dec 29, 2008
Messages
5,926
Location
The city of the original vlaai
I'm trying to find the courage to do my first modding attempt (aside from drawing maps in civ II a long long time ago)

If I'd want to change the UP of the Inca (from every worked mountaintile giving two food and one production into giving two food and one free citizen). What parts of the code would I have to change for that?
And what programs would I need to acces that code? (/find it?)

It's great to see that you want to try it. :goodjob: I hope you find the courage. It may seem a bit daunting at first, but it becomes better when you get some experience. (I can speak from my own experience)

The Incan UP (and many other UPs) are in the CvGameCoreDLL. You can find a folder in the mod folder with that name that contains all source files for building the DLL. Editing the DLL requires 2 steps. The first is editing the code itself, which is done by editing the code in the source files. The second is building the DLL. The link below has a tutorial how to set up everything in order to build the DLL. (The author of that tutorial should be familiar)
https://forums.civfanatics.com/threads/the-easiest-way-to-compile-a-new-dll.608137/
(I recommend building a clean DLL before you make any changes to the code yourself to verify if you installed everything correctly)

The language of the DLL source files is C++. Editing the source files can be done with any text editor, but I highly recommend not using just any. Visual Studio (required anyway for building the DLL) can be used for editing the source files for the DLL. Notepad++ is IMO also a good option, and that one can also be used for editing python. (And has a very useful "search in files" function)

The Incan UP is coded in CvPlot.cpp. (Search for "Inca" and you will easily find it) It should be easy to see what you should do to disable the production on peaks. Adding a free citizen is harder. It can be done in CvCity.cpp. You should probably modify the setWorkingPlot() function by adding the changeFreeSpecialistCount(). I'll leave it up to you to figure out the details. Not because I don't want to help, but because I think that this is the best way to learn it. (And IMO figuring out things like this is what makes modding fun and I don't want to take this part away from you) But feel free to aks for help if you need it.
 
Last edited:

LikeNothing

Warlord
Joined
Dec 25, 2016
Messages
101
Hi, I edited the 1700AD scenario map file using Notepad++. Made a few very simple edits, just changing the culture of a few pre-placed cities.

When I start the game, everyone has no Techs. It seems the Tech initializing function did not run - the game starts up abnormally fast.

When I reverted the scenario map edits, the problem is gone. Everything works fine.

This is the latest Git version. I used to modify the scenario maps much more extensively in slightly older (before Code Rewrite, e.g. Jan 2020) versions, without such problems.

What went wrong? Thank you for your help!
 

Leoreth

Vampire of the Blue Moon
Moderator
Joined
Aug 23, 2009
Messages
36,009
Location
Paris
Have you enabled Python exceptions? Most likely, one of your edits was incorrect which causes the scenario file parser to fail and game setup to aboard early.
 

Louis the XIV

Sun King
Joined
Jun 23, 2020
Messages
837
Location
Court of Versailles
Does anyone know how to add resource Camel to a mod?
Cause I already have all the Files required, the Nif and the Animations and dds, but I can't find the Bonus XML File anywhere in the Civ 4 BTS Assets.
But in the Doc mod there is a Xml file for Bonus.
 

LikeNothing

Warlord
Joined
Dec 25, 2016
Messages
101
Thanks! I found the problem.

Scenarios.py adds specific things to a few specific cities, and I deleted one of those cities from the map file. I removed the relevant lines from Scenarios.py and that fixed it.
 

Tab911

Chieftain
Joined
Jun 20, 2019
Messages
58
What’s the best way to save a map file that can be played?

I intend to try and remake the old map with the new terrains and resources so that they might be in a playable state. Problem is worldbuilder files do not work correctly. I’m not sure if there is a dedicated map editor or a different way to make it playable. If it’s possible, I will upload it too if anyone wants to play around with resource spawns or other script related features.
 

merijn_v1

Black Belt
Joined
Dec 29, 2008
Messages
5,926
Location
The city of the original vlaai
When you want to edit only the map but not the starting units etc, you can do the following. Edit the map in WB and export it with the WB option as usual. After that, close Civ and open the newly created scenario file with a text editor. (I use notepad++, but any text editor will do) If you scroll down, you see a part where the plotinfo begins, like this:

Spoiler :
Code:
... (playerinfo and some stuff)

BeginMap
    grid width=124
    grid height=68
    prime meridian=53
    equator=26
    top latitude=75
    bottom latitude=-75
    wrap X=1
    wrap Y=0
    world size=WORLDSIZE_HUGE
    climate=CLIMATE_TEMPERATE
    sealevel=SEALEVEL_MEDIUM
    num plots written=8432
EndMap

### Plot Info ###
BeginPlot
    x=0,y=0
    FeatureType=FEATURE_ICE, FeatureVariety=0
    TerrainType=TERRAIN_OCEAN
    PlotType=3
EndPlot
BeginPlot
    x=0,y=1
    FeatureType=FEATURE_ICE, FeatureVariety=0
    TerrainType=TERRAIN_OCEAN
    PlotType=3
EndPlot

...

Open the original file, select everything above ### Plot Info ### (playerinfo, teaminfo, gameinfo etc) and copy-paste it into your new file, replacing everything above ### Plot Info ### in the new file.
 

Tab911

Chieftain
Joined
Jun 20, 2019
Messages
58
So I've finished the conversion... call it a work in progress. I tried to just merge relevant xml files into my original DoC library but its certainly not playable. Gonna tinker with python to see if I can do anything, here's the file if anyone else wants a go...
 

Attachments

  • Temp.zip
    50.8 KB · Views: 32

Louis the XIV

Sun King
Joined
Jun 23, 2020
Messages
837
Location
Court of Versailles
Does anyone know how can you make custom dawn of man titles for every civ? I checked a lot of python files from doc but don't see were the define tag for the Dawn Of Man title is defined for every civ?
 

Leoreth

Vampire of the Blue Moon
Moderator
Joined
Aug 23, 2009
Messages
36,009
Location
Paris
getDawnOfManText in RFCUtils.py
 

Louis the XIV

Sun King
Joined
Jun 23, 2020
Messages
837
Location
Court of Versailles
I am planning on adding a new civ to Dawn of Civilization. I already have about everything figured out except for 3 big problems that I need help answering.
In the AI War maps.py there are a bunch of numbers for each civ, how can you create one?
Same for the settler maps.
Were are the coordinates defined for were the civ spawns? (I'm guessing the settler maps but to me it's just a bunch of numbers!)
 

merijn_v1

Black Belt
Joined
Dec 29, 2008
Messages
5,926
Location
The city of the original vlaai
You can use the WB to create settlermaps and warmaps. The WB has a section "DoC Maps", which allows you to edit and export the maps. If you have exported your map you can simply copy-paste it into their respective python files.

The civ spawn coordinates are in Areas.py. If you base you changes on the v1.16.2 release, they in the tCapitals section. If you base it on the git version which includes the code rewrite, the coordinates are in dCapitals.

This guide is very useful to create new civs for DoC. It is a bit outdated though, especially since the code rewrite. It is still very useful to see what you should change, but the exact code or the file in which the code is might have been changed now.
https://forums.civfanatics.com/threads/guide-adding-a-civilization-to-doc-updated.561840/
 
Joined
Jan 25, 2011
Messages
993
Location
Hangzhou,China PR
Hello everyone, I want to make an 1800ad scenerio by myself. But I can only open the 1700ad scenerio file by .txt and edit it in every tile. It's very tiresome and boring. Is there a way or any tools to make it simple and fast? Thank you all!
 

Louis the XIV

Sun King
Joined
Jun 23, 2020
Messages
837
Location
Court of Versailles
You can use the WB to create settlermaps and warmaps. The WB has a section "DoC Maps", which allows you to edit and export the maps. If you have exported your map you can simply copy-paste it into their respective python files.

The civ spawn coordinates are in Areas.py. If you base you changes on the v1.16.2 release, they in the tCapitals section. If you base it on the git version which includes the code rewrite, the coordinates are in dCapitals.

This guide is very useful to create new civs for DoC. It is a bit outdated though, especially since the code rewrite. It is still very useful to see what you should change, but the exact code or the file in which the code is might have been changed now.
https://forums.civfanatics.com/threads/guide-adding-a-civilization-to-doc-updated.561840/
Thanks!
 
Joined
Jan 25, 2011
Messages
993
Location
Hangzhou,China PR
You can use the WB to edit and export a scenario.
But I find that in that way, the .txt of the scenerio is different in form of codes from the existed 3000bc, 600ad and 1700ad scenerios. Will it cause some bugs?
Also, how can I get to the year 1800ad? Just start a game and play until 1800ad? Or can I edit some data to make it get to the year 1800? Thx
 
Last edited:

Leoreth

Vampire of the Blue Moon
Moderator
Joined
Aug 23, 2009
Messages
36,009
Location
Paris
You need to do some work to add the new scenario to the rest of the code, at least getScenario, getScenarioStartingTurn and getScenarioStartingYear in C++ and Python.

You will also need to include it in Scenarios.py (current git).

Editing a scenario in WB will produce a new wbsave file when saved. It will look different to the existing scenarios in the scenario metadata, but everything describing the map itself should be equivalent.

A good way to handle this is to copy an existing scenario (e.g. 1700 AD) and the replace only everything after PlotInfo with the output wbsave. Everything else (e.g. players) should and easily can be edited manually.
 

MalayanGamer

Prince
Joined
Sep 30, 2018
Messages
332
Help me guys. I want to make a Varietas Delectat mod for a Merijn but the problem is when i tried to make a VD for a Phillipines Civ it didn't work. Can anyone tell me how to do it?!?!? :confused::confused:

Moderator Action: Please use this thread for modding questions instead of starting new threads (post moved) -- Leoreth
 
Last edited by a moderator:

MalayanGamer

Prince
Joined
Sep 30, 2018
Messages
332
Top Bottom