Skip to content

Instantly share code, notes, and snippets.

@Lusamine
Created December 14, 2025 00:37
Show Gist options
  • Select an option

  • Save Lusamine/1bca8a01d9f84b55446ac83217256060 to your computer and use it in GitHub Desktop.

Select an option

Save Lusamine/1bca8a01d9f84b55446ac83217256060 to your computer and use it in GitHub Desktop.
void __fastcall pml::Capture::JudgeCapture(pml::Capture *a1)
{
pml::Capture::Result *__shifted(pml::Capture,0x38) p_result; // x20
unsigned int item_id; // w0
pml::CapturePoke *target_pokemon; // x0
float v5; // s8
unsigned int dex_capture_count; // w9
float v7; // s0
float v8; // s1
bool v9; // w8
int donut_bonus; // w9
bool v11; // zf
int failed_catch; // w8
int v13; // w10
_BOOL4 is_skip_random_shake_check; // w9
int v15; // w10
_BOOL4 is_critical_capture; // w22
int catch_chance; // w21
int rand1; // w0
char v19; // w8
unsigned int shake_count; // w8
*(_DWORD *)&a1->result.is_captured = 0;
a1->result.friendship = 0;
p_result = &a1->result;
item_id = (unsigned __int16)a1->capture_param.item_id;
ADJ(p_result)->result.catch_fail_value = 0;
ADJ(p_result)->result.indicator.hp_ratio = 1.0;
ADJ(p_result)->result.indicator.dex_ratio = 1.0;
ADJ(p_result)->result.indicator.capture_value_ratio = 1.0;
ADJ(p_result)->result.indicator.ball_capture_ratio = 1.0;
ADJ(p_result)->result.indicator.alpha_ko_ratio = 1.0;
ADJ(p_result)->result.indicator.sick_ratio = 1.0;
ADJ(p_result)->result.indicator.shiny_ratio = 1.0;
ADJ(p_result)->result.indicator.behavior_ratio = 1.0;
ADJ(p_result)->result.indicator.backstrike_ratio = 1.0;
ADJ(p_result)->result.indicator.alpha_ratio = 1.0;
ADJ(p_result)->result.indicator.za_level_ratio = 1.0;
ADJ(p_result)->result.indicator.plush_ratio = 1.0;
if ( pml::pokepara::CalcTool::GetBallNo(item_id) == BallID_Master )
{
a1->result.is_captured = 1;
a1->result.shake_count = 3;
return;
}
target_pokemon = a1->capture_param.target_pokemon;
if ( target_pokemon
&& (((__int64 (__fastcall *)(pml::CapturePoke *))target_pokemon->IsCapturable)(target_pokemon) & 1) == 0 )
{
return;
}
v5 = pml::Capture::CalcCaptureIndicator(a1, &ADJ(p_result)->capture_param);
if ( a1->capture_param.can_critical_capture )
{
dex_capture_count = (unsigned __int16)a1->capture_param.dex_capture_count;
if ( dex_capture_count <= 600 )
{
if ( dex_capture_count <= 450 )
{
if ( dex_capture_count <= 300 )
{
if ( dex_capture_count <= 150 )
{
if ( dex_capture_count < 31 )
{
v9 = 0;
LABEL_22:
a1->result.is_critical_capture = v9;
goto LABEL_23;
}
v7 = 0.5;
}
else
{
v7 = 1.0;
}
}
else
{
v7 = 1.5;
}
}
else
{
v7 = 2.0;
}
}
else
{
v7 = 2.5;
}
if ( a1->capture_param.has_catching_charm )
v7 = v7 + v7;
v8 = 255.0;
if ( v5 <= 255.0 )
v8 = v5;
v9 = (float)((float)(v8 * v7) / 6.0) > (float)(unsigned int)pml::local::Random::GetValue(0x100u);
goto LABEL_22;
}
LABEL_23:
if ( pml::pokepara::CalcTool::GetBallNo((unsigned __int16)a1->capture_param.item_id) == BallID_Friend )
a1->result.friendship = 150;
if ( v5 >= 255.0 )
{
a1->result.is_captured = 1;
if ( a1->result.is_critical_capture )
v19 = 1;
else
v19 = 3;
a1->result.shake_count = v19;
}
else
{
donut_bonus = a1->capture_param.donut_bonus;
v11 = donut_bonus == 0;
failed_catch = (int)(float)(65535.0 - (float)((float)((float)(v5 + 1.0) * (float)(v5 + 1.0)) + -1.0));
v13 = failed_catch - donut_bonus;
is_skip_random_shake_check = a1->capture_param.is_skip_random_shake_check;
v15 = v13 & ~(v13 >> 31);
if ( !v11 )
failed_catch = v15;
a1->result.catch_fail_value = failed_catch;
if ( !is_skip_random_shake_check )
{
is_critical_capture = a1->result.is_critical_capture;
a1->result.is_captured = 0;
a1->result.shake_count = 0;
catch_chance = 0xFFFF - failed_catch;
rand1 = pml::local::Random::GetValue(0x10000u);
if ( is_critical_capture )
{
if ( rand1 >= catch_chance )
return;
}
else if ( rand1 >= catch_chance
&& (int)pml::local::Random::GetValue(0x10000u) >= catch_chance
&& (int)pml::local::Random::GetValue(0x10000u) >= catch_chance )
{
return;
}
shake_count = (unsigned __int8)a1->result.shake_count;
if ( shake_count <= 2 )
a1->result.shake_count = shake_count + 1;
ADJ(p_result)->result.is_captured = 1;
}
}
}
----
.text:0000007100447210 ; void __fastcall pml::Capture::JudgeCapture(_QWORD a1)
.text:0000007100447210 pml__Capture__JudgeCapture ; CODE XREF: sub_7100446BC4+4C↑p
.text:0000007100447210 ; sub_7100602560+34↓p
.text:0000007100447210
.text:0000007100447210 var_10 = -0x10
.text:0000007100447210 var_s0 = 0
.text:0000007100447210 var_s10 = 0x10
.text:0000007100447210 var_s20 = 0x20
.text:0000007100447210
.text:0000007100447210 STP D9, D8, [SP,#-0x30+var_10]!
.text:0000007100447214 STP X29, X30, [SP,#0x10+var_s0]
.text:0000007100447218 STP X22, X21, [SP,#0x10+var_s10]
.text:000000710044721C STP X20, X19, [SP,#0x10+var_s20]
.text:0000007100447220 ADD X29, SP, #0x10
.text:0000007100447224 MOV X20, X0
.text:0000007100447228 MOV X19, X0
.text:000000710044722C MOV X8, #0x3F8000003F800000
.text:0000007100447230 STR XZR, [X20,#0x38]!
.text:0000007100447234 LDURH W0, [X20,#-0x20] ; a1
.text:0000007100447238 STR WZR, [X20,#8]
.text:000000710044723C STUR X8, [X20,#0xC]
.text:0000007100447240 STUR X8, [X20,#0x14]
.text:0000007100447244 STUR X8, [X20,#0x1C]
.text:0000007100447248 STUR X8, [X20,#0x24]
.text:000000710044724C STUR X8, [X20,#0x2C]
.text:0000007100447250 STUR X8, [X20,#0x34]
.text:0000007100447254 BL pml__pokepara__CalcTool__GetBallNo
.text:0000007100447258 AND W8, W0, #0xFF
.text:000000710044725C CMP W8, #1
.text:0000007100447260 B.NE loc_7100447284
.text:0000007100447264 STRB W8, [X19,#0x38]
.text:0000007100447268 MOV W8, #3
.text:000000710044726C STRB W8, [X19,#0x3B]
.text:0000007100447270
.text:0000007100447270 loc_7100447270 ; CODE XREF: pml__Capture__JudgeCapture+88↓j
.text:0000007100447270 ; pml__Capture__JudgeCapture+1A8↓j ...
.text:0000007100447270 LDP X20, X19, [SP,#0x10+var_s20]
.text:0000007100447274 LDP X22, X21, [SP,#0x10+var_s10]
.text:0000007100447278 LDP X29, X30, [SP,#0x10+var_s0]
.text:000000710044727C LDP D9, D8, [SP+0x10+var_10],#0x40
.text:0000007100447280 RET
.text:0000007100447284 ; ---------------------------------------------------------------------------
.text:0000007100447284
.text:0000007100447284 loc_7100447284 ; CODE XREF: pml__Capture__JudgeCapture+50↑j
.text:0000007100447284 LDR X0, [X19,#0x10]
.text:0000007100447288 CBZ X0, loc_710044729C
.text:000000710044728C LDR X8, [X0]
.text:0000007100447290 LDR X8, [X8,#0xD0]
.text:0000007100447294 BLR X8
.text:0000007100447298 TBZ W0, #0, loc_7100447270
.text:000000710044729C
.text:000000710044729C loc_710044729C ; CODE XREF: pml__Capture__JudgeCapture+78↑j
.text:000000710044729C SUB X1, X20, #0x30 ; '0' ; param
.text:00000071004472A0 MOV X0, X19 ; this
.text:00000071004472A4 BL pml__Capture__CalcCaptureIndicator
.text:00000071004472A8 LDRB W8, [X19,#0x30]
.text:00000071004472AC FMOV S8, S0
.text:00000071004472B0 CBZ W8, loc_7100447348
.text:00000071004472B4 LDRH W9, [X19,#0x22]
.text:00000071004472B8 CMP W9, #0x258
.text:00000071004472BC LDRB W8, [X19,#0x2A]
.text:00000071004472C0 B.LS loc_71004472CC
.text:00000071004472C4 FMOV S0, #2.5
.text:00000071004472C8 B loc_7100447308
.text:00000071004472CC ; ---------------------------------------------------------------------------
.text:00000071004472CC
.text:00000071004472CC loc_71004472CC ; CODE XREF: pml__Capture__JudgeCapture+B0↑j
.text:00000071004472CC CMP W9, #0x1C2
.text:00000071004472D0 B.LS loc_71004472DC
.text:00000071004472D4 FMOV S0, #2.0
.text:00000071004472D8 B loc_7100447308
.text:00000071004472DC ; ---------------------------------------------------------------------------
.text:00000071004472DC
.text:00000071004472DC loc_71004472DC ; CODE XREF: pml__Capture__JudgeCapture+C0↑j
.text:00000071004472DC CMP W9, #0x12C
.text:00000071004472E0 B.LS loc_71004472EC
.text:00000071004472E4 FMOV S0, #1.5
.text:00000071004472E8 B loc_7100447308
.text:00000071004472EC ; ---------------------------------------------------------------------------
.text:00000071004472EC
.text:00000071004472EC loc_71004472EC ; CODE XREF: pml__Capture__JudgeCapture+D0↑j
.text:00000071004472EC CMP W9, #0x96
.text:00000071004472F0 B.LS loc_71004472FC
.text:00000071004472F4 FMOV S0, #1.0
.text:00000071004472F8 B loc_7100447308
.text:00000071004472FC ; ---------------------------------------------------------------------------
.text:00000071004472FC
.text:00000071004472FC loc_71004472FC ; CODE XREF: pml__Capture__JudgeCapture+E0↑j
.text:00000071004472FC CMP W9, #0x1F
.text:0000007100447300 B.CC loc_7100447470
.text:0000007100447304 FMOV S0, #0.5
.text:0000007100447308
.text:0000007100447308 loc_7100447308 ; CODE XREF: pml__Capture__JudgeCapture+B8↑j
.text:0000007100447308 ; pml__Capture__JudgeCapture+C8↑j ...
.text:0000007100447308 FADD S1, S0, S0
.text:000000710044730C CMP W8, #0
.text:0000007100447310 MOV W8, #0x437F0000
.text:0000007100447314 MOV W0, #0x100
.text:0000007100447318 FCSEL S0, S0, S1, EQ
.text:000000710044731C FMOV S1, W8
.text:0000007100447320 FCMP S8, S1
.text:0000007100447324 FCSEL S1, S1, S8, GT
.text:0000007100447328 FMUL S0, S1, S0
.text:000000710044732C FMOV S1, #6.0
.text:0000007100447330 FDIV S9, S0, S1
.text:0000007100447334 BL pml__local__Random__GetValue
.text:0000007100447338 UCVTF S0, W0
.text:000000710044733C FCMP S9, S0
.text:0000007100447340 CSET W8, GT
.text:0000007100447344
.text:0000007100447344 loc_7100447344 ; CODE XREF: pml__Capture__JudgeCapture+264↓j
.text:0000007100447344 STRB W8, [X19,#0x39]
.text:0000007100447348
.text:0000007100447348 loc_7100447348 ; CODE XREF: pml__Capture__JudgeCapture+A0↑j
.text:0000007100447348 LDRH W0, [X19,#0x18] ; a1
.text:000000710044734C BL pml__pokepara__CalcTool__GetBallNo
.text:0000007100447350 AND W8, W0, #0xFF
.text:0000007100447354 CMP W8, #0x16
.text:0000007100447358 B.NE loc_7100447364
.text:000000710044735C MOV W8, #0x96
.text:0000007100447360 STR W8, [X19,#0x3C]
.text:0000007100447364
.text:0000007100447364 loc_7100447364 ; CODE XREF: pml__Capture__JudgeCapture+148↑j
.text:0000007100447364 MOV W8, #0x437F0000
.text:0000007100447368 FMOV S0, W8
.text:000000710044736C FCMP S8, S0
.text:0000007100447370 B.GE loc_71004473E8
.text:0000007100447374 FMOV S0, #1.0
.text:0000007100447378 FMOV S1, #-1.0
.text:000000710044737C MOV W8, #0x477FFF00
.text:0000007100447384 LDR W9, [X19,#0x34]
.text:0000007100447388 FADD S0, S8, S0
.text:000000710044738C CMP W9, #0
.text:0000007100447390 FMUL S0, S0, S0
.text:0000007100447394 FADD S0, S0, S1
.text:0000007100447398 FMOV S1, W8
.text:000000710044739C FSUB S0, S1, S0
.text:00000071004473A0 FCVTZS W8, S0
.text:00000071004473A4 SUB W10, W8, W9
.text:00000071004473A8 LDRB W9, [X19,#0x2E]
.text:00000071004473AC BIC W10, W10, W10,ASR#31
.text:00000071004473B0 CSEL W8, W8, W10, EQ
.text:00000071004473B4 STR W8, [X19,#0x40]
.text:00000071004473B8 CBNZ W9, loc_7100447270
.text:00000071004473BC LDRB W22, [X19,#0x39]
.text:00000071004473C0 MOV W9, #0xFFFF
.text:00000071004473C4 MOV W0, #0x10000
.text:00000071004473C8 STRB WZR, [X19,#0x38]
.text:00000071004473CC STRB WZR, [X19,#0x3B]
.text:00000071004473D0 SUB W21, W9, W8
.text:00000071004473D4 BL pml__local__Random__GetValue
.text:00000071004473D8 CBZ W22, loc_7100447418
.text:00000071004473DC CMP W0, W21
.text:00000071004473E0 B.GE loc_7100447270
.text:00000071004473E4 B loc_7100447440
.text:00000071004473E8 ; ---------------------------------------------------------------------------
.text:00000071004473E8
.text:00000071004473E8 loc_71004473E8 ; CODE XREF: pml__Capture__JudgeCapture+160↑j
.text:00000071004473E8 MOV W8, #1
.text:00000071004473EC STRB W8, [X19,#0x38]
.text:00000071004473F0 LDRB W8, [X19,#0x39]
.text:00000071004473F4 CMP W8, #0
.text:00000071004473F8 MOV W8, #3
.text:00000071004473FC CSINC W8, W8, WZR, EQ
.text:0000007100447400 STRB W8, [X19,#0x3B]
.text:0000007100447404 LDP X20, X19, [SP,#0x10+var_s20]
.text:0000007100447408 LDP X22, X21, [SP,#0x10+var_s10]
.text:000000710044740C LDP X29, X30, [SP,#0x10+var_s0]
.text:0000007100447410 LDP D9, D8, [SP+0x10+var_10],#0x40
.text:0000007100447414 RET
.text:0000007100447418 ; ---------------------------------------------------------------------------
.text:0000007100447418
.text:0000007100447418 loc_7100447418 ; CODE XREF: pml__Capture__JudgeCapture+1C8↑j
.text:0000007100447418 CMP W0, W21
.text:000000710044741C B.LT loc_7100447440
.text:0000007100447420 MOV W0, #0x10000
.text:0000007100447424 BL pml__local__Random__GetValue
.text:0000007100447428 CMP W0, W21
.text:000000710044742C B.LT loc_7100447440
.text:0000007100447430 MOV W0, #0x10000
.text:0000007100447434 BL pml__local__Random__GetValue
.text:0000007100447438 CMP W0, W21
.text:000000710044743C B.GE loc_7100447270
.text:0000007100447440
.text:0000007100447440 loc_7100447440 ; CODE XREF: pml__Capture__JudgeCapture+1D4↑j
.text:0000007100447440 ; pml__Capture__JudgeCapture+20C↑j ...
.text:0000007100447440 LDRB W8, [X19,#0x3B]
.text:0000007100447444 CMP W8, #2
.text:0000007100447448 B.HI loc_7100447454
.text:000000710044744C ADD W8, W8, #1
.text:0000007100447450 STRB W8, [X19,#0x3B]
.text:0000007100447454
.text:0000007100447454 loc_7100447454 ; CODE XREF: pml__Capture__JudgeCapture+238↑j
.text:0000007100447454 MOV W8, #1
.text:0000007100447458 STRB W8, [X20]
.text:000000710044745C LDP X20, X19, [SP,#0x10+var_s20]
.text:0000007100447460 LDP X22, X21, [SP,#0x10+var_s10]
.text:0000007100447464 LDP X29, X30, [SP,#0x10+var_s0]
.text:0000007100447468 LDP D9, D8, [SP+0x10+var_10],#0x40
.text:000000710044746C RET
.text:0000007100447470 ; ---------------------------------------------------------------------------
.text:0000007100447470
.text:0000007100447470 loc_7100447470 ; CODE XREF: pml__Capture__JudgeCapture+F0↑j
.text:0000007100447470 MOV W8, WZR
.text:0000007100447474 B loc_7100447344
.text:0000007100447474 ; End of function pml__Capture__JudgeCapture

Comments are disabled for this gist.