//
// PlayLayer::destroyPlayer from 0x5d1ae8 to 0x5d23b0 (2248 bytes)
//
// 2 xrefs:
// > ??> @ 0x3bd90
// > ??> @ 0x1148a20
//
// 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 PlayLayer::destroyPlayer(PlayLayer *a1, PlayerObject *a2, GameObject *a3)
{
PlayerObject *m_player1; // x22
GameObject *m_anticheatSpike; // x0
_BOOL4 m_isPracticeMode; // w0
_BOOL4 m_hintShown; // w0
int v8; // w0
_BOOL4 m_hitboxesOnDeath; // w0
int CurrentPercentInt; // w0
_BOOL4 v11; // w23
int v12; // w27
int v13; // w25
bool v14; // w26
_BOOL4 v15; // w24
FMODAudioEngine *v16; // x28
void *v17; // x0
GameManager *v18; // x0
GameManager *v19; // x0
float m_unkUint14; // s0
cocos2d::CCSequence *v21; // x21
cocos2d::CCFiniteTimeAction *v22; // x0
cocos2d::CCAction *v23; // x0
FMODAudioEngine *v24; // x0
FMODAudioEngine *v25; // x0
GameManager *v26; // x0
float v27; // s8
cocos2d::CCSequence *v28; // x21
cocos2d::CCFiniteTimeAction *v29; // x0
cocos2d::CCAction *v30; // x21
_BOOL4 v31; // w1
int v32; // w22
GJGameLevel *m_level; // x1
double TempMilliTime; // d0
GameStatsManager *v35; // x0
int v36; // w0
GJGameLevel *v37; // x1
GameStatsManager *v38; // x0
int v39; // w0
int NormalPercent; // w0
GameManager *v41; // x0
PlayerObject *OtherPlayer; // x22
GameManager *v43; // x0
_BOOL4 v44; // w22
GameStatsManager *v45; // x0
bool v46; // w0
GameManager *v47; // x0
DialogObject *v48; // x0
DialogLayer *v49; // x24
void *v50; // x0
void *v51; // x0
unsigned int *v52; // x1
int v53; // w2
GameManager *v54; // x0
GameStatsManager *v55; // x0
unsigned int *v56; // x1
int v57; // w2
unsigned int *v58; // x1
int v59; // w2
__int64 v60; // [xsp+88h] [xbp+88h] BYREF
__int64 v61; // [xsp+90h] [xbp+90h] BYREF
cocos2d::_ccColor3B v62; // 0:w5.3
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);
a1->updateTimeWarp(a1, 1.0);
PlayLayer::commitJumps(a1);
GJEffectManager::playerDied(a1->m_effectManager);
m_isPracticeMode = a1->m_isPracticeMode;
a1->m_gameState.m_pauseCounter = 0;
if ( !m_isPracticeMode )
{
v41 = GameManager::sharedState();
if ( !GameManager::getGameVariable(v41, "0014") )
GJBaseGameLayer::shakeCamera(a1, 0.15, 1.0, 0.0);
}
m_hintShown = a1->m_hintShown;
a1->m_staticCameraShake = 1;
if ( !m_hintShown )
{
v8 = a1->m_level->m_levelID.random - a1->m_level->m_levelID.seed;
if ( (v8 == 1 || v8 == 1001) && !a1->m_player1->m_hasEverJumped && a1->m_attempts > 1 )
{
PlayLayer::showHint(a1);
if ( a1->m_hintShown )
goto LABEL_14;
v8 = a1->m_level->m_levelID.random - a1->m_level->m_levelID.seed;
}
if ( (v8 == 3 || v8 == 1003) && !a1->m_player1->m_hasEverHitRing && a1->m_attempts > 1 )
PlayLayer::showHint(a1);
}
LABEL_14:
m_hitboxesOnDeath = a1->m_hitboxesOnDeath;
a1->m_playerDied = 1;
if ( m_hitboxesOnDeath && !a1->m_debugDrawNode->isVisible(a1->m_debugDrawNode) )
PlayLayer::toggleDebugDraw(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);
}
CurrentPercentInt = PlayLayer::getCurrentPercentInt(a1);
if ( a1->m_isTestMode || a1->m_isPlatformer )
{
v11 = 0;
v12 = 0;
v13 = 0;
v14 = 0;
v15 = 0;
}
else
{
v31 = a1->m_isPracticeMode;
if ( CurrentPercentInt < 0 )
CurrentPercentInt = 0;
if ( CurrentPercentInt > 99 )
v32 = 99;
else
v32 = CurrentPercentInt;
if ( a1->m_isPracticeMode
|| (v15 = 1,
NormalPercent = GJGameLevel::getNormalPercent(a1->m_level),
v31 = a1->m_isPracticeMode,
v32 <= NormalPercent) )
{
v15 = 0;
}
v14 = 0;
if ( !v31 )
{
m_level = a1->m_level;
if ( v32 <= m_level->m_orbCompletion.random - m_level->m_orbCompletion.seed
&& a1->m_showLeaderboardPercentage
&& !v15 )
{
v15 = v32 > m_level->m_newNormalPercent2.random - m_level->m_newNormalPercent2.seed;
v14 = v32 > m_level->m_newNormalPercent2.random - m_level->m_newNormalPercent2.seed;
}
}
TempMilliTime = PlayLayer::getTempMilliTime(a1);
GJGameLevel::savePercentage(
a1->m_level,
v32,
a1->m_isPracticeMode,
a1->m_clicks,
(int)(TempMilliTime - a1->m_currentTime - a1->m_pauseDelta),
a1->m_damageVerified);
if ( a1->m_level->m_levelType == Main )
{
v54 = GameManager::sharedState();
GameManager::reportPercentageForLevel(
v54,
a1->m_level->m_levelID.random - a1->m_level->m_levelID.seed,
v32,
a1->m_isPracticeMode);
}
if ( a1->m_isPracticeMode )
{
v11 = 0;
v12 = 0;
v13 = 0;
if ( a1->m_gameState.m_unkBool22 )
goto LABEL_22;
LABEL_36:
if ( !a1->m_practiceMusicSync )
{
LABEL_38:
v25 = FMODAudioEngine::sharedEngine();
FMODAudioEngine::stopAllEffects(v25);
goto LABEL_22;
}
LABEL_37:
v24 = FMODAudioEngine::sharedEngine();
FMODAudioEngine::pauseAllMusic(v24, 0);
goto LABEL_38;
}
if ( a1->m_level->m_stars.random - a1->m_level->m_stars.seed <= 0 || a1->m_isPlatformer )
{
v11 = 0;
v12 = 0;
v13 = 0;
LABEL_34:
a1->m_lastAttemptPercent = PlayLayer::getCurrentPercentInt(a1);
if ( a1->m_gameState.m_unkBool22 )
goto LABEL_22;
if ( !a1->m_isPracticeMode )
goto LABEL_37;
goto LABEL_36;
}
v35 = GameStatsManager::sharedState();
GameStatsManager::awardCurrencyForLevel(v35, a1->m_level);
v13 = v36;
v37 = a1->m_level;
if ( v37->m_dailyID.random - v37->m_dailyID.seed > 0 || v37->m_gauntletLevel )
{
v38 = GameStatsManager::sharedState();
GameStatsManager::awardDiamondsForLevel(v38, a1->m_level);
v12 = v39;
v11 = v13 + v39 > 0;
}
else
{
v12 = 0;
v11 = v36 > 0;
}
}
if ( !a1->m_isPracticeMode )
goto LABEL_34;
if ( !a1->m_gameState.m_unkBool22 )
goto LABEL_36;
LABEL_22:
if ( !a1->m_gameState.m_unkBool26 )
{
v16 = FMODAudioEngine::sharedEngine();
sub_D153B8((int)&v61, "explode_11.ogg");
FMODAudioEngine::playEffect((__int64)v16, (__int64)&v61, 1.0, 0.0, 0.65);
v17 = (void *)(v61 - 24);
if ( (__int64 *)(v61 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v52 = (unsigned int *)(v61 - 8);
do
v53 = __ldaxr(v52);
while ( __stlxr(v53 - 1, v52) );
}
else
{
v53 = *(_DWORD *)(v61 - 8);
*(_DWORD *)(v61 - 8) = v53 - 1;
}
if ( v53 <= 0 )
operator delete(v17);
}
}
v18 = GameManager::sharedState();
if ( !GameManager::getGameVariable(v18, "0026") && !a1->m_isPracticeMode )
{
if ( v11 )
PlayLayer::showNewBest(a1, !v15, v13, v12, 0, 0, 0);
v19 = GameManager::sharedState();
UILayer::disableMenu(v19->m_playLayer->m_uiLayer);
m_unkUint14 = a1->m_gameState.m_unkUint14;
shouldRefreshBanner = 0;
if ( m_unkUint14 <= 0.5 )
m_unkUint14 = 0.5;
v21 = (cocos2d::CCSequence *)cocos2d::CCDelayTime::create(m_unkUint14);
v22 = (cocos2d::CCFiniteTimeAction *)cocos2d::CCCallFunc::create(a1, PlayLayer::showRetryLayer, 0);
v23 = (cocos2d::CCAction *)cocos2d::CCSequence::create(v21, v22, 0);
cocos2d::CCNode::runAction(a1, v23);
return;
}
a1->m_inResetDelay = (unsigned __int8)&dword_0 + 1;
v26 = GameManager::sharedState();
if ( GameManager::getGameVariable(v26, "0052") )
v27 = 0.5;
else
v27 = 1.0;
if ( v27 < a1->m_gameState.m_unkUint14 )
v27 = a1->m_gameState.m_unkUint14;
if ( !v11 && !v15 )
{
LABEL_45:
cocos2d::CCNode::stopActionByTag(a1, 16);
v28 = (cocos2d::CCSequence *)cocos2d::CCDelayTime::create(v27);
v29 = (cocos2d::CCFiniteTimeAction *)cocos2d::CCCallFunc::create(a1, PlayLayer::delayedResetLevel, 0);
v30 = (cocos2d::CCAction *)cocos2d::CCSequence::create(v28, v29, 0);
v30->setTag(v30, 16);
cocos2d::CCNode::runAction(a1, v30);
return;
}
v43 = GameManager::sharedState();
v44 = 0;
if ( !GameManager::getUGV(v43, "17") )
{
v55 = GameStatsManager::sharedState();
v44 = GameStatsManager::getStat(v55, "14") > 500;
}
v45 = GameStatsManager::sharedState();
v46 = GameStatsManager::awardSecretKey(v45);
PlayLayer::showNewBest(a1, !v15, v13, v12, v46, v44, v14);
if ( v27 < 1.4 )
v27 = 1.4;
if ( v11 )
{
if ( !v44 )
{
cocos2d::CCNode::stopActionByTag(a1, 16);
return;
}
}
else if ( !v44 )
{
goto LABEL_45;
}
v47 = GameManager::sharedState();
GameManager::setUGV(v47, "17", 1);
sub_D153B8((int)&v60, "The Shopkeeper");
sub_D153B8((int)&v61, "I see you have a lot of orbs. You should visit my shop!");
v48 = (DialogObject *)DialogObject::create(
(DialogObject *)&v60,
(std::string)&v61,
(std::string)5LL,
0,
1.0,
(bool)&unk_FFFFFF,
v62);
v49 = DialogLayer::create(v48, (int)&dword_0 + 1);
v50 = (void *)(v61 - 24);
if ( (__int64 *)(v61 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v58 = (unsigned int *)(v61 - 8);
do
v59 = __ldaxr(v58);
while ( __stlxr(v59 - 1, v58) );
}
else
{
v59 = *(_DWORD *)(v61 - 8);
*(_DWORD *)(v61 - 8) = v59 - 1;
}
if ( v59 <= 0 )
operator delete(v50);
}
v51 = (void *)(v60 - 24);
if ( (__int64 *)(v60 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v56 = (unsigned int *)(v60 - 8);
do
v57 = __ldaxr(v56);
while ( __stlxr(v57 - 1, v56) );
}
else
{
v57 = *(_DWORD *)(v60 - 8);
*(_DWORD *)(v60 - 8) = v57 - 1;
}
if ( v57 <= 0 )
operator delete(v51);
}
a1->addChild_0(a1, v49, 100);
v49->setOpacity(v49, 0);
v49->m_delegate = &a1->DialogDelegate;
DialogLayer::updateChatPlacement(v49, Top);
DialogLayer::animateIn(v49, FromTop);
cocos2d::CCNode::stopActionByTag(a1, 16);
}