Quick Modding Questions Thread

So I changed some religions in a mod I'm working on, and for whatever reason now, when I discover a religion-associated tech, the religion doesn't found automatically. Any idea why this is happening? It could just have been an option I set and then forgot to change, or it could be a genuine bug. I don't know.
 
Repost: As I still need some code for this

Is it possible to get cities to be renamed through python?

Like this: Indraprastha->Delhi (1200 AD)->Shahjahanabad (1600 AD)

Or perhaps through conquest by another civ, let's say if Indraprastha is conquered by the Mughal Empire, it is renamed Shahjahanabad.
 
Repost: As I still need some code for this

Is it possible to get cities to be renamed through python?

Like this: Indraprastha->Delhi (1200 AD)->Shahjahanabad (1600 AD)

Or perhaps through conquest by another civ, let's say if Indraprastha is conquered by the Mughal Empire, it is renamed Shahjahanabad.

Through conquest is possible, I think, via the onCityAcquiredAndKept event manager (CvEventManager.py) function.

Dates would require a check every turn in python to see if the correct date had been reached.

Rats when my computer crashed I lost my link to the Python classes documentation etc., so sorry can't be more specific. Now I need to go hunt up that web page again
 
You have been given all the information to at least attempt your own implementation or look up mods that do something similar. Since you're not asking any follow up questions I assume you haven't actually put in any work of your own yet.
 
You have been given all the information to at least attempt your own implementation or look up mods that do something similar. Since you're not asking any follow up questions I assume you haven't actually put in any work of your own yet.
I can't find any mods that do that. Well, DoC does it, but that probably requires DLL.
And I do not know anything of Python. If I am to learn how do that, I'd probably better start reading a guide, if there is one. Honestly, the python codes are quite difficult to comprehend.

So, sorry to say it but I don't really see myself creating such an advanced piece of python coding.
 
You need to use the gatName() and setName() function on the city.
That would be getName(). I just answered the next question before it was even asked :lol:

I think it would be something as simple as this:
PHP:
if pCity.getName() == "Indraprastha":
    pCity.setName("Delhi");
Make a chain of those at the right location and you likely have what you want. This will rename regardless of who conquers the city though. You like need two if statements or two checks in one joined with "and". Something about if conquering player is of civ type X.

Maybe instead of specific civs, it could be triggered by the civ art style. Just one civ would be too rare while using art styles makes it way more likely to reach the trigger conditions. Something like
PHP:
if pCity.getName() == "Indraprastha":
    if pNewOwner.getArtStyleType() == gc.getDefineInt("ARTSTYLE_A"):
        pCity.setName("Delhi");

if pCity.getName() == "Delhi":
    if pNewOwner.getArtStyleType() == gc.getDefineInt("ARTSTYLE_B"):
        pCity.setName("Indraprastha");
Now this city will change name when conquered depending on the art style of the player getting the city. I didn't look up the precise variable names though, but they are presumably named something like this.
 
And I do not know anything of Python. If I am to learn how do that, I'd probably better start reading a guide, if there is one. Honestly, the python codes are quite difficult to comprehend.
I'm not too happy with the python structure either, but that is what we have to work with, so it would be good to at least know the very basic of it. Do pay attention to the tab layout. It's unusually important in python.

So, sorry to say it but I don't really see myself creating such an advanced piece of python coding.
It's not that advanced compared to what it could have been. It's more or less like I wrote in the last post. It's fairly close to how you would say it in English, at least compared to how "non-English" programming can be.
 
I would prefer if it changes depending on the civ.
Like if the CIVILIZATION_DELHI_SULTANATE captures "Indraprastha", the name changes to Delhi

Also, would I need to paste that code in the the CvEventManager?
And could I paste it just anywhere or do I need to paste it at a specific line?
 
I would prefer if it changes depending on the civ.
Like if the CIVILIZATION_DELHI_SULTANATE captures "Indraprastha", the name changes to Delhi
PHP:
if pNewOwner.getCivilizationType() == gc.getDefineInt("CIVILIZATION_DELHI_SULTANATE"):
I think that should do it.

Also, would I need to paste that code in the the CvEventManager?
And could I paste it just anywhere or do I need to paste it at a specific line?
If you copy paste, it will screw up tabs and the code will not work :(
Also it should be in the function for conquering the city.

Where i can found mod/mod component which increase terrain/feature yields if player research some specific technology ?
Medieval Conquest can do that, though I don't think that will help you :p
 
Thank you Nightinggale, but will not. I can't remember where i see that terrain/features yields are increased if player discover specific tech.
 
One word of warning regarding plot yield production. When it was first implemented in M:C, it looped techs just like it is done in most places. However the functions for plot production seems to be called quite frequently, which made the game slow down significantly. I replaced the loops with a cache and performance became acceptable again. The cache also gained knowledge of other bonus sources, like traits and I think this code ended up being faster than vanilla, but it was far from trivial to implement as well as time consuming.

This mean yield bonus from techs seems to be one of those features where just getting it to work isn't enough. It has to be done correctly to avoid a game breaking slowness.
 
in python code I think you have to use a consistent indentation system (either tab OR Space)

and each line of code has to be indented to the correct degree so that the code is read properly, subordinate code being indented further than code that runs it. Some copy pasting from some sources can mess up the very exacting and specific indentations and poof! Gone wrong.
 
in python code I think you have to use a consistent indentation system (either tab OR Space)
From what I read and experienced, tabs is the way to go. Using notepad++ and set it to show whitespace makes it print a tab character, which is very useful to tell tabs and spaces apart as well as to count the number of whitespace characters.

Some copy pasting from some sources can mess up the very exacting and specific indentations and poof! Gone wrong.
The forum fairly consistently changes tabs to spaces, meaning whatever python code you copy paste from the forum will break and has to be corrected. Copy pasting from the browser is also prone to encoding issues, though this is an issue for non-English comments and similar. The only safe way to distribute the code is to transmit it as a file, possibly as a txt file inside a zip file. However this isn't readable in the browser and defeats the purpose of typing it on the forum.
 
I add new formations in my mod and i get this errors:

Code:
Assert Failed

File:  CvInfos.cpp
Line:  7454
Expression:  false
Message:  [Jason] Unknown unit formation entry type.

Code:
Assert Failed

File:  CvInfos.cpp
Line:  7462
Expression:  m_vctSiegeUnitEntries.size() > 0
Message:  [Jason] Formation missing siege tower entry.

Code:
Assert Failed

File:  CvXMLLoadUtilitySet.cpp
Line:  1605
Expression:  bSuccess
Message:  OWN TYPE - dependency not found: (null), in file: "NONE"
 
The 3rd assert just tells of an incorrect xml setup. I hate that one because it doesn't tell what went wrong, just that something went wrong.

The first two tells of incorrect xml setup as well, but at least they are more descriptive. However they aren't vanilla and I haven't seen them before. It looks like missing formation type in XML, though it doesn't tell precisely which unit. It would have been nice if the assert had added getType() as this would tell precisely which one failed.
 
Back
Top Bottom