//
// PlayLayer::destroyPlayer from 0x1000b9ec0 to 0x1000ba845 (2437 bytes)
//
// 1 xrefs:
// > ??> @ 0x1008b7348
//
// 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
//
void __fastcall PlayLayer::destroyPlayer(PlayLayer *a1, PlayerObject *a2, GameObject *a3)
{
PlayerObject *m_player1; // r14
GameObject *m_anticheatSpike; // rax
GameStatsManager *v6; // rax
GameManager *v7; // rax
bool m_hintShown; // al
int v9; // ecx
int v10; // eax
unsigned __int8 v11; // r15
PlayerObject *OtherPlayer; // r14
unsigned int *v13; // rax
GJGameLevel *m_level; // rdi
int m_timestamp; // ecx
__m128 v16; // xmm0
float m_levelLength; // xmm1_4
int v18; // eax
int v19; // r14d
int v20; // r12d
bool v21; // zf
_BOOL8 v22; // r15
bool v23; // r13
bool m_isPracticeMode; // al
GJGameLevel *v25; // rax
GameManager *v26; // rax
bool v27; // r15
unsigned int *v28; // rax
int v29; // ecx
__m128 v30; // xmm0
float v31; // xmm1_4
FMODAudioEngine *v32; // rax
FMODAudioEngine *v33; // rax
FMODAudioEngine *v34; // rax
int v35; // r12d
GameManager *v36; // rax
GameManager *v37; // rax
float v38; // xmm0_4
GameManager *v39; // rax
bool v40; // r13
float v41; // xmm0_4
GameManager *v42; // rax
unsigned int v43; // r14d
unsigned int v44; // eax
int v45; // ecx
int v46; // r8d
int v47; // r9d
PlayLayer *v48; // rdi
cocos2d::CCAction *v49; // rsi
GameStatsManager *v50; // rax
GameStatsManager *v51; // rax
bool v52; // al
GameManager *v53; // rax
DialogObject *v54; // rax
DialogLayer *v55; // r14
unsigned int v56; // r14d
unsigned int v57; // eax
int v58; // ecx
int v59; // r8d
int v60; // r9d
__int64 v61; // r14
GameStatsManager *v62; // rax
__int64 v63; // rax
GJGameLevel *v64; // rax
GameStatsManager *v65; // rax
int v66; // eax
timeb v67; // [rsp+8h] [rbp-98h] BYREF
_BOOL8 v68; // [rsp+18h] [rbp-88h]
_QWORD v69[2]; // [rsp+20h] [rbp-80h] BYREF
void *v70; // [rsp+30h] [rbp-70h]
char v71; // [rsp+38h] [rbp-68h] BYREF
_BYTE v72[23]; // [rsp+39h] [rbp-67h] BYREF
char v73; // [rsp+50h] [rbp-50h] BYREF
void *v74[3]; // [rsp+51h] [rbp-4Fh] BYREF
float v75; // [rsp+6Ch] [rbp-34h]
float v76[12]; // [rsp+70h] [rbp-30h]
m_player1 = a2;
if ( !a2 )
m_player1 = a1->m_player1;
if ( a1->m_player1->m_isLocked || a1->m_playerDied )
return;
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 *, float))a1->updateTimeWarp)(a1, 1.0);
v6 = GameStatsManager::sharedState();
GameStatsManager::incrementStat(v6, "1", a1->m_uncommittedJumps);
a1->m_uncommittedJumps = 0;
GJEffectManager::playerDied(a1->m_effectManager);
a1->m_gameState.m_pauseCounter = 0;
if ( !a1->m_isPracticeMode )
{
v7 = GameManager::sharedState();
if ( !GameManager::getGameVariable(v7, "0014") )
GJBaseGameLayer::shakeCamera(a1, 0.15000001, 1.0, 0.0);
}
a1->m_staticCameraShake = 1;
m_hintShown = a1->m_hintShown;
if ( !m_hintShown )
{
v9 = a1->m_level->m_levelID.random - a1->m_level->m_levelID.seed;
if ( (v9 == 1001 || v9 == 1) && !a1->m_player1->m_hasEverJumped && a1->m_attempts >= 2 )
{
PlayLayer::showHint(a1);
m_hintShown = a1->m_hintShown;
}
}
if ( !m_hintShown )
{
v10 = a1->m_level->m_levelID.random - a1->m_level->m_levelID.seed;
if ( (v10 == 1003 || v10 == 3) && !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 *))a1->m_debugDrawNode->isVisible)(a1->m_debugDrawNode) )
{
if ( !a1->m_isDebugDrawEnabled || (v11 = 1, !a1->m_isPracticeMode) )
v11 = a1->m_hitboxesOnDeath && a1->m_playerDied;
if ( v11 != ((unsigned __int8 (__fastcall *)(cocos2d::CCDrawNode *))a1->m_debugDrawNode->isVisible)(a1->m_debugDrawNode) )
{
cocos2d::CCDrawNode::clear(a1->m_debugDrawNode);
((void (__fastcall *)(cocos2d::CCDrawNode *, _QWORD))a1->m_debugDrawNode->setVisible)(a1->m_debugDrawNode, v11);
if ( v11 )
((void (__fastcall *)(PlayLayer *))a1->updateDebugDraw)(a1);
}
}
PlayerObject::playerDestroyed(m_player1, 0);
if ( a1->m_gameState.m_isDualMode )
{
OtherPlayer = GJBaseGameLayer::getOtherPlayer(a1, m_player1);
GJBaseGameLayer::playExitDualEffect(a1, OtherPlayer);
PlayerObject::playerDestroyed(OtherPlayer, 1);
}
v13 = (unsigned int *)((__int64 (__fastcall *)(PlayerObject *))a1->m_player1->getPosition)(a1->m_player1);
m_level = a1->m_level;
m_timestamp = m_level->m_timestamp;
if ( m_timestamp <= 0 )
{
v16 = (__m128)*v13;
m_levelLength = a1->m_levelLength;
}
else
{
v16 = 0;
v16.f32[0] = (float)(int)a1->m_gameState.m_currentProgress;
m_levelLength = (float)(2 * m_timestamp);
}
v16.f32[0] = fminf(fmaxf((float)(v16.f32[0] / m_levelLength) * 100.0, 0.0), 100.0);
v18 = (int)_mm_round_ss(v16, v16, 9).f32[0];
v19 = 0;
if ( v18 <= 0 )
v18 = 0;
v20 = 99;
if ( v18 < 99 )
v20 = v18;
v21 = !a1->m_isTestMode;
*(_QWORD *)v76 = 0;
v22 = 0;
v23 = 0;
if ( v21 )
{
v19 = 0;
v21 = !a1->m_isPlatformer;
*(_QWORD *)v76 = 0;
v22 = 0;
v23 = 0;
if ( v21 )
{
m_isPracticeMode = a1->m_isPracticeMode;
if ( m_isPracticeMode )
{
v23 = 0;
}
else
{
v23 = v20 > GJGameLevel::getNormalPercent(m_level);
m_isPracticeMode = a1->m_isPracticeMode;
}
v22 = 0;
if ( !m_isPracticeMode && a1->m_showLeaderboardPercentage )
{
v25 = a1->m_level;
if ( v20 <= v25->m_orbCompletion.random - v25->m_orbCompletion.seed && !v23 )
{
LOBYTE(v22) = v20 > v25->m_newNormalPercent2.random - v25->m_newNormalPercent2.seed;
v23 = v22;
}
}
ftime(&v67);
GJGameLevel::savePercentage(
a1->m_level,
v20,
a1->m_isPracticeMode,
a1->m_clicks,
(int)((double)(v67.millitm + 1000 * (v67.time & 0xFFFFF)) / 1000.0 - a1->m_currentTime - a1->m_pauseDelta),
a1->m_damageVerified);
if ( a1->m_level->m_levelType == Main )
{
v26 = GameManager::sharedState();
GameManager::reportPercentageForLevel(
v26,
a1->m_level->m_levelID.random - a1->m_level->m_levelID.seed,
v20,
a1->m_isPracticeMode);
}
v19 = 0;
if ( a1->m_isPracticeMode || a1->m_level->m_stars.random <= a1->m_level->m_stars.seed || a1->m_isPlatformer )
{
*(_QWORD *)v76 = 0;
}
else
{
v62 = GameStatsManager::sharedState();
GameStatsManager::awardCurrencyForLevel(v62, a1->m_level);
*(_QWORD *)v76 = v63;
v64 = a1->m_level;
if ( v64->m_dailyID.random > v64->m_dailyID.seed || v64->m_gauntletLevel )
{
v65 = GameStatsManager::sharedState();
GameStatsManager::awardDiamondsForLevel(v65, a1->m_level);
v19 = v66;
}
}
}
}
if ( a1->m_isPracticeMode )
{
if ( a1->m_gameState.m_unkBool22 )
goto LABEL_61;
LABEL_67:
if ( !a1->m_isPracticeMode || a1->m_practiceMusicSync )
{
v32 = FMODAudioEngine::sharedEngine();
FMODAudioEngine::pauseAllMusic(v32, 0);
}
v33 = FMODAudioEngine::sharedEngine();
FMODAudioEngine::stopAllEffects(v33);
v68 = v22;
v27 = v23;
if ( a1->m_gameState.m_unkBool26 )
goto LABEL_73;
goto LABEL_71;
}
v28 = (unsigned int *)((__int64 (__fastcall *)(PlayerObject *))a1->m_player1->getPosition)(a1->m_player1);
v29 = a1->m_level->GJBaseGameLayer::m_timestamp;
if ( v29 <= 0 )
{
v30 = (__m128)*v28;
v31 = a1->m_levelLength;
}
else
{
v30 = 0;
v30.f32[0] = (float)(int)a1->m_gameState.m_currentProgress;
v31 = (float)(2 * v29);
}
v30.f32[0] = fminf(fmaxf((float)(v30.f32[0] / v31) * 100.0, 0.0), 100.0);
a1->m_lastAttemptPercent = (int)_mm_round_ss(v30, v30, 9).f32[0];
if ( !a1->m_gameState.m_unkBool22 )
goto LABEL_67;
LABEL_61:
v68 = v22;
v27 = v23;
if ( !a1->m_gameState.m_unkBool26 )
{
LABEL_71:
v34 = FMODAudioEngine::sharedEngine();
v71 = 28;
strcpy(v72, "explode_11.ogg");
FMODAudioEngine::playEffect(v34, &v71, 1.0, 0.0, 0.64999998);
if ( (v71 & 1) != 0 )
operator delete(*(void **)&v72[15]);
}
LABEL_73:
v35 = LODWORD(v76[0]) + v19;
v36 = GameManager::sharedState();
if ( !GameManager::getGameVariable(v36, "0026") && !a1->m_isPracticeMode )
{
if ( v35 > 0 )
PlayLayer::showNewBest(a1, !v27, SLODWORD(v76[0]), v19, 0, 0, 0);
v42 = GameManager::sharedState();
UILayer::disableMenu(v42->m_playLayer->m_uiLayer);
byte_1009A3EB8 = 0;
v43 = (unsigned int)cocos2d::CCDelayTime::create(fmaxf(a1->m_gameState.m_unkUint14, 0.5));
v44 = (unsigned int)cocos2d::CCCallFunc::create(
a1,
(cocos2d::SEL_CallFunc)(unsigned __int64)PlayLayer::showRetryLayer);
v48 = a1;
v49 = (cocos2d::CCAction *)sub_1003B5760(v43, v44, 0, v45, v46, v47);
goto LABEL_94;
}
a1->m_inResetDelay = 1;
v37 = GameManager::sharedState();
if ( GameManager::getGameVariable(v37, "0052") )
v38 = 0.5;
else
v38 = 1.0;
v75 = fmaxf(a1->m_gameState.m_unkUint14, v38);
if ( !v27 && v35 <= 0 )
{
cocos2d::CCNode::stopActionByTag(a1, 16);
v41 = v75;
LABEL_93:
v56 = (unsigned int)cocos2d::CCDelayTime::create(v41);
v57 = (unsigned int)cocos2d::CCCallFunc::create(
a1,
(cocos2d::SEL_CallFunc)(unsigned __int64)PlayLayer::delayedResetLevel);
v61 = sub_1003B5760(v56, v57, 0, v58, v59, v60);
(*(void (__fastcall **)(__int64, __int64))(*(_QWORD *)v61 + 72LL))(v61, 16);
v48 = a1;
v49 = (cocos2d::CCAction *)v61;
LABEL_94:
cocos2d::CCNode::runAction(v48, v49);
return;
}
v39 = GameManager::sharedState();
if ( GameManager::getUGV(v39, "17") )
{
v40 = 0;
}
else
{
v50 = GameStatsManager::sharedState();
v40 = GameStatsManager::getStat(v50, "14") >= 501;
}
v51 = GameStatsManager::sharedState();
v52 = GameStatsManager::awardSecretKey(v51);
PlayLayer::showNewBest(a1, !v27, SLODWORD(v76[0]), v19, v52, v40, v68);
v76[0] = fmaxf(1.4, v75);
if ( v40 )
{
v53 = GameManager::sharedState();
GameManager::setUGV(v53, "17", 1);
v73 = 28;
strcpy((char *)v74, "The Shopkeeper");
v70 = operator new(0x48u);
v69[0] = 73;
v69[1] = 71;
strcpy((char *)v70, "I see you have a lot of orbs. You should visit my shop!");
v54 = (DialogObject *)DialogObject::create(&v73, v69, 5, 0, 0xFFFFFF, 1.0);
v55 = DialogLayer::create(v54, 1);
if ( (v69[0] & 1) != 0 )
operator delete(v70);
if ( (v73 & 1) != 0 )
operator delete(*(void **)((char *)&v74[1] + 7));
((void (__fastcall *)(PlayLayer *, DialogLayer *, __int64))a1->addChild_0)(a1, v55, 100);
((void (__fastcall *)(DialogLayer *, _QWORD))v55->setOpacity)(v55, 0);
v55->m_delegate = &a1->DialogDelegate;
DialogLayer::updateChatPlacement(v55, Top);
DialogLayer::animateIn(v55, FromTop);
}
cocos2d::CCNode::stopActionByTag(a1, 16);
v41 = v76[0];
if ( !v40 && v35 <= 0 )
goto LABEL_93;
}