Unit Naming

the only think left to do is to turn on logging and see if it is throwing any python errors. I can also put in a bunch of debug code and ship that to you to try and see what is happening (or not happening).

Are you up to that?
 
firstly - edit your civilization.ini file (typically found in the my docs/civ4 directory and turn on error logging ...

ini file said:
[DEBUG]

; Enable the logging system
LoggingEnabled = 1

; Enable synchronization logging
SynchLog = 1

; Overwrite old network and message logs
OverwriteLogs = 1

; Enable rand event logging
RandLog = 1

; Enable message logging
MessageLog = 1

Then, copy your 'UnitNameEventManager.py' file (found under '\Python\Contrib' of the mod directory) and replace it with the following (remove the '-print' from the file name).

Start the game, build a couple of melee units and send me the following files ...

'PythonErr.log' <- I expect this one will be empty
'PythonDbg.log'

These files are found in the 'C:\Users\<user>\Documents\My Games\Beyond the Sword\Logs' directory.
 

Attachments

  • UnitNameEventManager-print.zip
    5 KB · Views: 188
I just thought of something as I was reading your instructions for the debug mode. I have been trying to implement this in a game I just staeted. I never tried from a brand new game. I started a new game and it worked. Not sure why that makes a difference?
 
well then - problem solved? Good to know that it works for you. If you think you come up with a really good naming convention - please send them to me - I am getting bored of the default ones.
 
Thanks again for all your help. I now have a new question. Now that I have the naming working I think I want to change it slightly and wonder if this will work or cause confusion within the naming function. I see that in the Adv Naming area all the units are broke out. What I want to try is 1st Div 3rd Melee Bg. I see I can use the combat type option, but I only want Melee to be assigned to Warriors, Axeman, and Maceman (Heavy Footman). I want a different assignment for Spearman and Pikeman - 1st Div 1st Anti-Mount Bn. Swordsman would be different as well.

Will the naming module have problems iterating over Melee units when all of these are Melee? I am not so much concerned if it groups them all by Melee and they increment that way, I would probably need to increase the total that it can add from 5:5 to 15:15 or something. Worse case I can remove the division name and let it count 1,2,3... forever, but edit the name and add the division, but that brings up another question if I edit the name does this impact the creation of new names. For example:

I have it name a new unit 1st Melee Bg
I edit after creation the unit to be 1st Div 1st Melee Bg
Does my next unit created become 2nd Melee Bg? Or does it see the 1st unit is missing I will start with 1st Melee Bg again?
 
It's been ages since I put this code together so my memory of it may be shacky ... I guess I am saying 'try it and see'.

To your 2nd questions, IIRC, you will not have a problem changing a units name ... your 2nd melee unit will totally ignore what you renamed the first one.

Re your first question ... if you are counting over combat type (ie melee), then it will increment the counter if you build a warrior, axe, sword or spear - it doesn't care. If you want to use a different naming convention for spears, you will have to use the 'advanced naming' option and specify it as required (it breaks it down into ERA and Combat Type) - you will have complete control over 'Bgd' or 'Anti-Mount', etc.

Either way, if you build (say) warrior, axe, axe, archer, spear, warrior, axe and you are looping (counting) over combat type ... they will have names like:

warrior #1
axe #2
axe #3
archer #1
spear #4 <- 4th melee unit
warrior #5
axe #6

To get the spear to be '1st' you will need to count over unit - but then your axe will be #1, etc.
 
I think I know the answer to this question, but I will ask anyway..Is there a way to lump spears and pikes together, separate from axe, warrior, mace?

If not I guess what you are saying is i would have to have

axe = count by combat type
warrior = count by combat type
mace = count by combat type
sword = count by unit
spear = count by unit
pike = count by unit
 
I think I know the answer to this question, but I will ask anyway..Is there a way to lump spears and pikes together, separate from axe, warrior, mace?
No, not with the code the way it is.
 
There are tt1 and tt2 for counting. Are there more? What if we used instead tt[x] where x is a number?

With that, you could assign 2 numbers to each "branch" where you decide how to group units into "branches".
 
well - we currently have a 'count over' code - but you are probably right - we could expand / modify that to free it up.
 
Here is the code for unit naming.

## Naming Convention
## - ^civ4^ - no naming convention, uses standard civ4
## - ^rd^ - random name
## - ^rc^ - random civ related name
## - ^ct^ - City
## - ^cv^ - Civilization
## - ^ut^ - unit (eg Archer)
## - ^ct^ - combat type (Melee)
## - ^dm^ - domain (Water)
## - ^ld^ - leader
## - ^cnt[f]^ - count across all units (increments based on unit)
## - ^cntu[f]^ - count across same unit (increments based on unit)
## - ^cntct[f]^ - count across same city (increments based on unit)
## - ^cntuct[f]^ - count across same unit / city (increments based on unit)
## - ^cntc[f]^ - count across same combat type (increments based on combat type)
## - ^cntd[f]^ - count across same domain (increments based on domain)
We could change the 'cnt' part to something like this ...
## - ^cnt[?][f]^ - count across all units (increments based on unit)

where:

? = 'u' - count across same unit (increments based on unit)
? = 'ct' - count across same city (increments based on unit)
? = 'uct' - count across same unit / city (increments based on unit)
? = 'c' - count across same combat type (increments based on ? = 'u'combat type)
? = 'd' - count across same domain (increments based on domain)
? = anything else - count across units with the same '?' code

So, '^cnt[w][f]^' would count across any unit that had the same 'w' code while '^cnt[am][f]^' would count across any unit that had the same 'am' code.

So, use the 'w code for warriors, axes, swords, maces, etc and it would count across those. Use 'am' code for spears, pikes, elephants(?) and it would count across anti-mount units.

Note: This code is not currently in BUG.
 
been playing with the naming code ... anyone want to do some testing? This is what I changed it to ...

## - ^cnt[f][r]^ - counting code, if the code isn't there - return 'ALL'
## - where
## - r = 'a' means count across all units (just increments)
## - r = 'u' means count across same unit (increments based on unit)
## - r = 'c' means count across same city (increments based on city)
## - r = 't' means count across same unit / city (increments based on unit / city)
## - r = 'b' means count across same combat type (increments based on combat type)
## - r = 'd' means count across same domain (increments based on domain)
## - r = other, means count across units that have the same code
 

Attachments

  • UnitNameEventManager.zip
    5.2 KB · Views: 143
How does this interact with the count-cycling codes tt1 and tt2?
Nothing has changed for them. They just control how far up the count goes and what it resets to.
 
They just control how far up the count goes and what it resets to.

Which counter? All of them? Does each code have a pair of counters so you can do the

xth Bgd yth Div Supersoldiers
mth Bat nth Sqd PointyStickCarriers

thing?
 
yes, yes and yes. Actually - there is only 1 counter. Maybe an example will help ...

my fav ... borg ...

"7 of 9, unimatrix 1" would be generated by ...

^cnt[1][a]^ of ^tt1[1][6:9]^, unimatrix ^tt2[1][1]^

This will count over all units (the '[a]' in 'cnt') from 1 to a random number between 6 and 9. Once the counter hits that max, it resets to 1, the tt2 part goes up 1 and a new random max (tt1) is calculated.

Change the [a] to [c] and it counts from 1 to n for each city. Build a unit in City B and it starts at 1. tt1 and tt2 will be unique to that city.

Does that answer the question?
 
Yup. New question: How do counters with the same code but for different naming conventions interact?

Example

Melee: ^cnt[1][ma]^ of ^tt1[1][10:10]^ Melee/Ranged
Archery: ^cnt[1][ma]^ of ^tt1[1][10:10]^ Melee/Ranged

The first two have the same code (ma), so from my understanding you'll see

1 of 1 Warrior
2 of 1 Warrior
3 of 1 Archer
4 of 1 Spearman
...
10 of 1 Archer
1 of 2 Warrior

Is this correct? If so, what would happen if we changed the Archery convention's tt1 range?

Archery: ^cnt[1][ma]^ of ^tt1[1][5:5]^ Melee/Ranged
 
Yup. New question: How do counters with the same code but for different naming conventions interact?
Good question. I think that the list of unit names that you have given above will be generated.

If so, what would happen if we changed the Archery convention's tt1 range?
Now that is just evil! With zero testing, I would say that the following would happen ...

Melee: ^cnt[1][ma]^ of ^tt1[1][10:10]^ ^ut^
Archery: ^cnt[1][ma]^ of ^tt1[1][5:5]^ ^ut^

if you just built warriors ...

Warrior: 1 of 10 Warrior
Warrior: 2 of 10 Warrior
Warrior: 3 of 10 Warrior
Warrior: 4 of 10 Warrior
Warrior: 5 of 10 Warrior
Warrior: 6 of 10 Warrior
Warrior: 7 of 10 Warrior
Warrior: 8 of 10 Warrior
Warrior: 9 of 10 Warrior
Warrior: 10 of 10 Warrior
Warrior: 1 of 10 Warrior

if you just built archers ...

Archer: 1 of 5 Archer
Archer: 2 of 5 Archer
Archer: 3 of 5 Archer
Archer: 5 of 5 Archer
Archer: 5 of 5 Archer
Archer: 1 of 5 Archer

if you built warrior, archer, warrior, etc

Warrior: 1 of 10 Warrior
Archer: 2 of 5 Archer
Warrior: 3 of 10 Warrior
Archer: 4 of 5 Archer
Warrior: 5 of 10 Warrior
Archer: 1 of 5 Archer
Warrior: 2 of 10 Warrior
Archer: 3 of 5 Archer
Warrior: 4 of 10 Warrior
Archer: 5 of 5 Archer
Warrior: 6 of 10 Warrior
Archer: 1 of 5 Archer
etc

That is, the tt2 would only come into play when the counter exceeds it and it depends on the naming convention code for that particular unit.

^ut^ will return the unit.

You are just sitting there dreaming up this questions to bug me, aren't you!
 
Top Bottom