//
// PlayLayer::destroyPlayer from 0x10011e998 to 0x10011f08c (1780 bytes)
//
// 1 xrefs:
// > ??> @ 0x10078fd88
//
// 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; // x20
bool *p_m_isPlatformer; // x24
GameObject *m_anticheatSpike; // x8
GameStatsManager *v7; // x0
GameManager *v8; // x0
int v9; // w8
bool v10; // zf
int v11; // w8
PlayerObject *OtherPlayer; // x20
int v13; // w8
int v14; // w8
int v15; // w21
int v16; // w22
int v17; // w21
bool v18; // w20
bool v19; // w25
int NormalPercent; // w0
GJGameLevel *m_level; // x8
GameManager *v22; // x0
FMODAudioEngine *v23; // x0
FMODAudioEngine *v24; // x0
FMODAudioEngine *v25; // x23
int v26; // w26
GameManager *v27; // x0
GameManager *v28; // x0
_BOOL4 GameVariable; // w0
float v30; // s0
float m_unkUint14; // s8
char v32; // w8
GameManager *v33; // x0
_BOOL4 v34; // w23
GameManager *v35; // x0
cocos2d::CCDelayTime *v36; // x20
cocos2d::CCAction *v37; // x1
PlayLayer *v38; // x0
GameStatsManager *v39; // x0
GameStatsManager *v40; // x0
bool v41; // w0
GameManager *v42; // x0
char *v43; // x0
DialogLayer *v44; // x20
cocos2d::CCDelayTime *v45; // x20
__int64 v46; // x20
GameStatsManager *v47; // x0
int v48; // w0
GJGameLevel *v49; // x8
GameStatsManager *v50; // x0
int v51; // w0
void *v52[2]; // [xsp+18h] [xbp-A8h] BYREF
char v53; // [xsp+2Fh] [xbp-91h]
void *v54[2]; // [xsp+30h] [xbp-90h] BYREF
char v55; // [xsp+47h] [xbp-79h]
void *__p[2]; // [xsp+48h] [xbp-78h] BYREF
char v57; // [xsp+5Fh] [xbp-61h]
timeb v58; // [xsp+60h] [xbp-60h] BYREF
cocos2d::SEL_CallFunc v59; // 0:x1.16
cocos2d::SEL_CallFunc v60; // 0:x1.16
if ( a2 )
m_player1 = a2;
else
m_player1 = a1->m_player1;
if ( !a1->m_player1->m_isLocked )
{
p_m_isPlatformer = &a1->m_isPlatformer;
if ( !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 *, float))a1->updateTimeWarp)(a1, 1.0);
v7 = GameStatsManager::sharedState();
GameStatsManager::incrementStat(v7, "1", a1->m_uncommittedJumps);
a1->m_uncommittedJumps = 0;
GJEffectManager::playerDied(a1->m_effectManager);
a1->m_gameState.m_pauseCounter = 0;
if ( !p_m_isPlatformer[290] )
{
v8 = GameManager::sharedState();
if ( !GameManager::getGameVariable(v8, "0014") )
GJBaseGameLayer::shakeCamera(a1, 0.15, 1.0, 0.0);
}
p_m_isPlatformer[378] = 1;
if ( !p_m_isPlatformer[1931] )
{
v9 = a1->m_level->m_levelID.random - a1->m_level->m_levelID.seed;
v10 = v9 == 1001 || v9 == 1;
if ( !v10
|| a1->m_player1->m_hasEverJumped
|| a1->m_attempts < 2
|| (PlayLayer::showHint(a1), !p_m_isPlatformer[1931]) )
{
v11 = a1->m_level->m_levelID.random - a1->m_level->m_levelID.seed;
if ( (v11 == 1003 || v11 == 3) && !a1->m_player1->m_hasEverHitRing && a1->m_attempts >= 2 )
PlayLayer::showHint(a1);
}
}
p_m_isPlatformer[380] = 1;
if ( p_m_isPlatformer[1572]
&& (((__int64 (__fastcall *)(cocos2d::CCDrawNode *))a1->m_debugDrawNode->isVisible)(a1->m_debugDrawNode) & 1) == 0 )
{
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);
}
v13 = vcvtms_s32_f32(PlayLayer::getCurrentPercent(a1));
v14 = v13 & ~(v13 >> 31);
if ( v14 >= 99 )
v15 = 99;
else
v15 = v14;
if ( p_m_isPlatformer[354] || *p_m_isPlatformer )
{
v16 = 0;
v17 = 0;
v18 = 0;
v19 = 0;
}
else
{
if ( p_m_isPlatformer[290] )
{
v18 = 0;
v19 = 0;
}
else
{
NormalPercent = GJGameLevel::getNormalPercent(a1->m_level);
v19 = v15 > NormalPercent;
if ( p_m_isPlatformer[290] )
{
v18 = 0;
}
else
{
v18 = 0;
if ( p_m_isPlatformer[2054] && v15 <= NormalPercent )
{
m_level = a1->m_level;
if ( v15 <= m_level->m_orbCompletion.random - m_level->m_orbCompletion.seed )
{
v18 = v15 > m_level->m_newNormalPercent2.random - m_level->m_newNormalPercent2.seed;
v19 = v18;
}
}
}
}
ftime(&v58);
GJGameLevel::savePercentage(
a1->m_level,
v15,
p_m_isPlatformer[290],
a1->m_clicks,
(int)((double)(v58.millitm + 1000 * (unsigned __int64)(v58.time & 0xFFFFF)) / 1000.0
- a1->m_currentTime
- a1->m_pauseDelta),
p_m_isPlatformer[1634]);
if ( a1->m_level->m_levelType == Main )
{
v22 = GameManager::sharedState();
GameManager::reportPercentageForLevel(
v22,
a1->m_level->m_levelID.random - a1->m_level->m_levelID.seed,
v15,
p_m_isPlatformer[290]);
}
if ( p_m_isPlatformer[290] || a1->m_level->m_stars.random <= a1->m_level->m_stars.seed || *p_m_isPlatformer )
{
v16 = 0;
v17 = 0;
}
else
{
v47 = GameStatsManager::sharedState();
GameStatsManager::awardCurrencyForLevel(v47, a1->m_level);
v17 = v48;
v49 = a1->m_level;
if ( v49->m_dailyID.random > v49->m_dailyID.seed || v49->m_gauntletLevel )
{
v50 = GameStatsManager::sharedState();
GameStatsManager::awardDiamondsForLevel(v50, a1->m_level);
v16 = v51;
}
else
{
v16 = 0;
}
}
}
if ( !p_m_isPlatformer[290] )
a1->m_lastAttemptPercent = vcvtms_s32_f32(PlayLayer::getCurrentPercent(a1));
if ( !a1->m_gameState.m_unkBool22 )
{
if ( !p_m_isPlatformer[290] || p_m_isPlatformer[291] )
{
v23 = FMODAudioEngine::sharedEngine();
FMODAudioEngine::pauseAllMusic(v23, 0);
}
v24 = FMODAudioEngine::sharedEngine();
FMODAudioEngine::stopAllEffects(v24);
}
if ( !a1->m_gameState.m_unkBool26 )
{
v25 = FMODAudioEngine::sharedEngine();
sub_100009900(__p, "explode_11.ogg");
FMODAudioEngine::playEffect(v25, __p, 1.0, 0.0, 0.65);
if ( v57 < 0 )
operator delete(__p[0]);
}
v26 = v17 + v16;
v27 = GameManager::sharedState();
if ( !GameManager::getGameVariable(v27, "0026") && !p_m_isPlatformer[290] )
{
if ( v26 >= 1 )
PlayLayer::showNewBest(a1, !v19, v17, v16, 0, 0, 0);
v35 = GameManager::sharedState();
UILayer::disableMenu(v35->m_playLayer->m_uiLayer);
byte_100885CF0 = 0;
v36 = cocos2d::CCDelayTime::create(fmaxf(a1->m_gameState.m_unkUint14, 0.5));
v59.ptr = (void (*)(void))PlayLayer::showRetryLayer;
v59.adj = 0;
cocos2d::CCCallFunc::create(a1, v59);
v37 = (cocos2d::CCAction *)sub_10018A494(v36);
v38 = a1;
goto LABEL_90;
}
p_m_isPlatformer[2056] = 1;
v28 = GameManager::sharedState();
GameVariable = GameManager::getGameVariable(v28, "0052");
v30 = 1.0;
if ( GameVariable )
v30 = 0.5;
if ( a1->m_gameState.m_unkUint14 <= v30 )
m_unkUint14 = v30;
else
m_unkUint14 = a1->m_gameState.m_unkUint14;
v32 = v26 > 0 || v19;
if ( (v32 & 1) == 0 )
{
cocos2d::CCNode::stopActionByTag(a1, 16);
LABEL_89:
v45 = cocos2d::CCDelayTime::create(m_unkUint14);
v60.ptr = (void (*)(void))PlayLayer::delayedResetLevel;
v60.adj = 0;
cocos2d::CCCallFunc::create(a1, v60);
v46 = sub_10018A494(v45);
(*(void (__fastcall **)(__int64, __int64))(*(_QWORD *)v46 + 72LL))(v46, 16);
v38 = a1;
v37 = (cocos2d::CCAction *)v46;
LABEL_90:
cocos2d::CCNode::runAction(v38, v37);
return;
}
v33 = GameManager::sharedState();
if ( GameManager::getUGV(v33, "17") )
{
v34 = 0;
}
else
{
v39 = GameStatsManager::sharedState();
v34 = GameStatsManager::getStat(v39, "14") > 500;
}
v40 = GameStatsManager::sharedState();
v41 = GameStatsManager::awardSecretKey(v40);
PlayLayer::showNewBest(a1, !v19, v17, v16, v41, v34, v18);
if ( m_unkUint14 < 1.4 )
m_unkUint14 = 1.4;
if ( v34 )
{
v42 = GameManager::sharedState();
GameManager::setUGV(v42, "17", 1);
sub_100009900(v54, "The Shopkeeper");
sub_100009900(v52, "I see you have a lot of orbs. You should visit my shop!");
v43 = DialogObject::create((__int64)v54, (__int64)v52, 5, 0, 0xFFFFFF, 1.0);
v44 = DialogLayer::create((DialogObject *)v43, 1);
if ( v53 < 0 )
operator delete(v52[0]);
if ( v55 < 0 )
operator delete(v54[0]);
((void (__fastcall *)(PlayLayer *, DialogLayer *, __int64))a1->addChild_0)(a1, v44, 100);
((void (__fastcall *)(DialogLayer *, _QWORD))v44->setOpacity)(v44, 0);
v44->m_delegate = &a1->DialogDelegate;
DialogLayer::updateChatPlacement(v44, Top);
DialogLayer::animateIn(v44, FromTop);
}
cocos2d::CCNode::stopActionByTag(a1, 16);
if ( v26 <= 0 && !v34 )
goto LABEL_89;
}
}
}