Special ships

Special ships; support/discussion/questions

Moderator: thunderchero

Post Reply
User avatar
DCER
Code Master
Code Master
Posts: 683
Joined: Sat Apr 26, 2008 2:00 am

Special ships

Post by DCER »

If you want to change special ships IDs they are found in trek.exe
(addresses are valid in Joker's patched exe)

Address->Value (ship index)

0xF31D5 -> 0x1A
0xF323B -> 0x1B
0xF3241 -> 0x22
0xF3247 -> 0x29
0xF324D -> 0x2A

If you want to change which empire has special ships change the value at 0xF31CF from 1 to desired empire id (valid ones are 0-4, but others won't throw errors).

Another fun value is at 0xF31D0

if set to 0x74 only the selected empire has special ships

if set to 0x75 all empires except the selected ones have special ships
(this means changing empire to a ridiculous value such as 0xFF will allow all empires to build special ships, botf will still check race req of ships! meaning Cardassians can't build Federation ships etc.)

if set to 0xEB special ships are disabled - they can be built normally without Utopia Planitia.


Special ships require a building that allows building special ships. Unfortunately there can be only one such building and it's id is fixed to 0x26 (Utopia Planitia id)

At 0xF31DB is the value 0x26 and can be changed to another building id.

Adding support for more of these buildings is a bit tricky. Botf checks only for id and not the buildings bonus type.

Untested possible solution:

Place all "builds special ships" structures at the beginning of the buildings list.

At 0x3AEB8 is another magic value.

set to 0x74 it means only accept building with specified id (default 0x26 - see above)

set to 0x7E it will mean accept all id's that are equal or lower than the specified id

so change 0x74 to 0x7E and change special structure id to the id of he last "build special ships" building id. This should allow us to have 5 of these special structures (one for each empire) and five special ships (one for each empire)
Last edited by DCER on Sun Mar 01, 2009 3:19 am, edited 1 time in total.
User avatar
DCER
Code Master
Code Master
Posts: 683
Joined: Sat Apr 26, 2008 2:00 am

Post by DCER »

Thunderchild wrote:Is there a way to make more then 5 specialships in the game or is this the limit?
You could with a similar "lower/greater or equal" ship id trick, but only the Cardassians and Romulans could benefit from it.

EDIT: basically you'd end up with unlimited number of special ships for cards and roms, but the other three empires would be left with three remaining slots only.
User avatar
Thunderchild
Ensign
Ensign
Posts: 28
Joined: Wed Apr 30, 2008 2:00 am

Post by Thunderchild »

So there could only be 5 fix adresses setted when i want to give all empires give specialships? I don't understand why only cards and roms could benefit from it. Can you explain it please?

Would there be an option in the next UE-version where all these changes can be made?

You are really a genius Dcer with all the things you find out and with this fantastic editor you made :D
Spocks-cuddly-tribble wrote:This is because they are at the beginning / end of shiplist.sst.
If it works correctly, card/roms can have unlimited special ships and the other empires every five.

@DCER fantastic job again
User avatar
DCER
Code Master
Code Master
Posts: 683
Joined: Sat Apr 26, 2008 2:00 am

Post by DCER »

thanks :D

Spocks-cuddly-tribble you are right, two slots would already be given to card/roms (one each), so in total three would be left for three remaining empires (one for each for instance). Five slots altogether.

It'll probably be added to UE. :)
User avatar
DCER
Code Master
Code Master
Posts: 683
Joined: Sat Apr 26, 2008 2:00 am

Post by DCER »

Spocks-cuddly-tribble wrote:Is it realy nessesary to sort ships in shiplist belong the empires?
Yes, because of shiprace.sst. It has one ship id for each race, it's the first ship of each race on the list. It divides shiplist.sst into blocks of ships. The race set in shiplist.sst doesn't matter, what matters is what block of ships a ship belongs to.
Spocks-cuddly-tribble wrote:And is it possible to move the other empires at the beginning / end of shiplist without getting troubles?
No. Ships of a given race need to be grouped together. Blocks go the same as race ids - cardassians ships first, then federation...
User avatar
thunderchero
Site Administrator aka Fleet Admiral
Site  Administrator aka Fleet Admiral
Posts: 7824
Joined: Fri Apr 25, 2008 2:00 am
Location: On a three month training mission, in command of the USS Valiant.

Post by thunderchero »

Ok I have been tring to get 1 special ship per race.

this has what I have done so far.

first set 1 ship per race to;

0xF31D5 -> 0x10 cardassians
0xF323B -> 0x2C federation
0xF3241 -> 0x3F dominion/ferengi
0xF3247 -> 0x53 klignons
0xF324D -> 0x63 romulans

All these ships are available at tech start advanced and that is level I have done all my testing.

next set 0xF31CF to 0x05 DCER stated (valid ones are 0-4, but others won't throw errors). if I set this to 0-4 one race special structure did not work.

next set 0xF31D0 to 0x74
DCER had this one backwards 0x74 is for all empires except the selected ones have special ships. and 0x75 only the selected empire has special ships (default is 0x75) and setting to 0xFF crashed on all races when viewing ship build screen.

next changed 0xF31DB from 0x26 to 0x10 and created a new special ship structure (using Utopia Planitia id would not work) If I used 0x26 feds would not build special ships right no matter what setting I used unless they were only ones building special ships.

now I have 1 special ship per race using the one structure and all races can build ship if special structure is built and can not build if special ship structure is not built. looks good so far :lol:

so what I still need to test is if I create 2 more special structures for special ship in slots 14, 15, 16 (0x08, 0x09, 0x10) I should be able to set to 0x3AE58 from 0x74 to 0x7E it should use all 3 special structures. I will test this last part tomorrow or sunday.

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

Re: Special ships

Post by Gowron »

There are quite some possibilities for special ships, I'll first explain some of the default code and then introduce a few options.

1. Default checks

1a. Outpost Check
trek.exe offset: 0xF31C0
length: 6 bytes
default hex code: 6683FA067459

Explanation:
"6683FA06" compares the register dx (the ship function is stored there) with 0x06 (function: "outpost") by subtraction.
"7459" is a JUMP IF EQUAL or JUMP IF ZERO (that's the same because the subtraction yields zero only if the values are equal) statement. If the ship function is "outpost", then this will skip the test that determines whether the ship can be built in the system.

Warning:
Altering this can lead to Outposts being built in star systems (edit: this means that the outpost would be built by the shipyard!). One turn after completion, the game will crash with an "invalid ship type" error.


1b. Starbase Check
trek.exe offset: 0xF31C6
length: 6 bytes
default hex code: 6683FA077453

Explanation: Same as the outpost check, but the function ID 06 is replaced by 07, and the jump target offset (0x53 instead of 0x59) is smaller (by 6 bytes), because it's a relative offset and the starbase check comes 6 bytes after the outpost check.

Warning: same problem as for the Outpost Check.


1c. Empire Check
trek.exe offset: 0xF31CC
length: 6 bytes
default hex code: 807E4C017519

Explanation: "807E4C01" compares the empire ID with 0x01 (Federation) by subtraction.
"7519" is a JUMP IF NOT EQUAL or JUMP IF NOT ZERO statement. It will lead to the ship being not special if the empire is not the Federation.


1d. Primary ID Check
trek.exe offset: 0xF31D2
length: 6 bytes
default hex code: 6683FB1A7560

Explanation: "6683FB1A" compares the register bx (the ship ID is stored there) with 0x1A by subtraction.
"7560" is a JUMP IF NOT EQUAL or JUMP IF NOT ZERO statement that will cause a jump to the secondary ID checks if the ID is not 0x1A.

Warning:
Any ship that passes all of the above checks will be treated as a special ship, and in this case the other checks will not be done. Keep this in mind if you replace them by other checks.


1e. Secondary ID Checks
trek.exe offset: 0xF3238
length: 4*6 = 24 bytes
default hex code: 6683FB1B749A 6683FB227494 6683FB29748E 6683FB2A7488

Explanation: Similar to the first ID check, but this time JUMP IF EQUAL statements are used, so any ship with one of these IDs is treated as a special ship, and all other ships pass these checks without any actions.


1f. Final Jump Statement
trek.exe offset: 0xF3250
length: 2 bytes
default hex code: EB 99

Explanation: All ships that were not affected by the above checks are now treated as not special. "EB" means JUMP, and "99" is the relative offset.



2. Some Possible Modifications

2a. Replacing Checks

To make certain ships special, you can replace some of the listed checks by other, custom checks. The outpost and starbase checks should remain unchanged, except if your mod does not contain bases with the function ID 06 resp. 07 (then you could replace the corresponding check).

Be careful with the primary ID check, it could cause the game to skip the secondary checks (see above).

To replace a check, you have to change the comparison (4 bytes) and the jump statement (2 bytes).

The comparison can either be a subtraction or a bitwise "AND".
Subtraction codes (XX is a signed byte that you can choose):

Code: Select all

807E4CXX     subtracts XX from the empire ID
6683FAXX     subtracts XX from the ship function ID
6683FBXX     subtracts XX from the ship ID
Codes for bitwise "AND":

Code: Select all

F6464CXX     [empire ID] AND XX
90F6C2XX     [ship function ID] AND XX
90F6C3XX     [ship ID] AND XX

The first byte of the jump statement determines the jump type.

Code: Select all

74     jump if zero
75     jump if not zero
7C     jump if negative
7D     jump if not negative
7E     jump if not positive
7F     jump if positive

And the last byte ("offset byte") contains the relative offset. This depends on the actual position of the statement itself, so it's a bit tricky to calculate.

Use the offset
0xF321E - [address of the offset byte]
to keep the ship(s) out of the build list (default for outposts/starbases)

Use the offset
0xF31D7 - [address of the offset byte]
to make the ship(s) special.

Use the offset
0xF31EA - [address of the offset byte]
to make the ship(s) "normal" (i.e. not special)


2b. Deleting checks

To delete a check, simply overwrite it with
909090909090.


2c. Changing the final jump statement

The second byte of the final jump statement is a relative offset. You can change it to one of the other possible relative offset (see above) to make all ships unbuildable/special that were not affected by any of the checks.
Last edited by Gowron on Thu Sep 25, 2008 11:13 am, edited 2 times in total.
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

Post by Gowron »

thunderchero wrote:Gowron,

very interesting read But I did not understand any of it. :lol:

But most of your post are that way until I try to start changing some of it.

Just one thing what I have done in post above does it sound right?

thunderchero
Well, if it works, it can't be that wrong, can it? ;)

If 5 special ship slots are enough for you, then you don't need to alter any checks. But on the other hand, by smart combination of custom checks, you could have 2, 3 or even more special ships per empire.
A discovery consists in seeing something everybody has seen and at the same time thinking something nobody has thought yet.
User avatar
ketteringdave
Lieutenant-Junior Grade
Lieutenant-Junior Grade
Posts: 99
Joined: Sun Apr 27, 2008 2:00 am

Post by ketteringdave »

I feel like I almost understand what's going on here, but I'm sure I'm missing something.
thunderchero wrote:next set 0xF31D0 to 0x74
DCER had this one backwards 0x74 is for all empires except the selected ones have special ships. and 0x75 only the selected empire has special ships (default is 0x75) and setting to 0xFF crashed on all races when viewing ship build screen.
I think DCER was saying to change 0xF31CF to 0xFF so all empires are valid with the change to 0x74 (same as using 0x05).
thunderchero wrote:so what I still need to test is if I create 2 more special structures for special ship in slots 14, 15, 16 (0x0E, 0x0F, 0x10) I should be able to set to 0x3AE58 from 0x74 to 0x7E it should use all 3 special structures.
Won't this also allow every building before 0x10 to be a "special" activator? Including the dilithium refinery? Is there something wrong with moving the new buildings down to the first three slots?
User avatar
thunderchero
Site Administrator aka Fleet Admiral
Site  Administrator aka Fleet Admiral
Posts: 7824
Joined: Fri Apr 25, 2008 2:00 am
Location: On a three month training mission, in command of the USS Valiant.

Post by thunderchero »

Gowron wrote:
thunderchero wrote: ketteringdave,

and I did use the first 4 slot but it should not matter due to it would only pick up buildings that used builds special ships.
Are you sure? DCER wrote that the game only checks for the building ID, not the output type.
You are right I did miss read that, That is why I took no chances and put them at the beginning of the list so I would not have to redo them if it did not work.

I am glad you guys are around :wink:

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

Re: Special ships

Post by thunderchero »

Gowron wrote:There are quite some possibilities for special ships, I'll first explain some of the default code and then introduce a few options.

1b. Starbase Check
trek.exe offset: 0xF31C6
length: 6 bytes
default hex code: 6683FA077453

Explanation: Same as the outpost check, but the function ID 06 is replaced by 07, and the jump target offset (0x53 instead of 0x59) is smaller (by 6 bytes), because it's a relative offset and the starbase check comes 6 bytes after the outpost check.

Warning: same problem as for the Outpost Check.
I understand I can remove this check by changing code to 909090909090

But as warned game will crash on next turn. But with auto upgrade of outpost to starbases this ship type is no longer being used by any race.

so I have 3 questions

1. is there a way to stop game from crashing on next turn?

2. if so can this slot be assigned to a different type such as scout?

3. would starbase slot still use lexicon description for starbase, so type would still be listed differently when displayed?

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

Re: Special ships

Post by Gowron »

thunderchero wrote:1. is there a way to stop game from crashing on next turn?
Removing all starbases (i.e. all entries with role 0x07) from shiplist.sst should work.
thunderchero wrote:2. if so can this slot be assigned to a different type such as scout?
This depends on what you mean by "this slot".

If you refer to the check, then yes, you could change 0x07 to 0x00, thus making scouts unavailable.

If you refer to the role ID 0x07, then no, any shiplist entries with that role will still be starbases. Just modifying the availability check won't change this.
thunderchero wrote:3. would starbase slot still use lexicon description for starbase, so type would still be listed differently when displayed?
Again, this depends on what you refer to as a slot.
A discovery consists in seeing something everybody has seen and at the same time thinking something nobody has thought yet.
Post Reply

Return to “Special ships”