//
// PlayLayer::destroyPlayer from 0x405880 to 0x40604e (1998 bytes)
//
// 0 xrefs:
//
// This function is hookable on this platform (idp: arm, 32 bit: True, 64 bit: False!
//
// 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:47:27 +0000
//
int __fastcall PlayLayer::destroyPlayer(PlayLayer *this, PlayerObject *a2, GameObject *a3)
{
int result; // r0
PlayerObject *v5; // r10
int v6; // r3
GameManager *CurrentPercentInt; // r0
int v8; // r7
GameManager *v9; // r0
GameManager *GameVariable; // r0
GameManager *v11; // r0
int v12; // r6
int v13; // r6
PlayerObject *OtherPlayer; // r5
int v15; // r5
GJGameLevel *v16; // r0
int *v17; // r3
int v18; // r3
int v19; // r7
GameManager *v20; // r0
int v21; // r6
GJGameLevel *v22; // r0
int *v23; // r3
int v24; // r1
_BOOL4 v25; // r8
_BOOL4 v26; // r5
bool v27; // r9
double TempMilliTime; // r0
GameManager *v29; // r5
const char *v30; // r11
const cocos2d::CCPoint *v31; // r0
float v32; // s17
FMODAudioEngine *v33; // r0
FMOD::ChannelControl **v34; // r0
int v35; // r6
int v36; // r0
FMODAudioEngine *v37; // r7
GameManager *v38; // r0
GameManager *v39; // r0
int v40; // r0
float v41; // r1
float v42; // s14
float v43; // r0
cocos2d::CCSequence *v44; // r0
cocos2d::CCSequence *v45; // r6
cocos2d::CCFiniteTimeAction *v46; // r0
cocos2d::CCAction *v47; // r1
cocos2d::CCNode *v48; // r0
GameManager *v49; // r0
GameStatsManager *v50; // r0
GameStatsManager *v51; // r0
float v52; // s16
GameManager *v53; // r0
bool v54; // zf
GameManager *v55; // r0
GameManager *v56; // r0
GameManager *v57; // r0
GameStatsManager *UGV; // r0
GameStatsManager *v59; // r0
int v60; // r6
GameStatsManager *v61; // r0
char v62; // r0
GameManager *v63; // r0
DialogLayer *v64; // r0
int v65; // r2
_DWORD *v66; // r5
float v67; // r1
cocos2d::CCSequence *v68; // r0
cocos2d::CCSequence *v69; // r5
cocos2d::CCFiniteTimeAction *v70; // r0
cocos2d::CCAction *v71; // r5
bool v72[4]; // [sp+4h] [bp-48h]
int v73[2]; // [sp+1Ch] [bp-30h] BYREF
int v74[2]; // [sp+24h] [bp-28h] BYREF
int v75[3]; // [sp+2Ch] [bp-20h] BYREF
int v76; // [sp+38h] [bp-14h] BYREF
int v77; // [sp+3Ch] [bp-10h]
int v78; // [sp+40h] [bp-Ch]
result = _stack_chk_guard;
if ( a2 )
v5 = a2;
else
v5 = *((PlayerObject **)this + 519);
if ( *(_BYTE *)(*((_DWORD *)this + 519) + 2066) || *((_BYTE *)this + 10866) )
return result;
if ( a3 )
{
v6 = *((_DWORD *)this + 2913);
if ( v6 )
{
if ( *((_DWORD *)a3 + 195) == *(_DWORD *)(v6 + 780) )
{
*((_BYTE *)this + 11708) = 1;
return result;
}
}
}
cocos2d::CCNode::stopActionByTag(this, 20);
*((_BYTE *)this + 1438) = 1;
(*(void (__fastcall **)(PlayLayer *, int))(*(_DWORD *)this + 732))(this, 1065353216);
PlayLayer::commitJumps(this);
CurrentPercentInt = (GameManager *)PlayLayer::getCurrentPercentInt(this);
v8 = (int)CurrentPercentInt;
if ( !*((_BYTE *)this + 10784)
|| (v9 = (GameManager *)GameManager::sharedState(CurrentPercentInt),
(GameVariable = (GameManager *)GameManager::getGameVariable(v9, "0212")) == nullptr) )
{
GameVariable = (GameManager *)GJEffectManager::playerDied(*((GJEffectManager **)this + 381));
}
*((_DWORD *)this + 350) = 0;
if ( !*((_BYTE *)this + 10784) )
{
v11 = (GameManager *)GameManager::sharedState(GameVariable);
if ( !GameManager::getGameVariable(v11, "0014") )
GJBaseGameLayer::shakeCamera(this, 0.15, 1.0, 0.0);
}
*((_BYTE *)this + 10864) = 1;
if ( !*((_BYTE *)this + 11909) )
{
v12 = *(_DWORD *)(*((_DWORD *)this + 352) + 268) - *(_DWORD *)(*((_DWORD *)this + 352) + 272);
if ( (v12 == 1 || v12 == 1001) && !*(_BYTE *)(*((_DWORD *)this + 519) + 2104) && *((int *)this + 2647) > 1 )
PlayLayer::showHint(this);
}
if ( !*((_BYTE *)this + 11909) )
{
v13 = *(_DWORD *)(*((_DWORD *)this + 352) + 268) - *(_DWORD *)(*((_DWORD *)this + 352) + 272);
if ( (v13 == 3 || v13 == 1003) && !*(_BYTE *)(*((_DWORD *)this + 519) + 2105) && *((int *)this + 2647) > 1 )
PlayLayer::showHint(this);
}
*((_BYTE *)this + 10866) = 1;
if ( (*((_BYTE *)this + 11590) || *((_BYTE *)this + 11592))
&& !(*(int (__fastcall **)(_DWORD))(**((_DWORD **)this + 2894) + 176))(*((_DWORD *)this + 2894)) )
{
PlayLayer::toggleDebugDraw((cocos2d::CCDrawNode **)this);
}
PlayerObject::playerDestroyed(v5, 0);
if ( *((_BYTE *)this + 866) )
{
OtherPlayer = (PlayerObject *)GJBaseGameLayer::getOtherPlayer(this, v5);
GJBaseGameLayer::playExitDualEffect(this, OtherPlayer);
PlayerObject::playerDestroyed(OtherPlayer, 1);
}
v15 = *((unsigned __int8 *)this + 1424);
if ( *((_BYTE *)this + 1424) )
{
v18 = 0x80000000;
*((_DWORD *)this + 3000) = 0x80000000;
goto LABEL_41;
}
if ( !*((_BYTE *)this + 10784) )
{
v16 = (GJGameLevel *)(*(int (__fastcall **)(PlayerObject *))(*(_DWORD *)v5 + 96))(v5);
GJGameLevel::cellForPosition(v16, (const cocos2d::CCPoint *)v73, v74, v17);
if ( PlayLayer::dtCellKnown(this, v73[0], v74[0])
|| (v18 = v74[0], v73[0] == *((_DWORD *)this + 3000)) && v74[0] == *((_DWORD *)this + 3001) )
{
v15 = 1;
goto LABEL_42;
}
*((_DWORD *)this + 3000) = v73[0];
LABEL_41:
v15 = 0;
*((_DWORD *)this + 3001) = v18;
}
LABEL_42:
v19 = v8 & ~(v8 >> 31);
if ( v19 >= 99 )
v19 = 99;
*(float *)&v20 = COERCE_FLOAT(PlayLayer::tracksPercent(this));
if ( *(float *)&v20 != 0.0 && !*((_BYTE *)this + 11797) && !*((_BYTE *)this + 11798) && !*((_BYTE *)this + 10612) )
{
if ( !*((_BYTE *)this + 10784) && *((int *)this + 202) > 29 && !v15 )
{
GJGameLevel::recordDeath(
*((GJGameLevel **)this + 352),
*((_DWORD *)this + 2950),
v19,
*((_DWORD *)this + 2680) != 0);
if ( !*((_DWORD *)this + 2680) && v19 > *((_DWORD *)this + 2996) )
*((_DWORD *)this + 2996) = v19;
}
*(_DWORD *)(*((_DWORD *)this + 352) + 1188) = 2;
*(float *)&v20 = COERCE_FLOAT(PlayLayer::dtCommitPlaytime(this));
}
v21 = *((unsigned __int8 *)this + 11797);
if ( *((_BYTE *)this + 11797) )
goto LABEL_58;
if ( *((_BYTE *)this + 11798) )
goto LABEL_61;
if ( *((_BYTE *)this + 10612) || *((_BYTE *)this + 10784) || (v21 = *((_DWORD *)this + 2680)) != 0 )
{
LABEL_58:
v21 = 0;
goto LABEL_61;
}
if ( *((int *)this + 202) > 29 )
{
v21 = 1;
if ( !v15 )
{
v22 = (GJGameLevel *)(*(int (__fastcall **)(PlayerObject *))(*(_DWORD *)v5 + 96))(v5);
GJGameLevel::cellForPosition(v22, (const cocos2d::CCPoint *)v73, v74, v23);
*(float *)&v20 = COERCE_FLOAT(PlayLayer::dtBumpCell(this, v73[0], v74[0], v19));
*(_DWORD *)(*((_DWORD *)this + 352) + 1188) = 2;
*(_BYTE *)(*((_DWORD *)this + 352) + 1300) = 1;
}
}
LABEL_61:
if ( *((_BYTE *)this + 10836)
|| (*(float *)&v20 = COERCE_FLOAT(PlayLayer::tracksPercent(this)), *(float *)&v20 == 0.0) )
{
v29 = nullptr;
v30 = nullptr;
v27 = 0;
v25 = 0;
goto LABEL_92;
}
v25 = !*((_BYTE *)this + 10784) && v19 > GJGameLevel::getNormalPercent(*((GJGameLevel **)this + 352));
if ( *((_BYTE *)this + 10784) )
{
v26 = 0;
}
else
{
v24 = *((_DWORD *)this + 352);
v26 = v19 > *(_DWORD *)(v24 + 688) - *(_DWORD *)(v24 + 692);
}
if ( !*((_BYTE *)this + 12096) || *((_BYTE *)this + 10784) || v25 )
{
v27 = 0;
}
else
{
if ( !v26 )
v25 = v19 > *(_DWORD *)(*((_DWORD *)this + 352) + 700) - *(_DWORD *)(*((_DWORD *)this + 352) + 704);
v27 = v25;
}
TempMilliTime = PlayLayer::getTempMilliTime(this, v24);
*(float *)&v20 = COERCE_FLOAT(
GJGameLevel::savePercentage(
*((GJGameLevel **)this + 352),
v19,
*((_BYTE *)this + 10784),
*((_DWORD *)this + 2646),
(int)(TempMilliTime - *((double *)this + 1523) - *((double *)this + 1524)),
*((_BYTE *)this + 11708)));
if ( *(_DWORD *)(*((_DWORD *)this + 352) + 952) == 1 && !*((_BYTE *)this + 10614) )
{
v49 = (GameManager *)GameManager::sharedState(v20);
*(float *)&v20 = COERCE_FLOAT(
GameManager::reportPercentageForLevel(
v49,
*(_DWORD *)(*((_DWORD *)this + 352) + 268) - *(_DWORD *)(*((_DWORD *)this + 352) + 272),
v19,
*((_BYTE *)this + 10784)));
}
v29 = (GameManager *)*((unsigned __int8 *)this + 10784);
if ( *((_BYTE *)this + 10784) )
{
v29 = nullptr;
LABEL_91:
v30 = (const char *)v29;
goto LABEL_92;
}
if ( *(_DWORD *)(*((_DWORD *)this + 352) + 772) - *(_DWORD *)(*((_DWORD *)this + 352) + 776) <= 0 )
goto LABEL_91;
v50 = (GameStatsManager *)GameStatsManager::sharedState(v20);
v30 = (const char *)GameStatsManager::awardCurrencyForLevel(v50, *((GJGameLevel **)this + 352));
*(float *)&v20 = COERCE_FLOAT(GJGameLevel::levelHasDiamonds(*((GJGameLevel **)this + 352)));
if ( *(float *)&v20 != 0.0 )
{
v51 = (GameStatsManager *)GameStatsManager::sharedState(v20);
*(float *)&v20 = COERCE_FLOAT(GameStatsManager::awardDiamondsForLevel(v51, *((GJGameLevel **)this + 352)));
}
v29 = v20;
LABEL_92:
if ( !*((_BYTE *)this + 10784) )
*((_DWORD *)this + 3025) = v19;
if ( v21 )
{
v31 = (const cocos2d::CCPoint *)(*(int (__fastcall **)(PlayerObject *))(*(_DWORD *)v5 + 96))(v5);
*(float *)&v20 = COERCE_FLOAT(PlayLayer::tryShowDeathMarkers(this, v31, v19, v25));
v32 = *(float *)&v20;
}
else
{
v32 = 0.0;
}
if ( !*((_BYTE *)this + 1006) )
{
if ( !*((_BYTE *)this + 10784) || *((_BYTE *)this + 10785) )
{
v33 = (FMODAudioEngine *)FMODAudioEngine::sharedEngine(v20);
*(float *)&v20 = COERCE_FLOAT(FMODAudioEngine::pauseAllMusic(v33, 0));
}
v34 = (FMOD::ChannelControl **)FMODAudioEngine::sharedEngine(v20);
*(float *)&v20 = COERCE_FLOAT(FMODAudioEngine::stopAllEffects(v34));
}
v35 = *((unsigned __int8 *)this + 1012);
if ( !*((_BYTE *)this + 1012) )
{
v36 = FMODAudioEngine::sharedEngine(v20);
v76 = v35;
v77 = v35;
v78 = v35;
v37 = (FMODAudioEngine *)v36;
std::string::__init(&v76, "explode_11.ogg", 0xEu);
FMODAudioEngine::playEffect(v37, (int)&v76, 1065353216, 0, 1059481190);
*(float *)&v20 = COERCE_FLOAT(std::string::~string((int)&v76));
}
v38 = (GameManager *)GameManager::sharedState(v20);
v39 = (GameManager *)GameManager::getGameVariable(v38, "0026");
if ( !v39 && !*((_BYTE *)this + 10784) )
{
if ( (int)v29 + (int)v30 > 0 )
v39 = (GameManager *)PlayLayer::showNewBest(this, !v25, v30, (const char *)v29, 0, 0, 0);
v40 = GameManager::sharedState(v39);
UILayer::disableMenu(*(UILayer **)(*(_DWORD *)(v40 + 404) + 11240));
v42 = *((float *)this + 252);
shouldRefreshBanner = 0;
if ( v42 > 0.5 )
v43 = v42;
else
v43 = 0.5;
v44 = (cocos2d::CCSequence *)cocos2d::CCDelayTime::create((cocos2d::CCDelayTime *)LODWORD(v43), v41);
v74[1] = 0;
v74[0] = (int)PlayLayer::showRetryLayer;
v45 = v44;
v46 = (cocos2d::CCFiniteTimeAction *)cocos2d::CCCallFunc::create(this, PlayLayer::showRetryLayer, 0);
v47 = (cocos2d::CCAction *)cocos2d::CCSequence::create(v45, v46, 0);
v48 = this;
return cocos2d::CCNode::runAction(v48, v47);
}
*((_BYTE *)this + 12098) = 1;
v52 = 1.0;
v53 = (GameManager *)GameManager::sharedState(v39);
v54 = GameManager::getGameVariable(v53, "0052") == 0;
v55 = (GameManager *)*((unsigned __int8 *)this + 10784);
if ( !v54 )
v52 = 0.5;
if ( v32 > 0.0 )
v52 = v32;
if ( *((_BYTE *)this + 10784) )
{
v56 = (GameManager *)GameManager::sharedState(v55);
v55 = (GameManager *)GameManager::getGameVariable(v56, "0212");
}
if ( *((float *)this + 252) > v52 && !v55 )
v52 = *((float *)this + 252);
if ( v25 || (int)v29 + (int)v30 > 0 )
{
v57 = (GameManager *)GameManager::sharedState(v55);
UGV = (GameStatsManager *)GameManager::getUGV(v57, "17");
if ( UGV )
{
v60 = 0;
}
else
{
v59 = (GameStatsManager *)GameStatsManager::sharedState(nullptr);
UGV = (GameStatsManager *)GameStatsManager::getStat(v59, "14");
v60 = (int)UGV > 500;
}
if ( !v25 && (int)v29 + (int)v30 <= 0 )
goto LABEL_137;
v61 = (GameStatsManager *)GameStatsManager::sharedState(UGV);
v62 = GameStatsManager::awardSecretKey(v61);
UGV = (GameStatsManager *)PlayLayer::showNewBest(this, !v25, v30, (const char *)v29, v62, v60, v27);
if ( v52 < 1.4 )
v52 = 1.4;
if ( (int)v29 + (int)v30 > 0 )
{
if ( !v60 )
return cocos2d::CCNode::stopActionByTag(this, 16);
}
else
{
LABEL_137:
if ( !v60 )
goto LABEL_140;
}
v63 = (GameManager *)GameManager::sharedState(UGV);
GameManager::setUGV(v63, "17", 1);
memset(v75, 0, sizeof(v75));
std::string::__init(v75, "The Shopkeeper", 0xEu);
v76 = 0;
v77 = 0;
v78 = 0;
std::string::__init(&v76, "I see you have a lot of orbs. You should visit my shop!", 0x47u);
*(_WORD *)v72 = -1;
v72[2] = -1;
v64 = (DialogLayer *)DialogObject::create(v75, &v76, 5, 1065353216, 0, *(_DWORD *)v72);
v66 = (_DWORD *)DialogLayer::create(v64, (DialogObject *)((char *)&dword_0 + 1), v65);
std::string::~string((int)&v76);
std::string::~string((int)v75);
v60 = 1;
(*(void (__fastcall **)(PlayLayer *, _DWORD *, int))(*(_DWORD *)this + 232))(this, v66, 100);
(*(void (__fastcall **)(_DWORD *, _DWORD))(*v66 + 584))(v66, 0);
v66[122] = (char *)this + 11696;
DialogLayer::updateChatPlacement(v66, 1);
DialogLayer::animateIn(v66, 4);
}
else
{
v60 = 0;
}
LABEL_140:
result = cocos2d::CCNode::stopActionByTag(this, 16);
if ( !v60 )
{
v68 = (cocos2d::CCSequence *)cocos2d::CCDelayTime::create((cocos2d::CCDelayTime *)LODWORD(v52), v67);
v73[1] = 0;
v73[0] = (int)PlayLayer::delayedResetLevel;
v69 = v68;
v70 = (cocos2d::CCFiniteTimeAction *)cocos2d::CCCallFunc::create(this, PlayLayer::delayedResetLevel, 0);
v71 = (cocos2d::CCAction *)cocos2d::CCSequence::create(v69, v70, 0);
(*(void (__fastcall **)(cocos2d::CCAction *, int))(*(_DWORD *)v71 + 36))(v71, 16);
v48 = this;
v47 = v71;
return cocos2d::CCNode::runAction(v48, v47);
}
return result;
}