A Nuts and Bolts Guide

A Nuts and Bolts Guide; support/discussion/questions

Moderator: thunderchero

Post Reply
User avatar
Peter1981
Rear-Admiral
Rear-Admiral
Posts: 1118
Joined: Tue May 06, 2008 2:00 am
Location: England

A Nuts and Bolts Guide

Post by Peter1981 »

Hi Spike (Spychoic),

Here is a complete nuts and bolts guide to modding Star Trek The Next Generation: Birth of the Federation (BotF):

1. THE TOOLS OF THE TRADE:

There are two vital programs for editing BotF:

1. Ultimate Editor (UE)
2. Hex Editor

1.1 THE ULTIMATE EDITOR (UE)

The latest version of UE is avaliable here:-

https://www.armadafleetcommand.com/get- ... file_id=71

Infomation on installing and running UE is here

ultimate-editor-basics

1.2 THE HEX EDITOR

The hex (short for hexadecimal) editor I use, recommended to me by Gowron, is Hex Editor Nero and it is free and from hhdsoftware.com here:-

http://www.hhdsoftware.com/Download/fre ... or-neo.exe

2. WHAT IS IT ALL ABOUT?

2.1 WHY IS BOTF HARD TO MOD?

Unlike most games where many moddifications require a drag and drop approach or highly use-friendly interfaces allow customisation of the game (Civilisation 4 comes to mind) BotF was never designed to be altered by the user when it was released in 1999 customisation and modding wern't seen as importand or disirable by the games developers.

Modding BotF is a much more root and branches affair, the coding has to be done in the simplist language a computer understands - Machine Code. (If you learnt computer programming in the late 1970's early 1980's then you may have come across this before!) I am not going to go into depth about this subject however every time you see on this forum a block of number to be edited into Trek.exe this is in effect what you being asked to do. The danger of this kind of editing is mis-typing since each number represents in hexadecimal either a operation or a number and it is the operation that determine how a hexadecimal number is read by the computer processor.

2.2 WHAT IS HEXADECIMAL?

Hexadecimal is a number system with digits 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E and, F where A to F represent the decimal numbers 10 to 15

eg. 1F is 1*16 + F(15) = 31 decimal, F6 is F(15)*16 + 6 = 246 decimal

there is a reason for using a unusual number system since computer processors undersand binary i.e. only 0's and 1's; and strings of binary are hard to understand 01010100 = 84 decimal (54 hex). Where as with one hex digit we represent 4 bits and with a double digit hex number we represent 8 bits.

2.3 WHAT CAN I DO WITH UE?

As the name suggests UE is the Ultimate Editor it was created by DCER and brought together a number of editors and has been added to and expanded
and now can edit many aspects of the game these include:

2.3.1 UE & TREK.EXE

2.3.1.1 AI

AI Ship building Stats

2.3.1.2 GAME

Galaxy Generation
Ship Building and Upgrading
Ship Map Ranges
Starting Conditions

2.3.1.3 OTEHR

CD Protection
Check integrity

2.3.2 UE & STBOF.RES

2.3.2.1 AI

AI Buliding Requirements
Colony Value
Major Empire Tolerance
Minor Race Attributes

2.3.2.2 BUILDINGS

Building Stats
Buildings Overview
Group Edit of Building Stats

2.3.2.3 GALAXY

Environments
Maximum Planet Populations
Planet Bonuses
Planets
Star Names
Stellar Objects

2.3.2.4 GRAPHICS

Add/Remove Ship Models
Animations
HOB Files
Textures

2.3.2.5 OTHER

Check Integrity
Files
List of Modified Files

2.3.2.6 RACES

Morale Penalties
Race Info

2.3.2.7 SHIPS

Group Edit of Ship Stats
Ship Names
Ship Stats
Ships Overview

2.3.2.8 STARTING CONDITIONS

Major Empire Home Systems
Starting Buildings
Starting Technology

2.3.2.9 TECHNOLOGY

Technology Fields

2.3.2.10 TEXT

In-Game Text
Lexicon

2.3.3 UE & .SAV

2.3.3.1 GALAXY

Galactic Map
Galactic Map v2 (early preview)
Stellar Objects

2.3.3.2 GAME

Empire Info
Game Info

2.3.3.3 OTHER

Check Integrity
Files

2.3.3.4 SHIPS

Starbases

2.3.3.5 SYSTEMS

List of Built Structures
System Info

2.3.4 UE & .SND

2.3.4.1 OTHER

Check Integrity
List of Modified Files

2.3.4.2 Sounds

Switch Race Voices
Voices
Game Sounds

2.3.5 UE TOOLS

Convert image to 16bit tga
Create animation/cursor
Supervise a multiplayer game
Calculator
Convert Adresss

2.4 WHY DO I NEED A HEX EDITOR?

While UE is increadably brilliant and for most people will do what they want many of the more subtle bug fixes and moddifications aren't avaliable through UE (although the ability to build minor ships in membered minors is an exception to this!)

Hex editing is used for two types of modification.

1. Changing programming.
2. Changing values

2.4.1 CHANGING PROGRAMMING

This is the most complicated and frustrating (IMHO) type of modding and ultimately really requires disasembly understanding, However this more of the Codemasters domain so I won't go into it myself here. But for an excellent example of this type of modding is found here:

viewtopic.php?name=Forums&file=viewtopi ... ght=#17544

2.4.2 CHANGING VALUES

The two examples are both obsolete as UE now does this for you however it is a good example of how just changing values can open up some new possibilities:-

viewtopic.php?name=Forums&file=viewtopic&t=1531
viewtopic.php?name=Forums&file=viewtopic&t=1599

2.4.3 CHANGING BOTH VALUES AND PROGRAMMING

In truth most major improvements to BotF will require a combination of the above. Therefore, getting to a point where you feel comfortable to make these changes will pay dividends.

3 Making SCT change:

SCT Wrote:
Well, I felt it was time to finish this task, thus...

The AI Map Scan Matrix Reloaded

Code:

Code: Select all

41D04F       mov     ecx, 19h // max distance in sectors to check ? 
This has to be equal to the large map horizontal edge (i.e. the largest edge of the exe).

Therewith, hopefully, AI should expand and behave as usual on enlarged maps.

Close to this, there is also a float with the same value, but I don't think it correlates with map size, but is rather a ratio value (i.e. don't change this for now):

Code:

Code: Select all

41D05A         push    40390000h  (first part of 8 byte float 25.0) 
SCT has used an ASM address these usuall start with either a 4 or 5 and are always a hexadecimal address refering to trek.exe. To convert this open UE and goto TOOLS -> OTHER -> CONVERT ADDRESS copy & paste or write this number into the box labeled 'Botf Assembler offset' and click the 'convert' button next to it, the other boxes should now have numbers in them:

so 41D04F -> 0x1c44f -> 115791

Now open trek.exe in your hex editor:

if your using Nero then Ctrl-G will bring up the goto offset dialogue box -- copy and paste the hexadecimal address from UE into the goto offset box

you should have highlighted the first byte of the following:

B9 19 00 00 00

(B9 will probably be on the end of the line)

B9 is the operation mov ecx, followed by the 4byte hexadecimal value 19 00 00 00 this number is read in in a format called little endian so the right most pair of hexadecimal digits are the 'sixteens&units' and the left most is '2^17ths&2^16ths' so 19 00 00 00 is read as 00000019 or just 19 = 16+9 = 25

to increase this take the horizontal map value found in UE load trek.exe EDIT -> GAME -> GALAXY GENERATION find under 'Map size', the value in the 3x2-table at 'Large' & 'Width' vanilla is 25 UMD is 39 IIRC

eg using 39 in UE select TOOLS -> OTHER -> CALCULATOR and enter 39 in the 'decimal box'
select 'Type:' tick box 'integer (4 byte)'
select 'Endian:' tick box 'little endian'

click 'convert' next to decimal

the Hexadecimal value, 27 00 00 00, appears in the 'Hex:' box.

now in your hex editor replace 19 00 00 00 with 27 00 00 00 in effect you can just replace 19 with 27 in this example as the 00's don't change.

save you new trek.exe and your done.

Hope this helps as an overviex to hedadecimal editing Spike.

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

Re: A Nuts and Bolts Guide

Post by Kurn »

This guide really helped me in editing some things with hex editor neo. :up:

Unfortunately now I have a problem with replacing a really long number:
Spocks-cuddly-tribble wrote: Sun Dec 19, 2010 8:45 am 10. Protecting the AI from Neutron Stars

Since we cannot make the AI aware of neutron stars (AI mass graves in vanilla low tech games), here is how to make neutron stars aware of AI:

Code: Select all

trek.exe at 0x6B076 change 90 to -> 86

AND at 0x6B086
replace: (48 bytes)
00 00 00 00 00 00 00 00 00 00 55 83 EC 34 89 44 24 2C 89 54 24 28 0F BF 00 31 D2 E8 7A DB FD FF 66 8B 50 34 31 ED 66 89 54 24 30 66 83 FA 23 76
with:
55 83 EC 34 89 44 24 2C 89 54 24 28 0F BF 00 33 D2 E8 84 DB FD FF 33 ED 51 66 8B 48 34 66 89 4C 24 34 B5 01 D2 E5 84 2D 28 2B 5A 00 59 90 90 75
How can I replace such a long number with hex editor neo?
I googled it, but the explanations weren't helpful.
User avatar
thunderchero
Site Administrator aka Fleet Admiral
Site  Administrator aka Fleet Admiral
Posts: 7849
Joined: Fri Apr 25, 2008 2:00 am
Location: On a three month training mission, in command of the USS Valiant.

Re: A Nuts and Bolts Guide

Post by thunderchero »

The easiest way would be to use QD's patcher instead of hex editor.

note; this patch is part of original patch folder, patch name; "AI Tweak 10: Protecting the AI from Neutron Stars"

but, for other patches you can create a custom patch.
viewtopic.php?f=126&t=2515

just edit any current patch (just use same formatting) and save as different name.

but as always make backups first and test after.

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

Re: A Nuts and Bolts Guide

Post by Kurn »

I solved the problem by using hex editor mx. :smile:
Post Reply

Return to “A Nuts and Bolts Guide”