//
// SequenceTriggerGameObject::triggerObject from 0x1001c47e0 to 0x1001c4d21 (1345 bytes)
//
// 1 xrefs:
// > ??> @ 0x1008cf718
//
// 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 SequenceTriggerGameObject::triggerObject(
SequenceTriggerGameObject *a1,
GJBaseGameLayer *a2,
int a3,
std::vector *const a4)
{
int v5; // r11d
int *end; // rax
float *p_m_sequenceState; // rdi
unsigned __int64 value; // r8
__m128 v9; // xmm0
unsigned __int64 v10; // r10
unsigned __int64 v11; // rcx
__int64 **v12; // rax
__int64 *v13; // r9
unsigned __int64 v14; // r8
unsigned __int64 v15; // rax
__int64 v16; // rax
float *v17; // rbx
float *v18; // rax
int v19; // r12d
__m128 v20; // xmm0
__m128 v21; // xmm1
float m_minInt; // xmm2_4
float m_reset; // xmm2_4
_QWORD *v24; // rax
__m128i v25; // xmm0
int m_sequenceTotalCount; // r15d
int v27; // eax
std::__vector_base::pointer v28; // rax
std::__vector_base::pointer v29; // rcx
int v30; // edx
int m_groupID; // r12d
std::__vector_base::pointer begin; // rdx
std::__vector_base::pointer v33; // rax
unsigned __int64 v34; // rsi
std::__vector_base::pointer v35; // rcx
std::__vector_base::pointer v36; // rbx
signed __int64 v37; // r15
int *v38; // r13
__int64 v39; // rsi
__int64 v40; // rdi
__int64 v41; // rsi
int *p_m_chance; // rdx
__m128i v43; // xmm0
__m128i v44; // xmm1
__m128i v45; // xmm1
int m_sequenceMode; // ecx
std::vector __p; // [rsp+10h] [rbp-50h] BYREF
float v50; // [rsp+2Ch] [rbp-34h]
int v51; // [rsp+30h] [rbp-30h] BYREF
v51 = 0;
v5 = 0;
if ( a4 )
{
if ( a1->m_uniqueRemap )
{
end = a4->__end_;
if ( a4->__begin_ != end )
{
v5 = -*(end - 1);
v51 = v5;
}
}
}
p_m_sequenceState = (float *)&a1->m_sequenceState;
value = a1->m_sequenceState.m_sequenceTimes.__table_.__bucket_list_.__ptr_.__value_.__data_.__value_;
v9 = (__m128)0xBF800000;
v50 = -1.0;
if ( !value )
goto LABEL_33;
v10 = (0x101010101010101LL
* ((((value - ((value >> 1) & 0x5555555555555555LL)) & 0x3333333333333333LL)
+ (((value - ((value >> 1) & 0x5555555555555555LL)) >> 2) & 0x3333333333333333LL)
+ ((((value - ((value >> 1) & 0x5555555555555555LL)) & 0x3333333333333333LL)
+ (((value - ((value >> 1) & 0x5555555555555555LL)) >> 2) & 0x3333333333333333LL)) >> 4))
& 0xF0F0F0F0F0F0F0FLL)) >> 56;
if ( v10 <= 1 )
{
v11 = v5 & (value - 1);
v12 = *(__int64 ***)(*(_QWORD *)p_m_sequenceState + 8 * v11);
if ( !v12 )
goto LABEL_33;
goto LABEL_13;
}
v11 = v5;
if ( value <= v5 )
{
if ( !((value | v5) >> 32) )
{
v11 = v5 % (unsigned int)value;
v12 = *(__int64 ***)(*(_QWORD *)p_m_sequenceState + 8 * v11);
if ( !v12 )
goto LABEL_33;
goto LABEL_13;
}
v11 = v5 % value;
}
v12 = *(__int64 ***)(*(_QWORD *)p_m_sequenceState + 8 * v11);
if ( !v12 )
{
LABEL_33:
v17 = (float *)&a1->m_sequenceState;
goto LABEL_34;
}
LABEL_13:
v13 = *v12;
if ( !*v12 )
goto LABEL_33;
if ( (unsigned int)v10 < 2 )
{
v14 = value - 1;
while ( 1 )
{
v16 = v13[1];
if ( v16 == v5 )
{
if ( *((_DWORD *)v13 + 4) == v5 )
goto LABEL_31;
}
else if ( (v14 & v16) != v11 )
{
goto LABEL_33;
}
v13 = (__int64 *)*v13;
if ( !v13 )
goto LABEL_33;
}
}
while ( 1 )
{
v15 = v13[1];
if ( v15 == v5 )
break;
if ( v15 < value )
goto LABEL_22;
if ( (value | v15) >> 32 )
{
v15 %= value;
LABEL_22:
if ( v15 != v11 )
goto LABEL_33;
goto LABEL_17;
}
if ( (unsigned int)v15 % (unsigned int)value != v11 )
goto LABEL_33;
LABEL_17:
v13 = (__int64 *)*v13;
if ( !v13 )
goto LABEL_33;
}
if ( *((_DWORD *)v13 + 4) != v5 )
goto LABEL_17;
LABEL_31:
__p.__begin_ = &v51;
v17 = (float *)&a1->m_sequenceState;
v18 = (float *)sub_100174230(p_m_sequenceState, &v51, (__m128)0xBF800000, (__int64)&unk_1008174F2, &__p.__begin_);
v9 = (__m128)*((unsigned int *)v18 + 5);
v50 = v18[5];
LABEL_34:
__p.__begin_ = &v51;
v19 = *((_DWORD *)sub_100055BA0(
(float *)&a1->m_sequenceState.m_sequenceIndices,
&v51,
v9,
(__int64)&unk_1008174F2,
&__p.__begin_)
+ 5);
v20 = (__m128)*(unsigned __int64 *)&a2->m_gameState.m_unkDouble3;
v21 = 0;
v21.f32[0] = a2->m_gameState.m_unkDouble3 - v50;
m_minInt = a1->m_minInt;
if ( m_minInt <= 0.0 || v50 < 0.0 || m_minInt <= v21.f32[0] )
{
if ( v19 > 0 )
{
m_reset = a1->m_reset;
if ( m_reset > 0.0 && v50 >= 0.0 && v21.f32[0] > m_reset )
{
if ( a1->m_resetMode )
{
v21.f32[0] = v21.f32[0] / m_reset;
v19 = (int)fmaxf((float)v19 - _mm_round_ss(v21, v21, 9).f32[0], 0.0);
}
else
{
v19 = 0;
}
}
}
v20.f32[0] = *(double *)v20.i64;
v50 = v20.f32[0];
__p.__begin_ = &v51;
v24 = sub_100174230(v17, &v51, v20, (__int64)&unk_1008174F2, &__p.__begin_);
v25 = _mm_cvtsi32_si128(LODWORD(v50));
*((_DWORD *)v24 + 5) = _mm_cvtsi128_si32(v25);
m_sequenceTotalCount = a1->m_sequenceTotalCount;
if ( m_sequenceTotalCount == -1 )
{
a1->m_sequenceTotalCount = 0;
begin = a1->m_chanceObjects.__begin_;
v33 = a1->m_chanceObjects.__end_;
if ( begin == v33 )
{
m_sequenceTotalCount = 0;
v27 = v19 + 1;
if ( v19 >= 0 )
goto LABEL_73;
}
else
{
v34 = (char *)v33 - (char *)begin - 16;
m_sequenceTotalCount = 0;
if ( v34 > 0x7F )
{
v39 = (v34 >> 4) + 1;
v40 = 8;
if ( (v39 & 7) != 0 )
v40 = v39 & 7;
v41 = v39 - v40;
v35 = &begin[v41];
p_m_chance = &begin[7].m_chance;
v43 = 0;
v44 = 0;
do
{
v43 = _mm_add_epi32(
v43,
_mm_insert_epi32(
_mm_insert_epi32(
_mm_insert_epi32(_mm_cvtsi32_si128(*(p_m_chance - 28)), *(p_m_chance - 24), 1),
*(p_m_chance - 20),
2),
*(p_m_chance - 16),
3));
v44 = _mm_add_epi32(
v44,
_mm_insert_epi32(
_mm_insert_epi32(
_mm_insert_epi32(_mm_cvtsi32_si128(*(p_m_chance - 12)), *(p_m_chance - 8), 1),
*(p_m_chance - 4),
2),
*p_m_chance,
3));
p_m_chance += 32;
v41 -= 8;
}
while ( v41 );
v45 = _mm_add_epi32(v44, v43);
v25 = _mm_add_epi32(_mm_shuffle_epi32(v45, 238), v45);
m_sequenceTotalCount = _mm_cvtsi128_si32(_mm_add_epi32(_mm_shuffle_epi32(v25, 85), v25));
}
else
{
v35 = a1->m_chanceObjects.__begin_;
}
do
{
m_sequenceTotalCount += v35->m_chance;
++v35;
}
while ( v35 != v33 );
a1->m_sequenceTotalCount = m_sequenceTotalCount;
v27 = v19 + 1;
if ( v19 >= m_sequenceTotalCount )
goto LABEL_73;
}
goto LABEL_46;
}
v27 = v19 + 1;
if ( v19 < m_sequenceTotalCount )
goto LABEL_46;
LABEL_73:
m_sequenceMode = a1->m_sequenceMode;
if ( m_sequenceMode )
{
if ( m_sequenceMode == 1 )
{
m_sequenceTotalCount = 1;
goto LABEL_47;
}
if ( m_sequenceMode == 2 )
{
LABEL_47:
v28 = a1->m_chanceObjects.__begin_;
v29 = a1->m_chanceObjects.__end_;
if ( v28 == v29 )
{
LABEL_51:
m_groupID = 0;
}
else
{
v30 = 0;
while ( 1 )
{
v30 += v28->m_chance;
if ( v30 >= m_sequenceTotalCount )
break;
if ( ++v28 == v29 )
goto LABEL_51;
}
m_groupID = v28->m_groupID;
}
__p.__begin_ = &v51;
*((_DWORD *)sub_100055BA0(
(float *)&a1->m_sequenceState.m_sequenceIndices,
&v51,
(__m128)v25,
(__int64)&unk_1008174F2,
&__p.__begin_)
+ 5) = m_sequenceTotalCount;
if ( a4 )
{
memset(&__p, 0, sizeof(__p));
v36 = a4->__begin_;
v37 = (char *)a4->__end_ - (char *)a4->__begin_;
if ( v37 )
{
if ( v37 < 0 )
sub_1000C40D0();
__p.__begin_ = (std::__vector_base::pointer)operator new(v37);
v38 = (std::__vector_base::pointer)((char *)__p.__begin_ + v37);
__p.__end_cap_.__value_ = (std::__vector_base::pointer)((char *)__p.__begin_ + v37);
memcpy(__p.__begin_, v36, v37);
__p.__end_ = v38;
}
}
else
{
memset(&__p, 0, sizeof(__p));
}
GJBaseGameLayer::spawnGroupTriggered(a2, m_groupID, 0.0, 0, &__p, a1->m_uniqueID, a1->m_controlID);
if ( __p.__begin_ )
{
__p.__end_ = __p.__begin_;
operator delete(__p.__begin_);
}
return;
}
LABEL_46:
m_sequenceTotalCount = v27;
goto LABEL_47;
}
}
}