View Full Version : Random names for Units


Rabbit_Alex
Feb 27, 2006, 05:37 PM
Hello,

Which one of the Python scripts and/or XML files controls unit creation? By that I mean which script controls what happens immediately after a unit finishes being built at the beginning of a turn (giving experience/promotions if you have a barracks in a city, etc)?

I'd like to make a mini-mod where certain units are given random names taken from a list, kind of like how cities are given names from a list (although they go in order). Any suggestions on what is the best way to proceed?

Thanks for any help :goodjob:

IVZanIV
Feb 27, 2006, 05:45 PM
I'm assuming you mean naming a unit beyond it's given name e.g. Warrior to something like Kaarn Banderworth or the like. If I'm wrong, sorry.

In the UnitInfos.xml file there is a tag below each specific unit type called:
<UniqueNames></UniqueNames>
It is always closed except for in two cases. 1). All of the Great People have Unique Names to distinguish them. 2). The player opens them and inserts unique names of their own.

I think that generating random names could be able to be done akin to the random city name generator that has been created.

TheLopez
Feb 27, 2006, 05:45 PM
Rabbit Alex,

I wasn't planning to make a separate release of the code that does the random naming in the mercenaries mod, but if you want I can. So do you?

TheLopez
Feb 27, 2006, 05:47 PM
BTW, in the mercenaries mod there are over 16,000,000 possible names right now, I might expand that though.

Rabbit_Alex
Feb 27, 2006, 06:04 PM
That would be great Lopez. From my understanding, your mod makes the names up completely randomly, which is kinda what I want to do. Is there a way to take a random name from a list?

TheLopez
Feb 27, 2006, 06:16 PM
That would be great Lopez. From my understanding, your mod makes the names up completely randomly, which is kinda what I want to do.
When do you need it by?


Is there a way to take a random name from a list?


Yep,


nameList =[.........]
iNameList = len(nameList)

strName = listOfNames[gc.getGame().getMapRand().get(iNameList, "Random Name")]

Rabbit_Alex
Feb 27, 2006, 06:52 PM
When do you need it by?


No hurry. Whenever you feel like it.

Edit: How can I have the names be based on civilization? For example, an American battleship would be named the "U.S.S. Missouri" while a German battleship could be named the "Bismarck."

TheLopez
Feb 27, 2006, 08:43 PM
Alright here it is:
http://forums.civfanatics.com/showthread.php?t=161132 or just check my sig.....


EDIT: now