Map Range

Map Range; support/discussion/questions

Moderator: thunderchero

Post Reply
User avatar
Gowron
Code Master
Code Master
Posts: 304
Joined: Sat Apr 26, 2008 2:00 am
Location: 50° N, 11° E

Map Range

Post by Gowron »

This topic explains how the behaviour of the ships' map range with respect to the range classification (short/medium/long) and to the propulsion tech level can be altered.

First off, some important remarks:
  • The map range is an integer value; it's the number of sectors that the respective color-bordered area on the map screen extends in left, right, top and bottom directions.
  • All listed values are stored as signed 4-bit integers.
  • Only propulsion tech levels 1-11 can have custom range values. Higher tech levels are treated like tech level 11.
  • The map range for each tech level is displayed in the tech field database (F4 screen). Any modifications will also show up there. BUT the range is always off by one tech level. So the values for tech level 1 will be listed at "Propulsion 0", the values for tech level 2 will be listed at "Propulsion 1", and so on.
The actual range of any given ship depends on
  • the controlling empire,
  • its propulsion tech level,
  • the ship's range class (short, medium or long).
The map range is the sum of two values:
  • the base value (there is one for each empire/range class combination; 5*3=15 values in total)
  • the propulsion tech bonus (there are 11 for each empire/range class combination; 11*5*3=165 values in total)
Negative values are possible both for the base values and for the bonuses. By default, the bonuses are the same for each empire, but the base values are 1/2/3 for the Cardassians, Klingons and Romulans and 1/2/4 for the Federation and the Ferengi.

For any given empire/tech combination, "short" cannot outrange "medium", and "medium" cannot outrange "long".
If you change the values so that a lower range class has a higher value than a higher range class, then both range perimeters will be the same on the map (it will be the lower value, i.e. the value of the higher range class), AND the perimeter shape will become more and more squarish, depending on how much higher the value for the lower range class is.


Base value offsets in trek.exe:

Code: Select all

Card. 0x18E62C
Fedr. 0x18E638
Ferg. 0x18E644
Klng. 0x18E650
Roml. 0x18E65C
(12 bytes per race: first short, then medium, then long range)


Bonus value offsets in trek.exe:

Code: Select all

Card. 0x18E880
Fedr. 0x18E904
Ferg. 0x18E988
Klng. 0x18EA0C
Roml. 0x18EA90
(132 bytes per race, divided into 11 tech blocks, starting at tech 1)
(12 bytes per tech block: first short, then medium, then long range)


---------------------------------------------------------------


Important note by ketteringdave:
ketteringdave wrote:In particular, changing position 18E8D4 from 01 to 02 finally fixes the Cardassian range "bug" at level 7, where they would actually lose short range for a tech level.
A discovery consists in seeing something everybody has seen and at the same time thinking something nobody has thought yet.
User avatar
DCER
Code Master
Code Master
Posts: 683
Joined: Sat Apr 26, 2008 2:00 am

Post by DCER »

I'd just like to add that the maximum allowed value for the base range seems to be 24. Setting it higher caused botf to lock-up when I clicked on the Orders button (for the colony ship) playing as Klingons.

It's a weird bug, can someone confirm this is not happening just to me?

Negative values could have the same effect.

EDIT:
I've checked now and it only happens to Klingons. Other races don't cause this.
User avatar
DCER
Code Master
Code Master
Posts: 683
Joined: Sat Apr 26, 2008 2:00 am

Post by DCER »

LordLeksDarkmind wrote:looks like i`m dumb (
i get to rom bonus offset and searched for hex 01000002000003, changed them and get no result.
i searched all trek.exe for that values, found about 10 of them - near pointed spot - so i started to change them all... that gives me weird result)
but i managed to find romulan values at 18e5bc. maybe it is because of my trek.exe (v.1.2, cured of cd by UE).
These values will work on trek.exe of size 1781248 bytes (Joker's patch).

UE also works on trek.exe with size of 1780736 bytes, but the addresses are different for that version of trek.exe

The base values in the second version of trek.exe are at 0x18E58C and the tech bonuses start at 0x18e7e0 (Cards)

The values on the forums are usually given for Jokers patch and one needs to figure out what they are in other versions of trek.exe.

Hope that helps.
User avatar
thunderchero
Site Administrator aka Fleet Admiral
Site  Administrator aka Fleet Admiral
Posts: 7848
Joined: Fri Apr 25, 2008 2:00 am
Location: On a three month training mission, in command of the USS Valiant.

Post by thunderchero »

I was just wondering is there a map range for minors?

thunderchero
User avatar
Spocks-cuddly-tribble
Code Master
Code Master
Posts: 1883
Joined: Sun Apr 27, 2008 2:00 am

Re: Map Range

Post by Spocks-cuddly-tribble »

Gowron wrote:The map range for each tech level is displayed in the tech field database (F4 screen)... BUT the range is always off by one tech level.
Well, then let's correct the bug. :wink:

Sub_47C1B0 is used for this purpose (exclusively). And, since BotF pigheaded refuses our joining as minor race or as monster, the code is pointless for the most part and can be altered. For example in trek.exe at 0x7B5B4 we can replace BB 05 00 00 00 with 85 D2 74 01 4A.

The side effect is that the range bonus of the propulsion tech level 11 (aka future propulsion tech 1) is not longer displayed anywhere. But it's a small drawback since vanilla and most mods use no different values for the 10th & 11th level. :)



Gowron wrote:Only propulsion tech levels 1-11 can have custom range values. Higher tech levels are treated like tech level 11.
The corresponding check (sub_47C350) is located at position:

Code: Select all

47C36F     cmp   ax, 0Ah
47C373     jbe   short loc_47C3B7
47C375     mov   ebx, 0Ah
Increasing of the values allows usage of custom range-values for higher tech levels.

One must still free up the space in trek.exe of course, or the data offset calculation has to be adapted e.g. each data value must have a size of 2 bytes instead of 4, or e.g. all empires have to share the same values.

Anyhow it would be an interesting enhancement for the future technologies on enlarged maps. :)




:arrow: The Range Labels (i.e. lexicon.dic entries) are stored in sub_46F410:

Code: Select all

46F432      mov    eax, 47Bh   //   Short (1147)
46F46F      mov    eax, 273h   //   Medium (627)
46F468      mov    eax, 263h   //   Long (611) 
46F476      mov    eax, 31Eh   //   n/a (798)
Note the entry 798 ("n/a") is shared for different purposes, so if you intend to use e.g. the term "towable" for fighters, just enter number of an unused lexicon entry instead.



thunderchero wrote:I was just wondering is there a map range for minors?
Here still is a lack of testing/research. Looking at the code, bonus value offset for minors is at asm-590D14. But prepare for inconsistencies. At 590D8C there is also a bonus set for monsters, and somehow I doubt it's really used. 59089C could be the minor base range. Ultimately, I wouldn't be surprised if it turns out that minors use just the cardassian base values.

asm - base offsets for:

Code: Select all

59082C   short_base_ranges
590830   medium_base_ranges
590834   long_base_ranges

59089C   (unknown) maybe minor base ranges? /sub_47B030(AI range control?)

590A80   tech_bonus_ranges_Majors
590D14   tech_bonus_ranges_Minors
590D8C   tech_bonus_ranges_Monster

590D98   (unknown) maybe minor/monster ranges?

590F7C   next data field
Concerning map range of minor races is notable that minors do NOT share the OWN range with an affiliated empire, but instead provide the range of the trading partner. Unlike when empires share the own range.
Last edited by Spocks-cuddly-tribble on Mon Jan 11, 2010 1:15 pm, edited 1 time in total.
I don't know how many bugs is too many but that point is reached somewhere before however many in BotF is.
User avatar
Gowron
Code Master
Code Master
Posts: 304
Joined: Sat Apr 26, 2008 2:00 am
Location: 50° N, 11° E

Re: Map Range

Post by Gowron »

Spocks-cuddly-tribble wrote:
Gowron wrote:The map range for each tech level is displayed in the tech field database (F4 screen)... BUT the range is always off by one tech level.
Well, then let's correct the bug. :wink:

Sub_47C1B0 is used for this purpose (exclusively). And, since BotF pigheaded refuses our joining as minor race or as monster, the code is pointless for the most part and can be altered.
Thanks for finding this :)

There's really a lot of redundant/inefficient code at that area :?
A discovery consists in seeing something everybody has seen and at the same time thinking something nobody has thought yet.
User avatar
Gowron
Code Master
Code Master
Posts: 304
Joined: Sat Apr 26, 2008 2:00 am
Location: 50° N, 11° E

Re: Map Range

Post by Gowron »

Spocks-cuddly-tribble wrote:
Gowron wrote:The map range for each tech level is displayed in the tech field database (F4 screen)... BUT the range is always off by one tech level.
Well, then let's correct the bug. :wink:

Sub_47C1B0 is used for this purpose (exclusively). And, since BotF pigheaded refuses our joining as minor race or as monster, the code is pointless for the most part and can be altered.
I just tested this, and there's a minor flaw: The tech 11 range values magically re-appeared at the display for tech 0 ^^
That's because the "dec edx" statement does not work as intended if edx is already zero (integer underflow).


But since we have enough space to work with, I suggest

Code: Select all

47C1B4 85D2                    test edx, edx
47C1B6 7401                    je 0047C1B9
47C1B8 4A                      dec edx
Spocks-cuddly-tribble wrote:You're right, thank you. :)

I modified other code to prevent this from happening, but forgot to add this info in my post.
However, your code is more compact/elegant, so I'll update my post accordingly. :)
Last edited by Gowron on Mon Aug 02, 2010 4:07 am, edited 1 time in total.
A discovery consists in seeing something everybody has seen and at the same time thinking something nobody has thought yet.
User avatar
DOT
Lieutenant-Commander
Lieutenant-Commander
Posts: 100
Joined: Tue Dec 23, 2008 3:00 am
Location: 49°N, 8°E

Post by DOT »

BTW: I modded map range for large map with UE and ended at tech level 4 with an exe hangup; had a max range of 10/12/14 sectors for high range (all races at level 4/5/6) and a running alliance with the feds and that seems to be the problem:
The accessable sectors from the feds "exploded" to nearly 1/4 of the whole map, and no, the feds where located only in the area of the lower right corner and I controlled the middle and upper right side of the map. The cards where located in the center of the map and I was just beginning to prepare for war against them.
I took another (older) exe version of my mod and added all new mods, but didn't channge map range. With this exe I was able to continue the game.
life long and prosper
User avatar
Peter1981
Rear-Admiral
Rear-Admiral
Posts: 1118
Joined: Tue May 06, 2008 2:00 am
Location: England

Post by Peter1981 »

:. i suggest that maybe making map range purely arithmetic rather than tabular might make more sence.
keep the race base table but use the 138bytes in the tech offset for the codeing?


if range is based on tech level (L) then
Tech Short Medium Long
Level int((L+4)/3) int((L+8)/3) int((L+9)/2.5)
T0 1 2 3
T1 1 3 4
T2 2 3 4
T3 2 3 4
T4 2 4 5
T5 3 4 5
T6 3 4 6
T7 3 5 6
T8 4 5 6
T9 4 5 7
T10 4 6 7
T11 5 6 8
T12 5 6 8
T13 5 7 8
T14 5 7 9
T15 6 7 9
T16 6 8 10
T17 6 8 10
T18 7 8 10
T19 7 9 11
T20 7 9 11

etc...

to be honest i wouldn't even use the race base tech bonus table either? -- could this be done more simply than making the subroutine work on 2bytes?

Spocks-cuddly-tribble wrote:Yes, if not race specific, you just need the first rules of arithmetic and a bit time.

But note sub_47C350(&47C1B0) gives out an address! (in eax) not the range value, so you have to adapt the registers for all calling instances.
User avatar
Gowron
Code Master
Code Master
Posts: 304
Joined: Sat Apr 26, 2008 2:00 am
Location: 50° N, 11° E

Post by Gowron »

Tethys wrote:gets its range information from Tech 11 positions. Subquestion: Is this the same for the other tech categories as well (weapons etc)?
No, the respective subroutine only applies to propulsion tech levels and their effect on map range values.
Tethys wrote:I am trying to find out if there is a way to change which tech level that Tech 0 reads from, preferably its own independent tech,
In trek.exe at position 0x7B76E change "48" to "90".
After that, the bonus values for tech 1-11 will become bonus values for tech 0-10.

This will also "automatically" fix the F4 screen display bug.
A discovery consists in seeing something everybody has seen and at the same time thinking something nobody has thought yet.
User avatar
Spocks-cuddly-tribble
Code Master
Code Master
Posts: 1883
Joined: Sun Apr 27, 2008 2:00 am

Re: Map Range

Post by Spocks-cuddly-tribble »

Spocks-cuddly-tribble wrote:
Gowron wrote:Only propulsion tech levels 1-11 can have custom range values. Higher tech levels are treated like tech level 11.
...usage of custom range-values for higher tech levels.

One must still free up the space in trek.exe of course, or the data offset calculation has to be adapted e.g. each data value must have a size of 2 bytes instead of 4, or e.g. all empires have to share the same values.

Anyhow it would be an interesting enhancement for the future technologies on enlarged maps. :)
In step with the progress of How to add a Science and technologies: (I've lost track of the project)


=> Shared bonus ranges for all empires (i.e. trek.exe code space for up to 55 propulsion tech levels)

Code: Select all

-> tech screen display

47C203                 add     ebx, eax   // race base offset
at 0x7B603 change 01 C3 -> 90 90


-> bonus ranges effective

47C39B                 add     ecx, eax   // race base offset
at 0x7B79B change 01 C1 -> 90 90

=> Tech limit for custom range values (unmodded max tech level -1, i.e. 0xA = max TL 11). Higher tech levels will be treated like the max tech level.


- Tech limit for the tech screen display: (not for the number of displayed techs!)

Code: Select all

47C1CD                 cmp     dx, 0Ah  //  0x7B5D0
47C1D1                 jbe     loc_47C284
47C1D7                 mov     edx, 0Ah //  0x7B5D8

-> F4 screen display bug/fix: (option A)
replace:
47C1B4                 mov     ebx, 5
with:
47C1B4 85D2                    test edx, edx
47C1B6 7401                    je 47C1B9
47C1B8 4A                      dec edx
i.e. at 0x7B5B4 change BB 05 00 00 00 -> 85 D2 74 01 4A
- Tech limit for bonus ranges effective:

Code: Select all

47C36E                 dec     eax   // (see below quote)
47C36F                 cmp     ax, 0Ah  //  0x7B771
47C373                 jbe     short loc_47C3B7
47C375                 mov     ebx, 0Ah //  0x7B776
Gowron wrote:
Tethys wrote:I am trying to find out if there is a way to change which tech level that Tech 0 reads from, preferably its own independent tech,
In trek.exe at position 0x7B76E change "48" to "90".
After that, the bonus values for tech 1-11 will become bonus values for tech 0-10.

This will also "automatically" fix the F4 screen display bug.
But note that this will waste a tech level, since the ranges of propulsion tech 0 (i.e. the base ranges) already are custom values, albeit it doesn't matter with extended bonus tech levels.

It goes without saying that ALL above tech limits now represent the max tech level (not level -1).

Don't combine this with fix option A !


EDIT:

==> Detailed Implementation Example using the Ultimate Editor :idea:
Last edited by Spocks-cuddly-tribble on Tue Feb 22, 2011 11:50 am, edited 1 time in total.
I don't know how many bugs is too many but that point is reached somewhere before however many in BotF is.
User avatar
thunderchero
Site Administrator aka Fleet Admiral
Site  Administrator aka Fleet Admiral
Posts: 7848
Joined: Fri Apr 25, 2008 2:00 am
Location: On a three month training mission, in command of the USS Valiant.

Re: Map Range

Post by thunderchero »

I doubt if many will need this info but thought I would add info

this drove me nuts for 4 hours, every time I edited using above code for Shared bonus ranges for all empires.
The cardassains, Klingons, and romulans would lose 1 long range from tech 12 to tech 20 and federation and ferengi would gain 1 long range from tech 1 to tech 11.

the issue was the "Base values" are different, so before you edit with UE change

0x0018e640 04 -> 03 (federation long range base value)
and
0x0018e64c 04 -> 03 (ferengi long range base value)

this will make all base values 1 - 2 - 3
User avatar
Spocks-cuddly-tribble
Code Master
Code Master
Posts: 1883
Joined: Sun Apr 27, 2008 2:00 am

Re: Map Range

Post by Spocks-cuddly-tribble »

Shared bonus ranges still allow for custom (empire specific) base ranges.

Just note that depending on the used 'F4 screen display fix' option the tech limit values for custom ranges might change by one (option A max tech level -1).

If there is an UE interface issue, setting base ranges equal during UE editing and diversifying them again afterwards should work.

Unless there is a conflict with the extended technologies patch: viewtopic.php?name=Forums&file=viewtopic&t=1531#p20978
I don't know how many bugs is too many but that point is reached somewhere before however many in BotF is.
User avatar
thunderchero
Site Administrator aka Fleet Admiral
Site  Administrator aka Fleet Admiral
Posts: 7848
Joined: Fri Apr 25, 2008 2:00 am
Location: On a three month training mission, in command of the USS Valiant.

Re: Map Range

Post by thunderchero »

Spocks-cuddly-tribble wrote: Tue May 19, 2020 2:20 pm Shared bonus ranges still allow for custom (empire specific) base ranges.

Just note that depending on the used 'F4 screen display fix' option the tech limit values for custom ranges might change by one (option A max tech level -1).

If there is an UE interface issue, setting base ranges equal during UE editing and diversifying them again afterwards should work.

Unless there is a conflict with the extended technologies patch: viewtopic.php?name=Forums&file=viewtopic&t=1531#p20978
when editing with UE it only displays total range (base + bonus)

so yes editing base values afterward works.
User avatar
Spocks-cuddly-tribble
Code Master
Code Master
Posts: 1883
Joined: Sun Apr 27, 2008 2:00 am

Disable Shared Map Ranges for Affiliation & Alliance

Post by Spocks-cuddly-tribble »

thunderchero wrote: Wed Nov 02, 2022 11:31 pmwhen AI signs affiliation or alliance and ship range increase turn processing quadruples.
Nop call or change sub to retn:

Code: Select all

0047B825     call  47B310 ShareMapRanges_Affiliated_Alliance
But that'd be a bad AI crippling workaround. So better go ahead with fixing sub_426D90 AIShpUnts_to_Tasks_TurnLag. :wink: :wink:


EDIT: Here is the option to share map-range only for Alliance but not Affiliation:

Code: Select all

0047B361   jnz   short loc_47B396         ; jmp share range alliance only 0x7A761 75 -> EB
I don't know how many bugs is too many but that point is reached somewhere before however many in BotF is.
Post Reply

Return to “Map Range”