View Full Version : Unit Naming
ruff_hi Sep 02, 2007, 11:13 PM 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)
## - ^tt1[f][x:y]^ - total where the total is a random number between x and y (number)
## - ^tt2[f][x]^ - total count (starts at x, incremented by 1 each time ^tt is reset to 1)
##
## Where [f] can be either 's', 'A', 'a', 'p', 'g', 'n', 'o' or 'r' for ...
## - silent (not shown)
## - alpha (A, B, C, D, ...)
## - alpha (a, b, c, d, ...)
## - phonetic (alpha, bravo, charlie, delta, echo, ...)
## - greek (alpha, beta, gamma, delta, epsilon, ...)
## - number
## - ordinal (1st, 2nd, 3rd, 4th, ...)
## - roman (I, IV, V, X, ...)
I've also written a short document that illustrates some possible unit naming conventions. You can set a default naming convention that is used for all units via the options screen. You can also set a different naming convention for each combat type from the options screen. If you select, 'Advanced', then the combat type naming conventions are ignored (note: the default naming convention is NOT ignored). The Advanced option allows you to set different naming conventions by ERA and by UNIT TYPE. You will need to edit the BUG Mod.ini file directly, these options are not available from the options screen.
Edit: Note that we changed some of the counting conventions so the above doesn't work for v3.6 (or maybe earlier) onwards. See this post for more details (http://forums.civfanatics.com/showpost.php?p=8379579&postcount=103).
ruff_hi Sep 02, 2007, 11:17 PM reserved for options screen shot.
alerum68 Sep 02, 2007, 11:47 PM Sweet! Thanks Ruff. Are you going to release this standalone or keep it in the family only?
ruff_hi Sep 03, 2007, 06:12 AM keep it in the family. I was thinking that we should have a thread here that touches on the components of our mod ...
- dom adviser
- logger
- main screen
- city screen
- etc
Cammagno Sep 03, 2007, 06:32 AM keep it in the family. I was thinking that we should have a thread here that touches on the components of our mod ...
I agree, at least for the one still under development.
What about the idea to ask the admin to move the old thread inside this folder?
Cammagno Sep 04, 2007, 03:27 PM Here is the code for unit naming.
Not tried yet in the game, but I'm reading the readme and it looks great! :goodjob:
The only thing that I have to say is that I fear it may be a bit confusing using [n] for generic attribute when we already have ^n^ for no naming convention and [n] (a real 'n' in this case) for 'number' as an attribute.
I suggest using something else, maybe even a capital N will be better.
I think it doesn't appear in the code, so it's only a doc's problem.
Cammagno Sep 05, 2007, 07:07 AM I'm sorry to say that it seems not to work for me.
What I did was to go to option screen and to check the box for using the unit renaming component, i left unchecked the advanced box, and I left all the text boxes as they were (so, the first one with ^u^ ^cnt[r]^ of ^ct^ and all the other one with "DEFAULT").
I built a couple of warriors, but they are still called simply "warrior" (well, the Italian word for "warrior").
I've missed something? :confused:
ruff_hi Sep 05, 2007, 07:45 AM hmmn - I will take a look at it.
Re your other comments about 'n' ... I am thinking of changing it so that ...
## - ^civ4^ - no naming convention, uses standard civ4
## - ^r^ - random name
## - ^rc^ - random civ related name
## - ^ct^ - City
## - ^v^ - Civilization
## - ^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)
## - ^tt1[f][x:y]^ - total where the total is a random number between x and y (number)
## - ^tt2[f][x]^ - total count (starts at x, incremented by 1 each time ^tt is reset to 1)
## - ^u^ - unit (eg Archer)
## - ^t^ - combat type (Melee)
## - ^d^ - domain (Water)
## - ^l^ - leader
##
## Where [f] is the number format and can be either 's', 'A', 'a', 'p', 'g', 'n', 'o' or 'r' for ...
## - silent (not shown)
## - alpha (A, B, C, D, ...)
## - alpha (a, b, c, d, ...)
## - phonetic (alpha, bravo, charlie, delta, echo, ...)
## - greek (alpha, beta, gamma, delta, epsilon, ...)
## - number
## - ordinal (1st, 2nd, 3rd, 4th, ...)
## - roman (I, IV, V, X, ...)
Cammagno Sep 05, 2007, 08:34 AM hmmn - I will take a look at it.
Re your other comments about 'n' ... I am thinking of changing it so that ...
## - ^civ4^ - no naming convention, uses standard civ4
## - ^r^ - random name
## - ^rc^ - random civ related name
## - ^ct^ - City
## - ^v^ - Civilization
## - ^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)
## - ^tt1[f][x:y]^ - total where the total is a random number between x and y (number)
## - ^tt2[f][x]^ - total count (starts at x, incremented by 1 each time ^tt is reset to 1)
## - ^u^ - unit (eg Archer)
## - ^t^ - combat type (Melee)
## - ^d^ - domain (Water)
## - ^l^ - leader
##
## Where [f] is the number format and can be either 's', 'A', 'a', 'p', 'g', 'n', 'o' or 'r' for ...
## - silent (not shown)
## - alpha (A, B, C, D, ...)
## - alpha (a, b, c, d, ...)
## - phonetic (alpha, bravo, charlie, delta, echo, ...)
## - greek (alpha, beta, gamma, delta, epsilon, ...)
## - number
## - ordinal (1st, 2nd, 3rd, 4th, ...)
## - roman (I, IV, V, X, ...)
better ^_^
what about ^cv^ for civilization (as ^ct^ is for city) and maybe ^st^ (for 'standard') or ^v^ (stands for 'vanilla') instead of ^civ4^? And, if you want to completly avoid using the same letter in 2 places, maybe ^rn^ instead of ^r^ for random name.
ruff_hi Sep 08, 2007, 03:29 PM Unit Naming bug fixes complete. I have also changed the logic behind how it searches for the naming convention / code.
look for ERA_UNIT naming convention in ini file (you have to manually edit these in the ini file, way too many options to put on screen
if not found, or returns DEFAULT, look for COMBAT naming convention
if DEFAULT, look for DEFAULT naming convention
Unfortunately, I cannot get the python code to read the ERA_UNIT value directly from the ini file HELP EF!!!
I'll update my word doc and give some more counting examples tonight.
ruff_hi Sep 08, 2007, 10:48 PM Unfortunately, I cannot get the python code to read the ERA_UNIT value directly from the ini file HELP EF!!!
I'll update my word doc and give some more counting examples tonight.
Problem fixed by removing some comments or some such. Doesn't make a lot of sense but it works.
I also updated the zip file in the first post.
Cammagno Sep 09, 2007, 10:26 AM Problem fixed by removing some comments or some such. Doesn't make a lot of sense but it works.
Now it works properly ^_^
And it seems to be really great! :goodjob:
Note: some of the "default" values in the ini file are already replaced by some code, is it intentional?
ruff_hi Sep 09, 2007, 01:20 PM re the 'defaults' ... yes, I was just playing. I fully expect people to change them.
Cammagno Sep 17, 2007, 05:11 PM Ehm, I'm a bit dumb, but I didn't get the true behaviour of tt1 and tt2.
Let's look at your Borg example (I think tou had to put "n" instead "f" in this, but doesn't matter):
^cnt[f]^ of ^tt1[f][6:10]^, Unimatrix ^tt2[f][1]^
Scout 1 of 7, Unimatrix 1
Worker 2 of 7, Unimatrix 1
Galley 3 of 7, Unimatrix 1
Bomber 4 of 7, Unimatrix 1
Axeman 5 of 7, Unimatrix 1
Swordman 6 of 7, Unimatrix 1
So, ^cnt[f]^ counts over all units (regardless of unit type, combat type and domain), from 1 to a random number chosen between 6 and 10, in this case 7.
I get it. But what about tt2?. It starts as 1 and stays equal to 1 until tt1 resets to 1? If it works in this way, the next unit will be something like:
Archer 7 of 7, Unimatrix 1
Bowman 1 of 9, Unimatrix 2
Correct? :confused:
ruff_hi Sep 17, 2007, 05:57 PM Correct? :confused:Yes. That is how it is meant to work.
Cammagno Sep 17, 2007, 06:04 PM Yes. That is how it is meant to work.
Good ^_^
------------------
Cammagno Oct 06, 2007, 04:02 AM hmmn - I will take a look at it.
Re your other comments about 'n' ... I am thinking of changing it so that ...
## - ^civ4^ - no naming convention, uses standard civ4
## - ^r^ - random name
## - ^rc^ - random civ related name
## - ^ct^ - City
## - ^v^ - Civilization
## - ^u^ - unit (eg Archer)
## - ^t^ - combat type (Melee)
## - ^d^ - domain (Water)
## - ^l^ - leader
I've just realized that in your readme you report a different one:
• ^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
so... what are the correct ones? :confused:
Cammagno Oct 06, 2007, 04:11 AM I've just realized that in your readme you report a different one:
• ^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
so... what are the correct ones? :confused:
Oh, answering to myself, i suppose that the correct one is the one included as a comment inside the file itself, so this one:
## - ^civ4^ - no naming convention, uses standard civ4
## - ^rd^ - random name
## - ^rc^ - random civ related name
## - ^ct^ - City
## - ^cv^ - Civilization
## - ^ut^ - unit (eg Archer)
## - ^cb^ - combat type (Melee)
## - ^dm^ - domain (Water)
## - ^ld^ - leader
So, I'll update the readme with that cb :)
Cammagno Oct 06, 2007, 06:53 AM Ok, so I started a new game, and I choose to leave all the naming convention set to DEFAULT, and to set the DEFAULT box to :
^ut^ ^cntu(n)^ (^ct^)
So, I expected that my firs Settler will be called something like:
Settler 1 (Rome)
instead I get a random name... where is my error? :confused: :blush:
Psyringe Oct 06, 2007, 07:23 AM Ok, so I started a new game, and I choose to leave all the naming convention set to DEFAULT, and to set the DEFAULT box to :
^ut^ ^cntu(n)^ (^ct^)
So, I expected that my firs Settler will be called something like:
Settler 1 (Rome)
instead I get a random name... where is my error? :confused: :blush:
Open the "BUG mod.ini" and find these lines:
# Advanced optional naming conventions based on ERA and UNIT CLASS
ANCIENT_SETTLER = ^rd^
This is a setting that is not accessible via the in-game option, but overrides whatever you specify there. Changing "^rd^" to "DEFAULT" in the ini should do the job.
ruff_hi Oct 06, 2007, 07:26 AM thx Psyringe - good catch.
Cammagno Oct 06, 2007, 08:23 AM Open the "BUG mod.ini" and find these lines:
# Advanced optional naming conventions based on ERA and UNIT CLASS
ANCIENT_SETTLER = ^rd^
This is a setting that is not accessible via the in-game option, but overrides whatever you specify there. Changing "^rd^" to "DEFAULT" in the ini should do the job.
Thanks :)
Edit:
The strange thing is that I had the advanced naming set to 0, so it had to ignore that convention... something wrong here, I suppose...
@ Ruff
I suggest that we provide a BUG.ini file with all the unit-naming options set to DEFAULT, in particular the advanced ones... we'll avoid a lot of questions.
Then maybe we can add a couple examples to the readme about using the advanced options... what do you think about this?
Edit:
I also suggest to include a "Use Advanced Options" check box in the Option screen.
EmperorFool Oct 06, 2007, 01:48 PM ^^ +1
All very good suggestions, Cammagno.
ruff_hi Oct 06, 2007, 01:58 PM Thanks :)
Edit:
The strange thing is that I had the advanced naming set to 0, so it had to ignore that convention... something wrong here, I suppose...
@ Ruff
I suggest that we provide a BUG.ini file with all the unit-naming options set to DEFAULT, in particular the advanced ones... we'll avoid a lot of questions.
Then maybe we can add a couple examples to the readme about using the advanced options... what do you think about this?
Edit:
I also suggest to include a "Use Advanced Options" check box in the Option screen.
Alerumn suggested moving the advanced naming options to a different ini file ... the coding for that defeated me. I took out the 'use advanced' a while back and changed the code to (in order) ...
check for unit / era
check for combat type
check for global
We can put the advanced option back ... any yeas or nays?
EmperorFool Oct 06, 2007, 02:08 PM You currently got a note on the options tab saying that the advanced options are in the INI. I'd change that by putting a checkbox on the tab "Use Advanced Settings (see INI file)", killing two birds with one stone.
If you check that box, it should ignore all the formats on the tab (combat type and global), unless of course the unit being named as "DEFAULT" as its format.
I haven't played with it yet, but does it fallback as I just described? If you have Ancient Archer set to DEFAULT, will it use Combat Type Archer's format, falling back to the Global format if CTA's is DEFAULT? That's what I inferred, but I'm not sure.
In fact, maybe change "Use Advanced Options" to be "Use Advanced Era/Type Formats" so the user knows what they'll get if they enable it without having to open the INI file. Minor suggestion, and maybe there's better wording. Of course, the hover text can be fully descriptive, so maybe ignore this.
ruff_hi Oct 06, 2007, 02:23 PM I haven't played with it yet, but does it fallback as I just described? If you have Ancient Archer set to DEFAULT, will it use Combat Type Archer's format, falling back to the Global format if CTA's is DEFAULT? That's what I inferred, but I'm not sure.This is what the code does. I'll put the 'Advanced' option back in with a very long hover text.
Anthrax Oct 13, 2007, 10:55 PM now all units are being named default........... literally !! :lol: :crazyeye:
[UnitName]
Enabled = 1
UseAdvanced = 0
Default = DEFAULT
CombatAIR = DEFAULT
CombatARCHER = DEFAULT
CombatARMOR = DEFAULT
CombatGUN = DEFAULT
CombatHELICOPTER = DEFAULT
CombatMELEE = DEFAULT
CombatMOUNTED = DEFAULT
CombatNAVAL = DEFAULT
CombatNone = DEFAULT
CombatRECON = DEFAULT
CombatSIEGE = DEFAULT
I liked the old file a little better ;)
[UnitName]
Enabled = 1
UseAdvanced = 0
Default = ^ut^ ^cnt[r]^ of ^ct^
CombatAIR = Birdie ^cntc[r]^
CombatARCHER = ^rc^
CombatARMOR = DEFAULT
CombatGUN = DEFAULT
CombatHELICOPTER = Whirly Birdie ^cntc[r]^
CombatMELEE = DEFAULT
CombatMOUNTED = Horsie ^cntc[r]^
CombatNAVAL = Floatie ^cntc[r]^
CombatNone = DEFAULT
CombatRECON = ^cntc[p]^ Recon
CombatSIEGE = ^cntc[o]^ Charles (Chuck)
Cammagno Oct 14, 2007, 02:08 AM now all units are being named default........... literally !! :lol: :crazyeye:
My mistake, sorry :blush: Already fixed.
ruff_hi Oct 18, 2007, 08:00 AM I've done it. It isn't pretty but it works (sorry EP). I've managed to move the advanced unit name codes out of the bug mod.ini file and into an ini file of their own. The advanced unit naming conventions are now in a separate ini file (Adv Unit Naming.ini). To use this file, you must check the 'use advanced' option.
So, the code does this ...
if use advanced, try to get unitnameconv from separate advanced ini file else unitnameconv = default
if not default, return
get combat unitnameconv
if not default, return
get default unitnameconv
return
Cammagno Oct 18, 2007, 08:14 AM I've done it. It isn't pretty but it works (sorry EP). I've managed to move the advanced unit name codes out of the bug mod.ini file and into an ini file of their own. The advanced unit naming conventions are now in a separate ini file (Adv Unit Naming.ini). To use this file, you must check the 'use advanced' option.
:goodjob: :goodjob: :goodjob:
# Advanced optional naming conventions based on ERA and UNIT CLASS
see other ini file (Adv Unit Naming.ini)
I'm not a py expert, but before the second line probably a "#" is missing... but I'm not sure of how comments works in py... :confused:
ruff_hi Oct 18, 2007, 08:44 AM errr - might be an error. Which file?
Cammagno Oct 18, 2007, 03:30 PM errr - might be an error. Which file?
BUG Mod.ini
Thornburgh Oct 20, 2007, 03:51 PM I think the idea of unit names is really cool. I like to see how a unit evolves over time. E.g., see centuries later that this was my capitol's first unit, etc.
However, the long names mess up the mouse over display, preventing stats from appearing on the same line as the name, usually with an awkward line break. This has caused me to revert to normal short names. Any ideas on how to fix that?
Thanks!
ruff_hi Oct 20, 2007, 04:07 PM I think the idea of unit names is really cool. I like to see how a unit evolves over time. E.g., see centuries later that this was my capitol's first unit, etc.
However, the long names mess up the mouse over display, preventing stats from appearing on the same line as the name, usually with an awkward line break. This has caused me to revert to normal short names. Any ideas on how to fix that?
Thanks!Yes - set up your own naming convention but with short names ... eg "Axe 4"
EmperorFool Oct 20, 2007, 06:41 PM If you want to keep long names and have less wrapping, you'd need to modify the C++ DLL to specify a wider hover area. Unfortunately, this isn't done from Python code.
I am getting more and more tempted to add some features to the DLL. I hesitated before because I used BetterAI, but now that it's baked into the game, I might go for it. It would still be unaltered gameplay, but I'd probably package it separately from BUG.
However, I'm short on time so this is still just an idea. I'd like to add other things to the hover text:
City: culter and GP turns, happiness and health
Units: the latest PLE adds some nice things I think. For one, the minimum movement points for a stack of selected units.
I guess I don't really have that many things to add. I'm sure I'm forgetting some.
Sam_Yeager Oct 21, 2007, 02:47 AM I am getting more and more tempted to add some features to the DLL.
The big problem with that is that anyone who wants to use a DLL mod for something else e.g. the BTS 3.13 unofficial patch is stuffed.
EDIT: I realise that those who are handy with C++ could merge changes in but a lot of us lack those skills.
pholkhero Oct 21, 2007, 10:16 AM as long as the dll changes are separate from the BUG, then it wouldn't be a problem.
also, i was wondering if it was possible to get rid of the "(unit type)" naming that is still displayed once you change a unit's name, eg, my units read: "1st Rome Swordsmans (Swordsman)" ~ is that deletable??
ruff_hi Oct 21, 2007, 10:27 AM also, i was wondering if it was possible to get rid of the "(unit type)" naming that is still displayed once you change a unit's name, eg, my units read: "1st Rome Swordsmans (Swordsman)" ~ is that deletable??No. Nothing we can do about that.
EmperorFool Oct 21, 2007, 11:37 AM Don't worry. Any changes I made to the DLL would be complete separate and unneeded by BUG. It would truly be an "extra" feature you could install. If I did it, I'd probably install it with BUG as "game.dll.removethisextensiontoinstall" or something. It would be unused by default and not clash with anything.
But this is a loooong way off.
ruff_hi Sep 26, 2008, 09:24 AM We've had reports of unit naming occurring even when it is disabled.
Hi,
I noticed that some units (not all) show custom names even if I have
customized unit names neither in the BUG options menu nor in the Adv Unit
Naming.ini file; and overall the unit naming is NOT ENABLED;.
There are 2 conventions showed; examples:
1) "Archer (Archer 1 of Washington)"
2) "Spy (Spy)"
I'm using Varietas Delectat 4.0 mod and not BAT mod.
BtS version is 3.17 (latest)
Thank you for your attention.
I got some saves from this game but ...
http://img442.imageshack.us/img442/4884/unitrename0015ky1.jpg
I guess I should have read the write up. What is 'Varietas Delectat 4.0 mod'?
EmperorFool Sep 26, 2008, 10:28 AM VD is a mod that contains ethnic unit and building graphics. BAT is essentially VD + BUG + a few other graphic mods, but this guy is running just BUG with VD it seems.
Keep in mind that the latest version of BUG creates INI files on the fly, and UN is on by default.
ruff_hi Sep 26, 2008, 11:19 AM I cannot load these saves after I load up the mod. My PC isn't big enough(?).
Ninja2 Nov 13, 2008, 06:34 AM I get this error in PythonErr.txt related to unit naming:
Traceback (most recent call last):
File "CvEventInterface", line 30, in onEvent
File "BugEventManager", line 250, in handleEvent
File "BugEventManager", line 263, in _handleDefaultEvent
File "UnitNameEventManager", line 250, in onUnitBuilt
File "UnitNameEventManager", line 401, in getUnitNameConvFromIniFile
File "BugCore", line 145, in get
AttributeError: 'NoneType' object has no attribute 'isColor'
ERR: Python function onEvent failed, module CvEventInterface
And in PythonDbg.txt:
12:52:11 ERROR: BugCore - option UnitNaming__Combat_AGE_OF_SAIL not found
I have added the new combat types to the BugUnitNamingOptionsTab.py:
def create(self, screen):
tab = self.createTab(screen)
panel = self.createMainPanel(screen)
column = self.addOneColumnLayout(screen, panel)
screen.attachHSeparator(column, column + "Sep1")
left, right = self.addTwoColumnLayout(screen, column, "Options")
self.addCheckbox(screen, left, "UnitNaming__Enabled")
self.addCheckbox(screen, right, "UnitNaming__UseAdvanced")
columnL, columnR = self.addTwoColumnLayout(screen, column, "UnitNaming")
self.addTextEdit(screen, columnL, columnR, "UnitNaming__Default")
self.addTextEdit(screen, columnL, columnR, "UnitNaming__Combat_AGE_OF_SAIL")
self.addTextEdit(screen, columnL, columnR, "UnitNaming__Combat_AGE_OF_STEAM")
self.addTextEdit(screen, columnL, columnR, "UnitNaming__Combat_AIR")
self.addTextEdit(screen, columnL, columnR, "UnitNaming__Combat_ANTIAIR")
self.addTextEdit(screen, columnL, columnR, "UnitNaming__Combat_ARCHER")
self.addTextEdit(screen, columnL, columnR, "UnitNaming__Combat_ARMOR")
self.addTextEdit(screen, columnL, columnR, "UnitNaming__Combat_DREADNOUGHT_AGE")
self.addTextEdit(screen, columnL, columnR, "UnitNaming__Combat_GUN")
self.addTextEdit(screen, columnL, columnR, "UnitNaming__Combat_HELICOPTER")
self.addTextEdit(screen, columnL, columnR, "UnitNaming__Combat_JET_AIR")
self.addTextEdit(screen, columnL, columnR, "UnitNaming__Combat_MELEE")
self.addTextEdit(screen, columnL, columnR, "UnitNaming__Combat_MODERN_NAVAL")
self.addTextEdit(screen, columnL, columnR, "UnitNaming__Combat_MOUNTED")
self.addTextEdit(screen, columnL, columnR, "UnitNaming__Combat_NAVAL")
self.addTextEdit(screen, columnL, columnR, "UnitNaming__Combat_None")
self.addTextEdit(screen, columnL, columnR, "UnitNaming__Combat_NUCLEAR_AGE")
self.addTextEdit(screen, columnL, columnR, "UnitNaming__Combat_PRE_DREADNOUGHT_AGE")
self.addTextEdit(screen, columnL, columnR, "UnitNaming__Combat_RECON")
self.addTextEdit(screen, columnL, columnR, "UnitNaming__Combat_SIEGE")
self.addTextEdit(screen, columnL, columnR, "UnitNaming__Combat_TRENCH")
Where else do I need to add these new types? I've looked at the Unit Naming.ini file, but not tried to edit it. If that is indeed where I need to edit, isn't it a little silly to have to do edits outside of the mod directory? It certainly makes it a little more difficult to make a simple zipfile mod... :)
ruff_hi Nov 13, 2008, 10:14 AM Where else do I need to add these new types? I've looked at the Unit Naming.ini file, but not tried to edit it.Yes. You need to add AGE_OF_SAIL against each unit for the 'advanced' feature to work.
EmperorFool Nov 13, 2008, 11:32 AM ERROR: BugCore - option UnitNaming__Combat_AGE_OF_SAIL not found
It looks like AGE_OF_SAIL is a new CombatType like MELEE and GUNPOWDER. This is not part of the Advanced Unit Naming feature, but it is somewhat related.
BUG has two methods of "placeholder" settings: those that use Python-supplied parameters to determine the actual setting to access. The first method--the one you're using--is used when you want to place those settings onto the options screen. The other method--used by the Advanced Unit Naming feature--doesn't allow for that.
The trick is that options screen requires an actual <option> or <list> defined in the configuration XML for each option on the screen. You then use the <accessor> tag to provide parameterized access to all your options:
<option id="CombatAGE_OF_SAIL" key="CombatAGE_OF_SAIL"
type="string" default="DEFAULT"/>
<accessor get="getByCombatType" set="setByCombatType"
args="combatType" id="Combat_%s"/>
To define an option using the second method, you just need a single <option> or <list>:
<option id="ByEraAndClass" key="%s_%s" args="era, class"
type="string" default="DEFAULT"/>
Why the difference? The options screen has translatable labels and hover text which are attached to Python Option objects, and I don't anticipate rewriting the screen to handle the second method of parameterized options. I'll take a look and see how much effort it will be, though.
That being said, what other options (no pun intended) do we have here? You want to be able to define options without modifying the configuration XML file from BUG, right? One thing I can probably add fairly easily would be the ability to tack on options to an existing INI file defined in another XML file. This would let you define the <option> for your new CombatTypes in your XML file, but have them attached to UnitNaming's INI file.
You still need to modify BUG UnitNamingOptionTab as you're doing now, but you don't seem to take issue with that. I assume that's kosher, yes? If so, I'll look into that when I get home tonight.
Ninja2 Nov 13, 2008, 02:09 PM Thanks for that explanation. I'm sure I don't understand all of it! :D All I wanted to know was where to do some extra edits. I found out that it was in Unit Naming.xml (your hint), and the section in that file now looks like this:
<option id="Combat_None" key="CombatNone"
type="string" default="DEFAULT"/>
<option id="Combat_AGE_OF_SAIL" key="CombatAGE_OF_SAIL"
type="string" default="DEFAULT"/>
<option id="Combat_AGE_OF_STEAM" key="CombatAGE_OF_STEAM"
type="string" default="DEFAULT"/>
<option id="Combat_AIR" key="CombatAIR"
type="string" default="DEFAULT"/>
<option id="Combat_ANTIAIR" key="CombatANTIAIR"
type="string" default="DEFAULT"/>
<option id="Combat_ARCHER" key="CombatARCHER"
type="string" default="DEFAULT"/>
<option id="Combat_ARMOR" key="CombatARMOR"
type="string" default="DEFAULT"/>
<option id="Combat_DREADNOUGHT_AGE" key="CombatDREADNOUGHT_AGE"
type="string" default="DEFAULT"/>
<option id="Combat_GUN" key="CombatGUN"
type="string" default="DEFAULT"/>
<option id="Combat_HELICOPTER" key="CombatHELICOPTER"
type="string" default="DEFAULT"/>
<option id="Combat_JET_AIR" key="CombatJET_AIR"
type="string" default="DEFAULT"/>
<option id="Combat_MELEE" key="CombatMELEE"
type="string" default="DEFAULT"/>
<option id="Combat_MODERN_NAVAL" key="CombatMODERN_NAVAL"
type="string" default="DEFAULT"/>
<option id="Combat_MOUNTED" key="CombatMOUNTED"
type="string" default="DEFAULT"/>
<option id="Combat_NAVAL" key="CombatNAVAL"
type="string" default="DEFAULT"/>
<option id="Combat_NUCLEAR_AGE" key="CombatNUCLEAR_AGE"
type="string" default="DEFAULT"/>
<option id="Combat_PRE_DREADNOUGHT_AGE" key="CombatPRE_DREADNOUGHT_AGE"
type="string" default="DEFAULT"/>
<option id="Combat_RECON" key="CombatRECON"
type="string" default="DEFAULT"/>
<option id="Combat_SIEGE" key="CombatSIEGE"
type="string" default="DEFAULT"/>
<option id="Combat_TRENCH" key="CombatTRENCH"
type="string" default="DEFAULT"/>
<accessor get="getByCombatType" set="setByCombatType"
args="combatType" id="Combat_%s"/>
Problem solved! :) So for my sake you don't need to spend any time on this.
Cheers!
mcorey Apr 17, 2009, 12:38 PM I am still somewhat confused on this module especially how the tt attribute works. So perhaps if I explain what I would like to do and perhaps someone could give me an example.
I am not sure if I want the subdivision at the unit or combat type level, but what I would like to see is 1st Div 1st Melee Bgd or 1st Div 1st Axeman Bgd. Each Axeman/Melee increments to a max of like 20. Then it starts over with 2nd Division. There should be a max there of some number like 4.
Is this possible?
ruff_hi Apr 17, 2009, 02:22 PM sure - I think I can help. How about you rattle off a couple of units with suitable names and I'll see what I can do for getting you a code that works
For Example (fill in what you would like each name below to be - assume that your groups loop at 4 so we don't have to get too carried away):
axe #1 -> 'name'
axe #2 -> 'name'
axe #3 -> 'name'
axe #4 -> 'name'
axe #5 -> 'name'
axe #6 -> 'name'
sword #1 -> 'name'
archer #1 -> 'name'
mcorey Apr 17, 2009, 03:00 PM Thanks. Here is what I am looking for...
axe #1 -> '1st Div 1st Axe Bgd'
axe #2 -> '1st Div 2nd Axe Bgd'
axe #3 -> '1st Div 3rd Axe Bgd'
axe #4 -> '1st Div 4th Axe Bgd'
axe #5 -> '1st Div 5th Axe Bgd'
... the axe bgd for 1st Div would go to let's say 10, then ...
axe #6 -> '2nd Div 1st Axe Bgd'
... and so on for 2nd Div, repeat for 3rd and 4th Div ...
sword #1 -> '1st Div 1st Swords Bgd'
... same as the axes ...
archer #1 -> '1st Div 1st Archery Rgmt'
... same as the axes ...
Thanks.
ruff_hi Apr 17, 2009, 04:36 PM Lets break this down into parts. But before we do that ... did you know that you can test your codes in the game? Ctrl-Alt-N will bring up a dialog box that will let you test your naming codes on the unit #1. Now, the required name for the first axe ... "1st Div 1st Axe Bgd" and here is the way to construct the code ...
Step 1 - the easy part ...
The 'Div' and 'Bgd' are easy - just put them in as words.
Naming code = "? Div ? ? Bgd"
Step 2 - name of unit
This is also pretty easy - just include the following:
^ut^ - unit (eg Archer)
So the code is now:
Naming code = "? Div ? ^ut^ Bgd"
Step 3 - incrementing by type of unit ...
The code contains a bunch of ways of counting (across all units, unit type, city, unit type and city, etc). For this one, we want to use the version that counts across unit. That is:
^cntu[f]^ - count across same unit (increments based on unit)
The number formatting in this case is 'ordinal' which is code 'o'. So, this means that our naming code is now ...
Naming code = "? Div ^cntu[o]^ ^ut^ Bgd"
Step 4 - telling it when to reset back to 1
We want to count up to 5, then loop back to 1. To do this, we need to include a tt1 code(basically telling it when to reset). That is:
^tt1[f][x:y]^ - total where the total is a random number between x and y (number)
Now for this particular name, you don't actually want to display this result. So you need to use the format code for silent ... [s]. This brings our naming code to:
Naming code = "? Div ^cntu[o]^ ^ut^ Bgd ^tt1[s][5:5]^"
Step 5 - Group counter
This requires a tt2 code. Again, the help file tells us what that is too ...
^tt2[f][x]^ - total count (starts at x, incremented by 1 each time ^tt is reset to 1)
And the naming code is now ...
Naming code = "^tt2[o][1]^ Div ^cntu[o]^ ^ut^ Bgd ^tt1[s][5:5]^"
I just tried this in game and it was golden :goodjob:
mcorey Apr 17, 2009, 11:19 PM Thank you. I will give this a try. I assume I change the 5 to a 10 if I want to start the next group at 10. But how do I stop the Division count at 4?
mcorey Apr 18, 2009, 12:14 AM Okay. Something is not working. My Axeman name came out to be
^tt2[o][1]^ Div 4th Axeman Bgd ^tt1[s][5:5]^
I blocked and copied the line from your post.
ruff_hi Apr 18, 2009, 04:18 AM hmmn - it worked for me. Did you try the in-game name testing option? Try moving the tt1 component to the start.
I just used it in-game and it worked for me ...
http://img21.imageshack.us/img21/7589/name0282.jpg
http://img21.imageshack.us/img21/2079/name0281.jpg
mcorey Apr 18, 2009, 05:15 PM Here is what I get when using the in-game name option.
http://img7.imageshack.us/img7/5075/unitprob.jpg
ruff_hi Apr 18, 2009, 05:21 PM hmmn - what can I say - it looks ok. Try changing the [s] to an [o] so that it will display.
mcorey Apr 18, 2009, 06:10 PM I tried and it just displayed the same with an o as it did with the s. Is there another option I need to have turned on? Also I am using BAT 1.1 does that make a difference?
ruff_hi Apr 18, 2009, 10:12 PM I tried and it just displayed the same with an o as it did with the s. Is there another option I need to have turned on? Also I am using BAT 1.1 does that make a difference?No - not really. And it is a little hard to debug because that is BUG option specific. Try dropping one of the 'tt' and see what you get.
mcorey Apr 18, 2009, 10:25 PM Okay I did a little at a time starting with
^tt1[o][5:5]^ Div
and I got 10th Div
When I added ^cntu[o]^ to the end of the line, I receivied just the format back. I then added ^ut^ to the line and received the format back. So it works at first then goes crazy.
ruff_hi Apr 18, 2009, 10:44 PM Put in the whole code and then send me your 'Unit Naming.ini' file - look under the 'Beyond the Sword\BUG Mod' folder.
ruff.hi at gmail dot com
ruff_hi Apr 18, 2009, 11:16 PM got it - tested it - worked perfectly. Which version of BUG are you using? I don't think we have played with the naming code for a good 12 months.
mcorey Apr 19, 2009, 01:34 AM I am running BAT 1.1, so I think that comes with BUG 3.5
ruff_hi Apr 19, 2009, 06:41 AM 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?
mcorey Apr 19, 2009, 11:54 AM Sure. I'm up for that just let me know what to do.
ruff_hi Apr 19, 2009, 12:08 PM firstly - edit your civilization.ini file (typically found in the my docs/civ4 directory and turn on error logging ...
[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.
mcorey Apr 19, 2009, 01:31 PM 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?
ruff_hi Apr 19, 2009, 01:38 PM 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.
mcorey Apr 20, 2009, 02:13 PM 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?
ruff_hi Apr 20, 2009, 02:35 PM 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.
mcorey Apr 20, 2009, 02:59 PM 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
ruff_hi Apr 20, 2009, 03:05 PM 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.
EmperorFool Apr 20, 2009, 04:48 PM 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".
ruff_hi Apr 20, 2009, 05:05 PM well - we currently have a 'count over' code - but you are probably right - we could expand / modify that to free it up.
ruff_hi Apr 20, 2009, 05:23 PM 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.
ruff_hi Apr 20, 2009, 07:40 PM 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
EmperorFool Apr 20, 2009, 08:18 PM How does this interact with the count-cycling codes tt1 and tt2?
ruff_hi Apr 20, 2009, 08:26 PM 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.
EmperorFool Apr 20, 2009, 08:32 PM 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?
ruff_hi Apr 20, 2009, 08:40 PM 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?
EmperorFool Apr 20, 2009, 08:51 PM 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
ruff_hi Apr 20, 2009, 09:14 PM 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!
EmperorFool Apr 20, 2009, 09:20 PM You are just sitting there dreaming up this questions to bug me, aren't you!
That's what happens when I put on my Quality Assurance hat! ;)
ruff_hi Apr 20, 2009, 09:22 PM That's what happens when I put on my Quality Assurance hat! ;)Question for you - do you think that I actually ran the new code that I banged together?
mcorey Apr 20, 2009, 09:33 PM I am willing to test this if you still looking for a tester. Of course I am still a little unsure of how to set up the code, So if you could give me the code for the example I had listed which started this. That would be great!!
ruff_hi Apr 20, 2009, 09:40 PM Great! Firstly, you will need to turn on 'advanced naming convention'. Then you will need to edit that appropriate ini file and use the following for your group 1 units (warrior, axe, sword, mace, etc):
Naming code = "^tt2[o][1]^ Div ^cnt[o][m1]^ ^ut^ Bgd ^tt1[s][5:5]^"
For your anti-horse units (spears, pikes, other?), you will need to use the following:
Naming code = "^tt2[o][1]^ Div ^cnt[o][m2]^ ^ut^ Anti-Mount ^tt1[s][5:5]^"
I think this should work. It should count over the 'm1' group and separately over the 'm2' group.
mcorey Apr 21, 2009, 01:43 AM Alright created my first Spearman and the unit name came out to be
1st Div 6th Spearman Bgd.
I expected 1st Div 1st Spearman Bgd. Here is the order of the Warriors, Axes, and Spearman I created were
Warrior - Warrior (inital one at start)
Warrior - 1st Div 1st Warrior Bgd
Warrior - 1st Div 3rd Warrior Bgd
Axeman - 1st Div 4th Axeman Bgd
Spearman - 1st Div 6th Spearman Bgd
Axeman - 1st Div 7th Axeman Bgd
Spearman - 1st Div 8th Spearman Bgd
I am not sure why 2nd Warrior Bgd was not built.
ruff_hi Apr 21, 2009, 02:25 AM that is great news! ie - it didn't crash and seems to have (almost) produced sensible names. Suggest changing the 'Bgd' to 'anti-mount' for spears so that we can make sure that it is actually picking up the spear naming convention.
I'll create my own file and see if I can find #2 and #5 tomorrow.
mcorey Apr 21, 2009, 09:25 AM Okay. I will change the Spearman name tonight. Also I had in mind that Swords would be totally different from Spears and Axe/Warriors, so is it conceivable I can use m3 for those?
Also, I thought the spearman was going to be 1st Div 1st Spear?
ruff_hi Apr 21, 2009, 09:37 AM Okay. I will change the Spearman name tonight. Also I had in mind that Swords would be totally different from Spears and Axe/Warriors, so is it conceivable I can use m3 for those?sure - that 'should' work.
Also, I thought the spearman was going to be 1st Div 1st Spear?that was my expectation too.
mcorey Apr 21, 2009, 10:33 PM I ran through the game again to add the AntiMount for the Spearman and I noticed while modifying the ini file that AntiMount was already there, since I copied your example. So I checked the settings and everything was set coorrectly in BUG, but I was producing the incorrect names.
I have BUG 3.6 and BAT 1.1 installed. I had been testing this in BUG 3.6. BUG is installed in my
C:\Program Files\2K Games\Firaxis Games\Sid Meier's Civilization 4 Gold\Beyond the Sword\Mods\BUG Mod 3.6\BUG Mod
directory, but was using the ini files
...\Documents\My Games\Beyond the Sword\BUG Mod
which is where BAT installed its BUG files. Is there an option I needed to change to use the BUG only files installed in the Program Files area?
Anyway, I changed the ini file there and it started producing the correct names, however the it grouped spears with axes. So I am wondering if the correct .py file is being used. I can copy the .py file over to the other area, but the BUG version there I believe is 3.5.
Nevertheless I ran threw some unit creations and here is what I got.
Warrior - Warrior (initial)
Warrior - 1st Div 1st Warrior AME Bgd (Washington)
Warrior - 1st Div 2nd Warrior AME Bgd (New York)
Warrior - 1st Div 3rd Warrior AME Bgd (Washington)
Axeman - 1st Div 4th Axeman AME Bgd (New York)
Spearman - 1st Div 5th Spearman AntiMount Bgd (New York)
Spearman - 2nd Div 1st Spearman AntiMount Bgd (New York)
Archer - 6th A2 Bn (Washington)
Archer - 7th A2 Bn (New York)
Axeman - 2nd Div 2nd Axeman AME Bgd (Washington)
Axeman - 2nd Div 3rd Axeman AME Bgd (New York)
Spearman - 2nd Div 4th Spearman AntiMount Bgd (Washington)
Swordsman - 2nd Div 5th Swordsman Raiders (Washington)
Spearman - 3rd Div 1st Spearman Bgd (New York)
Aseman - 3rd Div 2nd Axeman AME Bgd (Washington)
Axeman - 3rd Div 3rd Axeman AME Bgd (Washington)
Axeman - 3rd Div 4th Axeman AME Bgd (New York)
Swordsman - 3rd Div 5th Swordsman Raiders (Washington)
Spearman - 4th Div 1st Spearman AntiMount Bgd (New York)
Swordsman - 4th Div 2nd Swordsman Raiders (New York)
Also I was trying a name for Archers that was set in the UnitName.ini (not the advance), so this was bring used. So I was wondering if I have use Advance Naming enabled, but still have a name in UnitName.ini but DEFAULT in Advanced.ini is it supposed to use the UnitName name?
ruff_hi Apr 21, 2009, 11:32 PM 3.6 ... 3.5 ... makes no difference. We haven't changed the naming code for ages. It looks like the codes are still not producing the names you are after.
Re your question re archers ... I think that if you have DEFAULT in the advanced naming file, it picks the naming convention you have entered under 'default'. I could be wrong - it might look at the combat type one first - not sure (you could test it to see :D).
ruff_hi Apr 22, 2009, 10:01 AM I actually did some testing of my code, located the issue and fixed it. Re-tested it and it works fine. Will upload to SVN in a few minutes.
mcorey Apr 23, 2009, 09:21 PM I actually did some testing of my code, located the issue and fixed it. Re-tested it and it works fine. Will upload to SVN in a few minutes.
Was there something you wanted me to test? If so I am not sure how to get the code from the SVN.
Thanks again.
StMikael Jul 18, 2009, 01:59 PM Hmm ... been looking at this in Legends of Revolutions, and I am wondering, is there a way to give each unit a different name taken from a list? Say you want to name your battleships USS Maine, USS Arizona, USS Missouri, and so forth.
EmperorFool Jul 18, 2009, 04:19 PM Having lists of names is something we've wanted to add for a while now, we've just been so busy with other things. It shouldn't be that hard for a modder to pick up and add, and we'd gladly fold it into BUG.
alerum68 Aug 02, 2009, 11:34 PM Create a counting code at the front of the program, allowing for several counters, allowing people to count across units, unit types, units from certain cities, as well as longer counting strings.
ruff_hi Aug 02, 2009, 11:55 PM alerum's idea will probably need totally different code to count stuff. It will NOT be backwards compatible ... do we need to worry about that or should we add an option to use the old method and the new (yet to be written) method?
ruff_hi Aug 03, 2009, 10:20 AM here is my preliminary thoughts ...
add a counter control somewhere in the naming code ... something like this ...
{5,[2:5,6:10,x,y],[5:5,10:10],[2:2,4:4],[1:1,10:15],[101:101]}
translation
{5,...} means there are 5 counters
{...,[2:5,6:10,x,y],...} means that the 1st counter starts at a random number between 2 and 5 and counts up to another random number between 6 and 10, it counts over 'x' (same type of code as previous, city, combat type, city & combat type, etc) with special code 'y' so you can tell spears from axes
{...,[5:5,10:10],...} means that the 2nd counter starts at a random number between 5 and 5 and counts up to another random number between 10 and 10, it gets incremented once the 1st counter exceeds its max
{...,[2:2,4:4],...} means that the 3rd counter starts at a random number between 2 and 2 and counts up to another random number between 4 and 4, it gets incremented once the 2nd counter exceeds its max
{...,[1:1,10:15],...} means that the 4th counter starts at a random number between 1 and 1 and counts up to another random number between 10 and 15, it gets incremented once the 3rd counter exceeds its max
{...,[101:101]} means that the 5th counter starts at a random number between 101 and 101 and just keeps increasing, it gets incremented once the 4th counter exceeds its max
The balance of the naming code would tell you where to put each counter ...
"Group ct1[f], ct2[f] Div, etc"
where ct1 represents counter 1, ct2 represents counter 2, etc and the [f] controls the formatting.
alerum68 Aug 03, 2009, 05:49 PM will there be a limit on the amount of counters you can create, or will it be unlimited?
We need to make sure that counting between all different types, (unit, city, unit from city, etc) have their own counter. Right now only cnt will work, while cntu, cntuct, and things like that aren't working.
Also, there should be some kind of command or button to clear the counter.
ShannonCT Aug 06, 2009, 12:15 AM ## - ^cnt[f]^ - count across all units (increments based on unit)
## - ^cntu[f]^ - count across same unit (increments based on unit)
It seems these two codes are reversed. ^cnt[n]^ counts across same units (e.g. Warrior 1, Warrior 2, Archer 1). ^cntu[n]^ counts across all units (e.g. Warrior 1, Warrior 2, Archer 3).
## - ^cntc[f]^ - count across same combat type (increments based on combat type)
This isn't working the way I was expecting. I thought it should give something like Archer 1, Longbowman 2, Warrior 1, Axeman 2, Swordsman 3. It seems to be just counting across all units.
Ignorant Teacher Aug 19, 2009, 08:18 PM Hello guys!
I've updated my BUG to 4.0 and noticed that the numbering system is different. In 3.6 you'd have the units numbered based on what type of units they were. For example, if I went worker first, built 1 workboat and 2 warriors in London, they would be called Worker 1 (London), Workboat 1 (London), Warrior 1 (London), Warrior 2 (London). Now in the new version the number of the units have been following the total of all types of units you've produced. In the same build order, the names are Worker 1 (London), Workboat 2 (London), Warrior 3 (London), Warrior 4 (London). Was this intended? If so, is there a way I can set the naming system to the way it was before?
Thanks in advance.
Edit. I think what I asked is what is already being discussed, but I'm a total dummy for codes.
EmperorFool Aug 19, 2009, 08:44 PM No, this is indeed a bug introduced in 4.0 somehow. I'm seeing it in my current game as well, and I didn't change my own codes from the defaults. I'll ask Ruff to look at it.
ruff_hi Aug 19, 2009, 09:59 PM consider myself asked.
ruff_hi Aug 19, 2009, 10:36 PM I've updated my BUG to 4.0 and noticed that the numbering system is different. In 3.6 you'd have the units numbered based on what type of units they were. For example, if I went worker first, built 1 workboat and 2 warriors in London, they would be called Worker 1 (London), Workboat 1 (London), Warrior 1 (London), Warrior 2 (London). Now in the new version the number of the units have been following the total of all types of units you've produced. In the same build order, the names are Worker 1 (London), Workboat 2 (London), Warrior 3 (London), Warrior 4 (London). Was this intended? If so, is there a way I can set the naming system to the way it was before?Opps - I made a change to the counting code (developed a new counting convention) and failed to update the documentation or the default. Here is the translation (old to new) ...
OLD
^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)
NEW
^cnt[f][r]^ - counting code, if the code isn't there - return 'ALL'
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
Sorry about that. I did this so that the user can implement their own groupings to count over. For example, say you wanted to count over anti-mounted units differently than other melee units, then ...
turn on advanced unit naming
put ^cnt[f][Mount]^ against the spears, pikes, etc
put ^cnt[f][Other]^ against the other melee units
Ignorant Teacher Aug 19, 2009, 10:44 PM Please, help me understand.
If I want to go back to the old naming system, I should press ctrl+alt+o and go the the "Naming" tab. There I have a first line with a code. What should I type there?
Sorry if it's a stupid question. I'm really ignorant when it comes to programming.
EmperorFool Aug 19, 2009, 10:48 PM ^ut^ ^cnt[n][u]^ (^ct^)
This will produce names like these:
Warrior 1 (London)
Axeman 1 (London)
Warrior 2 (Edinburg)
Swordsman 1 (London)
Ignorant Teacher Aug 19, 2009, 10:56 PM Thanks. I'll test it when I get home and then confirm to you it's working.
Edit. Let me see if I get it. If I want to keep separate counts for the units/cities, I should replace the ^cnt[n][u]^ by ^cnt[n][t]^ Is that right?
ruff_hi Aug 19, 2009, 11:10 PM Is that right?Yes - I think it is.
Aristos Aug 19, 2009, 11:13 PM to be honest with you, this was changed way ago (I always download SVNs), not in 4.0
I had to discover the new convention by trial and error, until I found how, some 1 month ago. I thought I was crazy and confused the original coding.
Nice to know I'm not. Yet. :D
Ignorant Teacher Aug 20, 2009, 12:06 PM It worked as intended.
Thanks for the support guys, I'd be unable to do it without your help.
EmperorFool Aug 20, 2009, 04:00 PM It worked as intended.
Thanks for reporting back success! :goodjob:
Siltur Oct 30, 2009, 03:22 AM Opps - I made a change to the counting code (developed a new counting convention) and failed to update the documentation or the default. Here is the translation (old to new) ...
OLD
^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)
NEW
^cnt[f][r]^ - counting code, if the code isn't there - return 'ALL'
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
Sorry about that. I did this so that the user can implement their own groupings to count over. For example, say you wanted to count over anti-mounted units differently than other melee units, then ...
turn on advanced unit naming
put ^cnt[f][Mount]^ against the spears, pikes, etc
put ^cnt[f][Other]^ against the other melee units
I notice that even in the BUG version 4.1, chm guide and contextual help report the old counting format (different codes with 1 parameter), not the new one (unique code with 2 parameters).
Please, have a look and update docs.
Thanks in advance.
Woodreaux Oct 30, 2009, 10:22 PM Is there are a FAQ or documentation for the "Unit Naming.ini" or "Adv Unit Naming.ini" config file? I saw in earlier posts there were references to it, regarding specific unit types:
* turn on advanced unit naming
* put ^cnt[f][Mount]^ against the spears, pikes, etc
* put ^cnt[f][Other]^ against the other melee units
I'd like to do things like that, but I don't know exactly how to define new categories like this. If such documents don't exist, I won't want you to write one just for this request, but maybe you could direct me to the Python (assuming it's not a DLL) file(s) which reads and interacts with it. I can probably figure it out from there.
Also, I wanted to thank the whole BUG team for all your hard work which has made the best video game in history even better! :goodjob:
EDIT: Please disregard everything before the last paragraph. I was looking at the wrong file.:hammer2:. Fail!
Dead-Eye Nov 21, 2009, 02:12 PM I want to insert a lot of units into "Adv unit naming.ini" (53 units per era, 371 units total) for BASE-Mod (BtS Additive Selective Enhancement; it is a collection of different mods into one mod), but while testing, the units aren't named as well.
I've tested with the simple rule for a few land units: ^cnt[o][b]^ Infantry, but the game called it with standard names like Warrior for Warriors and Archer for Archers instead 1st Infantry, 2nd Infantry and so on.
If I insert the same rule into BUG naming menu for close combats, they are named with 1st Infantry, 2nd Infantry and so on.
The field for extended unit naming was checked on in all cases.
There is a limit in BUG-Mod about the lines of units?
I've attached the file here. I had testet it without blank lines between the blocks, but with the same result. I hope, anyone can help me with my problem. Thanks!
234985
EmperorFool Nov 21, 2009, 03:22 PM The file looks okay, and blank lines are ignored. Did you try setting naming rules for the pre-existing lines in the file? You said you named close combat in the screen so I assume you mean you set naming for some combat type on the BUG Options screen. Is that what you meant?
Otherwise, make sure that the file is the correct file. Do you have another Adv Unit Naming.ini file that's being used elsewhere?
Dead-Eye Nov 21, 2009, 03:56 PM I've a backup here, so I can test it in original state.
Yes, the rules works in BUG-option screens, but doesn't works in Adv Unit Naming.ini with cleared screen (close combat field is clear).
I was little confused, because before I've inserted all neccessary lines, I've successfully tested with an unit. Now, after inserting 53 units per era, it doesn't works.
In next days, I'll test it step for step. At first with original file, then inserting 1 to 3 lines and then more and more.
For further tests, which file has higher priority: standard Unit Naming (BUG-Option screen) or Adv Unit Naming.ini?
EmperorFool Nov 21, 2009, 06:00 PM That sounds very much like it was not finding the right file. I believe that if you have the Advanced checkbox on the screen checked, the other fields on the screen are ignored and the file is used instead.
Dead-Eye Nov 22, 2009, 03:23 AM Mhmm, maybe the file has been modified by MS Word. It's easier to edit with Word than Wordpad or Notepad (it's a hard work to edit the lines every era), but I guess, it's a very stupid software to convert into txt-file.
I try to edit with Notepad and use copy & paste.
EmperorFool Nov 22, 2009, 03:25 AM I highly recommend getting Notepad++ (free). It's a great all-around text editor that would make adding those extra lines a breeze.
Dead-Eye Nov 22, 2009, 03:40 AM Thanks for your tip! I'll test it today evening.
I'll report here, if it's successful or not.
P.S.
You're working until deep in the night? At the moment, it's 01:30 AM in CA?! :)
EmperorFool Nov 22, 2009, 04:26 AM You're working until deep in the night? At the moment, it's 01:30 AM in CA?! :)
I was playing Left for Dead 2 actually. :)
Dead-Eye Dec 04, 2009, 11:25 AM Ok, it's time for a report.
Adv Unit Naming.ini works fine at me, but there is a guy, who have a problem with his file.
After editing and starting a game, no units of him was renamed. All units get civ4 standard name. I've tried to find out the error, but all I had find out was a error message at the beginning of the game.
See the picture below:
236243
Then I tested the same with my file without any error message at the beginning.
I've attached the file causes the problem here.
236245
I hope, anyone can find out the problem.
Thank you very much!
Best regards,
Dead-Eye
P.S.
How I can get a bigger picture here as attachment instead this thumbnail?
EmperorFool Dec 04, 2009, 02:54 PM The error is about [Custom]Assets/Config/UnitNaming.xml--not the INI file. Can you attach his version of that file?
To post larger pictures, upload them to an image hosting service like ImageShack or PhotoBucket and then use the Insert Image icon above your text when posting to place the [IMG] tag into your post (or just copy and paste it from the hosting site).
Dead-Eye Dec 04, 2009, 03:01 PM This file is a part of BUG 4.0.
Here is the file:
236255
EmperorFool Dec 04, 2009, 03:15 PM Tell him to replace all the non-English letters with their XML entities. He can look them up on Google; they look like ˜ and such. When I try opening that file on my work Ubuntu machine, it crashes gedit. I can see it's loading some of the special characters fine, so I can only guess that one or more of them are breaking the INI parser.
I'll try opening it again when I get home to see if there's anything else i can spot. Again, this is only a guess.
Dead-Eye Dec 04, 2009, 05:29 PM BINGO!!!!!
That is! I've replaced his INI-file all letters like ä and ü to ae and ue, and now, it works.
It's a little strange, because if there is a default parameter, all axemens are called as "Axtkämpfer" in german. Using the string "Axtkämpfer" in the INI-file cause an error message and Unit Naming will be deacitvated until reload the mod.
I've tested with unicodes instead using non-english letters.
For example:
ANCIENT_AXEMAN = ^cnt[n][u]^. Axtkämpfer
-> Axemens are named like "1. Axtk" instead "1. Axtkämpfer"
I recommend him to replace all non-english letters for a while (maybe forever).
EmperorFool Dec 04, 2009, 07:22 PM Oh, my post didn't come through correctly. I was saying you should be able to (test one) use the XML entities (http://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references) for those characters. I gave an example but the forum munged it. Lemme try again:
ä = ä
Dead-Eye Dec 05, 2009, 01:33 AM Ouch, I've write the wrong example. Sorry!
This is the correct example with result:
ANCIENT_AXEMAN = ^cnt[n][u]^. Axtkäämpfer
-> Axemens are named like "1. Axtk" instead "1. Axtkämpfer"
I shall not write at the midnight. :crazyeye:
Edith:
Uhm, the code has been replaced by this board.
Whatever, I had tried to use the code, you'd showed. The result is, the name will be cut off.
EmperorFool Dec 05, 2009, 01:51 AM Oh right, # and ; are comment characters in INI files. :( You can try enclosing the whole thing in quotes:
ANCIENT_AXEMAN = "^cnt[n][u]^. Axtkäämpfer"
Dead-Eye Dec 05, 2009, 02:02 AM Ok, so I'll test it in next days.
Dead-Eye Dec 05, 2009, 04:20 PM Now, I had tested your suggestion. Units will get randomized names like ^rc^ or ^rd^.
EmperorFool Dec 05, 2009, 07:03 PM That's probably what it does when it doesn't understand the code. Strange. Even if it doesn't understand the quotes, it should just treat them as normal text just like the names you're entering.
Sorry, I have no other ideas here. The INI file format has it's limitations. I'm actually more surprised that putting in the raw letters like á didn't work. When the file is opened, I don't think the INI parser specifies a specific encoding. In that case, it may get tripped up. I'll see if I can specify a different encoding.
Dead-Eye Dec 06, 2009, 03:42 AM Thanks a lot for your help.
At the moment, I recommend all users, who editing the INI file for naming, they shouldn't use non-english letters or unicodes until the code can read out the letters as well.
In the guide, there shall be a notice, who said, all non-english letters and unicodes in the INI file causes troubles. That would be fine for all european users.
DaleSwanson Jan 27, 2010, 12:38 AM Great mod, however I am having a problem. It seems the phonetic and greek alphabets are advanced one past where they should be. They start with bravo, and beta instead of alpha. If I use the tester and do not increment, and test the different outputs the rest are correct. I get: A, a, bravo, beta, 1, 1st, I.
Any ideas as to why this is? Where is the list of letters stored, can I just edit it myself?
Edit:
I found the python file, changed the array so that zulu, and omega are first in the list. Now it works fine, but I'm still puzzled as to why.
DaddyHolby Jan 27, 2010, 10:00 PM I think I see the problem. The FormatNumber function has the current code for phonetic:
i = ((i + 1) % 26) - 1
But when the first unit is created the value of i is 1. So you get (2 % 26) - 1 which results in a value of 1. Since the arrays are 0 based the value returned for phonetic_array[i] is Bravo instead of Alpha.
The greek code has the same problem.
The fix, I believe is to replace the code up above with this:
i = (i % 26) - 1
The reason why the top code works for the two alpha values is that it adds the result value (in this case 1) to either 96 or 64 which results in a chr(97) or chr(65). Which are the values for a and A respectively.
I hope this helps.
DaddyHolby Jan 27, 2010, 10:09 PM Here's a quick enhancement for random names for the next version.
Instead of having the ^rd^ and ^rc^ names just returning the random names why doesn't the code just do a replacement like the others? This way you could use the ^rd^ and ^rc^ tokens to randomly create ship names and still retain things like "USS" or "HMS" at the front.
Ex. - If you have the token DS-^cnt[n][Destroyers]^ ^rc^ the current code will just generate the ^rc^ portion and ditch the rest of the string. But if the code is changed to just replace the ^rc^ token then the result will be something like this, DS-12 Homer Simpson.
The key is that just doing the replacement won't damage the current functionality as anyone who just wants a random name can still just have a singular ^rc^ or ^rd^ token.
I've done this to the version of UnitNameEventManager.py that I have and here's the code I have:
## - ^rd^ - random name
# check if random naming convention is required
if not (zsName.find("^rd^") == -1):
zsRandomName = RandomNameUtils.getRandomName()
zsName = zsName.replace("^rd^", zsRandomName)
## - ^rc^ - random civ related name
# check if random civ related naming convention is required
if not (zsName.find("^rc^") == -1):
zsRandomName = RandomNameUtils.getRandomCivilizationName(pPlayer. getCivilizationType())
zsName = zsName.replace("^rc^", zsRandomName)
EmperorFool Jan 28, 2010, 12:21 AM Thanks for the fixes. I have committed them to SVN for the next release. I also fixed Juliet (one t). What's the preferred form for X?
X-Ray
X-ray (lowercase r)
Xray (no hyphen)
ruff_hi Jan 28, 2010, 05:22 AM http://en.wikipedia.org/wiki/NATO_phonetic_alphabet
Xray
Edit: Mind you, I wouldn't trust a site that has alpha as 'alfa'! Stuoopid idiots. Here is where I originally got it ... http://www.dynamoo.com/technical/phonetic.htm
Edit2: Maybe take this version ... they also have some history of other phonetic alphabets :) http://www.militaryconnection.com/military-alphabet.asp Apparently they went through quite some changes moving to NATO's version as they had to get one that could cater with some very strange accents (deep south anyone? :lol:)
DaddyHolby Jan 28, 2010, 09:49 AM Glad I could help.
Is it possible to have the unit's you start with renamed? You know that first warrior or scout?
It just always bugs me that that one unit doesn't follow the naming convention and if I'm using the counting name conventions then I have to start it a 0 or I end up with two units with a 1 in their names.
EmperorFool Jan 28, 2010, 12:52 PM Is it possible to have the unit's you start with renamed? You know that first warrior or scout?
I'll take a look at this tonight. It's absolutely possible, just gotta see how much work it is. If the API to access the naming is done well, it'll be a snap: loop over all units and call naming function for each.
I have to start it a 0 or I end up with two units with a 1 in their names.
You mean you don't name your first Warrior/Scout "Bob"?! :mischief:
DaddyHolby Jan 28, 2010, 12:56 PM I think I might have found the solution in a question I posted on the SDK/Python forum, so I'll give it a whack tonight too.
I'll take a look at this tonight. It's absolutely possible, just gotta see how much work it is. If the API to access the naming is done well, it'll be a snap: loop over all units and call naming function for each.
You mean you don't name your first Warrior/Scout "Bob"?! :mischief:
Strangely enough that's what I had been doing! :D
ruff_hi Jan 28, 2010, 01:06 PM Is it possible to have the unit's you start with renamed? You know that first warrior or scout?I'll take a look at this tonight. It's absolutely possible, just gotta see how much work it is. If the API to access the naming is done well, it'll be a snap: loop over all units and call naming function for each.I think it is possible in the 'GameStart' event (or something like that) ... just check that it is Turn 0 before you call loop over all of the players units and call the rename unit function.
Actually, I would do it in the 'end turn' event (again, checking for turn 0) so that you don't destroy the ability to regenerate the map (unit naming stores value in the save and doing that removes the regenerate option.
BTW - what happens with free units from huts?
DaddyHolby Jan 28, 2010, 01:09 PM BTW - what happens with free units from huts?
It doesn't generate a name, just the standard civ name. I was going to look into that next. I believe there's a hook like "onGiftReceived" or "onGoodyGifted" or some such that I saw in the main EventHandler last night that I believe you could hook into.
DaddyHolby Jan 28, 2010, 10:08 PM Well I've been playing with for a few hours now and I can't seem to get the eventhandlers for either onGameStart or onEndGameTurn to fire.
Here's the code I used to hook up the event in UnitNameEventManager.py:
def __init__(self, eventManager, *args, **kwargs):
super(BuildUnitName, self).__init__(eventManager, *args, **kwargs)
eventManager.addEventHandler("kbdEvent", self.onKbdEvent)
eventManager.addEventHandler("unitBuilt", self.onUnitBuilt)
eventManager.addEventHandler("endTurn", self.onEndGameTurn)
self.eventMgr = eventManager
self.config = None
And here's the coded for the event:
def onEndGameTurn(self, argsList):
'Called at the end of the end of each turn'
iGameTurn = argsList[0]
for iPlayer in range(gc.getMAX_PLAYERS()):
pPlayer = gc.getPlayer(iPlayer)
lUnitReName = UnitReName()
if (pPlayer.isAlive() and pPlayer.isHuman()):
(pUnit, iter) = pPlayer.firstUnit(false)
while (pUnit):
zsEra = gc.getEraInfo(pPlayer.getCurrentEra()).getType()
zsUnitCombat = lUnitReName.getUnitCombat(pUnit)
zsUnitClass = gc.getUnitClassInfo(pUnit.getUnitClassType()).getT ype()
BUGPrint("ERA(%s)" % (zsEra))
BUGPrint("Combat(%s)" % (zsUnitCombat))
BUGPrint("Class(%s)" % (zsUnitClass))
zsUnitNameConv = lUnitReName.getUnitNameConvFromIniFile(zsEra, zsUnitClass, zsUnitCombat)
zsUnitName = lUnitReName.getUnitName(zsUnitNameConv, pUnit, pCity, True)
BUGPrint("onUnitBuild-D")
if not (zsUnitName == ""):
pUnit.setName(zsUnitName)
BUGPrint("onUnitBuild-E")
(pUnit, iter) = pPlayer.nextUnit(iter, false)
return
My python's not that good so it's probably buggy as hell, but I believe something like that is what should happen.
EmperorFool Jan 29, 2010, 01:31 AM A couple random ideas:
Name initial units in onEndTurnReady event (fires after you've moved all your units).
Name initial units when the first city is founded. This way there's also a city to use for the name.
Name goody hut units using the capital as well.
Or use the civilization name (England) for all free units.
EmperorFool Jan 29, 2010, 01:49 AM As for detecting units from goody huts, it looks like I can handle it inside onGoodyReceived. The event is fired before the unit that takes the hut moves to the plot, so if the GoodyType gifts a unit I can assume the one unit on the goody plot is the unit to be named. :)
EmperorFool Jan 29, 2010, 05:23 PM Units from goody huts and initial units are now named, the latter when you found your first city. If you don't have a city when you get a unit from a goody hut, and the naming code for that unit type includes the city name, your civilization's empire name is used instead (e.g. Scout 1 of England).
DaddyHolby Jan 29, 2010, 10:32 PM Awesome.
MadmanAtW Jan 30, 2010, 02:10 PM I like that it waits on the first city to name your starting units, because that gives you the opportunity to turn off unit naming before it starts doing it automatically. :)
EmperorFool Jan 30, 2010, 02:40 PM Should I add a little warning on the screen?
zOMG YOUR UNITS WILL BE RENAMED IF YOU DON'T TURN IT OFF!!1!!11!1!
ruff_hi Jan 30, 2010, 03:06 PM zOMG YOUR UNITS WILL BE RENAMED IF YOU DON'T TURN IT OFF!!1!!11!1!ummm - you have to work on your interpersonal skills EF ... his name is 'MadmanAtW', not 'zOMG'.
caveman1917 Feb 11, 2010, 01:08 PM If i put in ^dm^ i get for example "DOMAIN_LAND" instead of "Land"
"^cntd[o]^ ^dm^ Army" will give "1st DOMAIN_LAND Army".
Is this supposed to be like this?
ruff_hi Feb 11, 2010, 01:36 PM probably not - that looks like a bug. I'll take a look at it when I get back from my trip (2 weeks).
EmperorFool Feb 11, 2010, 09:24 PM If i put in ^dm^ i get for example "DOMAIN_LAND" instead of "Land"
Fixed in r2131.
caveman1917 Feb 19, 2010, 06:55 PM A question, where can i get the latest release? And how do i update the version currently in BUG (as downloaded about last week)?
Also i seem to be having a problem with using multiple counts.
For example "^ut^ ^cnt[n][u]^, ^cnt[o][c]^ unit from ^ct^" will give "Warrior 1, ^cnt[o][c]^ unit from Thebes". I tried using the old convention but it gave the same error. It gives this error everytime i use multiple counts (eg unit & city, domain & city, ...)
EmperorFool Feb 19, 2010, 10:01 PM You can grab the file from our here (http://civ4bug.svn.sourceforge.net/viewvc/civ4bug/trunk/CustomAssets/Python/Contrib/UnitNameEventManager.py?revision=2131) and place it into [Custom]Assets/Python/Contrib, overwriting the file that's there.
ruff_hi Feb 20, 2010, 08:58 AM Also i seem to be having a problem with using multiple counts. For example "^ut^ ^cnt[n][u]^, ^cnt[o][c]^ unit from ^ct^" will give "Warrior 1, ^cnt[o][c]^ unit from Thebes". I tried using the old convention but it gave the same error. It gives this error everytime i use multiple counts (eg unit & city, domain & city, ...)and you cannot use multiple counts like that.
caveman1917 Feb 20, 2010, 11:14 AM You can grab the file from our here (http://civ4bug.svn.sourceforge.net/viewvc/civ4bug/trunk/CustomAssets/Python/Contrib/UnitNameEventManager.py?revision=2131) and place it into [Custom]Assets/Python/Contrib, overwriting the file that's there.
Ok thanks.
and you cannot use multiple counts like that.
Is it possible to implement this? I'm not familiar enough with python syntax to easily code in it, but by looking through the code i noticed there is a one time call to "getCounter". Perhaps it could be looped over a "getNextCounter"?
caveman1917 Feb 20, 2010, 12:01 PM I implemented the multiple counts. Since "getCounter" in essence already functions like a "getNextCounter", all that was needed was a simple while-loop around part of the code.
# check if there are any more codes to swap out, return if not
while (zsName.find("^") > -1):
# determine what I am counting across
zsSDKey = self.getCounter(zsName)
if zsSDKey == "UNIT": zsSDKey = zsSDKey + zsUnit
elif zsSDKey == "COMBAT": zsSDKey = zsSDKey + zsUnitCombat
elif zsSDKey == "CITY": zsSDKey = zsSDKey + zsCity
elif zsSDKey == "UNITCITY": zsSDKey = zsSDKey + zsUnit + zsCity
elif zsSDKey == "DOMAIN": zsSDKey = zsSDKey + zsUnitDomain
#BUGPrint("UnitNameEM-E [" + zsSDKey + "]")
# see if we have already started this counter
if (sdEntityExists(sdGroup, zsSDKey) == False):
#Since no record create entries
ziTT1 = self.getTotal1(zsName)
ziTT2 = self.getTotal2(zsName)
zDic = {'cnt':0, 'tt1':ziTT1, 'tt2':ziTT2}
sdEntityInit(sdGroup, zsSDKey, zDic)
# get the count values
ziCnt = sdGetVal(sdGroup, zsSDKey, "cnt")
ziTT1 = sdGetVal(sdGroup, zsSDKey, "tt1")
ziTT2 = sdGetVal(sdGroup, zsSDKey, "tt2")
#BUGPrint("UnitNameEM-F [" + str(ziCnt) + "] [" + str(ziTT1) + "] [" + str(ziTT2) + "]")
# increment count, adjust totals if required
if bIncrementCounter:
ziCnt = ziCnt + 1
if (ziCnt > ziTT1
and ziTT1 > 0):
ziCnt = 1
ziTT1 = self.getTotal1(zsName)
ziTT2 = ziTT2 + 1
# store the new values
sdSetVal(sdGroup, zsSDKey, "cnt", ziCnt)
sdSetVal(sdGroup, zsSDKey, "tt1", ziTT1)
sdSetVal(sdGroup, zsSDKey, "tt2", ziTT2)
# swap out the count code items for count value
zsName = self.swapCountCode(zsName, "^cnt", ziCnt)
zsName = self.swapCountCode(zsName, "^tt1", ziTT1)
zsName = self.swapCountCode(zsName, "^tt2", ziTT2)
return zsName
Seems to work.
Perhaps though there could be problems with tt1 and tt2 as they are incremented multiple times when you use multiple counts, or as it seems they are specific relative to each key so you'd have multiple tt1/tt2 counters.
EmperorFool Feb 20, 2010, 04:33 PM Thanks for that. :goodjob: Each counter type has its own current, tt1, and tt2 values. I'll put this into BUG later this weekend.
ruff_hi Feb 20, 2010, 06:09 PM there was some talk to overhaul the counter code a few pages back - we had a solution for unlimited number of counters - I just never got the time to code it up.
EmperorFool Feb 21, 2010, 06:49 AM Hmm, I just noticed that the hover text for the counting codes is still using the old codes. :( I've added the above code for multiple codes, but Ruff could you please fix the hover text when you get a chance (all languages)?
caveman1917 Feb 21, 2010, 11:13 AM I noticed when using domain it gives the full description.
For example "^dm^ Army" gives "Land units Army", where i suppose it should give "Land Army".
I don't know if it was intended like this, but in case it should have been the latter, i made a quick fix: in class UnitRename, def getUnitName changing
zsUnitDomain = gc.getDomainInfo(pUnit.getDomainType()).getDescrip tion()
into
zsUnitDomainList = (gc.getDomainInfo(pUnit.getDomainType()).getDescri ption()).split(None, 1)
zsUnitDomain = zsUnitDomainList[0]
EmperorFool Feb 21, 2010, 04:54 PM That won't work for all languages. In French, Italian, and Spanish you need to use [1]. :( In German it's a single word, but that should work since split() will return a single-element list I think.
So I'm putting translations into BUG directly without the Units portion:
<TEXT>
<Tag>TXT_KEY_BUG_UNIT_NAMING_DOMAIN_LAND</Tag>
<English>Land</English>
<French>Terrestre</French>
<German>Land</German>
<Italian>Terrestre</Italian>
<Spanish>Terrestre</Spanish>
</TEXT>
<TEXT>
<Tag>TXT_KEY_BUG_UNIT_NAMING_DOMAIN_SEA</Tag>
<English>Naval</English>
<French>Naval</French>
<German>Marine</German>
<Italian>Navale</Italian>
<Spanish>Naval</Spanish>
</TEXT>
<TEXT>
<Tag>TXT_KEY_BUG_UNIT_NAMING_DOMAIN_AIR</Tag>
<English>Air</English>
<French>Aérien</French>
<German>Aire</German>
<Italian>Aerea</Italian>
<Spanish>Aérea</Spanish>
</TEXT>
<TEXT>
<Tag>TXT_KEY_BUG_UNIT_NAMING_DOMAIN_IMMOBILE</Tag>
<English>Stationary</English>
<French>Stationnaire</French>
<German>Stationär</German>
<Italian>Stazionario</Italian>
<Spanish>Estacionaria</Spanish>
</TEXT>
If any of those are incorrect, please advise. Since these will be specifically for Unit Naming, do you want adjectives or nouns? Water vs. Naval? Heck, I could use better words for all of them.
Fuyu Feb 21, 2010, 05:03 PM immobile: <German>Unbeweglich</German> without the e. "Stationär" (german for stationary) would work too
edit: but if it is used as adjective then nvm, no matter what you use it would be wrong in some cases, german adjectives need declinations -_-
caveman1917 Feb 21, 2010, 06:54 PM Yes hadn't thought of that :(
As for the names i think they're good. They would, as far as i see it, be used mostly as an adjective form (eg Naval Battalion) instead of a noun (that would almost give "Battalion on Water" or something).
Perhaps change immobile to stationary. In the context of military use it seems to sound better to talk of a "stationary field emplacement" instead of an "immobile field emplacement". But i'm not a native english speaker so i may be totally wrong in this :)
The adjective-noun thing made me think of something, in the documentation it says that the civ name is in adjective form, but using this as Carthage in my current game it just still gave "Carthage" instead of the expected "Carthaginian". I looked at the code and found this
zsCiv = gc.getPlayer(iPlayer).getCivilizationShortDescript ion(0)
I'm not familiar with the game code itself, is this supposed to give the adjective or the noun form? If the former i'll test some more civilizations. The (0) suggests it would be returning the first item in some array which could be the noun.
EmperorFool Feb 21, 2010, 09:04 PM I almost want to say that "Land" should be Army if you're going to put this adjective before "Battalion," but I'm no military historian. I agree that "Stationary" sounds better here too.
I don't know the functions off the top of my head here, but one gives the noun and the other the adjective. I'll let Ruff take care of this. ;)
EmperorFool Feb 21, 2010, 09:24 PM I changed a few of the land/sea/air/immobile descriptions above.
caveman1917 Feb 21, 2010, 09:25 PM Yes you're right, it seems 'Army' is used specifically for land units. In dutch one may use it's equivalent 'leger' for the whole and 'landmacht' (land forces) for the terrestrial one. But it doesn't seem to be used that way in english :)
Do you perhaps know where i could find a reference on those available functions to hook into the game? I found a couple of tutorials for a variety of things, but not really a good reference overview of the classes and methods themselves.
EmperorFool Feb 21, 2010, 10:00 PM The Python API (http://civ4bug.sourceforge.net/PythonAPI/index.html) lists the functions and the parameters they take, but there is little in the way of actual documentation (what they do). The best way is to read the code and try things out.
caveman1917 Feb 21, 2010, 10:37 PM Found it, changing this
zsCiv = gc.getPlayer(iPlayer).getCivilizationShortDescript ion(0)
into this
zsCiv = gc.getPlayer(iPlayer).getCivilizationAdjective(0)
monoolho Mar 23, 2010, 04:17 PM I've read mostly everything here and still my brain can't process it, I think I'm getting too old for this...
I'm sorry but I have to ask this...
How do you use multiple counters? I've tried most possible combinations and still no success, it keeps showing the code instead of the counter.
Do I have to edit the .ini for that or is it possible to do it in-game(alt+tab+o)? I still haven't messed around with the .ini, so I'm not sure how it will work, maybe I'll have to edit too many things...
Anyway I suggest updating the documentation, and if anyone can help me with multiple counters I'd be glad.
IPEX-731BA5DD06 Dec 27, 2011, 06:50 PM Ha Ha, Thread revival.
Seriously, is there a way to use the tt1 and tt2 naming conventions so that it doesn't produce a random number.
Specifically I want to number them in the Army naming convention given as an example, but have them numbered sequentially, but resetting once a set number has been achieved.
What do I mean;
Army Group 1, 1st Corps , Squads (Able [1st]..Hotel[8th] ) Reset
Army Group 1, 4th Corps, Squads (Able...Hotel) Reset
Army Group 2, 1st Corps, Squads (Able..Hotel)
Basically I want to count as an example 8 Squads, reset, count 4 corps, reset and infinite Army Groups.
As is set up now, its a Random number for Companies, but it'll never reset, even once all options have been used, ie, tt1, 1 used 3 times, 2 used once, 3 used 5 times, 4 used twice, 5 used once but won't reset tt2
I tried this using the Cntl-Alt-N naming options, but never resets tt2
ruff_hi Dec 27, 2011, 10:44 PM Seriously, is there a way to use the tt1 and tt2 naming conventions so that it doesn't produce a random number.
No. tt2 never resets ... it just keeps on counting. We did brain storm some code for infinite counters (see back a few pages) but we never got around to implementing it.
Here is an example from earlier in this thread for what is is trying to do ...
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.
IPEX-731BA5DD06 Dec 28, 2011, 03:21 AM I've gotten some errors from unit naming.
It worked previously, as I wanted it too, as given in the example on screen shot
http://i282.photobucket.com/albums/kk264/IPEX-731BA5DD06/Linux%20problems/bug%20mod/Unitnamingconvention.png
I produced 3 Modern infantry and 1 mobile missile carrier. Fine, excellent work Ruff :goodjob:
but now when I try to test various other combinations, I get this error
http://i282.photobucket.com/albums/kk264/IPEX-731BA5DD06/Linux%20problems/bug%20mod/unitnamingerror.png
Might be because, I've activated screen saver a couple of times, left it running for 8 hr's straight, etc. Or because I've enacted an arcane set of key's using Cntl-Alt- P and L or Cntl or Alt with Shift and P or L.
Trying to use the civ swap in REV_DCM
Key's also got stuck on capitals with caps off and non capitals with it on, so may go away.
But seen that error before with naming conventions, so its an actual bug. Don't know it it helps, or even if your inclined to look into it.
Thanks for Bug.
Oh, lastly, how would I re-enable the SVNutil.py checking in bug, if its been disabled in being merged into a mod, just change the Check's from false to true??
ruff_hi Dec 28, 2011, 04:50 AM I think that error is because you need to select a unit before starting the Unit Rename tester dialog box.
IPEX-731BA5DD06 Dec 28, 2011, 05:46 PM I tried the next day, fresh boot, well rested computer. I selected a unit 1st to try out unit naming conventions (Cntl+Alt+N) and got same error.
Next I selected and opened a city, tried again, same error.
here's an example of my Unit naming convention ([party])
Using Rise of Mankind - A New Dawn Mod
http://i282.photobucket.com/albums/kk264/IPEX-731BA5DD06/Linux%20problems/bug%20mod/Armynamingconventionsused.png
here's and example of the out put over many units. (not sorted in out put order, just a random grouping.) Hey I have 4 separate fronts going at once, 5 if you count the invasion group for the 2 tile island.
http://i282.photobucket.com/albums/kk264/IPEX-731BA5DD06/Linux%20problems/bug%20mod/Armynamingactual.png
http://i282.photobucket.com/albums/kk264/IPEX-731BA5DD06/Linux%20problems/bug%20mod/Screenshot.png
I'm such a Ruthless Tyrant, size 19 city and I abandon it. (using larger cities mod, 3rd ring enabled, and doesn't meet my Plan for Continent/Island)
Here's the error, once more
http://i282.photobucket.com/albums/kk264/IPEX-731BA5DD06/Linux%20problems/bug%20mod/unitnamingerror.png
I've tried it with advance unit naming on and off, and upgrade name on and off and both on and off (6 combinations) all gave same error.
Its not game breaking, just mildly annoying, BUT, you never know what else it may effect.
Finally, the random number generator, does that use a maths function in Python, a spreadsheet, or a created program. Its just I'd like to build, as an example;
-5 companies for each division.
-25 Divisions for each Army group
-Army groups ad infinitum.
Oh, just to slip in a final query. Is it possible, as a added feature, to count the Captured workers, Units (mods) etc from each player.
E.G.
1st Liberated Barbarian (worker)
14th Liberate Holy roman (worker)
5th Liberated Persia (worker)
3rd Captured Zulu (cannon)
1st Abandon Paris (worker)
2nd Abandon Paris (worker)
1st Abandon Paris (Settler)
Or will I have to keep manually counting, no biggie, just a nice to add if inclined.
IPEX-731BA5DD06 Dec 28, 2011, 06:08 PM Just had a quick thought on Army naming, I could, and will change it too;
^cnt[p][d]^ Squad, ^tt1[o][1:10]^ Company, ^tt2[o][1]^ Division of the 1st Army group. (alter to 2nd etc when I have enough divisions)
P.S. Example of the unit numbering for captured units I meant
http://i282.photobucket.com/albums/kk264/IPEX-731BA5DD06/Linux%20problems/bug%20mod/Capturedunitnaming.png
ruff_hi Dec 28, 2011, 07:48 PM ^cnt[p][d]^ Squad, ^tt1[o][1:10]^ Company, ^tt2[o][1]^ Division of the 1st Army group
Yes, that will work. Note that the ^tt1[o][1:10]^ part means that the number of squads per company will be a random number between 1 and 10. If you want each company to have 10 squads, change the [1:10] part to [10:10].
alter to 2nd etc when I have enough divisionsThat should work.
IPEX-731BA5DD06 Dec 29, 2011, 06:41 AM Bad dog Ruff Hi *Hits with a rolled up newspaper*..
that suggestion you made, just outputs company 10 all the time, no reseting at all
I'll try a single 10 to see if that changes things.
ruff_hi Dec 29, 2011, 09:24 AM Bad dog Ruff Hi *Hits with a rolled up newspaper*..
http://www.youtube.com/watch?v=3uTyZ-YC6qY
that suggestion you made, just outputs company 10 all the time, no reseting at all
Ahh, right. I coded this about a billion years ago so I guess I have forgotten. Given your comment and a slightly refreshed memory ... try this ...
[tab]^cnt[p][d]^ ^tt1[s][10:10]^ Squad, ^tt2[o][1]^ Company, 1st Division of the 1st Army group
As the code currently is, there is only 1 counter (^cnt[p][d]^), the tt1 part tells it when to reset to '1' and when to increment the tt2 counter. The '[s]' part tells it that the display mode for the tt1 counter is silent (ie not shown).
As I said above, we did brain storm some code that adds unlimited counters, we never implemented it.
IPEX-731BA5DD06 Dec 29, 2011, 05:08 PM Ruff, had a look into your most excellent coding *ruffles Ruff_hi ears*
Is this the code set I'd need to change
def getTotal1(self, conv):
## - ^tt1[f][x:y]^ - total where the total is a random number between x and y (number)
# return 'not found' indicator
ziStart = conv.find("^tt1[")
if (ziStart == -1):
return -1
# locate and extract the 'low' value
ziStart = conv.find("[",ziStart)
ziStart = conv.find("[",ziStart + 1)
ziEnd = conv.find(":",ziStart)
ziLow = int(conv[ziStart + 1:ziEnd])
if (ziLow < 1): ziLow = 1
# locate and extract the 'high' value
ziStart = ziEnd
ziEnd = conv.find("]",ziStart)
ziHigh = int(conv[ziStart + 1:ziEnd])
if (ziHigh < 1): ziHigh = 1
# check that the user isn't an idiot
if (ziLow > ziHigh): return ziLow
# return the value
return random.randint(ziLow, ziHigh)
So if I understand it correctly, I just need to edit the last bit of coding to
return(ziLow, ziHigh)
This will eliminate the random number generator, but still retain your :thumbsup: :worship: coding.
check that the user isn't an idiot
Hey Bad Ruff_Hi, Very naughty (http://www.youtube.com/watch?v=tBIba8YLDt0)
C:/...Path to Beyond the sword Mod.../Assets/Python/Contrib/UnitNameEventManager.py
This is the files address in the Mod I need to amend??
ruff_hi Dec 29, 2011, 05:41 PM C:/...Path to Beyond the sword Mod.../Assets/Python/Contrib/UnitNameEventManager.py
This is the files address in the Mod I need to amend??Yes - depending on what you are trying to do.
ruff_hi Dec 29, 2011, 05:43 PM def getTotal1(self, conv):
...
# check that the user isn't an idiot
if (ziLow > ziHigh): return ziLow
I was reading over the code earlier today to answer your questions and I also saw this part ... had to laugh at myself with the comment.
IPEX-731BA5DD06 Dec 29, 2011, 10:58 PM ok I've had a look at it a bit of a think and tinkered.
Tried 2 things, both don't work.
1st
1st 6 trials worked for Squad, great. :goodjob:
BUT, it started at foxtrot company and not Able !!!
http://i282.photobucket.com/albums/kk264/IPEX-731BA5DD06/Linux%20problems/bug%20mod/Unit%20naming%20conventions/Renametrial1st6.png
But on 7th unit, when it should reset tt1
http://i282.photobucket.com/albums/kk264/IPEX-731BA5DD06/Linux%20problems/bug%20mod/Unit%20naming%20conventions/Wontresettt1.png
Oh yeah, that error, I said I had, I think I need to build a new unit when ever I restart the game and try unit numbering, having previously build units in a prior save won't do it. Built another new unit, and it worked, didn't build a unit and got error.
Hmm 1st was removed randomint completely from line at end of return the value, no.. Hmmm ok I need to give it a value, it needs and interger so added int back (for interger)
Didn't work either. Double :hmm:
Zoh, its not resetting tt1, why is it so 'Professor Julius Sumner Miller'..."Watch the egg, watch the egg" (http://www.youtube.com/watch?v=tbTBPS_Dtv8) (oh my god I'm old!!!!!)
had a look and thought this may be problem, but can't quite see way around it.
http://i282.photobucket.com/albums/kk264/IPEX-731BA5DD06/Linux%20problems/bug%20mod/Unit%20naming%20conventions/ziHigherror.png
Seems to me, that the High Value for tt1 is being incorrectly extracted. It's just giving the highest number for both.
eg I have unit naming convention [party] ^cnt[o][u]^ Squad, ^tt1[p][1:6]^ Company, ^tt2[r][1]^ Division of the 1st Army.
I get;
1st Squad, Foxtrot Company, I Division of the 1st Army
2st Squad, Foxtrot Company, I Division of the 1st Army
3rd Squad, Foxtrot Company, I Division of the 1st Army
4th Squad, Foxtrot Company, I Division of the 1st Army
5th Squad, Foxtrot Company, I Division of the 1st Army
6th Squad, Foxtrot Company, I Division of the 1st Army
Then is spits out Python errors
So starts at 6 (highest Number) and won't reset.
I have unit naming convention [party] ^cnt[o][u]^ Squad, ^tt1[p][1:6]^ Company, ^tt2[r][1]^ Division of the 1st Army.
with randomint (ziLow, ziHigh)
I'd get Alpha with 1 squad, Gamma with 3, Epsilon with 5, etc with a corresponding increase in divisions for each company change, partly what I'm after.
I'll use the silent (s) function on tt1 to fix this, but to fix code??
so its correctly reading ziLow and ziHigh, and assigning a random number and reseting once its reached.
Seems to me, it works this way. With Return int (ziLow, ziHigh)
1) Extracts ziLow, in my example its 1.
2) ziStart = ziEnd
3) Exstracts ziHigh, in my example its 6
4) returns the values of (6,6) for ziLow and ziHigh
Solution
ziStart = ziEnd
ziEnd = conv.find("]",ziStart)
Change to read
ziStart = conv.find(":",ziStart)
ziStart = conv.find(":",ziStart + 1)
ziEnd = conv.find("]",ziStart)
Am I even close..or just way way off base.
IPEX-731BA5DD06 Dec 30, 2011, 02:56 AM After having more of a play around with it, breaking it totally, and having to re-install a pristine copy of the UnitNameEventManager.py
I've found that the unit testing, for 1 city only, only works for codes of r=t,u all others will just stay at initial value.
As well, if you change the tt1 coding, you need to close the unit name tester, and restart it for that change to take effect.
My current tested code is
^cnt[o][t]^ Squad, ^tt1[s][6:6]^ ^tt2[p][1]^ Company, ^ct^ I Division of the Ancient Era Army
Further it seems to be ignoring the end part of the tt2 function, it just counts by 1, even if you change it to 3, 6 or any other number. Omit it entirely, and it has no effect. Note, this was only for the unit name testing, in actual game play, it'll give a python error if this value is missing, re-installing it, removes said error.
Playing to trial out the t function, I assume its correct, but will test.
ruff_hi Dec 30, 2011, 08:34 AM ok I've had a look at it a bit of a think and tinkered
...
Am I even close..or just way way off base.
I have no idea what you are trying to do so it is hard to say if you are close or not. If you are trying to mod the current system to generate a counter like you have previously desired (ie 1st Platoon, 2nd Squad, Alpha Regiment, 101st Army) then you are way off and it is better to start again (see below).
Zo, its not resetting tt1, why is it so 'Professor Julius Sumner Miller'..."Watch the egg, watch the egg" (http://www.youtube.com/watch?v=tbTBPS_Dtv8) (oh my god I'm old!!!!!)
Here is a quiz to gauge your age: Who is Ron Barassi (http://en.wikipedia.org/wiki/Ron_Barassi)?
A1: 'A great football player' (selecting this indicates that you are old ... very old!)
A2: 'A great football coach' (selecting this indicates that you about my age ... a perfect age)
A3: 'Who?' (selecting this indicates that you are a young whipper snapper ... or that you don't live in Melbourne)
As I indicated previously, we did brain storm a way of getting unlimited counters in unit names ...
here is my preliminary thoughts ...
add a counter control somewhere in the naming code ... something like this ...
{5,[2:5,6:10,x,y],[5:5,10:10],[2:2,4:4],[1:1,10:15],[101:101]}
translation
{5,...} means there are 5 counters
{...,[2:5,6:10,x,y],...} means that the 1st counter starts at a random number between 2 and 5 and counts up to another random number between 6 and 10, it counts over 'x' (same type of code as previous, city, combat type, city & combat type, etc) with special code 'y' so you can tell spears from axes
{...,[5:5,10:10],...} means that the 2nd counter starts at a random number between 5 and 5 and counts up to another random number between 10 and 10, it gets incremented once the 1st counter exceeds its max
{...,[2:2,4:4],...} means that the 3rd counter starts at a random number between 2 and 2 and counts up to another random number between 4 and 4, it gets incremented once the 2nd counter exceeds its max
{...,[1:1,10:15],...} means that the 4th counter starts at a random number between 1 and 1 and counts up to another random number between 10 and 15, it gets incremented once the 3rd counter exceeds its max
{...,[101:101]} means that the 5th counter starts at a random number between 101 and 101 and just keeps increasing, it gets incremented once the 4th counter exceeds its max
The balance of the naming code would tell you where to put each counter ...
"Group ct1[f], ct2[f] Div, etc"
where ct1 represents counter 1, ct2 represents counter 2, etc and the [f] controls the formatting.
... why don't we try and code this system into the existing code?
ruff_hi Dec 30, 2011, 08:41 AM To do this, I would start with the following ... change this ...
# check if there are any more codes to swap out, return if not
counters = BugData.getGameData().getTable(SD_MOD_ID)
while zsName.find("^cnt") != -1:
# determine what I am counting across
zsSDKey = self.getCounter(zsName)
...
# swap out the count code items for count value
zsName = self.swapCountCode(zsName, "^cnt", ziCnt)
zsName = self.swapCountCode(zsName, "^tt1", ziTT1)
zsName = self.swapCountCode(zsName, "^tt2", ziTT2)
... to this ...
# check if there are any more codes to swap out, return if not
counters = BugData.getGameData().getTable(SD_MOD_ID)
if self.NewCountCodeExists(zsName)
szName=self.doNewCountCode(zsName)
else:
szName=self.doOldCountCode(zsName)
def NewCountCodeExists(self, zsName):
return zsName.find("^{") != -1:
def doNewCountCode(self, zsName): # you might need to pass some other parameters
# need new code here
def doOldCountCode(self, zsName): # you might need to pass some other parameters
while zsName.find("^cnt") != -1:
# determine what I am counting across
zsSDKey = self.getCounter(zsName)
...
# swap out the count code items for count value
zsName = self.swapCountCode(zsName, "^cnt", ziCnt)
zsName = self.swapCountCode(zsName, "^tt1", ziTT1)
zsName = self.swapCountCode(zsName, "^tt2", ziTT2)
IPEX-731BA5DD06 Dec 30, 2011, 03:42 PM Great Player = Historically I know. (went from Melbourne Captain, to Carlton Captain/Coach= Huge Scandal at the time)
Great Coach = North Melbourne in 70's (I'm Hawthorn, '75 never forget, never forgive. RIP No 5 little champ)
Who is he??? = That bloke assaulted at Nimben NSW
Trouble is, I remember watch Professor Julius on the ABC doing his science specials as a young lad, in the 70's, he made it all seem so interesting to a >10Yr old. Cadbury adds came later.
Why are you so Hot to trot on Random numbers, why not, and I know its more coding, have an option for random numbers f(x) and fixed counting.
I do realize its your personal favourate, and your doing the coding.
That suggestion of (s) for tt1 worked perfectly for the counter, thanks Ruff_Hi tt1(s)(5:5) counts 5 squads, for each company, and then counts infinite companies, (well cycles over at Zulu)
Interesting that the cnt(t,u) only works and not for the other options. I did only test in name testing, but I assume its the same for game play. (I forgot to reset, got caught up in play)
eg
cnt(o)(c) Squad,.... only gives 1st Squad, Alpha Company...1st Squad, Alpha Company...1st Squad, Alpha Company...
cnt(o)(a)...
cnt(o)(b)...
cnt(o)(d)...
all gave same result in unit naming test.
I will test in actual play today...
ruff_hi Dec 30, 2011, 04:48 PM Great Player = Historically I know. (went from Melbourne Captain, to Carlton Captain/Coach= Huge Scandal at the time)
Great Coach = North Melbourne in 70's (I'm Hawthorn, '75 never forget, never forgive. RIP No 5 little champ)
Who is he??? = That bloke assaulted at Nimben NSW
Trouble is, I remember watch Professor Julius on the ABC doing his science specials as a young lad, in the 70's, he made it all seem so interesting to a >10Yr old. Cadbury adds came later.Seems we are about the same age.
Why are you so Hot to trot on Random numbers, why not, and I know its more coding, have an option for random numbers f(x) and fixed counting.
I do realize its your personal favourate, and your doing the coding.Nice option, costs nothing in the coding and can be overcome by saying 'random number between x and x'.
Interesting that the cnt(t,u) only works and not for the other options. I did only test in name testing, but I assume its the same for game play. (I forgot to reset, got caught up in play)I wasn't sure what you meant by this until I said that you didn't play test it. That rings a bell ... remember that the options are ...
## - ^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
... so when you are 'testing' your naming convention using that dialog box, there is no way to tell the code which city it comes from ... so all of the ones using city either ignore the city or use the capital (ie the same city) ... so they look just like the ones based on units only.
ruff_hi Dec 30, 2011, 04:49 PM why don't we try and code this system into the existing code?So ... do you want to try and code this 'unlimited counter' option into the code? Do you want to lead the coding or be a tester? If you elect testing, then I cannot guarantee very quick turn around ... in fact, I can guarantee very slow turn around.
IPEX-731BA5DD06 Dec 30, 2011, 05:29 PM On the unit naming convention :blush:
It seems each convention has its own distinct memory counter, and when you change a counter, it double counts 1 then moves on to the next unit.
Eg, 1,1,2,3,4,5,6,1,2,...... for cnt(f)(6:6), note didn't go over the cycle. only went as far as 3 builds for different counters.
On the coding change, I guess, if I'm going to suggest it, its the least I could do, besides, I want to have a go at Merging REVDCM 2.90 into RAND 2.65 (Beta 5, alpha 1) might even have a go at CLEANING UP ERROR ONLY. No new coding (beyond my abilities) Its my Mod of obsession at moment (6 months ongoing)
RUFF_HI I'll try your suggestions, yeah random (x:x), random (y:y) is easy solution for fixed counter.
ruff_hi Jan 15, 2012, 04:05 PM On the coding change, I guess, if I'm going to suggest it, its the least I could doany movement here? ie coding that needs testing?
IPEX-731BA5DD06 Jan 29, 2012, 05:37 PM Sorry Ruff, I just don't have the motivation or the expertise to do it.
I'm actually quite happy with the work around we've made up, sorry, I just don't have the cognitive resources to do coding.
Personally I'd leave it as is. I just like to tinker with ridiculous naming conventions, probably 99% of users would just use the default, or some minor city notifications.
Thanks for offer of assistance, but its really beyond my skills, motivation and educational training.
ruff_hi Jan 29, 2012, 07:01 PM np - I will put this on my back burning and knock something up over the next 3-6 months. I'll post something here so that you can test it.
|
|