Qhimm.com Forums
Miscellaneous Forums => Scripting and Reverse Engineering => Topic started by: DLPB_ on 2018-01-30 01:55:27
-
NFITC1 has done the rest, so gave him a little head start with this one. It's more or less complete aside from a few unknown flags and their function.
https://pastebin.com/t7aL85Wg
Hopefully, that will prove useful to you, NFITC1 :) Have at you.
Edit.
The Sleep, Confusion, Manip flags are there to remove the status if hit. Those 3 are removed on physical attack. Not sure why it's ecx+0000023C and not ecx+00000228. Evidently, the former is checked to see what needs removing.
-
There is valuable info I will paste here for reference even tho the pastebin still working:
-18 : status of actor
-0c: status of target
5DDC10
Hitvar:= -1
5DDC17
if 0x1 on Unknown Var then
Hitvar:= 255;
5DDC31
if unknownvar = 99 then
HitVar:= 255;
5DDC4B
if TargetStatus is Death, Sleep, Confusion, Stop, Petrify, Manip, Paralysis then
Begin
if TargetStatus = Sleep then
Set 0x4 on Unknown Var
if TargetStatus = Confusion then
Set 0x40 on Unknown Var
if TargetStatus = Manip then
Set 0x400000 on Unknown Var
HitVar:= 255
End;
5DDCF7
if 0x20 on unknownvar then
HitVar:= 255
5DDD11
[edx+00000260] = Attack%
ebp[-28] = (Attacker's Dex / 4) + Attack%.
ebp[-20] = attacker's defence rate
ebp[-1c] = target's defence rate
5DDD78
if HitVar <> 255 then
begin
HitVar = (Attacker's Dex / 4) + Attack% + ( Attacker's Df% - Target's Df%)
FuryCheck
end
5DDD99
if HitVar < 1 then
Hitvar:= 1
5DDDA6
RandomVar:= Random (0..99)
5DDDB5
[Lucky Hit]
If RandomVar < Luck /4
then HitVar = 255.
Skips the Lucky Evade check.
5DDDEF
[Lucky Evade. Ally only.]
if user is enemy and target is ally then
if RandomVar < Luck /4 then
HitVar is 0.
005DDE29
RandomVar2 (1..100). Unknown mechanism.
5DDE31 :
if Randomvar2 < HitVar then
unknown
else
Set Miss flag.
I wonder if the 5DDC31 is not the squall check, so making him always hit. Will try this
-
Here is the same function in C code, hope it helps:
//[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);
}