pop & planets limits for free- minor- & starting-systems

pop & planets limits for free- minor- & starting-systems; support/discussion/questions

Moderator: thunderchero

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

pop & planets limits for free- minor- & starting-systems

Post by Gowron » Sat Jan 17, 2009 7:16 pm

UPDATE:


1. Number of Planets

At the start of a new game, after stars have been generated, subroutine 4B4F70 is called - time for adding some planets :)

After a relatively uninteresting climate probability check, we enter a loop (for each star system):

Code: Select all

Offset    hex code                asm code

:004B5033 8BB4244C010000          mov esi, dword[esp+0000014C]   // load current star system ID
:004B503A 8B1DC8365A00            mov ebx, dword[005A36C8]
:004B5040 01F3                    add ebx, esi
:004B5042 668B4B44                mov cx, word[ebx+44]   // determine controlling race (-1=none, 0=Card, 1=Fedr, 2=Ferg ...)
:004B5046 6685C9                  test cx, cx
:004B5049 0F8CEB000000            jl 004B513A
After that, the number of planets for the current star system is generated randomly:

Code: Select all

Offset    hex code                asm code
:004B513A 6800004040              push 40400000   // 3.0 (maybe a seed)
:004B513F E87C300500              call 005081C0   // generate a random value
:004B5144 E88B850600              call 0051D6D4   // round to integer
:004B5149 DB9C2450010000          fistp dword[esp+00000150]   // store as integer
:004B5150 8B842450010000          mov eax, dword[esp+00000150]
:004B5157 668984245C010000        mov word[esp+0000015C], ax
:004B515F 8B94245A010000          mov edx, dword[esp+0000015A]
:004B5166 C1FA10                  sar edx, 10
:004B5169 BE07000000              mov esi, 00000007   // [esi] = 7
:004B516E 89D0                    mov eax, edx
:004B5170 C1FA1F                  sar edx, 1F
:004B5173 F7FE                    idiv esi   // divide previously generated random integer value by [esi], store integer quotient in [eax] and remainder (between 0 and 6) in [edx]
:004B5175 8D4201                  lea eax, dword[edx+01]   // [eax] = [edx] + 1 (result is between 1 and 7)
:004B5178 E9FEFEFFFF              jmp 004B507B
This opens up a wide variety of options, for example changing the divisor from 7 to 1 (division by 1, remainder is always zero) and changing

Code: Select all

:004B5175 8D4201                  lea eax, dword[edx+01]
to

Code: Select all

:004B5175 8D4209                  lea eax, dword[edx+09]
will result in 9 planets per system, barring population capacity boundaries.


Note that clicking into a system with 10 (or more) planets will crash the game. However, for testing purpose it is possible to create a galaxy with some systems containing 10 planets and hover the mouse cursor over every star to view the number of planets, thus avoiding accidentially entering a system with 10 planets.
11 or more planets in a system reliably meant a CTD during testing.


2. Population Limits

The lower/upper limits of 80 and 400 are stored as 0x320 (= 800) and 0xFA0 (= 4000), respectively. This is why they were so hard to find. But now they're available, and even better, there are three different subroutines that do the work: subroutine 4B47B0 for free systems, subroutine 4B49C0 for minor race systems, and subroutine 4B4C20 for additional major empire starting systems. This is great, since it means these three types of systems can be modified separately :)

The game adds planets one by one until either the random number (see section 1) has been reached or the population capacity exceeds the upper limit (400 by default).
If the resulting system has a population capacity of less than the lower limit (80 resp. 130 by default), then the game tries to compensate that by adding more planets (if there aren't already 7 planets), and if that's still not enough, then the game (repeatedly) tries to replace planets with bigger ones, until there's enough population space (or until all planets are pop 140 class M planets ^^).

A warning in advance: Increasing the upper limit and the number of planets can lead to some planets not being displayed in the game, because there's only limited space for the planet animations. Gas Giants are the biggest troublemakers in this case, since they have big animations and a population capacity of zero.


Free Systems

Code: Select all

Offset    hex code                asm code

:004B48BD 817C244CA00F0000        cmp dword[esp+4C], 0FA   // upper limit
----------
:004B4849 817C244C20030000        cmp dword[esp+4C], 00000320   // lower limit
----------
:004B485C 817C244C20030000        cmp dword[esp+4C], 00000320   // lower limit
----------
:004B492C 66837D6A07              cmp word[ebp+6A], 007   // maximum number of planets
The lower limit is stored twice. The "maximum number of planets" is used for the check if the game can add another planet to a system that does not reach the lower limit yet.


Minor Race Systems

Code: Select all

Offset    hex code                asm code

:004B4B0B 817C244CA00F0000        cmp dword[esp+4C], 0FA   // upper limit
----------
:004B4A43 817C244C14050000        cmp dword[esp+4C], 00000514   // lower limit
----------
:004B4A53 817C244C14050000        cmp dword[esp+4C], 00000514   // lower limit
----------
:004B4B7C 66837D6A07              cmp word[ebp+6A], 007   // maximum number of planets
The lower limit is 130 for minor race systems (stored as 0x514, i.e. 1300).
Note that the population capacity of the home planet does not count.


Additional Major Empire Starting Systems

Code: Select all

Offset    hex code                asm code

:004B4D3D 817C244CA00F0000        cmp dword[esp+4C], 0FA   // upper limit
----------
:004B4C6D 817C244C14050000        cmp dword[esp+4C], 00000514   // lower limit
----------
:004B4C7D 817C244C14050000        cmp dword[esp+4C], 00000514   // lower limit
----------
:004B4DFB 66837D6A07              cmp word[ebp+6A], 007   // maximum number of planets
The lower limit is 130 here, as well. Note that an additional major empire starting system will always get a class M planet (comparable to the home planet of a minor race).


Edit:
Class specification for the additional planet (default = 6 = terran):

Code: Select all

:004B4C9D B806000000              mov eax, 00000006
This can be changed to any other class (0=arctic, ..., 7=volcanic), even gas giants work. Each additional major empire starting system will contain at least one planet of the specified class.

These "special planets" can be disabled by replacing

Code: Select all

:004B4C9B 753E                    jne 004B4CDB
with

Code: Select all

:004B4C9B EB3E                    jmp 004B4CDB
Last edited by Gowron on Sun Jan 31, 2010 6:01 pm, edited 6 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
AlexMcpherson79
Commander
Commander
Posts: 282
Joined: Thu Sep 04, 2008 2:00 am

Re: pop & planets limits for free- minor- & starting-systems

Post by AlexMcpherson79 » Sun Dec 21, 2014 4:49 pm

Just wondering if these types of changes were made editable with UE? just an idea. ;)

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

Re: pop & planets limits for free- minor- & starting-systems

Post by thunderchero » Sun Dec 21, 2014 4:54 pm

AlexMcpherson79 wrote:Just wondering if these types of changes were made editable with UE? just an idea. ;)
unfortunately UE is no longer be updated by Dcer, But is open source if any one is interested in making changes if they know how.

thunderchero

User avatar
AlexMcpherson79
Commander
Commander
Posts: 282
Joined: Thu Sep 04, 2008 2:00 am

Re: pop & planets limits for free- minor- & starting-systems

Post by AlexMcpherson79 » Fri Jan 09, 2015 2:13 pm

*sigh* Remember: if you want, say, systems to have a minimum/maximum limits of between say, 200 to 550, the numbers you need to convert is 2000 and 5500. otherwise the population in game will be set between 20 and 55! D'Oh!

User avatar
Axis
Lieutenant-Commander
Lieutenant-Commander
Posts: 144
Joined: Sun Aug 16, 2015 8:28 am

Re: pop & planets limits for free- minor- & starting-systems

Post by Axis » Fri Aug 21, 2015 4:33 am

If someone wants to have a maximum of 9 planets, here`s how to do it :

Change :
Offset, Hex code
004B5169, BE07000000 (7 planets maximum).
to
004B5169, BE09000000 (9 planets maximum).

Free systems
004B492C, 66837D6A07
to
004B492C, 66837D6A09

Minor race systems
004B4B7C, 66837D6A07
to
004B4B7C, 66837D6A09

Additional starting systems
004B4DFB, 66837D6A07
to
004B4DFB, 66837D6A09

And here`s the result (a pearl! :wink: ):
9Planets.jpg
9Planets.jpg (240.83 KiB) Viewed 2780 times
It seems that 9 is the highest value possible, the game crashes if I enter 10 (0A), or it doesn`t even generate so many planets
(tried this on my small 52 x 39 map with 500 stars), there should have been at least 1 system with 10 planets.

But, I`m happy with even this increase, after all, if you count carefully, there ARE 10 objects in the system screen.

User avatar
Tenor
Cadet 1st Year
Cadet 1st Year
Posts: 3
Joined: Mon Jun 24, 2019 11:56 pm

Re: pop & planets limits for free- minor- & starting-systems

Post by Tenor » Tue Jun 25, 2019 12:09 am

Can I get some clarification please? Are these offsets in trek.exe or stbof.res? The copy of trek.exe I have doesn't have that many and the data at those offsets in stbof.res is way different.

Also, I'm using HxD but it seems lacking in the information it gives. Does anyone have a better recomendation?

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

Re: pop & planets limits for free- minor- & starting-systems

Post by thunderchero » Tue Jun 25, 2019 6:55 am

yes, these offsets in trek.exe

User avatar
Tenor
Cadet 1st Year
Cadet 1st Year
Posts: 3
Joined: Mon Jun 24, 2019 11:56 pm

Re: pop & planets limits for free- minor- & starting-systems

Post by Tenor » Tue Jun 25, 2019 11:09 pm

I'm using the trek.exe from vanilla and the offsets written here do not exist.

Let me list the steps I did in case I missed something:
I installed the all-in-one.
I opened my hex editor, pointed it to the vanilla path, and opened trek.exe
I use the lookup feature to look up an offset (for this example I used 004B5169) and got "The file doesn't contain the offset 004B5169." I also tried 4B5169 without the leading zeros and got the same error.

Did I miss a step?

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

Re: pop & planets limits for free- minor- & starting-systems

Post by thunderchero » Wed Jun 26, 2019 6:56 am

Tenor wrote:
Tue Jun 25, 2019 11:09 pm
Did I miss a step?
yes, those are assembly off sets and need to be converted to hex location. You can use UE to convert address.

User avatar
Tenor
Cadet 1st Year
Cadet 1st Year
Posts: 3
Joined: Mon Jun 24, 2019 11:56 pm

Re: pop & planets limits for free- minor- & starting-systems

Post by Tenor » Wed Jun 26, 2019 9:24 am

thunderchero wrote:
Wed Jun 26, 2019 6:56 am
yes, those are assembly off sets and need to be converted to hex location. You can use UE to convert address.
Ah! That should help greatly. Thank you!

Post Reply

Return to “pop & planets limits for free- minor- & starting-systems”

Who is online

Users browsing this forum: No registered users