//
// PlayLayer::destroyPlayer from 0x1403b39d0 to 0x1403b472f (3423 bytes)
//
// 2 xrefs:
// > ??> @ 0x1405c9bf8
// > ??> @ 0x1406d6ecc
//
// 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
//
// Hidden C++ exception states: #wind=21
void PlayLayer::destroyPlayer(PlayLayer *a1, PlayerObject *a2, GameObject *a3)
{
float v3; // xmm3_4
PlayerObject *m_player1; // r12
GameObject *m_anticheatSpike; // rax
unsigned __int64 v7; // rdx
GJEffectManager *m_effectManager; // r14
int v9; // r15d
std::_Vector_val>::pointer Myfirst; // rbx
__int64 v11; // rsi
GameManager *v12; // rcx
int v13; // ecx
int v14; // ecx
PlayerObject *m_player2; // rbx
bool v16; // si
char v17; // r14
int v18; // r13d
int v19; // r12d
float CurrentPercent; // xmm0_4
int v21; // ebx
__int64 v22; // r9
__int64 v23; // r8
bool m_isPracticeMode; // dl
GJGameLevel *m_level; // rax
double v26; // xmm0_8
GameManager *v27; // rcx
GJGameLevel **p_m_level; // r14
GameStatsManager *v29; // rcx
int v30; // eax
GameStatsManager *v31; // rcx
int v32; // eax
int v33; // r15d
float v34; // xmm0_4
FMODAudioEngine *v35; // r14
__int64 *v36; // rbx
FMOD::Channel *v37; // rax
int v38; // ecx
GameManager *v39; // rcx
__int64 v40; // rax
__int64 v41; // rcx
float m_unkUint14; // xmm6_4
__int64 v43; // rbx
struct cocos2d::CCDelayTime *v44; // rax
struct cocos2d::CCSequence *v45; // rdx
cocos2d::ccColor3B *v46; // r8
float v47; // xmm6_4
GameManager *v48; // rcx
float v49; // xmm7_4
GameManager *v50; // rcx
GameStatsManager *v51; // rcx
bool v52; // bl
char v53; // r14
GameStatsManager *v54; // rcx
bool v55; // al
GameManager *v56; // rcx
char *v57; // rax
DialogLayer *DialogLayer; // r15
cocos2d::CCDirector *v59; // rax
cocos2d::CCLayer_vtbl *v60; // rbx
const cocos2d::CCPoint *v61; // rax
_BOOL8 v62; // rdx
float v63; // xmm1_4
cocos2d::CCLayer_vtbl *v64; // rbx
__int64 v65; // rcx
cocos2d::CCDirector *v66; // rax
float v67; // xmm0_4
const cocos2d::CCPoint *v68; // rax
struct cocos2d::CCMoveTo *v69; // rax
struct cocos2d::CCEaseElasticOut *v70; // rax
cocos2d::ccColor3B *v71; // r8
float v72; // xmm6_4
struct cocos2d::CCFadeTo *v73; // rax
cocos2d::ccColor3B *v74; // r8
__int64 v75; // rbx
struct cocos2d::CCDelayTime *v76; // rax
struct cocos2d::CCSequence *v77; // rbx
float v78; // [rsp+28h] [rbp-79h]
float v79; // [rsp+28h] [rbp-79h]
_QWORD v80[2]; // [rsp+48h] [rbp-59h] BYREF
__int64 v81; // [rsp+58h] [rbp-49h]
__int64 v82; // [rsp+60h] [rbp-41h]
__int128 v83; // [rsp+68h] [rbp-39h] BYREF
__int64 v84; // [rsp+78h] [rbp-29h]
__int64 v85; // [rsp+80h] [rbp-21h]
__int128 *v86; // [rsp+108h] [rbp+67h] BYREF
FMODAudioEngine *v87; // [rsp+110h] [rbp+6Fh]
FMODAudioEngine *v88; // [rsp+120h] [rbp+7Fh]
m_player1 = a2;
if ( !a2 )
m_player1 = a1->m_player1;
if ( !a1->m_player1->m_isLocked && !a1->m_playerDied )
{
if ( a3 )
{
m_anticheatSpike = a1->m_anticheatSpike;
if ( m_anticheatSpike )
{
if ( a3->m_uniqueID == m_anticheatSpike->m_uniqueID )
{
a1->m_damageVerified = 1;
return;
}
}
}
cocos2d::CCNode::stopActionByTag(a1, 20);
((void (__fastcall *)(PlayLayer *))a1->updateTimeWarp)(a1);
PlayLayer::commitJumps(a1);
m_effectManager = a1->m_effectManager;
v9 = 0;
if ( m_effectManager->m_triggerEffectDelegate )
{
Myfirst = m_effectManager->m_unkVector248._Mypair._Myval2._Myfirst;
v7 = m_effectManager->m_unkVector248._Mypair._Myval2._Mylast - Myfirst;
if ( v7 )
{
v11 = 0;
do
{
if ( !Myfirst[v11].m_disabled )
{
sub_14024B270(v80, (__int64)&Myfirst[v11].m_remapKeys);
v78 = *(float *)&Myfirst[v11].m_triggerUniqueID;
((void (__fastcall *)(TriggerEffectDelegate *, _QWORD, bool, _QWORD *))m_effectManager->m_triggerEffectDelegate->toggleGroupTriggered)(
m_effectManager->m_triggerEffectDelegate,
(unsigned int)Myfirst[v11].m_targetGroupID,
Myfirst[v11].m_activateGroup,
v80);
sub_14005E430((__int64)v80);
}
++v9;
++v11;
Myfirst = m_effectManager->m_unkVector248._Mypair._Myval2._Myfirst;
v7 = m_effectManager->m_unkVector248._Mypair._Myval2._Mylast - Myfirst;
}
while ( v9 < v7 );
}
}
a1->m_gameState.m_pauseCounter = 0;
if ( !a1->m_isPracticeMode )
{
v12 = (GameManager *)qword_1406C2ED8;
if ( !qword_1406C2ED8 )
{
v86 = (__int128 *)operator new(0x668u);
qword_1406C2ED8 = sub_14017AB00((__int64)v86);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2ED8 + 72LL))(qword_1406C2ED8);
v12 = (GameManager *)qword_1406C2ED8;
}
if ( !GameManager::getGameVariable(v12, "0014") )
{
v3 = 0.0;
GJBaseGameLayer::shakeCamera(a1, 0.15000001, 1.0, 0.0);
}
}
a1->m_staticCameraShake = 1;
if ( !a1->m_hintShown )
{
v13 = a1->m_level->m_levelID.random - a1->m_level->m_levelID.seed;
if ( (v13 == 1 || v13 == 1001) && !a1->m_player1->m_hasEverJumped && a1->m_attempts >= 2 )
PlayLayer::showHint(a1);
if ( !a1->m_hintShown )
{
v14 = a1->m_level->m_levelID.random - a1->m_level->m_levelID.seed;
if ( (v14 == 3 || v14 == 1003) && !a1->m_player1->m_hasEverHitRing && a1->m_attempts >= 2 )
PlayLayer::showHint(a1);
}
}
a1->m_playerDied = 1;
if ( a1->m_hitboxesOnDeath
&& !((unsigned __int8 (__fastcall *)(cocos2d::CCDrawNode *, unsigned __int64))a1->m_debugDrawNode->isVisible)(
a1->m_debugDrawNode,
v7) )
{
PlayLayer::toggleDebugDraw(a1);
}
PlayerObject::playerDestroyed(m_player1, 0);
if ( a1->m_gameState.m_isDualMode )
{
m_player2 = a1->m_player1;
if ( m_player1->m_uniqueID == m_player2->m_uniqueID )
m_player2 = a1->m_player2;
GJBaseGameLayer::playExitDualEffect(a1, m_player2);
PlayerObject::playerDestroyed(m_player2, 1);
}
v16 = 0;
v17 = 0;
LOBYTE(v86) = 0;
v18 = 0;
v19 = 0;
CurrentPercent = PlayLayer::getCurrentPercent(a1);
v21 = (int)floorf(CurrentPercent);
if ( v21 < 0 )
v21 = 0;
if ( v21 > 99 )
v21 = 99;
v23 = 1;
if ( !a1->m_isTestMode && !a1->m_isPlatformer )
{
m_isPracticeMode = a1->m_isPracticeMode;
if ( !m_isPracticeMode )
{
m_level = a1->m_level;
v16 = v21 > m_level->m_normalPercent.random - m_level->m_normalPercent.seed;
if ( v21 > m_level->m_orbCompletion.random - m_level->m_orbCompletion.seed )
v17 = 1;
}
if ( a1->m_showLeaderboardPercentage
&& !m_isPracticeMode
&& !v16
&& !v17
&& v21 > a1->m_level->m_newNormalPercent2.random - a1->m_level->m_newNormalPercent2.seed )
{
v16 = 1;
LOBYTE(v86) = 1;
}
v26 = sub_14003CF30();
GJGameLevel::savePercentage(
a1->m_level,
v21,
a1->m_isPracticeMode,
a1->m_clicks,
(int)(v26 - a1->m_currentTime - a1->m_pauseDelta),
a1->m_damageVerified);
p_m_level = &a1->m_level;
if ( a1->m_level->m_levelType == Main )
{
if ( !qword_1406C2ED8 )
{
v87 = (FMODAudioEngine *)operator new(0x668u);
qword_1406C2ED8 = sub_14017AB00((__int64)v87);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2ED8 + 72LL))(qword_1406C2ED8);
}
GameManager::reportPercentageForLevel(
v27,
a1->m_level->m_levelID.random - a1->m_level->m_levelID.seed,
v21,
a1->m_isPracticeMode);
p_m_level = &a1->m_level;
}
if ( !a1->m_isPracticeMode && a1->m_level->m_stars.random - a1->m_level->m_stars.seed > 0 && !a1->m_isPlatformer )
{
v29 = (GameStatsManager *)qword_1406C2EE8;
if ( !qword_1406C2EE8 )
{
v87 = (FMODAudioEngine *)operator new(0x3E0u);
qword_1406C2EE8 = sub_1401D0AE0((__int64)v87);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2EE8 + 72LL))(qword_1406C2EE8);
p_m_level = &a1->m_level;
v29 = (GameStatsManager *)qword_1406C2EE8;
}
GameStatsManager::awardCurrencyForLevel(v29, *p_m_level);
v18 = v30;
if ( (*p_m_level)->m_dailyID.random - (*p_m_level)->m_dailyID.seed > 0 || (*p_m_level)->m_gauntletLevel )
{
v31 = (GameStatsManager *)qword_1406C2EE8;
if ( !qword_1406C2EE8 )
{
v87 = (FMODAudioEngine *)operator new(0x3E0u);
qword_1406C2EE8 = sub_1401D0AE0((__int64)v87);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2EE8 + 72LL))(qword_1406C2EE8);
v31 = (GameStatsManager *)qword_1406C2EE8;
}
GameStatsManager::awardDiamondsForLevel(v31, *p_m_level);
v19 = v32;
}
}
}
v33 = v19 + v18;
if ( !a1->m_isPracticeMode )
{
v34 = PlayLayer::getCurrentPercent(a1);
a1->m_lastAttemptPercent = (int)floorf(v34);
}
if ( !a1->m_gameState.m_unkBool22 )
{
if ( !a1->m_isPracticeMode || a1->m_practiceMusicSync )
{
if ( !qword_1406C2E88 )
{
v87 = (FMODAudioEngine *)operator new(0x888u);
qword_1406C2E88 = (__int64)FMODAudioEngine::FMODAudioEngine(v87);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2E88 + 72LL))(qword_1406C2E88);
}
v35 = (FMODAudioEngine *)qword_1406C2E88;
v36 = **(__int64 ***)(qword_1406C2E88 + 328);
if ( v36 != *(__int64 **)(qword_1406C2E88 + 328) )
{
do
{
if ( !*((_BYTE *)v36 + 73) )
{
v37 = FMODAudioEngine::channelForChannelID(v35, *((_DWORD *)v36 + 6));
if ( v37 )
FMOD::ChannelControl::setPaused(v37, 1);
}
v36 = (__int64 *)*v36;
}
while ( v36 != (__int64 *)v35->m_fmodMusic._List._Mypair._Myval2._Myhead );
}
}
if ( !qword_1406C2E88 )
{
v87 = (FMODAudioEngine *)operator new(0x888u);
qword_1406C2E88 = (__int64)FMODAudioEngine::FMODAudioEngine(v87);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2E88 + 72LL))(qword_1406C2E88);
}
FMODAudioEngine::stopAllEffects((FMODAudioEngine *)qword_1406C2E88);
}
if ( !a1->m_gameState.m_unkBool26 )
{
v87 = (FMODAudioEngine *)v80;
HIBYTE(v80[1]) = 0;
v81 = 14;
v82 = 15;
strcpy((char *)v80, "explode_11.ogg");
v38 = qword_1406C2E88;
if ( !qword_1406C2E88 )
{
v88 = (FMODAudioEngine *)operator new(0x888u);
qword_1406C2E88 = (__int64)FMODAudioEngine::FMODAudioEngine(v88);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2E88 + 72LL))(qword_1406C2E88);
v38 = qword_1406C2E88;
}
v3 = 0.0;
FMODAudioEngine::playEffect(v38, (__int64)v80, v23, v22, 1059481190);
}
v39 = (GameManager *)qword_1406C2ED8;
if ( !qword_1406C2ED8 )
{
v87 = (FMODAudioEngine *)operator new(0x668u);
qword_1406C2ED8 = sub_14017AB00((__int64)v87);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2ED8 + 72LL))(qword_1406C2ED8);
v39 = (GameManager *)qword_1406C2ED8;
}
if ( !GameManager::getGameVariable(v39, "0026") && !a1->m_isPracticeMode )
{
if ( (v16 || v33 > 0) && v19 + v18 > 0 )
PlayLayer::showNewBest(a1, !v16, v18, v19, 0, 0, 0);
v40 = qword_1406C2ED8;
if ( !qword_1406C2ED8 )
{
v86 = (__int128 *)operator new(0x668u);
qword_1406C2ED8 = sub_14017AB00((__int64)v86);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2ED8 + 72LL))(qword_1406C2ED8);
v40 = qword_1406C2ED8;
}
v41 = *(_QWORD *)(*(_QWORD *)(*(_QWORD *)(v40 + 520) + 13632LL) + 568LL);
(*(void (__fastcall **)(__int64, _QWORD))(*(_QWORD *)v41 + 920LL))(v41, 0);
m_unkUint14 = 0.5;
if ( a1->m_gameState.m_unkUint14 > 0.5 )
m_unkUint14 = a1->m_gameState.m_unkUint14;
v43 = cocos2d::CCCallFunc::create(a1, PlayLayer::showRetryLayer);
v44 = cocos2d::CCDelayTime::create(m_unkUint14);
v45 = cocos2d::CCSequence::create(v44, v43, 0);
goto LABEL_127;
}
a1->m_inResetDelay = 1;
v47 = 1.0;
v48 = (GameManager *)qword_1406C2ED8;
if ( !qword_1406C2ED8 )
{
v87 = (FMODAudioEngine *)operator new(0x668u);
qword_1406C2ED8 = sub_14017AB00((__int64)v87);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2ED8 + 72LL))(qword_1406C2ED8);
v48 = (GameManager *)qword_1406C2ED8;
}
if ( GameManager::getGameVariable(v48, "0052") )
v47 = 0.5;
v49 = fmaxf(a1->m_gameState.m_unkUint14, v47);
if ( !v16 && v33 <= 0 )
goto LABEL_113;
v50 = (GameManager *)qword_1406C2ED8;
if ( !qword_1406C2ED8 )
{
v87 = (FMODAudioEngine *)operator new(0x668u);
qword_1406C2ED8 = sub_14017AB00((__int64)v87);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2ED8 + 72LL))(qword_1406C2ED8);
v50 = (GameManager *)qword_1406C2ED8;
}
if ( GameManager::getUGV(v50, (const char *)&word_140544450) )
goto LABEL_113;
v51 = (GameStatsManager *)qword_1406C2EE8;
if ( !qword_1406C2EE8 )
{
v87 = (FMODAudioEngine *)operator new(0x3E0u);
qword_1406C2EE8 = sub_1401D0AE0((__int64)v87);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2EE8 + 72LL))(qword_1406C2EE8);
v51 = (GameStatsManager *)qword_1406C2EE8;
}
if ( GameStatsManager::getStat(v51, "14") <= 500 )
LABEL_113:
v52 = 0;
else
v52 = 1;
v53 = v52;
if ( v16 || v33 > 0 )
{
v54 = (GameStatsManager *)qword_1406C2EE8;
if ( !qword_1406C2EE8 )
{
v87 = (FMODAudioEngine *)operator new(0x3E0u);
qword_1406C2EE8 = sub_1401D0AE0((__int64)v87);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2EE8 + 72LL))(qword_1406C2EE8);
v54 = (GameStatsManager *)qword_1406C2EE8;
}
v55 = GameStatsManager::awardSecretKey(v54);
PlayLayer::showNewBest(a1, !v16, v18, v19, v55, v52, (bool)v86);
v49 = fmaxf(v49, 1.4);
if ( v19 + v18 > 0 )
v53 = 1;
}
if ( v52 )
{
v56 = (GameManager *)qword_1406C2ED8;
if ( !qword_1406C2ED8 )
{
v86 = (__int128 *)operator new(0x668u);
qword_1406C2ED8 = sub_14017AB00((__int64)v86);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2ED8 + 72LL))(qword_1406C2ED8);
v56 = (GameManager *)qword_1406C2ED8;
}
GameManager::setUGV(v56, (const char *)&word_140544450, 1);
v86 = &v83;
LOWORD(v86) = -1;
BYTE2(v86) = -1;
v83 = 0;
v84 = 0;
v85 = 15;
*(_QWORD *)&v83 = sub_14003AA10(0x50u);
v84 = 71;
v85 = 79;
strcpy((char *)v83, "I see you have a lot of orbs. You should visit my shop!");
HIBYTE(v80[1]) = 0;
v81 = 14;
v82 = 15;
strcpy((char *)v80, "The Shopkeeper");
v3 = 1.0;
v57 = DialogObject::create((__int64)v80, (__int64)&v83, 5, 1.0, 0, (__int64)&v86);
DialogLayer = DialogLayer::createDialogLayer((DialogObject *)v57, nullptr, 1);
a1->addChild_0(a1, DialogLayer, 100);
DialogLayer->setOpacity(&DialogLayer->cocos2d::CCRGBAProtocol, 0);
DialogLayer->m_delegate = &a1->DialogDelegate;
v59 = (cocos2d::CCDirector *)cocos2d::CCDirector::sharedDirector(&a1->DialogDelegate);
cocos2d::CCDirector::getWinSize(v59);
v60 = DialogLayer->m_mainLayer->__vftable;
cocos2d::CCPoint::CCPoint(1.9431574e-19, *(float *)&v86 * 0.5);
v60->setPosition_0(DialogLayer->m_mainLayer, v61);
LOBYTE(v62) = 1;
DialogLayer->setVisible(DialogLayer, v62);
v63 = sub_14003CF30();
DialogLayer->m_animateTime = v63;
DialogLayer->m_mainLayer->getPosition_0(DialogLayer->m_mainLayer);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v86);
v64 = DialogLayer->m_mainLayer->__vftable;
v66 = (cocos2d::CCDirector *)cocos2d::CCDirector::sharedDirector(v65);
v67 = (float)(cocos2d::CCDirector::getScreenTop(v66) + 50.0) + 1.0;
cocos2d::CCPoint::CCPoint(v67, *(float *)&v86);
v64->setPosition_0(DialogLayer->m_mainLayer, v68);
v69 = cocos2d::CCMoveTo::create(0.5, (const struct cocos2d::CCPoint *)&v86);
v70 = cocos2d::CCEaseElasticOut::create(v69, 0.60000002);
cocos2d::CCNode::runAction((CCLightFlash *)DialogLayer->m_mainLayer, (cocos2d::CCPoint)v70, v71, 1.0, v79);
v72 = (float)DialogLayer->getOpacity(&DialogLayer->cocos2d::CCRGBAProtocol);
if ( v72 > 0.0 )
{
DialogLayer->setOpacity(&DialogLayer->cocos2d::CCRGBAProtocol, 0);
v73 = cocos2d::CCFadeTo::create(0.14, (int)v72);
cocos2d::CCNode::runAction((CCLightFlash *)DialogLayer, (cocos2d::CCPoint)v73, v74, 1.0, v78);
}
}
cocos2d::CCNode::stopActionByTag(a1, 16);
if ( !v53 )
{
v75 = cocos2d::CCCallFunc::create(a1, PlayLayer::delayedResetLevel);
v76 = cocos2d::CCDelayTime::create(v49);
v77 = cocos2d::CCSequence::create(v76, v75, 0);
v77->setTag(v77, 16);
v45 = v77;
LABEL_127:
cocos2d::CCNode::runAction((CCLightFlash *)a1, (cocos2d::CCPoint)v45, v46, v3, v78);
}
}
}