//
// ChallengeNode::init from 0x100032e3c to 0x1000339d8 (2972 bytes)
//
// 1 xrefs:
// > ChallengeNode::create @ 0x100032a74
//
// This function is hookable on this platform!
//
// Using BromaIDA 8.0.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit ba9f177b at Thu Jul 16 22:52:06 2026 from https://github.com/geode-sdk/bindings
//
bool __fastcall ChallengeNode::init(ChallengeNode *a1, GJChallengeItem *a2, ChallengesPage *a3, bool a4)
{
_BOOL4 v4; // w22
_BOOL4 v8; // w19
GJChallengeItem *m_challengeItem; // x8
const char *v10; // x24
cocos2d::extension::CCScale9Sprite *v11; // x23
std::string *p_m_name; // x0
cocos2d::CCLabelBMFont *v13; // x23
__n128 v14; // q0
__n128 v15; // q1
__n128 v16; // q0
__n128 v17; // q1
GJChallengeType m_challengeType; // w8
const std::string::value_type *v19; // x1
cocos2d::CCLabelBMFont *v20; // x0
const std::string::value_type *v21; // x1
std::string *v22; // x0
std::string *v23; // x9
cocos2d::CCString *v24; // x0
const char *CString; // x0
cocos2d::CCLabelBMFont *v26; // x24
__n128 v27; // q0
__n128 v28; // q1
float32x2_t *v29; // x25
__n128 v30; // q0
__n128 v31; // q1
double v32; // d0
void **v33; // x0
cocos2d::CCSprite *v34; // x24
float32x2_t *v35; // x25
float v36; // s9
float v37; // s8
float v38; // s10
__n128 v39; // q0
__n128 v40; // q1
double v41; // d0
cocos2d::CCLabelBMFont *v42; // x22
__n128 v43; // q0
__n128 v44; // q1
float v45; // s8
float v46; // s9
float v47; // s10
__n128 v48; // q0
__n128 v49; // q1
cocos2d::CCSprite *v50; // x22
__n128 v51; // q0
__n128 v52; // q1
__n128 v53; // q0
__n128 v54; // q1
cocos2d::CCSprite *v55; // x23
float width; // s8
__n128 v57; // q0
__n128 v58; // q1
__int64 v59; // x0
__n128 v60; // q0
__n128 v61; // q1
int v62; // w8
float v63; // s1
float v64; // s2
cocos2d::CCString *v65; // x0
const char *v66; // x0
cocos2d::CCLabelBMFont *v67; // x23
float32x2_t *v68; // x24
__n128 v69; // q0
__n128 v70; // q1
double v71; // d0
cocos2d::CCSprite *v72; // x22
CCMenuItemSpriteExtra *v73; // x22
cocos2d::CCMenu *v74; // x22
__n128 v75; // q0
__n128 v76; // q1
cocos2d::CCSprite *v77; // x23
__n128 v78; // q0
__n128 v79; // q1
cocos2d::CCString *v80; // x0
const char *v81; // x0
cocos2d::CCLabelBMFont *v82; // x21
__n128 v83; // q0
__n128 v84; // q1
float32x2_t *v85; // x23
__n128 v86; // q0
__n128 v87; // q1
double v88; // d0
double *v89; // x0
cocos2d::CCSprite *v90; // x22
__n128 v91; // q0
__n128 v92; // q1
cocos2d::CCString *v93; // x0
const char *v94; // x0
cocos2d::CCLabelBMFont *v95; // x21
__n128 v96; // q0
__n128 v97; // q1
float32x2_t *v98; // x20
__n128 v99; // q0
__n128 v100; // q1
double v101; // d0
float32x2_t v103[2]; // [xsp+14h] [xbp-ACh] BYREF
__int16 v104; // [xsp+24h] [xbp-9Ch] BYREF
char v105; // [xsp+26h] [xbp-9Ah]
float32x2_t v106; // [xsp+28h] [xbp-98h] BYREF
void *__p[2]; // [xsp+30h] [xbp-90h] BYREF
char v108; // [xsp+47h] [xbp-79h]
std::string v109; // [xsp+48h] [xbp-78h] BYREF
cocos2d::SEL_MenuHandler v110; // 0:x3.16
cocos2d::CCRect v111; // 0:s0.4,4:s1.4,8:s2.4,12:s3.4
v4 = a4;
v8 = cocos2d::CCNode::init(a1);
if ( !v8 )
return v8;
a1->m_challengeItem = a2;
if ( a2 )
{
cocos2d::CCObject::retain(a2);
m_challengeItem = a1->m_challengeItem;
v10 = "GJ_square02.png";
if ( m_challengeItem && m_challengeItem->m_canClaim )
v10 = "GJ_square03.png";
}
else
{
v10 = "GJ_square02.png";
}
a1->m_challengesPage = a3;
sub_100022990((float *)&v109, 0.0, 0.0, 80.0, 80.0);
v11 = cocos2d::extension::CCScale9Sprite::create(v10, v111);
((void (__fastcall *)(cocos2d::extension::CCScale9Sprite *, __int64))v11->setOpacity)(v11, 255);
sub_100022988((float *)&v109, 300.0, 70.0);
((void (__fastcall *)(cocos2d::extension::CCScale9Sprite *, std::string *))v11->setContentSize)(v11, &v109);
((void (__fastcall *)(ChallengeNode *, cocos2d::extension::CCScale9Sprite *, __int64))a1->addChild_0)(
a1,
v11,
0xFFFFFFFFLL);
if ( !a1->m_challengeItem )
{
((void (__fastcall *)(cocos2d::extension::CCScale9Sprite *, void *))v11->setColor)(v11, &unk_100635790);
((void (__fastcall *)(cocos2d::extension::CCScale9Sprite *, __int64))v11->setOpacity)(v11, 75);
v20 = cocos2d::CCLabelBMFont::create_1("00:00:00", "bigFont.fnt");
a1->m_countdownLabel = v20;
((void (__fastcall *)(cocos2d::CCLabelBMFont *, float))v20->setScale)(v20, 0.5);
((void (__fastcall *)(ChallengeNode *, cocos2d::CCLabelBMFont *))a1->addChild)(a1, a1->m_countdownLabel);
a1->m_unloaded = 1;
return v8;
}
p_m_name = &a2->m_name;
if ( a2->m_name.m_data.m_short.shortStorage.__elems_[22] < 0 )
p_m_name = (std::string *)p_m_name->m_data.m_long.capacitym1;
v13 = cocos2d::CCLabelBMFont::create_1((const char *)p_m_name, "bigFont.fnt");
((void (__fastcall *)(ChallengeNode *, cocos2d::CCLabelBMFont *))a1->addChild)(a1, v13);
v14 = ((__n128 (__fastcall *)(cocos2d::CCLabelBMFont *, float))v13->setScale)(v13, 0.5);
v14.n128_u32[0] = 0;
v15.n128_u32[0] = 1.0;
sub_100022980(v14, v15, &v109);
v16 = ((__n128 (__fastcall *)(cocos2d::CCLabelBMFont *, std::string *))v13->setAnchorPoint)(v13, &v109);
v16.n128_u32[0] = -1022623744;
v17.n128_u32[0] = 29.0;
sub_100022980(v16, v17, &v109);
((void (__fastcall *)(cocos2d::CCLabelBMFont *, std::string *))v13->setPosition)(v13, &v109);
sub_100009900(&v109, "");
sub_100009900(__p, "currencyOrbIcon_001.png");
m_challengeType = a2->m_challengeType;
switch ( m_challengeType )
{
case 3:
std::string::assign(&v109, "Stars/Moons");
v19 = "GJ_starsIcon_001.png";
break;
case 2:
if ( a2->m_goal.random - a2->m_goal.seed == 1 )
v21 = "Silver Coin";
else
v21 = "Silver Coins";
std::string::assign(&v109, v21);
v19 = "GJ_coinsIcon2_001.png";
break;
case 1:
std::string::assign(&v109, "Mana Orbs");
v19 = "currencyOrbIcon_001.png";
break;
default:
v19 = "?";
v22 = &v109;
goto LABEL_23;
}
v22 = (std::string *)__p;
LABEL_23:
std::string::assign(v22, v19);
v23 = &v109;
if ( (v109.__r_.__value_.__r.__words[2] & 0x8000000000000000LL) != 0LL )
v23 = (std::string *)v109.__r_.__value_.__r.__words[0];
v24 = (cocos2d::CCString *)sub_100268F4C("Collect %i %s.", a2->m_goal.random - a2->m_goal.seed, (const char *)v23);
CString = cocos2d::CCString::getCString(v24);
v26 = cocos2d::CCLabelBMFont::create_1(CString, "goldFont.fnt");
v27.n128_u32[0] = 0;
v28.n128_u32[0] = 1.0;
sub_100022980(v27, v28, v103);
((void (__fastcall *)(cocos2d::CCLabelBMFont *, float32x2_t *))v26->setAnchorPoint)(v26, v103);
v29 = (float32x2_t *)((__int64 (__fastcall *)(cocos2d::CCLabelBMFont *))v13->getPosition)(v13);
v30.n128_u32[0] = 0;
v31.n128_u32[0] = -20.0;
sub_100022980(v30, v31, &v106);
*(float32x2_t *)&v32 = sub_1000229DC(v29, &v106, v103);
((void (__fastcall *)(cocos2d::CCLabelBMFont *, float32x2_t *, double))v26->setPosition)(v26, v103, v32);
((void (__fastcall *)(cocos2d::CCLabelBMFont *, float))v26->setScale)(v26, 0.5);
((void (__fastcall *)(ChallengeNode *, cocos2d::CCLabelBMFont *))a1->addChild)(a1, v26);
if ( v108 >= 0 )
v33 = __p;
else
v33 = (void **)__p[0];
v34 = cocos2d::CCSprite::createWithSpriteFrameName((const char *)v33);
((void (__fastcall *)(ChallengeNode *, cocos2d::CCSprite *))a1->addChild)(a1, v34);
((void (__fastcall *)(cocos2d::CCSprite *, float))v34->setScale)(v34, 0.7);
v35 = (float32x2_t *)((__int64 (__fastcall *)(cocos2d::CCLabelBMFont *))v13->getPosition)(v13);
v36 = *(float *)((__int64 (__fastcall *)(cocos2d::CCLabelBMFont *))v13->getContentSize)(v13);
v37 = ((float (__fastcall *)(cocos2d::CCLabelBMFont *))v13->getScale)(v13);
v38 = *(float *)(((__int64 (__fastcall *)(cocos2d::CCLabelBMFont *))v13->getContentSize)(v13) + 4);
v39.n128_f64[0] = ((double (__fastcall *)(cocos2d::CCLabelBMFont *))v13->getScale)(v13);
v40.n128_f32[0] = (float)((float)(v38 * v39.n128_f32[0]) * -0.5) + -1.0;
v39.n128_f32[0] = (float)(v36 * v37) + 14.0;
sub_100022980(v39, v40, &v106);
*(float32x2_t *)&v41 = sub_1000229DC(v35, &v106, v103);
((void (__fastcall *)(cocos2d::CCSprite *, float32x2_t *, double))v34->setPosition)(v34, v103, v41);
if ( v4 )
{
v42 = cocos2d::CCLabelBMFont::create_1("New!", "goldFont.fnt");
v43.n128_u32[0] = 0;
v44.n128_u32[0] = 0.5;
sub_100022980(v43, v44, v103);
((void (__fastcall *)(cocos2d::CCLabelBMFont *, float32x2_t *))v42->setAnchorPoint)(v42, v103);
v45 = *(float *)((__int64 (__fastcall *)(cocos2d::CCSprite *))v34->getPosition)(v34);
v46 = *(float *)(((__int64 (__fastcall *)(cocos2d::CCLabelBMFont *))v13->getPosition)(v13) + 4);
v47 = *(float *)(((__int64 (__fastcall *)(cocos2d::CCLabelBMFont *))v13->getContentSize)(v13) + 4);
v48.n128_f64[0] = ((double (__fastcall *)(cocos2d::CCLabelBMFont *))v13->getScale)(v13);
v49.n128_f32[0] = v46 + (float)((float)(v47 * v48.n128_f32[0]) * -0.5);
v48.n128_f32[0] = v45 + 15.0;
sub_100022980(v48, v49, v103);
((void (__fastcall *)(cocos2d::CCLabelBMFont *, float32x2_t *))v42->setPosition)(v42, v103);
((void (__fastcall *)(cocos2d::CCLabelBMFont *, float))v42->setScale)(v42, 0.6);
((void (__fastcall *)(ChallengeNode *, cocos2d::CCLabelBMFont *))a1->addChild)(a1, v42);
}
v105 = 0;
v104 = 0;
v50 = cocos2d::CCSprite::create("GJ_progressBar_001.png");
((void (__fastcall *)(cocos2d::CCSprite *, __int16 *))v50->setColor)(v50, &v104);
((void (__fastcall *)(cocos2d::CCSprite *, __int64))v50->setOpacity)(v50, 125);
((void (__fastcall *)(cocos2d::CCSprite *, float))v50->setScaleX)(v50, 0.5);
((void (__fastcall *)(cocos2d::CCSprite *, float))v50->setScaleY)(v50, 0.525);
v51 = ((__n128 (__fastcall *)(ChallengeNode *, cocos2d::CCSprite *, __int64))a1->addChild_0)(a1, v50, 3);
v51.n128_u32[0] = 0;
v52.n128_u32[0] = 1.0;
sub_100022980(v51, v52, v103);
v53 = ((__n128 (__fastcall *)(cocos2d::CCSprite *, float32x2_t *))v50->setAnchorPoint)(v50, v103);
v53.n128_u32[0] = -1022623744;
v54.n128_u32[0] = -13.0;
sub_100022980(v53, v54, v103);
((void (__fastcall *)(cocos2d::CCSprite *, float32x2_t *))v50->setPosition)(v50, v103);
v55 = cocos2d::CCSprite::create("GJ_progressBar_001.png");
((void (__fastcall *)(cocos2d::CCSprite *, float))v55->setScaleX)(v55, 0.98);
((void (__fastcall *)(cocos2d::CCSprite *, float))v55->setScaleY)(v55, 0.78);
((void (__fastcall *)(cocos2d::CCSprite *, void *))v55->setColor)(v55, &unk_100635793);
width = v55->m_obRect.size.width;
v57 = ((__n128 (__fastcall *)(cocos2d::CCSprite *, cocos2d::CCSprite *, __int64))v50->addChild_0)(v50, v55, 1);
v57.n128_u32[0] = 0;
v58.n128_u32[0] = 0.5;
sub_100022980(v57, v58, v103);
((void (__fastcall *)(cocos2d::CCSprite *, float32x2_t *))v55->setAnchorPoint)(v55, v103);
v59 = ((__int64 (__fastcall *)(cocos2d::CCSprite *))v50->getContentSize)(v50);
v60.n128_f32[0] = (float)(width + (float)(width * -0.98)) * 0.5;
v61.n128_f32[0] = *(float *)(v59 + 4) * 0.5;
sub_100022980(v60, v61, v103);
((void (__fastcall *)(cocos2d::CCSprite *, float32x2_t *))v55->setPosition)(v55, v103);
v62 = a2->m_goal.random - a2->m_goal.seed;
v63 = v55->m_obRect.size.width;
if ( v63 <= (float)(v63 * (float)((float)(a2->m_count.random - a2->m_count.seed) / (float)v62)) )
v64 = v55->m_obRect.size.width;
else
v64 = v63 * (float)((float)(a2->m_count.random - a2->m_count.seed) / (float)v62);
sub_100022990((float *)v103, 0.0, 0.0, v64, v55->m_obRect.size.height);
((void (__fastcall *)(cocos2d::CCSprite *, float32x2_t *))v55->setTextureRect)(v55, v103);
v65 = (cocos2d::CCString *)sub_100268F4C(
"%i / %i",
a2->m_count.random - a2->m_count.seed,
a2->m_goal.random - a2->m_goal.seed);
v66 = cocos2d::CCString::getCString(v65);
v67 = cocos2d::CCLabelBMFont::create_1(v66, "bigFont.fnt");
((void (__fastcall *)(cocos2d::CCLabelBMFont *, float))v67->setScale)(v67, 0.28);
((void (__fastcall *)(ChallengeNode *, cocos2d::CCLabelBMFont *, __int64))a1->addChild_0)(a1, v67, 4);
v68 = (float32x2_t *)((__int64 (__fastcall *)(cocos2d::CCSprite *))v50->getPosition)(v50);
v69.n128_f32[0] = (float)(*(float *)((__int64 (__fastcall *)(cocos2d::CCSprite *))v50->getContentSize)(v50) * 0.5)
* 0.5;
v70.n128_u32[0] = -5.0;
sub_100022980(v69, v70, &v106);
*(float32x2_t *)&v71 = sub_1000229DC(v68, &v106, v103);
((void (__fastcall *)(cocos2d::CCLabelBMFont *, float32x2_t *, double))v67->setPosition)(v67, v103, v71);
if ( a2->m_canClaim )
{
v72 = cocos2d::CCSprite::createWithSpriteFrameName("GJ_rewardBtn_001.png");
((void (__fastcall *)(cocos2d::CCSprite *, float))v72->setScale)(v72, 0.8);
v110.ptr = (void (__cdecl *)(cocos2d::CCObject *))ChallengeNode::onClaimReward;
v110.adj = 0;
v73 = CCMenuItemSpriteExtra::create(v72, nullptr, a1, v110);
CCMenuItemSpriteExtra::setSizeMult(v73, 1.5);
v74 = cocos2d::CCMenu::createWithItem(v73);
v75 = ((__n128 (__fastcall *)(ChallengeNode *, cocos2d::CCMenu *))a1->addChild)(a1, v74);
v75.n128_u32[0] = 1122369536;
v76.n128_u32[0] = 0;
sub_100022980(v75, v76, v103);
((void (__fastcall *)(cocos2d::CCMenu *, float32x2_t *))v74->setPosition)(v74, v103);
v77 = cocos2d::CCSprite::createWithSpriteFrameName("GJ_bigDiamond_001.png");
((void (__fastcall *)(ChallengeNode *, cocos2d::CCSprite *))a1->addChild)(a1, v77);
v78 = ((__n128 (__fastcall *)(cocos2d::CCSprite *, float))v77->setScale)(v77, 0.6);
v78.n128_u32[0] = 1116471296;
v79.n128_u32[0] = 0;
sub_100022980(v78, v79, v103);
((void (__fastcall *)(cocos2d::CCSprite *, float32x2_t *))v77->setPosition)(v77, v103);
v80 = (cocos2d::CCString *)sub_100268F4C("%ix", a2->m_reward.random - a2->m_reward.seed);
v81 = cocos2d::CCString::getCString(v80);
v82 = cocos2d::CCLabelBMFont::create_1(v81, "bigFont.fnt");
v83 = ((__n128 (__fastcall *)(ChallengeNode *, cocos2d::CCLabelBMFont *))a1->addChild)(a1, v82);
v83.n128_u32[0] = 1.0;
v84.n128_u32[0] = 0.5;
sub_100022980(v83, v84, v103);
((void (__fastcall *)(cocos2d::CCLabelBMFont *, float32x2_t *))v82->setAnchorPoint)(v82, v103);
((void (__fastcall *)(cocos2d::CCLabelBMFont *, float))v82->setScale)(v82, 0.4);
v85 = (float32x2_t *)((__int64 (__fastcall *)(cocos2d::CCSprite *))v77->getPosition)(v77);
v86.n128_u32[0] = -14.0;
v87.n128_u32[0] = 0;
sub_100022980(v86, v87, &v106);
*(float32x2_t *)&v88 = sub_1000229DC(v85, &v106, v103);
((void (__fastcall *)(cocos2d::CCLabelBMFont *, float32x2_t *, double))v82->setPosition)(v82, v103, v88);
v89 = (double *)((__int64 (__fastcall *)(cocos2d::CCMenu *))v74->getPosition)(v74);
sub_1000229D0(&a1->m_unkPoint, v89);
}
else
{
v90 = cocos2d::CCSprite::createWithSpriteFrameName("GJ_bigDiamond_001.png");
((void (__fastcall *)(ChallengeNode *, cocos2d::CCSprite *))a1->addChild)(a1, v90);
v91 = ((__n128 (__fastcall *)(cocos2d::CCSprite *, float))v90->setScale)(v90, 0.8);
v91.n128_u32[0] = 1122762752;
v92.n128_u32[0] = 0;
sub_100022980(v91, v92, v103);
((void (__fastcall *)(cocos2d::CCSprite *, float32x2_t *))v90->setPosition)(v90, v103);
v93 = (cocos2d::CCString *)sub_100268F4C("%ix", a2->m_reward.random - a2->m_reward.seed);
v94 = cocos2d::CCString::getCString(v93);
v95 = cocos2d::CCLabelBMFont::create_1(v94, "bigFont.fnt");
v96 = ((__n128 (__fastcall *)(ChallengeNode *, cocos2d::CCLabelBMFont *))a1->addChild)(a1, v95);
v96.n128_u32[0] = 1.0;
v97.n128_u32[0] = 0.5;
sub_100022980(v96, v97, v103);
((void (__fastcall *)(cocos2d::CCLabelBMFont *, float32x2_t *))v95->setAnchorPoint)(v95, v103);
((void (__fastcall *)(cocos2d::CCLabelBMFont *, float))v95->setScale)(v95, 0.6);
v98 = (float32x2_t *)((__int64 (__fastcall *)(cocos2d::CCSprite *))v90->getPosition)(v90);
v99.n128_u32[0] = -20.0;
v100.n128_u32[0] = 0;
sub_100022980(v99, v100, &v106);
*(float32x2_t *)&v101 = sub_1000229DC(v98, &v106, v103);
((void (__fastcall *)(cocos2d::CCLabelBMFont *, float32x2_t *, double))v95->setPosition)(v95, v103, v101);
}
if ( v108 < 0 )
operator delete(__p[0]);
if ( SHIBYTE(v109.__r_.__value_.__r.__words[2]) < 0 )
operator delete(v109.__r_.__value_.__l.__data_);
return v8;
}