//
// PlayerObject::hitGround from 0x14039bf30 to 0x14039c63b (1803 bytes)
//
// 15 xrefs:
// > GJBaseGameLayer::checkCollisions @ 0x140213b87
// > GJBaseGameLayer::checkCollisions @ 0x140213be8
// > GJBaseGameLayer::checkCollisions @ 0x140213e50
// > GJBaseGameLayer::checkCollisions @ 0x140214109
// > MenuGameLayer::update @ 0x140332512
// > PlayerObject::collidedWithSlopeInternal @ 0x1403907ad
// > PlayerObject::collidedWithObjectInternal @ 0x1403925d0
// > PlayerObject::collidedWithObjectInternal @ 0x140392bd4
// > PlayerObject::collidedWithObjectInternal @ 0x140392fdd
// > PlayerObject::collidedWithObjectInternal @ 0x14039371d
// > PlayerObject::collidedWithObjectInternal @ 0x14039392b
// > PlayerObject::hitGroundNoJump @ 0x14039beff
// > ??> @ 0x14069831c
// > ??> @ 0x1406983d0
// > ??> @ 0x1406d6614
//
// 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 PlayerObject::hitGround(PlayerObject *a1, GameObject *a2, bool a3)
{
int m_objectMaterial; // r8d
bool m_isUpsideDown; // dl
double m_yVelocity; // xmm1_8
int v9; // eax
char v10; // r12
GJBaseGameLayer *m_gameLayer; // rcx
double v12; // xmm0_8
bool v13; // cf
bool v14; // zf
GJGameEvent v15; // edx
bool v16; // cf
bool v17; // zf
bool v18; // cf
bool v19; // zf
bool v20; // cf
bool v21; // zf
GJBaseGameLayer *v22; // rcx
GJGameEvent v23; // edx
bool m_useLandParticles0; // al
cocos2d::CCParticleSystemQuad *v25; // r14
cocos2d::CCParticleSystemQuad_vtbl *v26; // rdi
const cocos2d::CCPoint *v27; // rax
double v28; // xmm0_8
const cocos2d::CCPoint *v29; // rax
const cocos2d::CCPoint *v30; // rax
__int64 v31; // rax
float v32; // xmm0_4
const cocos2d::CCPoint *v33; // rax
float v34; // xmm1_4
char v35[32]; // [rsp+20h] [rbp-78h] BYREF
char v36; // [rsp+A8h] [rbp+10h] BYREF
if ( a2 )
m_objectMaterial = a2->m_objectMaterial;
else
m_objectMaterial = 0;
a1->m_groundObjectMaterial = m_objectMaterial;
m_isUpsideDown = a1->m_isUpsideDown;
m_yVelocity = a1->m_yVelocity;
v9 = -1;
a1->m_isOnIce = 0;
v10 = 0;
m_gameLayer = a1->m_gameLayer;
if ( !m_isUpsideDown )
v9 = 1;
v12 = (double)v9 * m_yVelocity;
if ( v12 > 5.0 )
v10 = 1;
if ( m_gameLayer && !a1->m_isDart )
{
if ( m_isUpsideDown )
{
v13 = m_yVelocity < 14.0;
v14 = m_yVelocity == 14.0;
}
else
{
v13 = m_yVelocity > -14.0;
v14 = m_yVelocity == -14.0;
}
if ( v13 || v14 )
{
if ( m_isUpsideDown )
{
v16 = m_yVelocity < 8.0;
v17 = m_yVelocity == 8.0;
}
else
{
v16 = m_yVelocity > -8.0;
v17 = m_yVelocity == -8.0;
}
if ( v16 || v17 )
{
if ( m_isUpsideDown )
{
v18 = m_yVelocity < 4.0;
v19 = m_yVelocity == 4.0;
}
else
{
v18 = m_yVelocity > -4.0;
v19 = m_yVelocity == -4.0;
}
if ( v18 || v19 )
{
if ( m_isUpsideDown )
{
v20 = m_yVelocity < 1.0;
v21 = m_yVelocity == 1.0;
}
else
{
v20 = m_yVelocity > -1.0;
v21 = m_yVelocity == -1.0;
}
if ( v20 || v21 || !a1->m_gameLayer )
{
LABEL_33:
*(float *)&v12 = a1->m_fallStartY;
if ( *(float *)&v12 == 0.0 )
goto LABEL_49;
LODWORD(v12) = fabs(a1->m_fallStartY - a1->getPosition_0(a1)->y);
if ( *(float *)&v12 <= 0.0 )
goto LABEL_48;
if ( *(float *)&v12 <= 450.0 )
{
if ( *(float *)&v12 <= 300.0 )
{
if ( *(float *)&v12 <= 150.0 )
{
if ( *(float *)&v12 <= 7.5 )
goto LABEL_48;
v22 = a1->m_gameLayer;
if ( !v22 )
goto LABEL_48;
v23 = FallLow;
goto LABEL_47;
}
v22 = a1->m_gameLayer;
if ( v22 )
{
v23 = FallMed;
goto LABEL_47;
}
}
else
{
v22 = a1->m_gameLayer;
if ( v22 )
{
v23 = FallHigh;
goto LABEL_47;
}
}
}
else
{
v22 = a1->m_gameLayer;
if ( v22 )
{
v23 = FallVHigh;
LABEL_47:
GJBaseGameLayer::gameEventTriggered(v22, v23, a1->m_groundObjectMaterial, a1->m_uniqueID);
}
}
LABEL_48:
a1->m_fallStartY = 0.0;
goto LABEL_49;
}
v15 = TinyLanding;
if ( !a1->m_isOnGround2 )
v15 = FeatherLanding;
}
else
{
v15 = SoftLanding;
}
}
else
{
v15 = NormalLanding;
}
}
else
{
v15 = HardLanding;
}
GJBaseGameLayer::gameEventTriggered(m_gameLayer, v15, m_objectMaterial, a1->m_uniqueID);
goto LABEL_33;
}
LABEL_49:
a1->m_yVelocity = 0.0;
a1->m_isSliding = 0;
if ( !a1->m_isOnGround2 && !a3 && !PlayerObject::levelFlipping(a1) && !a1->m_isHidden )
{
m_useLandParticles0 = a1->m_useLandParticles0;
v25 = m_useLandParticles0 ? a1->m_landParticles0 : a1->m_landParticles1;
a1->m_useLandParticles0 = !m_useLandParticles0;
if ( v25->getParticleCount(v25) <= 2 )
{
((void (__fastcall *)(cocos2d::CCParticleSystemQuad *))v25->setAngle)(v25);
v26 = v25->cocos2d::CCParticleSystem::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
v27 = a1->m_landParticles0->getGravity(a1->m_landParticles0);
v28 = cocos2d::CCPoint::CCPoint(*(float *)&v12, v27->x);
v26->setGravity(v25, v29);
cocos2d::CCPoint::CCPoint(*(float *)&v28, 0.0);
((void (__fastcall *)(cocos2d::CCParticleSystemQuad *))v25->setRotation)(v25);
if ( a2 && a2->getType(a2) == Slope )
((void (__fastcall *)(cocos2d::CCParticleSystemQuad *))v25->setRotation)(v25);
v30 = a1->getPosition_0(a1);
cocos2d::CCPoint::operator+(v30, &v36);
v25->setPosition_0(v25, (const cocos2d::CCPoint *)&v36);
cocos2d::CCParticleSystem::resetSystem(v25);
}
}
if ( !a1->m_justPlacedStreak )
{
PlayerObject::placeStreakPoint(a1);
a1->m_justPlacedStreak = 1;
}
if ( !a1->m_isOnGround2 && !a1->m_isDashing )
{
if ( a1->m_isRobot )
{
v31 = sub_14003BDB0((__int64)v35, (__int64)&a1->m_currentRobotAnimation);
CCAnimatedSprite::runAnimation((__int64)a1->m_robotSprite, v31);
}
else if ( a1->m_isSpider )
{
PlayerObject::playDynamicSpiderRun(a1);
}
}
a1->m_isOnGround2 = 1;
a1->m_unkA29 = !a3;
if ( !v10 )
{
a1->m_lastLandTime = a1->m_totalTime;
a1->m_isOnGround = 1;
}
v14 = !a1->m_isBall;
a1->m_isOnGround3 = 1;
a1->m_stateOnGround = 2;
if ( v14 )
{
if ( a1->m_isRotating || a1->m_wasOnSlope )
{
*(_WORD *)&a1->m_isRotating = 0;
a1->m_isBallRotating = 0;
a1->m_rotationSpeed = 0.0;
}
}
else
{
if ( a1->m_isBallRotating && !a1->m_isOnSlope )
{
*(_WORD *)&a1->m_isRotating = 0;
a1->m_isBallRotating = 0;
a1->m_rotationSpeed = 0.0;
}
if ( a1->m_isBallRotating2 )
{
*(_WORD *)&a1->m_isRotating = 0;
a1->m_isBallRotating = 0;
a1->m_rotationSpeed = 0.0;
}
if ( !a1->m_isRotating && !a1->m_isLocked && !a1->m_isDashing )
{
*(_WORD *)&a1->m_isRotating = 0;
a1->m_isBallRotating = 0;
a1->m_rotationSpeed = 0.0;
PlayerObject::runBallRotation(a1, 1.0);
}
}
if ( !a1->m_isBall
&& !a1->m_isShip
&& !a1->m_isBird
&& !a1->m_isDart
&& !a1->m_isSwing
&& !a1->m_isOnSlope
&& !a1->m_wasOnSlope )
{
v32 = a1->getRotation(a1);
if ( (int)v32 != 90 * ((int)v32 / 90) )
{
*(_WORD *)&a1->m_isRotating = 0;
a1->m_isBallRotating = 0;
a1->m_rotationSpeed = 0.0;
}
}
v33 = a1->getPosition_0(a1);
cocos2d::CCPoint::operator=(&a1->m_lastGroundedPos, v33);
if ( !a1->m_isShip && !a1->m_isBird && !a1->m_isDart && !a1->m_isSwing && a1->m_shouldTryPlacingCheckpoint )
{
if ( !a1->m_alwaysShowStreak )
cocos2d::CCMotionStreak::stopStroke(a1->m_regularTrail);
if ( a1->m_fadeOutStreak )
{
v14 = !a1->m_playEffects;
a1->m_fadeOutStreak = 0;
if ( v14 )
v34 = 0.60000002;
else
v34 = 0.2;
PlayerObject::fadeOutStreak2(a1, v34);
}
a1->m_canPlaceCheckpoint = 1;
}
a1->m_shouldTryPlacingCheckpoint = 0;
}