Civ Specific Great People Name

Yeah, so long as you are happy :D
Although I will not use the codes you copied and paste from GP portion.
Because the CyStatistics().getPlayerNumUnitsBuilt(XXX) only count those that you built.
You will end up with units with similar unique names.
For instance, First Rifleman built is Peter.
Now I draft a new Rifleman.
oUC is activated so a name is given to the new one.
However, CyStatistics().getPlayerNumUnitsBuilt(XXX) has not increased since you have not built a new Rifleman.
Thus, the drafted Rifleman will be Peter as well...

I guess there is no CyStatistics().getPlayerNumUnitsCreated... I have no idea where to look for that.

If not, using your new code would mean replacing CyStatistics...UnitsBuilt by your long formula used for iUnitCount, right?

Thanks, but on second thoughts, I prefer to stick to units built. Draftees are just cannon fodder not worthy to retain their names :devil:. Other cases: warriors from goody huts, units captured (don't have that in my mod), free units from technologies (reducing them in my mod), units received via Events, Python created units (don't have): all of them, I don't care. Still other cases?

@ JoeyB98: I made the list above also for you because the first thing you should ask yourself is if you want the code on onUnitCreated or onUnitBuilt. onUnitBuilt is restricted to Units built in a city but if you do need more i.e. names for the above cases, then you should use onUnitCreated.

onUnitBuilt: "my" code is valid (still in testing phase though).

onUnitCreated: code would have to be reviewed + you would need to activate a Python callback.

To enable Python exceptions:

under My Documents/My Games/Beyond the Sword folder, you have a file called CivilizationIV.ini. Inside you should find something like this:

; Set to 1 for no python exception popups
HidePythonExceptions = 0

The 0 setup will bring popups ingame if there are Python problems.
 
CyStatistics only keeps record of built, killed and lost. Basically those you see in the info screen.
Unfortunately, lost only refers to those killed in battle here.

onUnitBuilt is activated only when units are built, literally.
onUnitCreated is activated under much more situations as I already mentioned.
Built, Draft, Initial Units, Captured Workers, Gifted Units, Events, Python, WorldBuilder, Great People Born, Free Units from Techs.

However, even the method I used for onUnitCreated is not 100% foolproof, because as I mentioned, "lost" in CyStatistics only keep track of those killed in battle.
Yet there are many more ways to lose units, such as Gifting away, Deleting them, Spies detected, Usage of Great People.

This is why I only intended to keep it restricted to Great People Born and City Built List.
You can keep it simpler like isenchine by restricting it to units built only, ignoring all others.
 
Thanks for the link and the explanation!
 
Well, if you look at what I copied and paste from yours, and what isenchine posted, the alignment aka indentation is clearly different.

Follow isenchine, use tabs instead of spaces, and make sure the alignment is similar.

And activate python exceptions as mentioned.
 
Joey, what exceptions on startup?

Actually, we were expecting exceptions on building a unit, not before.

Please post your CvEventManager file again.

Of course we could provide you with a file ready for your use but then... what would you learn in the process? ;) Modding is fun! :) In the end, we'll get it right.

PS: unless you are using BUG of course.
 
When indentations are wrong, you will get errors upon startup. Because it cannot read the rest of the python file
 
Could the Golden Python enlighten me? :bowdown:

what does "if sName.find("TXT_") == -1:" do exactly?

.find("TXT_")?

== -1?

Thank you.
 
http://www.tutorialspoint.com/python/python_strings.htm

find(str, beg=0 end=len(string))
Determine if str occurs in string, or in a substring of string if starting index beg and ending index end are given; returns index if found and -1 otherwise

If there is an entry in the text file:
TXT_I_AM_BORED will translate into whatever it is in the text file.
If there isn't, it remains the same.

Thus, if it has translated, you won't find "TXT_" in the string anymore.
 
Thanks for the link and the explanation, Golden Python, now I think I got it.

So if you don't have that condition and if there is no entry for the text TXT_I_AM_BORED, you would end up with a unit named TXT_I_AM_BORED ! :D
 
2) Units Created have numbers attached to them.
Applied to all situations including building, drafting, capturing, world builder etc
Only exception is upgrading, unit retains name.
First Warrior will be Warrior 1

Can you create a option when upgrading the unit not retains the name? In RI, we would like to begin to include the real names of military units, however, some civilizations go through major changes, given the concept that we adopt in our mod. For example: Romans become Italians. Therefore we would like the Roman names not "upgrade" when it becomes Italian.
 
Eh you are confusing me.
You do not want the Roman names to upgrade to Italian ones.
Means you want to retain old name.
Yet you want an option not to retain old name?

Anyway I did mention the one for units created is not perfect though
 
Eh you are confusing me.
You do not want the Roman names to upgrade to Italian ones.
Means you want to retain old name.
Yet you want an option not to retain old name?

Anyway I did mention the one for units created is not perfect though

Yes, expressed myself badly. I don't want the Italian units with Romans names. This happens with upgrade. Yes, I want an option not to retain old name.

"Anyway I did mention the one for units created is not perfect though." What do you mean? Can you make a version just for units names/feature 2?
 
Because there isn't any section to edit the unit you are upgrading to.
Also, as mentioned there are ways where onUnitCreated gets screwed because there isn't a good counter to use to keep track.

Which is why in the end isenchine decided to just use onUnitBuilt and ignore the others.
Which is why I only bothered to give names to Great People and Cities because they work well.
 
Back
Top Bottom