//
// GJBaseGameLayer::activateItemEditTrigger from 0x890fc4 to 0x891328 (868 bytes)
//
// 2 xrefs:
// > ItemTriggerGameObject::triggerObject @ 0x770b8c
// > ??> @ 0x66f00
//
// 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 GJBaseGameLayer::activateItemEditTrigger(GJBaseGameLayer *a1, ItemTriggerGameObject *a2)
{
int m_resultType2; // w28
int m_resultType3; // w27
int m_targetItemMode; // w20
float v5; // s0
int m_itemID; // w2
int m_itemID2; // w4
int m_targetGroupID; // w21
int m_item1Mode; // w5
int m_item2Mode; // w3
int m_resultType1; // w22
int m_roundType1; // w23
int m_roundType2; // w24
int m_signType1; // w25
int m_signType2; // w26
_BOOL4 v16; // w6
float v18; // s8
double v19; // d10
double v20; // d9
double v21; // d1
int v22; // w20
double ItemValue; // d10
int v24; // [xsp+80h] [xbp+80h]
int v25; // [xsp+88h] [xbp+88h]
int v26; // [xsp+88h] [xbp+88h]
_BOOL4 v27; // [xsp+90h] [xbp+90h]
int v28; // [xsp+90h] [xbp+90h]
double v29; // [xsp+90h] [xbp+90h]
m_resultType2 = a2->m_resultType2;
m_resultType3 = a2->m_resultType3;
m_targetItemMode = a2->m_targetItemMode;
if ( m_resultType2 <= 0 )
m_resultType2 = 1;
v5 = roundf(a2->m_mod1 * 1000.0);
if ( m_resultType3 <= 2 )
m_resultType3 = 3;
m_itemID = a2->m_itemID;
m_itemID2 = a2->m_itemID2;
m_targetGroupID = a2->m_targetGroupID;
m_item1Mode = a2->m_item1Mode;
m_item2Mode = a2->m_item2Mode;
m_resultType1 = a2->m_resultType1;
m_roundType1 = a2->m_roundType1;
m_roundType2 = a2->m_roundType2;
m_signType1 = a2->m_signType1;
m_signType2 = a2->m_signType2;
if ( m_targetItemMode <= 0 )
{
m_targetItemMode = 1;
}
else if ( m_targetItemMode == 3 )
{
goto LABEL_9;
}
if ( m_targetGroupID <= 0 )
return;
LABEL_9:
v16 = 0;
if ( m_item1Mode )
{
v16 = 1;
if ( m_itemID <= 0 )
v16 = (unsigned int)(m_item1Mode - 3) <= 1;
}
v18 = v5 / 1000.0;
if ( m_item2Mode && (m_itemID2 > 0 || (unsigned int)(m_item2Mode - 3) <= 1) )
{
v26 = a2->m_item2Mode;
v28 = a2->m_itemID2;
if ( v16 )
{
ItemValue = GJBaseGameLayer::getItemValue(a1, m_item1Mode, m_itemID);
v29 = GJBaseGameLayer::getItemValue(a1, v26, v28);
v20 = GJBaseGameLayer::getItemValue(a1, m_targetItemMode, m_targetGroupID);
v19 = GJBaseGameLayer::performMathOperation(a1, ItemValue, v29, m_resultType2);
}
else
{
v19 = GJBaseGameLayer::getItemValue(a1, m_item2Mode, m_itemID2);
GJBaseGameLayer::getItemValue(a1, v26, v28);
v20 = GJBaseGameLayer::getItemValue(a1, m_targetItemMode, m_targetGroupID);
}
}
else
{
v27 = v16;
v24 = a2->m_item2Mode;
v25 = a2->m_itemID2;
v19 = GJBaseGameLayer::getItemValue(a1, m_item1Mode, m_itemID);
GJBaseGameLayer::getItemValue(a1, v24, v25);
v20 = GJBaseGameLayer::getItemValue(a1, m_targetItemMode, m_targetGroupID);
if ( !v27 )
{
v21 = v18;
if ( m_roundType1 )
goto LABEL_36;
LABEL_15:
if ( m_signType1 )
goto LABEL_34;
LABEL_16:
if ( m_resultType1 )
goto LABEL_32;
LABEL_17:
if ( m_roundType2 )
goto LABEL_29;
LABEL_18:
if ( m_signType2 )
goto LABEL_30;
goto LABEL_19;
}
}
v21 = GJBaseGameLayer::performMathOperation(a1, v19, v18, m_resultType3);
if ( !m_roundType1 )
goto LABEL_15;
LABEL_36:
v21 = GJBaseGameLayer::performMathRounding(a1, v21, m_roundType1);
if ( !m_signType1 )
goto LABEL_16;
LABEL_34:
v21 = performMathSign(v21, m_signType1);
if ( !m_resultType1 )
goto LABEL_17;
LABEL_32:
v21 = GJBaseGameLayer::performMathOperation(a1, v20, v21, m_resultType1);
if ( !m_roundType2 )
goto LABEL_18;
LABEL_29:
v21 = GJBaseGameLayer::performMathRounding(a1, v21, m_roundType2);
if ( m_signType2 )
{
LABEL_30:
v21 = performMathSign(v21, m_signType2);
if ( m_targetItemMode == 2 )
goto LABEL_31;
goto LABEL_20;
}
LABEL_19:
if ( m_targetItemMode == 2 )
{
LABEL_31:
GJEffectManager::updateTimer(a1->m_effectManager, m_targetGroupID, v21);
return;
}
LABEL_20:
if ( m_targetItemMode == 3 )
{
a1->m_gameState.m_unkBool32 = 1;
a1->m_gameState.m_points = (int)v21;
}
else if ( m_targetItemMode == 1 )
{
v22 = (int)v21;
GJEffectManager::updateCountForItem(a1->m_effectManager, m_targetGroupID, (int)v21);
GJBaseGameLayer::updateCounters(a1, m_targetGroupID, v22);
}
}