//
// SetupRandAdvTriggerPopup::init from 0x1405d2a80 to 0x1405d3766 (3302 bytes)
//
// 2 xrefs:
// > SetupRandAdvTriggerPopup::create @ 0x1405d2a32
// > ??> @ 0x14092e8bc
//
// 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:56 +0000
//
// Hidden C++ exception states: #wind=4
char __fastcall SetupRandAdvTriggerPopup::init(__int64 a1, int a2, int a3, int a4)
{
char result; // al
__int64 v6; // rcx
cocos2d::CCObject *v7; // rax
__int64 v8; // rcx
__int64 v9; // rax
cocos2d::CCObject *v10; // rbx
cocos2d::CCObject *v11; // rax
char *v12; // rsi
__int64 v13; // rdi
__int64 v14; // rbx
__int64 v15; // rax
__int64 v16; // rax
const struct cocos2d::CCPoint *v17; // rax
char *v18; // rbx
void *v19; // r8
__int64 v20; // rax
struct cocos2d::CCLabelBMFont *v21; // rdi
__int64 v22; // rbx
__int64 v23; // rax
__int64 v24; // rax
__int64 v25; // rax
_QWORD *v26; // rsi
__int64 v27; // rdx
void (__fastcall *v28)(_QWORD *, __int64); // r8
__int64 v29; // rbx
__int64 v30; // rax
__int64 v31; // rdx
__int64 v32; // rcx
char *v33; // rax
__int64 v34; // rdi
__int64 v35; // rbx
__int64 v36; // rax
__int64 v37; // rcx
__int64 v38; // rcx
__int64 v39; // rcx
__int64 v40; // rcx
cocos2d::CCString *v41; // rax
const char *CString; // rax
size_t v43; // r8
cocos2d::CCObject *v44; // rbx
cocos2d::CCObject *v45; // rdi
__int64 v46; // rax
__int64 v47; // rbx
__int64 v48; // rax
__int64 v49; // rbx
__int64 v50; // rax
__int64 v51; // rax
__int64 *v52; // rdi
__int64 v53; // rdx
void (__fastcall *v54)(__int64 *, __int64); // r8
__int64 v55; // rbx
__int64 v56; // rax
__int64 v57; // rbx
__int64 v58; // rax
__int64 v59; // rbx
__int64 v60; // rax
cocos2d::CCSprite *v61; // rbx
cocos2d::CCObject *v62; // rax
__int64 v63; // rax
struct cocos2d::CCSprite *v64; // rbx
cocos2d::CCObject *v65; // rax
__int64 v66; // rax
__int64 v67; // rax
__int64 v68; // rax
__int64 v69; // rbx
__int64 v70; // rax
void **v71; // [rsp+60h] [rbp-A0h] BYREF
float v72; // [rsp+68h] [rbp-98h] BYREF
float v73; // [rsp+6Ch] [rbp-94h]
void *v74; // [rsp+70h] [rbp-90h] BYREF
__int16 v75; // [rsp+78h] [rbp-88h]
_BYTE v76[12]; // [rsp+7Ch] [rbp-84h] BYREF
_BYTE v77[4]; // [rsp+88h] [rbp-78h] BYREF
float v78; // [rsp+8Ch] [rbp-74h]
__int128 v79; // [rsp+90h] [rbp-70h] BYREF
__int64 v80; // [rsp+A0h] [rbp-60h]
__int64 v81; // [rsp+A8h] [rbp-58h]
_BYTE v82[8]; // [rsp+B0h] [rbp-50h] BYREF
_BYTE v83[8]; // [rsp+B8h] [rbp-48h] BYREF
_BYTE v84[8]; // [rsp+C0h] [rbp-40h] BYREF
void *Block[2]; // [rsp+C8h] [rbp-38h] BYREF
__int64 v86; // [rsp+D8h] [rbp-28h]
unsigned __int64 v87; // [rsp+E0h] [rbp-20h]
result = SetupTriggerPopup::init(a1, a2, a3, a4, 1133903872, 1, 0);
if ( result )
{
v7 = (cocos2d::CCObject *)cocos2d::CCArray::create(v6);
*(_QWORD *)(a1 + 1008) = v7;
cocos2d::CCObject::retain(v7);
(*(void (__fastcall **)(__int64))(*(_QWORD *)a1 + 1096LL))(a1);
v9 = cocos2d::CCDirector::sharedDirector(v8);
cocos2d::CCDirector::getWinSize(v9, &v72);
*(_OWORD *)Block = 0;
v86 = 0;
v87 = 0;
Block[0] = sub_14003D460(0x20u);
v86 = 23;
v87 = 31;
strcpy((char *)Block[0], "Advanced Random Trigger");
SetupTriggerPopup::addTitle(a1, Block);
v71 = (void **)operator new(0x2C8u);
v10 = (cocos2d::CCObject *)ButtonSprite::ButtonSprite((__int64)v71);
if ( v10 )
{
if ( ButtonSprite::init_1(
(__int64)v10,
(__int64)"OK",
40,
0,
1061997773,
1,
"goldFont.fnt",
(__int64)"GJ_button_01.png",
1106247680) )
{
cocos2d::CCObject::autorelease(v10);
}
else
{
(*(void (__fastcall **)(cocos2d::CCObject *, __int64))(*(_QWORD *)v10 + 8LL))(v10, 1);
LODWORD(v10) = 0;
}
}
v11 = CCMenuItemSpriteExtra::create((int)v10, 0, a1, (__int64)sub_14009D628);
(*(void (__fastcall **)(_QWORD, cocos2d::CCObject *))(**(_QWORD **)(a1 + 552) + 464LL))(*(_QWORD *)(a1 + 552), v11);
v71 = Block;
*(_OWORD *)Block = 0;
v86 = 0;
v87 = 0;
Block[0] = sub_14003D460(0xE0u);
v86 = 219;
v87 = 223;
strcpy(
(char *)Block[0],
"Triggers one of several groups randomly. Chance is how likely it is that the group is triggered. T"
"his value is then divided by the sum of the chances to calculate the chance in percentage for each group.");
v79 = 0;
v80 = 4;
v81 = 15;
strcpy((char *)&v79, "Help");
v12 = InfoAlertButton::create((__int64)&v79, (__int64)Block);
(*(void (__fastcall **)(_QWORD, char *))(**(_QWORD **)(a1 + 552) + 464LL))(*(_QWORD *)(a1 + 552), v12);
v13 = *(_QWORD *)v12;
v14 = *(_QWORD *)(a1 + 552);
cocos2d::CCPoint::CCPoint(
(cocos2d::CCPoint *)&v71,
(float)((float)(v72 * 0.5) - (float)(*(float *)(a1 + 732) * 0.5)) + 18.0,
(float)((float)(*(float *)(a1 + 736) * 0.5) + (float)(v73 * 0.5)) - 18.0);
cocos2d::CCNode::convertToNodeSpace(v14, &v74, v15);
(*(void (__fastcall **)(char *, __int64))(v13 + 184))(v12, v16);
cocos2d::CCPoint::CCPoint(
(cocos2d::CCPoint *)v84,
(float)((float)(v72 * 0.5) - 50.0) - 50.0,
(float)(v73 * 0.5) + 65.0);
cocos2d::CCPoint::CCPoint(
(cocos2d::CCPoint *)v82,
(float)((float)((float)(v72 * 0.5) + 50.0) - 50.0) + 35.0,
(float)(v73 * 0.5) + 65.0);
Block[1] = nullptr;
v86 = 7;
v87 = 15;
Block[0] = (void *)0x444970756F7247LL;
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v74, (const struct cocos2d::CCPoint *)v84);
v18 = IDNameInput::create(a1, a1 + 544, 1, 1, (__int64)Block, v17, 1065353216, 6, 0, 0, 0);
if ( v87 > 0xF )
{
v19 = Block[0];
if ( v87 + 1 >= 0x1000 )
{
v19 = *((void **)Block[0] - 1);
if ( (unsigned __int64)((char *)Block[0] - (char *)v19 - 8) > 0x1F )
invoke_watson(nullptr, nullptr, nullptr, 0, 0);
}
j_j_free(v19);
}
v86 = 0;
v87 = 15;
LOBYTE(Block[0]) = 0;
if ( v18 )
v20 = *((_QWORD *)v18 + 48);
else
v20 = 0;
*(_QWORD *)(a1 + 1016) = v20;
v21 = cocos2d::CCLabelBMFont::create("Chance", "goldFont.fnt");
(*(void (__fastcall **)(struct cocos2d::CCLabelBMFont *))(*(_QWORD *)v21 + 160LL))(v21);
v22 = *(_QWORD *)v21;
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v74, 0.5, 0.0);
(*(void (__fastcall **)(struct cocos2d::CCLabelBMFont *, __int64))(v22 + 288))(v21, v23);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v74, 0.0, 25.0);
cocos2d::CCPoint::operator+(v82, &v71, v24);
(*(void (__fastcall **)(struct cocos2d::CCLabelBMFont *, void ***))(*(_QWORD *)v21 + 184LL))(v21, &v71);
(*(void (__fastcall **)(_QWORD, struct cocos2d::CCLabelBMFont *))(**(_QWORD **)(a1 + 584) + 464LL))(
*(_QWORD *)(a1 + 584),
v21);
cocos2d::CCRect::CCRect((cocos2d::CCRect *)Block, 0.0, 0.0, 40.0, 40.0);
v26 = (_QWORD *)cocos2d::extension::CCScale9Sprite::create("square02_small.png", v25);
v27 = v26[40];
v28 = *(void (__fastcall **)(_QWORD *, __int64))(v27 + 40);
LOBYTE(v27) = 100;
v28(v26 + 40, v27);
v29 = *v26;
cocos2d::CCSize::CCSize((cocos2d::CCSize *)&v74, 70.0, 30.0);
(*(void (__fastcall **)(_QWORD *, __int64))(v29 + 312))(v26, v30);
(*(void (__fastcall **)(_QWORD, _QWORD *, __int64))(**(_QWORD **)(a1 + 584) + 456LL))(
*(_QWORD *)(a1 + 584),
v26,
0xFFFFFFFFLL);
(*(void (__fastcall **)(_QWORD *, _BYTE *))(*v26 + 184LL))(v26, v82);
v33 = CCTextInputNode::create(v32, v31, (__int64)"Num");
*(_QWORD *)(a1 + 1024) = v33;
(*(void (__fastcall **)(_QWORD, char *, __int64))(**(_QWORD **)(a1 + 584) + 456LL))(*(_QWORD *)(a1 + 584), v33, 20);
v34 = **(_QWORD **)(a1 + 1024);
v35 = *(_QWORD *)(a1 + 1024);
v36 = (*(__int64 (__fastcall **)(_QWORD *))(*v26 + 200LL))(v26);
(*(void (__fastcall **)(__int64, __int64))(v34 + 184))(v35, v36);
v37 = *(_QWORD *)(a1 + 1024);
*(_DWORD *)(v37 + 564) = 1058642330;
CCTextInputNode::refreshLabel(v37);
v38 = *(_QWORD *)(a1 + 1024);
*(_DWORD *)(v38 + 560) = 1128792064;
CCTextInputNode::refreshLabel(v38);
(*(void (__fastcall **)(_QWORD, _QWORD))(**(_QWORD **)(*(_QWORD *)(a1 + 1024) + 592LL) + 336LL))(
*(_QWORD *)(*(_QWORD *)(a1 + 1024) + 592LL),
0);
*(_DWORD *)(*(_QWORD *)(a1 + 1024) + 608LL) = 5;
v86 = 10;
v87 = 15;
Block[0] = *(void **)"0123456789";
Block[1] = (void *)*(unsigned __int16 *)"89";
BYTE2(Block[1]) = 0;
CCTextInputNode::setAllowedChars(*(_QWORD *)(a1 + 1024), Block);
v75 = -21896;
v39 = *(_QWORD *)(a1 + 1024);
*(_WORD *)(v39 + 572) = -21896;
*(_BYTE *)(v39 + 574) = -16;
CCTextInputNode::refreshLabel(v39);
v40 = *(_QWORD *)(a1 + 1024);
*(_DWORD *)(v40 + 568) = 1056964608;
CCTextInputNode::refreshLabel(v40);
*(_QWORD *)(*(_QWORD *)(a1 + 1024) + 600LL) = a1 + 544;
*(_BYTE *)(*(_QWORD *)(a1 + 1024) + 424LL) = 1;
(*(void (__fastcall **)(_QWORD, __int64))(**(_QWORD **)(a1 + 1024) + 64LL))(*(_QWORD *)(a1 + 1024), 2);
v41 = cocos2d::CCString::createWithFormat((const char *)&word_1406ED6F8, 10);
CString = cocos2d::CCString::getCString(v41);
v79 = 0;
v80 = 0;
v81 = 0;
v43 = -1;
do
++v43;
while ( CString[v43] );
sub_14003D230(&v79, CString, v43);
CCTextInputNode::setString(*(_QWORD **)(a1 + 1024), &v79);
v74 = operator new(0x2C8u);
v44 = (cocos2d::CCObject *)ButtonSprite::ButtonSprite((__int64)v74);
if ( v44 )
{
if ( ButtonSprite::init_1(
(__int64)v44,
(__int64)"Add",
50,
0,
1060320051,
1,
"goldFont.fnt",
(__int64)"GJ_button_04.png",
1103626240) )
{
cocos2d::CCObject::autorelease(v44);
}
else
{
(*(void (__fastcall **)(cocos2d::CCObject *, __int64))(*(_QWORD *)v44 + 8LL))(v44, 1);
LODWORD(v44) = 0;
}
}
v45 = CCMenuItemSpriteExtra::create((int)v44, 0, a1, (__int64)SetupRandAdvTriggerPopup::onAddChance);
(*(void (__fastcall **)(_QWORD, cocos2d::CCObject *))(**(_QWORD **)(a1 + 552) + 464LL))(*(_QWORD *)(a1 + 552), v45);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v74, 95.0, 0.0);
v47 = v46;
v48 = (*(__int64 (__fastcall **)(_QWORD))(**(_QWORD **)(a1 + 1024) + 200LL))(*(_QWORD *)(a1 + 1024));
cocos2d::CCPoint::operator+(v48, &v71, v47);
v49 = *(_QWORD *)v45;
cocos2d::CCNode::convertToNodeSpace(*(_QWORD *)(a1 + 552), v76, &v71);
(*(void (__fastcall **)(cocos2d::CCObject *, __int64))(v49 + 184))(v45, v50);
cocos2d::CCRect::CCRect((cocos2d::CCRect *)Block, 0.0, 0.0, 80.0, 80.0);
v52 = (__int64 *)cocos2d::extension::CCScale9Sprite::create("square02_001.png", v51);
v53 = v52[40];
v54 = *(void (__fastcall **)(__int64 *, __int64))(v53 + 40);
LOBYTE(v53) = 50;
v54(v52 + 40, v53);
v55 = *v52;
cocos2d::CCSize::CCSize((cocos2d::CCSize *)v76, 350.0, 90.0);
(*(void (__fastcall **)(__int64 *, __int64))(v55 + 312))(v52, v56);
(*(void (__fastcall **)(_QWORD, __int64 *, __int64))(**(_QWORD **)(a1 + 584) + 456LL))(
*(_QWORD *)(a1 + 584),
v52,
0xFFFFFFFFLL);
v57 = *v52;
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v76, v72 * 0.5, (float)(v73 * 0.5) - 10.0);
(*(void (__fastcall **)(__int64 *, __int64))(v57 + 184))(v52, v58);
v59 = *(_QWORD *)(a1 + 552);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v76, (float)(v72 * 0.5) - 175.0, (float)(v73 * 0.5) - 10.0);
cocos2d::CCNode::convertToNodeSpace(v59, v83, v60);
v61 = cocos2d::CCSprite::createWithSpriteFrameName("GJ_arrow_03_001.png");
(*(void (__fastcall **)(cocos2d::CCSprite *))(*(_QWORD *)v61 + 160LL))(v61);
cocos2d::CCSprite::setFlipY(v61, 1);
(*(void (__fastcall **)(cocos2d::CCSprite *))(*(_QWORD *)v61 + 352LL))(v61);
v62 = CCMenuItemSpriteExtra::create((int)v61, 0, a1, (__int64)SetupRandAdvTriggerPopup::onGroupIDScrollDown);
*(_QWORD *)(a1 + 1040) = v62;
(*(void (__fastcall **)(_QWORD, cocos2d::CCObject *))(**(_QWORD **)(a1 + 552) + 464LL))(*(_QWORD *)(a1 + 552), v62);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v76, 0.0, 20.0);
cocos2d::CCPoint::operator+(v83, &v71, v63);
(*(void (__fastcall **)(_QWORD, void ***))(**(_QWORD **)(a1 + 1040) + 184LL))(*(_QWORD *)(a1 + 1040), &v71);
*(_DWORD *)(*(_QWORD *)(a1 + 1040) + 372LL) = 1069547520;
(*(void (__fastcall **)(_QWORD, _QWORD))(**(_QWORD **)(a1 + 1040) + 336LL))(*(_QWORD *)(a1 + 1040), 0);
v64 = cocos2d::CCSprite::createWithSpriteFrameName("GJ_arrow_03_001.png");
(*(void (__fastcall **)(struct cocos2d::CCSprite *))(*(_QWORD *)v64 + 160LL))(v64);
(*(void (__fastcall **)(struct cocos2d::CCSprite *))(*(_QWORD *)v64 + 352LL))(v64);
v65 = CCMenuItemSpriteExtra::create((int)v64, 0, a1, (__int64)SetupRandAdvTriggerPopup::onGroupIDScrollUp);
*(_QWORD *)(a1 + 1048) = v65;
(*(void (__fastcall **)(_QWORD, cocos2d::CCObject *))(**(_QWORD **)(a1 + 552) + 464LL))(*(_QWORD *)(a1 + 552), v65);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v76, 0.0, -20.0);
cocos2d::CCPoint::operator+(v83, &v71, v66);
(*(void (__fastcall **)(_QWORD, void ***))(**(_QWORD **)(a1 + 1048) + 184LL))(*(_QWORD *)(a1 + 1048), &v71);
*(_DWORD *)(*(_QWORD *)(a1 + 1048) + 372LL) = 1069547520;
(*(void (__fastcall **)(_QWORD, _QWORD))(**(_QWORD **)(a1 + 1048) + 336LL))(*(_QWORD *)(a1 + 1048), 0);
cocos2d::CCPoint::CCPoint(
(cocos2d::CCPoint *)v77,
(float)((float)(v72 * 0.5) - (float)(*(float *)(a1 + 732) * 0.5)) + 20.0,
(float)((float)(v73 * 0.5) - (float)(*(float *)(a1 + 736) * 0.5)) + 20.0);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v76, 0.0, 30.0);
cocos2d::CCPoint::operator+(v77, &v71, v67);
cocos2d::CCPoint::CCPoint(
(cocos2d::CCPoint *)&v74,
(float)((float)(v72 * 0.5) + (float)(*(float *)(a1 + 732) * 0.5)) - 76.0,
v78 + 30.0);
v69 = v68;
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)Block, (const struct cocos2d::CCPoint *)v77);
SetupTriggerPopup::createMultiTriggerItems(a1, &v71, v70, v69);
SetupRandAdvTriggerPopup::updateGroupIDButtons(a1);
*(_BYTE *)(a1 + 744) = 0;
return 1;
}
return result;
}