Page 1 of 2 12 LastLast
Results 1 to 20 of 26

Thread: Settlement Coordinate Locator

  1. #1
    HouseOfHam's Avatar Primicerius
    Join Date
    Apr 2007
    Location
    Minnesota, USA
    Posts
    3,030

    Default Settlement Coordinate Locator

    It's been sitting in the download section for quite a while, but I haven't gotten around to creating a thread for it here till now... so here we go:

    Download link: http://www.twcenter.net/forums/downl...o=file&id=2429

    Rome: Total War Settlement Locator v1.2.0.4

    - What does it do?

    Tells you strategy map coordinates of all settlements. It works for both RTW-and BI-based mods. Probably works for Alexander-based mods, too, but I don't have it so I can't be sure.


    - How does it work?

    It loads in information from descr_regions.txt, then uses it to locate
    settlements on map_regions.tga (well, map_regions.bmp, actually).


    - What programming language is this written in? Do I need anything to run it?

    It's an AutoIt v3 script. The .exe file is a compiled version of the source code in the .au3 file. The .exe should be able to run on any Windows box without any additional run-time libraries.


    - How do I use it?

    1. First, you need to convert your map_regions.tga into map_regions.bmp. Leave it in the same folder. There are plenty of free programs you can use for this, so it should be easy. I used XnView.

    You only need to do this once per mod. That is, unless you modify
    map_regions.tga, then you'll need to generate a new map_regions.bmp, too.

    2. Once map_regions.bmp has been created, just run this script/program, select the folder your mod lives in, and click ok. It takes 15-20 seconds to process everything (on my box), then it'll give you the results in a nice, compact table. Settlement coordinates will be in the right-most column.

    Here is the window you'll see while it's scanning the map:



    When it's done, it'll pop up another window like this:




    - My anti-virus scanner says the .exe file is infected!

    Some anti-virus products freak out when they see compiled AutoIt scripts. AutoIt uses the UPX packer to make the .exe files it generates smaller. Nothing wrong with using a packer, but some anti-virus program don't like them (probably because they don't know how to unpack it) so they get all paranoid and throw a feat. Feel free to ignore them.

    If you're still concerned, I've attached the source file so you can download
    AutoIt v3 and compile it yourself, or even run the script directly, without
    compiling. You can download AutoIt here: http://www.autoitscript.com/

    More info about UPX (Ultimate Packer for eXecutables) can be found here:
    http://upx.sourceforge.net/


    - "It doesn't find settlements that are on the map's edges!"

    Nope, and it's not going to. AI never attacks such settlements, so you shouldn't be putting them there in the first place.


    - "It doesn't work!" or "It gives wrong numbers!"

    Well, it's a pretty simple script. It took 1 weekend of coding and testing to
    make and there isn't a whole lot of "sanity" checks, so if your
    descr_regions.txt is a mess, or colors don't match between descr_regions.txt and map_regions.tga, it's possible something might not work. If you run into a problem, you can send me (HouseOfHam) a PM on http://www.twcenter.net/forums

    I've tested it on Vanilla RTW/BI and several mods (RTR VII:TIC, RTR VII:FOE beta, ExRM, and RS2 beta). It seemed to work for me, so I hope it works for you, too.

    Have fun modding!

    Cheers, HouseOfHam

    ---
    Change History:

    v1.2.0.4: Also added headers to the result output window that appears after re-sorting.

    v1.2.0.3: Added headers to the result output windows. Added a new column to show settlement coordinates in the map_regions.tga/bmp file.

    v1.2.0.2: Fixed a descr_regions.txt parsing bug that caused the last settlement configured in the file to be missed
    for vanilla RTW-based mods, which then caused the settlement to be reported as missing from descr_regions.txt.

    v1.2.0.1: Ability to sort output by any of settlement name, region name, faction, or rebel tribe has been added.
    Also, improved detection of multiple settlements per region (now the program will give a warning and continue, rather than abort)
    and settlements marked on the map but not configured in descr_regions.txt.

    v1.1.0.3: The output window is now alphabetically sorted by settlement name.

    v1.1.0.2: Tweaks to RGB color parsing code to make it work when the numbers are separated by more than one space/tab in descr_regions.txt.

    v1.1.0.1: Fixed the code for parsing RGB values in descr_regions.txt so it now works properly when tabs are used as separators. Previously only worked with spaces.

    v1.1.0.0: The original release
    Last edited by HouseOfHam; December 23, 2009 at 12:14 PM.
    RTR website/SVN admin

    - Settlement coordinate locator -for RTW/M2TW
    - EDB Validator v1.2.8 (Oct 16, 2012) - for RTW/M2TW
    - RTW scripting tutorials
    - n-turns per year script generator

  2. #2

    Default Re: Settlement Coordinate Locator

    Great job, already used it, great tool !

    Btw, how hard would it be to make a search function ? Sure is a when you need to find a name between 196 regions

  3. #3

    Default Re: Settlement Coordinate Locator

    Not if you've sorted your descr_regions properly.

    Great tool, HoH. This will make descr_strat coding a lot quicker.

    As a side note, how hard would it be to make this work for M2TW? I'm sure those modders would love an additional tool.

    Expand your borders, a mod based on XGM 5.

  4. #4
    HouseOfHam's Avatar Primicerius
    Join Date
    Apr 2007
    Location
    Minnesota, USA
    Posts
    3,030

    Default Re: Settlement Coordinate Locator

    Quote Originally Posted by Mr.Blackadder View Post
    Great job, already used it, great tool !

    Btw, how hard would it be to make a search function ? Sure is a when you need to find a name between 196 regions
    Putting in a search function would be too much work.

    Posted v1.1.0.3 that sorts the output by settlement name.

    Quote Originally Posted by CaesarVincens View Post
    As a side note, how hard would it be to make this work for M2TW? I'm sure those modders would love an additional tool.
    Not very hard, I imagine.

    I don't have M2TW, though, so I have nothing to develop an M2TW version against. Based on what I know, the only thing that would need to be changed for M2TW is the additional sea tile colors that didn't exist in RTW. In RTW, there were just 5 (41 140 233 - 41 140 237), so some code would need to be added to handle the new ones.

    In my implementation, I used the fact that the 1st 5 characters of the hex representation of these colors are all the same, so I just hard-coded a color pattern on line 26 (in the .au3 source file):
    Code:
    Const $settlementColor = "000000", $portColor = "FFFFFF", $seaColorPattern = "298CE"
    Then, in the FindSettlement function, I just use StringInStr to see if the color of the adject pixels contains that pattern. Not 100% accurate (since it could produce a false positive on a non-sea tile pixel color like ?298CE rather than 298CE?) but it's so unlikely that you'll ever run into that, that I didn't want to spend the time looking for a better way to do the check.

    The religions line in descr_regions.txt looks a bit different in M2TW, but it doesn't look at that line, so that shouldn't cause any problems.
    RTR website/SVN admin

    - Settlement coordinate locator -for RTW/M2TW
    - EDB Validator v1.2.8 (Oct 16, 2012) - for RTW/M2TW
    - RTW scripting tutorials
    - n-turns per year script generator

  5. #5
    Stuie's Avatar Laudir Agus Mir
    Join Date
    Sep 2004
    Location
    Upper Gwynedd, PA
    Posts
    990

    Default Re: Settlement Coordinate Locator

    This thing is awesome!! Wish I had it three and a half years ago when I was building TFT.

  6. #6
    Augustus Lucifer's Avatar Life = Like a beanstalk
    Patrician Citizen

    Join Date
    Aug 2006
    Location
    Mote of Dust
    Posts
    10,697

    Default Re: Settlement Coordinate Locator

    It seems to partially work with M2, but 55/182 settlements come out without any information in Column 10(btw, might want to name the columns so we know what's in each, even though it's kinda obvious). I'm not noticing any similarities between the ones which do output and those which don't. All of them have similar religion lines, some of each have hyphen separated names, so on and so forth.

    Actually, come to think of it all of the settlements seem to be located in roughly the lower left quadrant of the map(or just the lower third or so, I can get the exact pixel it stops on if that will help). Our map that I tested it on is 510 x 389, but I don't suppose that has anything to do with it since the height is shorter than the width.

  7. #7
    HouseOfHam's Avatar Primicerius
    Join Date
    Apr 2007
    Location
    Minnesota, USA
    Posts
    3,030

    Default Re: Settlement Coordinate Locator

    If you can post your descr_regions.txt and map_regions.bmp (or .tga), I'll take a look.
    RTR website/SVN admin

    - Settlement coordinate locator -for RTW/M2TW
    - EDB Validator v1.2.8 (Oct 16, 2012) - for RTW/M2TW
    - RTW scripting tutorials
    - n-turns per year script generator

  8. #8
    Caligula Caesar's Avatar Horse Lord
    Join Date
    Dec 2008
    Location
    England
    Posts
    5,510

    Default Re: Settlement Coordinate Locator

    Would it be possible to have options on how it is ordered? So ordered by cities, regions or descr_regions. This would make it quite a bit easier to use, since I have a well-ordered descr_regions
    RTR-VII Team Leader and Leader of Fortuna Orbis, an RTR Submod

    "History has only one concern and aim, and that is the useful; which again has one single source, and that is truth." -Lucian of Samosata

    Fortuna Orbis Beta is released!

  9. #9
    HouseOfHam's Avatar Primicerius
    Join Date
    Apr 2007
    Location
    Minnesota, USA
    Posts
    3,030

    Default Re: Settlement Coordinate Locator

    lol, anything is possible, if I ever get around to it...
    RTR website/SVN admin

    - Settlement coordinate locator -for RTW/M2TW
    - EDB Validator v1.2.8 (Oct 16, 2012) - for RTW/M2TW
    - RTW scripting tutorials
    - n-turns per year script generator

  10. #10
    HouseOfHam's Avatar Primicerius
    Join Date
    Apr 2007
    Location
    Minnesota, USA
    Posts
    3,030

    Default Re: Settlement Coordinate Locator

    v1.2.0.1: Ability to sort output by any of settlement name, region name, faction, or rebel tribe has been added.
    Also, improved detection of multiple settlements per region (now the program will give a warning and continue, rather than abort)
    and settlements marked on the map but not configured in descr_regions.txt.
    RTR website/SVN admin

    - Settlement coordinate locator -for RTW/M2TW
    - EDB Validator v1.2.8 (Oct 16, 2012) - for RTW/M2TW
    - RTW scripting tutorials
    - n-turns per year script generator

  11. #11
    Caligula Caesar's Avatar Horse Lord
    Join Date
    Dec 2008
    Location
    England
    Posts
    5,510

    Default Re: Settlement Coordinate Locator

    This is weird. I have a (working) map, and I have 196 regions and 4 sea regions. However, it tells me that it can't match one of my settlements. I have checked it, and it is matched correctly and appears ingame. I don't understand what is causing this error.
    RTR-VII Team Leader and Leader of Fortuna Orbis, an RTR Submod

    "History has only one concern and aim, and that is the useful; which again has one single source, and that is truth." -Lucian of Samosata

    Fortuna Orbis Beta is released!

  12. #12
    HouseOfHam's Avatar Primicerius
    Join Date
    Apr 2007
    Location
    Minnesota, USA
    Posts
    3,030

    Default Re: Settlement Coordinate Locator

    v1.2.0.2: Fixed a descr_regions.txt parsing bug that caused the last settlement configured in the file to be missed for vanilla RTW-based mods, which then caused the settlement to be reported as missing from descr_regions.txt.
    RTR website/SVN admin

    - Settlement coordinate locator -for RTW/M2TW
    - EDB Validator v1.2.8 (Oct 16, 2012) - for RTW/M2TW
    - RTW scripting tutorials
    - n-turns per year script generator

  13. #13

    Default Re: Settlement Coordinate Locator

    Great program and very useful!

  14. #14
    Squid's Avatar Opifex
    Patrician Artifex Technical Staff

    Join Date
    Feb 2007
    Location
    Frozen waste lands of the north
    Posts
    17,735
    Blog Entries
    3

    Default Re: Settlement Coordinate Locator

    Have two bugs to report, and a feature to request.

    First the bugs:


    1. The program will fail to match a region if the sea colour used in map_regions is not in the range of valid sea numbers (this is a problem with RS1.6, and probably the problem for Caligula Caesar as well). I'm not quite sure how to go about fixing this, but the bug is there.
    2. In the initial screen once the file has been parsed anytime a window goes over it it blanks any part of the map that gets covered.


    Second three feature requests:

    1. As AL asked could you toss headers onto the columns, this can be done by just adding extra parameters into your _ArrayDisplay function calls (http://www.autoitscript.com/autoit3/...rayDisplay.htm)
    2. Add an extra column for the position of settlements in map_ground_types.tga/map_heights.tga
    3. Add an extra column for the position of settlements in map_regions.tga

    The last two suggestions are to make it easier to find the correct pixel when actually editing the tgas themselves.
    Under the patronage of Roman_Man#3, Patron of Ishan
    Click for my tools and tutorials
    "Two things are infinite: the universe and human stupidity; and I'm not sure about the universe." -----Albert Einstein

  15. #15
    HouseOfHam's Avatar Primicerius
    Join Date
    Apr 2007
    Location
    Minnesota, USA
    Posts
    3,030

    Default Re: Settlement Coordinate Locator

    Quote Originally Posted by Sqυιd View Post
    Have two bugs to report, and a feature to request.

    First the bugs:


    1. The program will fail to match a region if the sea colour used in map_regions is not in the range of valid sea numbers (this is a problem with RS1.6, and probably the problem for Caligula Caesar as well). I'm not quite sure how to go about fixing this, but the bug is there.
    2. In the initial screen once the file has been parsed anytime a window goes over it it blanks any part of the map that gets covered.


    Second three feature requests:

    1. As AL asked could you toss headers onto the columns, this can be done by just adding extra parameters into your _ArrayDisplay function calls (http://www.autoitscript.com/autoit3/...rayDisplay.htm)
    2. Add an extra column for the position of settlements in map_ground_types.tga/map_heights.tga
    3. Add an extra column for the position of settlements in map_regions.tga

    The last two suggestions are to make it easier to find the correct pixel when actually editing the tgas themselves.
    1. As far as I'm aware, 41 140 233 - 41 140 237 are the only valid sea colors for RTW. As I've explained before, I don't have M2TW and since no one has sent me M2TW sea tile colors (or sample files containing them), there is nothing I can do about them. The locator has no way of knowing if it's a sea tile or a bordering region unless it's one of the colors it knows about.

    2. That behavior might be specific to your OS. Doesn't happen for me on Vista. Just don't minimize it or drag other windows over it while it's searching and it should work. The settlement search is based on screen-scraping pixel colors from the displayed image, so if something messes up the displayed image, it will affect the results.

    Requests:

    1. The extra parameter for the _ArrayDisplay function was only added in AutoIt v3.3.2.0 that was released Dec. 17 (less than a week ago). I'll add it in the next version of the locator.
    2. I'll think about it. These files could be different size, so coordinates would have to recalculated to scale
    3. I'll add it to my to-do list.
    RTR website/SVN admin

    - Settlement coordinate locator -for RTW/M2TW
    - EDB Validator v1.2.8 (Oct 16, 2012) - for RTW/M2TW
    - RTW scripting tutorials
    - n-turns per year script generator

  16. #16
    Squid's Avatar Opifex
    Patrician Artifex Technical Staff

    Join Date
    Feb 2007
    Location
    Frozen waste lands of the north
    Posts
    17,735
    Blog Entries
    3

    Default Re: Settlement Coordinate Locator

    For the sea colour RS1.6 uses 41 140 243 (or 298CF3) and there are no problems. I haven't tested but I'd be curious what other colours would work as a sea colour.

    For the sea colour bug, one way of checking for it, at least for RTW where the ground types are fixed, is to do a double pass over map_regions.tga. The first pass takes every non-settlement/non-port pixel and checks the corresponding location in map_ground_types.tga and if the ground type is a sea ground type adds the colour to a sea pixel array if it isn't there already. The second pass does what your program does now, with one difference the sea pixel check checks the adjacent pixels against the array instead of the single value you have now.

    As a note your sea pixel constant doesn't check from 41 140 233- 41 140 237 it actually checks from 41 140 224- 41 140 239.

    As for suggestion 1 I didn't see a release date, just that it was possible without too much extra code.
    Under the patronage of Roman_Man#3, Patron of Ishan
    Click for my tools and tutorials
    "Two things are infinite: the universe and human stupidity; and I'm not sure about the universe." -----Albert Einstein

  17. #17
    HouseOfHam's Avatar Primicerius
    Join Date
    Apr 2007
    Location
    Minnesota, USA
    Posts
    3,030

    Default Re: Settlement Coordinate Locator

    Quote Originally Posted by Sqυιd View Post
    As a note your sea pixel constant doesn't check from 41 140 233- 41 140 237 it actually checks from 41 140 224- 41 140 239.
    That's a fair note, but it makes no practical difference.

    Edit: Posted v1.2.0.4
    Last edited by HouseOfHam; December 23, 2009 at 12:22 PM.
    RTR website/SVN admin

    - Settlement coordinate locator -for RTW/M2TW
    - EDB Validator v1.2.8 (Oct 16, 2012) - for RTW/M2TW
    - RTW scripting tutorials
    - n-turns per year script generator

  18. #18
    Wundai's Avatar Artifex
    Join Date
    Mar 2006
    Location
    Eindhoven
    Posts
    5,352

    Default Re: Settlement Coordinate Locator

    Great tool mate!

    Now call me a noob but I have to ask this question about the locations themselves

    The First location (map_region_coords) is the location of the region?
    The Second location (RTW Coordinates) is the location of the settlement presented in the region, is this correct?

    And secondly what if your tool does not display coordinates for these at all, but all the rest of information is displayed perfectly, does this mean a mismatch in the descr_regions.txt?
    Last edited by Wundai; December 26, 2009 at 03:02 AM.

  19. #19
    HouseOfHam's Avatar Primicerius
    Join Date
    Apr 2007
    Location
    Minnesota, USA
    Posts
    3,030

    Default Re: Settlement Coordinate Locator

    The reason there are 2 coordinate columns is because the game doesn't calculate them in the same way as most graphics viewers/editors.

    - The map_region coordinates are to help you find settlements when looking at map_regions.tga in a graphics viewer/editor. The origin (0,0) is at the top left of the screen. The value of x increases from left to right and the value of y increased from the top down.
    - RTW coordinates are tile coordinates as the game calculates them (and as reported by the show_cursorstat command). The origin is in the bottom left, so x works the same, but y increased from the bottom as you go up.
    RTR website/SVN admin

    - Settlement coordinate locator -for RTW/M2TW
    - EDB Validator v1.2.8 (Oct 16, 2012) - for RTW/M2TW
    - RTW scripting tutorials
    - n-turns per year script generator

  20. #20
    Wundai's Avatar Artifex
    Join Date
    Mar 2006
    Location
    Eindhoven
    Posts
    5,352

    Default Re: Settlement Coordinate Locator

    I see, thank you

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •