1. We have added the ability to collapse/expand forum categories and widgets on forum home.
    Dismiss Notice
  2. Photobucket has changed its policy concerning hotlinking images and now requires an account with a $399.00 annual fee to allow hotlink. More information is available at: this link.
    Dismiss Notice
  3. All Civ avatars are brought back and available for selection in the Avatar Gallery! There are 945 avatars total.
    Dismiss Notice
  4. To make the site more secure, we have installed SSL certificates and enabled HTTPS for both the main site and forums.
    Dismiss Notice
  5. Civ6 is released! Order now! (Amazon US | Amazon UK | Amazon CA | Amazon DE | Amazon FR)
    Dismiss Notice
  6. Dismiss Notice
  7. Forum account upgrades are available for ad-free browsing.
    Dismiss Notice

Unit Naming

Discussion in 'Civ4 - BTS Unaltered Gameplay (BUG, BAT and BULL)' started by ruff_hi, Sep 3, 2007.

  1. IPEX-731BA5DD06

    IPEX-731BA5DD06 Chieftain

    Joined:
    Dec 15, 2005
    Messages:
    2,560
    Location:
    Melbourne, Victoria, Australia
    Ruff, had a look into your most excellent coding *ruffles Ruff_hi ears*

    Is this the code set I'd need to change

    Code:
     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
    Code:
          return(ziLow, ziHigh) 
    This will eliminate the random number generator, but still retain your :thumbsup: :worship: coding.

    Code:
    check that the user isn't an idiot
    Hey Bad Ruff_Hi, Very naughty

    C:/...Path to Beyond the sword Mod.../Assets/Python/Contrib/UnitNameEventManager.py

    This is the files address in the Mod I need to amend??
     
  2. ruff_hi

    ruff_hi Live 4ever! Or die trying

    Joined:
    Oct 24, 2005
    Messages:
    8,882
    Location:
    an Aussie in Boston
    Yes - depending on what you are trying to do.
     
  3. ruff_hi

    ruff_hi Live 4ever! Or die trying

    Joined:
    Oct 24, 2005
    Messages:
    8,882
    Location:
    an Aussie in Boston
    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.
     
  4. IPEX-731BA5DD06

    IPEX-731BA5DD06 Chieftain

    Joined:
    Dec 15, 2005
    Messages:
    2,560
    Location:
    Melbourne, Victoria, Australia
    ok I've had a look at it a bit of a think and tinkered.

    Tried 2 things, both don't work.

    1st
    Spoiler :

    1st 6 trials worked for Squad, great. :goodjob:
    BUT, it started at foxtrot company and not Able !!!​


    But on 7th unit, when it should reset tt1

    Spoiler :


    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" (oh my god I'm old!!!!!)

    had a look and thought this may be problem, but can't quite see way around it.

    Spoiler :


    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]^ 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]^ 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

    Code:
    ziStart = ziEnd
    
    		ziEnd = conv.find("]",ziStart)
    Change to read

    Code:
     ziStart = conv.find(":",ziStart)
    
    		ziStart = conv.find(":",ziStart + 1)
    
    		ziEnd = conv.find("]",ziStart)
    Am I even close..or just way way off base.
     
  5. IPEX-731BA5DD06

    IPEX-731BA5DD06 Chieftain

    Joined:
    Dec 15, 2005
    Messages:
    2,560
    Location:
    Melbourne, Victoria, Australia
    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

    Code:
     ^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.
     
  6. ruff_hi

    ruff_hi Live 4ever! Or die trying

    Joined:
    Oct 24, 2005
    Messages:
    8,882
    Location:
    an Aussie in Boston
    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).
    Here is a quiz to gauge your age: Who is 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 ...
    ... why don't we try and code this system into the existing code?
     
  7. ruff_hi

    ruff_hi Live 4ever! Or die trying

    Joined:
    Oct 24, 2005
    Messages:
    8,882
    Location:
    an Aussie in Boston
    To do this, I would start with the following ... change this ...

    Code:
    #		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 ...
    Code:
    #		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)
     
  8. IPEX-731BA5DD06

    IPEX-731BA5DD06 Chieftain

    Joined:
    Dec 15, 2005
    Messages:
    2,560
    Location:
    Melbourne, Victoria, Australia
    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...
     
  9. ruff_hi

    ruff_hi Live 4ever! Or die trying

    Joined:
    Oct 24, 2005
    Messages:
    8,882
    Location:
    an Aussie in Boston
    Seems we are about the same age.
    Nice option, costs nothing in the coding and can be overcome by saying 'random number between x and x'.
    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 ...
    ... 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.
     
  10. ruff_hi

    ruff_hi Live 4ever! Or die trying

    Joined:
    Oct 24, 2005
    Messages:
    8,882
    Location:
    an Aussie in Boston
    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.
     
  11. IPEX-731BA5DD06

    IPEX-731BA5DD06 Chieftain

    Joined:
    Dec 15, 2005
    Messages:
    2,560
    Location:
    Melbourne, Victoria, Australia
    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.
     
  12. ruff_hi

    ruff_hi Live 4ever! Or die trying

    Joined:
    Oct 24, 2005
    Messages:
    8,882
    Location:
    an Aussie in Boston
    any movement here? ie coding that needs testing?
     
  13. IPEX-731BA5DD06

    IPEX-731BA5DD06 Chieftain

    Joined:
    Dec 15, 2005
    Messages:
    2,560
    Location:
    Melbourne, Victoria, Australia
    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.
     
  14. ruff_hi

    ruff_hi Live 4ever! Or die trying

    Joined:
    Oct 24, 2005
    Messages:
    8,882
    Location:
    an Aussie in Boston
    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.
     
  15. Cruel

    Cruel Chieftain

    Joined:
    Jun 22, 2005
    Messages:
    823
    Location:
    São Paulo, Brazil
    What are the files that the "Unit Naming" uses in the BUG? A bit I realized that component of BUG is not available in our mod and I want to merge, if not have further complications.
     
  16. EmperorFool

    EmperorFool Chieftain

    Joined:
    Mar 2, 2007
    Messages:
    9,633
    Location:
    Mountain View, California
    You need "Unit Naming.xml" from the Config folder plus RandomNameUtils.py, Roman.py, and UnitNameEventManager.py from Python/Contrib. You'll need to check the imports of those Python modules to make sure you have all the necessary BUG Core modules as well. For the options screen you'll need BugUnitNameOptionsTab.py from Python/BUG/Tabs plus add it to your main options screen. Finally, include "Adv Unit Naming.ini" from the UserSettings folder so players can thoroughly customize their names if they want to go to that level. If your mod adds new unit/class types, you should modify this file by adding them. Just follow the pattern.

    If your mod modifies the available eras, you'll need to modify the config file to make the options in line with them. You need one line for each era like below:

    Code:
    <option id="Combat_MELEE" key="CombatMELEE" 
            type="string" default="DEFAULT"/>
    
    You'll also need to modify the options screen tab as well, having one line per era like this:

    Code:
    self.addTextEdit(screen, columnL, columnR, "UnitNaming__Combat_MELEE")
    
    I think that's it. If you have any trouble, post again with the debug and error logs.
     
  17. Noyyau

    Noyyau Privateer Captain

    Joined:
    Jun 9, 2012
    Messages:
    1,419
    Location:
    Italy
    Hello, I got to this thread from the Search button. I'm using Rise of Mankind - A New Dawn, which has BUG and the Unit Naming component.

    My question is: is it possible to name a certain unit type (e.g. Wooden Ships, but not all water units) with names from a user defined list?
    Similarly to how Great People get individual names for each GP type.
     

Share This Page