You must be logged in to post messages.
Please login or register

Modpack Discussion
Moderated by Crazed Ewok, Gen_Rhys_Dallows

Hop to:    
Welcome! You are not logged in. Please Login or Register.2 replies
SWGB Heaven » Forums » Modpack Discussion » dynamic accuracy vs. air units
Bottom
Topic Subject:dynamic accuracy vs. air units
UBR365K
Clone Trooper
posted 09-12-19 07:57 AM EDT (US)         
I want my land units to be able to shoot at aircraft, but don't want them dropping air units too fast, after some IDA probing, i think i got some useful & reliable unit data offsets:

aat oom9; cls34; building; 4x attack type
e60[+18]=id1
f8c/+144=rng max
f9e/+156=accu
fb6/+16e:shown atk?
fb8/+170=rng shown
fbc/+174=rld shown

hvy aa tf; cls55; unit; 3x attack type
c60[+18]=id1 ;word
d8c/+144=rng max ;float
d9e/+156=accu ;word?
db6/+16e:shown atk? ;word
db8/+170=rng shown ;float
dbc/+174=rld shown ;float

shown_reload_time seems quite redudunt.

Enter the EXE editing, the Ewok ID code section is conviniently called whenever an unit's AI decide to attack(EF ground-2-air.txt also attached here), so I wrote a branching code in place, long story short:

1. I genie'd units data, and store their accuracy actually to "shown reload time"
2. In game when a land unit's AI want to attack another unit, it'll check if another unit is air or land
3. If the land unit is attacking an air unit, first to be able to shoot at air it have to more than 6 range, and is not a grenedier/artillery etc.
4. Then the land unit reads "shown reload time", minus 10 then divide 5 then stored to accuracy. It'll miss a lot
5. If it's attacking another non-air unit, it reads from "shown reload time" and store back to accuracy without change.

results so far looking good




-----------------------------------------

problem:
1. it's not 100% reliable, in rare occasion accuracy may trickle if many air/land units are around.
I think either the attacker's AI can examine another unit other than it's target? or the game only check accuracy on interval?

2. "shown reload time" is not affected by tech. Though there aren't many land units accuracy tech to begin with.

3. It's known AOK/SWGB calculating a primary projectile's damage etc. on the instant it hits the target, so changing target could affect projectile-on-the-way data. Spread wont be affected though.

Wanna check if range and secondary projectile ID can be modified in same fashion, then I can have an X-Wing shooting laser at fighter, shooting torp at buildings, without any unit-changing-shenanigan. That'll be cool!


------------------------------------------------

here the crude test code:

.rsrc:007B8020 tvar_1 dd 41200000h ; DATA XREF: .rsrc:007B8154r
.rsrc:007B8024 tvar_2 dd 40A00000h ; DATA XREF: .rsrc:007B815Ar
.rsrc:007B8030 ; ---------------------------------------------------------------------------
.rsrc:007B8030
.rsrc:007B8030 unable_to_attack: ; CODE XREF: .rsrc:007B80D1j
.rsrc:007B8030 ; .rsrc:007B80DAj ...
.rsrc:007B8030 pop ecx
.rsrc:007B8031 jmp loc_41C6EB ; jumptable 0041C66C default case
.rsrc:007B8031 ; ---------------------------------------------------------------------------
.rsrc:007B8040 ; ---------------------------------------------------------------------------
.rsrc:007B8040
.rsrc:007B8040 able_to_attack: ; CODE XREF: .rsrc:007B8107j
.rsrc:007B8040 ; .rsrc:007B8110j ...
.rsrc:007B8040 pop ecx
.rsrc:007B8041 jmp loc_41C6E1 ; jumptable 0041C66C cases 3,15
.rsrc:007B8041 ; ---------------------------------------------------------------------------
.rsrc:007B8050 ; ---------------------------------------------------------------------------
.rsrc:007B8050
.rsrc:007B8050 skip_next_line: ; CODE XREF: .rsrc:007B81CCj
.rsrc:007B8050 ; .rsrc:007B81D5j ...
.rsrc:007B8050 pop ecx
.rsrc:007B8051 jmp loc_41C59A
.rsrc:007B8051 ; ---------------------------------------------------------------------------
.rsrc:007B805F ; ---------------------------------------------------------------------------
.rsrc:007B805F
.rsrc:007B805F loc_7B805F: ; CODE XREF: AA+5Fj
.rsrc:007B805F push ecx
.rsrc:007B8060 mov ecx, [edx+1Eh]
.rsrc:007B8063 cmp cl, 30h ; target: fighter
.rsrc:007B8066 jz target_air_check_l
.rsrc:007B806C cmp cl, 2Bh ; target: bomber
.rsrc:007B806F jz target_air_check_l
.rsrc:007B8075 cmp cl, 3Bh ; target: air transport
.rsrc:007B8078 jz target_air_check_l
.rsrc:007B807E cmp cl, 3Eh ; target: air cruiser
.rsrc:007B8081 jz target_air_check_l
.rsrc:007B8087 cmp cl, 3Fh ; target: geonosian warrior
.rsrc:007B808A jz target_air_check_l
.rsrc:007B8090 cmp cl, 40h ; target: jedi starfighter
.rsrc:007B8093 jnz target_is_land ; not all above
.rsrc:007B8099
.rsrc:007B8099 target_air_check_l: ; CODE XREF: .rsrc:007B8066j
.rsrc:007B8099 ; .rsrc:007B806Fj ...
.rsrc:007B8099 mov ecx, [eax+1Eh]
.rsrc:007B809C cmp cl, 30h ; Ima fighter
.rsrc:007B809F jz air_special
.rsrc:007B80A5 cmp cl, 2Bh ; Ima bomber
.rsrc:007B80A8 jz air_special
.rsrc:007B80AE cmp cl, 3Bh ; Ima air trans
.rsrc:007B80B1 jz air_special
.rsrc:007B80B7 cmp cl, 3Eh ; Ima air cruiz
.rsrc:007B80BA jz air_special
.rsrc:007B80C0 cmp cl, 3Fh ; Ima geonosian warrior: considered land units when attacking air
.rsrc:007B80C3 jz short check_range
.rsrc:007B80C5 cmp cl, 40h ; Ima jedi starfighter
.rsrc:007B80C8 jz air_special
.rsrc:007B80CE cmp cl, 3Ah ; vil
.rsrc:007B80D1 jz unable_to_attack
.rsrc:007B80D7 cmp cl, 31h ; grenedier
.rsrc:007B80DA jz unable_to_attack
.rsrc:007B80E0 cmp cl, 20h ; artillery
.rsrc:007B80E3 jz unable_to_attack
.rsrc:007B80E9 cmp cl, 0Bh ; cruiser
.rsrc:007B80EC jz unable_to_attack
.rsrc:007B80F2 cmp cl, 22h ; undeployed cannon
.rsrc:007B80F5 jz treb_special
.rsrc:007B80FB cmp cl, 24h ; cannon
.rsrc:007B80FE jz treb_special
.rsrc:007B8104 cmp cl, 37h ; aa trooper
.rsrc:007B8107 jz able_to_attack
.rsrc:007B810D cmp cl, 9 ; aa tower
.rsrc:007B8110 jz able_to_attack
.rsrc:007B8116 cmp cl, 10h ; aa
.rsrc:007B8119 jz able_to_attack
.rsrc:007B811F cmp cl, 28h ; aa
.rsrc:007B8122 jz able_to_attack
.rsrc:007B8128 cmp cl, 21h ; aa
.rsrc:007B812B jz able_to_attack
.rsrc:007B8131
.rsrc:007B8131 check_range: ; CODE XREF: .rsrc:007B80C3j
.rsrc:007B8131 push edx
.rsrc:007B8132 fld dword ptr [eax+144h] ; load unit data: range
.rsrc:007B8138 push edx ; float->int shenanigans
.rsrc:007B8139 push eax
.rsrc:007B813A call __ftol
.rsrc:007B813F mov ecx, eax
.rsrc:007B8141 pop eax
.rsrc:007B8142 pop edx
.rsrc:007B8143 cmp ecx, 6 ; minimum 6 to shoot air
.rsrc:007B8146 pop edx
.rsrc:007B8147 jl unable_to_attack
.rsrc:007B814D
.rsrc:007B814D swap_accuracy_aa:
.rsrc:007B814D push edx
.rsrc:007B814E fld dword ptr [eax+174h] ; load unit data: shown_reload_time
.rsrc:007B8154 fsub ds:tvar_1 ; -10
.rsrc:007B815A fdiv ds:tvar_2 ; /5
.rsrc:007B8160
.rsrc:007B8160 target_is_land2:
.rsrc:007B8160 push edx
.rsrc:007B8161 push eax
.rsrc:007B8162 call __ftol
.rsrc:007B8167 mov ecx, eax
.rsrc:007B8169 pop eax
.rsrc:007B816A pop edx
.rsrc:007B816B cmp ecx, 1 ; minimum 1
.rsrc:007B816E jge short loc_7B8175 ; maximum 100
.rsrc:007B8170 xor ecx, ecx
.rsrc:007B8172 inc ecx
.rsrc:007B8173 nop
.rsrc:007B8174 nop
.rsrc:007B8175
.rsrc:007B8175 loc_7B8175: ; CODE XREF: .rsrc:007B816Ej
.rsrc:007B8175 cmp ecx, 64h ; maximum 100
.rsrc:007B8178 jle short loc_7B817F ; write unit data: accuracy
.rsrc:007B817A
.rsrc:007B817A loc_7B817A:
.rsrc:007B817A mov ecx, 64h
.rsrc:007B817F
.rsrc:007B817F loc_7B817F: ; CODE XREF: .rsrc:007B8178j
.rsrc:007B817F mov [eax+156h], cx ; write unit data: accuracy
.rsrc:007B8186 pop edx
.rsrc:007B8187 jmp able_to_attack
.rsrc:007B8187 ; ---------------------------------------------------------------------------
.rsrc:007B818C db 0
.rsrc:007B818D db 0
.rsrc:007B818E db 0
.rsrc:007B818F db 0
.rsrc:007B8190 ; ---------------------------------------------------------------------------
.rsrc:007B8190
.rsrc:007B8190 target_is_land: ; CODE XREF: .rsrc:007B8093j
.rsrc:007B8190 mov ecx, [eax+1Eh]
.rsrc:007B8193 cmp cl, 30h
.rsrc:007B8196 jz air_special
.rsrc:007B819C cmp cl, 2Bh
.rsrc:007B819F jz air_special
.rsrc:007B81A5 cmp cl, 3Bh
.rsrc:007B81A8 jz air_special
.rsrc:007B81AE cmp cl, 3Eh
.rsrc:007B81B1 jz air_special
.rsrc:007B81B7 cmp cl, 3Fh
.rsrc:007B81BA jz air_special
.rsrc:007B81C0 cmp cl, 40h
.rsrc:007B81C3 jz air_special
.rsrc:007B81C9 cmp cl, 3Ah
.rsrc:007B81CC jz skip_next_line
.rsrc:007B81D2 cmp cl, 31h
.rsrc:007B81D5 jz skip_next_line
.rsrc:007B81DB cmp cl, 20h
.rsrc:007B81DE jz skip_next_line
.rsrc:007B81E4 cmp cl, 0Bh
.rsrc:007B81E7 jz skip_next_line
.rsrc:007B81ED cmp cl, 22h
.rsrc:007B81F0 jz treb_special
.rsrc:007B81F6 cmp cl, 24h
.rsrc:007B81F9 jz treb_special
.rsrc:007B81FF cmp cl, 9
.rsrc:007B8202 jz skip_next_line
.rsrc:007B8208 cmp cl, 28h
.rsrc:007B820B jz skip_next_line
.rsrc:007B8211 cmp cl, 21h
.rsrc:007B8214 jz skip_next_line
.rsrc:007B821A cmp cl, 10h
.rsrc:007B821D jz skip_next_line
.rsrc:007B8223 cmp cl, 37h
.rsrc:007B8226 jz skip_next_line
.rsrc:007B822C push edx
.rsrc:007B822D fld dword ptr [eax+174h]
.rsrc:007B8233 push edx
.rsrc:007B8234 push eax
.rsrc:007B8235 call __ftol
.rsrc:007B823A mov ecx, eax
.rsrc:007B823C pop eax
.rsrc:007B823D pop edx
.rsrc:007B823E cmp ecx, 1
.rsrc:007B8241 jge short loc_7B8248
.rsrc:007B8243 xor ecx, ecx
.rsrc:007B8245 inc ecx
.rsrc:007B8246 nop
.rsrc:007B8247 nop
.rsrc:007B8248
.rsrc:007B8248 loc_7B8248: ; CODE XREF: .rsrc:007B8241j
.rsrc:007B8248 cmp ecx, 64h
.rsrc:007B824B jle short loc_7B8252
.rsrc:007B824D
.rsrc:007B824D loc_7B824D:
.rsrc:007B824D mov ecx, 64h
.rsrc:007B8252
.rsrc:007B8252 loc_7B8252: ; CODE XREF: .rsrc:007B824Bj
.rsrc:007B8252 mov [eax+156h], cx
.rsrc:007B8259 pop edx
.rsrc:007B825A jmp able_to_attack
.rsrc:007B825A ; ---------------------------------------------------------------------------
.rsrc:007B825F db 0
.rsrc:007B8260 ; ---------------------------------------------------------------------------
.rsrc:007B8260
.rsrc:007B8260 treb_special: ; CODE XREF: .rsrc:007B80F5j
.rsrc:007B8260 ; .rsrc:007B80FEj ...
.rsrc:007B8260 jmp able_to_attack
.rsrc:007B8260 ; ---------------------------------------------------------------------------
.rsrc:007B8300 ; ---------------------------------------------------------------------------
.rsrc:007B8300
.rsrc:007B8300 air_special: ; CODE XREF: .rsrc:007B809Fj
.rsrc:007B8300 ; .rsrc:007B80A8j ...
.rsrc:007B8300 jmp able_to_attack
.rsrc:007B8300 ; ---------------------------------------------------------------------------

[This message has been edited by UBR365K (edited 09-12-2019 @ 08:14 AM).]

AuthorReplies:
rva2895
Clone Trooper
posted 09-12-19 11:12 AM EDT (US)     1 / 2       
You should not modify the property object in run time like that because it is shared by multiple units of the same type. You'll experience a race condition mess.
I suggest you join the Expanding Fronts Discord server if you want to discuss EXE editing.
UBR365K
Clone Trooper
posted 09-12-19 11:59 AM EDT (US)     2 / 2       
shoot, thought they're individual unit data, turns out it's shared
You must be logged in to post messages.
Please login or register

Hop to:    

SWGB Heaven | HeavenGames