Colonies: population, farms, factories

Colonies : population, farms, factories; support/discussion/questions

Moderator: thunderchero

User avatar
adi
Commander
Commander
Posts: 442
Joined: Sun Aug 12, 2012 6:53 pm
Location: US East Coast

Re: Colonies: population, farms, factories

Post by adi » Mon Oct 21, 2013 12:23 pm

No need to use the hex editor if you are not familiar with it. QD made this easy for us: he has given us a tool the bof_patcher; the patches for this tool are text files editable by notepad;
There is the better_colonies patch available; you can edit the values as you like inside and use the tool to install the patch.

Here is a link to a post about the patcher:
viewtopic.php?f=4&t=2515

User avatar
supertyp79
Cadet 1st Year
Cadet 1st Year
Posts: 4
Joined: Thu May 25, 2017 8:30 am

Re: Colonies: population, farms, factories

Post by supertyp79 » Fri May 26, 2017 4:04 am

I need help with something familiar and i'm a total loser with Editing or stuff. So i'll need a "step by step" how to do and what lines and Hexes to edit.
I don't want to have my new colonies updated to my Tech-Lv in UDM III. Also the enemies shouldn't have this either. Every new colony should start with Tech-Lv 1, but there's no need of change the quantity of the buildings for the colony ships. If there is a post for this already, please link me to, cause i've found nothing in two days of search. A kind of tutorial or maybe a short video would be more than just a little helpful.

Thanks, Manuel

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

Re: Colonies: population, farms, factories

Post by thunderchero » Fri May 26, 2017 7:38 am

Hi supertyp79,

This is a simple hex edit,

at 0x68fab change 03 D8 to 90 90

or you can use QD's patcher (in start menu in tools folder)

download this file and extract to UDM folder
tech1_patch.zip
(432 Bytes) Downloaded 47 times
execute QD's Patcher from start menu
QD's Patcher will look like this
qd1.jpg
qd1.jpg (166.62 KiB) Viewed 3455 times
first browse for new patch folder "Tech1_patch" folder
qd2.jpg
qd2.jpg (158.33 KiB) Viewed 3455 times
next use dropdown menu to select the UDM\trek.exe UDML\trek.exe depending on what version you want to edit
qd3.jpg
qd3.jpg (122.88 KiB) Viewed 3455 times
next select the line "UDM new colonies start at tech 1" (it should turn purple)
next select install button line "UDM new colonies start at tech 1" (it should turn yellow with + )
next select apply button.
after that you are done repeat on other UDM trek.exe if you want then close QD's Patcher

User avatar
supertyp79
Cadet 1st Year
Cadet 1st Year
Posts: 4
Joined: Thu May 25, 2017 8:30 am

Re: Colonies: population, farms, factories

Post by supertyp79 » Fri May 26, 2017 10:38 am

Thanks Thunderchero. Buddy, you're the best.

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

Re: Colonies: population, farms, factories

Post by jonesie85two » Thu Oct 19, 2017 1:00 pm

I have added this to my mod. works like a charn. My question. Is there a version of this that works with minor races on them becoming a member of your faction?

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

Re: Colonies: population, farms, factories

Post by thunderchero » Thu Oct 19, 2017 5:04 pm

this change has nothing to do with minors, you might check out Minor Race Advancement
viewtopic.php?f=187&t=13

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

Re: Colonies: population, farms, factories

Post by thunderchero » Sat Feb 10, 2018 12:25 am

I was planning on using the "Colonies Starting Pop and Buildings - experimental code" on mirror universe mod. but a comment by cleverwise
cleverwise wrote:
Fri Feb 09, 2018 9:08 am
Well you could always drop the colony ships. ;-)
got me wondering if it would be possible to change testing of production value to test tech level?
this would allow me to drop colony ship upgrades :idea:

example;
table entry 0 = tech 1
table entry 1 = tech 2
table entry 2 = tech 3
table entry 3 = tech 4
table entry 4 = tech 5
table entry 5 = tech 6 and so on until table entry 8 = tech 9

note; it would be nice to have a multiplier for extended techs levels "rounded down" :wink:

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

Re: Colonies: population, farms, factories

Post by Spocks-cuddly-tribble » Sat Feb 10, 2018 9:11 pm

I don't have BotF installed for hex-code, but this should work for Ollydbg:

Code: Select all

00469AD4   8A42 28          MOV AL,BYTE PTR DS:[EDX+28]
00469AD7   BA 06000000      MOV EDX,6  // tech ID = all tech aka lowest
00469ADC   E8 9F9BFEFF      CALL 00453680
00469AE1   48               DEC EAX
00469AE2   D1E8             SHR EAX,1  // tech level /2 rounded down
00469AE4   3C 08            CMP AL,8
00469AE6   7E 02            JLE SHORT 00469AEA
00469AE8   B0 08            MOV AL,8
00469AEA   8BF8             MOV EDI,EAX
00469AEC   90               NOP
00469AED   90               NOP
00469AEE   90               NOP
00469AEF   90               NOP
00469AF0   90               NOP
00469AF1   90               NOP
00469AF2   90               NOP
00469AF3   90               NOP
00469AF4   90               NOP
00469AF5   90               NOP
00469AF6   90               NOP
00469AF7   90               NOP
00469AF8   90               NOP
00469AF9   90               NOP
00469AFA   90               NOP
00469AFB   90               NOP
00469AFC   90               NOP
I don't know how many bugs is too many but that point is reached somewhere before however many in BotF is.

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

Re: Colonies: population, farms, factories

Post by thunderchero » Sun Feb 11, 2018 9:40 am

thanks SCT, I will give this a try and test when I start adding this code later. Right now I am keeping trek.exe with min changes until some of other major changes are complete so I can keep track of changes better, also to insure no conflicts.

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

Re: Colonies Starting Pop and Buildings - experimental code

Post by thunderchero » Sat Apr 18, 2020 3:17 pm

Spocks-cuddly-tribble wrote:
Wed Dec 21, 2011 7:58 pm
To adapt upgrade feature to reduced upgrades mods: (code is shared for all main buildings!)

Code: Select all

00469B9B     48                   DEC EAX  // current tech level -1
00469B9C     9090                 NOP
-> e.g. 'dec eax' & 'shr eax,1' = [tech level-1]/2 for BoP (4 upgrades instead of vanilla 8) 

00469B9E     3C 08                CMP AL, 8    // max upgrades for main buildings

00469BA2     B0 08                MOV AL, 8   // max upgrades for main buildings
-> e.g. set 4 for BoP, 0 if no upgrades
I could use some help here for Mirror universe mod

MUM has 5 total main structures (4 upgrades) so set I set 469B9E and 469BA2 to CMP AL, 4 and MOV AL, 4

but since it uses 20 tech level how would I set at 469B9B ?
upgrades happen at tech 5, 10, 15, 20

note; this will not work on BOP since food has 0 upgrades, industry has 4 upgrades, energy has 0 upgrades, intel has 8 upgrades, research has 8 upgrades.

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

Re: Colonies Starting Pop and Buildings - experimental code

Post by Spocks-cuddly-tribble » Sun Apr 19, 2020 9:13 am

thunderchero wrote:
Sat Apr 18, 2020 3:17 pm
MUM has 5 total main structures (4 upgrades) so set I set 469B9E and 469BA2 to CMP AL, 4 and MOV AL, 4

but since it uses 20 tech level how would I set at 469B9B ?
upgrades happen at tech 5, 10, 15, 20
This depends on what you want, the colony & building values of your mod and how much effort you're willing to invest in adapting the code.

In theory you would use div 5, but this requires moving parts of code and adapting its jump statements.

And how bad do you want always the latest upgrades pre-built in new colonies?

For example, for my taste, I would use the middleground for colonies anyways (i.e. not the latest and not always T1). In vanilla pre-built upgrade = [techlevel -1 ] /2 (dec eax shr eax, 1). So on tech 3 the first upgrade(T2), tech 5 the second(T3) with the T9 buildings at T19.

Problem is that depending on pop, pop growth, current industry buildings overall output vs. build cost of current upgrade-level buildings, one must buy buildings to prevent unemployment in newer colonies. Not good if one is short on credits....


The closest easy workaround for you is shr eax, 3 i.e. pre-built upgrade level on colonies is techlevel /8, but this means your latest upgrade is pre-built at tech 32 and not at tech 20 in new colonies.


Current level of the building's science-area requirement / pre-built upgrade levels in new colonies:

1-7 / base buildings
8-15 / 1st upgrades
16-23 / 2nd upgrades
24- 31 /3rd upgrades
32+ / 4th upgrades


note; this will not work on BOP since food has 0 upgrades, industry has 4 upgrades, energy has 0 upgrades, intel has 8 upgrades, research has 8 upgrades.
Thanks for noticing. I forgot about Gowron removing food & energy upgrades in latest BoP revision. So yes, the upgrade option of this patch must be disabled when using with BoP.
I don't know how many bugs is too many but that point is reached somewhere before however many in BotF is.

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

Re: Colonies Starting Pop and Buildings - experimental code

Post by thunderchero » Sun Apr 19, 2020 1:56 pm

Spocks-cuddly-tribble wrote:
Sun Apr 19, 2020 9:13 am
thunderchero wrote:
Sat Apr 18, 2020 3:17 pm
MUM has 5 total main structures (4 upgrades) so set I set 469B9E and 469BA2 to CMP AL, 4 and MOV AL, 4

but since it uses 20 tech level how would I set at 469B9B ?
upgrades happen at tech 5, 10, 15, 20
This depends on what you want, the colony & building values of your mod and how much effort you're willing to invest in adapting the code.

In theory you would use div 5, but this requires moving parts of code and adapting its jump statements.

And how bad do you want always the latest upgrades pre-built in new colonies?
tbh I am not sure what code would be for dev 5 I tried 48 90 90 -> C1 E8 05 , moving parts of code and adapting its jump statements is easy enough. :grin:

but now I am thinking I needed 48 C1 E8 05 then move code to make room?

edit:
ok I moved code up 1 byte reset call for sub_453680 and everything looks right in ida but does not place latest structures

here is what section looks like in ida
code.jpg
code.jpg (107.77 KiB) Viewed 573 times
I am lost any ideas

extra info on my upgrade list (thought it might help)
this list first column cards, first 5 down are upgrades then last upgrade repeats.
this is only way I found to get upgrades working properly.
30 00 type 1, 31 00 type 2, 32 00 type 3, 33 00 type 4, 34 00 type 5, then type 5 repeats to fill list
upgradelist.jpg
upgradelist.jpg (219.27 KiB) Viewed 570 times

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

Re: Colonies: population, farms, factories

Post by Spocks-cuddly-tribble » Sun Apr 19, 2020 5:00 pm

Sorry pal, but I really can't memorize all specific hex opcodes of asm statements. So no idea what your hex codes mean. :???:

IIRC at 469B9B you must:

xor ecx, ecx (looks like an unused register)
mov cl, 5
xor edx, edx
idiv ecx

But you need more than the 3 nop bytes.

In my code at asm-469BCC are four nops you can overwrite, so you have to move the code in between down to them (and pray we missed no fixed jumps from and into this area).

EDIT: Even with this you still need one byte more. There are some free nops above, but I can't check all possible xrefs just looking at posted code.

I'd use OllyDbg.


EDIT 2: If I'm not mistaken this should work for you:

At asm 469B85 enter in OllyDbg:

CALL EBX
MOVZX EDX, BYTE [ESP+85h]
MOV EAX, [ESP+0Ch]
CALL 453680
imul eax, 0Dh
shr eax, 6
I don't know how many bugs is too many but that point is reached somewhere before however many in BotF is.

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

Re: Colonies: population, farms, factories

Post by thunderchero » Sun Apr 19, 2020 10:23 pm

Spocks-cuddly-tribble wrote:
Sun Apr 19, 2020 5:00 pm
EDIT 2: If I'm not mistaken this should work for you:

At asm 469B85 enter in OllyDbg:

CALL EBX
MOVZX EDX, BYTE [ESP+85h]
MOV EAX, [ESP+0Ch]
CALL 453680
imul eax, 0Dh
shr eax, 6
Thank you, working on saves I had setup, but will test more.

BTW I would have never got that. :wink:

I had your first changes and crashed on turn process. I even had 8 bytes open lol

I wish I knew more about OllyDbg, but I was able to use it as you instructed.

Question will OllyDbg save changes to trek.exe? if so how.

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

Re: Colonies: population, farms, factories

Post by Spocks-cuddly-tribble » Mon Apr 20, 2020 8:32 am

thunderchero wrote:
Sun Apr 19, 2020 10:23 pm
I even had 8 bytes open lol
This doesn't sound right, shouldn't be more than 1-2 bytes (nops) left.

Question will OllyDbg save changes to trek.exe? if so how.
Yes, but IIRC it's really nerdish in some cases.

See my my hints here #3: viewtopic.php?f=72&t=598#p27485
Save code changes to exe:

Right click -> Copy to executable -> All modifications (ignore any strange warnig messages, just continue)

In pop-up "Copy to executable file" -> Copy all

In pop-up window with changed code (it's just a documentation!) -> Right click -> Save file [under different name e.g. trek1.exe]

Now just change the file names (e.g. trek.exe to trekold.exe and trek1.exe to trek.exe) and test your new code.

- I used version 110 (I think), not the newest 2+

- BotF must be installed to save code to a new trek.exe

Just a trek.exe on an usb stick won't allow for this, hence no hex code for your above request: viewtopic.php?p=52008#p48766
I don't know how many bugs is too many but that point is reached somewhere before however many in BotF is.

Post Reply

Return to “Colonies : population, farms, factories”

Who is online

Users browsing this forum: No registered users