Extending Edifbnft.bst (new building types/bonuses)

edifbnft.bst (building bonus types); support/discussion/questions

Moderator: thunderchero

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

Extending Edifbnft.bst (new building types/bonuses)

Post by Spocks-cuddly-tribble » Sat Dec 03, 2011 7:29 am

Here is how to disable the final frontier preventing us from adding new building types.

edifbnft.bst (stbof.res)
  • first 4 bytes are pointer for start of address map
  • output description strings, read until 0 (vs. 0x20 space in string)
  • address map 4 bytes per entry (start positions to read from)
By default the address map is stored separately (i.e. duplicated) at asm 5B4260. Since there is only space for up to 48 output addresses (far too less for e.g. file-extending fetishists like Peter1984 :wink:) we just ignore this code and read the addresses directly from the loaded original file. If you wanna have a dynamic data field with static address just overwrite asm 450853-450864 with with "90"s and dynamic area 5B4260-5B431F (length 0xC0 / 192 bytes) is unused. :)

:arrow: edifbnft.bst supporting 49+ entries fix

Code: Select all

trek.exe at 0x4FBDC new code 0xC bytes:

C1 E0 02 03 02 8B 04 10 03 C2 5A C3

Changes in sub_4507D0: edifbnft_bst_description_via_bonus_ID

004507DC     C1E0 02     SHL EAX, 2    // bonus ID * 4
004507DF     0302        ADD EAX, [EDX]    // + address of address map in edifbnft.bst
004507E1     8B0410      MOV EAX, [EAX+EDX]   // start position of description string
004507E4     03C2        ADD EAX, EDX    // + address of loaded edifbnft.bst
004507E6     5A          POP EDX
004507E7     C3          RETN
OllyDbg complains, but it much less believes in simplest maths than dyslexic agnostics believe in a dog...

Note that this is just the cosmetic part, building the new output types on your systems still requires: viewtopic.php?p=30656&sid=08634c44f60c2 ... c82#p30656
On the verge of a nervous breakdown? Try the relaxing tribble sounds.

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

Controlling the bonus positions in systInfo

Post by Spocks-cuddly-tribble » Wed Dec 07, 2011 2:18 pm

The next limit for new building outputs is the bonus area in systInfo (default 48 slots, 45 used) resp. the corresponding address-map in trek.exe (default 45 slots).

Note that the systInfo bonus area is an empire-only feature, thus e.g. local military outputs like OBs are unneeded since not loaded from there due to the minor & rebel system issue. Also output slots for unrest orders and trade goods can be cleaned up, because they are no real buildings (exception AI trade goods bug).

Below code decreases trek.exe address-map entry size from 4 to 2 bytes (i.e. 90 slots). Additionaly, it features a switch marker for outputs not to store in systInfo resp. for ship construction only. :idea:

Code: Select all

trek.exe at 0x3E5B4 new code 0x33 bytes:

8D 54 10 4C 0F B6 45 72 66 8B 04 45 6C FC 58 00 80 FC 01 7F 23 7C 08 80 7A 34 03 75 1B B4 00 03 84 24 74 01 00 00 8B 12 66 8B 94 55 86 00 00 00 0F B7 0E

asm code:

0043F1B4     8D5410 4C            LEA EDX, [EAX+EDX+4C]  // address systInfo+4C
0043F1B8     0FB645 72            MOVZX EAX, BYTE [EBP+72]  // building output ID
0043F1BC     66:8B0445 6CFC5800   MOV AX, WORD [EAX*2+58FC6C]  // bonus position in systInfo
0043F1C4     80FC 01              CMP AH, 1  // if switch marker...
0043F1C7     7F 23                JG SHORT 43F1EC  // 2+ -> not stored
0043F1C9     7C 08                JL SHORT 43F1D3  // 0 -> store
0043F1CB     807A 34 03           CMP BYTE [EDX+34], 3  // systInfo+80 = order ID
0043F1CF     75 1B                JNZ SHORT 43F1EC  // if not 3 = build ship -> not stored
0043F1D1     B4 00                MOV AH, 0       // clear switch marker
0043F1D3     038424 74010000      ADD EAX, [ESP+174]  // systInfo modus area
0043F1DA     8B12                 MOV EDX, [EDX]   // system owner ID
0043F1DC     66:8B9455 86000000   MOV DX, [EBP+EDX*2+86]  // edifice.bst building output
0043F1E4     0FB70E               MOVZX ECX, WORD [ESI]  // number of buildings
Next is an adapted and cleaned up vanilla address-map (unneeded outputs get ignored, local morale bonuses share address[+8C]). It also unlocks the unused local static industry bonus for output ID 45 /0x2D i.e. new entry 46 in edifbnft.bst should be " Industry" (strings without % start with a space) and local "% Shipbuilding" for output ID 0x2E i.e. new entry 47. :)

Note: Albeit the shipbuilding bonus preview-bug has been fixed (i.e. preview screen shows updated industry output when turning on/off building (or scrapping), there is still the Build Queue update bug i.e. old bonuses until re-entering screen or changing worker/energy settings (cf. 'Dilithium Shortage' warning).

Code: Select all

trek.exe 0x18DA6C new address-map 0xB4 bytes:

00 00 04 00 08 00 0C 00 FF 02 28 00 2C 00 18 00 1C 00 20 00 38 00 40 00 44 00 10 00 14 00 48 00 FF 02 FF 02 FF 02 FF 02 8C 00 B8 00 60 00 64 00 68 00 6C 00 70 00 4C 00 74 00 78 00 B0 00 7C 00 AC 00 80 00 3C 00 50 00 FF 02 94 00 A4 00 98 00 88 00 90 00 A0 00 A8 01 BC 00 A8 00 14 01 FF 02 FF 02 FF 02 FF 02 FF 02 FF 02 FF 02 FF 02 FF 02 FF 02 FF 02 FF 02 FF 02 FF 02 FF 02 FF 02 FF 02 FF 02 FF 02 FF 02 FF 02 FF 02 FF 02 FF 02 FF 02 FF 02 FF 02 FF 02 FF 02 FF 02 FF 02 FF 02 FF 02 FF 02 FF 02 FF 02 FF 02 FF 02 FF 02 FF 02 FF 02 FF 02 FF 02
First byte of each entry is postion (unsigned) second byte the switch marker (signed): 0=store, 1=for ship construction only, 2=ignore. Ignored output types use FF 02 with the FF being pointless.

Output indexes are same as in edifbnft.bst (see above) i.e. entry postion = output ID * 2.


A How-To example: Adding a % Shipbuilding bonus to shipyards

In edifbnft.bst " Builds Ships" is entry 19 (i.e. ID 18 /0x12, since entry 1 is ID 0).
-> at 0x18DA6C +2*0x12 -> default FF 02 (ignored, since unused) former: 5C
-> systInfo bonus area +C0/+180h (see above link) +5C = 11C resp. 1DC
- systInfo wiki info:
Offset 0x011C to 0x011F = Builds Ships (i.e. yard output value -> unused)
Offset 0x01DC to 0x01DF = Builds Ships (i.e. yard output value -> unused)

Offset 0x00D4 to 0x00D7 = +% industry
Offset 0x0194 to 0x0197 = +% industry
-> D4/194h minus C0/180h = +14h

I.e. replacing the above default FF 02 with 14 01 (using the new switch marker) does the job.


More fixes & modding options to be expected soon. :wink:
Last edited by Spocks-cuddly-tribble on Thu Dec 22, 2011 8:13 pm, edited 2 times in total.
On the verge of a nervous breakdown? Try the relaxing tribble sounds.

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

Fixing empire-wide bonus addresses & some local bugs

Post by Spocks-cuddly-tribble » Sun Dec 11, 2011 6:45 am

Let's complete this topic with unlocking scientific-& military intel and the powerful empire-wide industry bonus. I've also included fixes for the local % research & intel bonuses (probably the vanilla Ullian building was meant to be % intel local, see below 'intel total') and an updated edifbnft.bst file. :wink:


BotF 1.0.2 building output type issues:

Unused but working:
  • % energy (local)
    % total credits (empire-wide)
Broken:
  • % research (local)
    % economic intel
    % raiding (empire-wide)
Two-in-one bug:
  • % intel total (empire-wide +local ->wrong position)
Missing:
  • % industry empire-wide
    Industry (local static bonus)
    % intel (local)
    % scientific intel
    % military intel
    % Shipbuilding

:arrow: empsInfo building bonuses fix

Code: Select all

trek.exe at 0x43AFA new code 0x39 bytes:

8B 51 50 66 01 50 10 8B 51 54 66 01 50 12 66 8B 91 88 00 00 00 66 01 50 02 8B 51 58 66 01 50 14 8B B1 98 00 00 00 66 01 70 04 8B 51 30 66 01 50 06 90 66 8B 78 16 66 8B 91

asm changes:

004446FA     8B51 50            MOV EDX, [ECX+50]
004446FD     66:0150 10         ADD [EAX+10], DX  // % economic intel
00444701     8B51 54            MOV EDX, [ECX+54]
00444704     66:0150 12         ADD [EAX+12], DX  // % scientific intel

00444713     8B51 58            MOV EDX, [ECX+58]
00444716     66:0150 14         ADD [EAX+14], DX  // % military intel
0044471A     8BB1 98000000      MOV ESI, [ECX+98]
00444720     66:0170 04         ADD [EAX+4], SI  // % raiding
00444724     8B51 30            MOV EDX, [ECX+30]
00444727     66:0150 06         ADD [EAX+6], DX  // % industry
0044472B     90                 NOP

00444730     66:8B91 90000000   MOV DX, [ECX+90]  // % traderoute credits
:arrow: adapted & updated systInfo bonuses address-map

Code: Select all

trek.exe 0x18DA6C new address-map 0xB4 bytes:

00 00 04 00 08 00 0C 00 FF 02 28 00 2C 00 18 00 1C 00 20 00 38 00 40 00 44 00 10 00 14 00 48 00 FF 02 FF 02 FF 02 FF 02 8C 00 B8 00 60 00 64 00 68 00 6C 00 70 00 4C 00 74 00 78 00 B0 00 7C 00 AC 00 80 00 3C 00 50 00 FF 02 94 00 A4 00 98 00 88 00 90 00 A0 00 A8 01 BC 00 A8 00 14 01 5C 00 54 00 58 00 30 00 FF 02 FF 02 FF 02 FF 02 FF 02 FF 02 FF 02 FF 02 FF 02 FF 02 FF 02 FF 02 FF 02 FF 02 FF 02 FF 02 FF 02 FF 02 FF 02 FF 02 FF 02 FF 02 FF 02 FF 02 FF 02 FF 02 FF 02 FF 02 FF 02 FF 02 FF 02 FF 02 FF 02 FF 02 FF 02 FF 02 FF 02 FF 02 FF 02
:arrow: % intel total two-in-one bug & unlock % intel (local) fix

Code: Select all

trek.exe at 0x409BA change 3C -> 5C

004415B8     8B73 5C     MOV ESI, [EBX+5C] // local intel % bonus
:arrow: % research (local) fix

Code: Select all

trek.exe at 0x40ABC new code 0x17 bytes:

0F B7 41 44 03 43 1C 83 E8 64 89 04 24 DD 05 94 89 57 00 DB 04 24 90

asm code:
004416BC     0FB741 44       MOVZX EAX, WORD [ECX+44] // system morale
004416C0     0343 1C         ADD EAX, [EBX+1C]  // system %-bonus
004416C3     83E8 64         SUB EAX, 64
004416C6     890424          MOV [ESP], EAX
004416C9     DD05 94895700   FLD QWORD [578994]
004416CF     DB0424          FILD DWORD [ESP]
004416D2     90              NOP
Link to an updated edifbnft.bst file:
edifbnft.bst (english)


New output IDs to use in edifice.bst:
  • 0x2D = Industry (local static bonus)
    0x2E = % Shipbuilding
    0x2F = % intel (local)
    0x30 = % scientific intel
    0x31 = % military intel
    0x32 = % industry empire-wide
To-Do:
  • % raiding (empire wide)
Last edited by Spocks-cuddly-tribble on Thu Dec 22, 2011 8:15 pm, edited 2 times in total.
On the verge of a nervous breakdown? Try the relaxing tribble sounds.

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

Re: Extending Edifbnft.bst (new building types/bonuses)

Post by thunderchero » Sun Dec 11, 2011 11:29 am

Very sweet,

I have wanted these bonus types working for a long time. I will be checking this out later today.

great job SCT

Off topic question
Btw how is the minor building bug fix (no structures when membering) going that is still a very needed fix. :wink:

thunderchero

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

Re: Extending Edifbnft.bst (new building types/bonuses)

Post by Spocks-cuddly-tribble » Sun Dec 11, 2011 1:10 pm

Note that you'll need all 6 codes from this topic (just the address map in post 3 replaces that from post2).

@ Minor buidings fix - Yes, should be more important than %raiding & main research/intel bonuses. So I'll do this next.
On the verge of a nervous breakdown? Try the relaxing tribble sounds.

User avatar
Tethys
Past Administrator
Past Administrator
Posts: 2065
Joined: Fri Jul 18, 2008 2:00 am
Location: Your mom's bed ;)
Contact:

Re: Controlling the bonus positions in systInfo

Post by Tethys » Tue Dec 20, 2011 9:56 pm

Spocks-cuddly-tribble wrote: Next is an adapted and cleaned up vanilla address-map (unneeded outputs get ignored, local morale bonuses share address[+8C]). It also unlocks the unused local static industry bonus for output ID 45 /0x2D i.e. new entry 46 in edifbnft.bst should be " Industry" (strings without % start with a space) and local "% Shipbuilding" for output ID 0x2E i.e. new entry 47. :)

Note: Albeit the shipbuilding bonus preview-bug has been fixed (i.e. preview screen shows updated industry output when turning on/off building (or scrapping), there is still the Build Queue update bug i.e. old bonuses until re-entering screen or changing worker/energy settings (cf. 'Dilithium Shortage' warning).

Code: Select all

trek.exe 0x18DA6C new address-map 0xB4 bytes:

00 00 04 00 08 00 0C 00 FF 02 28 00 2C 00 18 00 1C 00 20 00 38 00 40 00 44 00 10 00 14 00 48 00 FF 02 FF 02 FF 02 FF 02 8C 00 B8 00 60 00 64 00 68 00 6C 00 70 00 4C 00 74 00 78 00 B0 00 7C 00 AC 00 80 00 3C 00 50 00 FF 02 FF 02 FF 02 98 00 88 00 90 00 A0 00 A8 01 BC 00 A8 00 14 01 FF 02 FF 02 FF 02 FF 02 FF 02 FF 02 FF 02 FF 02 FF 02 FF 02 FF 02 FF 02 FF 02 FF 02 FF 02 FF 02 FF 02 FF 02 FF 02 FF 02 FF 02 FF 02 FF 02 FF 02 FF 02 FF 02 FF 02 FF 02 FF 02 FF 02 FF 02 FF 02 FF 02 FF 02 FF 02 FF 02 FF 02 FF 02 FF 02 FF 02 FF 02 FF 02 FF 02
First byte of each entry is postion (unsigned) second byte the switch marker (signed): 0=store, 1=for ship construction only, 2=ignore. Ignored output types use FF 02 with the FF being pointless.

Output indexes are same as in edifbnft.bst (see above) i.e. entry postion = output ID * 2.
SCT upon testing this you accidentally disabled #38 energy.

@ 0x18DAB8

a4 00

I will let you know if I find other working ones you may have accidentally disabled.
Not for the weak of heart...
Image
GALM <--- GALM/Galaxies Mod

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

Re: Extending Edifbnft.bst (new building types/bonuses)

Post by Spocks-cuddly-tribble » Thu Dec 22, 2011 7:09 am

I've corrected both address tables.

Thank you very much and good work with investigating the solution. :)
On the verge of a nervous breakdown? Try the relaxing tribble sounds.

User avatar
Tethys
Past Administrator
Past Administrator
Posts: 2065
Joined: Fri Jul 18, 2008 2:00 am
Location: Your mom's bed ;)
Contact:

Re: Extending Edifbnft.bst (new building types/bonuses)

Post by Tethys » Thu Dec 22, 2011 4:37 pm

These are all the ones disabled using your updated table and vanilla edifbnft file (for reference):

4: Credits @ 18DA74

16: Ship Experience @ 18DA8C

17: Anti Ship Defense @ 18DA8E

18: Builds Ships @ 18DA90

19: Shield per energy tech @ 18DA92

36: Morale @ 18DAB4

37: % Ground defense @ 18DAB6

38: Energy (now fixed)

From testing, the Ship Experience still works with it disabled in the new table, but are we sure 36: and 37: need to be disabled as well?
Not for the weak of heart...
Image
GALM <--- GALM/Galaxies Mod

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

Re: Extending Edifbnft.bst (new building types/bonuses)

Post by thunderchero » Thu Dec 22, 2011 4:46 pm

Tethys wrote:These are all the ones disabled using your updated table and vanilla edifbnft file (for reference):
I have not done any testing on this project yet but shouldn't you be using the edited edifbnft.bst SCT uploaded?
Spocks-cuddly-tribble wrote:Link to an updated edifbnft.bst file:
http://www.file-upload.net/download-394 ... e.bst.html :idea:
thunderchero

User avatar
Tethys
Past Administrator
Past Administrator
Posts: 2065
Joined: Fri Jul 18, 2008 2:00 am
Location: Your mom's bed ;)
Contact:

Re: Extending Edifbnft.bst (new building types/bonuses)

Post by Tethys » Thu Dec 22, 2011 4:51 pm

The only difference between the 2 are the added bonuses near the "end".
SCT wrote:Missing:
  • % industry empire-wide
    Industry (local static bonus)
    % intel (local)
    % scientific intel
    % military intel
    % Shipbuilding
Since I was only concerned about vanilla bonuses that may have been turned off by accident, logic took over. :wink:
Not for the weak of heart...
Image
GALM <--- GALM/Galaxies Mod

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

Re: Extending Edifbnft.bst (new building types/bonuses)

Post by Spocks-cuddly-tribble » Thu Dec 22, 2011 8:11 pm

Tethys wrote:are we sure 36: and 37: need to be disabled as well?
#36 are unrest orders (see above)

#37 is a local military output i.e. should not be read from systInfo. However, BotF has some bugs and you just disclosed one of them:
Gowron wrote:2. Ground Combat Values

Say, Tamara has a current pop of 300 and a ground combat strength of 513. You divide 513 by 300 and the result by 0.9 (Tamarian ground combat value)...you get 1.9 as the result
viewtopic.php?f=9&t=56

Updating both address maps 0x18DAB4 -> 94 00

Minor fixes to-do list: Bunker network value to [systInfo+154h & +214h]. The minors will be very happy about your question. :wink:

Also "scan range" is not tested, thus still in systInfo.
On the verge of a nervous breakdown? Try the relaxing tribble sounds.

User avatar
Tethys
Past Administrator
Past Administrator
Posts: 2065
Joined: Fri Jul 18, 2008 2:00 am
Location: Your mom's bed ;)
Contact:

Re: Extending Edifbnft.bst (new building types/bonuses)

Post by Tethys » Mon Feb 11, 2013 8:28 pm

How do Outpost/Starbase/Shipyards give ships range? And can the value be manipulated to provide greater ranges for different instances, such as +1 range for Outpost and +2 for Starbase? Can the value be separated for an entirely new building type (for a planetside Starbase, we would use something like +Ground Defense and a passive bonus to range, like a Shipyard does +Build ships with passive range applied)

Any information you or anyone could provide would be useful even if its ASM and underdeveloped. I am quite curious as to how I would go about creating new bonus types as well.
Not for the weak of heart...
Image
GALM <--- GALM/Galaxies Mod

User avatar
EnPhreg
Lieutenant-Commander
Lieutenant-Commander
Posts: 130
Joined: Thu Jul 10, 2008 2:00 am

Re: Extending Edifbnft.bst (new building types/bonuses)

Post by EnPhreg » Sun Sep 25, 2016 8:42 am

if i want to adapt the edifbnft.bst for german language, how i will do that?

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

Re: Extending Edifbnft.bst (new building types/bonuses)

Post by thunderchero » Sun Sep 25, 2016 9:30 am

EnPhreg wrote:if i want to adapt the edifbnft.bst for german language, how i will do that?
make code changes SCT posted above, then add english edifbnft.bst and use UE to edit/translate bonus type descriptions. That should be all that is needed.

User avatar
EnPhreg
Lieutenant-Commander
Lieutenant-Commander
Posts: 130
Joined: Thu Jul 10, 2008 2:00 am

Re: Extending Edifbnft.bst (new building types/bonuses)

Post by EnPhreg » Sun Sep 25, 2016 9:50 am

yes, this should work :)

one concept i didn't understand is the effect of the 'bonus to unrest threshold' for buidlings. what effect has a positive or negative value?

Post Reply

Return to “edifbnft.bst (building bonus types)”

Who is online

Users browsing this forum: No registered users