//
// PlayerObject::setupStreak from 0x1403887c0 to 0x140388c94 (1236 bytes)
//
// 2 xrefs:
// > PlayerObject::init @ 0x140387a9b
// > ??> @ 0x1406d5f6c
//
// 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=8
void PlayerObject::setupStreak(PlayerObject *a1)
{
__int64 v2; // rax
int v3; // edx
cocos2d::CCString *v4; // rax
const char *CString; // rdx
float v6; // xmm0_4
float v7; // xmm2_4
cocos2d::CCMotionStreak *v8; // rax
__int64 v9; // rax
int v10; // edx
float v11; // xmm6_4
float v12; // xmm7_4
char *v13; // rax
const char *v14; // rdi
cocos2d::CCTextureCache *v15; // rax
struct cocos2d::CCTexture2D *v16; // rax
HardStreak *v17; // rax
__int64 v18; // rcx
float v19; // xmm1_4
void *v20; // [rsp+30h] [rbp-68h]
void *v21; // [rsp+30h] [rbp-68h]
void *v22; // [rsp+30h] [rbp-68h]
__int64 v23; // [rsp+38h] [rbp-60h] BYREF
char v24[32]; // [rsp+40h] [rbp-58h] BYREF
v2 = qword_1406C2ED8;
if ( !qword_1406C2ED8 )
{
v20 = operator new(0x668u);
qword_1406C2ED8 = sub_14017AB00((__int64)v20);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2ED8 + 72LL))(qword_1406C2ED8);
v2 = qword_1406C2ED8;
}
v3 = *(_DWORD *)(v2 + 840) - *(_DWORD *)(v2 + 844);
if ( v3 >= 7 )
{
v3 = 7;
}
else if ( v3 <= 1 )
{
v3 = 1;
}
a1->m_playerStreak = v3;
a1->m_hasGlow = *(_BYTE *)(v2 + 904);
v4 = cocos2d::CCString::createWithFormat("streak_%02d_001.png", v3);
CString = cocos2d::CCString::getCString(v4);
a1->m_streakStrokeWidth = 10.0;
v6 = 0.30000001;
v7 = 10.0;
switch ( a1->m_playerStreak )
{
case 2:
case 7:
v7 = 14.0;
a1->m_disableStreakTint = 1;
a1->m_streakStrokeWidth = 14.0;
break;
case 3:
a1->m_streakStrokeWidth = 8.5;
v7 = 8.5;
break;
case 4:
v6 = 0.40000001;
v7 = 10.0;
break;
case 5:
a1->m_streakStrokeWidth = 5.0;
v6 = 0.60000002;
a1->m_alwaysShowStreak = 1;
v7 = 5.0;
break;
case 6:
v6 = 1.0;
a1->m_alwaysShowStreak = 1;
a1->m_streakStrokeWidth = 3.0;
v7 = 3.0;
break;
default:
break;
}
v8 = cocos2d::CCMotionStreak::create(v6, 5.0, v7, (const struct cocos2d::_ccColor3B *)&word_140529BAC, CString);
a1->m_regularTrail = v8;
if ( a1->m_playerStreak == 6 )
cocos2d::CCMotionStreak::enableRepeatMode(v8, 0.1);
a1->m_regularTrail->m_fMaxSeg = 50.0;
a1->m_parentLayer->addChild_0(a1->m_parentLayer, a1->m_regularTrail, -2);
v9 = qword_1406C2ED8;
if ( !qword_1406C2ED8 )
{
v21 = operator new(0x668u);
qword_1406C2ED8 = sub_14017AB00((__int64)v21);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2ED8 + 72LL))(qword_1406C2ED8);
v9 = qword_1406C2ED8;
}
v10 = *(_DWORD *)(v9 + 852) - *(_DWORD *)(v9 + 856);
a1->m_shipStreakType = v10;
if ( v10 <= 6 )
{
if ( v10 > 1 )
{
switch ( v10 )
{
case 2:
v11 = 0.063600004;
v12 = 22.0;
break;
case 3:
v11 = 0.1278;
v12 = 28.599998;
break;
case 4:
v11 = 0.105;
v12 = 28.599998;
break;
case 5:
v11 = 0.090000004;
v12 = 18.700001;
break;
default:
v11 = 0.096000001;
v12 = 27.0;
break;
}
v13 = sub_140386060(v24, v10, 0.0);
v14 = v13;
if ( *((_QWORD *)v13 + 3) > 0xFu )
v14 = *(const char **)v13;
v15 = (cocos2d::CCTextureCache *)cocos2d::CCTextureCache::sharedTextureCache();
v16 = cocos2d::CCTextureCache::addImage(v15, v14, 0);
a1->m_shipStreak = cocos2d::CCMotionStreak::create(
v11,
1.0,
v12,
(const struct cocos2d::_ccColor3B *)&word_140529BAC,
v16);
sub_14003A830((__int64)v24);
a1->m_parentLayer->addChild_0(a1->m_parentLayer, a1->m_shipStreak, -3);
a1->m_shipStreak->m_fMaxSeg = 50.0;
a1->m_shipStreak->m_bDontOpacityFade = 1;
((void (__fastcall *)(cocos2d::CCTextureProtocol *, __int64))a1->m_shipStreak->setBlendFunc)(
&a1->m_shipStreak->cocos2d::CCTextureProtocol,
0x100000302LL);
}
}
else
{
a1->m_shipStreakType = ShipFire1;
}
v23 = 0x100000302LL;
((void (__fastcall *)(cocos2d::CCTextureProtocol *, __int64))a1->m_regularTrail->setBlendFunc)(
&a1->m_regularTrail->cocos2d::CCTextureProtocol,
0x100000302LL);
v17 = HardStreak::create();
a1->m_waveTrail = v17;
a1->m_parentLayer->addChild_0(a1->m_parentLayer, v17, -3);
v18 = qword_1406C2ED8;
if ( !qword_1406C2ED8 )
{
v22 = operator new(0x668u);
qword_1406C2ED8 = sub_14017AB00((__int64)v22);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2ED8 + 72LL))(qword_1406C2ED8);
v18 = qword_1406C2ED8;
}
if ( *(_DWORD *)(v18 + 804) - *(_DWORD *)(v18 + 808) != 15 || a1->m_switchWaveTrailColor )
cocos2d::CCDrawNode::setBlendFunc(a1->m_waveTrail, (const struct cocos2d::_ccBlendFunc *)&v23);
else
a1->m_waveTrail->m_isSolid = 1;
cocos2d::CCMotionStreak::stopStroke(a1->m_regularTrail);
if ( a1->m_fadeOutStreak )
{
a1->m_fadeOutStreak = 0;
if ( a1->m_playEffects )
v19 = 0.2;
else
v19 = 0.60000002;
PlayerObject::fadeOutStreak2(a1, v19);
}
}