Dynamic names

need my speed

Rex Omnium Imperarium
Joined
Oct 3, 2009
Messages
2,494
Location
European Union (Magna Batavia)
I wonder, does anyone have a tool that allows one to easily edit (and create new) dynamic names, based on the amount of cities, the civics (including combinations), the religion, the tech era, the specific civilisation, whether it's a vassal of someone, and whether the civilisation spawned recently / from a revolution / as a minor civilisation (those last two only make sense in RevolutionDCM's context)?

Because finding my way through DynamicCivNames.py is confusing.
 
I think there should be some sort of a Dynamic Civ Names modcomp to easily apply to mods. Currently there isn't.

And the process itself isn't the most straightforward one. Is there even a guide how to get it done?
 
I think the easiest approach would be to edit CvPlayer::getCivilizationDescription() in CvPlayer.cpp. It returns the description from civ xml.

What needs to be done is to edit the civ xml file to add more strings, CvInfo to read those strings from xml and store them in memory and make access functions to those new strings.

With that in place, CvPlayer::getCivilizationDescription() can be modded like this:
PHP:
const wchar* CvPlayer::getCivilizationDescription(uint uiForm) const
{
	if (GC.getInitCore().getCivDescription(getID(), uiForm).empty())
	{
		// start of modded code
		if (civ has civic(X) && !GC.getCivilizationInfo(getCivilizationType()).getDescriptionCivicX(uiForm).empty())
		{
			return GC.getCivilizationInfo(getCivilizationType()).getDescriptionCivicX(uiForm);
		}
		// more modded conditions for more names

		// vanilla code to ensure the civ always has a name
		return GC.getCivilizationInfo(getCivilizationType()).getDescription(uiForm);
	}
	else
	{
		return GC.getInitCore().getCivDescription(getID(), uiForm);
	}
}
With the right logics here, you can get what you want. However with the amount of input, the logics will not be that simple.

I have no idea if or how it can be done in python. Something about assigning a string to civ name under certain conditions. The DLL solution will check each time the name is used and as such it can't fail to update if the conditions change. It might fail to mark the screen dirty, but going into a city or an advisor and back should clear that issue, which mean it isn't as major as completely failing to change.
 
That is almost exactly what the DynamicCivNames.py does. The python code is just very confusing and thus not easily changed.
 
I just downloaded DynamicCivNames.py and.... yikes.

Programming logics and name strings are mixed together and.... I'm not investing the needed time to figure out how it works. It would take forever. It might be better to just start over and make a proper solution with separated setup and logics.

Also it modifies the DLL, yet the code for those modifications isn't included. That alone would be an issue when merging with other mods.

Sadly I'm not doing it because I have other modding, I consider more important.
 
I just downloaded DynamicCivNames.py and.... yikes.

Programming logics and name strings are mixed together and.... I'm not investing the needed time to figure out how it works. It would take forever.

Exactly:lol:. I did manage to make a minor changes to it based on the gender of the leader of the nation but "... the horror ...":D
 
I downloaded the standalone Dynamic Civ Names mod to take a look, but it simply crashes upon loading the mod. Does anyone have a working standalone? Actually I just need the dll with setCivName exposed to python.
 
Yeah, that's the one i downloaded.
The python is a mess and the mod cannot even run for me to test.
 
For those interested in the dll source code, see this post by jdog5000. It comes from the Revolution FAQ as indicated in a text file in the download.

Edit: it's all outdated code there, not updated to BtS 3.19
 
If someone provides a working dll with that function exposed to python, I can write a new python script from scratch.
 
I have just started a new SDK project and compiled the first basic BtS dll.

Now I have to find my way in the 57 source files provided for Revolution...

I think that all I really need is 5 files: CvPlayer.cpp+h, CyPlayer.cpp+h & CyPlayerInterface1.cpp.

I'll cry for help if needed. :cry:

Nightinggale, I presume that you don't really want to do it or else, you are welcome!

Anyway, now I have RL stuff to do.
 
My mod handles dynamic civ names in Python, adapting an implementation by embryodead for his Sword of Islam mod.

I think it is more elegant to use Python events to trigger a name change and then set a new value for the civ names, instead of implementing all sorts of conditions in the DLL. This way, the only thing that needs to be changed in the base DLL is exposing a setCivDescription() method for player instances (I think, not sure if the base DLL already allows that).

You can have a look at it here.
 
Looking at Dawn of civ, the feature looks quite simple from a DLL point of view.
PHP:
.def("setCivName", &CyPlayer::setCivName, "void(std::wstring szNewDesc, std::wstring szNewShort, std::wstring szNewAdj)" )
It adds this function to python. The function itself internally just writes the new strings to the player and then tell the exe to redraw the screen. I could make a DLL, which does just that in no time... if only I was actually sitting next to a computer with BTS installed.

I think it's just a matter of copy paste of setCivName in CvPlayer and CyPlayer as well as the line from CyPlayerInterface1.cpp I copy pasted here. If nobody else makes that DLL, then I will take a look at it this weekend.
 
My mod handles dynamic civ names in Python, adapting an implementation by embryodead for his Sword of Islam mod.

I think it is more elegant to use Python events to trigger a name change and then set a new value for the civ names, instead of implementing all sorts of conditions in the DLL. This way, the only thing that needs to be changed in the base DLL is exposing a setCivDescription() method for player instances (I think, not sure if the base DLL already allows that).

You can have a look at it here.

I thought you could only have a maximum of one event per player per turn. Wouldn't this reduce the chance of more "interesting" events that happen?

Looking at Dawn of civ, the feature looks quite simple from a DLL point of view.
PHP:
.def("setCivName", &CyPlayer::setCivName, "void(std::wstring szNewDesc, std::wstring szNewShort, std::wstring szNewAdj)" )
It adds this function to python. The function itself internally just writes the new strings to the player and then tell the exe to redraw the screen. I could make a DLL, which does just that in no time... if only I was actually sitting next to a computer with BTS installed.

I think it's just a matter of copy paste of setCivName in CvPlayer and CyPlayer as well as the line from CyPlayerInterface1.cpp I copy pasted here. If nobody else makes that DLL, then I will take a look at it this weekend.

That looks like exactly what is needed from the dll side.
 
Hopefully, here it is, with setCivName. It's a working dll but I did not test the Python function.

You might need more than just that, but that's largely enough for me for today... :(
 
I made a Dynamic Names XML Modcomp (i.e. defining dynamic names in XML) from scratch some time ago, but never got around releasing it (wanted to add more features then lost interest and forgot about it).
I just tested it and it seems to work, so I attached it. To change dynamic names, edit Civilizations/CIV4CivNameInfos.xml, which at the moment seems to contain names collected from RFC: Dawn of Civilization and Classical World (thanks), and probably Wikipedia.
I'm unlikely to work on this anytime soon, but if somebody finds a bug, I'll see what I can do.

Also included is AIAutoplay by jdog and a rather old version of platypings Worldbuilder for testing. I think the "Modules" and "python" folders contain nothing related to the core component, except two minor edits in CvMainInterface.py.
 

Attachments

  • CivNames.zip
    2.7 MB · Views: 43
Interesting names are based on various stuff (eg civics and era) but can also be special to some nations. Very complex stuff can be done.

Doesn't appear to handle gender differences based on the Leader:mischief:.
 
Top Bottom