//
// GJBaseGameLayer::volumeForProximityEffect from 0x868a58 to 0x868dac (852 bytes)
//
// 4 xrefs:
// > GJBaseGameLayer::updateProximityVolumeEffects @ 0x868e10
// > GJBaseGameLayer::addProximityVolumeEffect @ 0x88cdec
// > GJBaseGameLayer::activateSFXTrigger @ 0x88d064
// > ??> @ 0x90678
//
// 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
//
float GJBaseGameLayer::volumeForProximityEffect(GJBaseGameLayer *a1, SFXTriggerInstance *a2)
{
cocos2d::CCDirector *v4; // x0
SFXTriggerGameObject *m_sfxTriggerGameObject; // x19
cocos2d::CCArray *Group; // x26
float v7; // s0
float v8; // s1
PlayerObject *m_player2; // x1
_BOOL4 v10; // w24
int v11; // w25
float v12; // s0
float v13; // s1
float m_volumeNear; // s11
float m_volumeFar; // s9
int m_minDistMedium; // w23
int m_minDistFar; // w27
float v18; // s8
float v19; // s2
float MinDistance; // s10
float v21; // s1
float v23; // s0
float v24; // s1
float v25; // s1
float v26; // s0
GameObject *MainObject; // x0
float v28; // s0
float v29; // s1
const cocos2d::CCPoint *v30; // x0
float v31; // s2
const cocos2d::CCPoint *v32; // x0
float v33; // s2
float v34; // [xsp+80h] [xbp+80h]
float v35; // [xsp+84h] [xbp+84h]
__int64 v36; // [xsp+88h] [xbp+88h] BYREF
cocos2d::CCPoint v37; // [xsp+90h] [xbp+90h] BYREF
cocos2d::CCPoint v38; // [xsp+98h] [xbp+98h] BYREF
cocos2d::CCPoint v39; // [xsp+A0h] [xbp+A0h] BYREF
cocos2d::CCPoint v40; // 0:s0.4,4:s1.4
cocos2d::CCPoint v41; // 0:s0.4,4:s1.4
cocos2d::CCPoint v42; // 0:s0.4,4:s1.4
v4 = cocos2d::CCDirector::sharedDirector();
cocos2d::CCDirector::getWinSize(v4);
cocos2d::CCPoint::CCPoint(
&v39,
(float)(v34 / a1->m_gameState.m_cameraZoom) * 0.5,
(float)(v35 / a1->m_gameState.m_cameraZoom) * 0.5);
cocos2d::CCPoint::operator+(&v36, &a1->m_gameState.m_cameraPosition, &v39);
m_sfxTriggerGameObject = a2->m_sfxTriggerGameObject;
Group = GJBaseGameLayer::getGroup(a1, a2->m_groupID1);
cocos2d::CCPoint::CCPoint(&v37);
if ( m_sfxTriggerGameObject->m_cameraDistance )
{
v10 = 0;
v11 = 1;
cocos2d::CCPoint::operator=(&v37, v7, v8);
if ( !Group )
return 1.0;
}
else
{
if ( m_sfxTriggerGameObject->m_targetPlayer1 )
{
v23 = ((float (__fastcall *)(PlayerObject *))a1->m_player1->getPosition)(a1->m_player1);
cocos2d::CCPoint::operator=(&v37, v23, v24);
v10 = m_sfxTriggerGameObject->m_targetPlayer2 && a1->m_gameState.m_isDualMode;
v11 = 1;
}
else if ( m_sfxTriggerGameObject->m_targetPlayer2 )
{
if ( a1->m_gameState.m_isDualMode )
m_player2 = a1->m_player2;
else
m_player2 = a1->m_player1;
v10 = 0;
v11 = 1;
v12 = ((float (__fastcall *)(PlayerObject *))m_player2->getPosition)(m_player2);
cocos2d::CCPoint::operator=(&v37, v12, v13);
}
else
{
MainObject = GJBaseGameLayer::tryGetMainObject(a1, a2->m_groupID2);
v10 = 0;
if ( MainObject )
{
v11 = 1;
MainObject->getRealPosition((GameObject *)&v39);
cocos2d::CCPoint::operator=(&v37, v28, v29);
}
else
{
v11 = 0;
}
}
if ( !Group )
return 1.0;
}
if ( !(unsigned int)cocos2d::CCArray::count(Group) || !v11 )
return 1.0;
m_volumeNear = m_sfxTriggerGameObject->m_volumeNear;
m_volumeFar = m_sfxTriggerGameObject->m_volumeFar;
m_minDistMedium = m_sfxTriggerGameObject->m_minDistMedium;
m_minDistFar = m_sfxTriggerGameObject->m_minDistFar;
v18 = (float)(3 * m_sfxTriggerGameObject->m_minDistNear);
cocos2d::CCPoint::CCPoint(&v39, &v37);
v40.x = v18;
MinDistance = GJBaseGameLayer::getMinDistance(a1, v40, (cocos2d::CCArray *)&v39, v19, (int)Group);
if ( v18 < MinDistance && v10 )
{
v30 = a1->m_player2->getPosition(a1->m_player2);
cocos2d::CCPoint::CCPoint(&v38, v30);
v41.x = v18;
if ( MinDistance > GJBaseGameLayer::getMinDistance(a1, v41, (cocos2d::CCArray *)&v38, v31, (int)Group) )
{
v32 = a1->m_player2->getPosition(a1->m_player2);
cocos2d::CCPoint::CCPoint(&v39, v32);
v42.x = v18;
MinDistance = GJBaseGameLayer::getMinDistance(a1, v42, (cocos2d::CCArray *)&v39, v33, (int)Group);
}
}
v21 = 0.0;
if ( MinDistance > v18 )
{
v25 = (float)(3 * m_minDistMedium) + v18;
v26 = (float)(3 * m_minDistFar) + v25;
if ( MinDistance >= v26 )
{
v21 = 1.0;
}
else
{
if ( v25 > 0.0 )
{
if ( MinDistance < v25 )
{
m_volumeNear = m_sfxTriggerGameObject->m_volumeNear;
m_volumeFar = m_sfxTriggerGameObject->m_volumeMedium;
v26 = (float)(3 * m_minDistMedium) + v18;
}
else
{
m_volumeNear = m_sfxTriggerGameObject->m_volumeMedium;
m_volumeFar = m_sfxTriggerGameObject->m_volumeFar;
v18 = (float)(3 * m_minDistMedium) + v18;
}
}
v21 = 0.0;
if ( v18 != v26 )
v21 = (float)(MinDistance - v18) / (float)(v26 - v18);
}
}
return m_volumeNear + (float)((float)(m_volumeFar - m_volumeNear) * v21);
}