1
Scripting and Reverse Engineering / Re: Physical Accuracy Formula - 005DDBB0
« on: 2025-08-27 01:41:31 »
Here is the same function in C code, hope it helps:
Code: [Select]
//[0x00](callback)
void C_005DDBB0() {
struct {//x2c
struct t_temp_044 *local_11_unused;
int local_10;
struct t_temp_044 *local_9_unused;
int local_8;
int local_7;
struct t_battle_local_68 *local_6;
int dw100Roll;//local_5
int local_4;
struct t_battle_local_68 *local_3_unused;
int dwLuckRoll;//local_2
int dwProbability;//local_1
}lolo;
lolo.local_11_unused = &(D_009A8B10.f_0000[D_0099CE0C->f_000]);
lolo.local_9_unused = &(D_009A8B10.f_0000[D_0099CE0C->f_208]);
lolo.local_6 = &(D_009AB0A0.f_03c[D_0099CE0C->f_000]);
lolo.local_3_unused = &(D_009AB0A0.f_03c[D_0099CE0C->f_208]);
//-- --
C_005DE356();
//-- --
lolo.dwProbability = -1;
//-- check some status/flags --
//(no miss)
if(D_0099CE0C->f_234 & BIT(0))
lolo.dwProbability = 255;
if(D_0099CE0C->f_230 & (BIT(6) | BIT(5) | BIT(1) | BIT(0)))
lolo.dwProbability = 255;
if(D_0099CE0C->f_228 & (BIT(25) | BIT(22) | BIT(14) | BIT(10) | BIT(6) | BIT(2) | BIT(0))) {//else 005DDCF7
if(D_0099CE0C->f_228 & BIT(2))
D_0099CE0C->f_238[1] |= BIT(2);
if(D_0099CE0C->f_228 & BIT(6))
D_0099CE0C->f_238[1] |= BIT(6);
if(D_0099CE0C->f_228 & BIT(22))
D_0099CE0C->f_238[1] |= BIT(22);
lolo.dwProbability = 255;
}
if(D_0099CE0C->f_218 & BIT(5))
lolo.dwProbability = 255;
//-- attack probability --
lolo.local_4 = C_005C7EB3(D_0099CE0C->f_000, lolo.local_6->bDexterity, 5/*speed?*/);//apply modifier to attribute
lolo.local_10 = D_0099CE0C->f_260 + lolo.local_4 / 4;
lolo.local_8 = C_005DE2F1(D_0099CE0C->f_000);//compute evasion parameter?
lolo.local_7 = C_005DE2F1(D_0099CE0C->f_208);//compute evasion parameter?
if(lolo.dwProbability == -1) {
lolo.dwProbability = lolo.local_10 + lolo.local_8 - lolo.local_7;
lolo.dwProbability = C_005DE582(lolo.dwProbability);
}
if(lolo.dwProbability <= 0)
lolo.dwProbability = 1;
//-- Luck test --
lolo.dwLuckRoll = C_005C8BDC(100);//Battle.random:get unsigned char(with max)?
if(lolo.dwLuckRoll < D_009AB0A0.f_03c[D_0099CE0C->f_000].bLuck / 4)
lolo.dwProbability = 255;
else if(D_0099CE0C->f_000 >= 4 && D_0099CE0C->f_208 < 3 && lolo.dwLuckRoll < D_009AB0A0.f_03c[D_0099CE0C->f_208].bLuck / 4)
lolo.dwProbability = 0;
//-- --
lolo.dw100Roll = C_005D1924();//...:get random percentage?
if(lolo.dw100Roll < lolo.dwProbability)
C_005DE53B();
else
D_0099CE0C->f_218 |= BIT(0);
}