AI Civilizations Restarting Modification

tchristensen

Emperor
Joined
Jul 21, 2010
Messages
1,241
Location
Grand Rapids, Mi
I thought I remember reading a post about a mod that allowed AI nations to re-spawn from Barbarian cities.

I would like to add this modification to my mod, where if an AI is destroyed they have a slim chance of taking over a barbarian city and restarting the civilization.

Does anyone remember this, or am I mistaken?

-Troy-
 
To hell with the mod you're looking for - just do it the way you want to do it. :D

Resurrecting a dead Civ is the easiest thing, by the way. Just make some units with CyPlayer.initUnit() for the Civ and its instantly revived. (You have experience the Egyptian Lion Syndrome, right?) You could have it conquer some city with those units, if you want. (Or you could just have some cities change owners.)

Why not restore old Civs in their old heartland? There are methods for fetching starting locations and for looking up the original city owner. So if say the city of Rome (the Roman starting location) was conquered earlier in the game and some conditions are met (like rampant unhappiness in the city and/or the city's owner has the Nationalism Tech) then there is a chance of Roman rebel units spawning around that city. Or the city could flip to the respawned Roman Civilization and the rebellion would grow from there.

This feature could of course be limited to AI Civs only, if you're worried about human players losing cities to respawning rebels. :rolleyes:

Yet another way of doing this could be to give the human player the option of granting independence to some city or some cities. If the human player refuses there could be a rebellion like proposed above - otherwise the takeover would be peaceful and the respawned city could start as a vassal of its former conquerer. Like with the Colonies feature.
 
What you just described sounds a lot like the RevDCM mod. I got the mod Neoteric World, which includes that one with it, and it did pretty close to what you described. I was playing as Germany, and one of my captured cities tried to revolt. You can also grant rebellious cities independence, and they'll become your vassal. Maybe you need RevDCM?
 
RevDCM is a good next bet Barb cities can form new civs and revolts can bring old civs back if I remember correctly.
 
Resurrecting a dead Civ is the easiest thing, by the way. Just make some units with CyPlayer.initUnit() for the Civ and its instantly revived. (You have experience the Egyptian Lion Syndrome, right?) You could have it conquer some city with those units, if you want. (Or you could just have some cities change owners.)

Why not restore old Civs in their old heartland? There are methods for fetching starting locations and for looking up the original city owner. So if say the city of Rome (the Roman starting location) was conquered earlier in the game and some conditions are met (like rampant unhappiness in the city and/or the city's owner has the Nationalism Tech) then there is a chance of Roman rebel units spawning around that city. Or the city could flip to the respawned Roman Civilization and the rebellion would grow from there.

I do very much like this idea... how exactly could this be accomplished (I mean how to get the conditions and such, not the actual respawn).
 
I do very much like this idea... how exactly could this be accomplished (I mean how to get the conditions and such, not the actual respawn).
Do you know any Python?

The class methods (functions) mentioned in my post were:

CyCity.isDisorder(), and perhaps also CyPlayer.isAnarchy(), for the event condition.

CyTeam.isHasTech() if you wanna make some Tech a prerequisite for the respawn.

CyCity.getOriginalOwner() to get the city founder and CyPlayer.isAlive() to check whether or not that Civ is dead.

Probably CyInterface.addImmediateMessage() to tell the player what is going on.

Check the API for more details (what parameters to use with them the and what they return).

I guess you would have some code cycle through all Civs at some interval and detect if any of these are experiencing Anarchy. Perhaps also check if that Civ knows Nationalism. Then get a current active city list with PyPlayer.getCityList() which in turn is iterated through to see if any is in disorder. Once such city is located, the original owner is compared to the current one (the one from the first iteration) - and if they don't match and the original owner is dead - then the event can take place and the code prints out the event message. There could also be a random element to it, depending on the scenario.

edit: This is pretty basic programming and we could turn this into a little class if anyone is interested.
 
I do know a little bit of python, partly from what i've managed to scratch out myself and partly from others on this site (primarily The_J) helping me whenever I run into trouble. I also already have the API bookmarked. :)

Another possibility is to check the city for units, run a kill check, and then spawn some new units outside the city with the attributes of the units killed, to simulate desertion of Pro-rebel forces.
 
All sounds very interesting. Perhaps I will first look at the mod described above and then look at doing some basic programming.
Start with the programming, then look for other people's code for ideas. :D

Because once you know programming, you will be able to do your own ideas, instead of trying to implant other people's stuff into your own mod. Merging mods can be much harder than to actually make your own code, because you need to understand someone else's code in order to use it yourself. And there might also be compatibility issues that make it necessary for you to rewrite some that other code, and you won't be able to do that unless you understand what it does.

With that said, once you know what you're doing, merging mods can of course save you hundreds of hours of work...

We could of course jump start the programming thing with a hands-on lesson in CivIV Python. I think a little respawning/rebellion mod (as requested in the OP) would be a good place to start. Then you could backfill the information you need to fully understand what we just did. Just tell me and class will be in session. :king:

This also goes for the spell casting thing. If you do learn proper programming you can make your own thing, and get it just like you want it. I'll even walk you through it, if you want. Promise. :king:

Before you start Python modding though, you might wanna consider using the BUG mod as the basis of your own mod. I believe there is a tutorial to get you started with modding also, and BUG is supposed to be chock full of useful tools for this. (Unfortunately I'm basing my own modding on the RFC mod, so I'm yet to look into modding with BUG.)

Or you might wanna use another mod as a template for your own mod. Preferable one that you can use to build on - not strip down to bare bones. (In the last case I'd go with BUG, as it has no gameplay changes what-so-ever.)
 
Another possibility is to check the city for units, run a kill check, and then spawn some new units outside the city with the attributes of the units killed, to simulate desertion of Pro-rebel forces.
Yeah. Another idea for just having insurgencies would be spawn Barbarian rebel units with the same unit type that the current conscript unit type of the city. You can get that value with CyCity.getConscriptUnit() - because then the rebel units would always be at the same technological level that the city owner. (Pre gun-powder these will be melee units, by the way. But early on mostly just Warriors...)
 
Wow, I like that idea.
Which idea specifically? (There seems to be several flying around here. :lol:)

Now to figure out how to do that!
Pick up the textbook already and we'll get cracking on it. Whatever it may be. :king:

I guess my point is that if you define a mod idea of you own along these lines, I'll make the code for it and we'll walk through it line for line. But there will be homework assignments. :lol: In the end you will be able to use what you learn in the textbook and in this tutorial to make whatever changes you like to the code. Because once you know how to do it, you can much have it your way.
 
I liked the idea of rebels forming from duplicates of what is garrisoned in the city -- thus, they will always be of an equal challenge for the city and era.

Is that something that can be done in python, or is that done from the SDK?

I sort of understand the Python aspect and have fiddled with IDLE. Sometimes when I launch the IDLE I get two windows and other times I get one? The first window almost appears to be a command window but it seems like I could almost close that one and just work from the second?

The SDK side still seems perplexing because when I download the SDK I am unsure what to do with all the folders -- there doesn't seem to be an "application" to run it?!?
 
I liked the idea of rebels forming from duplicates of what is garrisoned in the city -- thus, they will always be of an equal challenge for the city and era.
Define exactly what you want, like in great detail. How often will this sort of thing happen? What are the conditions for it happening? How many units? Et cetera. (You'll be able to change anything once you learn programming, but I need something concrete to work with right now.)

Is that something that can be done in python, or is that done from the SDK?
Oh, this is easily done with Python. This is in fact what you do with Python. The SDK thing is for the far-reaching game concepts, although you'd also be able to make something like an advanced magic system with Python. (You wanna do it with Object-Oriented Programming though, so take the time to learn these things before you start coding the big projects.)

I sort of understand the Python aspect and have fiddled with IDLE. Sometimes when I launch the IDLE I get two windows and other times I get one? The first window almost appears to be a command window but it seems like I could almost close that one and just work from the second?
You actually use both. One is the Python editor and the other is the Python Shell. But you can disable the shell in some preference - I did. (I can still access it from the Run menu. Thats also where the Check Module feature is found - use it before trying any code in CivIV.)

Use the command line shell to test out code and different Python statements. (I'll fire it up as soon as I feel uncertain about something - there's nothing like instant feedback!) There is also a built-in Python console in CivIV that you wanna try out sometime soon. This is mostly for running the CivIV specific Python stuff, but its all Python none-the-less. (But you cant run scripts with it. For that you have to use modules with CivIV. I do however believe you can run code modules by importing them.)

The SDK side still seems perplexing because when I download the SDK I am unsure what to do with all the folders -- there doesn't seem to be an "application" to run it?!?
I wouldn't worry about getting into C++ until you at least learn some basic OOP - the powerful sort of programming. Because then you'll be able to use what you learned with Python and apply it to the C++ language. These are both high-level languages and I believe they have more in common than what makes them different.

Baby-steps, remember? :D
 
The SDK side still seems perplexing because when I download the SDK I am unsure what to do with all the folders -- there doesn't seem to be an "application" to run it?!?

Download the SDK? You don't need to download the SDK. It comes with the game (and has since some fairly early patch to the vanilla game). It is all those .h and .cpp files in the CvGameCoreDLL folder. Some mods have their source code available via a code management system, but I wouldn't worry about that just yet.

The application to run is the Microsoft Visual C++ version of Visual Studio (presumably the free express version downloaded from Microsoft since I expect you're not spending a several hundred dollars for the commercial version). Set everything up as explained in various places. Of course, you can just read the files with any text editor, like Notepad++, since they are just plain text but that doesn't help you to build a DLL much.

(Actually, I have never actually set things up to build the DLL myself - perhaps soon. I am a professional computer geek though, so it won't seem nearly so mysterious to me as it does to you programming newbies.)
 
Yeah. Another idea for just having insurgencies would be spawn Barbarian rebel units with the same unit type that the current conscript unit type of the city. You can get that value with CyCity.getConscriptUnit() - because then the rebel units would always be at the same technological level that the city owner. (Pre gun-powder these will be melee units, by the way. But early on mostly just Warriors...)

Now, what could all this be attached to? onBeginPlayerTurn? Wouldn't that slow the game down though? And I don't know what other function it could be attached to...
 
Now, what could all this be attached to? onBeginPlayerTurn? Wouldn't that slow the game down though? And I don't know what other function it could be attached to...
Probably onBeginGameTurn but the actual code doesn't have to run every single turn either. So there is nothing to worry about. And it wouldn't be many lines of code either. Its not noticeable, but it could of course be timed to make sure.
 
OK, let me try and get a handle on this. So the Python stuff is all the files i see with the .h and .cpp suffixes. And I assume it is the files with the .py suffix?

The .py files are the ones I can edit with Notepad++.

I assume anything I change from the BTS version, I place in my Mod directory in the exact same file structure?

Perhaps someone could nudge me in the right direction, since this is all sooooo new to me.

The Idea: A city can generate revolutionaries matching some or all of the entrenched soldiers of the city.

The Trigger: Any time the city goes into revolt through conquest, espionage, or event.

Length: 100 turns

Results: a 5 percent chance per turn that "revolutionaries" spawn next to the city equal to one-quarter (rounded down) of the entrenched troops.

These "Revolutionaries" take on the flag of the barbarians and behave thus.

=====

Is there a place where each of the .py files are detailed as to what they do? For example, can I reference something that tells me what "AbandonRazeDemolish.py" does? Or do I just need to open each one and figure it out?

Thanks!
 
Top Bottom