Minor Race Advancement
Moderator: thunderchero
- thunderchero
- Site Administrator aka Fleet Admiral
- Posts: 7963
- Joined: Fri Apr 25, 2008 2:00 am
- Location: On a three month training mission, in command of the USS Valiant.
Minor Race Advancement
Credit for this post topic; Gowron
Every minor race has 10 evolution levels (you can set the tech levels for each evolution level by using the Ultimate Editor). At the start of each turn, a minor race can either stay at its current EL (evolution level) or advance to the next EL.
There are 3 values in race.rst that influence minor race advancement:
[growth rate]
relative offset (in relation to the start of the minor race's entry): 0x44
type: floating-point
length: 4 bytes
The [growth rate] is also used for the planets' growth values. (use the search function for details)
[speed 1]
relative offset: 0x58
type: integer
signed: yes
length: 2 bytes
[speed 2]
relative offset: 0x5A
type: integer
signed: unknown
length: 2 bytes
1. Orbitals
At the start of a game, every minor race home system has 1 orbital battery per 50 population points (rounded down). So the Ullians with their starting pop of 100 have 2 orbitals. If their starting pop was 99, then they'd only have 1 orbital.
=> Initial Number of Orbitals for Minor Races
Every time a minor race advances, it gets a random number of additional orbitals (min. 1, max. 6, if anyone has seen greater increases, please tell me).
2. Ships (spacefaring races)
If the starting EL is high enough to fulfil the tech requirements for the ship(s) that this race can build, then the race starts with a random number of ships (min. 1, max. 4).
Every time the minor race advances, it gets a random number of additional ships (min. 1, max. 4), but only if both of the following conditions are fulfilled:
a) The new EL is high enough to fulfil the tech requirements for the ship(s).
b) The new population is 61 or more.
3. Population
Each minor race has an internal population number (IPN). At the start of a game, this is identical to the real population number.
At the beginning of every new turn, starting at turn 3, the IPN is updated as follows:
[new IPN] = [old IPN] * ( 1 + 0.1 * [growth rate] )
The result is then cut at the decimal point.
Every time the minor race advances, its real population number is set to its IPN or to the system's max. population space, whichever value is lower. Sometimes they fail to terraform enough planets, but most of the time they will make it.
The IPN is unaffected by bombardments, and the population update takes place after the losses by bombardment are applied. So if a minor race is bombarded during the turn that it advances, its population will be set to its IPN and not be reduced (except if it's completely wiped out, then it won't advance).
4. Advancement Speed
The advancement speed is controlled by the values [speed 1], [speed 2] and by the starting seed. The influence of the starting seed is so strong and erratic that I can't give an exact formula, but I can give you this rule of thumb that will be very accurate in the long-term average:
[turns needed to advance to next EL] ~= 0.306 * ( [number of next EL] + 2 ) * ( 18 - [speed 1] ) / [speed 2]
=> modding hints wrt the EL related delay factor 1/3
The value [speed 1] is between -70 and -15 by default, and it should be kept between -1000 and -15 if you want to use the above rule of thumb. Any further increase (positive values are possible) will result in rapid and very erratic growth.
The value [speed 2] is between 1 and 3 by dafault. Setting it to zero will completely stop this minor race from advancing.
I recommend setting this value to something between 0 (stagnation) and 1000 (instant advancement).
If you increase [speed 2], you should also decrease [speed 1] a bit (i.e. increase its absolute, since it's negative). This makes the advancement somewhat smoother (less erratic).
[speed 2] shows strange behaviour if further increased. At around 40.000, advancement starts to slow down again slowly but steadily as [speed 2] increases, and if it reaches 65535 (FFFF), then there's no advancement, just like if it was set to 0.
One thing that you should keep in mind is that a race that advances very fast will end up with a relatively low population because the IPN does not increase any faster just because the race advances faster.
If you want fast advancement AND high population, you must increase [growth rate] as well.
To get a better overview:
1. Make a backup of race.rst
2. Open race.rst with your Hex Editor and set the "bytes per row" to 108.
3. Delete the first 2 bytes in race.rst (don't just set them to zero, *delete* them).
Then race.rst will just look like a table, and you can use the offset row to quickly navigate to the positions 0x44, 0x58 and 0x5A
Once you see race.rst this way, it'll be much easier to find the values even under the default settings (i.e. 16 or 24 bytes per row and w/out deleting the first 2 bytes).
Starting Level of Minor Races
The starting EL depends on the difficulty level.
The difficulty level is a number between 1 and 5, with 1 being "simple" difficulty and 5 being "impossible" difficulty.
At difficulty level 1, for each minor race there's a 67% chance to start at EL 1 and a 33% chance to start at EL 2.
At the other difficulty levels, there's
a 33% chance to start at EL = [difficulty level] - 1
a 33% chance to start at EL = [difficulty level]
a 33% chance to start at EL = [difficulty level] + 1
Silent Advancement
A minor race that joins an empire will still have its own advancement level. It will also advance further "silently", i.e. its EL will increase normally, but its population and its ground combat value will be determined by the controlling empire.
If the minor race leaves the empire later, then it will continue to advance normally, as if it had never been a member of an empire.
Getting stuck
During the advancement tests, a minor race sometimes got stuck at EL 8 on "simple" difficulty. Maybe it was a bug, maybe purpose (to prevent them from getting too advanced with respect to the major empires). On the other hand, I've also seen minor races advance all the way to EL 10 on "simple" difficulty, and this seemed to be the normal case.
Every minor race has 10 evolution levels (you can set the tech levels for each evolution level by using the Ultimate Editor). At the start of each turn, a minor race can either stay at its current EL (evolution level) or advance to the next EL.
There are 3 values in race.rst that influence minor race advancement:
[growth rate]
relative offset (in relation to the start of the minor race's entry): 0x44
type: floating-point
length: 4 bytes
The [growth rate] is also used for the planets' growth values. (use the search function for details)
[speed 1]
relative offset: 0x58
type: integer
signed: yes
length: 2 bytes
[speed 2]
relative offset: 0x5A
type: integer
signed: unknown
length: 2 bytes
1. Orbitals
At the start of a game, every minor race home system has 1 orbital battery per 50 population points (rounded down). So the Ullians with their starting pop of 100 have 2 orbitals. If their starting pop was 99, then they'd only have 1 orbital.
=> Initial Number of Orbitals for Minor Races
Every time a minor race advances, it gets a random number of additional orbitals (min. 1, max. 6, if anyone has seen greater increases, please tell me).
2. Ships (spacefaring races)
If the starting EL is high enough to fulfil the tech requirements for the ship(s) that this race can build, then the race starts with a random number of ships (min. 1, max. 4).
Every time the minor race advances, it gets a random number of additional ships (min. 1, max. 4), but only if both of the following conditions are fulfilled:
a) The new EL is high enough to fulfil the tech requirements for the ship(s).
b) The new population is 61 or more.
3. Population
Each minor race has an internal population number (IPN). At the start of a game, this is identical to the real population number.
At the beginning of every new turn, starting at turn 3, the IPN is updated as follows:
[new IPN] = [old IPN] * ( 1 + 0.1 * [growth rate] )
The result is then cut at the decimal point.
Every time the minor race advances, its real population number is set to its IPN or to the system's max. population space, whichever value is lower. Sometimes they fail to terraform enough planets, but most of the time they will make it.
The IPN is unaffected by bombardments, and the population update takes place after the losses by bombardment are applied. So if a minor race is bombarded during the turn that it advances, its population will be set to its IPN and not be reduced (except if it's completely wiped out, then it won't advance).
4. Advancement Speed
The advancement speed is controlled by the values [speed 1], [speed 2] and by the starting seed. The influence of the starting seed is so strong and erratic that I can't give an exact formula, but I can give you this rule of thumb that will be very accurate in the long-term average:
[turns needed to advance to next EL] ~= 0.306 * ( [number of next EL] + 2 ) * ( 18 - [speed 1] ) / [speed 2]
=> modding hints wrt the EL related delay factor 1/3
The value [speed 1] is between -70 and -15 by default, and it should be kept between -1000 and -15 if you want to use the above rule of thumb. Any further increase (positive values are possible) will result in rapid and very erratic growth.
The value [speed 2] is between 1 and 3 by dafault. Setting it to zero will completely stop this minor race from advancing.
I recommend setting this value to something between 0 (stagnation) and 1000 (instant advancement).
If you increase [speed 2], you should also decrease [speed 1] a bit (i.e. increase its absolute, since it's negative). This makes the advancement somewhat smoother (less erratic).
[speed 2] shows strange behaviour if further increased. At around 40.000, advancement starts to slow down again slowly but steadily as [speed 2] increases, and if it reaches 65535 (FFFF), then there's no advancement, just like if it was set to 0.
One thing that you should keep in mind is that a race that advances very fast will end up with a relatively low population because the IPN does not increase any faster just because the race advances faster.
If you want fast advancement AND high population, you must increase [growth rate] as well.
To get a better overview:
1. Make a backup of race.rst
2. Open race.rst with your Hex Editor and set the "bytes per row" to 108.
3. Delete the first 2 bytes in race.rst (don't just set them to zero, *delete* them).
Then race.rst will just look like a table, and you can use the offset row to quickly navigate to the positions 0x44, 0x58 and 0x5A
Once you see race.rst this way, it'll be much easier to find the values even under the default settings (i.e. 16 or 24 bytes per row and w/out deleting the first 2 bytes).
Starting Level of Minor Races
The starting EL depends on the difficulty level.
The difficulty level is a number between 1 and 5, with 1 being "simple" difficulty and 5 being "impossible" difficulty.
At difficulty level 1, for each minor race there's a 67% chance to start at EL 1 and a 33% chance to start at EL 2.
At the other difficulty levels, there's
a 33% chance to start at EL = [difficulty level] - 1
a 33% chance to start at EL = [difficulty level]
a 33% chance to start at EL = [difficulty level] + 1
Silent Advancement
A minor race that joins an empire will still have its own advancement level. It will also advance further "silently", i.e. its EL will increase normally, but its population and its ground combat value will be determined by the controlling empire.
If the minor race leaves the empire later, then it will continue to advance normally, as if it had never been a member of an empire.
Getting stuck
During the advancement tests, a minor race sometimes got stuck at EL 8 on "simple" difficulty. Maybe it was a bug, maybe purpose (to prevent them from getting too advanced with respect to the major empires). On the other hand, I've also seen minor races advance all the way to EL 10 on "simple" difficulty, and this seemed to be the normal case.
- Flocke
- BORG Trouble Maker
- Posts: 3258
- Joined: Sun Apr 27, 2008 2:00 am
- Location: Hamburg, Germany
- Contact:
auto upgrade bug
That's working for conquered major race systems as well. The ai decides to upgrade industry or other buildings after some conditions are met. And if so, it'll upgrade the type of building that's already there and doesn't replace it by your own race specific ones. Didn't make any research on it, but ai normally seemed to build a few buildings of every type and a few more if it's completely in use, before it's beginning upgrading present ones.stardust wrote:On a different note, i can confirm the fact that minor races can auto upgrade on their own, regardless of what the empire tech is.
Get the minor to build something, anything, it doesn't matter what, but make sure you have them set to automatic in the build queue screen. After they've build what you've told them to (basically to nudge them into action) you should start seeing them auto upgrading things periodically.
- Spocks-cuddly-tribble
- Code Master
- Posts: 1961
- Joined: Sun Apr 27, 2008 2:00 am
Apparently, the makers of BotF decided in thier infinite wisdom that starting EL dependance on difficulty level isn't annoying enough...Gowron wrote:Starting Level of Minor Races
The starting EL depends on the difficulty level.
The difficulty level is a number between 1 and 5, with 1 being "simple" difficulty and 5 being "impossible" difficulty.
Influence of galaxy size:
Small: +1
Medium: +0
Large: -1
[galaxy size value] + [difficulty level] = predictor for starting EL of minor races
Limitations:
- values below zero will be stored as 0
- values larger nine will be stored as 9
0 -> predicted starting EL=1
1 -> predicted starting EL=2
(predicted starting EL = predictor value +1)
For the random implementive just replace [difficulty level] with [predicted starting EL] :
The predictor for starting EL of minor races (ds: 5A2B2B) is set by sub_451970 and read in sub_453000.Gowron wrote:At difficulty level 1, for each minor race there's a 67% chance to start at EL 1 and a 33% chance to start at EL 2.
At the other difficulty levels, there's
a 33% chance to start at EL = [difficulty level] - 1
a 33% chance to start at EL = [difficulty level]
a 33% chance to start at EL = [difficulty level] + 1
I'd recomend a dependance of something more useful e.g. starting techlevel of player/host or arithmetic average of ds:5A2B2C (starting levels for each empire).
I don't know how many bugs is too many but that point is reached somewhere before however many in BotF is.
Nice find. I like the arithmetic option better, but it would be harder to do because it would need more code.
Reading this topic again made me wonder. If IPN is set on every turn it would likely be possible to instead just increase the actual population. I'd much rather have minor race population grow normally then suddenly in the middle of bombardment they jump from 10 to 200.
Reading this topic again made me wonder. If IPN is set on every turn it would likely be possible to instead just increase the actual population. I'd much rather have minor race population grow normally then suddenly in the middle of bombardment they jump from 10 to 200.
I took a look at the subroutine. I expected less code. The same could be accomplished without the if else jumps.
I can easily add the starting eras together and divide by 5, but that would mean that if all empires start at era 4, the predictor would be 4, while actual empire levels would be 8 (at least in vanilla). To make minors have the same tech levels would need reading of the racetech.tec file to get actual empire level. That would be more difficult to do.
For the predictor to be from 0-4 depending on empire starting era paste this code at 0x50D70:
52 53 31 C0 31 D2 31 DB 8A 93 2C 2B 5A 00 01 D0 43 83 FB 05 7C F2 F6 F3 A2 2B 2B 5A 00 5B 5A C3
And optionally fill the bytes following with 00 until you get to the block of zeros.
I can easily add the starting eras together and divide by 5, but that would mean that if all empires start at era 4, the predictor would be 4, while actual empire levels would be 8 (at least in vanilla). To make minors have the same tech levels would need reading of the racetech.tec file to get actual empire level. That would be more difficult to do.
For the predictor to be from 0-4 depending on empire starting era paste this code at 0x50D70:
52 53 31 C0 31 D2 31 DB 8A 93 2C 2B 5A 00 01 D0 43 83 FB 05 7C F2 F6 F3 A2 2B 2B 5A 00 5B 5A C3
And optionally fill the bytes following with 00 until you get to the block of zeros.
Code: Select all
push edx
push ebx
xor eax, eax
xor edx, edx
xor ebx, ebx
loc_451978:
mov dl, ds:byte_5A2B2C[ebx]
add eax, edx
inc ebx
cmp ebx, 5
jl short loc_451978
div bl
mov ds:byte_5A2B2B, al
pop ebx
pop edx
retn
Just realised the EL levels are levels from racetech.tec. Since empires have 5 of them and minor races have ten we can just multiply the predictor by 2 to get a comparable tech level.
Spocks-cuddly-tribble wrote:Thank you very muchDCER wrote:I can easily add the starting eras together and divide by 5, but that would mean that if all empires start at era 4, the predictor would be 4
That's exactly the way it should be.
IMHO a depending on the actual racetech.tec starting tech levels isn't recommended, since there're too little remaining advancement steps left for shipbuilding and increase in population.
- Spocks-cuddly-tribble
- Code Master
- Posts: 1961
- Joined: Sun Apr 27, 2008 2:00 am
Minor Race Advancement
This topic yield many promising approaches. It's long overdue, that we complete the job and rebalance minor races in BotF to a whole new level.
The last piece of the jigsaw: (broken/biased feature)
EmpsMaxTech = highest major techlevel in game (e.g. [energy tech] 7) - Side note: Could be very useful for the Borg delay issue.
i.e. on "simple" there is a need of a major tech level 6 for EL9 (hexcode 08 )
+2 due to minor EL / major tech -range deviation & a check error:
Removing the jump at 452927 can turn off this limit (not recommended). But, much better than that, now, finally, we can correct the infamous minor race bias in BotF.
As Gowron pointed out, the minor start EL depends on difficulty level(& galaxy size). The problem is, this implementation of difficulty level would only make sense if applied to AI empires. In fact quite the reverse is true. Disastrous consequence of this is that (playing with minors) the effect of the difficulty level is reversed i.e. the higher the level the easier the game for players resp. harder for AI empires.
1. Correcting the Bias of the Minor Start EL (above code by DCER)
Now, the Minor start EL depends on the arithmetic average of the empires starting eras (thanks again to DCER).
2. Remove difficulty level bias from Minor EL limit and compensate code error
Now the EL cannot exceed EmpsMaxTech (excepting start EL)
This means more realism & balance for epic games (no more waiting for minor jumps without adequately developped majors).
3. Minor Starting Pop Bonus via Start EL (+ Terraform Option)
This is meant to keep balance on higher tech games, particularly when using the normal minor pop growth option (see section 4).
Pop bonus (X*Start EL), addet to race.rst start pop, is in trek.exe at 0x50950 (default 10)
Note, even when using 0, in unmodded BotF, there is now a chance that e.g. vulcans start with an additional planet terraformed, to support their race.rst starting pop.
=> Terraforming Fix for Additional Starting Systems and Minors (sub 4518F0)
Under default setting, this fix exacerbates the minor race imbalance issue in BotF, but see below.
4. Normal Minor Race Pop Growth
Minor race population grows normally up to the current system pop limit, terraform option still only via EL jump (external aid does still work).
The minor pop growth rate can be adjusted via:
Code for a normal minor race pop growth:
Minor pop/turn bonus is in trek.exe at 0x513E8 default: +1
New Minor Growth Calculation (close to the majors) - pop increase/turn:
current pop + [system growth rate]% + [static bonus (default 1 pop/turn)]
By the way of comparison, pop growth / turn:
=> Minors: (unmodded)
=> Majors:
->Pop Growth, Terraforming Costs, Trade Goods, Pulsar Patterns
The last piece of the jigsaw: (broken/biased feature)
The minor EL cannot exceed [EmpsMaxTech + difficulty level +2] -> (excepting start EL)Gowron wrote:Getting stuck
During the advancement tests, a minor race sometimes got stuck at EL 8 on "simple" difficulty. Maybe it was a bug, maybe purpose (to prevent them from getting too advanced with respect to the major empires).
EmpsMaxTech = highest major techlevel in game (e.g. [energy tech] 7) - Side note: Could be very useful for the Borg delay issue.
i.e. on "simple" there is a need of a major tech level 6 for EL9 (hexcode 08 )
+2 due to minor EL / major tech -range deviation & a check error:
Code: Select all
452901 mov eax, ds: 5B184C Minor_EL/speed_data_8bytes
452906 shl ecx, 3
452909 add ecx, eax
45290B mov dx, [ecx] // current EL
45290E cmp dx, 9 // max EL
452912 jge short 4528C5 // exit
452914 mov ax, ds: 5A2B44 difficulty_level
45291A add ax, ds: 5B4330 EmpsMaxTech
452921 movsx edx, dx
452924 cwde
452925 cmp edx, eax // EL vs. EmpsMaxTech+difficulty level
452927 jg short 4528C5 // exit
As Gowron pointed out, the minor start EL depends on difficulty level(& galaxy size). The problem is, this implementation of difficulty level would only make sense if applied to AI empires. In fact quite the reverse is true. Disastrous consequence of this is that (playing with minors) the effect of the difficulty level is reversed i.e. the higher the level the easier the game for players resp. harder for AI empires.
1. Correcting the Bias of the Minor Start EL (above code by DCER)
Code: Select all
Trek.exe at 0x50D70
replace:
52 A1 3C 2B 5A 00 83 F8 01 73 20 85 C0 75 1E B8 01 00 00 00 66 8B 15 44 2B 5A 00 0F BF D2 01 D0
with:
52 53 31 C0 31 D2 31 DB 8A 93 2C 2B 5A 00 01 D0 43 83 FB 05 7C F2 F6 F3 A2 2B 2B 5A 00 5B 5A C3
2. Remove difficulty level bias from Minor EL limit and compensate code error
Code: Select all
at 0x51D14 change 66 A1 44 2B 5A 00 66 03 05
to -> 80 C2 02 90 90 90 90 66 A1
at asm-452914
add dl, 2
nop...
mov ax, ds: EmpsMaxTech
This means more realism & balance for epic games (no more waiting for minor jumps without adequately developped majors).
3. Minor Starting Pop Bonus via Start EL (+ Terraform Option)
This is meant to keep balance on higher tech games, particularly when using the normal minor pop growth option (see section 4).
Code: Select all
Trek.exe at 0x5093B
replace: (51 bytes)
89 C8 31 D2 E8 6C 42 FF FF F7 B4 24 38 01 00 00 89 C2 31 C0 66 8B 84 24 F2 00 00 00 39 C2 73 10 89 C8 31 D2 B9 0A 00 00 00 E8 47 42 FF FF F7 F1 89 46 40
with:
0F B6 46 44 E8 DC 11 00 00 8B 15 4C 18 5B 00 0F B7 04 C2 6B C0 0A 0F B7 94 24 F2 00 00 00 03 D0 89 56 40 8B C1 E8 8B 03 00 00 90 90 90 90 90 90 90 90 90
45153B 0FB646 44 MOVZX EAX, BYTE [ESI+44] // race ID
45153F E8 DC110000 CALL 452720 // GetMinorResearchIndex
451544 8B15 4C185B00 MOV EDX, DS:[5B184C] // minor EL data 8bytes
45154A 0FB704C2 MOVZX EAX, WORD [EDX+EAX*8] // load minor EL
45154E 6BC0 0A IMUL EAX, EAX, 0A // multiply EL by 10
451551 0FB79424 F2000000 MOVZX EDX, WORD [ESP+F2] // start pop from race.rst
451559 03D0 ADD EDX, EAX // pop + EL *10
45155B 8956 40 MOV DWORD [ESI+40], EDX // update systInfo pop
45155E 8BC1 MOV EAX, ECX // star ID
451560 E8 8B030000 CALL 4518F0 // see terraform fix by Gowron
451565-45156D 90 NOP
Note, even when using 0, in unmodded BotF, there is now a chance that e.g. vulcans start with an additional planet terraformed, to support their race.rst starting pop.
=> Terraforming Fix for Additional Starting Systems and Minors (sub 4518F0)
Under default setting, this fix exacerbates the minor race imbalance issue in BotF, but see below.
4. Normal Minor Race Pop Growth
And here it comes: (minor evolution jump speed & mechanics untouched yet)DCER wrote:I'd much rather have minor race population grow normally then suddenly in the middle of bombardment they jump from 10 to 200.
Minor race population grows normally up to the current system pop limit, terraform option still only via EL jump (external aid does still work).
The minor pop growth rate can be adjusted via:
- race.rst Growth value (see first post)
- a static bonus (see below)
Code for a normal minor race pop growth:
Code: Select all
trek.exe at 0x5133C (196 bytes)
Replace:
66 3D 20 00 0F 83 CE 01 00 00 89 C1 B8 01 00 00 00 D3 E0 8B 35 50 2B 5A 00 89 C1 21 F1 0F 85 70 04 00 00 31 C0 66 8B 84 24 C0 01 00 00 66 8B 3C 45 60 23 5B 00 0F BF CF 69 D9 28 03 00 00 8B 15 C8 36 5A 00 01 DA 89 94 24 B0 01 00 00 80 7A 4C 05 0F 82 3C 04 00 00 E8 B8 16 00 00 89 C5 A1 C8 36 5A 00 01 C3 31 C0 8D B4 24 1C 01 00 00 66 8B 43 44 E8 9D CD 05 00 D9 84 24 60 01 00 00 DC 0D B8 94 57 00 BA FF 00 00 00 66 89 BC 24 C4 01 00 00 89 C8 DD 9C 24 A8 01 00 00 E8 65 15 FF FF DC 9C 24 A8 01 00 00 DF E0 9E 0F 86 47 01 00 00 D9 84 24 60 01 00 00 DC 0D B8 94 57 00 DD 9C 24 A0 01 00 00 8B
With:
89 94 24 B4 01 00 00 89 94 24 B8 01 00 00 66 8B 3C 45 60 23 5B 00 0F BF CF 69 D9 28 03 00 00 8B 15 C8 36 5A 00 03 D3 89 94 24 B0 01 00 00 80 7A 4C 05 0F 82 5B 04 00 00 E8 D7 16 00 00 8B E8 FF 42 40 0F BF C7 E8 6A F9 FF FF FF 4A 40 E9 02 01 00 00 00 00 53 51 55 83 EC 04 0F BF 14 5D 60 23 5B 00 69 CA 28 03 00 00 A1 C8 36 5A 00 03 C8 80 79 4C 05 72 46 8B C2 E8 B8 1A FF FF 8B F8 3B 41 40 74 38 8B C2 E8 7A 15 FF FF DB 41 40 DE C9 DC 0D DC 88 57 00 E8 FE B6 0C 00 DB 1C 24 BA 59 03 00 00 E8 0D 60 0B 00 83 E0 01 83 C0 01 03 04 24 01 41 40 39 79 40 7E 03 89 79 40 83 C4 04 5D 59 5B C3 00 00
at 0x51CC4 replace: 2D with: 24
AND at 0x51CE7
Change: 74 09 83 C4 0C 5F 5E 5A 59 5B C3 -> To: 75 DC E8 A2 F6 FF FF 90 90 90 90
modified part of MinorJump (i.e. new EL) for terraforming option, buildings & ships
451F3C 899424 B4010000 MOV [ESP+1B4], EDX
451F43 899424 B8010000 MOV [ESP+1B8], EDX
451F4A 66:8B3C45 60235B00 MOV DI, [EAX*2+5B2360] //starID from RToSInfo
451F52 0FBFCF MOVSX ECX, DI
451F55 69D9 28030000 IMUL EBX, ECX, 328
451F5B 8B15 C8365A00 MOV EDX, [5A36C8] // systInfo
451F61 03D3 ADD EDX, EBX
451F63 899424 B0010000 MOV [ESP+1B0], EDX // current systInfo entry
451F6A 807A 4C 05 CMP BYTE [EDX+4C], 5
451F6E 0F82 5B040000 JB 4523CF (exit if part of empire)
451F74 E8 D7160000 CALL 453650 // load minor tech levels
451F79 8BE8 MOV EBP, EAX
451F7B FF42 40 INC [EDX+40] // virtual pop increase for terraform check
451F7E 0FBFC7 MOVSX EAX, DI
451F81 E8 6AF9FFFF CALL 4518F0 (see terraform fix by Gowron)
451F86 FF4A 40 DEC [EDX+40]
451F89 E9 02010000 JMP 452090 // goto minor buildings & ships
451F8E 00 00
=> sub_451F90 (NewMinorPopGrowth)
451F90 53 PUSH EBX
451F91 51 PUSH ECX
451F92 55 PUSH EBP
451F93 83EC 04 SUB ESP, 4
451F96 0FBF145D 60235B00 MOVSX EDX, WORD [EBX*2+5B2360] //starID from RToSInfo
451F9E 69CA 28030000 IMUL ECX, EDX, 328
451FA4 A1 C8365A00 MOV EAX, [5A36C8] // systInfo
451FA9 03C8 ADD ECX, EAX // current systInfo entry
451FAB 8079 4C 05 CMP BYTE [ECX+4C], 5
451FAF 72 46 JB SHORT 451FF7 (exit if part of empire)
451FB1 8BC2 MOV EAX, EDX
451FB3 E8 B81AFFFF CALL 443A70 (GetSytemPopCap)
451FB8 8BF8 MOV EDI, EAX
451FBA 3B41 40 CMP EAX, [ECX+40]
451FBD 74 38 JE SHORT 451FF7 (exit if no pop space)
451FBF 8BC2 MOV EAX, EDX
451FC1 E8 7A15FFFF CALL 443540 (SytemGrowthPercentage to ST(0))
451FC6 DB41 40 FILD [ECX+40] // current pop
451FC9 DEC9 FMULP ST(1), ST // GrowthPercentage * pop
451FCB DC0D DC885700 FMUL QWORD [5788DC] // * 0.01
451FD1 E8 FEB60C00 CALL 51D6D4 (round float)
451FD6 DB1C24 FISTP [ESP]
451FD9 BA 59030000 MOV EDX, 359h // random seed
451FDE E8 0D600B00 CALL 507FF0 (RandomInteger)
451FE3 83E0 01 AND EAX, 1 // range 0-1
451FE6 83C0 01 ADD EAX, 1 // range 1-2 -> bonus pop/turn = 1
451FE9 030424 ADD EAX, [ESP] // + growth result
451FEC 0141 40 ADD [ECX+40], EAX // update system pop
451FEF 3979 40 CMP [ECX+40], EDI // check system limit
451FF2 7E 03 JLE SHORT 451FF7
451FF4 8979 40 MOV [ECX+40], EDI // prevent pop overflow
451FF7 83C4 04 ADD ESP, 4
451FFA 5D POP EBP
451FFB 59 POP ECX
451FFC 5B POP EBX
451FFD C3 RETN
451FFE-45208F 00 ( 146 bytes free )
global loop:
4528C3 74 24 JE SHORT 4528E9 // race alive, goto evolution
4528E7 75 DC JNZ SHORT 4528C5 // exit - race dead /not in game
4528E9 E8 A2F6FFFF CALL 451F90 (NewMinorPopGrowth)
4528EE-4528F1 90 NOP
New Minor Growth Calculation (close to the majors) - pop increase/turn:
current pop + [system growth rate]% + [static bonus (default 1 pop/turn)]
By the way of comparison, pop growth / turn:
=> Minors: (unmodded)
i.e. current pop + ( 10 + [growth rate])%Gowron wrote:[new IPN] = [old IPN] * ( 1 + 0.1 * [growth rate] )
=> Majors:
i.e. current pop + (pop * effective food /2) * [growth rate]%Gowron wrote:[population increase] = 0.5 * [growth rate] * ( [current population] + [effective food output] )
->Pop Growth, Terraforming Costs, Trade Goods, Pulsar Patterns
Last edited by Spocks-cuddly-tribble on Wed Oct 11, 2023 2:48 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.
- Spocks-cuddly-tribble
- Code Master
- Posts: 1961
- Joined: Sun Apr 27, 2008 2:00 am
Advancement Mechanism & Minor Race Building Behavior
Topic cleaned up, the split posts can be found here: Minor Race Advancement Project (old)
This post completes the information on minor races.
1. The Advancement Speed Mechanism
techInfo holds the relevant data for minor race evolution. 8 bytes per minor, 4 two byte entries:
( 1+ [current EL * 1/3] ) * base delay multiplier (rounded down)
The advancement-chance (by default negative) is increased by the [speed2] value every turn. Once it becomes 0 or greater, there is an advancement chance vs. following random value:
The EL related delay factor 1/3 is stored twice (8 byte float each) at asm-5794D0 (start of a game) and at asm-579538 (after evolution).
2. Minor Race Building Behavior
Note that:
Unlike when (pseudo-) upgrading, the major race source type of the main minor starting buildings is not determined by random, but by tech level (i.e. tech databases) and group IDs.
Number of initial main buildings: (given the tech requirements)
Number of Initial OBs: (info by Gowron)
For spacefaring minors sub_4517D0 (shared for advancement, cf. # 2.2) checks and/or adds the minor shipyard (building ID 0xF), a refinery (building ID 0x6), the dilithium flag for building requirements (not the dilithium recource level, so sometimes the dilithium icon is missing on the F1 map) and ships:
Number of ships: (1-4 ; given the tech requirements)
Base morale: (later overwritten?)
2.2 Buildings and Ships via Advancement
Main Buildings (pseudo-upgrades)
The major race source type of the minor main buildings changes for each evolution level and for each building group via a random generator. At asm-58FFAC is a table with the first resp. lowest IDs of minor main buildings and at asm-58FFD4 the corresponding last IDs: 2 byte building IDs * 4 groups (Industry, Food, Energy & Research) * 5 major race types * 2 first/last ID = 80 bytes, 40 building IDs in total
Number of Upgraded Main Buildings (current pop /15 + area bonus)
Number of Extra OBs (1-5 ; instead of main research buildings)
+1 OB (always)
Add Fed T1 Main Food Bug Fix (cf. Production Bonus Adding Wrong Main Building IDs Fix)
Ships, Shipyard & Refinery (for spacefaring minors)
Pop / Ships Limits for sub_4517D0 (cf. #2.1):
The code is broken due to mistakenly counting of task forces i.e. fleets instead of the actual number of ships. So the minors could build up to 11(max limit 12-1) * 9(max fleet size) + 4(max ships added by sub_4517D0) ships by default. For original BotF it's not that of an issue since ship building is coupled with evolution levels i.e. max ships = 10(levels) *4(sub_4517D0), but upcoming features require intact limits. Below an independent fix-code for reference:
Minor Race Ships Limit Fix
Bunker Network (pop limit 71+)
Shield Generator (pop limit 201+)
This post completes the information on minor races.
1. The Advancement Speed Mechanism
techInfo holds the relevant data for minor race evolution. 8 bytes per minor, 4 two byte entries:
- current evolution level (range 0-9 i.e. level 1 is code 0)
- advancement chance value (vs. random value)
- base delay multiplier (aka [speed1] from race.rst entry+0x58), default between -70 and -15
- bonus per turn (aka [speed2] from race.rst entry+0x5A), default 1-3
( 1+ [current EL * 1/3] ) * base delay multiplier (rounded down)
The advancement-chance (by default negative) is increased by the [speed2] value every turn. Once it becomes 0 or greater, there is an advancement chance vs. following random value:
Code: Select all
00452948 mov edi, 64h // random divisor 100
no advancement if random remainder (0-99) greater than chance value:
0045295C jg loc_4528C5 // exit_no_evolution
2. Minor Race Building Behavior
Note that:
- minors ignore tech & energy requirements of special buildings (e.g. tech 0, no energy but powered OBs)
- % ground defense building bonuses don't work for minors and orbital batteries use wrong tech levels (both bug-fixes)
Unlike when (pseudo-) upgrading, the major race source type of the main minor starting buildings is not determined by random, but by tech level (i.e. tech databases) and group IDs.
Minor race main building groups are: (virtual group IDs - not in edifice.bst)DCER wrote:edifice.bst offset 0x74 = group
Groups are:
- main food (bonus id 0): group ids 0-4 (cards - roms)
- main industry (bonus id D): 6-A
- main energy (bonus id 2): C-10
- main intel (bonus id A): 12-16h
- main research (bonus id 7): 18-1C
- scanners (bonus id 29h): 1E
- others: 22h
- 0x05 - Food
- 0x0B - Industry
- 0x11 - Energy
- 0x17 - Intel
- 0x1D - Research
Code: Select all
00450AC6 mov eax, 5 // main Food
00450B14 mov eax, 0Bh // main Industry
00450B3D mov eax, 11h // main Energy
Code: Select all
- Food -> number of pop units, min 4:
004515A5 cmp eax, 4
004515AE mov dword ptr [esp+140h], 4
- Industry -> 1-3
004515D8 mov ecx, 3 // random divisor
004515E2 lea esi, [edx+1] // remainder (0-2) +1 = 1-3
- Energy -> 2-3
004515F6 mov ecx, 2 // random divisor
00451607 lea ebx, [edx+ecx] // remainder (0-1) +2 = 2-3
Code: Select all
004516E5 mov ecx, 32h // pop divisor 50 for initial OBs
Number of ships: (1-4 ; given the tech requirements)
Code: Select all
004517FC mov ecx, 3 // random divisor
00451806 test edx, edx // if remainder not 0 (i.e. chance 2:3)
00451808 jnz loc_45189C // add 1 ship
Else (new random value)
0045181F mov ecx, 4 // random divisor
00451829 lea esi, [edx+1] // add remainder +1 ships (i.e. 0-3 +1)
Code: Select all
0045152B mov word ptr [esi+2F0h], 6Eh // = 110
2.2 Buildings and Ships via Advancement
Main Buildings (pseudo-upgrades)
The major race source type of the minor main buildings changes for each evolution level and for each building group via a random generator. At asm-58FFAC is a table with the first resp. lowest IDs of minor main buildings and at asm-58FFD4 the corresponding last IDs: 2 byte building IDs * 4 groups (Industry, Food, Energy & Research) * 5 major race types * 2 first/last ID = 80 bytes, 40 building IDs in total
Number of Upgraded Main Buildings (current pop /15 + area bonus)
Code: Select all
00452504 mov ecx, 0Fh // shared pop divisor 15
Type bonuses:
- Food +1-3
004521E1 mov ecx, 3 // random divisor
004521EB lea ecx, [edx+1] // remainder +1
- Industry +1-3
0045229E mov ecx, 3 // random divisor
004522A8 lea ecx, [edx+1] // remainder +1
- Energy +1-2
00452220 mov ecx, 2 // random divisor
0045222A lea ecx, [edx+1] // remainder +1
- Research +1 (if not extra OBs)
0045225D mov ecx, 2 // random divisor
00452267 test edx, edx // 50% reseach buildings or extra OBs
00452269 jz short loc_4522BF add_1-5 OBs
0045226B mov ecx, 1 // +1 research building
Code: Select all
004522D0 mov ecx, 5 // random divisor
004522DA lea ebx, [edx+1] // remainder +1
004522E7 mov edx, 5 // OB bld ID
Code: Select all
0045215D mov edx, 5 // OB bld ID
0045216C call sub_445DF0 // add_building_ID_edx
Code: Select all
Fix: at 0x51573 change 0F 85 -> 90 E9
00452173 jnz 452306 // jnz -> nop, jmp 452306
Bug code:
00452179 mov ebx, 2 // minimum 2 food buildings
0045217E mov esi, 90h // fed T1 main food bld ID
00452183 mov ebp, 0Fh // pop divisor 15
00452198 cmp eax, 2 // minimum 2 food buildings
Pop / Ships Limits for sub_4517D0 (cf. #2.1):
Code: Select all
00452360 cmp ecx, 78h // if pop greater 120
00452369 cmp eax, 0Ch // skip if 12+ ships
0045240C cmp ecx, 5Ah // if pop greater 90
00452411 cmp eax, 6 // skip if 6+ ships
00452419 cmp ecx, 3Ch // if pop greater 60
00452422 cmp eax, 4 // skip if 4+ ships
if pop 60 or lower skip always
Minor Race Ships Limit Fix
Code: Select all
trek.exe at 0x51729 new code 0x34 bytes:
33 F6 C1 E2 06 8B AA 2C 20 5A 00 8B 6D 00 85 ED 74 0F 8B 45 08 33 D2 E8 DB 74 FF FF 03 70 04 EB EA 8B 94 24 B0 01 00 00 8B C6 90 90 90 90 90 90 90 90 90 90
asm code:
00452329 33F6 XOR ESI, ESI // prepare ship count
0045232B C1E2 06 SHL EDX, 6 // race ID for address of...
0045232E 8BAA 2C205A00 MOV EBP, [EDX+5A202C] // alienTFInfo
00452334 8B6D 00 MOV EBP, [EBP] // load next entry
00452337 85ED TEST EBP, EBP
00452339 74 0F JE SHORT 45234A // exit if not given
0045233B 8B45 08 MOV EAX, [EBP+8] // taskforce ID
0045233E 33D2 XOR EDX, EDX
00452340 E8 DB74FFFF CALL 449820 // load taskforce entry
00452345 0370 04 ADD ESI, [EAX+4] // ships in taskforce
00452348 ^EB EA JMP SHORT 452334 // loop next entry
0045234A 8B9424 B0010000 MOV EDX, [ESP+1B0]// systInfo entry
00452351 8BC6 MOV EAX, ESI // number of ships
00452353-45235C 90 NOP
004523DC-0045240B -> unused
Code: Select all
00452387 cmp dword ptr [eax+40h], 46h // if pop greater 70
add bunker blg ID:
00452390 mov edx, 2
004523A0 mov edx, 2
004523AC mov edx, 2
Code: Select all
004523C6 cmp dword ptr [eax+40h], 0C8h // if pop greater 200
add SH blg ID:
0045242D mov edx, 14h
0045243D mov edx, 14h
I don't know how many bugs is too many but that point is reached somewhere before however many in BotF is.
- Spocks-cuddly-tribble
- Code Master
- Posts: 1961
- Joined: Sun Apr 27, 2008 2:00 am
Primitive Farms Not Upgradeable Bug Fix
The group ID in edifice.bst+0x74 (cf. #2.1 Initial Buildings above) must be changed to 05 for all five primitive farms (make sure the Ultimate Editor doesn't revert the fix).
In combination with the two fixes for the add wrong main food bug, this issue should be never seen again:
- Add Fed T1 Main Food Bug Fix (see above #2.2 Buildings and Ships via Advancement)
- Production Bonus Adding Wrong Main Building IDs Fix
In combination with the two fixes for the add wrong main food bug, this issue should be never seen again:
- Add Fed T1 Main Food Bug Fix (see above #2.2 Buildings and Ships via Advancement)
- Production Bonus Adding Wrong Main Building IDs Fix
I don't know how many bugs is too many but that point is reached somewhere before however many in BotF is.
- Spocks-cuddly-tribble
- Code Master
- Posts: 1961
- Joined: Sun Apr 27, 2008 2:00 am
Minors without Main Buildings Bug Fix
Good news, this vexatious affair is now a relict of the past.
In fact, it's a system takeover bug, more precisely the check for present 'one per empire' buildings mistakenly tries to read from the empsInfo entry of the old system owner i.e. for minor races always ID 0x23.
Keep in mind that no main buildings are still possible due to losses by bombing, scrapping by ex-owners or missing tech requirements of minor races on tech 0 (side note: maybe tech area 7 in racetech.tec is the all tech requirement and not sociology).
Options: (to apply after the main fix)
In fact, it's a system takeover bug, more precisely the check for present 'one per empire' buildings mistakenly tries to read from the empsInfo entry of the old system owner i.e. for minor races always ID 0x23.
Keep in mind that no main buildings are still possible due to losses by bombing, scrapping by ex-owners or missing tech requirements of minor races on tech 0 (side note: maybe tech area 7 in racetech.tec is the all tech requirement and not sociology).
Code: Select all
trek.exe at 0x407C3 fixed system takeover code 0x99 bytes:
D3 E0 84 44 24 67 75 37 EB 0D 31 C0 81 C4 B0 00 00 00 5F 5E 59 5B C3 31 D2 31 C0 66 8B 56 02 80 7C 24 73 02 75 0D 8A C1 E8 90 A6 FF FF 85 C0 74 D9 EB 1B 83 FA 06 75 D2 F6 47 71 08 75 CC 90 8A 64 24 72 84 E4 75 28 80 7C 24 72 0A 75 BC 0F BF 07 31 D2 31 DB 66 8B 54 24 50 66 8B 1E E8 1B 44 00 00 31 C0 81 C4 B0 00 00 00 5F 5E 59 5B C3 80 FC 02 74 D3 80 FC 07 74 CE 80 FC 0D 74 C9 80 FC 0A 74 C4 EB C9 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
-code changes:
004413C3 D3E0 SHL EAX, CL // new owner ID
004413C5 844424 67 TEST [ESP+67], AL // excluded empires mask
004413C9 75 37 JNZ 441402 // excluded -> remove foreign special & main intel
004413CB EB 0D JMP 4413DA // remove present one per empire & AI bonus refineries
004413E2 807C24 73 02 CMP BYTE [ESP+73], 2 // if not 'one per empire'
004413E7 75 0D JNZ 4413F6 // goto check AI bonus refinery
004413E9 8AC1 MOV AL, CL // new owner ID
004413EB E8 90A6FFFF CALL 43BA80 // check present one per empire buildings
004413F0 85C0 TEST EAX, EAX // if not present
004413F2 ^74 D9 JE 4413CD // keep building
004413F4 EB 1B JMP 441411 // else remove building
004413F6 83FA 06 CMP EDX, 6 // if not a refinery
004413F9 ^75 D2 JNZ 4413CD // keep building
004413FB F647 71 08 TEST BYTE [EDI+71], 8 // if dilithium present
004413FF ^75 CC JNZ 4413CD // keep refinery
00441401 90 NOP
00441446 ^EB C9 JMP 441411 // remove building
00441448-44145B 00
- keep foreign main intel of acceded minors = membership only (recommended)
Code: Select all
trek.exe at 0x40844 new code 0x18 bytes:
75 CB 80 7F 30 02 75 C5 80 7F 4C 23 75 BF EB D1 00 00 00 00 00 00 00 00
-asm-
00441444 ^75 CB JNZ 441411 // remove foreign special
00441446 807F 30 02 CMP BYTE [EDI+30], 2
0044144A ^75 C5 JNZ 441411 // remove foreign main intel
0044144C 807F 4C 23 CMP BYTE [EDI+4C], 23
00441450 ^75 BF JNZ 441411 // remove foreign main intel
00441452 ^EB D1 JMP 441425 // keep foreign main intel
00441454-44145B 00
- keep all foreign main intel buildings: 0x4080F -> EB
- keep all excluded foreign buildings: 0x407C9 -> 90 90 (not recommended)
Some notes:
The code is performed every time when already inhabited systems become part of an empire, thus shared for conquered major systems.
By default minors don't build main intel or their special structure, consequently the corresponding code affects only minors that were part of an empire.
Adding main intel to minors results in a 20% chance for existing main intel (1:5 random for the not excluded own empire type) whilst the removed foreign intel types are still buildable. Considering its shared effect on conquered major systems 'keep all foreign main intel' is not necessarily a recommendation.
Needless to say the 'keep all excluded' option is poison for game balance. It's just added for reference since a few players want the foreign special buildings on conquered enemy home systems.
Above OPTIONS already support every function discussed in this topic: Allow Intel Buildings to remain after conquest
Local minor system morale bonus for membership (turn of joining):
Limit of minor fleets to transfer when acquiring a minor race:Code: Select all
0045DF7A add eax, 0Fh // current morale +15
Code: Select all
0045DF94 cmp eax, 6 // if more than 6 task forces (fleets) 0045DFAD sar eax, 1 // remove [number of fleets]/2^1 fleets
Last edited by Spocks-cuddly-tribble on Sat Jan 14, 2023 5:54 am, edited 5 times in total.
I don't know how many bugs is too many but that point is reached somewhere before however many in BotF is.
- thunderchero
- Site Administrator aka Fleet Admiral
- Posts: 7963
- Joined: Fri Apr 25, 2008 2:00 am
- Location: On a three month training mission, in command of the USS Valiant.
Re: Minor Race Advancement
very nice, Great job as normal.
Could I ask for a list of what fixes would work the best together. Or are all needed from this post.
thunderchero
Could I ask for a list of what fixes would work the best together. Or are all needed from this post.
thunderchero
- Flocke
- BORG Trouble Maker
- Posts: 3258
- Joined: Sun Apr 27, 2008 2:00 am
- Location: Hamburg, Germany
- Contact:
Re: Minors without Main Buildings Bug Fix
Wonderful!Spocks-cuddly-tribble wrote:Good news, this vexatious affair is now a relict of the past.
Great work you do all the time!
Re: Minor Race Advancement
Indeed... another piece of the 10 million piece puzzle solved Great work and thanks!
"The only thing we have to fear is fear itself." -- FDR
- Spocks-cuddly-tribble
- Code Master
- Posts: 1961
- Joined: Sun Apr 27, 2008 2:00 am
Re: Minor Race Advancement
I'd suggest main fix + keep minor special building option (post edited with hints to the options).thunderchero wrote:Could I ask for a list of what fixes would work the best together.
If there is a demand for, we could also try a code for tech 0 industry, energy, intel & research buildings for minors in order to prevent no buildings due to missing tech requirements on low evolution levels (i.e. turn one of the the primitive farms each into another main tech 0). No idea how much work adapting the res-files e.g. tech databases would be.
I don't know how many bugs is too many but that point is reached somewhere before however many in BotF is.
- Spocks-cuddly-tribble
- Code Master
- Posts: 1961
- Joined: Sun Apr 27, 2008 2:00 am
Re: Minor Race Advancement
Let's keep the ball rolling.
Here is an optimised code for minor initial buildings (random selection of source types card-rom, some extra buildings for higher starting levels and support of main intel & research).
Number of initial buildings is loaded from default code (# 2.1 Number of initial main buildings) but with some bonuses added:
main food (default; unchanged)
main industry (1-3) + minor start EL predictor
main energy (2-3) + pop/128
main intel = 1 + pop units/8
main research = 1 + EL predictor/2
NOTE: Upgrade code doesn't add new buildings anymore (# 2.2 Number of Upgraded Main Buildings -> obsolete), exception: 1 building gets added if number of buildings is zero. Also main intel won't upgrade. A simple script for a turn based minor building behavior has to be written yet. Expect 3-4 weeks at least.
Upgrades and initial buildings are based on the vanilla default number of upgrade levels i.e. tech 1-9 (+food 0). An example how to adapt this: (here asm 450B11-450B1A)
viewtopic.php?p=33179&sid=6a77dec9c85b7 ... dee#p33179
Here is an optimised code for minor initial buildings (random selection of source types card-rom, some extra buildings for higher starting levels and support of main intel & research).
Number of initial buildings is loaded from default code (# 2.1 Number of initial main buildings) but with some bonuses added:
main food (default; unchanged)
main industry (1-3) + minor start EL predictor
main energy (2-3) + pop/128
main intel = 1 + pop units/8
main research = 1 + EL predictor/2
NOTE: Upgrade code doesn't add new buildings anymore (# 2.2 Number of Upgraded Main Buildings -> obsolete), exception: 1 building gets added if number of buildings is zero. Also main intel won't upgrade. A simple script for a turn based minor building behavior has to be written yet. Expect 3-4 weeks at least.
Code: Select all
1.) trek.exe at 0x4FE8F new code 0xE5 bytes:
89 84 24 64 01 00 00 89 94 24 60 01 00 00 8D B4 24 B0 00 00 00 50 8B C2 E8 A4 E2 05 00 58 83 FA 05 0F 82 BE 00 00 00 E8 05 00 00 00 E9 46 0A 00 00 53 51 56 57 55 81 EC B4 00 00 00 C7 04 24 20 4E 44 00 BE 05 00 00 00 8B FA 8B E8 BA 88 00 00 00 E8 0B 75 0B 00 8B D0 C1 FA 1F F7 FE 8A C2 8D 54 24 04 FF 14 24 0F B6 54 24 69 8B C7 E8 7F 2B 00 00 0F B6 54 24 76 85 C0 75 07 85 D2 75 1B 48 EB 0A 48 90 90 90 3C 08 7E 02 B0 08 0F B7 5C 24 54 03 D8 8B C5 E8 37 19 00 00 80 7C 24 01 51 74 09 81 04 24 C0 00 00 00 EB A2 81 C4 B4 00 00 00 5D 5F 5E 59 5B C3 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90
2.) at 0x509E3 change 72 to -> 7A
3.) at 0x50A0A new code 0x7E bytes:
89 04 24 8B 4E 40 C1 E9 07 03 D9 89 5C 24 04 8A 15 2B 2B 5A 00 03 FA 89 7C 24 08 C1 E8 03 40 89 44 24 0C D1 EA 42 89 54 24 10 90 90 90 90 90 90 90 90 8B 2E 33 FF 8B 9C 7E F8 02 00 00 F6 C7 40 75 14 8B 0C BC 83 E9 01 7E 0C 8B C5 8B D3 E8 93 47 FF FF 49 75 F4 47 83 FF 05 7C DA 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90
4.) at 0x518E9 new code 0x33 bytes:
0F B7 3B C1 F8 10 33 F6 66 8B 73 02 8B DF 8B D6 E8 42 33 FF FF EB 09 85 C9 75 B4 BF 01 00 00 00 31 DB 5E 90 90 90 90 90 90 90 90 90 90 90 90 90 90 3B DF
-asm changes-
-> sub_450A84:
00450A8F 898424 64010000 MOV [ESP+164], EAX // system ID
00450A96 899424 60010000 MOV [ESP+160], EDX // race ID
00450A9D 8DB424 B0000000 LEA ESI, [ESP+B0] // address for race.rst
00450AA4 50 PUSH EAX
00450AA5 8BC2 MOV EAX, EDX // race ID
00450AA7 E8 A4E20500 CALL 4AED50 // load race.rst
00450AAC 58 POP EAX
00450AAD 83FA 05 CMP EDX, 5
00450AB0 0F82 BE000000 JB 450B74 goto empire
00450AB6 E8 05000000 CALL 450AC0 // update minor main building IDs
00450ABB E9 460A0000 JMP 451506 goto minor
-> new sub_450AC0 (update minor main building IDs)
00450AC0 53 PUSH EBX
00450AC1 51 PUSH ECX
00450AC2 56 PUSH ESI
00450AC3 57 PUSH EDI
00450AC4 55 PUSH EBP
00450AC5 81EC B4000000 SUB ESP,0B4
00450ACB C70424 204E4400 MOV DWORD [ESP], 00444E20 // base offset main T1
00450AD2 BE 05000000 MOV ESI, 5 // random divisor
00450AD7 8BFA MOV EDI, EDX // race ID
00450AD9 8BE8 MOV EBP, EAX // system ID
00450ADB BA 88000000 MOV EDX, 88
00450AE0 E8 0B750B00 CALL 507FF0 // random integer
00450AE5 8BD0 MOV EDX, EAX
00450AE7 C1FA 1F SAR EDX, 1F
00450AEA F7FE IDIV ESI
00450AEC 8AC2 MOV AL, DL // random race 0-4
00450AEE 8D5424 04 LEA EDX, [ESP+4] // address for edifice.bst T1 entry
00450AF2 FF1424 CALL [ESP] // load main T1 entry
00450AF5 0FB65424 69 MOVZX EDX, BYTE [ESP+69] // Tech req. type
00450AFA 8BC7 MOV EAX, EDI // race ID
00450AFC E8 7F2B0000 CALL 453680 // get race tech level
00450B01 0FB65424 76 MOVZX EDX, BYTE [ESP+76] // bonus output type
00450B06 85C0 TEST EAX, EAX
00450B08 75 07 JNZ 450B11
00450B0A 85D2 TEST EDX, EDX
00450B0C 75 1B JNZ 450B29 // not given goto next area
00450B0E 48 DEC EAX
00450B0F EB 0A JMP 450B1B // add food T0 (primitive farm)
00450B11 48 DEC EAX
00450B12 909090 NOP
00450B15 3C 08 CMP AL, 8
00450B17 7E 02 JLE 450B1B
00450B19 B0 08 MOV AL, 8
00450B1B 0FB75C24 54 MOVZX EBX, WORD [ESP+54] // building ID
00450B20 03D8 ADD EBX, EAX // ID +/- tech factor
00450B22 8BC5 MOV EAX, EBP // system ID
00450B24 E8 37190000 CALL 452460 // update main buildings add 1 if not given
00450B29 807C24 01 51 CMP BYTE [ESP+1], 51
00450B2E 74 09 JE 450B39
00450B30 810424 C0000000 ADD DWORD [ESP], 0C0 // offset for next main group
00450B37 ^EB A2 JMP 450ADB // next area random race
00450B39 81C4 B4000000 ADD ESP, 0B4
00450B3F 5D POP EBP
00450B40 5F POP EDI
00450B41 5E POP ESI
00450B42 59 POP ECX
00450B43 5B POP EBX
00450B44 C3 RETN
00450B45-450B73 90 NOP
004515E2 8D7A 01 LEA EDI, [EDX+1] // industry random 1-3 (keep esi systInfo)
0045160A 890424 MOV [ESP], EAX // main food = pop units
0045160D 8B4E 40 MOV ECX, [ESI+40] // start pop
00451610 C1E9 07 SHR ECX, 7
00451613 03D9 ADD EBX, ECX
00451615 895C24 04 MOV [ESP+4], EBX // main energy = 2-3 + pop/128
00451619 8A15 2B2B5A00 MOV DL, [5A2B2B] // minor start EL predictor
0045161F 03FA ADD EDI, EDX
00451621 897C24 08 MOV [ESP+8], EDI // main industry = 1-3 + EL predictor
00451625 C1E8 03 SHR EAX, 3
00451628 40 INC EAX
00451629 894424 0C MOV [ESP+C], EAX // main intel = 1 + pop units/8
0045162D D1EA SHR EDX, 1
0045162F 42 INC EDX
00451630 895424 10 MOV [ESP+10], EDX // main research = 1 + EL predictor/2
00451634-45163B 90 NOP
0045163C 8B2E MOV EBP, [ESI] // system ID
0045163E 33FF XOR EDI, EDI
00451640 8B9C7E F8020000 MOV EBX, [ESI+EDI*2+2F8] // systInfo main building IDs
00451647 F6C7 40 TEST BH, 40 // if not given
0045164A 75 14 JNZ 451660 goto next area
0045164C 8B0CBC MOV ECX, [ESP+EDI*4] // number to add
0045164F 83E9 01 SUB ECX, 1
00451652 7E 0C JLE 451660 no more to add goto next area
00451654 8BC5 MOV EAX, EBP // system ID
00451656 8BD3 MOV EDX, EBX // building ID
0045165D 49 DEC ECX
0045165E ^75 F4 JNZ 451654 // loop add next building
00451660 47 INC EDI // area count
00451661 83FF 05 CMP EDI, 5
00451664 ^7C DA JL 451640 goto next area
00451666-451687 90 NOP
-> sub_452460:
004524E9 0FB73B MOVZX EDI, WORD [EBX] // number of buildings
004524EC C1F8 10 SAR EAX, 10 // system ID
004524EF 33F6 XOR ESI, ESI
004524F1 66:8B73 02 MOV SI, WORD [EBX+2] // building ID
004524F5 8BDF MOV EBX, EDI // number of buildings
004524F7 8BD6 MOV EDX, ESI // building ID
004524F9 E8 4233FFFF CALL 445840 // remove building(s)
004524FE EB 09 JMP SHORT 452509 goto add new number of removed
00452504 BF 01000000 MOV EDI, 1 // add 1 if no old
0045250C-452519 90 NOP
0045251A 3BDF CMP EBX, EDI
viewtopic.php?p=33179&sid=6a77dec9c85b7 ... dee#p33179
I don't know how many bugs is too many but that point is reached somewhere before however many in BotF is.