How do I make a mod with custom events?

KommissarReb

Chieftain
Joined
Aug 28, 2015
Messages
32
Location
United States
I read TC01's pinned thread but still haven't figured out how to successfully make an event mod.

What I want to do is make a mod with an event where the king contacts the player to inform them that they are at war with the king of another country, and that the player must declare war on that countries' colonies. This event will cause the player's king to declare war on the target king with the option of declaring war on the rival king's colonies to improve relations with the king by 1 (custom text: "We thank you for your service"), or worsen relations by 1 (custom text: "You engaged in desertion!").

The big feature I want to add to this event is making both the king of the message receiver's country and the king of the target country send their REF into the New World to duke it all out. I'm okay if they won't be able to send their land units back on their Man-O-Wars and back to Europe (though that would be nice), I could write that one off as the kings "protecting" their colonies. I want to also have an event that increases in percentage chance after 6 turns pass where the kings will cease hostilities with their rival kings and their rival king's colonies (so the event doesn't interfere with independence wars) and the player's king will tell the player to

I've always wanted to make an event mod like this since in real life the empires did help protect their colonies from other empires, partially as one of few benefits to being a colony. Is it possible to make a mod that allows this to happen?
 
Puh, it sounds like you actually need more than a simply Python event with some XML config.
(Which in itself is not trivial for a beginner in modding.)

It sounds like you want to code a Diplomacy Event (DLL Diplo Event) with the Human Player which is randomly triggered with increasing chances.
If you do it the first time is more tricky than you might think because you have to know how to write / read game variables (e.g. for saves) and need to know the DLL Diplo Event coding patterns.
(If a modder however already did it a couple of times it becomes quite easy because you already know the patterns.)

If you are looking for examples of that you could check the source code of RaR or now its successor WTP.
"European Wars" or "European Peace" DLL-Diplo-Events could help you as examples - although they are leading to Kings demanding War / Peace between Colonies only.
(You will need to know how to code C++ and how to use Visual Studio to compile a DLL though.)

Having 2 Kings send their REF troops to the colonies and start fighting each other there would most likely not be possible currently without heavy modifications.
1) Right now Kings cannot declare each other War because they technically do not know each other (this could be easily changed in DLL).
2) The AIs of the King would need to be recoded to actually find each other and not simply land troops somewhere in nirvana and not knowing how to find the enemy.
3) This could have heavy side effects on WOI later on.

I definitely wish you good luck in your modding. :thumbsup:
Sounds interesting.
 
Last edited:
It sounds like you want to code a Diplomacy Event (DLL Diplo Event) with the Human Player which is randomly triggered with increasing chances.
If you do it the first time is more tricky than you might think because you have to know how to write / read game variables (e.g. for saves) and need to know the DLL Diplo Event coding patterns.
(If a modder however already did it a couple of times it becomes quite easy because you already know the patterns.)
If I was to use the source code from .RAR as sort of a guide to do this, where would I find the specific .DLL file? Is it CvGameCoreDLL.dll? I also went through RAR's CIV4EventInfos.xml and CIV4EventTriggerInfos.xml and I don't think I found the event where the king tells players to declare war. Is it in there, or am I looking in the wrong place?

I would be interested in learning how to make it so the kings know all European players at the start like in RAR so they can wage war on each other. I was wondering if it would be possible to have the REF on the King of X to attack the colonies of the King of Y and vice versa (mimicking their invasion during the WOI, but attacking rivals instead of their own colonies). I know it sounds crazy, but its definitely an experiment I'd want to try!

I do have some knowledge of how to use Visual Studio, as I was making a game in unity using this guide but that's pretty much it, and I didn't really get around to finishing it.

I'm sorry if the mod I'd want to make is not beginner material. It's just that if there's a mod for Civ 4 Colonization I'd want to make, this is the only thing I can think of. I'm wondering if I should also ask in the WTP mod forum for how they made their diplomacy event so maybe I could make my own that triggers a WOI invasion but with rival colonies being invaded instead. I hope that's not hardcoded or anything because I think it would be cool if it could be done.
 
The DLL file (CvGameCoreDLL.dll) is the result of compiling the source code / source files in C++.
(For RaR and WTP you will find all source files needed in the downloads for the mods.)

It contains all the heavy logic that is better done in C++ than in Python.
(C++ is core logic, Pyhton is UI and small easy code Pyhton events)

The DLL Diplo Events are C++ logic and have nothing to do with the "light weight" Python Events or the EventInfos.xml which is the config for the Python Events.
(Those are 2 very different concepts.)

The main difference of DLL Diplo Events to Python Events:
DLL Diplo Events are a much more powerful concept and can trigger basically every core functionality. (For UI in Diplomacy Dialog they usually require a bit of Pyhon coding as well.)
Python Events can only do a very small subset of that functionality. (Actually they mainly call some DLL functions that have been made visible to them which then do the main execution of the logic.)

1) You will need to set up a project in Visual Studio and start searching the C++ source files for "European Wars" or "European Peace" - if you want to use it as example.
There are some guides around for setting up a project for Civ4Col. (Basically it will require to download and configure some libraries and other small assets to be able to compile.)

2) You will also need to learn to programm C++ at least basically or good enough to implement your changes. It is your choice how complicated you want to start.
It is not that difficult actually if you have been programming in any ohter object oriented language but in cannot be done in a few days only if you start from scratch.

3) You will need to get acquainted with the Civ4Col specific logic / methods in the source code.
That will probalby take a couple of days as well. It does not make sense to programm methods that already exists. That you need to figure out by getting an overview.

4) You will need to get a technical concept for your feature, implement it, compile the DLL, test and bugifix until it is working.
Since I don't know your technical knowledge I cannot give any estimation how long it will take you.

5) You will need to know a bit of Python (for UI in Diplomacy Dialog) and XML (for the config) as well of course.
But that is usually the simpler part.

About Hardcoded:
Yes, the DLL is "hardcoded" considering the actual logic but usually the modders implement XML settings that the logic reads - but they are very specific for the corresponding feature.
(e.g. Units to be spawned, timers the logic should consider, min/max amounts for rewards, ...)

By the way:
I am the modder who implemented most of the DLL-Diplomacy events in TAC, RaR and WTP.
But of course you should ask other modders as well. The more people you ask, the more help and advice you will get.

Please, learn the basics of C++ first and read the existing code of the DLL-features I was telling you about.
If you do understand C++, the code should become mostly self explaining.

If you have specific questions on some of my old code I might try to answer but I simply don't have enough time to teach C++.

------

Summary:
It is alll doable if you are really interested in modding Civ4Col. Otherwise there would be no modders around.
But it is not just as simple as editing a script file or modifying a few settings in an XML.

I wish you a lot of success learning C++.
Most importantly have fun modding. :thumbsup:
 
Last edited:
I just realized that at the moment I most likely confuse you more with my post than I might acutally help. :(
DLL-Diplo-Events however is not really the easiest topic to get started with.

As I said, try to get an overview of the C++ code first.
Then search for the comments "European Wars" or "European Peace" in the C++ code.
After that search for the same comments in the Python files.
Hopefully things will get a bit clearer then. :)

Sorry, but I just don't know how to explain it better to you before you have your first code specific questions.
Otherwise I would need to write a big tutorial that is basically wasted once you have learned how Civ4Col modding works and to read the code yourself.
 
By the way, maybe I can tell you how I learned modding Civ4Col (incl. programming C++ specific to Civ4Col):

1. I had known programming object oriented before already (basically Java/J2EE up and down).
2. I joined another bigger Civ4Col modding project (which was TAC).
3. I started taking over small stuff (bugfixes, small improvments) for a couple of weeks.
----
Thus the project members of course were interested to explain stuff to me and to take the time to teach me their knowledge.
The more I learned the more I could contribute to the mod.
----
4. After the first couple of weeks I started programming my first small features (stuff like Learning by Doing, Natives Stealing Guns and Horses, ...) which I did for a couple of further weeks.
5. Then I started coding / adapting heavier features (like "Whaling" or implementing a new Yield Cocoa with all the game mechanics around it - including the Diplo Events as we were talking about and other like that)

My advice would be:
(If you really want to become a Civ4Col modder)

1. Join forces with somebody who is willing to invest time and effort to teach you.
2. Start with small and easy stuff (like bugfixes and tiny features) and just ask the other team members whenever you have questions.
3. Once you know the basics well enough try the first bigger concepts - but take your time and contiue asking.

You could learn everything you need to know from Civ4 BTS modding as well by the way.
The basics / technologies are pretty much the same as in Civ4Col.
 
Sorry for the late reply, but what would be the best online tutorial for learning what I need to know in C++ as far as this is concerned? I'm currently watching this video but I already know a lot of stuff in the video already. I installed the programs he's using, but for Civ4Col I have mostly been using Visual Studio 2017. I've also been reading guides to help with making .DLL files.

I've been going through the source files and I believe I found what I was looking for in CvGlobals and CvPlayer. I know I'm probably lazy for asking this, but do you know where in the files the king sends his units into the new world to attack the player during the WOI? In the past I tried doing this in the vanilla game via WorldBuilder by having my rival's king declare war on him and all of his king's units stayed in the old world (did this to myself also to make sure REF units were even around). If there's special code or scripting that will only allow the king to invade during the WOI only, I don't know where to look. (checked via google if old posts other people made answered my question, but didn't find anything).

If it turns out to actually be impossible to make the REF appear any time other than WOI when a revolution is started, then I would be okay with giving the king free units. What I'd like to know is what I can remove since RAR changes a lot from vanilla.
 
Last edited:
Ok, as I understand you can already set up your VS project and can compile the DLL.
That is already the first step. :thumbsup:

If not, here is a link to a BTS tutorial (which can be applied for Civ4Col as well):
https://forums.civfanatics.com/threads/the-easiest-way-to-compile-a-new-dll.608137/

... but do you know where in the files the king sends his units into the new world to attack the player during the WOI?

Not by heart.
I would need to trace back method / function calls step by step as well.

You could probably start from one of the former TAC comments as start point to find the right methods.
(TAC was fully integrated in RaR and is thus fully integrated in WTP as well. But of course it was heavily modified.)

By briefly checking the code:

// TAC - Messages - Ray - START
//Alert all Human Players of Revolution


or maybe this entry point is even better:

// TAC - AI Revolution - koma13 - START


I don't know where to look.

The only place to look for is the source code (+ XML + Python).
Nobody wrote tutorials or even created YouTube videos that specifically for the implementation of Civ4Col.

What I'd like to know is what I can remove since RAR changes a lot from vanilla.

Please do not waste your time even trying that.
It is way too complicated and too much effort to rebuild WTP / RaR to Vanilla or TAC.

If you don't like what RaR or WTP did, you should rather start your coding based on source code of Vanilla or TAC.
It wil be much much easier (in terms of effort and bugs) to adapt specifical code examples of RaR to your new code based on Vanilla/TAC than rebuilding RaR to Vanilla/TAC.

But again, there is nothin in RaR / WTP that you can simply copy paste - the DLL-Diplo Events I told you about can just serve as an example for you.
It might help you though to get some solution ideas, find parts of code to reuses and better understanding of such DLL-Diplo Events.

------

As I said, you will need to learn step by step Civ4Col codding (C++) for what you want.
There really is no simply scripting or copy paste solution.

It might be a bit challenging at first but great once you achieved what you want.
Have a lot of fun modding. :thumbsup:
 
But again, there is nothin in RaR / WTP that you can simply copy paste - the DLL-Diplo Events I told you about can just serve as an example for you.
I've been looking around for the vanilla .DLL, but haven't turned up anything yet besides "C4ColMakefile_1_2" (I forgot where I downloaded it), but didn't find CvPlayer or CvGlobals files in it. I'm under the impression that this is what the DLL is made of since it has some of the same files like "CyCityInterface".

I suppose if triggering an invasion from the kings before the WOI is not possible, I could either give the kings free REF units, or try making my own version of this game in Unity or something.
 
Top Bottom