Thus, as a 'homage' to Gowron's posts, the topic is divided in different sections: the explanation on how intel works, bugfixes and the technical stuff.Gowron wrote:1. How does intel work, exactly?
2. How does the game determine the outcome of an invasion attempt? (click)
3. How does the game determine which empire may claim which sector? (click)
4. How is the actual impact of a Shield Generator calculated (given its output value)? (click)
5. How are the score and the powergraph generated at the end of the game? (click)
1. The Intricate Paths of Intel (descriptive section)
Details on the Intel Management Screen and what they represent.
Area sliders for Security; Espionage and Sabotage for up to 4 opponents:
- area stockpile for attack frequency (unless security)
- last 20 turn area outputs after bonuses for attack/defense success chance
- building bonus bug => bonuses read all sliders = 100% (unless 0%)
- select department odds (range 1-30) if button +2 per turn (all other -2/turn, 'general' +2 all)
- no own output or stockpile points
- building bonuses broken (see Economic Intel)
1.1 Attack frequency
Each turn there can be up to 1 attack per intel area i.e. 8 attacks max. [(espionage+sabotage) * 4 opponents], but due to the 'blame' attack-delay, the theoretical maximum is 16.
Area stockpile points get increased by the area output after bonuses each turn and reset to 0 after attacks.
Stockpile decay for 0 % area sliders = (total intel output * 0.02 ; minimum value 0).
The attack threshold (vs. the area stockpile points) is calculated that way:
1+[last area attack turnNumber]% * espionage/sabotage base delay [intelInfo+4/+18] * treaty label modifier [intelInfo+4C]%
(Espionage/Sabotage Base Delay) is an interim result = intel.bin base multiplier * enemy empire & difficulty level %-modifier
No attack this turn if stockpile points lower than attack threshold (not to confuse with nothing happens due to a failure, cf. #1.2).
The attack frequency easily can be adjusted via intel.bin (Ultimate Editor ), looking at the defaults we notice that:
- the espionage base delay is lower than sabotage base delay (it's reasonable)
- the attack threshold increases with the difficulty level i.e. on simple ~3* more attacks than on impossible (Bias should depend on own starting era)
-> so next multiplayer if you're card/rom and the opponents fed/kling suggest 'simple' and they will cry - e.g. romulan values are better than the cardassian's
- using [empsInfo+110h] treaty-label is quite imprecise (peace means here all non-alliance treaties)
1.2 Success chance of intel attacks
Depends on:
- Random value with a range of 0-99
- Security vs. attack-strength calculation (result range -50 to +50)
- Computer tech level of attacker minus defender
- AI vs. player attack/defense bonuses on 'Hard' & 'Impossible'
Security vs. attack-strength calculation:
[last 20 turns espionage + sabotage area outputs vs enemy /20]
-divided by-
[(last 20 turns security outputs /20) + (security stockpile * 0.02)] * [intel.bin+30h] security morale modifier%
Turn output of zero percent sliders/areas = [total intel output * -0.02 ; 0 for unknown opponents]
Security Stockpile = ([old stockpile * turn number] + current security output) / (turn number+1); min 0
AI Security Output Bonus: (unused) group ID 17h not given (wildcard for random minor race intel)
For difficulty levels 1-5: 0/ 0.5/ 1/ 2/ 3 * systems held * race output of for current tech available group ID 0x17 structure in edifice.bst
Result after the attack/security strength division (3 cases):
- if 1 (equal) = 0
- if greater 1 (attacker stronger) = [result -1] * 15 ; max 50
- if lower 1 (security stronger) = [-1/result +1] * 15 ; min -50
=> effect-limit at the ratio of 4 + 1/3 to 1
- Attack = systems held [*2.5], max bonus 15 [25]
- Defense = lower amount of (atk result *0.5 [*0.7], min15 [25]) or systems held [*2.5]
Due to a bug, the chance to blame an other empire is always ~30% i.e. for success values 0-4.
Let's get this straight:
- Security effectiveness exceeds the attacker's by +0.02 * stockpile (+/- the morale modifier). This is reasonable, since security must be stronger in order to be effective. Also the security strength is not affected by the (up to 7!) attacks defended earlier that turn.
- Unlike the frequency, the attack value also utilizes outputs of the area-counterparts i.e. sabotage attacks benefit from espionage output and vice versa! This means also e.g. espionage 0% reduces the sabotage attack base value (-2% of intel total output, see above), and it doubles the effect of the area bonus bug if buildings do affect both areas.
- Fewer attack messages are not always inferior, since failure(nothing happens) is a better result than a fiasco report.
The Always-100% Area-Bonus Bug (unless area slider = 0%)
If one has e.g. the Betazoid +50% security bonus and the security slider is set to 40% then the security output should be 60% of total intel output [40% +(50% of 40%)]. But due to a calculation error it's in fact 90% [40% +(50% of 100%)]. This unbalances the whole intel mechanism with disastrous ramifications. A simplified example using vanilla, T8, turn1 maximum intel total outputs:
Maximum 'for-free' attack strength vs. enemy security: (the 'activating' 1%+ per area go extra)
- Card 30%(intel total)*2 of 2362 = 1417 (vs. up to 4 opponents = +240%, including espionage attacks even +480%)
- Rom 25%(general intelligence)*2 of 3031 = 1515
- Card 30%(intel total) of 2362 = +708 per turn
- Rom 25%(general intelligence) of 3031 = +757 per turn
1.3 Department selection (before success check)
To determine the department actually used, a random value with a range of 0 - [(sum of all 4 department training values) -1] gets created. Then BotF cumulates the training values (in order of department IDs: 0-general, 1-economy, 2-science, 3-military) and selects the last added department, once the random value is lower than this result.
For unknown opponents the current department training status (range 1-30) can be calculated according to [turn number * 2] -1 i.e. on turn 16 all departments have reached max value 30. This is due to 'general' being default setting and the 'general' works for all feature (see above).
- the favored department button should be always set after first contact (intension to use intel doesn't matter, just in case...)
1.4 Intel events
There's yet no in-depth analysis of all intel events, but as an example, the destroyed/stolen credits reach up to 40% of credits total (a bit overdone), with an extra AI protection on difficulty level 3+ of amount / [difficulty level -1].
2. Bug-Fixes (sorted by priority)
2.1 Always-100% Intel-Area-Bonus Bug-fix
Code: Select all
trek.exe at 0x7D4A8 new code 0x11 bytes:
83 C0 64 89 6C 24 04 89 04 24 DF 2C 24 DE CA DE C9
asm changes:
0047E0A8 83C0 64 ADD EAX,64 // base bonus level 100%
0047E0B7 DEC9 FMULP ST(1),ST // area output * bonus level
The using of empire starting era corrects the bias (fixes mainly too little intel action during low-tech eras).
Code: Select all
trek.exe at 0x7D9EB new code 0x17 bytes:
89 44 24 70 0F B6 83 2C 2B 5A 00 69 DB 1C 2C 00 00 DB 44 24 70 D8 C9
asm changes: (aside of 47E5EF just position changes)
0047E5EB 894424 70 MOV [ESP+70], EAX
0047E5EF 0FB683 2C2B5A00 MOVZX EAX, BYTE [EBX+5A2B2C] // empire starting era
0047E5F6 69DB 1C2C0000 IMUL EBX, 2C1C
0047E5FC DB4424 70 FILD DWORD [ESP+70]
0047E600 D8C9 FMUL ST, ST(1)
Following code increases the attack strength of the departments, not attack frequency or select department odds!
Code: Select all
trek.exe at 0x7C6E2 new code 0x114 bytes:
89 54 24 78 8B 35 54 4D 5C 00 85 F6 74 16 0F B6 84 24 BC 00 00 00 69 C0 BC 01 00 00 0F B7 B4 70 9C 1B 5B 00 83 C6 64 0F B6 94 24 B8 00 00 00 69 DA 1C 2C 00 00 69 C2 BC 01 00 00 90 05 98 1A 5B 00 8B 80 B6 00 00 00 C1 F8 10 81 C3 EC 3A 5A 00 83 C0 04 31 D2 66 89 84 24 B0 00 00 00 89 D8 8D 4B 50 03 90 AC 00 00 00 83 C0 04 90 90 39 C8 75 F1 B9 14 00 00 00 89 D0 C1 FA 1F F7 F9 DB 83 A8 00 00 00 DC 0D 44 BD 57 00 89 84 24 A8 00 00 00 DB 84 24 A8 00 00 00 8B 84 24 AE 00 00 00 DE C1 C1 F8 10 E8 4A 03 0A 00 DB 9C 24 9C 00 00 00 DB 44 83 2C 8B 84 24 9C 00 00 00 DC 0D 4C BD 57 00 89 84 24 A8 00 00 00 DB 84 24 A8 00 00 00 DE C9 E8 1D 03 0A 00 DB 9C 24 9C 00 00 00 83 BC 24 9C 00 00 00 00 0F 8E 43 03 00 00 DB 44 24 78 89 74 24 78 DB 44 24 78 DE C9 DC 0D 64 AC 57 00 E8 EF 02 0A 00 DB 84 24 9C 00 00 00 90 90 90 90 90 90 90 90 90 90
code changes:
0047D2E2 895424 78 MOV [ESP+78], EDX // attack value
0047D2E6 8B35 544D5C00 MOV ESI, [5C4D54] // department 0-3
0047D2EC 85F6 TEST ESI, ESI // if general...
0047D2EE 74 16 JE SHORT 47D306 // ...skip bonus check
0047D2F0 0FB68424 BC000000 MOVZX EAX, BYTE [ESP+BC] // attacker ID
0047D2F8 69C0 BC010000 IMUL EAX,EAX,1BC // empsInfo block
0047D2FE 0FB7B470 9C1B5B00 MOVZX ESI, WORD [EAX+ESI*2+5B1B9C] // department bonus
0047D306 83C6 64 ADD ESI, 64 // add nominal level 100%
0047D309 0FB69424 B8000000 MOVZX EDX, BYTE [ESP+B8] // defender ID
0047D311 69DA 1C2C0000 IMUL EBX,EDX,2C1C // intelInfo block
0047D317 69C2 BC010000 IMUL EAX,EDX,1BC // empsInfo block
0047D31D 90 NOP
0047D344 0390 AC000000 ADD EDX, [EAX+AC] // security output
0047D34D 9090 NOP
0047D3CC DB4424 78 FILD DWORD [ESP+78] // load attack value
0047D3D0 897424 78 MOV [ESP+78], ESI // 100 + department bonus%
0047D3D4 DB4424 78 FILD DWORD [ESP+78] // load bonus factor
0047D3D8 DEC9 FMULP ST(1), ST // attack value * bonus factor
0047D3DA DC0D 64AC5700 FMUL QWORD [57AC64] // * 0.0005 (share system attack multiplier at 0x17A864)
0047D3E0 E8 EF020A00 CALL 51D6D4 // round down
0047D3E5 DB8424 9C000000 FILD DWORD [ESP+9C] // load security value
0047D3EC-47D3F5 90 NOP
Note: Scientific- & Military Intel still must be unlocked in the systInfo code, but this will go into another topic that will feature fixes for many building output bugs & broken output types, including the % intel total (empire-wide & local) two-in-one bug: viewtopic.php?p=32866#p32866
2.4 Chance to Blame Others Always 30% Bug-fix
Code: Select all
trek.exe at 0x7CDFA new code 0x1D bytes:
7D 20 90 90 90 90 83 FA 28 7D 17 90 90 90 90 83 FA 32 7D 0E 90 90 90 90 83 FA 3C 7D 05
asm changes:
0047D9FA 7D 20 JGE SHORT 47DA1C // 70% fix
0047D9FC 90909090 NOP
0047DA03 7D 17 JGE SHORT 47DA1C // 60% fix
0047DA05 90909090 NOP
0047DA0C 7D 0E JGE SHORT 47DA1C // 50% fix
0047DA0E 90909090 NOP
0047DA15 7D 05 JGE SHORT 47DA1C // 40% fix
- Steal / destroy up to 40% of credits total workaround example:
Code: Select all
Credits total % jump tables:
for steal Credits - 4805B0
00480612 C1E8 02 SHR EAX, 2 // divide stolen credits by 2^2 (= 4)
00480615 9090 NOP
for destroy Credits - 4803A0
00480409 D1E8 SHR EAX, 1 // divide destroyed credits by 2
This option will always delete all reports. Fixing sub_4877A0 would be more elegant, but I doubt it's worth the effort.
Code: Select all
004877C8 8BC2 MOV EAX, EDX // i.e. at 0x86BC8 change 39 D0 -> 8B C2
2.6 Skip General Department Trains All Feature (no bug-fix and not recommended)
Code: Select all
0047DFF2 jnz loc_47E15D // jnz -> jmp 0x7D3F2 set 0F 85 to 90 E9
2.7 AI Security Output Bonus Fix (not recommended - default unused due to other AI cheats)
Code: Select all
0047D0A1 mov edx, 17h // 0x7C4A2 set main intel group ID (cards-roms 12-16h) as base for cheat (all AIs)
3. Structure of Intel.bin and sub_47F7D0 - IntelProcessTurn (in order of processing)
intel.bin (stbof.res) lenght 0x1E0 = 5 blocks 96byte/0x60 per empire card-rom (all integer dword / 4 bytes):
Code: Select all
+0 = base multiplier for espionage attack threshold
+4 = base multiplier for sabotage attack threshold
+8 * 5 enemy empires(own empire value unused) = % multiplier for attack threshold
+1C * 5 difficulty level = % multiplier for attack threshold (Attack frequency bias-fix = * 5 own starting eras)
+30h * 8 empsInfo morale labels = security % multiplier (written to intelInfo+2C)
+50h * 4 empsInfo treaty labels = attack threshold % multiplier (written to intelInfo+4C)
IntelProcessTurn (sub_47F7D0)
3.1 sub_47FC10 -> past turn 'blame' attacks (+ maybe the AI complaints / comments)
3.2 sub_47DF60 -> Update intel area output values, stockpile points & department odds (-> sub_47D074 AI security bonus)
3.3 loc_47F855: -> area attack loop (espionage / sabotage vs. 4 opponents)
3.3.1 sub_47DDC0 -> Attack frequency
3.3.2 sub_47D150 -> Get department (random)
3.3.4 sub_47D1D0 -> Attack success calculation (AI bonus: attack 47D48B, defense 47D524)
3.3.5 sub_ 47D9B4 -> Chance to blame an other empire
3.3.6 Area/department-events & fiasco-results
0047F7C0 = department switch table for events:
0-general -> sub_482020
1-economy -> sub_480DB0
2-science -> sub_484FB0
3-military -> sub_4840A0
sub_4820C4 fiasco results 5-9 (& effects on AI diplomacy?)
3.4 sub_47E2D0 -> Update intel empire status screen with espionage results (+ally data)
Not connected to sub_47DDC0, but related: sub_47E710 -> AI_empsInfo_Intel_bonuses_for? (not yet analysed)