//
// SetupCountTriggerPopup::init from 0x1405b16e0 to 0x1405b1d24 (1604 bytes)
//
// 3 xrefs:
// > SetupCountTriggerPopup::create @ 0x1405b169e
// > ??> @ 0x14092db00
// > ??> @ 0x14092db0c
//
// This function is hookable on this platform (idp: pc, 32 bit: False, 64 bit: True!
//
// Using BromaIDA 8.3.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit 1c6ec395 at Thu Nov 26 21:29:22 2026 from https://github.com/geode-sdk/bindings
// Generated at Fri, 27 Nov 2026 11:34:42 +0000
//
// Hidden C++ exception states: #wind=3
char __fastcall SetupCountTriggerPopup::init(_BYTE *a1, int a2, int a3, int a4)
{
char result; // al
_BYTE *v6; // r9
_BYTE *v7; // rcx
const char *v8; // rdx
__int64 v9; // r8
__int64 v10; // rcx
__int64 v11; // rax
__int64 v12; // rdi
const struct cocos2d::CCPoint *v13; // rax
void *v14; // rcx
const struct cocos2d::CCPoint *v15; // rax
void *v16; // rcx
int v17; // eax
int v18; // eax
int v19; // eax
float v20; // [rsp+88h] [rbp-80h] BYREF
float v21; // [rsp+8Ch] [rbp-7Ch]
void **v22; // [rsp+90h] [rbp-78h] BYREF
void **v23; // [rsp+98h] [rbp-70h] BYREF
__int128 v24; // [rsp+A0h] [rbp-68h] BYREF
__int64 v25; // [rsp+B0h] [rbp-58h]
__int64 v26; // [rsp+B8h] [rbp-50h]
void *Block[2]; // [rsp+C0h] [rbp-48h] BYREF
__m128i si128; // [rsp+D0h] [rbp-38h]
result = SetupTriggerPopup::init((_DWORD)a1, a2, a3, a4, 1131413504, 1, 0);
if ( result )
{
a1[744] = 1;
(*(void (__fastcall **)(_BYTE *))(*(_QWORD *)a1 + 1096LL))(a1);
si128.m128i_i64[0] = 13;
si128.m128i_i64[1] = 15;
strcpy((char *)Block, "Count Trigger");
HIWORD(Block[1]) = 0;
SetupTriggerPopup::addTitle(a1, Block);
*(_OWORD *)Block = 0;
si128.m128i_i64[0] = 2;
si128.m128i_i64[1] = 15;
strcpy((char *)Block, "OK");
SetupTriggerPopup::addCloseButton(a1, Block);
v22 = Block;
*(_OWORD *)Block = 0;
si128 = 0u;
v6 = sub_14003D460(0x120u);
Block[0] = v6;
si128.m128i_i64[0] = 287;
si128.m128i_i64[1] = 287;
v7 = v6;
v8 = "Disable objects using Target ID when an Item ID reaches a certain Target Count. The con"
"dition is checked constantly.\n"
"Activate Group makes the trigger enable and spawn the group instead.\n"
"Multi Activate allows the trigger to activate more than once.";
v9 = 2;
do
{
*(_OWORD *)v7 = *(_OWORD *)v8;
*((_OWORD *)v7 + 1) = *((_OWORD *)v8 + 1);
*((_OWORD *)v7 + 2) = *((_OWORD *)v8 + 2);
*((_OWORD *)v7 + 3) = *((_OWORD *)v8 + 3);
*((_OWORD *)v7 + 4) = *((_OWORD *)v8 + 4);
*((_OWORD *)v7 + 5) = *((_OWORD *)v8 + 5);
*((_OWORD *)v7 + 6) = *((_OWORD *)v8 + 6);
v7 += 128;
*((_OWORD *)v7 - 1) = *((_OWORD *)v8 + 7);
v8 += 128;
--v9;
}
while ( v9 );
*(_OWORD *)v7 = *(_OWORD *)v8;
*((_QWORD *)v7 + 2) = *((_QWORD *)v8 + 2);
*((_DWORD *)v7 + 6) = *((_DWORD *)v8 + 6);
*((_WORD *)v7 + 14) = *((_WORD *)v8 + 14);
v7[30] = v8[30];
v6[287] = 0;
v24 = 0;
v25 = 4;
v26 = 15;
strcpy((char *)&v24, "Help");
SetupTriggerPopup::addHelpButton(a1, &v24, Block);
v11 = cocos2d::CCDirector::sharedDirector(v10);
cocos2d::CCDirector::getWinSize(v11, &v20);
Block[1] = nullptr;
si128 = _mm_load_si128((const __m128i *)&xmmword_140836580);
Block[0] = (void *)0x4449206D657449LL;
v12 = (__int64)(a1 + 544);
if ( !a1 )
v12 = 0;
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v22, (float)(v20 * 0.5) - 90.0, (float)(v21 * 0.5) + 40.0);
IDNameInput::create((__int64)a1, v12, 2, 80, (__int64)Block, v13, 1065353216, 6, 0, 0, 0);
if ( si128.m128i_i64[1] > 0xFuLL )
{
v14 = Block[0];
if ( (unsigned __int64)(si128.m128i_i64[1] + 1) >= 0x1000 )
{
v14 = *((void **)Block[0] - 1);
if ( (unsigned __int64)((char *)Block[0] - (char *)v14 - 8) > 0x1F )
invoke_watson(nullptr, nullptr, nullptr, 0, 0);
}
j_j_free(v14);
}
Block[1] = (void *)68;
si128 = _mm_load_si128((const __m128i *)&xmmword_1408365A0);
Block[0] = (void *)0x4920746567726154LL;
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v22, (float)(v20 * 0.5) + 90.0, (float)(v21 * 0.5) + 40.0);
IDNameInput::create((__int64)a1, v12, 1, 51, (__int64)Block, v15, 1065353216, 6, 0, 0, 0);
if ( si128.m128i_i64[1] > 0xFuLL )
{
v16 = Block[0];
if ( (unsigned __int64)(si128.m128i_i64[1] + 1) >= 0x1000 )
{
v16 = *((void **)Block[0] - 1);
if ( (unsigned __int64)((char *)Block[0] - (char *)v16 - 8) > 0x1F )
invoke_watson(nullptr, nullptr, nullptr, 0, 0);
}
j_j_free(v16);
}
v22 = Block;
si128.m128i_i64[0] = 12;
si128.m128i_i64[1] = 15;
strcpy((char *)Block, "Target Count");
BYTE5(Block[1]) = 0;
HIWORD(Block[1]) = 0;
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v23, (float)(v20 * 0.5) - 90.0, (float)(v21 * 0.5) - 25.0);
SetupTriggerPopup::createValueControlAdvanced(
(_DWORD)a1,
77,
(unsigned int)Block,
v17,
1061997773,
1,
2,
6,
1,
0,
1120403456,
1,
0,
0,
2,
0);
SetupTriggerPopup::createMultiTriggerItemsDefault(a1);
v23 = Block;
si128.m128i_i64[0] = 14;
si128.m128i_i64[1] = 15;
strcpy((char *)Block, "Activate\nGroup");
HIBYTE(Block[1]) = 0;
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v22, (float)(v20 * 0.5) + 50.0, (float)(v21 * 0.5) - 10.0);
SetupTriggerPopup::createToggleValueControl((_DWORD)a1, 56, (unsigned int)Block, v18, 0, 0, 0, 1065353216);
v23 = Block;
si128.m128i_i64[0] = 14;
si128.m128i_i64[1] = 15;
strcpy((char *)Block, "Multi\nActivate");
HIBYTE(Block[1]) = 0;
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v22, (float)(v20 * 0.5) + 50.0, (float)(v21 * 0.5) - 45.0);
SetupTriggerPopup::createToggleValueControl((_DWORD)a1, 104, (unsigned int)Block, v19, 0, 0, 0, 1065353216);
(*(void (__fastcall **)(_BYTE *))(*(_QWORD *)a1 + 1136LL))(a1);
a1[744] = 0;
return 1;
}
return result;
}