Skip to content

Instantly share code, notes, and snippets.

@Lusamine
Created June 19, 2025 18:09
Show Gist options
  • Select an option

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

Select an option

Save Lusamine/e66b92402bce49420bceeef17a4253fd to your computer and use it in GitHub Desktop.
__int32 __fastcall camp_decide_groups(__int64 a1)
{
unsigned __int64 party_size; // x8
unsigned __int64 count; // x21
unsigned __int64 total_sociability; // x20
unsigned __int8 CampFriendship; // w0
unsigned __int64 index; // x21
unsigned __int64 mons_180_sociability; // x20
unsigned __int8 v8; // w0
unsigned __int64 party_size2; // x8
unsigned __int64 index2; // x21
unsigned __int64 mons_70_sociability; // x20
unsigned __int8 v13; // w0
party_size = *(_QWORD *)(a1 + 128);
if ( party_size )
{
count = 0LL;
total_sociability = 0LL;
do
{
CampFriendship = Pml_PokePara_CoreParam__GetCampFriendship(*(Pml_PokePara_CoreParam_o **)(*(_QWORD *)(a1 + 8 * count)
+ 88LL));
party_size = *(_QWORD *)(a1 + 128);
total_sociability += CampFriendship;
++count;
}
while ( count < party_size );
if ( total_sociability / party_size >= 26 )
goto LABEL_5;
return 3;
}
if ( 0 / 0uLL < 26 )
return 3;
if ( !party_size )
return 0;
LABEL_5:
index = 0LL;
mons_180_sociability = 0LL;
do
{
v8 = Pml_PokePara_CoreParam__GetCampFriendship(*(Pml_PokePara_CoreParam_o **)(*(_QWORD *)(a1 + 8 * index) + 88LL));
party_size2 = *(_QWORD *)(a1 + 128);
++index;
if ( v8 > 179u )
++mons_180_sociability;
}
while ( index < party_size2 );
if ( mons_180_sociability > 2 )
{
if ( get_rand_float(global_struct->main_rng, 1.0) < 0.3 )
return 1; // Group of 3
party_size2 = *(_QWORD *)(a1 + 128);
}
if ( !party_size2 )
return 0;
index2 = 0LL;
mons_70_sociability = 0LL;
do
{
v13 = Pml_PokePara_CoreParam__GetCampFriendship(*(Pml_PokePara_CoreParam_o **)(*(_QWORD *)(a1 + 8 * index2++) + 88LL));
if ( v13 > 69u )
++mons_70_sociability;
}
while ( index2 < *(_QWORD *)(a1 + 128) );
if ( mons_70_sociability > 1 && get_rand_float(global_struct->main_rng, 1.0) < 0.5 )
return 2; // group of 2
else
return 0;
}
----
.text:00000071011BA9B0 ; =============== S U B R O U T I N E =======================================
.text:00000071011BA9B0
.text:00000071011BA9B0 ; Attributes: bp-based frame
.text:00000071011BA9B0
.text:00000071011BA9B0 ; __int32 __fastcall camp_decide_groups(__int64)
.text:00000071011BA9B0 camp_decide_groups ; CODE XREF: sub_71012369D0+98↓p
.text:00000071011BA9B0
.text:00000071011BA9B0 var_20 = -0x20
.text:00000071011BA9B0 var_10 = -0x10
.text:00000071011BA9B0 var_s0 = 0
.text:00000071011BA9B0
.text:00000071011BA9B0 STR X21, [SP,#-0x10+var_20]!
.text:00000071011BA9B4 STP X20, X19, [SP,#0x20+var_10]
.text:00000071011BA9B8 STP X29, X30, [SP,#0x20+var_s0]
.text:00000071011BA9BC ADD X29, SP, #0x20
.text:00000071011BA9C0 LDR X8, [X0,#0x80]
.text:00000071011BA9C4 MOV X19, X0
.text:00000071011BA9C8 CBZ X8, loc_71011BAA78
.text:00000071011BA9CC MOV X21, XZR
.text:00000071011BA9D0 MOV X20, XZR
.text:00000071011BA9D4
.text:00000071011BA9D4 loc_71011BA9D4 ; CODE XREF: camp_decide_groups+40↓j
.text:00000071011BA9D4 LDR X8, [X19,X21,LSL#3]
.text:00000071011BA9D8 LDR X0, [X8,#0x58]
.text:00000071011BA9DC BL Pml.PokePara.CoreParam$$GetCampFriendship
.text:00000071011BA9E0 LDR X8, [X19,#0x80]
.text:00000071011BA9E4 ADD X20, X20, W0,UXTB
.text:00000071011BA9E8 ADD X21, X21, #1
.text:00000071011BA9EC CMP X21, X8
.text:00000071011BA9F0 B.CC loc_71011BA9D4
.text:00000071011BA9F4 UDIV X9, X20, X8
.text:00000071011BA9F8 CMP X9, #0x1A
.text:00000071011BA9FC B.CC loc_71011BAA88
.text:00000071011BAA00
.text:00000071011BAA00 loc_71011BAA00 ; CODE XREF: camp_decide_groups+D4↓j
.text:00000071011BAA00 CBZ X8, loc_71011BAB14
.text:00000071011BAA04 MOV X21, XZR
.text:00000071011BAA08 MOV X20, XZR
.text:00000071011BAA0C
.text:00000071011BAA0C loc_71011BAA0C ; CODE XREF: camp_decide_groups+80↓j
.text:00000071011BAA0C LDR X8, [X19,X21,LSL#3]
.text:00000071011BAA10 LDR X0, [X8,#0x58]
.text:00000071011BAA14 BL Pml.PokePara.CoreParam$$GetCampFriendship
.text:00000071011BAA18 AND W8, W0, #0xFF
.text:00000071011BAA1C CMP W8, #0xB3
.text:00000071011BAA20 LDR X8, [X19,#0x80]
.text:00000071011BAA24 ADD X21, X21, #1
.text:00000071011BAA28 CINC X20, X20, HI
.text:00000071011BAA2C CMP X21, X8
.text:00000071011BAA30 B.CC loc_71011BAA0C
.text:00000071011BAA34 CMP X20, #2
.text:00000071011BAA38 B.LS loc_71011BAAA0
.text:00000071011BAA3C ADRP X8, #off_7102610848@PAGE
.text:00000071011BAA40 LDR X8, [X8,#off_7102610848@PAGEOFF]
.text:00000071011BAA44 LDR X8, [X8]
.text:00000071011BAA48 LDR X0, [X8,#0x98]
.text:00000071011BAA4C FMOV S0, #1.0
.text:00000071011BAA50 BL get_rand_float
.text:00000071011BAA54 ADRP X8, #dword_7101C4C774@PAGE
.text:00000071011BAA58 LDR S1, [X8,#dword_7101C4C774@PAGEOFF]
.text:00000071011BAA5C FCMP S0, S1
.text:00000071011BAA60 B.PL loc_71011BAA9C
.text:00000071011BAA64 MOV W0, #1
.text:00000071011BAA68 LDP X29, X30, [SP,#0x20+var_s0]
.text:00000071011BAA6C LDP X20, X19, [SP,#0x20+var_10]
.text:00000071011BAA70 LDR X21, [SP+0x20+var_20],#0x30
.text:00000071011BAA74 RET
.text:00000071011BAA78 ; ---------------------------------------------------------------------------
.text:00000071011BAA78
.text:00000071011BAA78 loc_71011BAA78 ; CODE XREF: camp_decide_groups+18↑j
.text:00000071011BAA78 MOV X20, XZR
.text:00000071011BAA7C UDIV X9, X20, X8
.text:00000071011BAA80 CMP X9, #0x1A
.text:00000071011BAA84 B.CS loc_71011BAA00
.text:00000071011BAA88
.text:00000071011BAA88 loc_71011BAA88 ; CODE XREF: camp_decide_groups+4C↑j
.text:00000071011BAA88 MOV W0, #3
.text:00000071011BAA8C LDP X29, X30, [SP,#0x20+var_s0]
.text:00000071011BAA90 LDP X20, X19, [SP,#0x20+var_10]
.text:00000071011BAA94 LDR X21, [SP+0x20+var_20],#0x30
.text:00000071011BAA98 RET
.text:00000071011BAA9C ; ---------------------------------------------------------------------------
.text:00000071011BAA9C
.text:00000071011BAA9C loc_71011BAA9C ; CODE XREF: camp_decide_groups+B0↑j
.text:00000071011BAA9C LDR X8, [X19,#0x80]
.text:00000071011BAAA0
.text:00000071011BAAA0 loc_71011BAAA0 ; CODE XREF: camp_decide_groups+88↑j
.text:00000071011BAAA0 CBZ X8, loc_71011BAB14
.text:00000071011BAAA4 MOV X21, XZR
.text:00000071011BAAA8 MOV X20, XZR
.text:00000071011BAAAC
.text:00000071011BAAAC loc_71011BAAAC ; CODE XREF: camp_decide_groups+120↓j
.text:00000071011BAAAC LDR X8, [X19,X21,LSL#3]
.text:00000071011BAAB0 LDR X0, [X8,#0x58]
.text:00000071011BAAB4 BL Pml.PokePara.CoreParam$$GetCampFriendship
.text:00000071011BAAB8 AND W8, W0, #0xFF
.text:00000071011BAABC CMP W8, #0x45 ; 'E'
.text:00000071011BAAC0 LDR X8, [X19,#0x80]
.text:00000071011BAAC4 ADD X21, X21, #1
.text:00000071011BAAC8 CINC X20, X20, HI
.text:00000071011BAACC CMP X21, X8
.text:00000071011BAAD0 B.CC loc_71011BAAAC
.text:00000071011BAAD4 CMP X20, #1
.text:00000071011BAAD8 B.LS loc_71011BAB14
.text:00000071011BAADC ADRP X8, #off_7102610848@PAGE
.text:00000071011BAAE0 LDR X8, [X8,#off_7102610848@PAGEOFF]
.text:00000071011BAAE4 LDR X8, [X8]
.text:00000071011BAAE8 LDR X0, [X8,#0x98]
.text:00000071011BAAEC FMOV S0, #1.0
.text:00000071011BAAF0 BL get_rand_float
.text:00000071011BAAF4 FMOV S1, #0.5
.text:00000071011BAAF8 FCMP S0, S1
.text:00000071011BAAFC B.PL loc_71011BAB14
.text:00000071011BAB00 MOV W0, #2
.text:00000071011BAB04 LDP X29, X30, [SP,#0x20+var_s0]
.text:00000071011BAB08 LDP X20, X19, [SP,#0x20+var_10]
.text:00000071011BAB0C LDR X21, [SP+0x20+var_20],#0x30
.text:00000071011BAB10 RET
.text:00000071011BAB14 ; ---------------------------------------------------------------------------
.text:00000071011BAB14
.text:00000071011BAB14 loc_71011BAB14 ; CODE XREF: camp_decide_groups:loc_71011BAA00↑j
.text:00000071011BAB14 ; camp_decide_groups:loc_71011BAAA0↑j ...
.text:00000071011BAB14 MOV W0, WZR
.text:00000071011BAB18 LDP X29, X30, [SP,#0x20+var_s0]
.text:00000071011BAB1C LDP X20, X19, [SP,#0x20+var_10]
.text:00000071011BAB20 LDR X21, [SP+0x20+var_20],#0x30
.text:00000071011BAB24 RET
.text:00000071011BAB24 ; End of function camp_decide_groups
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment