Minor Race Advancement

Minor Race Advancement; support/discussion/questions

Moderator: thunderchero

User avatar
jonesie85two
Lieutenant-Commander
Lieutenant-Commander
Posts: 201
Joined: Sat Apr 26, 2008 2:00 am

Re: Minor Race Advancement

Post by jonesie85two » Tue Jan 01, 2013 3:31 pm

Im curious, could this be modified to allow for more factories?
Spocks-cuddly-tribble wrote: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.

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

User avatar
Smoothie
Cadet 3rd Year
Cadet 3rd Year
Posts: 11
Joined: Sun Aug 08, 2010 2:00 am

Re: Minor Race Advancement

Post by Smoothie » Tue Oct 29, 2013 10:28 am

thunderchero wrote: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

Can you tell me where in the Ultimate Editor I can edit the above? Or which file to load? Im assuming stbof.res, but I haven't found where to change the evolution levels as well as growth rate.

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

Re: Minor Race Advancement

Post by thunderchero » Tue Oct 29, 2013 10:36 am

Smoothie wrote:Can you tell me where in the Ultimate Editor I can edit the above? Or which file to load? Im assuming stbof.res, but I haven't found where to change the evolution levels as well as growth rate.
to edit those value you must hex edit the race.rst in the stbof.res

thunderchero

User avatar
Smoothie
Cadet 3rd Year
Cadet 3rd Year
Posts: 11
Joined: Sun Aug 08, 2010 2:00 am

Re: Minor Race Advancement

Post by Smoothie » Tue Oct 29, 2013 2:38 pm

Thank you, so Ultimate Editor cannot edit these? Its no problem, I know how to hex edit.. Use to do it all the time back in the day with BOTF. Its just UE would be easier :)

User avatar
Smoothie
Cadet 3rd Year
Cadet 3rd Year
Posts: 11
Joined: Sun Aug 08, 2010 2:00 am

Re: Minor Race Advancement

Post by Smoothie » Thu Nov 07, 2013 12:16 pm

Quick question, if I want all minor races to move up like the Vulcans (I believe the Vulcans evolve the fastest), can I just copy the Vulcan hex code in the race.rst for all other minors? If so which hex codes?

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

Re: Minor Race Advancement

Post by thunderchero » Thu Nov 07, 2013 7:25 pm

Smoothie wrote:Quick question, if I want all minor races to move up like the Vulcans (I believe the Vulcans evolve the fastest), can I just copy the Vulcan hex code in the race.rst for all other minors? If so which hex codes?
depends on what other changes you have made if none then you should change your hex editor to display 108 wide instead of 16 for easier viewing. remove the first 2 bytes (this will have to be added back before saving file) from file to line races up.

then use this location for each race. (to change to same as Vulcans)

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

this can be changed in UE (or hex edit while you have it open)

[growth rate]
relative offset (in relation to the start of the minor race's entry): 0x44
type: floating-point
length: 4 bytes

next you would need to use UE to edit/starting conditions/starting technology

you would need to edit every minor race for all 10 tech levels for each minor race. (this will take a long time to do) might be quicker if you can copy and paste with hex editor but never tried myself.

good luck

thunderchero

User avatar
Smoothie
Cadet 3rd Year
Cadet 3rd Year
Posts: 11
Joined: Sun Aug 08, 2010 2:00 am

Re: Minor Race Advancement

Post by Smoothie » Mon Nov 11, 2013 2:19 pm

Thank you, but im having a hard time finding 0x58. Search function doesn't really work.

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

Re: Minor Race Advancement

Post by thunderchero » Mon Nov 11, 2013 3:00 pm

Smoothie wrote:Thank you, but im having a hard time finding 0x58. Search function doesn't really work.
I understand,

0x58 is the 88th byte (0x58 in hex) of each 108 bytes (0x6b in hex) section (race) there are 35 sections (5 majors and 30 minors) of 108 bytes long.

maybe image will help? (this is after I removed first 2 bytes)

Image

thunderchero

User avatar
Smoothie
Cadet 3rd Year
Cadet 3rd Year
Posts: 11
Joined: Sun Aug 08, 2010 2:00 am

Re: Minor Race Advancement

Post by Smoothie » Wed Nov 13, 2013 12:12 pm

Thank you friend, I will replace those with the Vulcans value and see how each race progresses and will cross my fingers botf won't crash :)

User avatar
Kurn
Lieutenant-Junior Grade
Lieutenant-Junior Grade
Posts: 64
Joined: Thu Aug 12, 2010 2:00 am
Location: Germany

Re: Advancement Mechanism & Minor Race Building Behavior

Post by Kurn » Mon Jul 16, 2018 4:09 pm

Spocks-cuddly-tribble wrote:
Mon Dec 19, 2011 2:27 pm
Number of Extra OBs (1-5 ; instead of main research buildings)

Code: Select all

004522D0                 mov     ecx, 5  // random divisor
004522DA                 lea     ebx, [edx+1]  // remainder +1
004522E7                 mov     edx, 5  // OB bld ID
Is it possible to edit the random divisor so the number of extra OBs is always 1?

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

Re: Advancement Mechanism & Minor Race Building Behavior

Post by Spocks-cuddly-tribble » Mon Jul 16, 2018 4:56 pm

Kurn wrote:
Mon Jul 16, 2018 4:09 pm
Is it possible to edit the random divisor so the number of extra OBs is always 1?
viewtopic.php?f=214&p=40658#p40658

-> Coding Guides -> Assembler Offsets -> hex location of asm statement to change divisor 05 to 01

@ your other question about cloak checks
-> Coding Guides -> Hex Editing For Beginners -> Value Range of signed byte


I'm not a programmer and out of practice with that stuff by myself. :wink:
I don't know how many bugs is too many but that point is reached somewhere before however many in BotF is.

User avatar
Kurn
Lieutenant-Junior Grade
Lieutenant-Junior Grade
Posts: 64
Joined: Thu Aug 12, 2010 2:00 am
Location: Germany

Re: Minor Race Advancement

Post by Kurn » Tue Jul 17, 2018 6:09 pm

Thanks for the link SCT. I'll try that.

Post Reply

Return to “Minor Race Advancement”

Who is online

Users browsing this forum: No registered users