#include "classes.h" // 00499a50 int * NpcHelper::chub_nearest_segment(int *param_1, int param_2) { uint32_t *puVar1; uint32_t *puVar2; uint32_t *puVar3; int *in_ECX; int rightSegment; int *in_EDX; int *leftNode; int *piVar4; float fVar5; float fVar6; float leftDy; float leftDx; int *firstNode; int leftSegment; rightSegment = in_EDX[2]; firstNode = in_EDX; piVar4 = in_EDX; leftNode = in_ECX; if (rightSegment != param_2) { leftSegment = in_ECX[2]; if (leftSegment != param_2) { fVar6 = *GHIDRA_CAST((param_2 + 0x33c)) - *GHIDRA_CAST((rightSegment + 0x33c)); leftDx = *GHIDRA_CAST((param_2 + 0x33c)) - *GHIDRA_CAST((leftSegment + 0x33c)); fVar5 = *GHIDRA_CAST((param_2 + 0x340)) - *GHIDRA_CAST((rightSegment + 0x340)); leftDy = *GHIDRA_CAST((param_2 + 0x340)) - *GHIDRA_CAST((leftSegment + 0x340)); fVar5 = sqrtf(fVar5 * fVar5 + fVar6 * fVar6); fVar6 = sqrtf(leftDy * leftDy + leftDx * leftDx); if (fVar5 < fVar6) goto LAB_00499ba3; rightSegment = in_EDX[2]; } do { do { leftNode = GHIDRA_CAST(*leftNode); if (leftNode == in_EDX) { return in_ECX; } leftSegment = leftNode[2]; } while (leftSegment == param_2); fVar6 = *GHIDRA_CAST((param_2 + 0x33c)) - *GHIDRA_CAST((rightSegment + 0x33c)); leftDx = *GHIDRA_CAST((param_2 + 0x33c)) - *GHIDRA_CAST((leftSegment + 0x33c)); fVar5 = *GHIDRA_CAST((param_2 + 0x340)) - *GHIDRA_CAST((rightSegment + 0x340)); leftDy = *GHIDRA_CAST((param_2 + 0x340)) - *GHIDRA_CAST((leftSegment + 0x340)); fVar5 = sqrtf(fVar5 * fVar5 + fVar6 * fVar6); fVar6 = sqrtf(leftDy * leftDy + leftDx * leftDx); rightSegment = in_EDX[2]; firstNode = in_ECX; } while (fVar6 <= fVar5); } LAB_00499ba3: in_EDX = GHIDRA_CAST(*in_EDX); if (in_EDX != param_1) goto code_r0x00499bae; goto LAB_00499c40; code_r0x00499bae: rightSegment = in_EDX[2]; if (rightSegment != param_2) { leftSegment = leftNode[2]; if (leftSegment != param_2) { fVar6 = *GHIDRA_CAST((param_2 + 0x33c)) - *GHIDRA_CAST((rightSegment + 0x33c)); leftDx = *GHIDRA_CAST((param_2 + 0x33c)) - *GHIDRA_CAST((leftSegment + 0x33c)); fVar5 = *GHIDRA_CAST((param_2 + 0x340)) - *GHIDRA_CAST((rightSegment + 0x340)); leftDy = *GHIDRA_CAST((param_2 + 0x340)) - *GHIDRA_CAST((leftSegment + 0x340)); fVar5 = sqrtf(fVar5 * fVar5 + fVar6 * fVar6); fVar6 = sqrtf(leftDy * leftDy + leftDx * leftDx); if (fVar5 < fVar6) goto LAB_00499ba3; } LAB_00499c40: puVar1 = GHIDRA_CAST(piVar4[1]); *puVar1 = in_EDX; puVar2 = GHIDRA_CAST(in_EDX[1]); *puVar2 = leftNode; puVar3 = GHIDRA_CAST(leftNode[1]); *puVar3 = piVar4; leftNode[1] = GHIDRA_INT(puVar2); in_EDX[1] = GHIDRA_INT(puVar1); piVar4[1] = GHIDRA_INT(puVar3); if (in_EDX == param_1) { return firstNode; } do { do { leftNode = GHIDRA_CAST(*leftNode); if (leftNode == in_EDX) { return firstNode; } rightSegment = in_EDX[2]; piVar4 = in_EDX; if (rightSegment == param_2) goto LAB_00499ba3; leftSegment = leftNode[2]; } while (leftSegment == param_2); fVar6 = *GHIDRA_CAST((param_2 + 0x33c)) - *GHIDRA_CAST((rightSegment + 0x33c)); leftDx = *GHIDRA_CAST((param_2 + 0x33c)) - *GHIDRA_CAST((leftSegment + 0x33c)); fVar5 = *GHIDRA_CAST((param_2 + 0x340)) - *GHIDRA_CAST((rightSegment + 0x340)); leftDy = *GHIDRA_CAST((param_2 + 0x340)) - *GHIDRA_CAST((leftSegment + 0x340)); fVar5 = sqrtf(fVar5 * fVar5 + fVar6 * fVar6); fVar6 = sqrtf(leftDy * leftDy + leftDx * leftDx); } while (fVar6 <= fVar5); } goto LAB_00499ba3; } // 0049f870 void NpcHelper::chimera_charge_begin(Entity_NPC *npc, Vector *target, float speed) { uint8_t bVar1; uint8_t *currentName; uint32_t compareResult; char *chargeBeginName; bool isLess; float length; float dirX; float local_c; float local_8; uint8_t *animData; Manager *manager; animData = (npc->_sprite)._animState._animData; if (animData != GHIDRA_CAST(0x0)) { currentName = animData; if (0xf < *GHIDRA_CAST((animData + 0x14))) { currentName = *GHIDRA_CAST(animData); } chargeBeginName = "ChargeBegin"; do { bVar1 = *currentName; isLess = bVar1 < (uint8_t)*chargeBeginName; if (bVar1 != *chargeBeginName) { LAB_0049f8b6: compareResult = -GHIDRA_UINT(isLess) | 1; goto LAB_0049f8bb; } if (bVar1 == 0) break; bVar1 = currentName[1]; isLess = bVar1 < (uint8_t)chargeBeginName[1]; if (bVar1 != chargeBeginName[1]) goto LAB_0049f8b6; currentName = currentName + 2; chargeBeginName = chargeBeginName + 2; } while (bVar1 != 0); compareResult = 0; LAB_0049f8bb: if ((compareResult == 0) && ((animData[0x34] == 0 || ((npc->_sprite)._animState._isPlaying != 0)))) goto LAB_0049f8ee; } bVar1 = ANM2::SetAnimation(&npc->_sprite,GHIDRA_CAST("ChargeBegin"),1); if (bVar1 != 0) { AnimationState::Rewind(&(npc->_sprite)._animState); (npc->_sprite)._animState._isPlaying = 1; } LAB_0049f8ee: npc->_state = 10; manager = g_manager; local_8 = 1.0; if (npc->_championColorIdx == 0x12) { local_8 = 1.5; } else if (npc->_championColorIdx == 0x13) { local_8 = 0.5; } local_c = 4.21791e-43; seed_fart_sound_override(GHIDRA_CAST(&local_c)); (GHIDRA_CAST((&manager->_sfxManager)))->SoundEffects::Play(GHIDRA_INT(local_c),1.0,2,0,local_8,0.0); dirX = target->x - (npc->_pos).x; local_c = target->y - (npc->_pos).y; length = sqrtf(dirX * dirX + local_c * local_c); if (0.0 < length) { dirX = dirX * (1.0 / length); local_c = local_c * (1.0 / length); } *GHIDRA_CAST(&npc->_i1) = 0; (npc->_targetPosition).x = dirX * speed; (npc->_targetPosition).y = local_c * speed; return; } // 004a2940 Vector * NpcHelper::colostomia_pick_target(Entity_NPC *npc, Vector *outTarget, uint8_t *isPlayerPos) { uint64_t qVar1; Entity *playerTarget; uint64_t *allocCounter; int gridWidth; uint32_t uVar3; uint32_t uVar4; int iVar5; float score; float dy; float cellX; float cellY; float fVar6; float fVar7; float bestY; EntityList_EL effects; Entity_NPC *local_720; uint8_t *local_71c; Vector *local_718; int cellCounts [448]; uint32_t local_14; void *local_10; uint8_t *puStack_c; int local_8; Game *game; int gridWidth; void *room; local_8 = 0xffffffff; puStack_c = &LAB_00af2fd0; local_10 = ExceptionList; local_14 = __security_cookie ^ GHIDRA_UINT((cellCounts + 0x1c4)); ExceptionList = &local_10; local_71c = isPlayerPos; local_718 = outTarget; local_720 = npc; memset(cellCounts,0,0x700); EntityList::QuerySublist(GHIDRA_CAST((GHIDRA_INT(g_game->_room) + 0x1218)),&effects,1000,0x8d,1,0,0); local_8 = 0; uVar4 = 0; if (effects._size != 0) { room = g_game->_room; do { uVar3 = 0; iVar5 = *GHIDRA_CAST(((*GHIDRA_CAST((GHIDRA_CAST(&(effects)) + 0x4))) + uVar4 * 4)); fVar6 = *GHIDRA_CAST((iVar5 + 0x33c)); fVar7 = *GHIDRA_CAST((iVar5 + 0x340)); do { iVar5 = GHIDRA_INT((((fVar6 + *GHIDRA_CAST((GHIDRA_INT(&DAT_00c5c5e8) + uVar3))) - 40.0) / 40.0 + 0.5)); gridWidth = GHIDRA_INT((((fVar7 + *GHIDRA_CAST((GHIDRA_INT(&DAT_00c5c5ec) + uVar3))) - 120.0) / 40.0 + 0.5)); if ((((-1 < iVar5) && (gridWidth = *GHIDRA_CAST((GHIDRA_CAST(room) + 0xc)), iVar5 < gridWidth)) && (-1 < gridWidth)) && ((gridWidth < *GHIDRA_CAST((GHIDRA_CAST(room) + 0x10)) && (iVar5 = gridWidth * gridWidth + iVar5, -1 < iVar5))) ) { cellCounts[iVar5] = cellCounts[iVar5] + 1; } uVar3 = uVar3 + 8; } while (uVar3 < 0x48); uVar4 = uVar4 + 1; } while (uVar4 < GHIDRA_UINT(effects._size)); outTarget = local_718; } playerTarget = Entity_NPC::GetPlayerTarget(local_720); game = g_game; local_718 = GHIDRA_CAST((playerTarget->_pos).x); local_720 = GHIDRA_CAST((playerTarget->_pos).y); iVar5 = GHIDRA_INT((((float)local_718 - 40.0) / 40.0 + 0.5)); gridWidth = GHIDRA_INT((((float)local_720 - 120.0) / 40.0 + 0.5)); if (((iVar5 < 0) || (gridWidth = *GHIDRA_CAST((GHIDRA_CAST(g_game->_room) + 0xc)), gridWidth <= iVar5)) || ((gridWidth < 0 || (*GHIDRA_CAST((GHIDRA_CAST(g_game->_room) + 0x10)) <= gridWidth)))) { *local_71c = 1; } else { iVar5 = gridWidth * gridWidth + iVar5; *local_71c = 1; if ((-1 < iVar5) && (iVar5 = cellCounts[iVar5], iVar5 != 0)) { uVar4 = 0; gridWidth = *GHIDRA_CAST((GHIDRA_CAST(game->_room) + 0xc)); uVar3 = *GHIDRA_CAST((GHIDRA_CAST(game->_room) + 0x10)) * gridWidth; fVar6 = (float)((double)iVar5 + __uint_to_double_fixup[-(iVar5 >> 0x1f)]) * 1000.0; fVar7 = (float)local_718; bestY = (float)local_720; if (uVar3 != 0) { do { cellY = (float)(GHIDRA_INT(uVar4) / gridWidth) * 40.0 + 120.0; iVar5 = cellCounts[uVar4] * cellCounts[uVar4]; cellX = (float)(GHIDRA_INT(uVar4) % gridWidth) * 40.0 + 40.0; dy = (float)local_720 - cellY; score = (float)local_718 - cellX; score = dy * dy + score * score + (float)((double)iVar5 + __uint_to_double_fixup[-(iVar5 >> 0x1f)]) * 10000.0; if (score < fVar6) { fVar6 = score; fVar7 = cellX; bestY = cellY; } uVar4 = uVar4 + 1; } while (uVar4 < uVar3); } *local_71c = 0; outTarget->x = fVar7; outTarget->y = bestY; if ((*GHIDRA_CAST((GHIDRA_CAST(&(effects)) + 0x0))) != '\0') { ExceptionList = local_10; return outTarget; } if (g_mainHeap == (void *)0x0) { allocCounter = &g_allocatedBytesNoHeap; } else { allocCounter = GHIDRA_CAST((GHIDRA_INT(g_mainHeap) + 0x30)); } if ((*GHIDRA_CAST((GHIDRA_CAST(&(effects)) + 0x4))) == 0) { ExceptionList = local_10; return outTarget; } uVar4 = *GHIDRA_CAST(((*GHIDRA_CAST((GHIDRA_CAST(&(effects)) + 0x4))) + -4)); qVar1 = *allocCounter; *GHIDRA_CAST(allocCounter) = GHIDRA_UINT(*allocCounter) - uVar4; *GHIDRA_CAST((GHIDRA_CAST(allocCounter) + 4)) = *GHIDRA_CAST((GHIDRA_CAST(allocCounter) + 4)) - GHIDRA_UINT((GHIDRA_UINT(qVar1) < uVar4)); goto LAB_004a2cad; } } outTarget->x = (float)local_718; outTarget->y = (float)local_720; if ((*GHIDRA_CAST((GHIDRA_CAST(&(effects)) + 0x0))) != '\0') { ExceptionList = local_10; return outTarget; } if (g_mainHeap == (void *)0x0) { allocCounter = &g_allocatedBytesNoHeap; } else { allocCounter = GHIDRA_CAST((GHIDRA_INT(g_mainHeap) + 0x30)); } if ((*GHIDRA_CAST((GHIDRA_CAST(&(effects)) + 0x4))) == 0) { ExceptionList = local_10; return outTarget; } uVar4 = *GHIDRA_CAST(((*GHIDRA_CAST((GHIDRA_CAST(&(effects)) + 0x4))) + -4)); qVar1 = *allocCounter; *GHIDRA_CAST(allocCounter) = GHIDRA_UINT(*allocCounter) - uVar4; *GHIDRA_CAST((GHIDRA_CAST(allocCounter) + 4)) = *GHIDRA_CAST((GHIDRA_CAST(allocCounter) + 4)) - GHIDRA_UINT((GHIDRA_UINT(qVar1) < uVar4)); LAB_004a2cad: free((void *)((*GHIDRA_CAST((GHIDRA_CAST(&(effects)) + 0x4))) + -4)); ExceptionList = local_10; return outTarget; } // 004a2ce0 void NpcHelper::colostomia_pick_dive_target(Entity_NPC *npc) { uint8_t bVar1; void **roomRef; Vector *candidatePos; Entity_Player *nearestPlayer; uint32_t uVar2; uint8_t *animData; int iVar4; uint8_t *pbVar5; int iVar6; Entity_NPC *pEVar7; bool bVar8; float fVar9; float fVar10; Vector freePos; Vector randomPos; int *local_24; int *local_20; void **roomSlot; uint32_t attempt; Entity_NPC *npcLocal; uint8_t *animData; uint32_t *childRef; Vector *diveTarget; Game *game; Room *room; game = g_game; diveTarget = &npc->_v1; diveTarget->x = g_vectorZero.x; (npc->_v1).y = g_vectorZero.y; attempt = 0; roomRef = &game->_room; npcLocal = npc; do { room = *roomRef; candidatePos = Room::GetRandomPosition(room,&randomPos,0.0); candidatePos = Room::FindFreePickupSpawnPosition(room,&freePos,candidatePos,0.0,0,0,0); pEVar7 = npcLocal; fVar10 = candidatePos->x; diveTarget->x = fVar10; fVar9 = candidatePos->y; (npc->_v1).y = fVar9; fVar10 = (npcLocal->_pos).x - fVar10; fVar9 = (npcLocal->_pos).y - fVar9; local_20 = GHIDRA_CAST(sqrtf(fVar9 * fVar9 + fVar10 * fVar10)); nearestPlayer = Game::GetNearestPlayer(g_game,diveTarget); fVar10 = (nearestPlayer->_pos).y - (npc->_v1).y; fVar9 = (nearestPlayer->_pos).x - diveTarget->x; local_24 = GHIDRA_CAST(sqrtf(fVar10 * fVar10 + fVar9 * fVar9)); roomSlot = &g_game->_room; bVar1 = Room::IsPositionInRoom(*roomSlot,diveTarget,60.0); if (bVar1 != 0) { room = *roomSlot; iVar6 = GHIDRA_INT(((diveTarget->x - 40.0) / 40.0 + 0.5)); iVar4 = GHIDRA_INT((((npc->_v1).y - 120.0) / 40.0 + 0.5)); if ((((iVar6 < 0) || (room->_gridWidth <= iVar6)) || (iVar4 < 0)) || (room->_gridHeight <= iVar4)) { iVar6 = -1; } else { iVar6 = room->_gridWidth * iVar4 + iVar6; } uVar2 = Room::GetGridCollision(room,iVar6); pEVar7 = npcLocal; if ((((uVar2 == 0) && (80.0 <= (float)local_20)) && (((float)local_20 <= 200.0 && (120.0 < (float)local_24)))) && ((iVar6 = npcLocal->_entityRef, iVar6 == 0 || (fVar10 = (npc->_v1).y - *GHIDRA_CAST((iVar6 + 0x340)), fVar9 = diveTarget->x - *GHIDRA_CAST((iVar6 + 0x33c)), 10000.0 < fVar10 * fVar10 + fVar9 * fVar9)))) break; } attempt = attempt + 1; roomRef = roomSlot; } while (attempt < 0xf); childRef = &pEVar7->_entityRef; if (pEVar7->_entityRef != 0) { local_20 = GHIDRA_CAST((pEVar7->_entityRef + 0x3bc)); if (*local_20 != 0) { local_24 = local_20; msvc::multiset::erase(&local_24); } *local_20 = 0; if (*childRef != 0) { local_24 = childRef; msvc::multiset::erase(&local_24); } *childRef = 0; } local_20 = GHIDRA_CAST(pEVar7->_child); if (local_20 != GHIDRA_CAST(0x0)) { *childRef = local_20; msvc::multiset::insert(childRef); if (pEVar7->_child != 0) { local_24 = &pEVar7->_child; msvc::multiset::erase(&local_24); } pEVar7->_child = 0; } animData = (pEVar7->_sprite)._animState._animData; if (animData != GHIDRA_CAST(0x0)) { animData = animData; if (0xf < *GHIDRA_CAST((animData + 0x14))) { animData = *GHIDRA_CAST(animData); } pbVar5 = &DAT_00b1d33c; do { bVar1 = *animData; bVar8 = bVar1 < *pbVar5; if (bVar1 != *pbVar5) { LAB_004a2fd4: uVar2 = -GHIDRA_UINT(bVar8) | 1; goto LAB_004a2fd9; } if (bVar1 == 0) break; bVar1 = animData[1]; bVar8 = bVar1 < pbVar5[1]; if (bVar1 != pbVar5[1]) goto LAB_004a2fd4; animData = animData + 2; pbVar5 = pbVar5 + 2; } while (bVar1 != 0); uVar2 = 0; LAB_004a2fd9: if ((uVar2 == 0) && ((animData[0x34] == 0 || ((pEVar7->_sprite)._animState._isPlaying != 0)))) goto LAB_004a2fed; } bVar1 = ANM2::SetAnimation(&pEVar7->_sprite,&DAT_00b1d33c,1); if (bVar1 != 0) { AnimationState::Rewind(&(pEVar7->_sprite)._animState); (pEVar7->_sprite)._animState._isPlaying = 1; npcLocal->_state = 6; return; } LAB_004a2fed: pEVar7->_state = 6; return; } // 004b70c0 void NpcHelper::hornfel_spawn_doors() { RailManager *this; Entity *pEVar1; uint8_t isCanStep; uint32_t uVar2; int iVar3; int iVar4; uint32_t seed; uint32_t startIndex; Room *toIndex; Room *room; int iVar5; Room *pRVar6; int *piVar7; float fVar8; float fVar9; int *doors; int *doorsEnd; Vector spawnPos; Vector leftSpawnPos; Room *local_2c; Entity *local_28; Entity *local_24; Room *local_20; int local_1c; Entity *local_18; int *doorsCapacity; void *local_10; uint8_t *puStack_c; uint32_t local_8; puStack_c = &LAB_00af336d; local_10 = ExceptionList; uVar2 = __security_cookie ^ GHIDRA_INT(register0x00000010) - 4U; ExceptionList = &local_10; doors = GHIDRA_CAST(0x0); doorsEnd = GHIDRA_CAST(0x0); doorsCapacity = GHIDRA_CAST(0x0); room = g_game->_room; local_20 = GHIDRA_CAST(room->_gridWidth); local_1c = room->_gridHeight; local_8 = 0; iVar5 = 1; local_2c = room; if (1 < local_1c + -1) { local_28 = GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST(&(local_20[-1])) + 0x7896)))); do { fVar9 = 120.0; fVar8 = 40.0; iVar4 = room->_gridWidth; if ((iVar4 < 1) || (room->_gridHeight <= iVar5)) { iVar3 = -1; } else { iVar3 = iVar4 * iVar5; } local_18 = GHIDRA_CAST((iVar4 * iVar5)); if ((iVar4 < 2) || (room->_gridHeight <= iVar5)) { iVar4 = -1; } else { iVar4 = GHIDRA_INT(local_18) + 1; } isCanStep = (GHIDRA_CAST((&room->_railManager)))->RoomGridPath::can_step(iVar4,iVar3); if (isCanStep != 0) { if ((room->_gridWidth < 1) || (room->_gridHeight <= iVar5)) { local_18 = GHIDRA_CAST(0xffffffff); } iVar4 = *GHIDRA_CAST((GHIDRA_CAST(g_game->_room) + 0xc)); leftSpawnPos.x = (float)(GHIDRA_INT(local_18) % iVar4) * fVar8 + fVar8; leftSpawnPos.y = (float)(GHIDRA_INT(local_18) / iVar4) * fVar8 + fVar9; seed = Random(); local_24 = Game::Spawn(g_game,0x3c7,0,&leftSpawnPos,&g_vectorZero,GHIDRA_CAST(0x0),0,seed); (local_24->_sprite)._rotation = -90.0; local_18 = GHIDRA_CAST(cos(-1.5707964)); fVar8 = sin(-1.5707964); (local_24->_sprite)._offset.x = (float)local_18 * 0.0 - fVar8 * 15.0; (local_24->_sprite)._offset.y = fVar8 * 0.0 + (float)local_18 * 15.0; if (doorsEnd == doorsCapacity) { msvc::vector::_Emplace_reallocate(doorsEnd,&local_24); doorsCapacity = GHIDRA_CAST(0x0); } else { *doorsEnd = GHIDRA_INT(local_24); doorsEnd = doorsEnd + 1; } fVar9 = 120.0; fVar8 = 40.0; } if (((GHIDRA_INT(&(*GHIDRA_CAST((GHIDRA_CAST(&(local_20[-1])) + 0x7897)))) < 0) || (room->_gridWidth <= GHIDRA_INT(&(*GHIDRA_CAST((GHIDRA_CAST(&(local_20[-1])) + 0x7897)))))) || (room->_gridHeight <= iVar5)) { iVar4 = -1; } else { iVar4 = GHIDRA_INT(local_20->_gridEntities) + room->_gridWidth * iVar5 + -0x25; } if (((GHIDRA_INT(&(*GHIDRA_CAST((GHIDRA_CAST(&(local_20[-1])) + 0x7896)))) < 0) || (room->_gridWidth <= GHIDRA_INT(local_28))) || (room->_gridHeight <= iVar5)) { iVar3 = -1; } else { iVar3 = GHIDRA_INT(local_20->_gridEntities) + room->_gridWidth * iVar5 + -0x26; } isCanStep = (GHIDRA_CAST((&room->_railManager)))->RoomGridPath::can_step(iVar3,iVar4); if (isCanStep != 0) { if (((GHIDRA_INT(&(*GHIDRA_CAST((GHIDRA_CAST(&(local_20[-1])) + 0x7897)))) < 0) || (room->_gridWidth <= GHIDRA_INT(&(*GHIDRA_CAST((GHIDRA_CAST(&(local_20[-1])) + 0x7897)))))) || (room->_gridHeight <= iVar5)) { local_18 = GHIDRA_CAST(0xffffffff); } else { local_18 = GHIDRA_CAST((GHIDRA_INT(local_20->_gridEntities) + room->_gridWidth * iVar5 + -0x25)); } iVar4 = *GHIDRA_CAST((GHIDRA_CAST(g_game->_room) + 0xc)); spawnPos.x = (float)(GHIDRA_INT(local_18) % iVar4) * fVar8 + fVar8; spawnPos.y = (float)(GHIDRA_INT(local_18) / iVar4) * fVar8 + fVar9; seed = Random(); local_18 = Game::Spawn(g_game,0x3c7,0,&spawnPos,&g_vectorZero,GHIDRA_CAST(0x0),0,seed); (local_18->_sprite)._rotation = 90.0; local_24 = GHIDRA_CAST(cos(1.5707964)); fVar8 = sin(1.5707964); pEVar1 = local_24; local_24 = local_18; (local_18->_sprite)._offset.x = (float)pEVar1 * 0.0 - fVar8 * 15.0; (local_18->_sprite)._offset.y = fVar8 * 0.0 + (float)pEVar1 * 15.0; if (doorsEnd == doorsCapacity) { msvc::vector::_Emplace_reallocate(doorsEnd,&local_24); doorsCapacity = GHIDRA_CAST(0x0); } else { *doorsEnd = GHIDRA_INT(local_18); doorsEnd = doorsEnd + 1; } } iVar5 = iVar5 + 1; } while (iVar5 < local_1c + -1); } local_18 = GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST(&(local_20[-1])) + 0x7897)))); pRVar6 = GHIDRA_CAST(0x1); if (1 < GHIDRA_INT(local_18)) { do { fVar9 = 120.0; fVar8 = 40.0; if ((GHIDRA_INT(pRVar6) < room->_gridWidth) && (0 < room->_gridHeight)) { iVar5 = room->_gridWidth; toIndex = pRVar6; LAB_004b747c: if (room->_gridHeight < 2) goto LAB_004b7486; iVar5 = GHIDRA_INT(pRVar6->_gridEntities) + iVar5 + -0x24; } else { iVar5 = room->_gridWidth; toIndex = GHIDRA_CAST(0xffffffff); if (GHIDRA_INT(pRVar6) < iVar5) goto LAB_004b747c; LAB_004b7486: iVar5 = -1; } isCanStep = (GHIDRA_CAST((&room->_railManager)))->RoomGridPath::can_step(iVar5,GHIDRA_INT(toIndex)); if (isCanStep != 0) { if ((GHIDRA_INT(pRVar6) < room->_gridWidth) && (0 < room->_gridHeight)) { local_20 = pRVar6; } else { local_20 = GHIDRA_CAST(0xffffffff); } iVar5 = *GHIDRA_CAST((GHIDRA_CAST(g_game->_room) + 0xc)); spawnPos.x = (float)(GHIDRA_INT(local_20) % iVar5) * fVar8 + fVar8; spawnPos.y = (float)(GHIDRA_INT(local_20) / iVar5) * fVar8 + fVar9; seed = Random(); local_24 = Game::Spawn(g_game,0x3c7,0,&spawnPos,&g_vectorZero,GHIDRA_CAST(0x0),0,seed); (local_24->_sprite)._rotation = 0.0; local_28 = GHIDRA_CAST(cos(0.0)); fVar8 = sin(0.0); pEVar1 = local_28; local_28 = local_24; (local_24->_sprite)._offset.x = (float)pEVar1 * 0.0 - fVar8 * 15.0; (local_24->_sprite)._offset.y = fVar8 * 0.0 + (float)pEVar1 * 15.0; if (doorsEnd == doorsCapacity) { msvc::vector::_Emplace_reallocate(doorsEnd,&local_28); doorsCapacity = GHIDRA_CAST(0x0); } else { *doorsEnd = GHIDRA_INT(local_24); doorsEnd = doorsEnd + 1; } } iVar5 = room->_gridWidth; this = &room->_railManager; if (((GHIDRA_INT(pRVar6) < iVar5) && (iVar4 = local_1c + -1, -1 < iVar4)) && (iVar4 < room->_gridHeight)) { iVar4 = GHIDRA_INT(pRVar6->_gridEntities) + iVar4 * iVar5 + -0x24; LAB_004b75cf: iVar3 = local_1c + -2; room = local_2c; if ((iVar3 < 0) || (local_2c->_gridHeight <= iVar3)) goto LAB_004b75e6; iVar5 = GHIDRA_INT(pRVar6->_gridEntities) + iVar3 * iVar5 + -0x24; } else { iVar4 = -1; if (GHIDRA_INT(pRVar6) < iVar5) goto LAB_004b75cf; LAB_004b75e6: iVar5 = -1; } isCanStep = this->RoomGridPath::can_step(iVar5,iVar4); if (isCanStep != 0) { local_28 = GHIDRA_CAST(FUN_004bb230()); if (doorsEnd == doorsCapacity) { msvc::vector::_Emplace_reallocate(doorsEnd,&local_28); doorsCapacity = GHIDRA_CAST(0x0); } else { *doorsEnd = GHIDRA_INT(local_28); doorsEnd = doorsEnd + 1; } } pRVar6 = GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((pRVar6)) + 0x1)))); } while (GHIDRA_INT(pRVar6) < GHIDRA_INT(local_18)); } local_18 = GHIDRA_CAST(0x0); piVar7 = doors; if (doorsEnd != GHIDRA_CAST(0x0)) { do { local_18 = GHIDRA_CAST(piVar7); local_1c = *GHIDRA_CAST(local_18); pRVar6 = GHIDRA_CAST((local_1c + 0x3bc)); local_2c = pRVar6; if ((*GHIDRA_CAST((local_1c + 0x3bc)) == 0) && (piVar7 = GHIDRA_CAST((GHIDRA_INT(local_18) + 4)), piVar7 < doorsEnd)) { do { local_28 = GHIDRA_CAST(*piVar7); local_20 = GHIDRA_CAST(&local_28->_parent); if (local_28->_parent == 0) { iVar5 = GHIDRA_INT((((local_28->_pos).x - 40.0) / 40.0 + 0.5)); iVar4 = GHIDRA_INT((((local_28->_pos).y - 120.0) / 40.0 + 0.5)); if ((((iVar5 < 0) || (room->_gridWidth <= iVar5)) || (iVar4 < 0)) || (room->_gridHeight <= iVar4)) { seed = 0xffffffff; } else { seed = iVar4 * room->_gridWidth + iVar5; } iVar4 = GHIDRA_INT(((*GHIDRA_CAST((local_1c + 0x33c)) - 40.0) / 40.0 + 0.5)); iVar5 = GHIDRA_INT(((*GHIDRA_CAST((local_1c + 0x340)) - 120.0) / 40.0 + 0.5)); if (((iVar4 < 0) || (room->_gridWidth <= iVar4)) || ((iVar5 < 0 || (room->_gridHeight <= iVar5)))) { startIndex = 0xffffffff; } else { startIndex = iVar5 * room->_gridWidth + iVar4; } isCanStep = room_grid_flood_fill(&room->_railManager,startIndex,seed); if (isCanStep != 0) { if (*GHIDRA_CAST(pRVar6) != 0) { local_2c = pRVar6; msvc::multiset::erase(&local_2c); } *GHIDRA_CAST(pRVar6) = local_28; msvc::multiset::insert(pRVar6); if (*GHIDRA_CAST(local_20) != 0) { local_2c = local_20; msvc::multiset::erase(&local_2c); } *GHIDRA_CAST(local_20) = local_1c; msvc::multiset::insert(local_20); } } piVar7 = piVar7 + 1; } while (piVar7 < doorsEnd); } local_18 = GHIDRA_CAST((GHIDRA_INT(local_18) + 4)); piVar7 = GHIDRA_CAST(local_18); } while (local_18 < doorsEnd); } if (doorsEnd != GHIDRA_CAST(0x0)) { do { (**(code **)(*GHIDRA_CAST(*doors) + 0xc))(uVar2); doors = doors + 1; } while (doors < doorsEnd); } if (room->_doors[0] != (void *)0x0) { *GHIDRA_CAST((GHIDRA_INT(room->_doors[0]) + 0xf4)) = 0; } if (room->_doors[1] != (void *)0x0) { *GHIDRA_CAST((GHIDRA_INT(room->_doors[1]) + 0xf4)) = 0; } if (room->_doors[2] != (void *)0x0) { *GHIDRA_CAST((GHIDRA_INT(room->_doors[2]) + 0xf4)) = 0; } if (room->_doors[3] != (void *)0x0) { *GHIDRA_CAST((GHIDRA_INT(room->_doors[3]) + 0xf4)) = 0; } if (room->_doors[4] != (void *)0x0) { *GHIDRA_CAST((GHIDRA_INT(room->_doors[4]) + 0xf4)) = 0; } if (room->_doors[5] != (void *)0x0) { *GHIDRA_CAST((GHIDRA_INT(room->_doors[5]) + 0xf4)) = 0; } if (room->_doors[6] != (void *)0x0) { *GHIDRA_CAST((GHIDRA_INT(room->_doors[6]) + 0xf4)) = 0; } if (room->_doors[7] != (void *)0x0) { *GHIDRA_CAST((GHIDRA_INT(room->_doors[7]) + 0xf4)) = 0; } ExceptionList = local_10; return; } // 004b78f0 void NpcHelper::hornfel_remove_doors() { void *pvVar1; int *hornfelDoorIter; uint32_t uVar3; int *linkedIter; uint32_t seed; Entity *pEVar4; int *linkedIter; int *piVar6; int *local_70; int *local_64; Vector scratchVec; int *local_44; uint32_t local_40; uint32_t uStack_3c; uint32_t uStack_38; uint32_t uStack_34; uint32_t local_30; uint32_t uStack_2c; uint32_t uStack_28; uint32_t uStack_24; uint32_t local_20; uint32_t local_1c; uint32_t local_18; uint32_t local_14; void *local_10; uint8_t *puStack_c; uint32_t local_8; int *hornfelDoorIter; puStack_c = &LAB_00af33a5; local_10 = ExceptionList; uVar3 = __security_cookie ^ GHIDRA_INT(register0x00000010) - 4U; ExceptionList = &local_10; linkedIter = GHIDRA_CAST(0x0); local_64 = GHIDRA_CAST(0x0); pvVar1 = g_game->_room; piVar6 = GHIDRA_CAST(0x0); local_70 = GHIDRA_CAST(0x0); local_8 = 1; scratchVec.y = 0.0; local_14 = uVar3; if (*GHIDRA_CAST((GHIDRA_CAST(pvVar1) + 0x1264)) != 0) { do { local_44 = *GHIDRA_CAST((*GHIDRA_CAST((GHIDRA_CAST(pvVar1) + 0x125c)) + GHIDRA_INT(scratchVec.y) * 4)); if (local_44[10] == 0x3c7) { if (linkedIter == GHIDRA_CAST(0x0)) { msvc::vector::_Emplace_reallocate(0,&local_44); linkedIter = local_64; } else { *linkedIter = GHIDRA_INT(local_44); local_64 = linkedIter + 1; linkedIter = local_64; } } if (local_44[0xf5] != 0) { if (piVar6 == GHIDRA_CAST(0x0)) { msvc::vector::_Emplace_reallocate(0,&local_44); piVar6 = local_70; } else { *piVar6 = GHIDRA_INT(local_44); local_70 = piVar6 + 1; piVar6 = local_70; } } scratchVec.y = (float)(GHIDRA_INT(scratchVec.y) + 1); } while (GHIDRA_UINT(scratchVec.y) < GHIDRA_UINT(*GHIDRA_CAST((GHIDRA_CAST(pvVar1) + 0x1264)))); } local_44 = GHIDRA_CAST(0x0); linkedIter = GHIDRA_CAST(0x0); hornfelDoorIter = local_44; hornfelDoorIter = local_44; if (piVar6 != GHIDRA_CAST(0x0)) { do { seed = Random(); scratchVec.x = *GHIDRA_CAST((*linkedIter + 0x33c)); scratchVec.y = *GHIDRA_CAST((*linkedIter + 0x340)); Game::Spawn(g_game,1000,0xf,&scratchVec,&g_vectorZero,GHIDRA_CAST(0x0),0,seed); (**(code **)(*GHIDRA_CAST(*linkedIter) + 0x28))(uVar3); (**(code **)(**GHIDRA_CAST((*linkedIter + 0x3d4)) + 0x28))(); linkedIter = linkedIter + 1; hornfelDoorIter = local_44; hornfelDoorIter = local_44; } while (linkedIter != piVar6); } for (; piVar6 = local_44, hornfelDoorIter != linkedIter; hornfelDoorIter = hornfelDoorIter + 1) { local_40 = 0x3ecccccd; uStack_3c = 0x3ecccccd; uStack_38 = 0x3ecccccd; uStack_34 = 0x3f800000; local_20 = 0; local_30 = 0x3f800000; uStack_2c = 0x3f800000; uStack_28 = 0x3f800000; uStack_24 = 0x3f800000; local_1c = 0; local_18 = 0; local_44 = hornfelDoorIter; uVar3 = Random(); scratchVec.x = *GHIDRA_CAST((*hornfelDoorIter + 0x33c)); scratchVec.y = *GHIDRA_CAST((*hornfelDoorIter + 0x340)); pEVar4 = Game::Spawn(g_game,1000,0xf,&scratchVec,&g_vectorZero,GHIDRA_CAST(0x0),0,uVar3); (**(code **)(*GHIDRA_CAST(pEVar4) + 0x3c))(&local_40,0xffffffff,0xff,0,1); (**(code **)(*GHIDRA_CAST(*hornfelDoorIter) + 0x28))(); hornfelDoorIter = local_44; local_44 = piVar6; } if (*GHIDRA_CAST((GHIDRA_CAST(pvVar1) + 0x724)) != 0) { *GHIDRA_CAST((*GHIDRA_CAST((GHIDRA_CAST(pvVar1) + 0x724)) + 0xf4)) = 0x3f800000; } if (*GHIDRA_CAST((GHIDRA_CAST(pvVar1) + 0x728)) != 0) { *GHIDRA_CAST((*GHIDRA_CAST((GHIDRA_CAST(pvVar1) + 0x728)) + 0xf4)) = 0x3f800000; } if (*GHIDRA_CAST((GHIDRA_CAST(pvVar1) + 0x72c)) != 0) { *GHIDRA_CAST((*GHIDRA_CAST((GHIDRA_CAST(pvVar1) + 0x72c)) + 0xf4)) = 0x3f800000; } if (*GHIDRA_CAST((GHIDRA_CAST(pvVar1) + 0x730)) != 0) { *GHIDRA_CAST((*GHIDRA_CAST((GHIDRA_CAST(pvVar1) + 0x730)) + 0xf4)) = 0x3f800000; } if (*GHIDRA_CAST((GHIDRA_CAST(pvVar1) + 0x734)) != 0) { *GHIDRA_CAST((*GHIDRA_CAST((GHIDRA_CAST(pvVar1) + 0x734)) + 0xf4)) = 0x3f800000; } if (*GHIDRA_CAST((GHIDRA_CAST(pvVar1) + 0x738)) != 0) { *GHIDRA_CAST((*GHIDRA_CAST((GHIDRA_CAST(pvVar1) + 0x738)) + 0xf4)) = 0x3f800000; } if (*GHIDRA_CAST((GHIDRA_CAST(pvVar1) + 0x73c)) != 0) { *GHIDRA_CAST((*GHIDRA_CAST((GHIDRA_CAST(pvVar1) + 0x73c)) + 0xf4)) = 0x3f800000; } if (*GHIDRA_CAST((GHIDRA_CAST(pvVar1) + 0x740)) != 0) { *GHIDRA_CAST((*GHIDRA_CAST((GHIDRA_CAST(pvVar1) + 0x740)) + 0xf4)) = 0x3f800000; } if (local_44 != GHIDRA_CAST(0x0)) { uVar3 = -GHIDRA_INT(local_44) & 0xfffffffc; linkedIter = local_44; if (0xfff < uVar3) { linkedIter = GHIDRA_CAST(local_44[-1]); uVar3 = uVar3 + 0x23; if (0x1f < GHIDRA_UINT((GHIDRA_INT(local_44) + (-4 - GHIDRA_INT(linkedIter))))) { local_44 = hornfelDoorIter; /* WARNING: Subroutine does not return */ _invalid_parameter_noinfo_noreturn(); } } local_44 = hornfelDoorIter; operator_delete(linkedIter,uVar3); } ExceptionList = local_10; return; } // 004b7e30 void NpcHelper::hornfel_charge(Entity_NPC *npc) { char *animName; float cartVelocityX; float cartVelocityY; ANM2 *sprite; sprite = &npc->_sprite; cartVelocityX = *GHIDRA_CAST((npc->_minecart + 0x360)); cartVelocityY = *GHIDRA_CAST((npc->_minecart + 0x364)); if (npc->_state != 10) { if (ABS(cartVelocityY) < ABS(cartVelocityX)) { animName = "IdleLeft"; if (0.0 <= cartVelocityX) { animName = "IdleRight"; } ANM2::Play(sprite,GHIDRA_CAST(animName),0); return; } animName = "IdleUp"; if (0.0 <= cartVelocityY) { animName = "IdleDown"; } ANM2::Play(sprite,GHIDRA_CAST(animName),0); return; } if (ABS(cartVelocityY) < ABS(cartVelocityX)) { animName = "ChargeLeft"; if (0.0 <= cartVelocityX) { animName = "ChargeRight"; } ANM2::Play(sprite,GHIDRA_CAST(animName),0); return; } animName = "ChargeUp"; if (0.0 <= cartVelocityY) { animName = "ChargeDown"; } ANM2::Play(sprite,GHIDRA_CAST(animName),0); return; } // 004b7ee0 Entity * NpcHelper::hornfel_pick_spawn() { int *piVar1; uint32_t uVar2; RNG rng; uint32_t uVar3; Entity *spawned; Entity *in_ECX; void *freeBlock; uint32_t uVar4; BitSet128 BVar5; uint32_t *local_44; uint32_t rngSeed; uint64_t uStack_3c; uint32_t uStack_34; void *outcomes; uint32_t *outcomesEnd; uint32_t *outcomesCapacity; uint32_t securityCookie; uint8_t *puStack_20; void *local_1c; uint8_t *puStack_18; uint32_t local_14; int oldParent; uint32_t *parentRef; puStack_20 = GHIDRA_CAST((GHIDRA_INT(register0x00000010) + -4)); puStack_18 = &LAB_00af332d; local_1c = ExceptionList; securityCookie = __security_cookie ^ GHIDRA_INT(register0x00000010) - 0x10U; ExceptionList = &local_1c; outcomes = (void *)0x0; outcomesEnd = GHIDRA_CAST(0x0); outcomesCapacity = GHIDRA_CAST(0x0); local_14 = 0; uStack_3c = (uint64_t)GHIDRA_UINT(uStack_3c); uStack_34 = 6; msvc::vector<8byte>::_Emplace_reallocate(0,GHIDRA_INT(&uStack_3c) + 4); uVar3 = 0; uVar4 = GHIDRA_INT(outcomesEnd) - GHIDRA_INT(outcomes) >> 3; if (uVar4 != 0) { do { if (*GHIDRA_CAST((GHIDRA_CAST(outcomes) + uVar3 * 8)) == 8) { piVar1 = GHIDRA_CAST((GHIDRA_INT(outcomes) + uVar3 * 8 + 4)); *piVar1 = *piVar1 + 3; if (*piVar1 < 0) { *GHIDRA_CAST((GHIDRA_CAST(outcomes) + uVar3 * 8 + 4)) = 0; } goto LAB_004b7fc7; } uVar3 = uVar3 + 1; } while (uVar3 < uVar4); } uStack_3c = CONCAT44(8,GHIDRA_UINT(uStack_3c)); uStack_34 = 3; if (outcomesEnd == outcomesCapacity) { msvc::vector<8byte>::_Emplace_reallocate(outcomesEnd,GHIDRA_INT(&uStack_3c) + 4); } else { *outcomesEnd = 8; outcomesEnd[1] = 3; outcomesEnd = outcomesEnd + 2; } LAB_004b7fc7: uVar3 = 0; uVar4 = GHIDRA_INT(outcomesEnd) - GHIDRA_INT(outcomes) >> 3; if (uVar4 != 0) { do { if (*GHIDRA_CAST((GHIDRA_CAST(outcomes) + uVar3 * 8)) == 0x10) { piVar1 = GHIDRA_CAST((GHIDRA_INT(outcomes) + uVar3 * 8 + 4)); *piVar1 = *piVar1 + 1; if (*piVar1 < 0) { *GHIDRA_CAST((GHIDRA_CAST(outcomes) + uVar3 * 8 + 4)) = 0; } goto LAB_004b8025; } uVar3 = uVar3 + 1; } while (uVar3 < uVar4); } uStack_3c = CONCAT44(0x10,GHIDRA_UINT(uStack_3c)); uStack_34 = 1; if (outcomesEnd == outcomesCapacity) { msvc::vector<8byte>::_Emplace_reallocate(outcomesEnd,GHIDRA_INT(&uStack_3c) + 4); } else { *outcomesEnd = 0x10; outcomesEnd[1] = 1; outcomesEnd = outcomesEnd + 2; } LAB_004b8025: rngSeed = Random(); rngSeed = rngSeed | 1; uStack_3c = 0x900000005; uStack_34 = 7; rng._shift1 = 5; rng._seed = rngSeed; rng._shift2 = 9; rng._shift3 = 7; uVar3 = WeightedOutcomePicker::PickOutcome(GHIDRA_CAST(&outcomes),rng); local_14 = 0xffffffff; uStack_34 = uVar3; if (outcomes != (void *)0x0) { uVar4 = GHIDRA_INT(outcomesCapacity) - GHIDRA_INT(outcomes) & 0xfffffff8; freeBlock = outcomes; if (0xfff < uVar4) { freeBlock = *(void **)(GHIDRA_CAST(outcomes) + -4); uVar4 = uVar4 + 0x23; if (0x1f < GHIDRA_UINT((GHIDRA_INT(outcomes) + (-4 - GHIDRA_INT(freeBlock))))) { /* WARNING: Subroutine does not return */ _invalid_parameter_noinfo_noreturn(); } } operator_delete(freeBlock,uVar4); } uVar4 = Random(); spawned = Game::Spawn(g_game,4,uVar3,&in_ECX->_pos,&g_vectorZero,in_ECX,0,uVar4); oldParent = spawned->_parent; parentRef = &spawned->_parent; spawned->_visible = 0; spawned->_entityCollisionClass = 0; spawned->_entityGridCollisionClass = 0; *GHIDRA_CAST((spawned + 1)) = 0x23; *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST(&(spawned[1])) + 0x4)))) = 0x23; if (oldParent != 0) { local_44 = parentRef; msvc::multiset::erase(&local_44); } *parentRef = in_ECX; if (in_ECX != GHIDRA_CAST(0x0)) { msvc::multiset::insert(parentRef); } if (uStack_34 == 8) { BVar5 = g_tearFlagBurn; } else { if (uStack_34 != 0x10) goto LAB_004b814e; BVar5 = g_tearFlagSadBomb; } spawned[1]._sprite._filename._buf[0xb] = '\x01'; *GHIDRA_CAST(&spawned[1]._type) = BVar5; LAB_004b814e: uVar2 = *GHIDRA_CAST((GHIDRA_INT(&spawned->_flags) + 4)); *GHIDRA_CAST(&spawned->_flags) = GHIDRA_UINT(spawned->_flags) | 0x20; *GHIDRA_CAST((GHIDRA_INT(&spawned->_flags) + 4)) = uVar2; ExceptionList = local_1c; return spawned; } // 004b8190 void NpcHelper::hornfel_minecart(Entity_NPC *npc) { uint32_t uVar1; uint32_t uVar2; int iVar3; int iVar4; Entity_NPC *pEVar5; Vector *velocity; int *piVar6; Entity_Player *player; uint32_t rngResult; Entity *spawned; char *ptr; int iVar7; int *remaining; float fVar8; uint32_t *puVar9; float deltaX; Vector railDirOut; Vector local_60; Vector local_58; Vector local_50; Entity_NPC *local_48; int *local_44; uint32_t *local_40; std_string anm2Path; uint32_t local_24; uint8_t *puStack_20; void *local_1c; uint8_t *puStack_18; uint32_t local_14; ANM2 *minecartSprite; void *room; puStack_20 = GHIDRA_CAST((GHIDRA_INT(register0x00000010) + -4)); local_14 = 0xffffffff; puStack_18 = &LAB_00af33dd; local_1c = ExceptionList; local_24 = __security_cookie ^ GHIDRA_INT(register0x00000010) - 0x10U; ExceptionList = &local_1c; local_48 = npc; if (npc->_state == 7) { pEVar5 = GHIDRA_CAST(npc->_entityRef); local_60.y = (float)pEVar5; if (pEVar5 != GHIDRA_CAST(0x0)) { local_40 = &npc->_entityRef; puStack_20 = GHIDRA_CAST((GHIDRA_INT(register0x00000010) + -4)); msvc::multiset::erase(&local_40); npc->_entityRef = 0; goto LAB_004b8213; } } local_60.y = (float)hornfel_free_door(); local_50.y = (float)g_game->_room; local_58.y = 0.0; if ((GHIDRA_CAST((GHIDRA_INT(local_50.y) + 0xf60)))->_brimstoneMarkCountdown != 0) { do { iVar7 = *GHIDRA_CAST(((GHIDRA_CAST((GHIDRA_INT(local_50.y) + 0xf60)))->_weaknessCountdown + GHIDRA_INT(local_58.y) * 4)); if (*GHIDRA_CAST((iVar7 + 0x28)) == 0x3c7) { if (*GHIDRA_CAST((iVar7 + 0x3c4)) == npc) { if (*GHIDRA_CAST((iVar7 + 0x3c4)) == GHIDRA_CAST(0x0)) { if ((*GHIDRA_CAST((iVar7 + 0x3bc)) == 0) || (*GHIDRA_CAST((*GHIDRA_CAST((iVar7 + 0x3bc)) + 0x3c4)) == 0)) goto LAB_004b8675; } else { local_40 = GHIDRA_CAST((iVar7 + 0x3c4)); msvc::multiset::erase(&local_40); } iVar3 = *GHIDRA_CAST((iVar7 + 0x3bc)); *GHIDRA_CAST((iVar7 + 0x3c4)) = 0; if (iVar3 != 0) { if (*GHIDRA_CAST((iVar3 + 0x3c4)) != 0) { local_40 = GHIDRA_CAST((iVar3 + 0x3c4)); msvc::multiset::erase(&local_40); } *GHIDRA_CAST((iVar3 + 0x3c4)) = 0; } } } LAB_004b8675: local_58.y = (float)(GHIDRA_INT(local_58.y) + 1); } while (GHIDRA_UINT(local_58.y) < GHIDRA_UINT((GHIDRA_CAST((GHIDRA_INT(local_50.y) + 0xf60)))->_brimstoneMarkCountdown)); } pEVar5 = GHIDRA_CAST(local_60.y); if (GHIDRA_CAST(local_60.y) == GHIDRA_CAST(0x0)) { KAGE_LogMessage(4,GHIDRA_CAST("no doors to enter from!\n")); *GHIDRA_CAST(&npc->_stateFrame) = 0xf; ExceptionList = local_1c; return; } LAB_004b8213: hornfel_get_rail_direction(pEVar5,&local_50); if ((local_50.x == g_vectorZero.x) && (local_50.y == g_vectorZero.y)) { KAGE_LogMessage(0x10,GHIDRA_CAST("exit velocity is zero\n")); } if ((local_50.x != g_vectorZero.x) || (local_50.y != g_vectorZero.y)) { npc->_visible = 1; npc->_entityCollisionClass = 4; npc->_shadowSize = *GHIDRA_CAST((GHIDRA_CAST(npc->_config) + 0x24)); local_58.y = (float)npc->_minecart; if (GHIDRA_CAST(local_58.y) != GHIDRA_CAST(0x0)) { FUN_004cf0f0(1); Entity_NPC::SetMinecartPosVel(GHIDRA_CAST(local_58.y),&pEVar5->_targetPosition,&local_50); fVar8 = (GHIDRA_CAST((GHIDRA_INT(local_58.y) + 0x33c)))->y; (npc->_pos).x = (GHIDRA_CAST((GHIDRA_INT(local_58.y) + 0x33c)))->x; (npc->_pos).y = fVar8; hornfel_claim_target(pEVar5,GHIDRA_CAST(npc)); local_40 = GHIDRA_CAST(npc->_parent); if (npc->_state == 6) { if (*GHIDRA_CAST((GHIDRA_INT(&npc->_projectileCooldown) + 1)) == '\0') { uVar2 = Random(); if (((uVar2 & 7) == 0) && ((local_40 == GHIDRA_CAST(0x0) || (4 < GHIDRA_INT(local_40[0x117]))))) { room = g_game->_room; iVar3 = *GHIDRA_CAST((GHIDRA_CAST(room) + 0x12c0)) + *GHIDRA_CAST((GHIDRA_CAST(room) + 0x12c4)); iVar7 = 0; if (0 < iVar3) { iVar7 = iVar3; } iVar4 = *GHIDRA_CAST((GHIDRA_CAST(room) + 0x12c8)) + *GHIDRA_CAST((GHIDRA_CAST(room) + 0x12cc)); iVar3 = 0; if (0 < iVar4) { iVar3 = iVar4; } if ((iVar7 - iVar3 < 2) && (spawned = hornfel_free_door(), spawned != GHIDRA_CAST(0x0))) { local_58.y = 0.0; local_44 = GHIDRA_CAST(((0x87 < *GHIDRA_CAST((GHIDRA_CAST(g_game->_room) + 0x10)) * *GHIDRA_CAST((GHIDRA_CAST(g_game->_room) + 0xc))) + 2)); do { local_60.y = (float)hornfel_free_door(); if (GHIDRA_CAST(local_60.y) == GHIDRA_CAST(0x0)) break; uVar2 = Random(); pEVar5 = (Entity_NPC *) Game::Spawn(g_game,0x38a,1,&g_vectorZero,&g_vectorZero,GHIDRA_CAST(npc),0, uVar2); uVar1 = *GHIDRA_CAST((GHIDRA_INT(&pEVar5->_flags) + 4)); iVar7 = *GHIDRA_CAST(pEVar5); *GHIDRA_CAST(&pEVar5->_flags) = GHIDRA_UINT(pEVar5->_flags) & 0xfffffffb; *GHIDRA_CAST((GHIDRA_INT(&pEVar5->_flags) + 4)) = uVar1; local_48 = pEVar5; (**(code **)(iVar7 + 0xc))(); velocity = hornfel_get_rail_direction(GHIDRA_CAST(local_60.y),&railDirOut); local_50.y = (float)Entity::GiveMinecart (GHIDRA_CAST(pEVar5),GHIDRA_CAST((GHIDRA_INT(local_60.y) + 0x334)), velocity); anm2Path._size = 0; minecartSprite = &(GHIDRA_CAST(local_50.y))->_sprite; anm2Path._capacity = 0xf; anm2Path._buf[0] = '\0'; anm2Path._buf[1] = '\0'; anm2Path._buf[2] = '\0'; anm2Path._buf[3] = '\0'; (*GHIDRA_CAST((GHIDRA_CAST(&(anm2Path._buf)) + 0x0))) = msvc::_Allocate(0x30); anm2Path._size = 0x21; anm2Path._capacity = 0x2f; builtin_strncpy((*GHIDRA_CAST((GHIDRA_CAST(&(GHIDRA_CAST(anm2Path._buf))) + 0x0))),"gfx/965.001_hornfel minecart.anm2",0x22 ); local_14 = 0; ANM2::Load(minecartSprite,&anm2Path,1); local_14 = 0xffffffff; if (0xf < anm2Path._capacity) { uVar2 = anm2Path._capacity + 1; ptr = (*GHIDRA_CAST((GHIDRA_CAST(&(GHIDRA_CAST(anm2Path._buf))) + 0x0))); if (0xfff < uVar2) { ptr = *GHIDRA_CAST(((*GHIDRA_CAST((GHIDRA_CAST(&(anm2Path._buf)) + 0x0))) + -4)); uVar2 = anm2Path._capacity + 0x24; if (GHIDRA_CAST(0x1f) < GHIDRA_CAST(((*GHIDRA_CAST((GHIDRA_CAST(&(anm2Path._buf)) + 0x0))) + (-4 - GHIDRA_INT(ptr))))) { /* WARNING: Subroutine does not return */ _invalid_parameter_noinfo_noreturn(); } } operator_delete(ptr,uVar2); } (**(code **)(*GHIDRA_CAST(local_50.y) + 0xc))(); pEVar5 = local_48; if ((*GHIDRA_CAST((GHIDRA_CAST(local_60.y) + 0x3c4)) == 0) && ((*GHIDRA_CAST((GHIDRA_CAST(local_60.y) + 0x3bc)) == 0 || (*GHIDRA_CAST((*GHIDRA_CAST((GHIDRA_CAST(local_60.y) + 0x3bc)) + 0x3c4)) == 0)))) { *GHIDRA_CAST((GHIDRA_CAST(local_60.y) + 0x3c4)) = local_48; msvc::multiset::insert(GHIDRA_CAST((GHIDRA_INT(local_60.y) + 0x3c4))); iVar7 = *GHIDRA_CAST((GHIDRA_CAST(local_60.y) + 0x3bc)); if (iVar7 != 0) { local_50.y = (float)(iVar7 + 0x3c4); if (*GHIDRA_CAST((iVar7 + 0x3c4)) != 0) { local_48 = GHIDRA_CAST(local_50.y); msvc::multiset::erase(&local_48); } *GHIDRA_CAST(local_50.y) = pEVar5; msvc::multiset::insert(local_50.y); } } local_58.y = (float)(GHIDRA_INT(local_58.y) + 1); } while (GHIDRA_INT(local_58.y) < GHIDRA_INT(local_44)); npc->_state = 0xe; uVar2 = Random(); *GHIDRA_CAST((GHIDRA_INT(&npc->_projectileCooldown) + 1)) = 100; *GHIDRA_CAST(&npc->_projectileDelay) = (short)(uVar2 % 0x1e) + 0x1e; if (local_40 == GHIDRA_CAST(0x0)) { ExceptionList = local_1c; return; } if (GHIDRA_INT(local_40[0x117]) < 0x96) { local_40[0x117] = 0x96; local_40[0x118] = 0x96; ExceptionList = local_1c; return; } ExceptionList = local_1c; return; } pEVar5 = GHIDRA_CAST(local_60.y); } } if ((((npc->_state == 6) && (*GHIDRA_CAST((GHIDRA_INT(&npc->_projectileCooldown) + 2)) == '\0')) && (uVar2 = Random(), (uVar2 & 7) == 0)) && ((GHIDRA_CAST(pEVar5->_parent) != GHIDRA_CAST(0x0) && (GHIDRA_CAST(pEVar5->_parent) != pEVar5)))) { npc->_state = 10; (GHIDRA_CAST((GHIDRA_INT(local_58.y) + 3000)))->x = 0.1; if (npc->_entityRef != 0) { local_44 = &npc->_entityRef; msvc::multiset::erase(&local_44); } npc->_entityRef = pEVar5; msvc::multiset::insert(&npc->_entityRef); *GHIDRA_CAST((GHIDRA_INT(&npc->_projectileCooldown) + 2)) = 100; uVar2 = Random(); *GHIDRA_CAST((GHIDRA_INT(&npc->_projectileDelay) + 2)) = (char)(uVar2 % 3) + '\x06'; ExceptionList = local_1c; return; } } if (npc->_state == 7) { npc->_state = 0xb; } else { npc->_state = 3; uVar2 = Random(); *GHIDRA_CAST(&npc->_projectileDelay) = (short)(uVar2 % 0xf) + 0xf; uVar2 = Random(); if (uVar2 % 3 == 0) { local_44 = *GHIDRA_CAST((GHIDRA_CAST(g_game->_room) + 0x1264)); if (local_44 != GHIDRA_CAST(0x0)) { piVar6 = *GHIDRA_CAST((GHIDRA_CAST(g_game->_room) + 0x125c)); uVar2 = 0; remaining = local_44; do { iVar7 = *GHIDRA_CAST((*piVar6 + 0x28)); if ((iVar7 == 0x333) || ((iVar7 == 4 && (*GHIDRA_CAST((*piVar6 + 0x2c)) == 0xe)))) { uVar2 = uVar2 + 1; } piVar6 = piVar6 + 1; remaining = GHIDRA_CAST((GHIDRA_INT(remaining) + -1)); } while (remaining != GHIDRA_CAST(0x0)); npc = local_48; if (3 < uVar2) { ExceptionList = local_1c; return; } } uVar2 = 0; local_40 = GHIDRA_CAST(0x7149f2ca); if (GHIDRA_INT((g_game->_playerManager)._playerList._end) - GHIDRA_INT((g_game->_playerManager)._playerList._begin) >> 2 != 0) { do { player = Game::GetPlayer(g_game,uVar2); uVar2 = uVar2 + 1; fVar8 = (npc->_pos).y - (player->_pos).y; deltaX = (npc->_pos).x - (player->_pos).x; puVar9 = GHIDRA_CAST((fVar8 * fVar8 + deltaX * deltaX)); if ((float)local_40 <= (float)puVar9) { puVar9 = local_40; } local_40 = puVar9; } while (uVar2 < GHIDRA_UINT((GHIDRA_INT((g_game->_playerManager)._playerList._end) - GHIDRA_INT((g_game->_playerManager)._playerList._begin) >> 2))); if ((float)puVar9 <= 57600.0) { ExceptionList = local_1c; return; } } local_40 = GHIDRA_CAST(0x2); do { uVar2 = Random(); rngResult = Random(); local_44 = GHIDRA_CAST((((float)((double)GHIDRA_INT(rngResult) + __uint_to_double_fixup[-(GHIDRA_INT(rngResult) >> 0x1f)]) * 2.3283064e-10 * 40.0 - 20.0) * 0.017453292)); local_48 = GHIDRA_CAST(cos((float)local_44)); fVar8 = sin((float)local_44); local_58.x = local_50.x * (float)local_48 - local_50.y * fVar8; local_58.y = local_50.y * (float)local_48 + local_50.x * fVar8; rngResult = Random(); fVar8 = (float)((double)GHIDRA_INT(rngResult) + __uint_to_double_fixup[-(GHIDRA_INT(rngResult) >> 0x1f)]) * 2.3283064e-10 * 3.14 ; local_44 = GHIDRA_CAST((fVar8 + fVar8)); fVar8 = cos((float)local_44); local_60.x = fVar8 * 6.0 + (npc->_pos).x; fVar8 = sin((float)local_44); local_60.y = fVar8 * 6.0 + (npc->_pos).y; spawned = Game::Spawn(g_game,0x333,0,&local_60,&local_58,GHIDRA_CAST(npc),0,uVar2); if (spawned->_parent != 0) { local_44 = &spawned->_parent; msvc::multiset::erase(&local_44); } spawned->_parent = npc; msvc::multiset::insert(&spawned->_parent); *GHIDRA_CAST(&spawned->_flags) = GHIDRA_UINT(spawned->_flags) & 0xfffffffb; local_40 = GHIDRA_CAST((GHIDRA_INT(local_40) + -1)); *GHIDRA_CAST((GHIDRA_INT(&spawned->_flags) + 4)) = *GHIDRA_CAST((GHIDRA_INT(&spawned->_flags) + 4)); } while (local_40 != GHIDRA_CAST(0x0)); } } } } ExceptionList = local_1c; return; } // 004b8a30 void NpcHelper::hornfel_ride_minecart(Entity_NPC *linkedNpc) { char *pcVar1; uint64_t qVar2; float *pfVar3; int flyBombData; float fVar4; uint64_t *allocatedBytes; uint32_t uVar5; float fVar6; EntityList_EL flyBombs; Vector scratchVec; uint32_t *local_14; void *local_10; uint8_t *puStack_c; uint32_t uStack_8; Game *game; Entity_NPC *linkedNpc; Entity_NPC *minecart; uint32_t *parentRef; uStack_8 = 0xffffffff; puStack_c = &LAB_00af341d; local_10 = ExceptionList; minecart = GHIDRA_CAST(linkedNpc->_minecart); if ((linkedNpc->_state == 10) && (linkedNpc = GHIDRA_CAST(linkedNpc->_entityRef), linkedNpc != GHIDRA_CAST(0x0))) { if ('\0' < *GHIDRA_CAST((GHIDRA_INT(&linkedNpc->_projectileDelay) + 2))) { ExceptionList = &local_10; hornfel_get_rail_direction(linkedNpc,&scratchVec); Entity_NPC::SetMinecartPosVel(minecart,&linkedNpc->_targetPosition,&scratchVec); fVar4 = (minecart->_pos).x; fVar6 = (minecart->_pos).y; pcVar1 = GHIDRA_CAST((GHIDRA_INT(&linkedNpc->_projectileDelay) + 2)); *pcVar1 = *pcVar1 + -1; (linkedNpc->_pos).x = fVar4; (linkedNpc->_pos).y = fVar6; ExceptionList = local_10; return; } linkedNpc->_state = 7; linkedNpc->_visible = 0; linkedNpc->_entityCollisionClass = 0; *GHIDRA_CAST(&linkedNpc->_stateFrame) = 1; (linkedNpc->_targetPosition).x = (linkedNpc->_pos).x; (linkedNpc->_targetPosition).y = (linkedNpc->_pos).y; linkedNpc->_shadowSize = 0.0; fVar4 = (minecart->_v2).x; fVar6 = 6.0; if (fVar4 <= 6.0) { fVar6 = fVar4; } minecart->_shadowSize = 0.0; (minecart->_v2).x = fVar6; return; } ExceptionList = &local_10; linkedNpc->_state = 6; *GHIDRA_CAST(&linkedNpc->_stateFrame) = 0x2d; linkedNpc->_visible = 0; linkedNpc->_entityCollisionClass = 0; (linkedNpc->_targetPosition).x = (linkedNpc->_pos).x; (linkedNpc->_targetPosition).y = (linkedNpc->_pos).y; game = g_game; linkedNpc->_shadowSize = 0.0; minecart->_shadowSize = 0.0; EntityList::QuerySublist(GHIDRA_CAST((GHIDRA_INT(game->_room) + 0x1218)),&flyBombs,0x333,-1,-1,0,0); uVar5 = 0; if (flyBombs._size != 0) { flyBombData = (*GHIDRA_CAST((GHIDRA_CAST(&(flyBombs)) + 0x4))); do { scratchVec.y = *GHIDRA_CAST((flyBombData + uVar5 * 4)); parentRef = GHIDRA_CAST((GHIDRA_INT(scratchVec.y) + 0x3bc)); if (*GHIDRA_CAST((GHIDRA_CAST(scratchVec.y) + 0x3bc)) == linkedNpc) { fVar4 = scratchVec.y; if (*GHIDRA_CAST((GHIDRA_CAST(scratchVec.y) + 0x3bc)) != GHIDRA_CAST(0x0)) { local_14 = parentRef; msvc::multiset::erase(&local_14); fVar4 = scratchVec.y; } local_14 = *GHIDRA_CAST((GHIDRA_CAST(fVar4) + 0x380)); scratchVec.y = 3.5; *parentRef = 0; pfVar3 = &scratchVec.y; if ((float)local_14 <= 3.5) { pfVar3 = GHIDRA_CAST(&local_14); } *GHIDRA_CAST((GHIDRA_CAST(fVar4) + 0x380)) = *pfVar3; flyBombData = (*GHIDRA_CAST((GHIDRA_CAST(&(flyBombs)) + 0x4))); } uVar5 = uVar5 + 1; } while (uVar5 < GHIDRA_UINT(flyBombs._size)); } if ((*GHIDRA_CAST((GHIDRA_CAST(&(flyBombs)) + 0x0))) == '\0') { if (g_mainHeap == (void *)0x0) { allocatedBytes = &g_allocatedBytesNoHeap; } else { allocatedBytes = GHIDRA_CAST((GHIDRA_INT(g_mainHeap) + 0x30)); } if ((*GHIDRA_CAST((GHIDRA_CAST(&(flyBombs)) + 0x4))) != 0) { uVar5 = *GHIDRA_CAST(((*GHIDRA_CAST((GHIDRA_CAST(&(flyBombs)) + 0x4))) + -4)); qVar2 = *allocatedBytes; *GHIDRA_CAST(allocatedBytes) = GHIDRA_UINT(*allocatedBytes) - uVar5; *GHIDRA_CAST((GHIDRA_CAST(allocatedBytes) + 4)) = *GHIDRA_CAST((GHIDRA_CAST(allocatedBytes) + 4)) - GHIDRA_UINT((GHIDRA_UINT(qVar2) < uVar5)); free(GHIDRA_CAST(((*GHIDRA_CAST((GHIDRA_CAST(&(flyBombs)) + 0x4))) + -4))); } } ExceptionList = local_10; return; } // 004b8ca0 void NpcHelper::hornfel_attack(Entity_NPC *npc) { RNG rng; uint32_t uVar1; Entity *target; uint32_t extraout_ECX; uint32_t extraout_ECX_00; uint32_t extraout_ECX_01; uint32_t uVar2; void *ptr; uint32_t uVar3; float targetDist; uint64_t uStack_48; float fStack_40; float targetDirY; void *picker; uint32_t *outcomesEnd; uint32_t *outcomesCapacity; float *local_2c; uint32_t *local_28; uint32_t local_24; uint8_t *puStack_20; void *local_1c; uint8_t *puStack_18; uint32_t local_14; char *animName; float *childSlot; int dequeBlock; uint32_t *firstChildSlot; int *outcomeWeight; puStack_20 = GHIDRA_CAST((GHIDRA_INT(register0x00000010) + -4)); puStack_18 = &LAB_00af344d; local_1c = ExceptionList; local_24 = __security_cookie ^ GHIDRA_INT(register0x00000010) - 0x10U; ExceptionList = &local_1c; picker = (void *)0x0; outcomesEnd = GHIDRA_CAST(0x0); outcomesCapacity = GHIDRA_CAST(0x0); local_14 = 0; uStack_48 = (uint64_t)GHIDRA_UINT(uStack_48); fStack_40 = 4.2039e-45; msvc::vector<8byte>::_Emplace_reallocate(0,GHIDRA_INT(&uStack_48) + 4); uVar1 = 0; uVar3 = GHIDRA_INT(outcomesEnd) - GHIDRA_INT(picker) >> 3; if (uVar3 != 0) { do { if (*GHIDRA_CAST((GHIDRA_CAST(picker) + uVar1 * 8)) == 1) { outcomeWeight = GHIDRA_CAST((GHIDRA_INT(picker) + uVar1 * 8 + 4)); *outcomeWeight = *outcomeWeight + 1; if (*outcomeWeight < 0) { *GHIDRA_CAST((GHIDRA_CAST(picker) + uVar1 * 8 + 4)) = 0; } goto LAB_004b8d87; } uVar1 = uVar1 + 1; } while (uVar1 < uVar3); } uStack_48 = CONCAT44(1,GHIDRA_UINT(uStack_48)); fStack_40 = 1.4013e-45; if (outcomesEnd == outcomesCapacity) { msvc::vector<8byte>::_Emplace_reallocate(outcomesEnd,GHIDRA_INT(&uStack_48) + 4); } else { *outcomesEnd = 1; outcomesEnd[1] = 1; outcomesEnd = outcomesEnd + 2; } LAB_004b8d87: if ((char)npc->_projectileCooldown == '\0') { uVar1 = 0; uVar3 = GHIDRA_INT(outcomesEnd) - GHIDRA_INT(picker) >> 3; if (uVar3 != 0) { do { if (*GHIDRA_CAST((GHIDRA_CAST(picker) + uVar1 * 8)) == 2) { outcomeWeight = GHIDRA_CAST((GHIDRA_INT(picker) + uVar1 * 8 + 4)); *outcomeWeight = *outcomeWeight + 1; if (*outcomeWeight < 0) { *GHIDRA_CAST((GHIDRA_CAST(picker) + uVar1 * 8 + 4)) = 0; } goto LAB_004b8df1; } uVar1 = uVar1 + 1; } while (uVar1 < uVar3); } uStack_48 = CONCAT44(2,GHIDRA_UINT(uStack_48)); fStack_40 = 1.4013e-45; if (outcomesEnd == outcomesCapacity) { msvc::vector<8byte>::_Emplace_reallocate(outcomesEnd,GHIDRA_INT(&uStack_48) + 4); } else { *outcomesEnd = 2; outcomesEnd[1] = 1; outcomesEnd = outcomesEnd + 2; } } LAB_004b8df1: uVar1 = Random(); uStack_48 = 0x900000005; fStack_40 = 9.80909e-45; rng._shift1 = 5; rng._seed = uVar1 | 1; rng._shift2 = 9; rng._shift3 = 7; uVar1 = WeightedOutcomePicker::PickOutcome(GHIDRA_CAST(&picker),rng); target = Entity_NPC::GetPlayerTarget(npc); local_28 = GHIDRA_CAST(((target->_pos).x - (npc->_pos).x)); targetDirY = (target->_pos).y - (npc->_pos).y; targetDist = sqrtf((float)local_28 * (float)local_28 + targetDirY * targetDirY); if (0.0 < targetDist) { local_28 = GHIDRA_CAST(((float)local_28 * (1.0 / targetDist))); targetDirY = targetDirY * (1.0 / targetDist); } *GHIDRA_CAST((GHIDRA_INT(&npc->_projectileDelay) + 3)) = 1; if (uVar1 == 0) { fStack_40 = (float)hornfel_pick_spawn(extraout_ECX); uVar1 = (npc->_entityDeque)._offset; uVar3 = uVar1 & 3; dequeBlock = *GHIDRA_CAST((GHIDRA_INT((npc->_entityDeque)._map) + ((npc->_entityDeque)._mapSize - 1 & uVar1 >> 2) * 4)); childSlot = GHIDRA_CAST((dequeBlock + uVar3 * 4)); if (*GHIDRA_CAST((dequeBlock + uVar3 * 4)) != 0) { local_2c = childSlot; msvc::multiset::erase(&local_2c); } *childSlot = fStack_40; if (fStack_40 != 0.0) { msvc::multiset::insert(childSlot); } if (-0.2 <= targetDirY) { if (0.0 <= (float)local_28) { animName = "Attack1Right"; } else { animName = "Attack1Left"; } LAB_004b9068: ANM2::Play(&npc->_sprite,GHIDRA_CAST(animName),0); } else { animName = "Attack1Left_Back"; if (0.0 <= (float)local_28) { animName = "Attack1Right_Back"; } ANM2::Play(&npc->_sprite,GHIDRA_CAST(animName),0); *GHIDRA_CAST((GHIDRA_INT(&npc->_projectileDelay) + 3)) = 0; } } else { if (uVar1 != 1) { if (uVar1 == 2) { ANM2::Play(&npc->_sprite,s_Attack2,0); npc->_state = 9; *GHIDRA_CAST(&npc->_projectileCooldown) = 0x96; } goto LAB_004b9077; } local_2c = GHIDRA_CAST(hornfel_pick_spawn(extraout_ECX)); uVar1 = (npc->_entityDeque)._offset; uVar3 = uVar1 & 3; dequeBlock = *GHIDRA_CAST((GHIDRA_INT((npc->_entityDeque)._map) + ((npc->_entityDeque)._mapSize - 1 & uVar1 >> 2) * 4)); firstChildSlot = GHIDRA_CAST((dequeBlock + uVar3 * 4)); uVar2 = 0; if (*GHIDRA_CAST((dequeBlock + uVar3 * 4)) != 0) { local_28 = firstChildSlot; msvc::multiset::erase(&local_28); uVar2 = extraout_ECX_00; } *firstChildSlot = local_2c; if (local_2c != GHIDRA_CAST(0x0)) { msvc::multiset::insert(firstChildSlot); uVar2 = extraout_ECX_01; } local_28 = GHIDRA_CAST(hornfel_pick_spawn(uVar2)); uVar1 = (npc->_entityDeque)._offset + 1; uVar3 = uVar1 & 3; dequeBlock = *GHIDRA_CAST((GHIDRA_INT((npc->_entityDeque)._map) + ((npc->_entityDeque)._mapSize - 1 & uVar1 >> 2) * 4)); childSlot = GHIDRA_CAST((dequeBlock + uVar3 * 4)); if (*GHIDRA_CAST((dequeBlock + uVar3 * 4)) != 0) { local_2c = childSlot; msvc::multiset::erase(&local_2c); } *childSlot = (float)local_28; if (local_28 != GHIDRA_CAST(0x0)) { msvc::multiset::insert(childSlot); } if (-0.2 <= targetDirY) { animName = "Attack1Double"; goto LAB_004b9068; } ANM2::Play(&npc->_sprite,GHIDRA_CAST("Attack1Double_Back"),0); *GHIDRA_CAST((GHIDRA_INT(&npc->_projectileDelay) + 3)) = 0; } npc->_state = 8; LAB_004b9077: *GHIDRA_CAST((GHIDRA_INT(&npc->_projectileDelay) + 2)) = 0; if (picker != (void *)0x0) { uVar1 = GHIDRA_INT(outcomesCapacity) - GHIDRA_INT(picker) & 0xfffffff8; ptr = picker; if (0xfff < uVar1) { ptr = *(void **)(GHIDRA_CAST(picker) + -4); uVar1 = uVar1 + 0x23; if (0x1f < GHIDRA_UINT((GHIDRA_INT(picker) + (-4 - GHIDRA_INT(ptr))))) { /* WARNING: Subroutine does not return */ _invalid_parameter_noinfo_noreturn(); } } operator_delete(ptr,uVar1); } ExceptionList = local_1c; return; } // 004b90e0 void NpcHelper::hornfel_launch_toward(Entity_NPC *npc, Entity *entity, Vector *targetPos) { int iVar1; Entity *pEVar2; float deltaX; float fVar3; float launchSpeed; float npcPosY; uint32_t *refSlot; fVar3 = targetPos->y; deltaX = (npc->_pos).x - targetPos->x; npcPosY = (npc->_pos).y - fVar3; targetPos = GHIDRA_CAST(targetPos->x); npcPosY = sqrtf(npcPosY * npcPosY + deltaX * deltaX); pEVar2 = entity; npcPosY = (npcPosY - 100.0) / 200.0; if (npcPosY <= 0.0) { npcPosY = 0.0; } if (1.0 <= npcPosY) { npcPosY = 1.0; } launchSpeed = npcPosY * 18.0 + 10.0; if (entity->_variant == 8) { launchSpeed = launchSpeed * 0.75; } fVar3 = fVar3 - (npc->_pos).y; targetPos = GHIDRA_CAST(((float)targetPos - (npc->_pos).x)); npcPosY = sqrtf(fVar3 * fVar3 + (float)targetPos * (float)targetPos); if (0.0 < npcPosY) { targetPos = GHIDRA_CAST(((float)targetPos * (1.0 / npcPosY))); fVar3 = fVar3 * (1.0 / npcPosY); } targetPos = GHIDRA_CAST(((float)targetPos * launchSpeed)); refSlot = &pEVar2->_spawnerEntity; if (*refSlot != 0) { entity = GHIDRA_CAST(refSlot); msvc::multiset::erase(&entity); } *refSlot = npc; if (npc != GHIDRA_CAST(0x0)) { msvc::multiset::insert(refSlot); } refSlot = &pEVar2->_parent; pEVar2->_spawnerType = npc->_type; pEVar2->_spawnerVariant = npc->_variant; if (*refSlot != 0) { entity = GHIDRA_CAST(refSlot); msvc::multiset::erase(&entity); } *refSlot = npc; msvc::multiset::insert(refSlot); pEVar2->_entityCollisionClass = 4; pEVar2->_visible = 1; *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST(&(pEVar2[1])) + 0xc)))) = 0xc0800000; (pEVar2->_posOffset).x = 0.0; (pEVar2->_posOffset).y = -24.0; (pEVar2->_pos).x = (npc->_pos).x; npcPosY = (npc->_pos).y; *GHIDRA_CAST(&pEVar2->_flags) = GHIDRA_UINT(pEVar2->_flags) & 0xffffffdf; (pEVar2->_pos).y = npcPosY; *GHIDRA_CAST((GHIDRA_INT(&pEVar2->_flags) + 4)) = *GHIDRA_CAST((GHIDRA_INT(&pEVar2->_flags) + 4)); iVar1 = *GHIDRA_CAST(pEVar2); (pEVar2->_velocity).x = (float)targetPos; (pEVar2->_velocity).y = fVar3 * launchSpeed; (**(code **)(iVar1 + 0xc))(); return; } // 004bb350 Entity * NpcHelper::hornfel_free_door() { uint32_t rngResult; int *candidatesEnd; float fVar1; float fVar2; int *candidatesEndCopy; int railDoor; uint32_t i; void *local_10; uint8_t *puStack_c; uint32_t local_8; char *currentRoom; int enterDoor; void *room; puStack_c = &LAB_00af34dd; local_10 = ExceptionList; ExceptionList = &local_10; candidatesEnd = GHIDRA_CAST(0x0); candidatesEndCopy = GHIDRA_CAST(0x0); room = g_game->_room; local_8 = 0; i = 0; if (*GHIDRA_CAST((GHIDRA_CAST(room) + 0x1264)) != 0) { do { railDoor = *GHIDRA_CAST((*GHIDRA_CAST((GHIDRA_CAST(room) + 0x125c)) + i * 4)); if (((*GHIDRA_CAST((railDoor + 0x28)) == 0x3c7) && (*GHIDRA_CAST((railDoor + 0x3c4)) == 0)) && ((*GHIDRA_CAST((railDoor + 0x3bc)) == 0 || (*GHIDRA_CAST((*GHIDRA_CAST((railDoor + 0x3bc)) + 0x3c4)) == 0)))) { currentRoom = g_game->_room; if (((*currentRoom == '\0') || (g_game->_frameCount - *GHIDRA_CAST((currentRoom + 0x11f0)) < 0x1e) ) && (enterDoor = g_game->_enterDoor, -1 < enterDoor)) { if (enterDoor < 8) { fVar1 = (float)(*GHIDRA_CAST((currentRoom + enterDoor * 4 + 0x744)) % *GHIDRA_CAST((currentRoom + 0xc))) * 40.0 + 40.0; fVar2 = (float)(*GHIDRA_CAST((currentRoom + enterDoor * 4 + 0x744)) / *GHIDRA_CAST((currentRoom + 0xc))) * 40.0 + 120.0; } else { fVar1 = g_vectorZero.x; fVar2 = g_vectorZero.y; } fVar1 = *GHIDRA_CAST((railDoor + 0x33c)) - fVar1; fVar2 = *GHIDRA_CAST((railDoor + 0x340)) - fVar2; if (fVar2 * fVar2 + fVar1 * fVar1 <= 3600.0) goto LAB_004bb4af; } if (candidatesEnd == GHIDRA_CAST(0x0)) { msvc::vector::_Emplace_reallocate(0,&railDoor); candidatesEnd = candidatesEndCopy; } else { *candidatesEnd = railDoor; candidatesEndCopy = candidatesEnd + 1; candidatesEnd = candidatesEndCopy; } } LAB_004bb4af: i = i + 1; } while (i < *GHIDRA_CAST((GHIDRA_CAST(room) + 0x1264))); if (candidatesEnd != GHIDRA_CAST(0x0)) { if (GHIDRA_INT(candidatesEnd) >> 2 == 0) { ExceptionList = local_10; return pERam00000000; } rngResult = Random(); ExceptionList = local_10; return *GHIDRA_CAST(((rngResult % GHIDRA_UINT((GHIDRA_INT(candidatesEnd) >> 2))) * 4)); } } ExceptionList = local_10; return GHIDRA_CAST(0x0); } // 004bb550 Vector * NpcHelper::hornfel_get_rail_direction(Entity_NPC *npc, Vector *outDirection) { int gridY; uint32_t railSign; uint32_t gridIdx; int gridX; uint8_t railFlags; void *room; float zeroY; zeroY = g_vectorZero.y; room = g_game->_room; gridX = GHIDRA_INT((((npc->_targetPosition).x - 40.0) / 40.0 + 0.5)); if ((((-1 < gridX) && (gridX < *GHIDRA_CAST((GHIDRA_CAST(room) + 0xc)))) && (gridY = GHIDRA_INT((((npc->_targetPosition).y - 120.0) / 40.0 + 0.5)), -1 < gridY)) && (((gridY < *GHIDRA_CAST((GHIDRA_CAST(room) + 0x10)) && (gridIdx = *GHIDRA_CAST((GHIDRA_CAST(room) + 0xc)) * gridY + gridX, gridIdx < 0x1c0)) && (railFlags = *GHIDRA_CAST((gridIdx + 0x746c + GHIDRA_INT(room))), railFlags != 0xff)))) { if ((railFlags & 0x40) == 0) { if ((railFlags & 0x10) == 0) { railSign = railFlags >> 5 & 1; } else { railSign = 0xffffffff; } } else { railSign = 0; } railFlags = *GHIDRA_CAST((GHIDRA_CAST(room) + gridIdx + 0x746c)); if (railSign != 0) { if ((railFlags & 0xf) != 0) { if (GHIDRA_INT(railSign) < 0) { outDirection->x = 0.0; outDirection->y = (float)&DAT_bf800000; return outDirection; } outDirection->x = 0.0; outDirection->y = 1.0; return outDirection; } if (GHIDRA_INT(railSign) < 0) { outDirection->x = (float)&DAT_bf800000; outDirection->y = (float)(railFlags & 0xf); return outDirection; } outDirection->x = 1.0; outDirection->y = 0.0; return outDirection; } } outDirection->x = g_vectorZero.x; outDirection->y = zeroY; return outDirection; } // 004bb6b0 int NpcHelper::hornfel_next_rail_index(Entity_NPC *npc) { int row; uint32_t railDirection; uint32_t gridIndex; int iVar1; uint8_t *directionSign; Vector nextPos; uint8_t railType; Room *room; room = g_game->_room; iVar1 = GHIDRA_INT((((npc->_targetPosition).x - 40.0) / 40.0 + 0.5)); if ((((-1 < iVar1) && (iVar1 < room->_gridWidth)) && (row = GHIDRA_INT((((npc->_targetPosition).y - 120.0) / 40.0 + 0.5)), -1 < row)) && (((row < room->_gridHeight && (gridIndex = room->_gridWidth * row + iVar1, gridIndex < 0x1c0)) && (railType = (room->_railManager)._sprite._filename._buf[gridIndex - 0x1c0], railType != 0xff)))) { if ((railType & 0x40) == 0) { if ((railType & 0x10) == 0) { railDirection = railType >> 5 & 1; } else { railDirection = 0xffffffff; } } else { railDirection = 0; } if (railDirection != 0) { if (((room->_railManager)._sprite._filename._buf[gridIndex - 0x1c0] & 0xfU) == 0) { if (GHIDRA_INT(railDirection) < 0) { directionSign = &DAT_bf800000; } else { directionSign = GHIDRA_CAST(0x3f800000); } nextPos.x = (float)directionSign * 40.0 + (npc->_targetPosition).x; nextPos.y = (npc->_targetPosition).y + 0.0; iVar1 = Room::GetGridIndex(room,&nextPos); return iVar1; } if (GHIDRA_INT(railDirection) < 0) { directionSign = &DAT_bf800000; } else { directionSign = GHIDRA_CAST(0x3f800000); } nextPos.x = (npc->_targetPosition).x + 0.0; nextPos.y = (float)directionSign * 40.0 + (npc->_targetPosition).y; iVar1 = Room::GetGridIndex(room,&nextPos); return iVar1; } } return -1; } // 004bb830 void NpcHelper::hornfel_set_anim(Entity_NPC *npc, int stateFrame) { uint8_t bVar1; uint8_t *curAnimChar; uint32_t animCompare; uint8_t *openAnimChar; bool isLess; int soundId; uint8_t *animData; Manager *manager; if (npc->_state != 3) goto LAB_004bb903; animData = (npc->_sprite)._animState._animData; if (animData == GHIDRA_CAST(0x0)) { LAB_004bb896: bVar1 = ANM2::SetAnimation(&npc->_sprite,s_Open,1); if (bVar1 != 0) { AnimationState::Rewind(&(npc->_sprite)._animState); (npc->_sprite)._animState._isPlaying = 1; } } else { curAnimChar = animData; if (0xf < *GHIDRA_CAST((animData + 0x14))) { curAnimChar = *GHIDRA_CAST(animData); } openAnimChar = s_Open; do { bVar1 = *curAnimChar; isLess = bVar1 < *openAnimChar; if (bVar1 != *openAnimChar) { LAB_004bb880: animCompare = -GHIDRA_UINT(isLess) | 1; goto LAB_004bb885; } if (bVar1 == 0) break; bVar1 = curAnimChar[1]; isLess = bVar1 < openAnimChar[1]; if (bVar1 != openAnimChar[1]) goto LAB_004bb880; curAnimChar = curAnimChar + 2; openAnimChar = openAnimChar + 2; } while (bVar1 != 0); animCompare = 0; LAB_004bb885: if ((animCompare != 0) || ((animData[0x34] != 0 && ((npc->_sprite)._animState._isPlaying == 0))) ) goto LAB_004bb896; } manager = g_manager; soundId = 0x24; seed_fart_sound_override(&soundId); (GHIDRA_CAST((&manager->_sfxManager)))->SoundEffects::Play(soundId,0.5,10,0,1.3,0.0); npc->_state = 4; LAB_004bb903: npc->_stateFrame = stateFrame; return; } // 004bb920 uint8_t NpcHelper::hornfel_claim_target(Entity_NPC *npc, Entity *target) { int iVar1; Entity *parentTargetRef; Entity *targetLocal; targetLocal = target; if ((npc->_target != 0) || ((iVar1 = npc->_parent, iVar1 != 0 && (*GHIDRA_CAST((iVar1 + 0x3c4)) != 0)))) { return 0; } npc->_target = target; if (target != GHIDRA_CAST(0x0)) { msvc::multiset::insert(&npc->_target); iVar1 = npc->_parent; } if (iVar1 != 0) { parentTargetRef = GHIDRA_CAST((iVar1 + 0x3c4)); if (*GHIDRA_CAST((iVar1 + 0x3c4)) != 0) { target = parentTargetRef; msvc::multiset::erase(&target); } *GHIDRA_CAST(parentTargetRef) = targetLocal; if (targetLocal != GHIDRA_CAST(0x0)) { msvc::multiset::insert(parentTargetRef); } } return 1; } // 004bc460 void NpcHelper::hornfel_room_controller(Entity_Effect *effect) { uint32_t uVar1; uint32_t uVar2; Entity_NPC *npc; uint32_t uVar3; Entity *cart; int iVar4; Vector railDirection; uint32_t cartTypeChoices [16]; void *room; int roomWidth; cartTypeChoices[0xe] = __security_cookie ^ GHIDRA_UINT(&railDirection); room = g_game->_room; if (effect->_state == 0) { hornfel_spawn_doors(); uVar2 = Random(); effect->_state = 1; iVar4 = uVar2 % 0xd2 + 0x96; effect->_timeout = iVar4; effect->_lifespan = iVar4; return; } if ((*GHIDRA_CAST((*GHIDRA_CAST((GHIDRA_CAST(room) + 4)) + 0x44)) & 1) != 0) { hornfel_remove_doors(); (**(code **)(*GHIDRA_CAST(effect) + 0x28))(); } roomWidth = *GHIDRA_CAST((GHIDRA_CAST(room) + 0x12cc)) + *GHIDRA_CAST((GHIDRA_CAST(room) + 0x12c8)); iVar4 = 0; if (0 < roomWidth) { iVar4 = roomWidth; } if ((0 < iVar4) && (effect->_dead != 0)) { npc = GHIDRA_CAST(hornfel_free_door()); if (npc != GHIDRA_CAST(0x0)) { hornfel_get_rail_direction(npc,&railDirection); if ((railDirection.x != g_vectorZero.x) || (railDirection.y != g_vectorZero.y)) { cartTypeChoices[0] = 0x337; cartTypeChoices[1] = 0; cartTypeChoices[2] = 0x334; cartTypeChoices[3] = 0; cartTypeChoices[0xc] = 0x124; cartTypeChoices[4] = 0x33b; cartTypeChoices[5] = 0; cartTypeChoices[6] = 0xe3; cartTypeChoices[7] = 0; cartTypeChoices[0xd] = 0; cartTypeChoices[8] = 0x57; cartTypeChoices[9] = 0; cartTypeChoices[10] = 0x21; cartTypeChoices[0xb] = 0; uVar2 = Random(); uVar3 = Random(); cart = Game::SpawnEx(g_game,cartTypeChoices[(uVar2 % 7) * 2], cartTypeChoices[(uVar2 % 7) * 2 + 1],&g_vectorZero,&g_vectorZero, GHIDRA_CAST(0x0),0,uVar3,0); uVar1 = *GHIDRA_CAST((GHIDRA_INT(&cart->_flags) + 4)); *GHIDRA_CAST(&cart->_flags) = GHIDRA_UINT(cart->_flags) & 0xfffffffb; *GHIDRA_CAST((GHIDRA_INT(&cart->_flags) + 4)) = uVar1; cart->_spawnerType = 0x38a; Entity::GiveMinecart(cart,&npc->_targetPosition,&railDirection); hornfel_claim_target(npc,cart); } } uVar2 = Random(); uVar2 = uVar2 % 0xd2 + 0x96; iVar4 = *GHIDRA_CAST((GHIDRA_CAST(g_game->_room) + 0x10)); roomWidth = *GHIDRA_CAST((GHIDRA_CAST(g_game->_room) + 0xc)); effect->_dead = 0; uVar3 = uVar2 / 2; if (iVar4 * roomWidth < 0x88) { uVar3 = uVar2; } effect->_timeout = uVar3; effect->_lifespan = uVar3; } return; } // 004bc680 uint8_t NpcHelper::horny_boys_pick_position(Entity_NPC *npc) { Entity_Player *nearestPlayer; Game *game; int gridWidth; int iVar1; int gridX; uint32_t gridIndex; float fVar2; float dy; float playerDistSq; Vector candidatePos; float candidateY; float candidateX; int attemptsLeft; float bestDistSq; void *room; game = g_game; bestDistSq = 0.0; attemptsLeft = 6; (npc->_targetPosition).x = g_vectorZero.x; (npc->_targetPosition).y = g_vectorZero.y; do { Room::GetRandomPosition(game->_room,&candidatePos,20.0); room = g_game->_room; gridX = GHIDRA_INT(((candidatePos.x - 40.0) / 40.0 + 0.5)); iVar1 = GHIDRA_INT(((candidatePos.y - 120.0) / 40.0 + 0.5)); if ((((gridX < 0) || (gridWidth = *GHIDRA_CAST((GHIDRA_CAST(room) + 0xc)), gridWidth <= gridX)) || (iVar1 < 0) ) || (*GHIDRA_CAST((GHIDRA_CAST(room) + 0x10)) <= iVar1)) { gridWidth = *GHIDRA_CAST((GHIDRA_CAST(room) + 0xc)); gridIndex = 0xffffffff; } else { gridIndex = gridWidth * iVar1 + gridX; } candidatePos.x = (float)(GHIDRA_INT(gridIndex) % gridWidth) * 40.0 + 40.0; candidatePos.y = (float)(GHIDRA_INT(gridIndex) / gridWidth) * 40.0 + 120.0; candidateY = candidatePos.y; candidateX = candidatePos.x; nearestPlayer = Game::GetNearestPlayer(g_game,&candidatePos); game = g_game; fVar2 = candidateX - (nearestPlayer->_pos).x; dy = candidateY - (nearestPlayer->_pos).y; playerDistSq = dy * dy + fVar2 * fVar2; if ((((20.0 <= ABS(fVar2)) && (20.0 <= ABS(dy))) || (160000.0 <= playerDistSq)) && (((40000.0 <= playerDistSq && ((0x1bf < gridIndex || (*GHIDRA_CAST((GHIDRA_CAST(g_game->_room) + gridIndex * 4 + 0x76c)) < 500)))) && (fVar2 = (npc->_pos).x - candidateX, dy = (npc->_pos).y - candidateY, fVar2 = dy * dy + fVar2 * fVar2, bestDistSq < fVar2)))) { (npc->_targetPosition).x = candidateX; (npc->_targetPosition).y = candidateY; bestDistSq = fVar2; } attemptsLeft = attemptsLeft + -1; } while (attemptsLeft != 0); if (((npc->_targetPosition).x == g_vectorZero.x) && ((npc->_targetPosition).y == g_vectorZero.y)) { return 0; } return 1; } // 004bc8c0 Entity * NpcHelper::horny_boys_pull_entity(Entity_NPC *npc, int slot, Vector *targetPos) { int iVar1; uint32_t uVar2; uint32_t blockSlot; Entity *pEVar3; float fVar4; float dx; int *local_c; float local_8; uint32_t *parentSlot; local_c = GHIDRA_CAST((npc->_entityDeque)._offset); uVar2 = GHIDRA_UINT((slot + GHIDRA_INT(local_c))) >> 2; blockSlot = slot + GHIDRA_INT(local_c) & 3; if (*GHIDRA_CAST((*GHIDRA_CAST((GHIDRA_INT((npc->_entityDeque)._map) + ((npc->_entityDeque)._mapSize - 1 & uVar2) * 4)) + blockSlot * 4)) == 0) { return GHIDRA_CAST(0x0); } pEVar3 = *(Entity **) (*GHIDRA_CAST((GHIDRA_INT((npc->_entityDeque)._map) + ((npc->_entityDeque)._mapSize - 1 & uVar2) * 4 )) + blockSlot * 4); if ((pEVar3 == GHIDRA_CAST(0x0)) || (pEVar3->_type != 4)) { pEVar3 = GHIDRA_CAST(0x0); } else { dx = (npc->_pos).x - targetPos->x; local_8 = targetPos->y; fVar4 = (npc->_pos).y - local_8; targetPos = GHIDRA_CAST(targetPos->x); fVar4 = sqrtf(fVar4 * fVar4 + dx * dx); targetPos = GHIDRA_CAST(((float)targetPos - (npc->_pos).x)); fVar4 = (fVar4 - 100.0) / 200.0; if (fVar4 <= 0.0) { fVar4 = 0.0; } if (1.0 <= fVar4) { fVar4 = 1.0; } local_c = GHIDRA_CAST((fVar4 * 18.0 + 10.0)); local_8 = local_8 - (npc->_pos).y; fVar4 = sqrtf(local_8 * local_8 + (float)targetPos * (float)targetPos); if (0.0 < fVar4) { local_8 = (1.0 / fVar4) * local_8; targetPos = GHIDRA_CAST(((1.0 / fVar4) * (float)targetPos)); } targetPos = GHIDRA_CAST(((float)targetPos * (float)local_c)); parentSlot = &pEVar3->_parent; local_8 = local_8 * (float)local_c; if (*parentSlot != 0) { local_c = parentSlot; msvc::multiset::erase(&local_c); } *parentSlot = npc; if (npc != GHIDRA_CAST(0x0)) { msvc::multiset::insert(parentSlot); } pEVar3->_entityCollisionClass = 4; pEVar3->_visible = 1; *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST(&(pEVar3[1])) + 0xc)))) = 0xc0800000; (pEVar3->_posOffset).x = 0.0; (pEVar3->_posOffset).y = -24.0; (pEVar3->_pos).x = (npc->_pos).x; fVar4 = (npc->_pos).y; *GHIDRA_CAST(&pEVar3->_flags) = GHIDRA_UINT(pEVar3->_flags) & 0xffffffdf; (pEVar3->_pos).y = fVar4; *GHIDRA_CAST((GHIDRA_INT(&pEVar3->_flags) + 4)) = *GHIDRA_CAST((GHIDRA_INT(&pEVar3->_flags) + 4)); iVar1 = *GHIDRA_CAST(pEVar3); (pEVar3->_velocity).x = (float)targetPos; (pEVar3->_velocity).y = local_8; (**(code **)(iVar1 + 0xc))(); } uVar2 = slot + (npc->_entityDeque)._offset; blockSlot = uVar2 & 3; iVar1 = *GHIDRA_CAST((GHIDRA_INT((npc->_entityDeque)._map) + (uVar2 >> 2 & (npc->_entityDeque)._mapSize - 1) * 4)); parentSlot = GHIDRA_CAST((iVar1 + blockSlot * 4)); if (*GHIDRA_CAST((iVar1 + blockSlot * 4)) != 0) { slot = GHIDRA_INT(parentSlot); msvc::multiset::erase(&slot); } *parentSlot = 0; return pEVar3; } // 004bcc70 Entity * NpcHelper::horny_boys_spawn_bomb(Entity_NPC *npc, int slot) { uint32_t uVar1; int iVar2; RNG rng; uint8_t *puVar3; Entity *pEVar4; uint32_t uVar5; void *ptr; uint32_t uVar6; BitSet128 bombTearFlags0; uint64_t uStack_3c; uint32_t *puStack_34; void *picker; uint32_t *outcomesEnd; uint32_t *outcomesCapacity; uint32_t local_24; uint8_t *puStack_20; void *local_1c; uint8_t *puStack_18; uint32_t local_14; uint32_t *bombSlot; int *outcomeWeight; puStack_20 = GHIDRA_CAST((GHIDRA_INT(register0x00000010) + -4)); local_14 = 0xffffffff; puStack_18 = &DAT_00af350d; local_1c = ExceptionList; local_24 = __security_cookie ^ GHIDRA_INT(register0x00000010) - 0x10U; ExceptionList = &local_1c; uVar5 = slot + (npc->_entityDeque)._offset; uVar6 = uVar5 >> 2; uVar5 = uVar5 & 3; puVar3 = GHIDRA_CAST((GHIDRA_INT(register0x00000010) + -4)); if (*GHIDRA_CAST((*GHIDRA_CAST((GHIDRA_INT((npc->_entityDeque)._map) + ((npc->_entityDeque)._mapSize - 1 & uVar6) * 4)) + uVar5 * 4)) != 0) { puStack_34 = GHIDRA_CAST((npc->_entityDeque)._offset); (**(code **)(**GHIDRA_CAST((*GHIDRA_CAST((GHIDRA_INT((npc->_entityDeque)._map) + ((npc->_entityDeque)._mapSize - 1 & uVar6) * 4)) + uVar5 * 4)) + 0x28))(local_24); puVar3 = puStack_20; } puStack_20 = puVar3; picker = (void *)0x0; outcomesEnd = GHIDRA_CAST(0x0); outcomesCapacity = GHIDRA_CAST(0x0); local_14 = 0; uStack_3c = (uint64_t)GHIDRA_UINT(uStack_3c); puStack_34 = GHIDRA_CAST(0x6); msvc::vector<8byte>::_Emplace_reallocate(0,GHIDRA_INT(&uStack_3c) + 4); uVar5 = 0; uVar6 = GHIDRA_INT(outcomesEnd) - GHIDRA_INT(picker) >> 3; if (uVar6 != 0) { do { if (*GHIDRA_CAST((GHIDRA_CAST(picker) + uVar5 * 8)) == 8) { outcomeWeight = GHIDRA_CAST((GHIDRA_INT(picker) + uVar5 * 8 + 4)); *outcomeWeight = *outcomeWeight + 3; if (*outcomeWeight < 0) { *GHIDRA_CAST((GHIDRA_CAST(picker) + uVar5 * 8 + 4)) = 0; } goto LAB_004bcda7; } uVar5 = uVar5 + 1; } while (uVar5 < uVar6); } uStack_3c = CONCAT44(8,GHIDRA_UINT(uStack_3c)); puStack_34 = GHIDRA_CAST(0x3); if (outcomesEnd == outcomesCapacity) { msvc::vector<8byte>::_Emplace_reallocate(outcomesEnd,GHIDRA_INT(&uStack_3c) + 4); } else { *outcomesEnd = 8; outcomesEnd[1] = 3; outcomesEnd = outcomesEnd + 2; } LAB_004bcda7: uVar5 = 0; uVar6 = GHIDRA_INT(outcomesEnd) - GHIDRA_INT(picker) >> 3; if (uVar6 != 0) { do { if (*GHIDRA_CAST((GHIDRA_CAST(picker) + uVar5 * 8)) == 0x10) { outcomeWeight = GHIDRA_CAST((GHIDRA_INT(picker) + uVar5 * 8 + 4)); *outcomeWeight = *outcomeWeight + 1; if (*outcomeWeight < 0) { *GHIDRA_CAST((GHIDRA_CAST(picker) + uVar5 * 8 + 4)) = 0; } goto LAB_004bce05; } uVar5 = uVar5 + 1; } while (uVar5 < uVar6); } uStack_3c = CONCAT44(0x10,GHIDRA_UINT(uStack_3c)); puStack_34 = GHIDRA_CAST(0x1); if (outcomesEnd == outcomesCapacity) { msvc::vector<8byte>::_Emplace_reallocate(outcomesEnd,GHIDRA_INT(&uStack_3c) + 4); } else { *outcomesEnd = 0x10; outcomesEnd[1] = 1; outcomesEnd = outcomesEnd + 2; } LAB_004bce05: uVar5 = Random(); uStack_3c = 0x900000005; puStack_34 = GHIDRA_CAST(&DAT_00000007); rng._shift1 = 5; rng._seed = uVar5 | 1; rng._shift2 = 9; rng._shift3 = 7; uVar5 = WeightedOutcomePicker::PickOutcome(GHIDRA_CAST(&picker),rng); bombTearFlags0 = (BitSet128)ZEXT816(0); if (uVar5 == 8) { bombTearFlags0 = g_tearFlagBurn; } else if (uVar5 == 0x10) { bombTearFlags0 = g_tearFlagSadBomb; } else { } uVar6 = Random(); pEVar4 = Game::Spawn(g_game,4,uVar5,&npc->_pos,&g_vectorZero,GHIDRA_CAST(npc),0,uVar6); pEVar4->_visible = 0; pEVar4->_entityCollisionClass = 0; pEVar4->_entityGridCollisionClass = 0; if (pEVar4->_parent != 0) { puStack_34 = &pEVar4->_parent; msvc::multiset::erase(&puStack_34); } pEVar4->_parent = npc; if (npc != GHIDRA_CAST(0x0)) { msvc::multiset::insert(&pEVar4->_parent); } uVar1 = *GHIDRA_CAST((GHIDRA_INT(&pEVar4->_flags) + 4)); *GHIDRA_CAST(&pEVar4->_flags) = GHIDRA_UINT(pEVar4->_flags) | 0x20; *GHIDRA_CAST((GHIDRA_INT(&pEVar4->_flags) + 4)) = uVar1; iVar2 = *GHIDRA_CAST(pEVar4); *GHIDRA_CAST((pEVar4 + 1)) = 0x23; *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST(&(pEVar4[1])) + 0x4)))) = 0x23; pEVar4[1]._type = GHIDRA_INT(bombTearFlags0._l); pEVar4[1]._variant = (*GHIDRA_CAST((GHIDRA_CAST(&(bombTearFlags0._l)) + 0x4))); pEVar4[1]._subtype = GHIDRA_INT(bombTearFlags0._h); pEVar4[1]._spawnerType = (*GHIDRA_CAST((GHIDRA_CAST(&(bombTearFlags0._h)) + 0x4))); pEVar4[1]._sprite._filename._buf[0xb] = '\x01'; (**(code **)(iVar2 + 0xc))(); puStack_34 = GHIDRA_CAST((npc->_entityDeque)._offset); uVar5 = slot + GHIDRA_INT(puStack_34) & 3; iVar2 = *GHIDRA_CAST((GHIDRA_INT((npc->_entityDeque)._map) + (GHIDRA_UINT((slot + GHIDRA_INT(puStack_34))) >> 2 & (npc->_entityDeque)._mapSize - 1) * 4)); bombSlot = GHIDRA_CAST((iVar2 + uVar5 * 4)); if (*GHIDRA_CAST((iVar2 + uVar5 * 4)) != 0) { puStack_34 = bombSlot; msvc::multiset::erase(&puStack_34); } *bombSlot = pEVar4; msvc::multiset::insert(bombSlot); if (picker != (void *)0x0) { uVar5 = GHIDRA_INT(outcomesCapacity) - GHIDRA_INT(picker) & 0xfffffff8; ptr = picker; if (0xfff < uVar5) { ptr = *(void **)(GHIDRA_CAST(picker) + -4); uVar5 = uVar5 + 0x23; if (0x1f < GHIDRA_UINT((GHIDRA_INT(picker) + (-4 - GHIDRA_INT(ptr))))) { /* WARNING: Subroutine does not return */ _invalid_parameter_noinfo_noreturn(); } } operator_delete(ptr,uVar5); } ExceptionList = local_1c; return pEVar4; } // 004d8d10 Entity_NPC * NpcHelper::gaper_l2_spawn_maggot(Vector *origin, float yOffset, Vector *velocity, float fallingSpeed) { void *pvVar1; code *pcVar2; uint32_t seed; Entity_NPC *maggot; float fVar3; float fVar4; float dirY; uint64_t flags; uint32_t flagsHigh; pvVar1 = g_game->_room; seed = Random(); maggot = GHIDRA_CAST(Game)::Spawn(g_game,0x355,0,origin,&g_vectorZero,GHIDRA_CAST(0x0),0,seed); *GHIDRA_CAST(&maggot->_flags) = GHIDRA_UINT(maggot->_flags) & 0xfffffffb; flagsHigh = *GHIDRA_CAST((GHIDRA_INT(&maggot->_flags) + 4)); flags = maggot->_flags; (maggot->_v1).x = fallingSpeed; *GHIDRA_CAST((GHIDRA_INT(&maggot->_flags) + 4)) = flagsHigh; fVar3 = sqrtf(velocity->x * velocity->x + velocity->y * velocity->y); (maggot->_v1).y = fVar3; fVar3 = velocity->x; (maggot->_targetPosition).x = fVar3; dirY = velocity->y; (maggot->_targetPosition).y = dirY; (maggot->_velocity).y = dirY; (maggot->_velocity).x = fVar3; maggot->_state = 0x10; maggot->_i1 = 2; *GHIDRA_CAST(&maggot->_flags) = GHIDRA_UINT(flags) | 0x4000000; *GHIDRA_CAST((GHIDRA_INT(&maggot->_flags) + 4)) = flagsHigh; if (*GHIDRA_CAST((GHIDRA_CAST(pvVar1) + 8)) == 0x10) { (maggot->_pos).y = yOffset + (maggot->_pos).y; (maggot->_velocity).y = fallingSpeed + (maggot->_velocity).y; } else { (maggot->_posOffset).y = yOffset; } (**(code **)(*GHIDRA_CAST(maggot) + 0xc))(); fVar3 = (maggot->_velocity).x; dirY = (maggot->_velocity).y; seed = maggot->_initSeed; fVar4 = sqrtf(fVar3 * fVar3 + dirY * dirY); if (0.0 < fVar4) { fVar3 = fVar3 * (1.0 / fVar4); dirY = dirY * (1.0 / fVar4); } (maggot->_pathfinder)._movementTarget.x = fVar3; (maggot->_pathfinder)._movementTarget.y = dirY; if (seed == 0) { KAGE_LogMessage(0x10,GHIDRA_CAST("RNG Seed is zero!\n")); pcVar2 = (code *)swi(3); maggot = GHIDRA_CAST((*pcVar2)()); return maggot; } seed = seed >> 5 ^ seed; seed = seed << 9 ^ seed; (maggot->_pathfinder)._moveCountdown = (seed >> 7 ^ seed) % 0x1e + 10; return maggot; } // 004d8f20 Vector * NpcHelper::adult_leech_heading(Vector *outHeading, Entity *target, Vector npcPos) { uint32_t rngResult; float fVar1; float cosAngle; rngResult = Random(); fVar1 = ((float)((double)GHIDRA_INT(rngResult) + __uint_to_double_fixup[-(GHIDRA_INT(rngResult) >> 0x1f)]) * 2.3283064e-10 - 0.5) * 90.0 * 0.017453292; cosAngle = cos(fVar1); outHeading->x = cosAngle; fVar1 = sin(fVar1); outHeading->y = fVar1; rngResult = Random(); if ((rngResult & 1) == 0) { outHeading->x = outHeading->x * -1.0; } rngResult = Random(); if ((rngResult & 1) == 0) { fVar1 = outHeading->y; cosAngle = (target->_pos).y; if (((fVar1 < 0.0) && (npcPos.y < cosAngle)) || ((0.0 < fVar1 && (cosAngle < npcPos.y)))) { outHeading->y = fVar1 * -1.0; } } return outHeading; } // 004db3c0 void NpcHelper::twitchy_jump_target(Vector *outTarget, Entity_NPC *npc) { Entity *playerTarget; Vector *resultPos; uint32_t gridCollision; int gridRow; int gridIndex; float fVar1; float fVar2; float fVar3; Vector scratchVec; float toTargetX; float local_c; float local_8; Room *room; room = g_game->_room; Entity_NPC::CalcTargetPosition(npc,outTarget,0.0); playerTarget = Entity_NPC::GetPlayerTarget(npc); local_8 = (playerTarget->_velocity).y; fVar2 = (npc->_pos).x - (playerTarget->_pos).x; local_c = (playerTarget->_velocity).x; fVar1 = (npc->_pos).y - (playerTarget->_pos).y; fVar1 = sqrtf(fVar1 * fVar1 + fVar2 * fVar2); local_c = local_c * 0.1 * fVar1 + outTarget->x; local_8 = local_8 * 0.1 * fVar1 + outTarget->y; outTarget->x = local_c; outTarget->y = local_8; scratchVec.y = local_8 - (npc->_pos).y; toTargetX = local_c - (npc->_pos).x; fVar1 = sqrtf(scratchVec.y * scratchVec.y + toTargetX * toTargetX); if (fVar1 <= 0.0) { fVar2 = toTargetX; fVar1 = scratchVec.y; } else { fVar2 = toTargetX * (1.0 / fVar1); fVar1 = scratchVec.y * (1.0 / fVar1); } outTarget->x = fVar2 * 40.0 + local_c; outTarget->y = fVar1 * 40.0 + local_8; resultPos = Room::GetClampedPositionImpl(room,&scratchVec,outTarget,0.0,0.0,0.0,0.0); local_8 = resultPos->x; outTarget->x = local_8; local_c = resultPos->y; outTarget->y = local_c; fVar2 = (npc->_pos).x - local_8; fVar1 = (npc->_pos).y - local_c; fVar1 = sqrtf(fVar1 * fVar1 + fVar2 * fVar2); if (fVar1 <= 200.0) { fVar1 = local_8; fVar2 = local_c; } else { local_c = local_c - (npc->_pos).y; local_8 = local_8 - (npc->_pos).x; fVar1 = sqrtf(local_c * local_c + local_8 * local_8); if (fVar1 <= 0.0) { fVar2 = local_8; fVar3 = local_c; } else { fVar2 = local_8 * (1.0 / fVar1); fVar3 = local_c * (1.0 / fVar1); } fVar1 = fVar2 * 200.0 + (npc->_pos).x; fVar2 = fVar3 * 200.0 + (npc->_pos).y; outTarget->x = fVar1; outTarget->y = fVar2; } gridRow = GHIDRA_INT(((fVar2 - 120.0) / 40.0 + 0.5)); gridIndex = GHIDRA_INT(((fVar1 - 40.0) / 40.0 + 0.5)); if ((((gridIndex < 0) || (room->_gridWidth <= gridIndex)) || (gridRow < 0)) || (room->_gridHeight <= gridRow)) { gridIndex = -1; } else { gridIndex = room->_gridWidth * gridRow + gridIndex; } gridCollision = Room::GetGridCollision(room,gridIndex); if (0 < GHIDRA_INT(gridCollision)) { resultPos = Room::FindFreeTilePosition(room,&scratchVec,outTarget,64.0); outTarget->x = resultPos->x; outTarget->y = resultPos->y; } return; } // 004e0930 void NpcHelper::gutted_fatty_burst_projectiles(Entity *timer) { uint32_t rngResult; uint32_t rngFraction; Entity_Projectile *pEVar1; int projectilesLeft; float originY; float dirX; float randomScale; Vector local_18; Vector local_10; float originX; float originY; projectilesLeft = 2; originX = (timer->_pos).x; originY = (timer->_pos).y; do { rngResult = Random(); originY = (float)((double)GHIDRA_INT(rngResult) + __uint_to_double_fixup[-(GHIDRA_INT(rngResult) >> 0x1f)]) * 2.3283064e-10 * 3.14; originY = originY + originY; dirX = cos(originY); originY = sin(originY); rngResult = Random(); rngFraction = Random(); randomScale = (float)((double)GHIDRA_INT(rngFraction) + __uint_to_double_fixup[-(GHIDRA_INT(rngFraction) >> 0x1f)]) * 2.3283064e-10; local_18.y = randomScale * originY * 2.8; local_18.x = randomScale * dirX * 2.8; rngFraction = Random(); randomScale = (float)((double)GHIDRA_INT(rngFraction) + __uint_to_double_fixup[-(GHIDRA_INT(rngFraction) >> 0x1f)]) * 2.3283064e-10; local_10.x = dirX * 5.0 * randomScale + originX; local_10.y = originY * 5.0 * randomScale + originY; pEVar1 = (Entity_Projectile *) Game::SpawnEx(g_game,9,0,&local_10,&local_18,GHIDRA_CAST(0x0),0,rngResult,0); pEVar1->_spawnerType = 0x33f; rngResult = Random(); pEVar1->_fallingAccel = 2.0; pEVar1->_scale = (float)((double)GHIDRA_INT(rngResult) + __uint_to_double_fixup[-(GHIDRA_INT(rngResult) >> 0x1f)]) * 2.3283064e-10 * 1.4; rngResult = Random(); pEVar1->_fallingSpeed = -15.0 - (float)((double)GHIDRA_INT(rngResult) + __uint_to_double_fixup[-(GHIDRA_INT(rngResult) >> 0x1f)]) * 2.3283064e-10 * 60.0; rngResult = Random(); pEVar1->_height = -23.0 - (float)((double)GHIDRA_INT(rngResult) + __uint_to_double_fixup[-(GHIDRA_INT(rngResult) >> 0x1f)]) * 2.3283064e-10 * 15.0; Entity_Projectile::apply_spawn_flags (pEVar1,*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST(&(timer[1])) + 0x40)))), *GHIDRA_CAST((timer[1]._sprite._animDefaultName._buf + 8)),timer->_flags,GHIDRA_CAST(0x0)); (**(code **)(*GHIDRA_CAST(pEVar1) + 0xc))(); projectilesLeft = projectilesLeft + -1; } while (projectilesLeft != 0); projectilesLeft = 2; do { rngResult = Random(); originY = (float)((double)GHIDRA_INT(rngResult) + __uint_to_double_fixup[-(GHIDRA_INT(rngResult) >> 0x1f)]) * 2.3283064e-10 * 3.14; originY = originY + originY; dirX = cos(originY); originY = sin(originY); rngResult = Random(); rngFraction = Random(); randomScale = (float)((double)GHIDRA_INT(rngFraction) + __uint_to_double_fixup[-(GHIDRA_INT(rngFraction) >> 0x1f)]) * 2.3283064e-10; local_10.y = randomScale * originY * 2.8; local_10.x = randomScale * dirX * 2.8; rngFraction = Random(); randomScale = (float)((double)GHIDRA_INT(rngFraction) + __uint_to_double_fixup[-(GHIDRA_INT(rngFraction) >> 0x1f)]) * 2.3283064e-10; local_18.x = dirX * 5.0 * randomScale + originX; local_18.y = originY * 5.0 * randomScale + originY; pEVar1 = (Entity_Projectile *) Game::SpawnEx(g_game,9,0,&local_18,&local_10,GHIDRA_CAST(0x0),0,rngResult,0); pEVar1->_spawnerType = 0x33f; rngResult = Random(); pEVar1->_fallingAccel = 2.0; pEVar1->_scale = (float)((double)GHIDRA_INT(rngResult) + __uint_to_double_fixup[-(GHIDRA_INT(rngResult) >> 0x1f)]) * 2.3283064e-10 * 1.4; rngResult = Random(); pEVar1->_fallingSpeed = -15.0 - (float)((double)GHIDRA_INT(rngResult) + __uint_to_double_fixup[-(GHIDRA_INT(rngResult) >> 0x1f)]) * 2.3283064e-10 * 60.0; rngResult = Random(); pEVar1->_height = -23.0 - (float)((double)GHIDRA_INT(rngResult) + __uint_to_double_fixup[-(GHIDRA_INT(rngResult) >> 0x1f)]) * 2.3283064e-10 * 1000.0; Entity_Projectile::apply_spawn_flags (pEVar1,*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST(&(timer[1])) + 0x40)))), *GHIDRA_CAST((timer[1]._sprite._animDefaultName._buf + 8)),timer->_flags,GHIDRA_CAST(0x0)); (**(code **)(*GHIDRA_CAST(pEVar1) + 0xc))(); projectilesLeft = projectilesLeft + -1; } while (projectilesLeft != 0); return; } // 004e4870 uint8_t NpcHelper::candler_is_free_cell(Vector *position) { uint32_t uVar1; int gridY; int gridY; Room *room; room = g_game->_room; gridY = GHIDRA_INT(((position->x - 40.0) / 40.0 + 0.5)); gridY = GHIDRA_INT(((position->y - 120.0) / 40.0 + 0.5)); if ((((gridY < 0) || (room->_gridWidth <= gridY)) || (gridY < 0)) || (room->_gridHeight <= gridY)) { gridY = -1; } else { gridY = room->_gridWidth * gridY + gridY; } uVar1 = Room::GetGridCollision(room,gridY); if (((((uVar1 == 0) && (gridY = GHIDRA_INT(((position->x - 40.0) / 40.0 + 0.5)), -1 < gridY)) && ((gridY < room->_gridWidth && ((gridY = GHIDRA_INT(((position->y - 120.0) / 40.0 + 0.5)), -1 < gridY && (gridY < room->_gridHeight)))))) && (gridY = room->_gridWidth * gridY + gridY, -1 < gridY)) && (((0x1bf < gridY || (room->_gridEntities[gridY] == (void *)0x0)) || (*GHIDRA_CAST((GHIDRA_INT(room->_gridEntities[gridY]) + 4)) != 0x17)))) { return 1; } return 0; } // 00501e10 void NpcHelper::bouncer_death_gib(Entity_Effect *timer) { uint32_t rngResult; Entity *pEVar1; float sinAngle; Vector local_20; float local_18; float velocityX; Vector gibVelocity; rngResult = Random(); local_20.x = (float)((double)GHIDRA_INT(rngResult) + __uint_to_double_fixup[-(GHIDRA_INT(rngResult) >> 0x1f)]) * 2.3283064e-10 * 3.14; local_20.x = local_20.x + local_20.x; rngResult = Random(); local_18 = (float)((double)GHIDRA_INT(rngResult) + __uint_to_double_fixup[-(GHIDRA_INT(rngResult) >> 0x1f)]) * 2.3283064e-10 * 12.0; velocityX = cos(local_20.x); velocityX = velocityX * local_18; gibVelocity.x = velocityX; sinAngle = sin(local_20.x); local_18 = sinAngle * local_18; gibVelocity.y = local_18; rngResult = Random(); local_20.x = (timer->_pos).x; local_20.y = (timer->_pos).y; pEVar1 = Game::SpawnEx(g_game,1000,2,&local_20,&gibVelocity,GHIDRA_CAST(0x0),3,rngResult,0); (pEVar1->_sprite)._offset.x = velocityX + 0.0; (pEVar1->_sprite)._offset.y = local_18 - 26.0; return; } // 00528ec0 void NpcHelper::migraine_timer_spawn(Entity *timer) { int *piVar1; int64_t lVar2; int64_t lVar3; int64_t lVar4; float fVar5; uint8_t isErased; char cVar6; uint32_t uVar7; uint32_t uVar8; int *piVar9; int iVar10; Entity *pEVar11; int unusedArg; int unusedArg_00; void *pvVar12; uint32_t uVar13; uint32_t uVar14; PlayerManager *playerManager; bool bVar15; float fVar16; float fVar17; uint64_t timeNs; float local_124; Entity *local_120; Game *local_11c; void *local_118; float local_114; float local_110; float local_10c; uint32_t local_108; uint32_t local_104; float spawnVelX; float fStack_fc; Game *local_f4; Entity *owner; Vector spawnPos; uint32_t local_e4; uint32_t local_e0; Vector local_d4; uint32_t uStack_cc; uint32_t spawnSeed; void *pvStack_c4; int *apiStack_bc [4]; Vector particleVel; int *local_a4; Vector spawnVel [2]; int iStack_8c; uint32_t uStack_88; int iStack_84; uint32_t uStack_80; Vector bloodVel [2]; uint32_t uStack_6c; uint32_t local_68; uint32_t uStack_64; uint32_t local_60 [5]; uint8_t auStack_4c [8]; int foundNode2; int foundNode; uint8_t auStack_30 [8]; int iStack_28; int iStack_24; uint32_t uStack_20; uint32_t stackCookie; code *fnPtr; Game *game; uint32_t *spawnerRef; ColorMod *spriteColor; stackCookie = __security_cookie ^ GHIDRA_UINT(&local_124); spawnPos.x = (timer->_pos).x; spawnPos.y = (timer->_pos).y; owner = timer; uVar7 = Random(); fVar16 = (float)((double)GHIDRA_INT(uVar7) + __uint_to_double_fixup[-(GHIDRA_INT(uVar7) >> 0x1f)]) * 2.3283064e-10 * 3.14; local_120 = GHIDRA_CAST((fVar16 + fVar16)); uVar7 = Random(); local_110 = (float)((double)GHIDRA_INT(uVar7) + __uint_to_double_fixup[-(GHIDRA_INT(uVar7) >> 0x1f)]) * 2.3283064e-10 * 4.0 + 6.0; spawnVelX = cos((float)local_120); spawnVelX = spawnVelX * local_110; spawnVel[0].x = spawnVelX; fVar16 = sin((float)local_120); local_118 = (void *)(fVar16 * local_110); spawnVel[0].y = (float)local_118; spawnSeed = Random(); local_11c = g_game; local_114 = 0.0; local_e4 = 3; local_f4 = GHIDRA_CAST(&DAT_00000004); lua_callback_run_pre_entity_spawn (GHIDRA_CAST(&local_f4),GHIDRA_CAST(&local_e4),&spawnPos,spawnVel,GHIDRA_CAST(0x0),GHIDRA_CAST(&local_114), &spawnSeed); uVar7 = local_e4; if (*GHIDRA_CAST(&g_game->_deathmatchManager) < 2) { LAB_0052926a: local_124 = local_114; } else { pEVar11 = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST(&((g_game->_deathmatchManager))) + 0xc)))); local_120 = pEVar11; uVar8 = Random(); fVar16 = local_114; local_68 = 5; uStack_64 = 9; local_110 = 9.80909e-45; local_60[0] = 7; if (local_f4 != GHIDRA_CAST(&DAT_00000005)) goto LAB_0052926a; if (uVar7 < 0x12d) { if (uVar7 == 300) { while ((local_124 = local_114, local_114 == 0.0 || (cVar6 = (**(code **)(*GHIDRA_CAST(pEVar11) + 0x24))(), cVar6 != '\0'))) { if (uVar8 == 0) { KAGE_LogMessage(0x10,GHIDRA_CAST("RNG Seed is zero!\n")); fnPtr = (code *)swi(3); (*fnPtr)(); return; } uVar8 = uVar8 >> ((uint8_t)local_68 & 0x1f) ^ uVar8; uVar8 = uVar8 << ((uint8_t)uStack_64 & 0x1f) ^ uVar8; uVar8 = uVar8 >> (SUB41(local_110,0) & 0x1f) ^ uVar8; iVar10 = ItemPool::GetCardEx(uVar8,0x19,10,10,1); iStack_28 = 5; iStack_24 = 9; uStack_20 = 7; (*GHIDRA_CAST((GHIDRA_CAST(&(auStack_30)) + 0x4))) = uVar8; local_114 = (float)lua_callback_run_get_card(GHIDRA_CAST((auStack_30 + 4)),iVar10,1,1,0); } } else { if (uVar7 == 0x46) { local_d4.x = (float)(GHIDRA_UINT(local_114) >> 0xb); do { local_124 = local_114; if (local_114 != 0.0) { fnPtr = *(code **)(*GHIDRA_CAST(pEVar11) + 0x28); ItemPool::GetPillEffect(&g_game->_itemPool,GHIDRA_UINT(local_114),GHIDRA_CAST(0x0)); cVar6 = (*fnPtr)(); if (cVar6 == '\0') goto LAB_00529272; pEVar11 = local_120; } if (uVar8 == 0) { KAGE_LogMessage(0x10,GHIDRA_CAST("RNG Seed is zero!\n")); fnPtr = (code *)swi(3); (*fnPtr)(); return; } uVar8 = uVar8 >> ((uint8_t)local_68 & 0x1f) ^ uVar8; uVar8 = uVar8 << ((uint8_t)uStack_64 & 0x1f) ^ uVar8; uVar8 = uVar8 >> (SUB41(local_110,0) & 0x1f) ^ uVar8; uVar7 = ItemPool::GetPill(uVar8); local_114 = (float)(uVar7 | (GHIDRA_UINT(local_d4.x) & 1) << 0xb); } while( true ); } if (uVar7 != 100) goto LAB_0052926a; local_124 = local_114; if (local_114 == 3.50325e-44) { LAB_005290ba: bVar15 = false; } else { local_d4.x = local_114; msvc::set::find_node(); if (((*GHIDRA_CAST((foundNode + 0xd)) == '\0') && (*GHIDRA_CAST((foundNode + 0x10)) <= GHIDRA_INT(fVar16))) && (foundNode != pEVar11->_index)) goto LAB_005290ba; bVar15 = true; } if ((fVar16 == 0.0) || (bVar15)) { local_124 = (float)(**(code **)(*GHIDRA_CAST(pEVar11) + 0x84))(); local_114 = local_124; } } } else { if (uVar7 != 0x15e) goto LAB_0052926a; while ((local_124 = local_114, local_114 == 0.0 || (cVar6 = (**(code **)(*GHIDRA_CAST(pEVar11) + 0x2c))(), cVar6 != '\0'))) { local_114 = (float)ItemPool::GetTrinket(&g_game->_itemPool,0); } } } LAB_00529272: local_120 = EntityFactory::Create(local_11c->_entityFactory,GHIDRA_UINT(local_f4),0); if (local_120 == GHIDRA_CAST(0x0)) goto LAB_00529568; timeNs = GetTimeNs(); pEVar11 = local_120; local_108 = GHIDRA_UINT((timeNs >> 0x20)); lVar2 = (timeNs & 0xffffffff) * 0x431bde82; local_104 = GHIDRA_UINT(((uint64_t)lVar2 >> 0x20)); lVar3 = (uint64_t)local_108 * 0xd7b634db + ((timeNs & 0xffffffff) * 0xd7b634db >> 0x20); local_d4.y = (float)(lVar3 + lVar2); lVar2 = (uint64_t)local_108 * 0x431bde82 + (uint64_t) CONCAT14(CARRY4(GHIDRA_UINT(((uint64_t)lVar3 >> 0x20)), local_104 + CARRY4(GHIDRA_UINT(lVar2),GHIDRA_UINT(lVar3))), GHIDRA_INT(((uint64_t)(lVar3 + lVar2) >> 0x20))); local_e0 = GHIDRA_UINT(((uint64_t)lVar2 >> 0x20)); spawnerRef = &local_120->_spawnerEntity; local_10c = (float)(GHIDRA_UINT(lVar2) >> 0x12 | local_e0 * 0x4000); local_e0 = local_e0 >> 0x12; local_120->_spawnerType = 0; local_120->_spawnerVariant = 0; if (*spawnerRef != 0) { local_a4 = spawnerRef; msvc::multiset::erase(); } iVar10 = *GHIDRA_CAST(pEVar11); *spawnerRef = 0; (pEVar11->_pos).x = spawnPos.x; (pEVar11->_pos).y = spawnPos.y; (pEVar11->_velocity).x = spawnVelX; (pEVar11->_velocity).y = (float)local_118; (**(code **)(iVar10 + 4))(local_f4,local_e4); game = local_11c; pvVar12 = local_11c->_room; iVar10 = *GHIDRA_CAST((GHIDRA_CAST(pvVar12) + 0x1214)); *GHIDRA_CAST((GHIDRA_CAST(pvVar12) + 0x1214)) = iVar10 + 1; pEVar11->_index = iVar10; EntityList::AddEntity(GHIDRA_CAST((GHIDRA_INT(pvVar12) + 0x1218)),pEVar11); isErased = Game::ShouldEraseEnemy(pEVar11); if (isErased != 0) { Entity::RemoveWithPoof(pEVar11,unusedArg); } if ((pEVar11->_exists != 0) && ((game->_proceduralItemManager)._proceduralItems._begin != (game->_proceduralItemManager)._proceduralItems._end)) { uStack_88 = pEVar11->_variant; iStack_8c = pEVar11->_type; msvc::map::find(); pvVar12 = (game->_proceduralItemManager)._spawnTriggerTargets._head; if (pvStack_c4 == pvVar12) { iStack_84 = pEVar11->_type; uStack_80 = 0xffffffff; piVar9 = GHIDRA_CAST(std)::map::find(); pvStack_c4 = (void *)*piVar9; if (pvStack_c4 == pvVar12) goto LAB_005294e4; } uVar7 = 0; playerManager = &g_game->_playerManager; if (GHIDRA_INT((g_game->_playerManager)._playerList._end) - GHIDRA_INT((playerManager->_playerList)._begin) >> 2 != 0) { do { pvVar12 = (playerManager->_playerList)._end; if (GHIDRA_INT(pvVar12) - GHIDRA_INT((playerManager->_playerList)._begin) >> 2 == 0) { KAGE_LogMessage(0x10,GHIDRA_CAST("PlayerManager::GetPlayer() : There are no players! \n")); pvVar12 = (playerManager->_playerList)._end; } piVar9 = (playerManager->_playerList)._begin; if (uVar7 < GHIDRA_UINT((GHIDRA_INT(pvVar12) - GHIDRA_INT(piVar9) >> 2))) { piVar9 = piVar9 + uVar7; } trigger_set_dispatch((void *)(*piVar9 + 0x1fc8),6,pEVar11,&spawnPos,spawnVel); uVar7 = uVar7 + 1; playerManager = &g_game->_playerManager; } while (uVar7 < GHIDRA_UINT((GHIDRA_INT((g_game->_playerManager)._playerList._end) - GHIDRA_INT((playerManager->_playerList)._begin) >> 2))); } } LAB_005294e4: timeNs = GetTimeNs(); uVar7 = GHIDRA_UINT((timeNs >> 0x20)); lVar2 = (timeNs & 0xffffffff) * 0x431bde82; local_104 = GHIDRA_UINT(((uint64_t)lVar2 >> 0x20)); lVar3 = (uint64_t)uVar7 * 0x431bde82; local_108 = GHIDRA_UINT(lVar3); lVar4 = (uint64_t)uVar7 * 0xd7b634db + ((timeNs & 0xffffffff) * 0xd7b634db >> 0x20); local_d4.y = (float)(lVar4 + lVar2); lVar3 = lVar3 + (uint64_t) CONCAT14(CARRY4(GHIDRA_UINT(((uint64_t)lVar4 >> 0x20)), local_104 + CARRY4(GHIDRA_UINT(lVar2),GHIDRA_UINT(lVar4))), GHIDRA_INT(((uint64_t)(lVar4 + lVar2) >> 0x20))); uVar8 = GHIDRA_UINT(((uint64_t)lVar3 >> 0x20)); fVar16 = (float)(GHIDRA_UINT(lVar3) >> 0x12 | uVar8 * 0x4000); uVar7 = GHIDRA_INT(fVar16) - GHIDRA_INT(local_10c); bVar15 = CARRY4(GHIDRA_UINT(g_entitySpawnTimeMs),uVar7); (*GHIDRA_CAST((GHIDRA_CAST(&(g_entitySpawnTimeMs)) + 0x0))) = GHIDRA_UINT(g_entitySpawnTimeMs) + uVar7; (*GHIDRA_CAST((GHIDRA_CAST(&(g_entitySpawnTimeMs)) + 0x4))) = (*GHIDRA_CAST((GHIDRA_CAST(&(g_entitySpawnTimeMs)) + 0x4))) + (((uVar8 >> 0x12) - local_e0) - GHIDRA_UINT((GHIDRA_UINT(fVar16) < GHIDRA_UINT(local_10c)))) + GHIDRA_UINT(bVar15); LAB_00529568: bloodVel[0].x = spawnVelX * 0.4; bloodVel[0].y = (float)local_118 * 0.4; iVar10 = GHIDRA_INT(owner[1]._pendingDamageFlags) * -7 + 0x42; *GHIDRA_CAST((local_120 + 1)) = iVar10; *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST(&(local_120[1])) + 0x4)))) = iVar10; uVar7 = Random(); pEVar11 = Game::Spawn(g_game,1000,2,&spawnPos,bloodVel,GHIDRA_CAST(0x0),1,uVar7); (**(code **)(*GHIDRA_CAST(pEVar11) + 0x3c))(&DAT_00c5c800,0xffffffff,0xff); (pEVar11->_sprite)._offset.x = 0.0; (pEVar11->_sprite)._offset.y = -5.0; pEVar11->_renderDepthOffset = 10.0; uVar7 = Random(); local_11c = GHIDRA_CAST(((uVar7 & 1) + 1)); do { if (local_11c == GHIDRA_CAST(0x0)) { return; } uVar7 = Random(); fVar16 = (float)((double)GHIDRA_INT(uVar7) + __uint_to_double_fixup[-(GHIDRA_INT(uVar7) >> 0x1f)]) * 2.3283064e-10 * 3.14; local_f4 = GHIDRA_CAST((fVar16 + fVar16)); fVar16 = cos((float)local_f4); local_d4.x = fVar16 * 12.0 * 0.5 + spawnVelX; fVar16 = sin((float)local_f4); local_d4.y = fVar16 * 12.0 * 0.5 + fStack_fc; uVar7 = Random(); fVar16 = (float)((double)GHIDRA_INT(uVar7) + __uint_to_double_fixup[-(GHIDRA_INT(uVar7) >> 0x1f)]) * 2.3283064e-10 * 3.14; fVar16 = fVar16 + fVar16; uVar7 = Random(); local_114 = (float)((double)GHIDRA_INT(uVar7) + __uint_to_double_fixup[-(GHIDRA_INT(uVar7) >> 0x1f)]) * 2.3283064e-10 * 4.0 + 2.0; fVar17 = cos(fVar16); pvStack_c4 = (void *)(fVar17 * local_114); particleVel.x = (float)pvStack_c4; local_10c = sin(fVar16); local_10c = local_10c * local_114; particleVel.y = local_10c; local_104 = Random(); local_f4 = g_game; piVar9 = GHIDRA_CAST(0x0); local_124 = 7.00649e-45; local_120 = GHIDRA_CAST(0x3e8); lua_callback_run_pre_entity_spawn (GHIDRA_CAST(&local_120),GHIDRA_CAST(&local_124),&local_d4,&particleVel,GHIDRA_CAST(0x0), GHIDRA_CAST((apiStack_bc + -0x1f)),&local_104); fVar16 = local_124; if (1 < *GHIDRA_CAST(&g_game->_deathmatchManager)) { piVar1 = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST(&((g_game->_deathmatchManager))) + 0xc)))); uVar7 = Random(); uStack_6c = 5; local_68 = 9; local_114 = 9.80909e-45; uStack_64 = 7; if (local_120 == GHIDRA_CAST(&DAT_00000005)) { if (GHIDRA_UINT(fVar16) < 0x12d) { if (fVar16 == 4.2039e-43) { while ((piVar9 == GHIDRA_CAST(0x0) || (cVar6 = (**(code **)(*piVar1 + 0x24))(piVar9), cVar6 != '\0'))) { if (uVar7 == 0) { KAGE_LogMessage(0x10,GHIDRA_CAST("RNG Seed is zero!\n")); fnPtr = (code *)swi(3); (*fnPtr)(); return; } uVar7 = uVar7 >> ((uint8_t)uStack_6c & 0x1f) ^ uVar7; uVar7 = uVar7 << ((uint8_t)local_68 & 0x1f) ^ uVar7; uVar7 = uVar7 >> (SUB41(local_114,0) & 0x1f) ^ uVar7; iVar10 = ItemPool::GetCardEx(uVar7,0x19,10,10,1); (*GHIDRA_CAST((GHIDRA_CAST(&(auStack_30)) + 0x4))) = 5; iStack_28 = 9; iStack_24 = 7; (*GHIDRA_CAST((GHIDRA_CAST(&(auStack_30)) + 0x0))) = uVar7; piVar9 = GHIDRA_CAST(lua_callback_run_get_card(GHIDRA_CAST(auStack_30),iVar10,1,1,0)); } } else { if (fVar16 == 9.80909e-44) { uVar8 = GHIDRA_UINT(piVar9) >> 0xb; do { if (piVar9 != GHIDRA_CAST(0x0)) { fnPtr = *(code **)(*piVar1 + 0x28); iVar10 = ItemPool::GetPillEffect (&g_game->_itemPool,GHIDRA_UINT(piVar9),GHIDRA_CAST(0x0)); cVar6 = (*fnPtr)(iVar10); if (cVar6 == '\0') goto LAB_00529a2e; } if (uVar7 == 0) { KAGE_LogMessage(0x10,GHIDRA_CAST("RNG Seed is zero!\n")); fnPtr = (code *)swi(3); (*fnPtr)(); return; } uVar7 = uVar7 >> ((uint8_t)uStack_6c & 0x1f) ^ uVar7; uVar7 = uVar7 << ((uint8_t)local_68 & 0x1f) ^ uVar7; uVar7 = uVar7 >> (SUB41(local_114,0) & 0x1f) ^ uVar7; uVar13 = ItemPool::GetPill(uVar7); piVar9 = GHIDRA_CAST((uVar13 | (uVar8 & 1) << 0xb)); } while( true ); } if (fVar16 == 1.4013e-43) { if (piVar9 == GHIDRA_CAST(0x19)) { LAB_00529876: bVar15 = false; } else { local_a4 = piVar9; msvc::set::find_node(auStack_4c,&local_a4); if (((*GHIDRA_CAST((foundNode2 + 0xd)) == '\0') && (*GHIDRA_CAST((foundNode2 + 0x10)) <= GHIDRA_INT(piVar9))) && (foundNode2 != piVar1[8])) goto LAB_00529876; bVar15 = true; } if ((piVar9 == GHIDRA_CAST(0x0)) || (bVar15)) { piVar9 = GHIDRA_CAST((**(code **)(*piVar1 + 0x84))(0)); } } } } else if (fVar16 == 4.90454e-43) { while ((piVar9 == GHIDRA_CAST(0x0) || (cVar6 = (**(code **)(*piVar1 + 0x2c))(piVar9), cVar6 != '\0'))) { piVar9 = GHIDRA_CAST(ItemPool)::GetTrinket(&g_game->_itemPool,0); } } } } LAB_00529a2e: pEVar11 = EntityFactory::Create(local_f4->_entityFactory,GHIDRA_UINT(local_120),0); if (pEVar11 != GHIDRA_CAST(0x0)) { timeNs = GetTimeNs(); uVar7 = GHIDRA_UINT((timeNs >> 0x20)); lVar2 = (timeNs & 0xffffffff) * 0x431bde82; lVar3 = (uint64_t)uVar7 * 0xd7b634db + ((timeNs & 0xffffffff) * 0xd7b634db >> 0x20); local_114 = (float)(lVar3 + lVar2); lVar2 = (uint64_t)uVar7 * 0x431bde82 + (uint64_t) CONCAT14(CARRY4(GHIDRA_UINT(((uint64_t)lVar3 >> 0x20)), GHIDRA_INT(((uint64_t)lVar2 >> 0x20)) + GHIDRA_UINT(CARRY4(GHIDRA_UINT(lVar2),GHIDRA_UINT(lVar3)))), GHIDRA_INT(((uint64_t)(lVar3 + lVar2) >> 0x20))); uStack_cc = GHIDRA_UINT(((uint64_t)lVar2 >> 0x20)); spawnerRef = &pEVar11->_spawnerEntity; uVar7 = GHIDRA_UINT(lVar2) >> 0x12 | uStack_cc * 0x4000; uStack_cc = uStack_cc >> 0x12; pEVar11->_spawnerType = 0; pEVar11->_spawnerVariant = 0; if (*spawnerRef != 0) { apiStack_bc[0] = spawnerRef; msvc::multiset::erase(apiStack_bc); } iVar10 = *GHIDRA_CAST(pEVar11); *spawnerRef = 0; (pEVar11->_pos).x = local_d4.x; (pEVar11->_pos).y = local_d4.y; (pEVar11->_velocity).x = (float)pvStack_c4; (pEVar11->_velocity).y = local_10c; (**(code **)(iVar10 + 4))(local_120,local_124,piVar9,local_104); game = local_f4; pvVar12 = local_f4->_room; iVar10 = *GHIDRA_CAST((GHIDRA_CAST(pvVar12) + 0x1214)); *GHIDRA_CAST((GHIDRA_CAST(pvVar12) + 0x1214)) = iVar10 + 1; pEVar11->_index = iVar10; EntityList::AddEntity(GHIDRA_CAST((GHIDRA_INT(pvVar12) + 0x1218)),pEVar11); isErased = Game::ShouldEraseEnemy(pEVar11); if (isErased != 0) { Entity::RemoveWithPoof(pEVar11,unusedArg_00); } if ((pEVar11->_exists != 0) && ((game->_proceduralItemManager)._proceduralItems._begin != (game->_proceduralItemManager)._proceduralItems._end)) { iStack_84 = pEVar11->_variant; uVar8 = pEVar11->_type; uStack_88 = uVar8; msvc::map::find(&local_118,&uStack_88); if (local_118 == (game->_proceduralItemManager)._spawnTriggerTargets._head) { local_e0 = 0xffffffff; local_e4 = uVar8; piVar9 = GHIDRA_CAST(std)::map::find(local_60,&local_e4); local_118 = (void *)*piVar9; if (local_118 == (game->_proceduralItemManager)._spawnTriggerTargets._head) goto LAB_00529ca4; } uVar8 = 0; playerManager = &g_game->_playerManager; if (GHIDRA_INT((g_game->_playerManager)._playerList._end) - GHIDRA_INT((playerManager->_playerList)._begin) >> 2 != 0) { do { pvVar12 = (playerManager->_playerList)._end; if (GHIDRA_INT(pvVar12) - GHIDRA_INT((playerManager->_playerList)._begin) >> 2 == 0) { KAGE_LogMessage(0x10,GHIDRA_CAST("PlayerManager::GetPlayer() : There are no players! \n")); pvVar12 = (playerManager->_playerList)._end; } piVar9 = (playerManager->_playerList)._begin; if (uVar8 < GHIDRA_UINT((GHIDRA_INT(pvVar12) - GHIDRA_INT(piVar9) >> 2))) { piVar9 = piVar9 + uVar8; } trigger_set_dispatch((void *)(*piVar9 + 0x1fc8),6,pEVar11,&local_d4,&particleVel); uVar8 = uVar8 + 1; playerManager = &g_game->_playerManager; } while (uVar8 < GHIDRA_UINT((GHIDRA_INT((g_game->_playerManager)._playerList._end) - GHIDRA_INT((playerManager->_playerList)._begin) >> 2))); } } LAB_00529ca4: timeNs = GetTimeNs(); uVar8 = GHIDRA_UINT((timeNs >> 0x20)); lVar2 = (timeNs & 0xffffffff) * 0x431bde82; pvStack_c4 = (void *)((uint64_t)lVar2 >> 0x20); lVar3 = (uint64_t)uVar8 * 0x431bde82; local_10c = (float)lVar3; lVar4 = (uint64_t)uVar8 * 0xd7b634db + ((timeNs & 0xffffffff) * 0xd7b634db >> 0x20); local_f4 = GHIDRA_CAST((lVar4 + lVar2)); lVar3 = lVar3 + (uint64_t) CONCAT14(CARRY4(GHIDRA_UINT(((uint64_t)lVar4 >> 0x20)), GHIDRA_INT(pvStack_c4) + GHIDRA_UINT(CARRY4(GHIDRA_UINT(lVar2),GHIDRA_UINT(lVar4)))), GHIDRA_INT(((uint64_t)(lVar4 + lVar2) >> 0x20))); uVar14 = GHIDRA_UINT(((uint64_t)lVar3 >> 0x20)); uVar8 = GHIDRA_UINT(lVar3) >> 0x12 | uVar14 * 0x4000; uVar13 = uVar8 - uVar7; bVar15 = CARRY4(GHIDRA_UINT(g_entitySpawnTimeMs),uVar13); (*GHIDRA_CAST((GHIDRA_CAST(&(g_entitySpawnTimeMs)) + 0x0))) = GHIDRA_UINT(g_entitySpawnTimeMs) + uVar13; (*GHIDRA_CAST((GHIDRA_CAST(&(g_entitySpawnTimeMs)) + 0x4))) = (*GHIDRA_CAST((GHIDRA_CAST(&(g_entitySpawnTimeMs)) + 0x4))) + (((uVar14 >> 0x12) - uStack_cc) - GHIDRA_UINT((uVar8 < uVar7))) + GHIDRA_UINT(bVar15); } (**(code **)(*GHIDRA_CAST(pEVar11) + 0x3c))(&DAT_00c5c800,0xffffffff,0xff,0,1); spriteColor = &(pEVar11->_sprite)._color; if (&pEVar11->_splatColor != spriteColor) { fVar16 = (pEVar11->_sprite)._color._tint[1]; fVar17 = (pEVar11->_sprite)._color._tint[2]; fVar5 = (pEVar11->_sprite)._color._tint[3]; (pEVar11->_splatColor)._tint[0] = spriteColor->_tint[0]; (pEVar11->_splatColor)._tint[1] = fVar16; (pEVar11->_splatColor)._tint[2] = fVar17; (pEVar11->_splatColor)._tint[3] = fVar5; fVar16 = (pEVar11->_sprite)._color._colorize[1]; fVar17 = (pEVar11->_sprite)._color._colorize[2]; fVar5 = (pEVar11->_sprite)._color._colorize[3]; (pEVar11->_splatColor)._colorize[0] = (pEVar11->_sprite)._color._colorize[0]; (pEVar11->_splatColor)._colorize[1] = fVar16; (pEVar11->_splatColor)._colorize[2] = fVar17; (pEVar11->_splatColor)._colorize[3] = fVar5; *GHIDRA_CAST((pEVar11->_splatColor)._offset) = *GHIDRA_CAST((pEVar11->_sprite)._color._offset); (pEVar11->_splatColor)._offset[2] = (pEVar11->_sprite)._color._offset[2]; } (**(code **)(*GHIDRA_CAST(pEVar11) + 0xc))(); local_11c = GHIDRA_CAST((GHIDRA_INT(local_11c) + -1)); } while( true ); } // 005441e0 uint8_t NpcHelper::tarboy_is_creep_near(Entity_NPC *npc, Vector *position) { int iVar1; uint32_t i; int *entityIt; float deltaY; float deltaX; uint32_t entityCount; bool isFriendly; if ((npc == GHIDRA_CAST(0x0)) || ((npc->_flags & 0x20000000) == 0)) { isFriendly = false; } else { isFriendly = true; } i = 0; entityCount = *GHIDRA_CAST((GHIDRA_CAST(g_game->_room) + 0x1264)); if (entityCount != 0) { entityIt = *GHIDRA_CAST((GHIDRA_CAST(g_game->_room) + 0x125c)); do { iVar1 = *entityIt; if ((*GHIDRA_CAST((iVar1 + 0x28)) == 1000) && (((*GHIDRA_CAST((iVar1 + 0x2c)) == 0x1a || ((isFriendly && (*GHIDRA_CAST((iVar1 + 0x2c)) == 0x2d)))) && (deltaX = position->x - *GHIDRA_CAST((iVar1 + 0x33c)), deltaY = position->y - *GHIDRA_CAST((iVar1 + 0x340)), deltaX * deltaX + deltaY * deltaY < 676.0)))) { return 1; } i = i + 1; entityIt = entityIt + 1; } while (i < entityCount); } return 0; } // 0055d070 uint8_t NpcHelper::polty_target_set(int gridIndex) { if (((gridIndex < 0) || (0x1bf < gridIndex)) || (*GHIDRA_CAST((GHIDRA_CAST(g_game->_room) + gridIndex * 2 + 0xe6c)) < 1)) { *GHIDRA_CAST((GHIDRA_CAST(this) + 0xbc4)) = gridIndex; return 1; } return 0; } // 0055d0b0 uint8_t NpcHelper::polty_is_target_liftable(Entity_NPC *npc) { uint8_t local_AL_113; int extraout_EDX; float snapY; int gridWidth; Room *room; gridWidth = npc->_spawnerEntity; if ((gridWidth == 0) || (*GHIDRA_CAST((gridWidth + 0x28)) != 5)) { if (npc->_i2 < 0) { return 0; } room = g_game->_room; local_AL_113 = Room::CanPickupGridEntity(room,npc->_i2); if (local_AL_113 == 0) { return 0; } if (npc->_variant == 1) { return 1; } gridWidth = room->_gridWidth; snapY = (float)(extraout_EDX / gridWidth) * 40.0 + 120.0; (npc->_pos).x = (float)(extraout_EDX % gridWidth) * 40.0 + 40.0; } else { snapY = *GHIDRA_CAST((gridWidth + 0x340)); (npc->_pos).x = *GHIDRA_CAST((gridWidth + 0x33c)); } (npc->_pos).y = snapY; (npc->_velocity).x = g_vectorZero.x; (npc->_velocity).y = g_vectorZero.y; return 1; } // 0055d180 uint8_t NpcHelper::polty_is_pot_cell(Entity_NPC *npc, int gridIndex) { uint8_t bVar1; Game *game; int gridWidth; game = g_game; if (GHIDRA_UINT(gridIndex) < 0x1c0) { gridWidth = *GHIDRA_CAST((GHIDRA_CAST(g_game->_room) + gridIndex * 4 + 0x24)); if ((gridWidth != 0) && (((*GHIDRA_CAST((gridWidth + 4)) == 6 || (*GHIDRA_CAST((gridWidth + 4)) == 0x1a)) && (*GHIDRA_CAST((gridWidth + 0xc)) == 1)))) { bVar1 = polty_target_set(npc,gridIndex); if (bVar1 != 0) { gridWidth = *GHIDRA_CAST((GHIDRA_CAST(game->_room) + 0xc)); (npc->_pos).x = (float)(gridIndex % gridWidth) * 40.0 + 40.0; (npc->_pos).y = (float)(gridIndex / gridWidth) * 40.0 + 120.0; return 1; } } } return 0; } // 005688c0 void NpcHelper::mother_set_collision_class(Entity_NPC *npc, int collisionClass) { uint32_t dequeBlock; uint32_t dequeBlockSlot; uint32_t dequeOffset; npc->_entityCollisionClass = collisionClass; if (npc->_subtype == 0) { dequeOffset = (npc->_entityDeque)._offset; dequeBlockSlot = dequeOffset + 1 & 3; dequeBlock = dequeOffset + 1 >> 2; if (*GHIDRA_CAST((*GHIDRA_CAST((GHIDRA_INT((npc->_entityDeque)._map) + ((npc->_entityDeque)._mapSize - 1 & dequeBlock) * 4)) + dequeBlockSlot * 4)) != 0) { *GHIDRA_CAST((*GHIDRA_CAST((*GHIDRA_CAST((GHIDRA_INT((npc->_entityDeque)._map) + ((npc->_entityDeque)._mapSize - 1 & dequeBlock) * 4)) + dequeBlockSlot * 4)) + 0x188)) = collisionClass; dequeOffset = (npc->_entityDeque)._offset; } dequeBlock = dequeOffset + 2 >> 2; dequeOffset = dequeOffset + 2 & 3; if (*GHIDRA_CAST((*GHIDRA_CAST((GHIDRA_INT((npc->_entityDeque)._map) + ((npc->_entityDeque)._mapSize - 1 & dequeBlock) * 4)) + dequeOffset * 4)) != 0) { *GHIDRA_CAST((*GHIDRA_CAST((*GHIDRA_CAST((GHIDRA_INT((npc->_entityDeque)._map) + ((npc->_entityDeque)._mapSize - 1 & dequeBlock) * 4)) + dequeOffset * 4)) + 0x188)) = collisionClass; } } return; } // 00568cc0 void NpcHelper::mother_spawn_parts() { uint32_t uVar1; uint32_t uVar2; Entity *pEVar3; Entity_NPC *npc; Entity *part2; Entity *in_ECX; uint32_t blockSlot; uint32_t *childRef; float offsetY; Vector part3Pos; Vector part2Pos; Vector part1Pos; Entity_NPC *local_24; float local_20; Entity_NPC *local_1c; int *local_18; Entity *local_14; int dequeBlock; uint64_t flags; part1Pos.x = DAT_00c33d3c + (in_ECX->_pos).x; part1Pos.y = DAT_00c33d40 + (in_ECX->_pos).y; npc = GHIDRA_CAST(Game)::Spawn(g_game,0x390,0,&part1Pos,&g_vectorZero,in_ECX,1,in_ECX->_initSeed) ; offsetY = (in_ECX->_posOffset).y - DAT_00c33d40; (npc->_posOffset).x = (in_ECX->_posOffset).x - DAT_00c33d3c; (npc->_posOffset).y = offsetY; local_24 = npc; mother_set_collision_class(npc,0); uVar1 = *GHIDRA_CAST((GHIDRA_INT(&npc->_flags) + 4)); npc->_isInvicible = 1; *GHIDRA_CAST(&npc->_flags) = GHIDRA_UINT(npc->_flags) & 0xfffffffb | 0x80100011; *GHIDRA_CAST((GHIDRA_INT(&npc->_flags) + 4)) = uVar1; Entity::SetVisibleFlag(GHIDRA_CAST(npc),0); if (npc->_parent != 0) { local_14 = GHIDRA_CAST(&npc->_parent); msvc::multiset::erase(&local_14); } npc->_parent = in_ECX; msvc::multiset::insert(&npc->_parent); (**(code **)(*GHIDRA_CAST(npc) + 0xc))(); part2Pos.x = DAT_00c33d44 + (in_ECX->_pos).x; part2Pos.y = DAT_00c33d48 + (in_ECX->_pos).y; part2 = Game::Spawn(g_game,0x390,0,&part2Pos,&g_vectorZero,in_ECX,2,in_ECX->_initSeed); local_20 = -g_vectorOne.x; local_1c = GHIDRA_CAST(-g_vectorOne.y); local_14 = part2; Entity::SetSize(part2,70.0,(Vector)(CONCAT44(g_vectorOne.y,g_vectorOne.x) ^ 0x8000000080000000),-1 ); offsetY = (in_ECX->_posOffset).y - DAT_00c33d48; (part2->_posOffset).x = (in_ECX->_posOffset).x - DAT_00c33d44; (part2->_posOffset).y = offsetY; if (part2->_parent != 0) { local_18 = &part2->_parent; msvc::multiset::erase(&local_18); } part2->_parent = in_ECX; msvc::multiset::insert(&part2->_parent); flags = part2->_flags; *GHIDRA_CAST((GHIDRA_INT(&part2->_flags) + 4)) = *GHIDRA_CAST((GHIDRA_INT(&part2->_flags) + 4)); *GHIDRA_CAST(&part2->_flags) = GHIDRA_UINT(flags) & 0xfffffffb | 0x80000000; (**(code **)(*GHIDRA_CAST(part2) + 0xc))(); part3Pos.x = DAT_00c33d4c + (in_ECX->_pos).x; part3Pos.y = DAT_00c33d50 + (in_ECX->_pos).y; part2 = Game::Spawn(g_game,0x390,0,&part3Pos,&g_vectorZero,in_ECX,3,in_ECX->_initSeed); local_20 = -g_vectorOne.x; local_1c = GHIDRA_CAST(-g_vectorOne.y); Entity::SetSize(part2,70.0,(Vector)(CONCAT44(g_vectorOne.y,g_vectorOne.x) ^ 0x8000000080000000),-1 ); offsetY = (in_ECX->_posOffset).y - DAT_00c33d50; (part2->_posOffset).x = (in_ECX->_posOffset).x - DAT_00c33d4c; (part2->_posOffset).y = offsetY; if (part2->_parent != 0) { local_18 = &part2->_parent; msvc::multiset::erase(&local_18); } part2->_parent = in_ECX; msvc::multiset::insert(&part2->_parent); flags = part2->_flags; *GHIDRA_CAST((GHIDRA_INT(&part2->_flags) + 4)) = *GHIDRA_CAST((GHIDRA_INT(&part2->_flags) + 4)); *GHIDRA_CAST(&part2->_flags) = GHIDRA_UINT(flags) & 0xfffffffb | 0x80000000; (**(code **)(*GHIDRA_CAST(part2) + 0xc))(); local_18 = GHIDRA_CAST(0x0); msvc::deque::resize(3,&local_18); uVar2 = in_ECX[2]._dropRNG._seed; blockSlot = uVar2 & 3; dequeBlock = *GHIDRA_CAST((in_ECX[2]._minecart + (uVar2 >> 2 & in_ECX[2]._hitEffect - 1) * 4)); local_1c = GHIDRA_CAST((dequeBlock + blockSlot * 4)); if (*GHIDRA_CAST((dequeBlock + blockSlot * 4)) != 0) { local_18 = GHIDRA_CAST(local_1c); msvc::multiset::erase(&local_18); } *GHIDRA_CAST(local_1c) = local_24; msvc::multiset::insert(local_1c); uVar2 = in_ECX[2]._dropRNG._seed + 1; blockSlot = uVar2 & 3; dequeBlock = *GHIDRA_CAST((in_ECX[2]._minecart + (uVar2 >> 2 & in_ECX[2]._hitEffect - 1) * 4)); local_1c = GHIDRA_CAST((dequeBlock + blockSlot * 4)); if (*GHIDRA_CAST((dequeBlock + blockSlot * 4)) != 0) { local_24 = local_1c; msvc::multiset::erase(&local_24); } *GHIDRA_CAST(local_1c) = local_14; msvc::multiset::insert(local_1c); uVar2 = in_ECX[2]._dropRNG._seed + 2; blockSlot = uVar2 & 3; dequeBlock = *GHIDRA_CAST((in_ECX[2]._minecart + (uVar2 >> 2 & in_ECX[2]._hitEffect - 1) * 4)); local_1c = GHIDRA_CAST((dequeBlock + blockSlot * 4)); if (*GHIDRA_CAST((dequeBlock + blockSlot * 4)) != 0) { local_24 = local_1c; msvc::multiset::erase(&local_24); } *GHIDRA_CAST(local_1c) = part2; msvc::multiset::insert(local_1c); local_1c = GHIDRA_CAST(&in_ECX->_child); if (in_ECX->_child != 0) { local_24 = local_1c; msvc::multiset::erase(&local_24); } pEVar3 = local_14; *GHIDRA_CAST(local_1c) = local_14; msvc::multiset::insert(local_1c); childRef = &pEVar3->_child; if (pEVar3->_child != 0) { local_24 = GHIDRA_CAST(childRef); msvc::multiset::erase(&local_24); } *childRef = part2; msvc::multiset::insert(childRef); return; } // 0056c800 void NpcHelper::mother_2_slam_burst(float *param_1) { uint32_t rngResult; Entity *spawnedEffect; uint32_t uVar1; int in_ECX; int iVar2; int iVar3; float fVar4; Vector local_3c; Vector local_34; Vector slamPos; float local_24; float local_20; float local_1c; float local_18; float backDirX; Manager *manager; Room::GetClampedPositionImpl (g_game->_room,&slamPos,GHIDRA_CAST((in_ECX + 0x33c)),10.0,10.0,10.0,10.0); manager = g_manager; local_18 = 1.079e-43; seed_fart_sound_override(GHIDRA_CAST(&local_18)); (GHIDRA_CAST((&manager->_sfxManager)))->SoundEffects::Play(GHIDRA_INT(local_18),1.0,2,0,1.0,0.0); Game::ShakeScreen(g_game,0xc); rngResult = Random(); spawnedEffect = Game::Spawn(g_game,1000,2,&slamPos,&g_vectorZero,GHIDRA_CAST(0x0),4,rngResult); rngResult = Random(); (spawnedEffect->_sprite)._rotation = (float)((double)GHIDRA_INT(rngResult) + __uint_to_double_fixup[-(GHIDRA_INT(rngResult) >> 0x1f)]) * 2.3283064e-10 * 360.0; rngResult = Random(); (spawnedEffect->_posOffset).x = 0.0; (spawnedEffect->_posOffset).y = -10.0 - (float)((double)GHIDRA_INT(rngResult) + __uint_to_double_fixup[-(GHIDRA_INT(rngResult) >> 0x1f)]) * 2.3283064e-10 * 20.0; (**(code **)(*GHIDRA_CAST(spawnedEffect) + 0x3c))(&g_colorGreenSplat,0xffffffff,0xff,0,1); (**(code **)(*GHIDRA_CAST(spawnedEffect) + 0xc))(); local_18 = param_1[1]; backDirX = *param_1; fVar4 = sqrtf(local_18 * local_18 + backDirX * backDirX); if (0.0 < fVar4) { local_18 = local_18 * (1.0 / fVar4); backDirX = backDirX * (1.0 / fVar4); } backDirX = -backDirX; local_18 = -local_18; iVar2 = 0xc; do { iVar3 = iVar2; rngResult = Random(); local_20 = ((float)((double)GHIDRA_INT(rngResult) + __uint_to_double_fixup[-(GHIDRA_INT(rngResult) >> 0x1f)]) * 2.3283064e-10 - 0.5) * 90.0 * 0.017453292; local_1c = cos(local_20); fVar4 = sin(local_20); local_20 = local_18 * local_1c + backDirX * fVar4; local_1c = backDirX * local_1c - local_18 * fVar4; rngResult = Random(); local_24 = (float)((double)GHIDRA_INT(rngResult) + __uint_to_double_fixup[-(GHIDRA_INT(rngResult) >> 0x1f)]) * 2.3283064e-10 * 10.0 + 20.0; rngResult = Random(); fVar4 = (float)((double)GHIDRA_INT(rngResult) + __uint_to_double_fixup[-(GHIDRA_INT(rngResult) >> 0x1f)]) * 2.3283064e-10; local_3c.y = fVar4 * local_20 * 5.0 + slamPos.y; local_3c.x = fVar4 * local_1c * 5.0 + slamPos.x; rngResult = Random(); local_34.x = local_24 * local_1c; local_34.y = local_24 * local_20; spawnedEffect = Game::Spawn(g_game,1000,4,&local_3c,&local_34,GHIDRA_CAST(0x0),0,rngResult); (**(code **)(*GHIDRA_CAST(spawnedEffect) + 0xc))(); iVar2 = iVar3 + -1; } while (iVar2 != 0); iVar3 = iVar3 + 0xb; do { rngResult = Random(); local_24 = ((float)((double)GHIDRA_INT(rngResult) + __uint_to_double_fixup[-(GHIDRA_INT(rngResult) >> 0x1f)]) * 2.3283064e-10 - 0.5) * 90.0 * 0.017453292; local_20 = cos(local_24); fVar4 = sin(local_24); local_1c = local_18 * local_20 + backDirX * fVar4; local_20 = backDirX * local_20 - local_18 * fVar4; rngResult = Random(); local_24 = (float)((double)GHIDRA_INT(rngResult) + __uint_to_double_fixup[-(GHIDRA_INT(rngResult) >> 0x1f)]) * 2.3283064e-10 * 25.0 + 5.0; rngResult = Random(); fVar4 = (float)((double)GHIDRA_INT(rngResult) + __uint_to_double_fixup[-(GHIDRA_INT(rngResult) >> 0x1f)]) * 2.3283064e-10; local_34.y = fVar4 * local_1c * 5.0 + slamPos.y; local_34.x = fVar4 * local_20 * 5.0 + slamPos.x; rngResult = Random(); uVar1 = Random(); if (uVar1 % 5 == 0) { uVar1 = 0; } else { uVar1 = Random(); uVar1 = (~uVar1 & 1) + 3; } local_3c.x = local_24 * local_20; local_3c.y = local_24 * local_1c; spawnedEffect = Game::Spawn(g_game,1000,2,&local_34,&local_3c,GHIDRA_CAST(0x0),uVar1,rngResult); rngResult = Random(); (spawnedEffect->_posOffset).x = 0.0; (spawnedEffect->_posOffset).y = -10.0; iVar2 = *GHIDRA_CAST(spawnedEffect); (spawnedEffect->_sprite)._rotation = (float)((double)GHIDRA_INT(rngResult) + __uint_to_double_fixup[-(GHIDRA_INT(rngResult) >> 0x1f)]) * 2.3283064e-10 * 360.0; (**(code **)(iVar2 + 0x3c))(&g_colorGreenSplat,0xffffffff,0xff,0,1); (**(code **)(*GHIDRA_CAST(spawnedEffect) + 0xc))(); iVar3 = iVar3 + -1; } while (iVar3 != 0); return; } // 0056fcf0 void NpcHelper::mother_render(Entity_NPC *npc, Vector *offset) { ColorMod *pCVar1; ColorMod *pCVar2; uint64_t uVar3; float fVar4; float fVar5; float fVar6; float fVar7; float fVar8; float fVar9; float fVar10; float fVar11; float fVar12; float fVar13; Entity_NPC *colorTarget; int layerId; float pixelScale; double dVar14; double dVar15; uint32_t local_6c [26]; float offsetY; if (npc->_variant == 0) { pixelScale = g_displayPixelRatio * g_screenPointScale; dVar14 = floor((double)(((((npc->_posOffset).x + (npc->_pos).x) - 60.0) * 0.65 + (g_screenWidth - 338.0) * 0.5) * pixelScale + 0.5)); dVar15 = floor((double)(((((npc->_pos).y + (npc->_posOffset).y) - 140.0) * 0.65 + (g_screenHeight - 182.0) * 0.5) * pixelScale + 0.5)); offsetY = offset->y; (npc->_renderPosition).x = (float)dVar14 / pixelScale + offset->x; (npc->_renderPosition).y = (float)dVar15 / pixelScale + offsetY; layerId = npc->_subtype; if ((layerId == 0) || (colorTarget = GHIDRA_CAST(npc->_parent), GHIDRA_CAST(npc->_parent) == GHIDRA_CAST(0x0))) { colorTarget = npc; } pixelScale = (colorTarget->_sprite)._color._tint[0]; fVar4 = (colorTarget->_sprite)._color._tint[1]; fVar5 = (colorTarget->_sprite)._color._tint[2]; fVar6 = (colorTarget->_sprite)._color._tint[3]; offsetY = (colorTarget->_sprite)._color._offset[2]; pCVar1 = &(colorTarget->_sprite)._color; pCVar2 = &(npc->_sprite)._color; fVar7 = (colorTarget->_sprite)._color._colorize[0]; fVar8 = (colorTarget->_sprite)._color._colorize[1]; fVar9 = (colorTarget->_sprite)._color._colorize[2]; fVar10 = (colorTarget->_sprite)._color._colorize[3]; uVar3 = *GHIDRA_CAST((colorTarget->_sprite)._color._offset); if (pCVar1 != pCVar2) { fVar11 = (npc->_sprite)._color._tint[1]; fVar12 = (npc->_sprite)._color._tint[2]; fVar13 = (npc->_sprite)._color._tint[3]; pCVar1->_tint[0] = pCVar2->_tint[0]; (colorTarget->_sprite)._color._tint[1] = fVar11; (colorTarget->_sprite)._color._tint[2] = fVar12; (colorTarget->_sprite)._color._tint[3] = fVar13; fVar11 = (npc->_sprite)._color._colorize[1]; fVar12 = (npc->_sprite)._color._colorize[2]; fVar13 = (npc->_sprite)._color._colorize[3]; (colorTarget->_sprite)._color._colorize[0] = (npc->_sprite)._color._colorize[0]; (colorTarget->_sprite)._color._colorize[1] = fVar11; (colorTarget->_sprite)._color._colorize[2] = fVar12; (colorTarget->_sprite)._color._colorize[3] = fVar13; *GHIDRA_CAST((colorTarget->_sprite)._color._offset) = *GHIDRA_CAST((npc->_sprite)._color._offset); (colorTarget->_sprite)._color._offset[2] = (npc->_sprite)._color._offset[2]; layerId = npc->_subtype; } (GHIDRA_CAST((GHIDRA_CAST(&colorTarget->_sprite))))->Sprite::RenderLayer(layerId,&npc->_renderPosition,&g_vectorZero, &g_vectorZero); if (pCVar1 != GHIDRA_CAST(local_6c)) { pCVar1->_tint[0] = pixelScale; (colorTarget->_sprite)._color._tint[1] = fVar4; (colorTarget->_sprite)._color._tint[2] = fVar5; (colorTarget->_sprite)._color._tint[3] = fVar6; (colorTarget->_sprite)._color._colorize[0] = fVar7; (colorTarget->_sprite)._color._colorize[1] = fVar8; (colorTarget->_sprite)._color._colorize[2] = fVar9; (colorTarget->_sprite)._color._colorize[3] = fVar10; *GHIDRA_CAST((colorTarget->_sprite)._color._offset) = uVar3; (colorTarget->_sprite)._color._offset[2] = offsetY; return; } } else { Entity::Render(GHIDRA_CAST(npc),offset); } return; } // 00572a70 Entity * NpcHelper::clutch_find_farthest_orbital(Entity_NPC *clutch, int unused) { uint64_t qVar1; uint8_t isClutchFriendly; int enemiesData; uint64_t *heapAllocatedBytes; uint8_t extraout_DL; Entity *tmpEntity; uint32_t uVar2; float fVar3; float deltaX; EntityList_EL local_38; uint32_t local_24; float maxDistance; Entity *local_18; void *local_10; uint8_t *puStack_c; uint32_t uStack_8; uStack_8 = 0xffffffff; puStack_c = &LAB_00af1840; local_10 = ExceptionList; ExceptionList = &local_10; local_18 = GHIDRA_CAST(0x0); maxDistance = 0.0; EntityList::QuerySublist(GHIDRA_CAST((GHIDRA_INT(g_game->_room) + 0x1218)),&local_38,0x379,-1,-1,0,0); uVar2 = 0; tmpEntity = GHIDRA_CAST(0x0); if (local_38._size != 0) { enemiesData = (*GHIDRA_CAST((GHIDRA_CAST(&(local_38)) + 0x4))); do { tmpEntity = *GHIDRA_CAST((enemiesData + uVar2 * 4)); if (tmpEntity != GHIDRA_CAST(0x0)) { if (((1 < *GHIDRA_CAST(&g_game->_deathmatchManager)) && (tmpEntity->_type == 1)) || (tmpEntity->_type - 10U < 0x3de)) { local_24 = *GHIDRA_CAST((GHIDRA_INT(&tmpEntity->_flags) + 4)); isClutchFriendly = Entity::IsFriendly(GHIDRA_CAST(clutch)); if (((extraout_DL == isClutchFriendly) && (GHIDRA_CAST(tmpEntity->_parent) == clutch)) && ((tmpEntity != GHIDRA_CAST(clutch->_child) && ((tmpEntity[2]._updateTime != 1.38729e-43 && (fVar3 = (clutch->_pos).y - (tmpEntity->_pos).y, deltaX = (clutch->_pos).x - (tmpEntity->_pos).x, fVar3 = sqrtf(fVar3 * fVar3 + deltaX * deltaX), (tmpEntity->_flags & 0x10) == 0)))))) { enemiesData = (*GHIDRA_CAST((GHIDRA_CAST(&(local_38)) + 0x4))); if (maxDistance < fVar3) { maxDistance = fVar3; local_18 = tmpEntity; } goto LAB_00572bab; } } enemiesData = (*GHIDRA_CAST((GHIDRA_CAST(&(local_38)) + 0x4))); } LAB_00572bab: uVar2 = uVar2 + 1; tmpEntity = local_18; } while (uVar2 < GHIDRA_UINT(local_38._size)); } if ((*GHIDRA_CAST((GHIDRA_CAST(&(local_38)) + 0x0))) == '\0') { if (g_mainHeap == (void *)0x0) { heapAllocatedBytes = &g_allocatedBytesNoHeap; } else { heapAllocatedBytes = GHIDRA_CAST((GHIDRA_INT(g_mainHeap) + 0x30)); } if ((*GHIDRA_CAST((GHIDRA_CAST(&(local_38)) + 0x4))) != 0) { uVar2 = *GHIDRA_CAST(((*GHIDRA_CAST((GHIDRA_CAST(&(local_38)) + 0x4))) + -4)); qVar1 = *heapAllocatedBytes; *GHIDRA_CAST(heapAllocatedBytes) = GHIDRA_UINT(*heapAllocatedBytes) - uVar2; *GHIDRA_CAST((GHIDRA_CAST(heapAllocatedBytes) + 4)) = *GHIDRA_CAST((GHIDRA_CAST(heapAllocatedBytes) + 4)) - GHIDRA_UINT((GHIDRA_UINT(qVar1) < uVar2)); free(GHIDRA_CAST(((*GHIDRA_CAST((GHIDRA_CAST(&(local_38)) + 0x4))) + -4))); } } ExceptionList = local_10; return tmpEntity; } // 00572cc0 void NpcHelper::clutch_spawn_fire(Entity_NPC *npc, Entity *target) { uint32_t uVar1; float fVar2; float fVar3; uint8_t bVar4; uint32_t uVar5; Entity *fire; uint8_t *pbVar6; LayerState *layer; uint32_t angleRoll; char *pcVar7; uint8_t *size; bool bVar8; float fVar9; Vector spawnPos; Vector local_64; ANM2 *local_5c; Entity *local_58; Entity_NPC *local_54; Entity *local_50; uint8_t local_4c [32]; int animPathSize; uint8_t *animPathCapacity; uint32_t local_24; uint8_t *puStack_20; void *local_1c; uint8_t *puStack_18; uint32_t local_14; code *addFlagsFn; ANM2 *fireSprite; uint32_t *parentSlot; puStack_20 = local_4c + 0x48; local_14 = 0xffffffff; puStack_18 = &LAB_00af506d; local_1c = ExceptionList; uVar5 = __security_cookie ^ GHIDRA_UINT((local_4c + 0x3c)); ExceptionList = &local_1c; local_58 = target; uVar1 = *GHIDRA_CAST((GHIDRA_INT(&target->_flags) + 4)); *GHIDRA_CAST(&target->_flags) = GHIDRA_UINT(target->_flags) | 0x10; *GHIDRA_CAST((GHIDRA_INT(&target->_flags) + 4)) = uVar1; addFlagsFn = *(code **)(*GHIDRA_CAST(target) + 0x24); local_54 = npc; local_24 = uVar5; EntityRef::constructor(GHIDRA_CAST(local_4c),GHIDRA_CAST(npc)); (*addFlagsFn)(local_4c,uVar5); uVar5 = Random(); local_64.x = (local_58->_pos).x; local_64.y = (local_58->_pos).y; fire = Game::Spawn(g_game,0x21,0xd,&local_64,&g_vectorZero,GHIDRA_CAST(npc),0,uVar5); animPathSize = 0; fireSprite = &fire->_sprite; animPathCapacity = &DAT_0000000f; (*GHIDRA_CAST((GHIDRA_CAST(&(local_4c)) + 0x10))) = 0.0; local_5c = fireSprite; local_50 = fire; (*GHIDRA_CAST((GHIDRA_CAST(&(local_4c)) + 0x10))) = msvc::_Allocate(0x30); animPathSize = 0x20; animPathCapacity = &DAT_0000002f; builtin_strncpy((*GHIDRA_CAST((GHIDRA_CAST(&(GHIDRA_CAST(local_4c))) + 0x10))),"gfx/009.002_Fire Projectile.anm2",0x21); local_14 = 0; ANM2::Load(fireSprite,GHIDRA_CAST((local_4c + 0x10)),1); local_14 = 0xffffffff; if (&DAT_0000000f < animPathCapacity) { size = animPathCapacity + 1; pcVar7 = (*GHIDRA_CAST((GHIDRA_CAST(&(GHIDRA_CAST(local_4c))) + 0x10))); if (GHIDRA_CAST(0xfff) < size) { pcVar7 = *GHIDRA_CAST(((*GHIDRA_CAST((GHIDRA_CAST(&(local_4c)) + 0x10))) + -4)); size = animPathCapacity + 0x24; if (GHIDRA_CAST(0x1f) < GHIDRA_CAST(((*GHIDRA_CAST((GHIDRA_CAST(&(local_4c)) + 0x10))) + (-4 - GHIDRA_INT(pcVar7))))) { /* WARNING: Subroutine does not return */ _invalid_parameter_noinfo_noreturn(); } } operator_delete(pcVar7,GHIDRA_UINT(size)); } pbVar6 = (fire->_sprite)._animState._animData; if (pbVar6 != GHIDRA_CAST(0x0)) { if (0xf < *GHIDRA_CAST((pbVar6 + 0x14))) { pbVar6 = *GHIDRA_CAST(pbVar6); } pcVar7 = "Flickering"; do { bVar4 = *pbVar6; bVar8 = bVar4 < (uint8_t)*pcVar7; if (bVar4 != *pcVar7) { LAB_00572e46: uVar5 = -GHIDRA_UINT(bVar8) | 1; goto LAB_00572e4b; } if (bVar4 == 0) break; bVar4 = pbVar6[1]; bVar8 = bVar4 < (uint8_t)pcVar7[1]; if (bVar4 != pcVar7[1]) goto LAB_00572e46; pbVar6 = pbVar6 + 2; pcVar7 = pcVar7 + 2; } while (bVar4 != 0); uVar5 = 0; LAB_00572e4b: if ((uVar5 == 0) && ((*GHIDRA_CAST((GHIDRA_INT((fire->_sprite)._animState._animData) + 0x34)) == '\0' || ((fire->_sprite)._animState._isPlaying != 0)))) goto LAB_00572e7c; } bVar4 = ANM2::SetAnimation(fireSprite,GHIDRA_CAST("Flickering"),1); if (bVar4 != 0) { AnimationState::Rewind(&(fire->_sprite)._animState); (fire->_sprite)._animState._isPlaying = 1; } LAB_00572e7c: fireSprite = local_5c; pbVar6 = GHIDRA_CAST(0x0); if ((local_50->_sprite)._layerCount != 0) { do { layer = ANM2::GetLayer(fireSprite,pbVar6); fVar3 = fRam00c34e34; fVar2 = fRam00c34e30; fVar9 = fRam00c34e2c; if (&layer->_color != GHIDRA_CAST(&DAT_00c34e28)) { (layer->_color)._tint[0] = _DAT_00c34e28; (layer->_color)._tint[1] = fVar9; (layer->_color)._tint[2] = fVar2; (layer->_color)._tint[3] = fVar3; fVar3 = fRam00c34e44; fVar2 = fRam00c34e40; fVar9 = fRam00c34e3c; (layer->_color)._colorize[0] = _DAT_00c34e38; (layer->_color)._colorize[1] = fVar9; (layer->_color)._colorize[2] = fVar2; (layer->_color)._colorize[3] = fVar3; *GHIDRA_CAST((layer->_color)._offset) = DAT_00c34e48; (layer->_color)._offset[2] = DAT_00c34e50; } pbVar6 = pbVar6 + 1; } while (pbVar6 < GHIDRA_CAST((local_50->_sprite)._layerCount)); npc = local_54; } (**(code **)(*GHIDRA_CAST(local_50) + 0xc))(); local_50 = GHIDRA_CAST(0x2); do { uVar5 = Random(); local_54 = GHIDRA_CAST((local_58->_pos).x); local_64.y = (local_58->_pos).y; angleRoll = Random(); fVar9 = (float)((double)GHIDRA_INT(angleRoll) + __uint_to_double_fixup[-(GHIDRA_INT(angleRoll) >> 0x1f)]) * 2.3283064e-10 * 3.14; local_5c = GHIDRA_CAST((fVar9 + fVar9)); fVar9 = cos((float)local_5c); spawnPos.x = fVar9 * 10.0 + (float)local_54; fVar9 = sin((float)local_5c); spawnPos.y = fVar9 * 10.0 + local_64.y; local_54 = (Entity_NPC *) Game::Spawn(g_game,0x399,1,&spawnPos,&g_vectorZero,GHIDRA_CAST(npc),0,uVar5); parentSlot = &local_54->_parent; if (local_54->_parent != 0) { local_64.y = (float)parentSlot; msvc::multiset::erase(&local_64.y); } *parentSlot = npc; if (npc != GHIDRA_CAST(0x0)) { msvc::multiset::insert(parentSlot); } uVar5 = Random(); local_50 = GHIDRA_CAST((GHIDRA_INT(local_50) + -1)); (local_54->_v1).x = (float)((double)GHIDRA_INT(uVar5) + __uint_to_double_fixup[-(GHIDRA_INT(uVar5) >> 0x1f)]) * 2.3283064e-10 * 360.0; } while (local_50 != GHIDRA_CAST(0x0)); ExceptionList = local_1c; return; } // 00575a10 void NpcHelper::clutch_render(Entity_NPC *npc, Vector *offset) { LayerState *pLVar1; float *pfVar2; int iVar3; int iVar4; int iVar5; void *layerFrames; int pointSlotOffset; int iVar6; void *animData; int pointIndex; uint32_t pointBlock; uint32_t nextPointBlock; float *nextPoint; float flipSign; float deltaX; float fVar7; double dVar8; double dVar9; int layerOffset; uint32_t nextPointIndex; uint8_t *layerId; float segmentStretch; Vector segmentPos [8]; ANM2 *animation; int *pointDeque; if (npc->_variant == 0) { pLVar1 = ANM2::GetLayer(&npc->_sprite,GHIDRA_CAST(0x1)); if ((0.0 < (pLVar1->_color)._tint[3]) && ((npc->_vectorDeque1)._size != 0)) { pLVar1 = ANM2::GetLayer(&npc->_sprite,GHIDRA_CAST(0x1)); pLVar1->_visible = 1; pLVar1 = ANM2::GetLayer(&npc->_sprite,GHIDRA_CAST(0x2)); layerId = GHIDRA_CAST(0x1); layerOffset = 0x3c; pLVar1->_visible = 1; pointBlock = (npc->_vectorDeque1)._offset; do { pointDeque = (npc->_vectorDeque1)._proxy; nextPointIndex = pointBlock + 3; pointIndex = pointBlock; while( true ) { pointBlock = (npc->_vectorDeque1)._offset; if (((npc->_vectorDeque1)._size - 3) + pointBlock <= GHIDRA_UINT(pointIndex)) break; if (pointDeque == GHIDRA_CAST(0x0)) { iVar3 = 0; } else { iVar3 = *pointDeque; } pointBlock = GHIDRA_UINT(pointIndex) >> 1; pointSlotOffset = (pointIndex & 1U) * 8; pfVar2 = GHIDRA_CAST((*GHIDRA_CAST((*GHIDRA_CAST((iVar3 + 4)) + (*GHIDRA_CAST((iVar3 + 8)) - 1U & pointBlock) * 4)) + pointSlotOffset)) ; if (pointDeque == GHIDRA_CAST(0x0)) { iVar3 = 0; } else { iVar3 = *pointDeque; } nextPointBlock = nextPointIndex >> 1; fVar7 = g_displayPixelRatio * g_screenPointScale; iVar6 = (nextPointIndex & 1) * 8; nextPoint = GHIDRA_CAST((*GHIDRA_CAST((*GHIDRA_CAST((iVar3 + 4)) + (*GHIDRA_CAST((iVar3 + 8)) - 1U & nextPointBlock) * 4)) + iVar6)); dVar8 = floor((double)((((*pfVar2 + *nextPoint) * 0.5 - 60.0) * 0.65 + (g_screenWidth - 338.0) * 0.5) * fVar7 + 0.5)); dVar9 = floor((double)((((pfVar2[1] + nextPoint[1]) * 0.5 - 140.0) * 0.65 + (g_screenHeight - 182.0) * 0.5) * fVar7 + 0.5)); segmentPos[0].x = (float)dVar8 / fVar7 + offset->x; segmentPos[0].y = (float)dVar9 / fVar7 + offset->y; if (pointDeque == GHIDRA_CAST(0x0)) { iVar3 = 0; } else { iVar3 = *pointDeque; } if (pointDeque == GHIDRA_CAST(0x0)) { iVar5 = 0; } else { iVar5 = *pointDeque; } iVar3 = GHIDRA_INT((8.0 - (*GHIDRA_CAST((*GHIDRA_CAST((*GHIDRA_CAST((iVar5 + 4)) + (nextPointIndex + 2 >> 1 & *GHIDRA_CAST((iVar5 + 8)) - 1U) * 4)) + (nextPointIndex + 2 & 1) * 8)) + *GHIDRA_CAST((*GHIDRA_CAST((*GHIDRA_CAST((iVar3 + 4)) + (nextPointIndex - 1 >> 1 & *GHIDRA_CAST((iVar3 + 8)) - 1U ) * 4)) + (nextPointIndex + 1 & 1) * 8))) * 0.5 * 8.0 )); if (iVar3 == 7) { segmentStretch = 1.0; LAB_00575d73: pLVar1 = ANM2::GetLayer(&npc->_sprite,layerId); (pLVar1->_size).x = segmentStretch; (pLVar1->_size).y = 1.0; if ((npc->_sprite)._flipX == 0) { flipSign = 1.0; } else { flipSign = (float)&DAT_bf800000; } if (pointDeque == GHIDRA_CAST(0x0)) { iVar5 = 0; } else { iVar5 = *pointDeque; } pfVar2 = GHIDRA_CAST((*GHIDRA_CAST((*GHIDRA_CAST((iVar5 + 4)) + (*GHIDRA_CAST((iVar5 + 8)) - 1U & nextPointBlock) * 4)) + iVar6)); if (pointDeque == GHIDRA_CAST(0x0)) { iVar6 = 0; } else { iVar6 = *pointDeque; } iVar6 = *GHIDRA_CAST((*GHIDRA_CAST((iVar6 + 4)) + (*GHIDRA_CAST((iVar6 + 8)) - 1U & pointBlock) * 4)); fVar7 = atan2f(pfVar2[1] - *GHIDRA_CAST((iVar6 + 4 + pointSlotOffset)), *pfVar2 - *GHIDRA_CAST((iVar6 + pointSlotOffset))); pLVar1 = ANM2::GetLayer(&npc->_sprite,layerId); pLVar1->_rotation = fVar7 * 57.295776 * flipSign; if ((npc->_sprite)._overlayAnimState._animData != (void *)0x0) { AnimationState::SetFrameFloat(&(npc->_sprite)._overlayAnimState,(float)iVar3); } if ((npc->_sprite)._loaded != 0) { if ((npc->_sprite)._overlayRenderFirst == 0) { animData = (npc->_sprite)._animState._animData; if (((animData != (void *)0x0) && (animation = (npc->_sprite)._animState._animation, GHIDRA_INT(layerId) < animation->_layerCount)) && (iVar3 = *GHIDRA_CAST((layerOffset + GHIDRA_INT(animData))), -1 < iVar3)) { AnimationLayer::RenderFrame (GHIDRA_CAST((iVar3 * 0x10 + *GHIDRA_CAST((GHIDRA_CAST(animData) + 0x18)))), segmentPos, *GHIDRA_CAST((GHIDRA_INT((npc->_sprite)._animState._layerFrames) + iVar3 * 4)), &g_vectorZero,&g_vectorZero,animation); } animData = (npc->_sprite)._overlayAnimState._animData; if (((animData != (void *)0x0) && (animation = (npc->_sprite)._overlayAnimState._animation, GHIDRA_INT(layerId) < animation->_layerCount)) && (iVar3 = *GHIDRA_CAST((layerOffset + GHIDRA_INT(animData))), -1 < iVar3)) { layerFrames = (npc->_sprite)._overlayAnimState._layerFrames; goto LAB_00575ed0; } } else { animData = (npc->_sprite)._overlayAnimState._animData; if (((animData != (void *)0x0) && (animation = (npc->_sprite)._overlayAnimState._animation, GHIDRA_INT(layerId) < animation->_layerCount)) && (iVar3 = *GHIDRA_CAST((layerOffset + GHIDRA_INT(animData))), -1 < iVar3)) { AnimationLayer::RenderFrame (GHIDRA_CAST((iVar3 * 0x10 + *GHIDRA_CAST((GHIDRA_CAST(animData) + 0x18)))), segmentPos, *GHIDRA_CAST((GHIDRA_INT((npc->_sprite)._overlayAnimState._layerFrames) + iVar3 * 4 )),&g_vectorZero,&g_vectorZero,animation); } animData = (npc->_sprite)._animState._animData; if (((animData != (void *)0x0) && (animation = (npc->_sprite)._animState._animation, GHIDRA_INT(layerId) < animation->_layerCount)) && (iVar3 = *GHIDRA_CAST((layerOffset + GHIDRA_INT(animData))), -1 < iVar3)) { layerFrames = (npc->_sprite)._animState._layerFrames; LAB_00575ed0: AnimationLayer::RenderFrame (GHIDRA_CAST((iVar3 * 0x10 + *GHIDRA_CAST((GHIDRA_CAST(animData) + 0x18)))), segmentPos,*GHIDRA_CAST((GHIDRA_CAST(layerFrames) + iVar3 * 4)),&g_vectorZero, &g_vectorZero,animation); } } } pointIndex = pointIndex + 3; nextPointIndex = nextPointIndex + 3; } else { if (pointDeque == GHIDRA_CAST(0x0)) { iVar5 = 0; } else { iVar5 = *pointDeque; } iVar5 = *GHIDRA_CAST((*GHIDRA_CAST((iVar5 + 4)) + (*GHIDRA_CAST((iVar5 + 8)) - 1U & pointBlock) * 4)); if (pointDeque == GHIDRA_CAST(0x0)) { iVar4 = 0; } else { iVar4 = *pointDeque; } pfVar2 = GHIDRA_CAST((*GHIDRA_CAST((*GHIDRA_CAST((iVar4 + 4)) + (*GHIDRA_CAST((iVar4 + 8)) - 1U & nextPointBlock) * 4)) + iVar6)); fVar7 = pfVar2[1] - *GHIDRA_CAST((iVar5 + 4 + pointSlotOffset)); deltaX = *pfVar2 - *GHIDRA_CAST((iVar5 + pointSlotOffset)); fVar7 = sqrtf(fVar7 * fVar7 + deltaX * deltaX); segmentStretch = (fVar7 * 0.5) / (float)(8 - iVar3); if (segmentStretch <= 1.0) { segmentStretch = 1.0; } if (3.0 <= segmentStretch) { segmentStretch = 3.0; } if (iVar3 < 8) goto LAB_00575d73; pointIndex = pointIndex + 3; nextPointIndex = nextPointIndex + 3; } } layerId = layerId + 1; layerOffset = layerOffset + 4; } while (layerOffset < 0x41); pLVar1 = ANM2::GetLayer(&npc->_sprite,GHIDRA_CAST(0x1)); pLVar1->_visible = 0; pLVar1 = ANM2::GetLayer(&npc->_sprite,GHIDRA_CAST(0x2)); pLVar1->_visible = 0; } } Entity::Render(GHIDRA_CAST(npc),offset); return; } // 00576090 void NpcHelper::raglich_pick_target_pos(Entity_NPC *npc, float speed) { float fVar1; float fVar2; uint8_t isInRoom; int gridWidth; uint32_t direction; int row; int iVar3; Vector probePos; Vector clampedPos; Vector local_24; Vector local_1c; Vector local_14; Vector local_c; Game *game; Vector *minResult; Room *room; direction = *GHIDRA_CAST((GHIDRA_INT(&npc->_i1) + 2)) + 4 + GHIDRA_INT((short)npc->_i1) & 0x80000003; if (GHIDRA_INT(direction) < 0) { direction = (direction - 1 | 0xfffffffc) + 1; } local_c.y = speed; Isaac::GetAxisAlignedUnitVectorFromDir(&local_24,direction); Isaac::GetAxisAlignedUnitVectorFromDir(&local_1c,GHIDRA_INT((short)npc->_i1)); game = g_game; fVar1 = (npc->_v1).y; fVar2 = npc->_speedMultiplier; local_14.y = ((npc->_pos).y - (npc->_targetPosition).y) * local_1c.y + ((npc->_pos).x - (npc->_targetPosition).x) * local_1c.x; local_14.x = local_1c.x * local_14.y; local_14.y = local_1c.y * local_14.y; (npc->_velocity).x = ((local_24.x * local_c.y + 0.0) - local_14.x * 0.1) * fVar1 * fVar2 + (npc->_velocity).x; (npc->_velocity).y = ((local_24.y * local_c.y + 0.0) - local_14.y * 0.1) * fVar1 * fVar2 + (npc->_velocity).y; room = game->_room; local_14.x = (npc->_pos).x - local_14.x; local_14.y = (npc->_pos).y - local_14.y; Room::GetClampedPositionImpl(room,&clampedPos,&local_14,10.0,10.0,10.0,10.0); local_14.y = local_24.x * 40.0; local_24.y = local_24.y * 40.0; local_c.x = clampedPos.x + local_14.y; local_c.y = clampedPos.y + local_24.y; isInRoom = Room::IsPositionInRoom(room,&local_c,0.0); if (isInRoom == 0) { direction = (GHIDRA_INT((short)npc->_i1) - GHIDRA_INT(*GHIDRA_CAST((GHIDRA_INT(&npc->_i1) + 2)))) + 4U & 0x80000003; if (GHIDRA_INT(direction) < 0) { direction = (direction - 1 | 0xfffffffc) + 1; } *GHIDRA_CAST(&npc->_i1) = (short)direction; iVar3 = GHIDRA_INT(((clampedPos.x - 40.0) / 40.0 + 0.5)); row = GHIDRA_INT(((clampedPos.y - 120.0) / 40.0 + 0.5)); if ((((iVar3 < 0) || (gridWidth = room->_gridWidth, gridWidth <= iVar3)) || (row < 0)) || (room->_gridHeight <= row)) { gridWidth = room->_gridWidth; iVar3 = -1; } else { iVar3 = gridWidth * row + iVar3; } row = iVar3 / gridWidth; iVar3 = iVar3 % gridWidth; } else { if (3 < *GHIDRA_CAST((*GHIDRA_CAST((*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((room)) + 0x4)))) + 0x10)) + 0x48)) - 9U) goto LAB_00576404; probePos.x = clampedPos.x - local_1c.x * 40.0; probePos.y = clampedPos.y - local_1c.y * 40.0; local_1c.y = probePos.y; local_c.y = probePos.x; isInRoom = Room::IsPositionInRoom(room,&probePos,0.0); if (isInRoom == 0) goto LAB_00576404; probePos.x = local_c.y - local_14.y; probePos.y = local_1c.y - local_24.y; isInRoom = Room::IsPositionInRoom(room,&probePos,0.0); if (isInRoom != 0) goto LAB_00576404; direction = (short)npc->_i1 + 4 + GHIDRA_INT(*GHIDRA_CAST((GHIDRA_INT(&npc->_i1) + 2))) & 0x80000003; if (GHIDRA_INT(direction) < 0) { direction = (direction - 1 | 0xfffffffc) + 1; } *GHIDRA_CAST(&npc->_i1) = (short)direction; iVar3 = Room::GetGridIndex(room,&clampedPos); row = iVar3 / room->_gridWidth; iVar3 = iVar3 % room->_gridWidth; } (npc->_targetPosition).y = (float)row * 40.0 + 120.0; (npc->_targetPosition).x = (float)iVar3 * 40.0 + 40.0; LAB_00576404: local_1c.y = 1.0; local_24.y = npc->_speedMultiplier * 0.1 + (npc->_v1).y; minResult = &local_24; if (1.0 <= local_24.y) { minResult = &local_1c; } (npc->_v1).y = minResult->y; return; } // 00576450 void NpcHelper::raglich_slam_spawn_grid(Entity_NPC *npc) { uint8_t bVar1; uint32_t uVar2; int gridX; GridEntity *pit; uint8_t *animNameChar; int gridY; uint8_t *wantedAnimChar; int gridIndex; bool isLess; Vector particlePos; Vector rightDamagePos; Vector local_68; int gridYCopy; uint32_t gridSeed; Vector local_58; int column; void *room; Vector slamOffset; ColorMod particleColor; uint32_t local_14; void *local_10; uint8_t *puStack_c; float local_8; uint8_t *animData; uint64_t flags; int *gridAtIndex; uint32_t *oldGrid; float posY; float targetY; local_8 = -NAN; puStack_c = &LAB_00af5157; local_10 = ExceptionList; uVar2 = __security_cookie ^ GHIDRA_UINT((&particleColor)[1]._colorize); local_14 = uVar2; if (npc->_state != 0) { if (npc->_state != 3) { return; } ExceptionList = &local_10; npc->_friction = 0.5; targetY = (npc->_targetPosition).y; posY = (npc->_pos).y; (npc->_velocity).x = (npc->_targetPosition).x - (npc->_pos).x; (npc->_velocity).y = targetY - posY; Entity::GetNullOffset(GHIDRA_CAST(npc),&slamOffset,&DAT_00b1d3b0); if ((slamOffset.x != g_vectorZero.x) || (slamOffset.y != g_vectorZero.y)) { if (npc->_i1 == 0) { npc->_i1 = 1; Entity_NPC::PlaySound(npc,0x34,1.0,2,0,1.0); Game::ShakeScreen(g_game,0xe); } local_68.x = slamOffset.x + (npc->_pos).x; local_68.y = slamOffset.y + (npc->_pos).y; Game::BombDamage(g_game,&local_68,10.0,20.0,0,GHIDRA_CAST(npc),(BitSet128)ZEXT816(0),0x1000000,0) ; local_58.x = slamOffset.x + ((npc->_pos).x - 40.0); local_58.y = slamOffset.y + (npc->_pos).y + 0.0; Game::BombDamage(g_game,&local_58,10.0,20.0,0,GHIDRA_CAST(npc),(BitSet128)ZEXT816(0),0x1000000,0) ; rightDamagePos.x = slamOffset.x + (npc->_pos).x + 40.0; rightDamagePos.y = slamOffset.y + (npc->_pos).y + 0.0; Game::BombDamage(g_game,&rightDamagePos,10.0,20.0,0,GHIDRA_CAST(npc),(BitSet128)ZEXT816(0), 0x1000000,0); gridX = GHIDRA_INT((((slamOffset.x + (npc->_pos).x) - 40.0) / 40.0 + 0.5)); gridY = GHIDRA_INT((((slamOffset.y + (npc->_pos).y) - 120.0) / 40.0 + 0.5)); column = gridX + -1; local_58.y = (float)(gridX + 1); gridYCopy = gridY; if (column <= GHIDRA_INT(local_58.y)) { do { gridX = column; room = g_game->_room; if ((((-1 < column) && (column < *GHIDRA_CAST((GHIDRA_CAST(room) + 0xc)))) && (-1 < gridY)) && ((gridY < *GHIDRA_CAST((GHIDRA_CAST(room) + 0x10)) && (gridIndex = *GHIDRA_CAST((GHIDRA_CAST(room) + 0xc)) * gridY + column, -1 < gridIndex)))) { gridSeed = Random(); if (gridIndex < 0x1c0) { if (*GHIDRA_CAST((GHIDRA_CAST(room) + gridIndex * 4 + 0x76c)) < 0x385) { pit = operator_new(0x158); local_8 = 8.40779e-45; local_68.y = (float)pit; if (pit == GHIDRA_CAST(0x0)) { pit = GHIDRA_CAST(0x0); } else { GridEntity::GridEntity(pit); *GHIDRA_CAST(pit) = IsaacRepentancePlus::GridEntity_Pit::vftable; } local_8 = -NAN; if (pit != GHIDRA_CAST(0x0)) { *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((pit)) + 0x4)))) = 7; pit->_gridIndex = gridIndex; oldGrid = *GHIDRA_CAST((GHIDRA_CAST(room) + gridIndex * 4 + 0x24)); if (oldGrid != GHIDRA_CAST(0x0)) { (**(code **)*oldGrid)(1); } *GHIDRA_CAST((GHIDRA_CAST(room) + gridIndex * 4 + 0x24)) = pit; *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((pit)) + 0x8)))) = 0; pit->_varData = 0; GridEntity::Init(pit,gridSeed); } gridX = column; } gridAtIndex = *GHIDRA_CAST((GHIDRA_CAST(g_game->_room) + gridIndex * 4 + 0x24)); if ((gridAtIndex != GHIDRA_CAST(0x0)) && (gridAtIndex[1] == 7)) { (**(code **)(*gridAtIndex + 4))(); } } else { KAGE_LogMessage(0x10,GHIDRA_CAST("SpawnGridEntity: Grid index invalid\n")); } particleColor._tint[0] = 1.0; particleColor._tint[1] = 1.0; particleColor._tint[2] = 1.0; particleColor._tint[3] = 1.0; particleColor._offset[0] = 0.0; particleColor._offset[1] = 0.0; particleColor._colorize[0] = 0.0; particleColor._colorize[1] = 0.0; particleColor._colorize[2] = 0.0; particleColor._colorize[3] = 0.0; particlePos.x = slamOffset.x + (npc->_pos).x; particlePos.y = slamOffset.y + (npc->_pos).y; particleColor._offset[2] = 0.0; Game::SpawnParticles(g_game,&particlePos,4,4,6.0,&particleColor,100000.0,0); gridY = gridYCopy; } column = gridX + 1; } while (column <= GHIDRA_INT(local_58.y)); } } if (((npc->_sprite)._animState._animData == (void *)0x0) || ((npc->_sprite)._animState._isPlaying == 0)) { (**(code **)(*GHIDRA_CAST(npc) + 0x28))(uVar2); ExceptionList = local_10; return; } ExceptionList = local_10; return; } animData = (npc->_sprite)._animState._animData; if (animData != GHIDRA_CAST(0x0)) { animNameChar = animData; if (0xf < *GHIDRA_CAST((animData + 0x14))) { animNameChar = *GHIDRA_CAST(animData); } wantedAnimChar = &DAT_00b61c98; do { bVar1 = *animNameChar; isLess = bVar1 < *wantedAnimChar; if (bVar1 != *wantedAnimChar) { LAB_00576910: uVar2 = -GHIDRA_UINT(isLess) | 1; goto LAB_00576915; } if (bVar1 == 0) break; bVar1 = animNameChar[1]; isLess = bVar1 < wantedAnimChar[1]; if (bVar1 != wantedAnimChar[1]) goto LAB_00576910; animNameChar = animNameChar + 2; wantedAnimChar = wantedAnimChar + 2; } while (bVar1 != 0); uVar2 = 0; LAB_00576915: if ((uVar2 == 0) && ((animData[0x34] == 0 || ((npc->_sprite)._animState._isPlaying != 0)))) goto LAB_00576948; } ExceptionList = &local_10; bVar1 = ANM2::SetAnimation(&npc->_sprite,&DAT_00b61c98,1); if (bVar1 != 0) { AnimationState::Rewind(&(npc->_sprite)._animState); (npc->_sprite)._animState._isPlaying = 1; } LAB_00576948: flags = npc->_flags; *GHIDRA_CAST((GHIDRA_INT(&npc->_flags) + 4)) = *GHIDRA_CAST((GHIDRA_INT(&npc->_flags) + 4)); *GHIDRA_CAST(&npc->_flags) = GHIDRA_UINT(flags) & 0xfffffffb | 0xc4000011; npc->_state = 3; (npc->_targetPosition).x = (npc->_pos).x; (npc->_targetPosition).y = (npc->_pos).y; ExceptionList = local_10; return; } // 005785a0 void NpcHelper::rainmaker_drop_timer_launch(Entity_Effect *timer) { int iVar1; int iVar2; uint32_t rngResult; float distance; float fVar3; float distance; float fVar5; float dirY; float dirX; iVar1 = timer->_parent; if (iVar1 == 0) { return; } if (*GHIDRA_CAST((iVar1 + 0x28)) != 9) { return; } distance = timer->_rotation; iVar2 = timer->_target; fVar3 = timer->_scale; *GHIDRA_CAST((iVar1 + 0x43c)) = *GHIDRA_CAST((iVar1 + 0x43c)) & 0xfffffeff; *GHIDRA_CAST((iVar1 + 0x438)) = *GHIDRA_CAST((iVar1 + 0x438)); if (iVar2 == 0) { rngResult = Random(); fVar3 = (float)((double)GHIDRA_INT(rngResult) + __uint_to_double_fixup[-(GHIDRA_INT(rngResult) >> 0x1f)]) * 2.3283064e-10 * 3.14; fVar3 = fVar3 + fVar3; dirX = cos(fVar3); dirY = sin(fVar3); } else { dirX = *GHIDRA_CAST((iVar2 + 0x33c)); dirY = *GHIDRA_CAST((iVar2 + 0x340)); if (fVar3 <= 0.0) { fVar5 = *GHIDRA_CAST((iVar1 + 0x33c)); } else { fVar5 = *GHIDRA_CAST((iVar1 + 0x33c)); distance = *GHIDRA_CAST((iVar1 + 0x340)) - dirY; distance = sqrtf(distance * distance + (fVar5 - dirX) * (fVar5 - dirX)); dirY = dirY + distance * *GHIDRA_CAST((iVar2 + 0x364)) * fVar3; dirX = dirX + distance * *GHIDRA_CAST((iVar2 + 0x360)) * fVar3; } dirY = dirY - *GHIDRA_CAST((iVar1 + 0x340)); dirX = dirX - fVar5; fVar3 = sqrtf(dirX * dirX + dirY * dirY); if (0.0 < fVar3) { dirY = dirY * (1.0 / fVar3); dirX = (1.0 / fVar3) * dirX; } } if (0.0 < distance) { rngResult = Random(); fVar3 = (float)((double)GHIDRA_INT(rngResult) + __uint_to_double_fixup[-(GHIDRA_INT(rngResult) >> 0x1f)]) * 2.3283064e-10; distance = ((fVar3 + fVar3) - 1.0) * distance * 0.017453292; fVar3 = cos(distance); distance = sin(distance); fVar5 = distance * dirX; dirX = fVar3 * dirX - distance * dirY; dirY = fVar5 + fVar3 * dirY; } *GHIDRA_CAST((iVar1 + 0x360)) = dirX * 10.0; *GHIDRA_CAST((iVar1 + 0x364)) = dirY * 10.0; return; } // 00582f60 void NpcHelper::scourge_whip(Entity_NPC *npc) { uint8_t bVar1; uint8_t *animNameCursor; uint32_t uVar2; Entity_NPC *segment; uint8_t *targetNameCursor; uint8_t *anim; bool isLess; Entity_NPC *local_c; float pitch; uint8_t *animData; Manager *manager; Entity_NPC *nextSegment; segment = npc; while (((nextSegment = GHIDRA_CAST(segment->_child), nextSegment != GHIDRA_CAST(0x0) && (nextSegment->_type == 0x38d)) && (nextSegment->_variant == 10))) { segment = nextSegment; } segment->_state = 7; (segment->_targetPosition).x = g_vectorZero.x; (segment->_targetPosition).y = g_vectorZero.y; segment = npc; while (((nextSegment = GHIDRA_CAST(segment->_parent), nextSegment != GHIDRA_CAST(0x0) && (nextSegment->_type == 0x38d)) && (nextSegment->_variant == 10))) { segment = nextSegment; } animData = (segment->_sprite)._animState._animData; anim = &DAT_00b62058; if (npc->_subtype == 0) { anim = &DAT_00b6208c; } local_c = npc; if (animData != GHIDRA_CAST(0x0)) { animNameCursor = animData; if (0xf < *GHIDRA_CAST((animData + 0x14))) { animNameCursor = *GHIDRA_CAST(animData); } targetNameCursor = anim; do { bVar1 = *animNameCursor; isLess = bVar1 < *targetNameCursor; if (bVar1 != *targetNameCursor) { LAB_00583024: uVar2 = -GHIDRA_UINT(isLess) | 1; goto LAB_00583029; } if (bVar1 == 0) break; bVar1 = animNameCursor[1]; isLess = bVar1 < targetNameCursor[1]; if (bVar1 != targetNameCursor[1]) goto LAB_00583024; animNameCursor = animNameCursor + 2; targetNameCursor = targetNameCursor + 2; } while (bVar1 != 0); uVar2 = 0; LAB_00583029: if ((uVar2 == 0) && ((animData[0x34] == 0 || ((segment->_sprite)._animState._isPlaying != 0)))) goto LAB_00583051; } bVar1 = ANM2::SetAnimation(&segment->_sprite,anim,1); if (bVar1 != 0) { AnimationState::Rewind(&(segment->_sprite)._animState); (segment->_sprite)._animState._isPlaying = 1; } LAB_00583051: manager = g_manager; pitch = 1.0; if (local_c->_championColorIdx == 0x12) { pitch = 1.5; } else if (local_c->_championColorIdx == 0x13) { pitch = 0.5; } local_c = GHIDRA_CAST(0x48); seed_fart_sound_override(GHIDRA_CAST(&local_c)); (GHIDRA_CAST((&manager->_sfxManager)))->SoundEffects::Play(GHIDRA_INT(local_c),1.0,2,0,pitch,0.0); return; } // 00587480 void NpcHelper::scourge_chain_shoot() { Entity *pEVar1; uint32_t rngResult; Entity_NPC *in_ECX; int chainEnd; float fVar2; float fVar3; float fVar4; float fVar5; Vector effectPos; Vector projVelocity; float local_ec; float local_e8; Vector shootPos; float local_dc; float soundPitch; float childChainOffsetY; float childChainOffsetX; float local_cc; float local_c8; float local_c4; uint8_t projParams [4]; float fStack_bc; float fStack_b8; float fStack_b4; float fStack_b0; float fStack_ac; float fStack_a8; float fStack_a4; float fStack_a0; float fStack_9c; float fStack_98; float fStack_94; float fStack_90; float fStack_8c; float fStack_88; float fStack_84; float fStack_80; float fStack_7c; float fStack_78; float afStack_74 [2]; float fStack_6c; uint32_t uStack_68; uint32_t uStack_64; float fStack_60; float fStack_5c; float fStack_58; float fStack_54; float fStack_50; float fStack_4c; float fStack_48; int iStack_44; uint64_t qStack_40; float fStack_38; int iStack_34; float fStack_30; int iStack_2c; uint8_t local_28; uint8_t *local_24; uint32_t local_20; uint8_t local_1c; float local_14; Manager *manager; int nextSegment; local_14 = (float)(__security_cookie ^ GHIDRA_UINT((afStack_74 + 0x19))); chainEnd = in_ECX->_child; while (((nextSegment = *GHIDRA_CAST((chainEnd + 0x3c0)), nextSegment != 0 && (*GHIDRA_CAST((nextSegment + 0x28)) == 0x38d)) && (*GHIDRA_CAST((nextSegment + 0x2c)) == 10))) { chainEnd = nextSegment; } local_e8 = (in_ECX->_pos).x; local_ec = (in_ECX->_pos).y; childChainOffsetX = *GHIDRA_CAST((chainEnd + 0x33c)) - local_e8; childChainOffsetY = *GHIDRA_CAST((chainEnd + 0x340)) - local_ec; chainEnd = in_ECX->_entityRef; while (((nextSegment = *GHIDRA_CAST((chainEnd + 0x3c0)), nextSegment != 0 && (*GHIDRA_CAST((nextSegment + 0x28)) == 0x38d)) && (*GHIDRA_CAST((nextSegment + 0x2c)) == 10))) { chainEnd = nextSegment; } local_e8 = *GHIDRA_CAST((chainEnd + 0x33c)) - local_e8; local_ec = *GHIDRA_CAST((chainEnd + 0x340)) - local_ec; pEVar1 = Entity_NPC::GetPlayerTarget(in_ECX); local_c8 = local_e8 - childChainOffsetX; local_cc = (pEVar1->_pos).y - (in_ECX->_pos).y; local_dc = (pEVar1->_pos).x - (in_ECX->_pos).x; local_c4 = local_ec - childChainOffsetY; fVar2 = sqrtf(local_c4 * local_c4 + local_c8 * local_c8); soundPitch = 1.0; fVar3 = local_c8; fVar4 = local_c4; if (0.0 < fVar2) { fVar3 = local_c8 * (1.0 / fVar2); fVar4 = local_c4 * (1.0 / fVar2); } fVar2 = -childChainOffsetY * fVar4 - childChainOffsetX * fVar3; fVar4 = fVar2 * fVar4 + childChainOffsetY; fVar3 = fVar2 * fVar3 + childChainOffsetX; fVar2 = fVar4 * local_cc; local_cc = 0.0; local_dc = (fVar2 + fVar3 * local_dc) / (fVar4 * fVar4 + fVar3 * fVar3); do { fVar3 = local_cc; rngResult = Random(); if (rngResult % 5 == 0) { fVar4 = local_dc; } else { rngResult = Random(); fVar4 = (float)((double)GHIDRA_INT(rngResult) + __uint_to_double_fixup[-(GHIDRA_INT(rngResult) >> 0x1f)]) * 2.3283064e-10; } shootPos.x = (in_ECX->_pos).x; shootPos.y = (in_ECX->_pos).y; fVar2 = childChainOffsetX * fVar4 + shootPos.x; fVar5 = childChainOffsetY * fVar4 + shootPos.y; shootPos.x = local_e8 * fVar4 + shootPos.x; shootPos.y = local_ec * fVar4 + shootPos.y; if (fVar3 == 0.0) { local_c4 = fVar2 - shootPos.x; local_c8 = fVar5 - shootPos.y; } else { local_c4 = shootPos.x - fVar2; local_c8 = shootPos.y - fVar5; shootPos.x = fVar2; shootPos.y = fVar5; } fVar3 = sqrtf(local_c4 * local_c4 + local_c8 * local_c8); if (0.0 < fVar3) { local_c4 = (1.0 / fVar3) * local_c4; local_c8 = local_c8 * (1.0 / fVar3); } projParams[0] = 1; fStack_bc = 0.0; fStack_b8 = 0.0; fStack_b4 = 0.0; fStack_b0 = 1.0; fStack_ac = 1.0; rngResult = Random(); fStack_60 = g_vectorZero.x; fStack_58 = g_vectorZero.x; fStack_50 = g_vectorZero.x; fStack_48 = -1000.0; iStack_44 = 0; fStack_38 = 0.0; iStack_34 = 0x1e; fStack_5c = g_vectorZero.y; fStack_54 = g_vectorZero.y; fStack_4c = g_vectorZero.y; fStack_30 = 0.0; iStack_2c = 0; local_28 = 0; local_24 = &DAT_bf800000; local_20 = 0; local_1c = 0; fStack_6c = DAT_00c34cf0; uStack_68 = 0x2000; fStack_a8 = (float)((double)GHIDRA_INT(rngResult) + __uint_to_double_fixup[-(GHIDRA_INT(rngResult) >> 0x1f)]) * 2.3283064e-10 * 3.1415927; uStack_64 = 0; fStack_a4 = 1.0; fStack_a0 = 0.005; fStack_9c = 1.01; fStack_98 = 1.0; qStack_40 = 0; fStack_bc = fStack_bc + 10.0; fStack_b4 = fStack_b4 - 0.14; fStack_94 = _DAT_00c34cc8; fStack_90 = fRam00c34ccc; fStack_8c = fRam00c34cd0; fStack_88 = fRam00c34cd4; fStack_84 = _DAT_00c34cd8; fStack_80 = fRam00c34cdc; fStack_7c = fRam00c34ce0; fStack_78 = fRam00c34ce4; afStack_74[0] = (float)DAT_00c34ce8; afStack_74[1] = (*GHIDRA_CAST((GHIDRA_CAST(&(DAT_00c34ce8)) + 0x4))); rngResult = Random(); projVelocity.x = (float)((double)GHIDRA_INT(rngResult) + __uint_to_double_fixup[-(GHIDRA_INT(rngResult) >> 0x1f)]) * 2.3283064e-10 + 5.0; projVelocity.y = projVelocity.x * local_c8; projVelocity.x = projVelocity.x * local_c4; Entity_NPC::FireProjectiles(in_ECX,&shootPos,&projVelocity,0,GHIDRA_CAST(projParams)); effectPos.x = local_c4 * 4.0 + shootPos.x; effectPos.y = local_c8 * 4.0 + shootPos.y; rngResult = Random(); pEVar1 = Game::Spawn(g_game,1000,2,&effectPos,&g_vectorZero,GHIDRA_CAST(0x0),1,rngResult); (**(code **)(*GHIDRA_CAST(pEVar1) + 0x3c))(&g_colorGreenSplat,0xffffffff,0xff,0,1); (pEVar1->_sprite)._offset.x = 0.0; (pEVar1->_sprite)._offset.y = -20.0; pEVar1->_renderDepthOffset = 10.0; manager = g_manager; local_cc = (float)(GHIDRA_INT(local_cc) + 1); } while (GHIDRA_INT(local_cc) < 2); if (in_ECX->_championColorIdx == 0x12) { soundPitch = 1.5; } else if (in_ECX->_championColorIdx == 0x13) { soundPitch = 0.5; } local_cc = 2.49431e-43; seed_fart_sound_override(GHIDRA_CAST(&local_cc)); (GHIDRA_CAST((&manager->_sfxManager)))->SoundEffects::Play(GHIDRA_INT(local_cc),1.0,2,0,soundPitch,0.0); return; } // 0058ac10 void NpcHelper::singe_explode_at(Entity_NPC *npc, Vector *position) { int iVar1; uint64_t qVar2; uint32_t uVar3; uint32_t angleRoll; Entity *minion; uint64_t *heapCounter; float fVar4; EntityList_EL minions; EntityList_EL nearby; Vector spawnPos; float angle; float angleSin; ColorMod explosionColor; uint32_t local_18; void *local_10; uint8_t *puStack_c; float local_8; uint32_t flagsHigh; Game *game; local_8 = -NAN; puStack_c = &LAB_00af54e5; local_10 = ExceptionList; local_18 = __security_cookie ^ GHIDRA_UINT(((&explosionColor)[1]._colorize + 1)); ExceptionList = &local_10; explosionColor._offset[0] = 0.0; explosionColor._offset[1] = 0.0; explosionColor._tint[0] = 1.0; explosionColor._tint[1] = 1.0; explosionColor._tint[2] = 1.0; explosionColor._tint[3] = 1.0; explosionColor._offset[2] = 0.0; explosionColor._colorize[0] = 0.0; explosionColor._colorize[1] = 0.0; explosionColor._colorize[2] = 0.0; explosionColor._colorize[3] = 0.0; Game::BombExplosionEffects (g_game,position,60.0,(BitSet128)ZEXT816(0),&explosionColor,GHIDRA_CAST(npc),1.15,1,4,0); Game::ButterBeanFart(g_game,position,120.0,GHIDRA_CAST(npc),0,0); Game::ShakeScreen(g_game,10); game = g_game; npc->_projectileCooldown = npc->_projectileCooldown + 1; EntityList::QueryRadius(GHIDRA_CAST((GHIDRA_INT(game->_room) + 0x1218)),&nearby,position,100.0,8); local_8 = 0.0; uVar3 = 0; if (nearby._size != 0) { do { iVar1 = *GHIDRA_CAST(((*GHIDRA_CAST((GHIDRA_CAST(&(nearby)) + 0x4))) + uVar3 * 4)); if ((*GHIDRA_CAST((iVar1 + 0x28)) == 0x393) && (*GHIDRA_CAST((iVar1 + 0x2c)) == 1)) { npc->_projectileCooldown = 0; break; } uVar3 = uVar3 + 1; } while (uVar3 < GHIDRA_UINT(nearby._size)); } EntityList::QuerySublist(GHIDRA_CAST((GHIDRA_INT(g_game->_room) + 0x1218)),&minions,0x393,1,-1,0,0); local_8 = (float)CONCAT31((*GHIDRA_CAST((GHIDRA_CAST(&(local_8)) + 0x1))),1); if (GHIDRA_UINT(minions._size) < npc->_i1 + 4U) { uVar3 = Random(); angleRoll = Random(); angle = (float)((double)GHIDRA_INT(angleRoll) + __uint_to_double_fixup[-(GHIDRA_INT(angleRoll) >> 0x1f)]) * 2.3283064e-10 * 3.14; angle = angle + angle; angleSin = sin(angle); fVar4 = cos(angle); spawnPos.x = fVar4 * 20.0 + (npc->_pos).x; spawnPos.y = angleSin * 20.0 + (npc->_pos).y; minion = Game::Spawn(g_game,0x393,1,&spawnPos,&g_vectorZero,GHIDRA_CAST(npc),0,uVar3); flagsHigh = *GHIDRA_CAST((GHIDRA_INT(&minion->_flags) + 4)); iVar1 = *GHIDRA_CAST(minion); *GHIDRA_CAST(&minion->_flags) = GHIDRA_UINT(minion->_flags) & 0xfffffffb; *GHIDRA_CAST((GHIDRA_INT(&minion->_flags) + 4)) = flagsHigh; (**(code **)(iVar1 + 0xc))(); iVar1 = *GHIDRA_CAST(minion); minion[2]._speedMultiplier = -500.0; minion[2]._prevVelocity.x = 10.0; (**(code **)(iVar1 + 0xc))(); } if ((*GHIDRA_CAST((GHIDRA_CAST(&(minions)) + 0x0))) == '\0') { heapCounter = GHIDRA_CAST((GHIDRA_INT(g_mainHeap) + 0x30)); if (g_mainHeap == (void *)0x0) { heapCounter = &g_allocatedBytesNoHeap; } if ((*GHIDRA_CAST((GHIDRA_CAST(&(minions)) + 0x4))) != 0) { uVar3 = *GHIDRA_CAST(((*GHIDRA_CAST((GHIDRA_CAST(&(minions)) + 0x4))) + -4)); qVar2 = *heapCounter; *GHIDRA_CAST(heapCounter) = GHIDRA_UINT(*heapCounter) - uVar3; *GHIDRA_CAST((GHIDRA_CAST(heapCounter) + 4)) = *GHIDRA_CAST((GHIDRA_CAST(heapCounter) + 4)) - GHIDRA_UINT((GHIDRA_UINT(qVar2) < uVar3)); free((void *)((*GHIDRA_CAST((GHIDRA_CAST(&(minions)) + 0x4))) + -4)); } } if ((*GHIDRA_CAST((GHIDRA_CAST(&(nearby)) + 0x0))) == '\0') { heapCounter = GHIDRA_CAST((GHIDRA_INT(g_mainHeap) + 0x30)); if (g_mainHeap == (void *)0x0) { heapCounter = &g_allocatedBytesNoHeap; } if ((*GHIDRA_CAST((GHIDRA_CAST(&(nearby)) + 0x4))) != 0) { uVar3 = *GHIDRA_CAST(((*GHIDRA_CAST((GHIDRA_CAST(&(nearby)) + 0x4))) + -4)); qVar2 = *heapCounter; *GHIDRA_CAST(heapCounter) = GHIDRA_UINT(*heapCounter) - uVar3; *GHIDRA_CAST((GHIDRA_CAST(heapCounter) + 4)) = *GHIDRA_CAST((GHIDRA_CAST(heapCounter) + 4)) - GHIDRA_UINT((GHIDRA_UINT(qVar2) < uVar3)); free((void *)((*GHIDRA_CAST((GHIDRA_CAST(&(nearby)) + 0x4))) + -4)); } } ExceptionList = local_10; return; } // 0058e260 void NpcHelper::siren_charm_familiar(Entity_NPC *npc, Entity_Familiar *familiar) { void *pvVar1; ANM2 *pAVar2; Entity_Familiar *pEVar3; uint32_t seed; Entity *secondEffect; uint32_t *refSlot; Vector local_1c; Vector local_14; int *eraseRef [2]; int temp_5f68b46de4; pEVar3 = familiar; if ((familiar->_flags & 0x100) == 0) { seed = Random(); local_14.x = (pEVar3->_velocity).x; local_14.y = (pEVar3->_velocity).y; local_1c.x = (pEVar3->_pos).x; local_1c.y = (pEVar3->_pos).y; familiar = (Entity_Familiar *) Game::Spawn(g_game,1000,0xa5,&local_1c,&local_14,GHIDRA_CAST(npc),0,seed); *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((familiar)) + 0x45c)))) = 0x4b; refSlot = &familiar->_parent; *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((familiar)) + 0x460)))) = 0x4b; if (familiar->_parent != 0) { eraseRef[0] = refSlot; msvc::multiset::erase(eraseRef); } *refSlot = npc; if (npc != GHIDRA_CAST(0x0)) { msvc::multiset::insert(refSlot); } refSlot = &familiar->_target; if (*refSlot != 0) { eraseRef[0] = refSlot; msvc::multiset::erase(eraseRef); } *refSlot = pEVar3; msvc::multiset::insert(refSlot); local_14.y = (float)npc->_sirenPlayerEntity; refSlot = &familiar->_child; if (*refSlot != 0) { eraseRef[0] = refSlot; msvc::multiset::erase(eraseRef); } *refSlot = local_14.y; if ((void *)local_14.y != (void *)0x0) { msvc::multiset::insert(refSlot); } (**(code **)(*GHIDRA_CAST(familiar) + 0xc))(); seed = Random(); local_1c.x = (pEVar3->_velocity).x; local_1c.y = (pEVar3->_velocity).y; local_14.x = (pEVar3->_pos).x; local_14.y = (pEVar3->_pos).y; secondEffect = Game::Spawn(g_game,1000,0xa5,&local_14,&local_1c,GHIDRA_CAST(npc),1,seed); temp_5f68b46de4 = secondEffect->_parent; pAVar2 = &secondEffect[1]._sprite; (pAVar2->_filename)._buf[4] = 'K'; (pAVar2->_filename)._buf[5] = '\0'; (pAVar2->_filename)._buf[6] = '\0'; (pAVar2->_filename)._buf[7] = '\0'; pAVar2 = &secondEffect[1]._sprite; (pAVar2->_filename)._buf[8] = 'K'; (pAVar2->_filename)._buf[9] = '\0'; (pAVar2->_filename)._buf[10] = '\0'; (pAVar2->_filename)._buf[0xb] = '\0'; if (temp_5f68b46de4 != 0) { familiar = GHIDRA_CAST(&secondEffect->_parent); msvc::multiset::erase(&familiar); } secondEffect->_parent = npc; msvc::multiset::insert(&secondEffect->_parent); if (secondEffect->_target != 0) { familiar = GHIDRA_CAST(&secondEffect->_target); msvc::multiset::erase(&familiar); } secondEffect->_target = pEVar3; msvc::multiset::insert(&secondEffect->_target); pvVar1 = npc->_sirenPlayerEntity; refSlot = &secondEffect->_child; if (*refSlot != 0) { familiar = GHIDRA_CAST(refSlot); msvc::multiset::erase(&familiar); } *refSlot = pvVar1; if (pvVar1 != (void *)0x0) { msvc::multiset::insert(refSlot); } (**(code **)(*GHIDRA_CAST(secondEffect) + 0xc))(); } return; } // 0058e490 void NpcHelper::siren_familiar_counts(int *outFreeCount, int *outCharmedCount, int *outTotalCount) { char isCharmable; uint32_t uVar1; int familiarsData; int extraout_ECX; uint32_t uVar2; uint32_t extraout_EDX; uint64_t *heapAllocatedBytes; EntityList_EL local_24; void *local_10; uint8_t *puStack_c; uint32_t uStack_8; int familiar; Game *game; uint64_t oldAllocatedBytes; game = g_game; uStack_8 = 0xffffffff; puStack_c = &LAB_00af1690; local_10 = ExceptionList; uVar1 = __security_cookie ^ GHIDRA_INT(register0x00000010) - 4U; ExceptionList = &local_10; *outFreeCount = 0; *outCharmedCount = 0; *outTotalCount = 0; EntityList::QuerySublist(GHIDRA_CAST((GHIDRA_INT(game->_room) + 0x1218)),&local_24,3,-1,-1,0,0); uVar2 = 0; if (local_24._size != 0) { familiarsData = (*GHIDRA_CAST((GHIDRA_CAST(&(local_24)) + 0x4))); do { familiar = *GHIDRA_CAST((familiarsData + uVar2 * 4)); if ((familiar != 0) && (*GHIDRA_CAST((familiar + 0x28)) == 3)) { isCharmable = FUN_0060dae0(uVar1); if (isCharmable != '\0') { if ((*GHIDRA_CAST((extraout_ECX + 0x168)) & 0x100) == 0) { *outFreeCount = *outFreeCount + 1; } else { *outCharmedCount = *outCharmedCount + 1; } *outTotalCount = *outTotalCount + 1; } familiarsData = (*GHIDRA_CAST((GHIDRA_CAST(&(local_24)) + 0x4))); uVar2 = extraout_EDX; } uVar2 = uVar2 + 1; } while (uVar2 < GHIDRA_UINT(local_24._size)); } if ((*GHIDRA_CAST((GHIDRA_CAST(&(local_24)) + 0x0))) == '\0') { if (g_mainHeap == (void *)0x0) { heapAllocatedBytes = &g_allocatedBytesNoHeap; } else { heapAllocatedBytes = GHIDRA_CAST((GHIDRA_INT(g_mainHeap) + 0x30)); } if ((*GHIDRA_CAST((GHIDRA_CAST(&(local_24)) + 0x4))) != 0) { uVar2 = *GHIDRA_CAST(((*GHIDRA_CAST((GHIDRA_CAST(&(local_24)) + 0x4))) + -4)); oldAllocatedBytes = *heapAllocatedBytes; *GHIDRA_CAST(heapAllocatedBytes) = GHIDRA_UINT(*heapAllocatedBytes) - uVar2; *GHIDRA_CAST((GHIDRA_CAST(heapAllocatedBytes) + 4)) = *GHIDRA_CAST((GHIDRA_CAST(heapAllocatedBytes) + 4)) - GHIDRA_UINT((GHIDRA_UINT(oldAllocatedBytes) < uVar2)); free(GHIDRA_CAST(((*GHIDRA_CAST((GHIDRA_CAST(&(local_24)) + 0x4))) + -4))); } } ExceptionList = local_10; return; } // 0058e590 int NpcHelper::siren_charmed_count(Entity_NPC *npc) { uint64_t qVar1; uint8_t isDetached; uint64_t *allocatedBytes; int extraout_ECX; uint32_t uVar2; uint32_t extraout_EDX; int count; EntityList_EL local_24; Entity_NPC *siren; void *local_10; uint8_t *puStack_c; uint32_t uStack_8; Entity_Familiar *familiar; uStack_8 = 0xffffffff; puStack_c = &LAB_00af38e0; local_10 = ExceptionList; ExceptionList = &local_10; count = 0; siren = npc; EntityList::QuerySublist(GHIDRA_CAST((GHIDRA_INT(g_game->_room) + 0x1218)),&local_24,3,-1,-1,0,0); uVar2 = 0; if (local_24._size != 0) { do { familiar = *GHIDRA_CAST(((*GHIDRA_CAST((GHIDRA_CAST(&(local_24)) + 0x4))) + uVar2 * 4)); if ((((familiar != GHIDRA_CAST(0x0)) && (familiar->_type == 3)) && ((familiar->_flags & 0x100) != 0)) && ((isDetached = Entity_Familiar::is_detached_from_follow(familiar), uVar2 = extraout_EDX, isDetached != 0 && (*(void **)(extraout_ECX + 0x410) == siren->_sirenPlayerEntity)))) { count = count + 1; } uVar2 = uVar2 + 1; } while (uVar2 < GHIDRA_UINT(local_24._size)); } if ((*GHIDRA_CAST((GHIDRA_CAST(&(local_24)) + 0x0))) == '\0') { if (g_mainHeap == (void *)0x0) { allocatedBytes = &g_allocatedBytesNoHeap; } else { allocatedBytes = GHIDRA_CAST((GHIDRA_INT(g_mainHeap) + 0x30)); } if ((*GHIDRA_CAST((GHIDRA_CAST(&(local_24)) + 0x4))) != 0) { uVar2 = *GHIDRA_CAST(((*GHIDRA_CAST((GHIDRA_CAST(&(local_24)) + 0x4))) + -4)); qVar1 = *allocatedBytes; *GHIDRA_CAST(allocatedBytes) = GHIDRA_UINT(*allocatedBytes) - uVar2; *GHIDRA_CAST((GHIDRA_CAST(allocatedBytes) + 4)) = *GHIDRA_CAST((GHIDRA_CAST(allocatedBytes) + 4)) - GHIDRA_UINT((GHIDRA_UINT(qVar1) < uVar2)); free((void *)((*GHIDRA_CAST((GHIDRA_CAST(&(local_24)) + 0x4))) + -4)); } } ExceptionList = local_10; return count; } // 0058e680 void NpcHelper::siren_pick(Entity_NPC *npc) { RNG rng; uint64_t qVar1; int charmedCount; uint32_t uVar2; int familiar; float fVar3; uint32_t outcomeCount; float fVar4; uint64_t *heapCounter; uint32_t *outcomesBegin; uint32_t *controlledCount; uint32_t *outcomeCursor; float roomCenterY; float rightEdgeStart; float leftEdgeStart; uint32_t *controlledTotal; EntityList_EL local_64; Entity_NPC *local_54; uint32_t *picker; uint32_t *outcomesEnd; uint32_t *outcomesCapacity; float local_44; float local_40; int local_3c [7]; uint8_t *puStack_20; void *local_1c; uint8_t *puStack_18; uint32_t local_14; void *room; int *weight; puStack_20 = GHIDRA_CAST((local_3c + 0xe)); puStack_18 = &LAB_00af55ad; local_1c = ExceptionList; local_3c[6] = __security_cookie ^ GHIDRA_UINT((local_3c + 0xb)); ExceptionList = &local_1c; controlledCount = GHIDRA_CAST(0x0); local_3c[4] = 0xc; local_3c[0] = 3; local_3c[1] = 8; local_3c[2] = 9; local_3c[3] = 10; local_3c[5] = 6; picker = GHIDRA_CAST(0x0); outcomesEnd = GHIDRA_CAST(0x0); outcomesCapacity = GHIDRA_CAST(0x0); local_14 = 0; local_54 = npc; siren_familiar_counts(GHIDRA_CAST(&local_40),GHIDRA_CAST(&local_44),&local_64._size); charmedCount = siren_charmed_count(local_54); controlledTotal = GHIDRA_CAST(0x0); EntityList::QuerySublist(GHIDRA_CAST((GHIDRA_INT(g_game->_room) + 0x1218)),&local_64,3,-1,-1,0,0); fVar4 = 0.0; outcomesBegin = controlledCount; outcomeCursor = GHIDRA_CAST(0x0); if ((float)local_64._size != 0.0) { do { familiar = *GHIDRA_CAST(((*GHIDRA_CAST((GHIDRA_CAST(&(local_64)) + 0x4))) + GHIDRA_INT(fVar4) * 4)); if ((familiar == 0) || (*GHIDRA_CAST((familiar + 0x28)) != 3)) { familiar = 0; } if (((*GHIDRA_CAST((familiar + 0x168)) & 0x100) != 0) && (*(void **)(familiar + 0x410) == local_54->_sirenPlayerEntity)) { controlledCount = GHIDRA_CAST((GHIDRA_INT(controlledCount) + 1)); } fVar4 = (float)(GHIDRA_INT(fVar4) + 1); } while (GHIDRA_UINT(fVar4) < GHIDRA_UINT(local_64._size)); outcomesBegin = picker; outcomeCursor = outcomesEnd; controlledTotal = controlledCount; } if ((*GHIDRA_CAST((GHIDRA_CAST(&(local_64)) + 0x0))) == '\0') { if (g_mainHeap == (void *)0x0) { heapCounter = &g_allocatedBytesNoHeap; } else { heapCounter = GHIDRA_CAST((GHIDRA_INT(g_mainHeap) + 0x30)); } if ((*GHIDRA_CAST((GHIDRA_CAST(&(local_64)) + 0x4))) != 0) { uVar2 = *GHIDRA_CAST(((*GHIDRA_CAST((GHIDRA_CAST(&(local_64)) + 0x4))) + -4)); qVar1 = *heapCounter; *GHIDRA_CAST(heapCounter) = GHIDRA_UINT(*heapCounter) - uVar2; *GHIDRA_CAST((GHIDRA_CAST(heapCounter) + 4)) = *GHIDRA_CAST((GHIDRA_CAST(heapCounter) + 4)) - GHIDRA_UINT((GHIDRA_UINT(qVar1) < uVar2)); free(GHIDRA_CAST(((*GHIDRA_CAST((GHIDRA_CAST(&(local_64)) + 0x4))) + -4))); } local_14 = local_14 & 0xffffff00; } if ((*GHIDRA_CAST((GHIDRA_INT(&(local_54->_v2).x) + 1)) == '\0') && (GHIDRA_INT(controlledTotal) < 2)) { fVar3 = (float)(GHIDRA_INT(controlledTotal) * -0x21 + 100); fVar4 = 0.0; if (0 < GHIDRA_INT(fVar3)) { fVar4 = fVar3; } if (0 < GHIDRA_INT(fVar4)) { local_64._capacity = 1; local_64._size = GHIDRA_INT(fVar4); msvc::vector<8byte>::_Emplace_reallocate(0,&local_64._capacity); outcomesBegin = picker; outcomeCursor = outcomesEnd; } } if (((*GHIDRA_CAST((GHIDRA_INT(&(local_54->_v2).x) + 3)) == '\0') && (GHIDRA_INT(local_44) < 6)) && (0 < GHIDRA_INT(local_40))) { fVar3 = (float)(GHIDRA_INT(local_40) * 0x21 + GHIDRA_INT(local_44) * -0xf); fVar4 = 1.4013e-45; if (1 < GHIDRA_INT(fVar3)) { fVar4 = fVar3; } local_40 = 2.10195e-43; if (GHIDRA_INT(fVar4) < 0x96) { local_40 = fVar4; } uVar2 = 0; outcomeCount = GHIDRA_INT(outcomeCursor) - GHIDRA_INT(outcomesBegin) >> 3; if (outcomeCount != 0) { do { if (outcomesBegin[uVar2 * 2] == 3) { weight = outcomesBegin + uVar2 * 2 + 1; *weight = *weight + GHIDRA_INT(local_40); if (*weight < 0) { outcomesBegin[uVar2 * 2 + 1] = 0; } goto LAB_0058e8af; } uVar2 = uVar2 + 1; } while (uVar2 < outcomeCount); } if (0 < GHIDRA_INT(local_40)) { local_64._capacity = 3; local_64._size = GHIDRA_INT(local_40); if (outcomeCursor == outcomesCapacity) { msvc::vector<8byte>::_Emplace_reallocate(outcomeCursor,&local_64._capacity); outcomesBegin = picker; outcomeCursor = outcomesEnd; } else { *outcomeCursor = 3; outcomeCursor[1] = local_40; outcomesEnd = outcomeCursor + 2; outcomeCursor = outcomesEnd; } } } LAB_0058e8af: if (*GHIDRA_CAST(&(local_54->_v2).y) == '\0') { fVar4 = 4.62428e-44; if (0x21 < charmedCount * 0x21) { fVar4 = (float)(charmedCount * 0x21); } local_40 = 1.4013e-43; if (GHIDRA_INT(fVar4) < 100) { local_40 = fVar4; } outcomeCount = GHIDRA_INT(outcomeCursor) - GHIDRA_INT(outcomesBegin) >> 3; uVar2 = 0; if (outcomeCount != 0) { do { if (outcomesBegin[uVar2 * 2] == 4) { weight = outcomesBegin + uVar2 * 2 + 1; *weight = *weight + GHIDRA_INT(local_40); if (*weight < 0) { outcomesBegin[uVar2 * 2 + 1] = 0; } goto LAB_0058e94b; } uVar2 = uVar2 + 1; } while (uVar2 < outcomeCount); } if (0 < GHIDRA_INT(local_40)) { local_64._capacity = 4; local_64._size = GHIDRA_INT(local_40); if (outcomeCursor == outcomesCapacity) { msvc::vector<8byte>::_Emplace_reallocate(outcomeCursor,&local_64._capacity); outcomesBegin = picker; outcomeCursor = outcomesEnd; } else { *outcomeCursor = 4; outcomeCursor[1] = local_40; outcomesEnd = outcomeCursor + 2; outcomeCursor = outcomesEnd; } } } LAB_0058e94b: if ((*GHIDRA_CAST((GHIDRA_INT(&(local_54->_v2).y) + 1)) == '\0') && (local_44 == 0.0)) { local_64._size = GHIDRA_INT((local_54->_pos).y); room = g_game->_room; fVar4 = *GHIDRA_CAST((GHIDRA_CAST(room) + 0x1c)); fVar3 = *GHIDRA_CAST((GHIDRA_CAST(room) + 0x20)); rightEdgeStart = fVar4 - 80.0; local_40 = *GHIDRA_CAST((GHIDRA_CAST(room) + 0x14)); leftEdgeStart = local_40 + 80.0; roomCenterY = (fVar3 - *GHIDRA_CAST((GHIDRA_CAST(room) + 0x18))) * 0.5 + *GHIDRA_CAST((GHIDRA_CAST(room) + 0x18)); local_44 = (local_54->_pos).x; if (rightEdgeStart == fVar4) { KAGE_LogMessage(0x10,GHIDRA_CAST("Start and End parameters cannot be the same!")); } fVar4 = (local_44 - rightEdgeStart) / (fVar4 - rightEdgeStart); if (fVar4 <= 0.0) { fVar4 = 0.0; } if (1.0 <= fVar4) { fVar4 = 1.0; } if (leftEdgeStart == local_40) { KAGE_LogMessage(0x10,GHIDRA_CAST("Start and End parameters cannot be the same!")); } local_44 = (local_44 - leftEdgeStart) / (local_40 - leftEdgeStart); if (local_44 <= 0.0) { local_44 = 0.0; } if (1.0 <= local_44) { local_44 = 1.0; } if (roomCenterY == fVar3) { KAGE_LogMessage(0x10,GHIDRA_CAST("Start and End parameters cannot be the same!")); } outcomeCount = GHIDRA_INT(outcomeCursor) - GHIDRA_INT(outcomesBegin) >> 3; uVar2 = 0; fVar3 = ((float)local_64._size - roomCenterY) / (fVar3 - roomCenterY); if (fVar3 <= 0.0) { fVar3 = 0.0; } if (1.0 <= fVar3) { fVar3 = 1.0; } fVar4 = (float)GHIDRA_INT(((fVar3 + 0.0 + local_44 + 0.0 + fVar4 + 0.0) * 100.0)); if (outcomeCount != 0) { do { if (outcomesBegin[uVar2 * 2] == 5) { weight = outcomesBegin + uVar2 * 2 + 1; *weight = *weight + GHIDRA_INT(fVar4); if (*weight < 0) { outcomesBegin[uVar2 * 2 + 1] = 0; } goto LAB_0058eb5f; } uVar2 = uVar2 + 1; } while (uVar2 < outcomeCount); } if (0 < GHIDRA_INT(fVar4)) { local_64._capacity = 5; local_64._size = GHIDRA_INT(fVar4); if (outcomeCursor == outcomesCapacity) { msvc::vector<8byte>::_Emplace_reallocate(outcomeCursor,&local_64._capacity); outcomesBegin = picker; outcomeCursor = outcomesEnd; } else { *outcomeCursor = 5; outcomeCursor[1] = fVar4; outcomesEnd = outcomeCursor + 2; outcomeCursor = outcomesEnd; } } LAB_0058eb5f: if (outcomesBegin != outcomeCursor) goto LAB_0058ebbb; } else if (GHIDRA_INT(local_44) < 1) goto LAB_0058eb5f; uVar2 = 0; outcomeCount = GHIDRA_INT(outcomeCursor) - GHIDRA_INT(outcomesBegin) >> 3; if (outcomeCount != 0) { do { if (outcomesBegin[uVar2 * 2] == 0) { weight = outcomesBegin + uVar2 * 2 + 1; *weight = *weight + 100; if (*weight < 0) { outcomesBegin[uVar2 * 2 + 1] = 0; } goto LAB_0058ebbb; } uVar2 = uVar2 + 1; } while (uVar2 < outcomeCount); } local_64._size = 100; (*GHIDRA_CAST((GHIDRA_CAST(&(local_64)) + 0x4))) = (*GHIDRA_CAST((GHIDRA_CAST(&(local_64)) + 0x4))) & 0xffffffff; if (outcomeCursor == outcomesCapacity) { msvc::vector<8byte>::_Emplace_reallocate(outcomeCursor,&local_64._capacity); } else { *outcomeCursor = 0; outcomeCursor[1] = 100; outcomesEnd = outcomeCursor + 2; } LAB_0058ebbb: (*GHIDRA_CAST((GHIDRA_CAST(&(local_64)) + 0x0))) = Random(); (*GHIDRA_CAST((GHIDRA_CAST(&(local_64)) + 0x0))) = (*GHIDRA_CAST((GHIDRA_CAST(&(local_64)) + 0x0))) | 1; (*GHIDRA_CAST((GHIDRA_CAST(&(local_64)) + 0x4))) = 5; local_64._capacity = 9; local_64._size = 7; rng._shift1 = 5; rng._seed = (*GHIDRA_CAST((GHIDRA_CAST(&(local_64)) + 0x0))); rng._shift2 = 9; rng._shift3 = 7; uVar2 = WeightedOutcomePicker::PickOutcome(GHIDRA_CAST(&picker),rng); if (uVar2 == 0) { *GHIDRA_CAST((GHIDRA_INT(&local_54->_projectileCooldown) + 2)) = 0; } else { charmedCount = local_3c[uVar2]; *GHIDRA_CAST(&local_54->_projectileCooldown) = 0xffff; local_54->_state = charmedCount; } if (picker != GHIDRA_CAST(0x0)) { uVar2 = GHIDRA_INT(outcomesCapacity) - GHIDRA_INT(picker) & 0xfffffff8; outcomesBegin = picker; if (0xfff < uVar2) { outcomesBegin = GHIDRA_CAST(picker[-1]); uVar2 = uVar2 + 0x23; if (0x1f < GHIDRA_UINT((GHIDRA_INT(picker) + (-4 - GHIDRA_INT(outcomesBegin))))) { /* WARNING: Subroutine does not return */ _invalid_parameter_noinfo_noreturn(); } } operator_delete(outcomesBegin,uVar2); } ExceptionList = local_1c; return; } // 00592050 void NpcHelper::siren_familiar_orbit(Entity_NPC *siren, Entity_Familiar *familiar) { void *pvVar1; uint8_t isDetached; int extraout_ECX; int extraout_ECX_00; int orbitSlot; int extraout_EDX; int extraout_EDX_00; void *orbitCenter; int detachedAheadCount; float fVar2; float fVar3; float fVar4; float fVar5; float deltaY; Entity_Familiar *chainFamiliar; int chainType; pvVar1 = siren->_sirenPlayerEntity; if (pvVar1 != (void *)0x0) { orbitCenter = pvVar1; if ((void *)siren->_child != (void *)0x0) { orbitCenter = (void *)siren->_child; } orbitSlot = 0; detachedAheadCount = 0; chainFamiliar = GHIDRA_CAST(familiar->_parent); if (chainFamiliar != GHIDRA_CAST(0x0)) { chainType = chainFamiliar->_type; while (chainType == 3) { isDetached = Entity_Familiar::is_detached_from_follow(chainFamiliar); if (isDetached != 0) { detachedAheadCount = detachedAheadCount + 1; } chainFamiliar = *GHIDRA_CAST((extraout_ECX + 0x3bc)); orbitSlot = extraout_EDX; if (chainFamiliar == GHIDRA_CAST(0x0)) break; chainType = chainFamiliar->_type; } } chainFamiliar = GHIDRA_CAST(familiar->_child); if (chainFamiliar != GHIDRA_CAST(0x0)) { chainType = chainFamiliar->_type; while (chainType == 3) { isDetached = Entity_Familiar::is_detached_from_follow(chainFamiliar); orbitSlot = extraout_EDX_00; if (isDetached != 0) { orbitSlot = extraout_EDX_00 + 1; } chainFamiliar = *GHIDRA_CAST((extraout_ECX_00 + 0x3c0)); if (chainFamiliar == GHIDRA_CAST(0x0)) break; chainType = chainFamiliar->_type; } } fVar5 = (((float)orbitSlot * 360.0) / (float)(orbitSlot + 1 + detachedAheadCount) + *GHIDRA_CAST((GHIDRA_CAST(pvVar1) + 0x334)) * 3.5) * 0.017453292; fVar2 = cos(fVar5); fVar3 = (fVar2 * 90.0 + *GHIDRA_CAST((GHIDRA_CAST(orbitCenter) + 0x33c))) - (familiar->_pos).x; fVar2 = sin(fVar5); deltaY = (fVar2 * 90.0 + *GHIDRA_CAST((GHIDRA_CAST(orbitCenter) + 0x340))) - (familiar->_pos).y; fVar4 = sqrtf(deltaY * deltaY + fVar3 * fVar3); fVar2 = g_vectorZero.y; fVar5 = g_vectorZero.x; if (20.0 < fVar4) { fVar4 = ((fVar4 - 20.0) * 0.1) / fVar4; fVar5 = g_vectorZero.x + fVar3 * fVar4; fVar2 = g_vectorZero.y + deltaY * fVar4; } fVar3 = *GHIDRA_CAST((GHIDRA_CAST(orbitCenter) + 0x360)); (familiar->_velocity).y = fVar2 + *GHIDRA_CAST((GHIDRA_CAST(orbitCenter) + 0x364)); (familiar->_velocity).x = fVar3 + fVar5; } return; } // 00597d00 void NpcHelper::beast_soul_render(Entity_NPC *npc, Vector *offset) { Vector *point; int iVar1; uint32_t dequeIndex; uint32_t uVar2; float fVar3; float fVar4; double dVar5; float smoothedPointX; float fStack_5c; uint32_t uStack_58; float fStack_54; float firstPointX; float fStack_4c; float fStack_48; float fStack_44; float local_40; float local_3c; ColorMod pointColor; uint32_t local_c; uint8_t auStack_8 [4]; float *screenPointsEnd; void *trailPointsEnd; local_c = __security_cookie ^ GHIDRA_UINT((auStack_8 + 4)); if (8 < (npc->_vectorDeque2)._size) { iVar1 = *GHIDRA_CAST(ThreadLocalStoragePointer); if ((*GHIDRA_CAST((iVar1 + 0xc)) < DAT_00c7f838) && (_Init_thread_header(), DAT_00c7f838 == -1)) { _atexit(GHIDRA_CAST<_func_4879 *>(&LAB_00b15560)); _Init_thread_footer(); } if ((*GHIDRA_CAST((iVar1 + 0xc)) < DAT_00c7f848) && (_Init_thread_header(), DAT_00c7f848 == -1)) { _atexit(GHIDRA_CAST<_func_4879 *>(&LAB_00b15500)); _Init_thread_footer(); } uVar2 = 0; DAT_00c7f840 = DAT_00c7f83c; g_beastTrailPointsEnd = g_beastTrailPoints; if ((npc->_vectorDeque2)._size != 0) { do { screenPointsEnd = DAT_00c7f840; fStack_54 = (float)(npc->_vectorDeque2)._offset; local_40 = g_displayPixelRatio * g_screenPointScale; dequeIndex = GHIDRA_INT(fStack_54) + uVar2 & 1; iVar1 = *GHIDRA_CAST((GHIDRA_INT((npc->_vectorDeque2)._map) + ((npc->_vectorDeque2)._mapSize - 1 & GHIDRA_INT(fStack_54) + uVar2 >> 1) * 4)); fStack_48 = *GHIDRA_CAST((iVar1 + dequeIndex * 8)); fStack_44 = *GHIDRA_CAST((iVar1 + 4 + dequeIndex * 8)); local_3c = ((g_screenWidth - 338.0) * 0.5 + (fStack_48 - 60.0) * 0.65) * local_40 + 0.5; dVar5 = floor((double)local_3c); fStack_54 = (float)dVar5 / local_40; local_3c = ((g_screenHeight - 182.0) * 0.5 + (fStack_44 - 140.0) * 0.65) * local_40 + 0.5; dVar5 = floor((double)local_3c); local_3c = (float)dVar5; fStack_48 = fStack_54 + offset->x; fStack_44 = local_3c / local_40 + offset->y; if (screenPointsEnd == DAT_00c7f844) { msvc::vector::_Emplace_reallocate(screenPointsEnd,&fStack_48); } else { *screenPointsEnd = fStack_48; DAT_00c7f840[1] = fStack_44; DAT_00c7f840 = DAT_00c7f840 + 2; } uVar2 = uVar2 + 3; } while (uVar2 < (npc->_vectorDeque2)._size); } trailPointsEnd = g_beastTrailPointsEnd; firstPointX = *DAT_00c7f83c; fStack_4c = DAT_00c7f83c[1]; uVar2 = (npc->_vectorDeque2)._offset + 2; local_40 = 0.0; fStack_44 = 0.0; fStack_48 = *GHIDRA_CAST((*GHIDRA_CAST((GHIDRA_INT((npc->_vectorDeque2)._map) + (uVar2 >> 1 & (npc->_vectorDeque2)._mapSize - 1) * 4)) + (uVar2 & 1) * 8)); if (g_beastTrailPointsEnd == DAT_00c7f854) { FUN_00598290(g_beastTrailPointsEnd,&firstPointX); } else { *GHIDRA_CAST(g_beastTrailPointsEnd) = firstPointX; *GHIDRA_CAST((GHIDRA_CAST(trailPointsEnd) + 4)) = fStack_4c; *GHIDRA_CAST((GHIDRA_CAST(trailPointsEnd) + 8)) = fStack_48; *GHIDRA_CAST((GHIDRA_CAST(trailPointsEnd) + 0xc)) = 0; g_beastTrailPointsEnd = (void *)(GHIDRA_INT(g_beastTrailPointsEnd) + 0x10); } fVar3 = 0.0; uVar2 = 1; if (1 < (GHIDRA_INT(DAT_00c7f840) - GHIDRA_INT(DAT_00c7f83c) >> 3) - 1U) { local_3c = 4.2039e-45; do { trailPointsEnd = g_beastTrailPointsEnd; dequeIndex = GHIDRA_INT(local_3c) + (npc->_vectorDeque2)._offset + 2; fStack_54 = 0.0; smoothedPointX = DAT_00c7f83c[uVar2 * 2 + -2] * 0.3 + DAT_00c7f83c[uVar2 * 2] * 0.4 + DAT_00c7f83c[uVar2 * 2 + 2] * 0.3; fStack_5c = DAT_00c7f83c[uVar2 * 2 + -1] * 0.3 + DAT_00c7f83c[uVar2 * 2 + 1] * 0.4 + DAT_00c7f83c[uVar2 * 2 + 3] * 0.3; uStack_58 = *(uint32_t *) (*GHIDRA_CAST((GHIDRA_INT((npc->_vectorDeque2)._map) + ((npc->_vectorDeque2)._mapSize - 1 & dequeIndex >> 1) * 4)) + (dequeIndex & 1) * 8); if (g_beastTrailPointsEnd == DAT_00c7f854) { FUN_00598290(g_beastTrailPointsEnd,&smoothedPointX); } else { *GHIDRA_CAST(g_beastTrailPointsEnd) = smoothedPointX; *GHIDRA_CAST((GHIDRA_CAST(trailPointsEnd) + 4)) = fStack_5c; *GHIDRA_CAST((GHIDRA_CAST(trailPointsEnd) + 8)) = uStack_58; *GHIDRA_CAST((GHIDRA_CAST(trailPointsEnd) + 0xc)) = 0; g_beastTrailPointsEnd = (void *)(GHIDRA_INT(g_beastTrailPointsEnd) + 0x10); } trailPointsEnd = g_beastTrailPointsEnd; iVar1 = GHIDRA_INT(g_beastTrailPointsEnd) - GHIDRA_INT(g_beastTrailPoints) >> 4; fVar3 = *GHIDRA_CAST((GHIDRA_CAST(g_beastTrailPoints) + (iVar1 + -2) * 0x10 + 4)) - *GHIDRA_CAST((GHIDRA_CAST(g_beastTrailPoints) + iVar1 * 0x10 + -0xc)); fVar4 = *GHIDRA_CAST((GHIDRA_CAST(g_beastTrailPoints) + (iVar1 + -2) * 0x10)) - *GHIDRA_CAST((GHIDRA_CAST(g_beastTrailPoints) + iVar1 * 0x10 + -0x10)); fVar3 = sqrtf(fVar3 * fVar3 + fVar4 * fVar4); fVar3 = fVar3 + local_40; uVar2 = uVar2 + 1; local_3c = (float)(GHIDRA_INT(local_3c) + 3); *GHIDRA_CAST((GHIDRA_CAST(trailPointsEnd) + -4)) = fVar3; local_40 = fVar3; } while (uVar2 < (GHIDRA_INT(DAT_00c7f840) - GHIDRA_INT(DAT_00c7f83c) >> 3) - 1U); } local_3c = 1.0; if ((128.0 < fVar3) && (local_3c = 128.0 / fVar3, local_3c <= 0.5)) { local_3c = 0.5; } DAT_00c78ef0 = &npc->_sprite; uVar2 = 0; DAT_00c78ef4 = 0; (*GHIDRA_CAST((GHIDRA_CAST(&(DAT_00c78ef8)) + 0x0))) = 0; g_beamRendererPointsEnd = g_beamRendererPoints; if (GHIDRA_INT(g_beastTrailPointsEnd) - GHIDRA_INT(g_beastTrailPoints) >> 4 != 0) { iVar1 = 0; do { point = GHIDRA_CAST((iVar1 + GHIDRA_INT(g_beastTrailPoints))); pointColor._offset[0] = 0.0; pointColor._offset[1] = 0.0; pointColor._offset[2] = 0.0; pointColor._colorize[0] = 0.0; pointColor._colorize[1] = 0.0; pointColor._colorize[2] = 0.0; pointColor._colorize[3] = 0.0; pointColor._tint[3] = point[1].x; pointColor._tint[0] = 1.0; pointColor._tint[1] = 1.0; pointColor._tint[2] = 1.0; BeamRenderer::Add(point,&pointColor,local_3c,local_3c * point[1].y); iVar1 = iVar1 + 0x10; uVar2 = uVar2 + 1; } while (uVar2 < GHIDRA_UINT((GHIDRA_INT(g_beastTrailPointsEnd) - GHIDRA_INT(g_beastTrailPoints) >> 4))); } BeamRenderer::End(); } return; } // 0059e2a0 void NpcHelper::UltraGreed_Heal(Entity_NPC *npc, int amount) { int healStacks; float newHealth; float fVar1; uint32_t healColor; uint32_t uStack_30; uint32_t uStack_2c; uint32_t uStack_28; uint32_t local_24; uint32_t uStack_20; uint32_t uStack_1c; uint32_t uStack_18; float flashIntensity; float local_10; float local_c; uint32_t local_8; local_8 = __security_cookie ^ GHIDRA_INT(register0x00000010) - 4U; npc->_i2 = npc->_i2 + amount; healStacks = npc->_i2; if (0x19 < healStacks) { healStacks = 0x19; } npc->_i2 = healStacks; fVar1 = npc->_maxHitPoints; newHealth = fVar1 * 0.00125 * (float)amount + npc->_health; npc->_health = newHealth; if (fVar1 < newHealth) { npc->_health = fVar1; } fVar1 = (float)amount / 3.0; healStacks = amount * 4; if (0xf < healStacks) { healStacks = 0xf; } flashIntensity = 1.0; if (fVar1 <= 1.0) { flashIntensity = fVar1; } healColor = 0x3f800000; uStack_30 = 0x3f800000; uStack_2c = 0x3f800000; uStack_28 = 0x3f800000; local_24 = 0; uStack_20 = 0; uStack_1c = 0; uStack_18 = 0; local_10 = flashIntensity * 0.84; local_c = flashIntensity * 0.0; (**(code **)(*GHIDRA_CAST(npc) + 0x3c))(&healColor,healStacks,0xff,1,1); return; } // 0059e630 Entity_NPC * NpcHelper::UltraDoor_Opposite(Entity_NPC *door, EntityList_EL doors) { uint32_t uVar1; Entity_NPC *oppositeDoor; uint64_t *heapAllocatedBytes; int oppositeSlot; uint32_t entityIdx; int oppositeSlots [9]; void *local_10; uint8_t *puStack_c; int local_8; uint64_t oldAllocatedBytes; puStack_c = &LAB_00af57bd; local_10 = ExceptionList; uVar1 = __security_cookie ^ GHIDRA_UINT((oppositeSlots + 0xc)); ExceptionList = &local_10; local_8 = 0; oppositeSlots[8] = uVar1; if (door != GHIDRA_CAST(0x0)) { oppositeSlot = -1; oppositeSlots[0] = 2; oppositeSlots[1] = 3; oppositeSlots[2] = 0; oppositeSlots[3] = 1; oppositeSlots[4] = 6; oppositeSlots[5] = 7; oppositeSlots[6] = 4; oppositeSlots[7] = 5; if (GHIDRA_UINT(door->_i1) < 8) { oppositeSlot = oppositeSlots[door->_i1]; } entityIdx = 0; if (doors._size != 0) { do { oppositeDoor = (Entity_NPC *) __RTDynamicCast(*GHIDRA_CAST(((*GHIDRA_CAST((GHIDRA_CAST(&(doors)) + 0x4))) + entityIdx * 4)),0, &IsaacRepentancePlus::Entity::RTTI_Type_Descriptor, &IsaacRepentancePlus::Entity_NPC::RTTI_Type_Descriptor,0, uVar1); if ((oppositeDoor != GHIDRA_CAST(0x0)) && (oppositeDoor->_i1 == oppositeSlot)) goto LAB_0059e6d2; entityIdx = entityIdx + 1; } while (entityIdx < GHIDRA_UINT(doors._size)); } } oppositeDoor = GHIDRA_CAST(0x0); LAB_0059e6d2: if ((*GHIDRA_CAST((GHIDRA_CAST(&(doors)) + 0x0))) == '\0') { if (g_mainHeap == (void *)0x0) { heapAllocatedBytes = &g_allocatedBytesNoHeap; } else { heapAllocatedBytes = GHIDRA_CAST((GHIDRA_INT(g_mainHeap) + 0x30)); } if ((*GHIDRA_CAST((GHIDRA_CAST(&(doors)) + 0x4))) != 0) { uVar1 = *GHIDRA_CAST(((*GHIDRA_CAST((GHIDRA_CAST(&(doors)) + 0x4))) + -4)); oldAllocatedBytes = *heapAllocatedBytes; *GHIDRA_CAST(heapAllocatedBytes) = GHIDRA_UINT(*heapAllocatedBytes) - uVar1; *GHIDRA_CAST((GHIDRA_CAST(heapAllocatedBytes) + 4)) = *GHIDRA_CAST((GHIDRA_CAST(heapAllocatedBytes) + 4)) - GHIDRA_UINT((GHIDRA_UINT(oldAllocatedBytes) < uVar1)); free((void *)((*GHIDRA_CAST((GHIDRA_CAST(&(doors)) + 0x4))) + -4)); } } ExceptionList = local_10; return oppositeDoor; } // 0059e730 void NpcHelper::UltraGreed_Smash(Entity_NPC *npc, Vector position) { int iVar1; RNG rng; EntityList_EL doors; EntityList_EL doors_00; EntityList_EL doors_01; uint64_t qVar2; uint32_t uVar3; Entity_NPC *oppositeDoor; Entity_NPC *randomDoor; uint32_t outcomeCount; Game *game; uint64_t *allocCounter; uint32_t uVar4; EntityList_EL ultraDoors; void *picker; uint32_t *pickerEnd; uint32_t *pickerCapacity; Entity_NPC *boss; uint32_t pickSeed; uint64_t uStack_8c; Entity_NPC *pEStack_84; float local_80; ColorMod particleColor; ColorMod explosionColor; uint32_t local_24; uint8_t *puStack_20; void *local_1c; uint8_t *puStack_18; float local_14; Manager *manager; int *outcomeWeight; void *room; puStack_20 = GHIDRA_CAST((&explosionColor)[1]._offset); local_14 = -NAN; puStack_18 = &LAB_00af580b; local_1c = ExceptionList; local_24 = __security_cookie ^ GHIDRA_UINT(((&explosionColor)[1]._colorize + 1)); ExceptionList = &local_1c; boss = npc; Entity_NPC::CreateGoldParticles(npc,0x1e); manager = g_manager; local_80 = 1.93379e-43; seed_fart_sound_override(GHIDRA_CAST(&local_80)); (GHIDRA_CAST((&manager->_sfxManager)))->SoundEffects::Play(GHIDRA_INT(local_80),1.0,2,0,1.0,0.0); uVar3 = Random(); manager = g_manager; local_80 = 6.72623e-44; pEStack_84 = (Entity_NPC *) ((float)((double)GHIDRA_INT(uVar3) + __uint_to_double_fixup[-(GHIDRA_INT(uVar3) >> 0x1f)]) * 2.3283064e-10 * 0.2 + 0.9); seed_fart_sound_override(GHIDRA_CAST(&local_80)); (GHIDRA_CAST((&manager->_sfxManager)))->SoundEffects::Play(GHIDRA_INT(local_80),1.0,2,0,(float)pEStack_84,0.0); game = g_game; pEStack_84 = GHIDRA_CAST(position.x); room = g_game->_room; local_80 = position.y; *GHIDRA_CAST((GHIDRA_CAST(room) + 0x70fc)) = *GHIDRA_CAST((GHIDRA_CAST(room) + 0x70fc)) + 1; uVar3 = *GHIDRA_CAST((GHIDRA_CAST(room) + 0x70fc)) & 0x80000001; if (GHIDRA_INT(uVar3) < 0) { uVar3 = (uVar3 - 1 | 0xfffffffe) + 1; } if (1 < uVar3) { KAGE_LogMessage(0x10,GHIDRA_CAST("Shockwave id is too large!")); game = g_game; } randomDoor = boss; iVar1 = uVar3 + 0x407; *GHIDRA_CAST((GHIDRA_CAST(room) + iVar1 * 0x1c)) = pEStack_84; *GHIDRA_CAST((GHIDRA_CAST(room) + iVar1 * 0x1c + 4)) = local_80; *GHIDRA_CAST((GHIDRA_CAST(room) + iVar1 * 0x1c + 8)) = 0; *GHIDRA_CAST((GHIDRA_CAST(room) + iVar1 * 0x1c + 0xc)) = 0x3ccccccd; *GHIDRA_CAST((GHIDRA_CAST(room) + iVar1 * 0x1c + 0x10)) = 0x3ccccccd; *GHIDRA_CAST((GHIDRA_CAST(room) + iVar1 * 0x1c + 0x14)) = 0; *GHIDRA_CAST((GHIDRA_CAST(room) + iVar1 * 0x1c + 0x18)) = 0x19; explosionColor._offset[0] = 0.5; explosionColor._offset[1] = 0.25; explosionColor._colorize[0] = 0.0; explosionColor._colorize[1] = 0.0; explosionColor._colorize[2] = 0.0; explosionColor._colorize[3] = 0.0; explosionColor._offset[2] = 0.0; explosionColor._tint[0] = 1.0; explosionColor._tint[1] = 1.0; explosionColor._tint[2] = 1.0; explosionColor._tint[3] = 1.0; Game::BombExplosionEffects (game,&position,60.0,(BitSet128)ZEXT816(0),&explosionColor,GHIDRA_CAST(boss),1.8,1,4,0); particleColor._tint[0] = 1.0; particleColor._tint[1] = 1.0; particleColor._tint[2] = 1.0; particleColor._tint[3] = 1.0; particleColor._offset[0] = 0.0; particleColor._colorize[0] = 0.0; particleColor._colorize[1] = 0.0; particleColor._colorize[2] = 0.0; particleColor._colorize[3] = 0.0; particleColor._offset[1] = 0.0; particleColor._offset[2] = 0.0; Game::SpawnParticles(g_game,&position,0x5f,0xf,5.0,&particleColor,100000.0,0); EntityList::QuerySublist(GHIDRA_CAST((GHIDRA_INT(g_game->_room) + 0x1218)),&ultraDoors,0x126,-1,-1,1,0); local_14 = 0.0; if ((randomDoor->_state == 700) || (randomDoor->_state == 0x10)) { picker = (void *)0x0; pickerEnd = GHIDRA_CAST(0x0); pickerCapacity = GHIDRA_CAST(0x0); local_14 = 1.4013e-45; uStack_8c = uStack_8c & 0xffffffff; pEStack_84 = GHIDRA_CAST(0x64); msvc::vector<8byte>::_Emplace_reallocate(0,GHIDRA_INT(&uStack_8c) + 4); uVar3 = 0; outcomeCount = GHIDRA_INT(pickerEnd) - GHIDRA_INT(picker) >> 3; if (outcomeCount != 0) { do { if (*GHIDRA_CAST((GHIDRA_CAST(picker) + uVar3 * 8)) == 1) { outcomeWeight = GHIDRA_CAST((GHIDRA_INT(picker) + uVar3 * 8 + 4)); *outcomeWeight = *outcomeWeight + 0x46; if (*outcomeWeight < 0) { *GHIDRA_CAST((GHIDRA_CAST(picker) + uVar3 * 8 + 4)) = 0; } goto LAB_0059eaaa; } uVar3 = uVar3 + 1; } while (uVar3 < outcomeCount); } uStack_8c = CONCAT44(1,(uint32_t)uStack_8c); pEStack_84 = GHIDRA_CAST(0x46); if (pickerEnd == pickerCapacity) { msvc::vector<8byte>::_Emplace_reallocate(pickerEnd,GHIDRA_INT(&uStack_8c) + 4); } else { *pickerEnd = 1; pickerEnd[1] = 0x46; pickerEnd = pickerEnd + 2; } LAB_0059eaaa: pickSeed = Random(); pickSeed = pickSeed | 1; uStack_8c = 0x900000005; pEStack_84 = GHIDRA_CAST(&DAT_00000007); rng._shift1 = 5; rng._seed = pickSeed; rng._shift2 = 9; rng._shift3 = 7; uVar3 = WeightedOutcomePicker::PickOutcome(GHIDRA_CAST(&picker),rng); if ((uVar3 == 0) || (boss->_state == 0x10)) { Game::ShakeScreen(g_game,0xd); if ((float)ultraDoors._size != 0.0) { uVar3 = Random(); local_80 = (float)(uVar3 % GHIDRA_UINT(ultraDoors._size) + 1); if (0 < GHIDRA_INT(local_80)) { do { uVar3 = Random(); uVar4 = 0; randomDoor = (Entity_NPC *) __RTDynamicCast(*(uint32_t *) ((*GHIDRA_CAST((GHIDRA_CAST(&(ultraDoors)) + 0x4))) + (uVar3 % GHIDRA_UINT(ultraDoors._size)) * 4), 0,&IsaacRepentancePlus::Entity::RTTI_Type_Descriptor, &IsaacRepentancePlus::Entity_NPC::RTTI_Type_Descriptor,0); (*GHIDRA_CAST((GHIDRA_CAST(&(doors_00)) + 0x1))) = (int3)(GHIDRA_UINT(uVar4) >> 8); (*GHIDRA_CAST((GHIDRA_CAST(&(doors_00)) + 0x0))) = 1; (*GHIDRA_CAST((GHIDRA_CAST(&(doors_00)) + 0x4))) = (*GHIDRA_CAST((GHIDRA_CAST(&(ultraDoors)) + 0x4))); doors_00._capacity = ultraDoors._capacity; doors_00._size = ultraDoors._size; oppositeDoor = UltraDoor_Opposite(randomDoor,doors_00); if ((randomDoor != GHIDRA_CAST(0x0)) && (randomDoor->_state == 3)) { randomDoor->_state = 8; } if ((oppositeDoor != GHIDRA_CAST(0x0)) && (oppositeDoor->_state == 3)) { oppositeDoor->_state = 9; } local_80 = (float)(GHIDRA_INT(local_80) + -1); } while (local_80 != 0.0); } } } else if ((uVar3 == 1) && (Game::ShakeScreen(g_game,0x12), (float)ultraDoors._size != 0.0)) { local_80 = (float)ultraDoors._size; do { if ((float)ultraDoors._size == 0.0) { uVar3 = 0; } else { uVar3 = Random(); uVar3 = uVar3 % GHIDRA_UINT(ultraDoors._size); } uVar4 = 0; randomDoor = (Entity_NPC *) __RTDynamicCast(*GHIDRA_CAST(((*GHIDRA_CAST((GHIDRA_CAST(&(ultraDoors)) + 0x4))) + uVar3 * 4)),0, &IsaacRepentancePlus::Entity::RTTI_Type_Descriptor, &IsaacRepentancePlus::Entity_NPC::RTTI_Type_Descriptor,0); (*GHIDRA_CAST((GHIDRA_CAST(&(doors)) + 0x1))) = (int3)(GHIDRA_UINT(uVar4) >> 8); (*GHIDRA_CAST((GHIDRA_CAST(&(doors)) + 0x0))) = 1; (*GHIDRA_CAST((GHIDRA_CAST(&(doors)) + 0x4))) = (*GHIDRA_CAST((GHIDRA_CAST(&(ultraDoors)) + 0x4))); doors._capacity = ultraDoors._capacity; doors._size = ultraDoors._size; oppositeDoor = UltraDoor_Opposite(randomDoor,doors); if ((randomDoor != GHIDRA_CAST(0x0)) && (randomDoor->_state == 3)) { randomDoor->_state = 8; } if ((oppositeDoor != GHIDRA_CAST(0x0)) && (oppositeDoor->_state == 3)) { oppositeDoor->_state = 9; } local_80 = (float)(GHIDRA_INT(local_80) - 1); } while (local_80 != 0.0); local_80 = 0.0; } local_14 = (float)(GHIDRA_UINT(local_14) & 0xffffff00); if (picker != (void *)0x0) { uVar3 = (GHIDRA_INT(pickerCapacity) - GHIDRA_INT(picker) >> 3) * 8; room = picker; if (0xfff < uVar3) { room = *(void **)(GHIDRA_CAST(picker) + -4); uVar3 = uVar3 + 0x23; if (0x1f < GHIDRA_UINT((GHIDRA_INT(picker) + (-4 - GHIDRA_INT(room))))) { /* WARNING: Subroutine does not return */ _invalid_parameter_noinfo_noreturn(); } } operator_delete(room,uVar3); } } if ((boss->_state == 0x2c6) && (Game::ShakeScreen(g_game,10), (float)ultraDoors._size != 0.0)) { uVar3 = Random(); uVar4 = 0; randomDoor = (Entity_NPC *) __RTDynamicCast(*(uint32_t *) ((*GHIDRA_CAST((GHIDRA_CAST(&(ultraDoors)) + 0x4))) + (uVar3 % GHIDRA_UINT(ultraDoors._size)) * 4),0, &IsaacRepentancePlus::Entity::RTTI_Type_Descriptor, &IsaacRepentancePlus::Entity_NPC::RTTI_Type_Descriptor,0); (*GHIDRA_CAST((GHIDRA_CAST(&(doors_01)) + 0x1))) = (int3)(GHIDRA_UINT(uVar4) >> 8); (*GHIDRA_CAST((GHIDRA_CAST(&(doors_01)) + 0x0))) = 1; (*GHIDRA_CAST((GHIDRA_CAST(&(doors_01)) + 0x4))) = (*GHIDRA_CAST((GHIDRA_CAST(&(ultraDoors)) + 0x4))); doors_01._capacity = ultraDoors._capacity; doors_01._size = ultraDoors._size; pEStack_84 = randomDoor; oppositeDoor = UltraDoor_Opposite(randomDoor,doors_01); if (randomDoor != GHIDRA_CAST(0x0)) { randomDoor->_state = 8; randomDoor->_stateFrame = 0; } if (oppositeDoor != GHIDRA_CAST(0x0)) { oppositeDoor->_state = 9; oppositeDoor->_stateFrame = 0; } } if ((*GHIDRA_CAST((GHIDRA_CAST(&(ultraDoors)) + 0x0))) == '\0') { if (g_mainHeap == (void *)0x0) { allocCounter = &g_allocatedBytesNoHeap; } else { allocCounter = GHIDRA_CAST((GHIDRA_INT(g_mainHeap) + 0x30)); } if ((*GHIDRA_CAST((GHIDRA_CAST(&(ultraDoors)) + 0x4))) != 0) { uVar3 = *GHIDRA_CAST(((*GHIDRA_CAST((GHIDRA_CAST(&(ultraDoors)) + 0x4))) + -4)); qVar2 = *allocCounter; *GHIDRA_CAST(allocCounter) = GHIDRA_UINT(*allocCounter) - uVar3; *GHIDRA_CAST((GHIDRA_CAST(allocCounter) + 4)) = *GHIDRA_CAST((GHIDRA_CAST(allocCounter) + 4)) - GHIDRA_UINT((GHIDRA_UINT(qVar2) < uVar3)); free((void *)((*GHIDRA_CAST((GHIDRA_CAST(&(ultraDoors)) + 0x4))) + -4)); } } ExceptionList = local_1c; return; } // 005a7010 void NpcHelper::visage_spawn_particles(Vector *position, Vector *direction) { int iVar1; uint32_t rngResult; uint32_t rngValue; Entity *particle; int iVar2; int particlesLeft; float cosQuarterTurn; float sinQuarterTurn; float sideDirX; float sideDirY; float fVar5; uint8_t *spinSign; float fVar6; Vector local_18; Vector spawnPos; float dirX; float dirY; float sideDirX; float sideDirY; rngResult = Random(); cosQuarterTurn = cos(1.5707964); sinQuarterTurn = sin(1.5707964); dirX = direction->x; dirY = direction->y; for (particlesLeft = (rngResult & 3) + 5; particlesLeft != 0; particlesLeft = particlesLeft + -1) { rngResult = Random(); rngValue = Random(); sideDirX = (float)((double)GHIDRA_INT(rngValue) + __uint_to_double_fixup[-(GHIDRA_INT(rngValue) >> 0x1f)]) * 2.3283064e-10; sideDirY = direction->x; fVar5 = direction->y; rngValue = Random(); fVar6 = (float)((double)GHIDRA_INT(rngValue) + __uint_to_double_fixup[-(GHIDRA_INT(rngValue) >> 0x1f)]) * 2.3283064e-10; fVar6 = (fVar6 + fVar6) - 1.0; local_18.y = sideDirX * fVar5 * 5.0 + fVar6 * (dirY * cosQuarterTurn + dirX * sinQuarterTurn); local_18.x = sideDirX * sideDirY * 5.0 + fVar6 * (dirX * cosQuarterTurn - dirY * sinQuarterTurn); rngValue = Random(); sideDirY = (float)((double)GHIDRA_INT(rngValue) + __uint_to_double_fixup[-(GHIDRA_INT(rngValue) >> 0x1f)]) * 2.3283064e-10 * 3.14; sideDirY = sideDirY + sideDirY; rngValue = Random(); fVar5 = (float)((double)GHIDRA_INT(rngValue) + __uint_to_double_fixup[-(GHIDRA_INT(rngValue) >> 0x1f)]) * 2.3283064e-10; sideDirX = cos(sideDirY); spawnPos.x = sideDirX * fVar5 * 20.0 + position->x; sideDirY = sin(sideDirY); spawnPos.y = sideDirY * fVar5 * 20.0 + position->y; particle = Game::SpawnEx(g_game,1000,0x3b,&spawnPos,&local_18,GHIDRA_CAST(0x0),0,rngResult,0); sideDirY = (particle->_pos).x; fVar5 = (particle->_pos).y; sideDirX = position->x; fVar6 = position->y; sideDirX = direction->x; sideDirY = direction->y; rngResult = Random(); if (((float)((double)GHIDRA_INT(rngResult) + __uint_to_double_fixup[-(GHIDRA_INT(rngResult) >> 0x1f)]) * 2.3283064e-10 * 10.0 + 2.0) * (float)((sideDirY - sideDirX) * sideDirX + (fVar5 - fVar6) * sideDirY < 0.0) == 0.0) { spinSign = GHIDRA_CAST(0x3f800000); } else { spinSign = &DAT_bf800000; } *GHIDRA_CAST((particle[1]._sprite._animDefaultName._buf + 4)) = spinSign; rngResult = Random(); (particle->_posOffset).x = 0.0; (particle->_posOffset).y = -16.0; iVar1 = *GHIDRA_CAST(particle); iVar2 = rngResult % 10 + 0x1e; *GHIDRA_CAST((particle[1]._sprite._filename._buf + 4)) = iVar2; *GHIDRA_CAST((particle[1]._sprite._filename._buf + 8)) = iVar2; (**(code **)(iVar1 + 0xc))(); } return; } // 005a7310 void NpcHelper::visage_spawn_chain(Entity_NPC *npc) { uint32_t uVar1; int iVar2; uint32_t subType; uint32_t seed; Entity_NPC *pEVar3; uint32_t *puVar4; uint32_t *linkIter; uint32_t *linksEnd; Entity_NPC *local_28; int *local_24; Vector *spawnPos; uint32_t linkIndex; uint32_t *linksCapacityEnd; Entity_NPC *visage; void *local_10; uint8_t *puStack_c; uint32_t local_8; puStack_c = &LAB_00af597d; local_10 = ExceptionList; ExceptionList = &local_10; linkIter = GHIDRA_CAST(0x0); linksCapacityEnd = GHIDRA_CAST(0x0); linksEnd = GHIDRA_CAST(0x0); local_8 = 0; spawnPos = &npc->_pos; linkIndex = 0; visage = npc; do { subType = linkIndex; seed = Random(); pEVar3 = (Entity_NPC *) Game::Spawn(g_game,0x387,10,spawnPos,&g_vectorZero,GHIDRA_CAST(visage),subType,seed); uVar1 = *GHIDRA_CAST((GHIDRA_INT(&pEVar3->_flags) + 4)); *GHIDRA_CAST(&pEVar3->_flags) = GHIDRA_UINT(pEVar3->_flags) & 0xfffffffb; *GHIDRA_CAST((GHIDRA_INT(&pEVar3->_flags) + 4)) = uVar1; local_28 = pEVar3; if (pEVar3->_parent != 0) { local_24 = &pEVar3->_parent; msvc::multiset::erase(&local_24); } pEVar3->_parent = npc; if (npc != GHIDRA_CAST(0x0)) { msvc::multiset::insert(&pEVar3->_parent); } if (npc->_variant == 10) { puVar4 = &npc->_child; if (npc->_child != 0) { local_24 = puVar4; msvc::multiset::erase(&local_24); } *puVar4 = pEVar3; msvc::multiset::insert(puVar4); } if (linksEnd == linksCapacityEnd) { msvc::vector<4byte>::_Emplace_reallocate(linksEnd,&local_28); linksCapacityEnd = GHIDRA_CAST(0x0); } else { *linksEnd = pEVar3; linksEnd = linksEnd + 1; } linkIndex = linkIndex + 1; npc = pEVar3; } while (GHIDRA_INT(linkIndex) < 0x28); local_24 = GHIDRA_CAST(linksEnd[-1]); puVar4 = &visage->_entityRef; if (*puVar4 != 0) { local_28 = GHIDRA_CAST(puVar4); msvc::multiset::erase(&local_28); } *puVar4 = local_24; if (local_24 != GHIDRA_CAST(0x0)) { msvc::multiset::insert(puVar4); } puVar4 = &pEVar3->_child; iVar2 = visage->_child; if (*puVar4 != 0) { local_28 = GHIDRA_CAST(puVar4); msvc::multiset::erase(&local_28); } *puVar4 = iVar2; if (iVar2 != 0) { msvc::multiset::insert(puVar4); } if (linksEnd != GHIDRA_CAST(0x0)) { do { (**(code **)(*GHIDRA_CAST(*linkIter) + 0xc))(); linkIter = linkIter + 1; } while (linkIter != linksEnd); } ExceptionList = local_10; return; } // 005a7510 int NpcHelper::visage_plasma_cap() { int iVar1; iVar1 = *GHIDRA_CAST((GHIDRA_CAST(g_game->_room) + 4)); if ((iVar1 != 0) && (iVar1 = *GHIDRA_CAST((iVar1 + 0x10)), iVar1 != 0)) { switch(*GHIDRA_CAST((iVar1 + 0x48))) { case 4: case 6: return 6; case 8: case 9: case 10: case 0xb: case 0xc: return 8; } } return 4; } // 005a7590 float NpcHelper::visage_score_position(Entity_NPC *npc, Vector *position) { int iVar1; Entity *pEVar2; float fVar3; float fVar4; float fVar5; float fVar6; float fVar7; float targetDistSq; float local_1c; float local_18; pEVar2 = Entity_NPC::GetPlayerTarget(npc); iVar1 = npc->_child; if (iVar1 == 0) { fVar3 = (pEVar2->_pos).y - position->y; fVar5 = (pEVar2->_pos).targetDistSq - position->targetDistSq; fVar3 = sqrtf(fVar3 * fVar3 + fVar5 * fVar5); return 0.0 - ABS(fVar3 - 120.0); } if (GHIDRA_UINT(npc->_state) < 0x71) { local_1c = *GHIDRA_CAST((iVar1 + 0x340)) - position->y; local_18 = *GHIDRA_CAST((iVar1 + 0x33c)) - position->targetDistSq; fVar5 = local_1c * local_1c + local_18 * local_18; fVar3 = sqrtf(fVar5); fVar5 = sqrtf(fVar5); if (0.0 < fVar5) { local_18 = local_18 * (1.0 / fVar5); local_1c = local_1c * (1.0 / fVar5); } fVar5 = (pEVar2->_pos).y - position->y; fVar7 = (pEVar2->_pos).targetDistSq - position->targetDistSq; targetDistSq = fVar5 * fVar5 + fVar7 * fVar7; fVar6 = sqrtf(targetDistSq); if (0.0 < fVar6) { fVar7 = fVar7 * (1.0 / fVar6); fVar5 = fVar5 * (1.0 / fVar6); } fVar6 = (npc->_pos).targetDistSq - position->targetDistSq; fVar4 = (npc->_pos).y - position->y; targetDistSq = sqrtf(targetDistSq); fVar6 = sqrtf(fVar4 * fVar4 + fVar6 * fVar6); return fVar6 * 1.2 + (((fVar5 * local_1c + fVar7 * local_18) * 300.0 + fVar3 * 0.5 + 0.0) - ABS(targetDistSq - 120.0)); } local_18 = *GHIDRA_CAST((iVar1 + 0x340)) - position->y; local_1c = *GHIDRA_CAST((iVar1 + 0x33c)) - position->targetDistSq; fVar5 = local_18 * local_18 + local_1c * local_1c; fVar3 = sqrtf(fVar5); fVar5 = sqrtf(fVar5); if (0.0 < fVar5) { local_1c = local_1c * (1.0 / fVar5); local_18 = local_18 * (1.0 / fVar5); } fVar7 = (pEVar2->_pos).targetDistSq - position->targetDistSq; fVar6 = (pEVar2->_pos).y - position->y; targetDistSq = fVar6 * fVar6 + fVar7 * fVar7; fVar5 = sqrtf(targetDistSq); if (0.0 < fVar5) { fVar7 = fVar7 * (1.0 / fVar5); fVar6 = fVar6 * (1.0 / fVar5); } fVar5 = sqrtf(targetDistSq); return ((fVar6 * local_18 + fVar7 * local_1c) * 0.2 * 300.0 + fVar3 * 0.25 + 0.0) - ABS(fVar5 - 120.0); } // 005a7920 void NpcHelper::visage_pick_target_position(Entity_NPC *npc) { uint32_t rngResult; int triesLeft; float fVar1; float fVar2; float candidateX; float bestScore; Vector candidatePos; Vector clampedPos; Room *room; (npc->_targetPosition).x = (npc->_pos).x; (npc->_targetPosition).y = (npc->_pos).y; bestScore = visage_score_position(npc,&npc->_pos); triesLeft = 0x14; do { rngResult = Random(); fVar1 = (float)((double)GHIDRA_INT(rngResult) + __uint_to_double_fixup[-(GHIDRA_INT(rngResult) >> 0x1f)]) * 2.3283064e-10 * 3.14; fVar1 = fVar1 + fVar1; rngResult = Random(); fVar2 = (float)((double)GHIDRA_INT(rngResult) + __uint_to_double_fixup[-(GHIDRA_INT(rngResult) >> 0x1f)]) * 2.3283064e-10 * 100.0; candidateX = cos(fVar1); candidateX = candidateX * fVar2 + (npc->_pos).x; candidatePos.x = candidateX; fVar1 = sin(fVar1); room = g_game->_room; fVar1 = fVar1 * fVar2 + (npc->_pos).y; candidatePos.y = fVar1; if (*GHIDRA_CAST((*GHIDRA_CAST((*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((room)) + 0x4)))) + 0x10)) + 0x48)) - 9U < 4) { Room::GetClampedPositionImpl(room,&clampedPos,&candidatePos,10.0,10.0,10.0,10.0); if ((clampedPos.x == candidateX) && (clampedPos.y == fVar1)) { LAB_005a7ace: fVar2 = visage_score_position(npc,&candidatePos); if (bestScore < fVar2) { (npc->_targetPosition).x = candidateX; (npc->_targetPosition).y = fVar1; bestScore = fVar2; } } } else if (((((room->_topLeftPos).x + 10.0 <= candidateX) && (candidateX <= (room->_bottomRightPos).x - 10.0)) && ((room->_topLeftPos).y + 10.0 <= fVar1)) && (fVar1 <= (room->_bottomRightPos).y - 10.0) ) goto LAB_005a7ace; triesLeft = triesLeft + -1; if (triesLeft == 0) { return; } } while( true ); } // 005ab180 void NpcHelper::visage_start_charge(Entity_NPC *npc) { uint8_t bVar1; Vector *pVVar2; uint8_t *curAnimChar; uint32_t animCompare; Entity_Laser *laser; uint8_t *newAnimChar; bool isLess; float fVar3; int iVar4; Entity_NPC *source; Vector local_18; Vector VStack_10; uint8_t *animData; uint32_t flagsHigh; Manager *manager; if (npc->_state == 0x6d) { flagsHigh = *GHIDRA_CAST((GHIDRA_INT(&npc->_flags) + 4)); *GHIDRA_CAST(&npc->_flags) = GHIDRA_UINT(npc->_flags) & 0xffffffee; iVar4 = *GHIDRA_CAST(npc); *GHIDRA_CAST((GHIDRA_INT(&npc->_flags) + 4)) = flagsHigh; npc->_health = npc->_maxHitPoints; npc->_isInvicible = 0; (**(code **)(iVar4 + 0x40))(*GHIDRA_CAST((GHIDRA_CAST(npc->_config) + 0x28))); } manager = g_manager; local_18.x = 1.0; if (npc->_championColorIdx == 0x12) { local_18.x = 1.5; } else if (npc->_championColorIdx == 0x13) { local_18.x = 0.5; } VStack_10.x = 1.61149e-43; seed_fart_sound_override(GHIDRA_CAST(&VStack_10)); (GHIDRA_CAST((&manager->_sfxManager)))->SoundEffects::Play(GHIDRA_INT(VStack_10.x),1.0,2,0,local_18.x,0.0); pVVar2 = Isaac::GetAxisAlignedUnitVectorFromDir(&VStack_10,npc->_i1); (npc->_targetPosition).x = pVVar2->x; (npc->_targetPosition).y = pVVar2->y; sprintf(&DAT_00c7f858,GHIDRA_CAST("Charge2Loop%s")); animData = (npc->_sprite)._animState._animData; if (animData != GHIDRA_CAST(0x0)) { curAnimChar = animData; if (0xf < *GHIDRA_CAST((animData + 0x14))) { curAnimChar = *GHIDRA_CAST(animData); } newAnimChar = &DAT_00c7f858; do { bVar1 = *curAnimChar; isLess = bVar1 < *newAnimChar; if (bVar1 != *newAnimChar) { LAB_005ab300: animCompare = -GHIDRA_UINT(isLess) | 1; goto LAB_005ab305; } if (bVar1 == 0) break; bVar1 = curAnimChar[1]; isLess = bVar1 < newAnimChar[1]; if (bVar1 != newAnimChar[1]) goto LAB_005ab300; curAnimChar = curAnimChar + 2; newAnimChar = newAnimChar + 2; } while (bVar1 != 0); animCompare = 0; LAB_005ab305: if ((animCompare == 0) && ((animData[0x34] == 0 || ((npc->_sprite)._animState._isPlaying != 0))) ) goto LAB_005ab33c; } bVar1 = ANM2::SetAnimation(&npc->_sprite,&DAT_00c7f858,1); if (bVar1 != 0) { AnimationState::Rewind(&(npc->_sprite)._animState); (npc->_sprite)._animState._isPlaying = 1; } LAB_005ab33c: npc->_state = 0x6e; pVVar2 = &local_18; VStack_10.x = (npc->_targetPosition).y * -1.0; bVar1 = 0; iVar4 = 0x14; local_18.x = 0.0; local_18.y = -40.0; source = npc; fVar3 = atan2f(VStack_10.x,(npc->_targetPosition).x * -1.0); laser = Entity_Laser::ShootAngle (1,&npc->_pos,fVar3 * 57.295776,iVar4,pVVar2,GHIDRA_CAST(source),bVar1); fVar3 = 0.0; if (0.0 <= VStack_10.x) { fVar3 = 1000.0; } laser->_renderDepthOffset = fVar3; (**(code **)(*GHIDRA_CAST(laser) + 0xc))(); return; } // 005acd30 void NpcHelper::visage_chain_solve(Entity_NPC *npc, uint8_t isInterpolate) { Vector *pVVar1; Entity_NPC *pEVar2; int iVar3; Entity_NPC *pEVar4; uint8_t isFlipX; uint32_t uVar5; Vector *normalized; Entity_NPC *pEVar6; Entity_NPC *pEVar7; float fVar8; float angleDeg; Vector local_2c; float headY; float headX; Vector normDir; float dirX; float anchorY; float anchorX; int *parentSlot; int *state; pEVar2 = GHIDRA_CAST(npc->_child); if (((pEVar2 == GHIDRA_CAST(0x0)) || (pEVar2->_type != 0x387)) || (pEVar2->_variant != 10)) { parentSlot = &npc->_parent; pEVar7 = GHIDRA_CAST(npc->_parent); pEVar6 = npc; while (pEVar4 = pEVar7, pEVar4 != GHIDRA_CAST(0x0)) { pEVar6 = pEVar4; pEVar7 = GHIDRA_CAST(pEVar4->_parent); } pEVar7 = npc; if ((pEVar6->_type != 0x387) || (pEVar6->_variant != 0)) { pEVar6 = GHIDRA_CAST(0x0); } while (pEVar4 = pEVar2, pEVar4 != GHIDRA_CAST(0x0)) { pEVar7 = pEVar4; pEVar2 = GHIDRA_CAST(pEVar4->_child); } if (((pEVar7 == GHIDRA_CAST(0x0)) || (pEVar7->_type != 0x387)) || (pEVar7->_variant != 1)) { pEVar7 = GHIDRA_CAST(0x0); } if (pEVar6 != GHIDRA_CAST(0x0)) { pVVar1 = &pEVar6->_pos; headX = pVVar1->x; state = &npc->_state; headY = (pEVar6->_pos).y; if (npc->_state == 3) { if (pEVar7 == GHIDRA_CAST(0x0)) { return; } normalized = &pEVar7->_pos; anchorX = normalized->x; anchorY = (pEVar7->_pos).y; if (isInterpolate != 0) { uVar5 = GHIDRA_UINT((pEVar6->_isInterpolating != 0)); headX = (pEVar6->_velocity).x * 0.5 + *GHIDRA_CAST((GHIDRA_CAST((&pEVar6->_splatColor + 7)) + (uVar5 * 2 + 9) * 4)); headY = (pEVar6->_velocity).y * 0.5 + *GHIDRA_CAST((GHIDRA_CAST((&pEVar6->_splatColor + 7)) + (uVar5 * 2 + 10) * 4)); if (pEVar7->_isInterpolating != 0) { anchorX = (pEVar7->_preInterpolatePos).x; normalized = &pEVar7->_preInterpolatePos; } anchorX = (pEVar7->_velocity).x * 0.5 + anchorX; anchorY = (pEVar7->_velocity).y * 0.5 + normalized->y; } local_2c.x = headX - anchorX; local_2c.y = headY - anchorY; normalized = (GHIDRA_CAST((&local_2c)))->Vector::Normalized(&normDir); dirX = normalized->x; normDir.y = normalized->y; } else { anchorX = (npc->_pos).x; anchorY = (npc->_pos).y; if (isInterpolate != 0) { if (pEVar6->_isInterpolating == 0) { normalized = pVVar1; } else { headX = (pEVar6->_preInterpolatePos).x; normalized = &pEVar6->_preInterpolatePos; } headX = (pEVar6->_velocity).x * 0.5 + headX; headY = (pEVar6->_velocity).y * 0.5 + normalized->y; } dirX = headX - anchorX; normDir.y = headY - anchorY; fVar8 = sqrtf(dirX * dirX + normDir.y * normDir.y); if (0.0 < fVar8) { normDir.y = normDir.y * (1.0 / fVar8); dirX = dirX * (1.0 / fVar8); } anchorX = anchorX - dirX * 8.0; anchorY = anchorY - normDir.y * 8.0; } iVar3 = *parentSlot; while (iVar3 != 0) { fVar8 = sqrtf((headY - anchorY) * (headY - anchorY) + (headX - anchorX) * (headX - anchorX)) ; if (8.0 < fVar8) { if (16.0 <= fVar8) { local_2c.y = dirX * 16.0 + anchorX; fVar8 = normDir.y * 16.0 + anchorY; } else { local_2c.y = pVVar1->x; fVar8 = (pEVar6->_pos).y; } if (isInterpolate == 0) { npc->_visible = 1; npc->_entityCollisionClass = 4; } if ((*state == 3) || (((iVar3 = npc->_child, iVar3 != 0 && (*GHIDRA_CAST((iVar3 + 0x28)) == 0x387)) && (*GHIDRA_CAST((iVar3 + 0x2c)) == 10)))) { (npc->_pos).x = (anchorX + local_2c.y) * 0.5; (npc->_pos).y = (anchorY + fVar8) * 0.5; (npc->_velocity).x = g_vectorZero.x; (npc->_velocity).y = g_vectorZero.y; } (npc->_posOffset).y = -35.0; angleDeg = atan2f(normDir.y,dirX); angleDeg = angleDeg * 57.295776; if ((90.0 < angleDeg) || (angleDeg < -90.0)) { isFlipX = 1; angleDeg = 180.0 - angleDeg; } else { isFlipX = 0; } (npc->_sprite)._flipX = isFlipX; (npc->_sprite)._rotation = angleDeg; anchorX = local_2c.y; anchorY = fVar8; } else if (isInterpolate == 0) { (npc->_pos).x = pVVar1->x; (npc->_pos).y = (pEVar6->_pos).y; npc->_visible = 0; npc->_entityCollisionClass = 0; } npc = GHIDRA_CAST(*parentSlot); parentSlot = &npc->_parent; iVar3 = npc->_parent; } } } return; } // 005add40 uint8_t NpcHelper::visage_handle_collision(Entity_NPC *npc, Entity *collider, int unused) { Entity *targetRef; float newHealth; float healCap; int iVar2; float local_3c; int *local_38; uint32_t local_34; uint32_t uStack_30; uint32_t uStack_2c; uint32_t uStack_28; uint32_t local_24; uint32_t uStack_20; uint32_t uStack_1c; uint32_t uStack_18; uint32_t local_14; uint32_t local_10; uint32_t local_c; uint32_t local_8; uint32_t *targetRef; local_8 = __security_cookie ^ GHIDRA_INT(register0x00000010) - 4U; iVar2 = npc->_variant; if (iVar2 == 0) { if (((npc->_state != 0x76) || (collider->_type != 0x387)) || (collider->_variant != 0x14)) { return 0xff; } Entity_NPC::PlaySound(npc,0xb9,1.0,2,0,(float)npc->_stateFrame * 0.15 + 1.0); npc->_stateFrame = npc->_stateFrame + 1; (**(code **)(*GHIDRA_CAST(collider) + 0x28))(); local_34 = 0x3f800000; uStack_30 = 0x3f800000; uStack_2c = 0x3f800000; uStack_28 = 0x3f800000; local_14 = 0x3f800000; local_10 = 0x3dcccccd; local_c = 0; local_24 = 0; uStack_20 = 0; uStack_1c = 0; uStack_18 = 0; (**(code **)(*GHIDRA_CAST(npc) + 0x3c))(&local_34,10,0xff,1,1); healCap = npc->_maxHitPoints * 0.4; newHealth = npc->_maxHitPoints * 0.025 + npc->_health; if (healCap <= newHealth) { newHealth = healCap; } npc->_health = newHealth; return 0xff; } if (iVar2 == 1) { if ((collider->_type == 9) && (collider->_variant == 2)) { collider->_dead = 1; return 0; } if ((collider == GHIDRA_CAST(npc->_parent)) && (npc->_state == 0x6c)) { return 1; } if (collider->_type != 0x387) { return 0xff; } if (collider->_variant != 0x14) { return 0xff; } if (collider[2]._preInterpolatePos.x == 5.60519e-45) { return 0xff; } if ((npc->_state == 0x6a) || (npc->_state == 0x6d)) { (**(code **)(*GHIDRA_CAST(collider) + 0x28))(); local_34 = 0x3f800000; uStack_30 = 0x3f800000; uStack_2c = 0x3f800000; uStack_28 = 0x3f800000; local_14 = 0x3f800000; local_10 = 0x3e19999a; local_c = 0; local_24 = 0; uStack_20 = 0; uStack_1c = 0; uStack_18 = 0; (**(code **)(*GHIDRA_CAST(npc) + 0x3c))(&local_34,10,0xff,1,1); visage_start_charge(npc); return 0xff; } return 0xff; } if (iVar2 != 10) { if (iVar2 == 0x14) { return 0xff; } return 0; } targetRef = &npc->_target; if (collider == GHIDRA_CAST(npc->_target)) { return 1; } if (npc->_state != 5) { return 0xff; } iVar2 = collider->_type; if (iVar2 == 1) { iVar2 = 0x4d; } else { if (iVar2 == 4) { iVar2 = *GHIDRA_CAST((collider + 1)); *GHIDRA_CAST((collider + 1)) = iVar2 + 1; *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST(&(collider[1])) + 0x4)))) = iVar2 + 1; goto LAB_005adfbb; } if (iVar2 != 0x387) { return 0xff; } if (collider->_variant != 1) { return 0xff; } iVar2 = 0x8a; } Entity_NPC::PlaySound(npc,iVar2,1.0,2,0,1.0); LAB_005adfbb: targetRef = GHIDRA_CAST(FUN_005acc70()); if ((collider == targetRef) && (collider[2]._preInterpolatePos.x == 1.48538e-43)) { local_3c = (collider->_pos).x - *GHIDRA_CAST((collider->_parent + 0x33c)); local_38 = GHIDRA_CAST(((collider->_pos).y - *GHIDRA_CAST((collider->_parent + 0x340)))); FUN_005aafd0(&local_3c); collider[2]._preInterpolatePos.x = 1.49939e-43; } if (*targetRef != 0) { local_38 = targetRef; msvc::multiset::erase(&local_38); } *targetRef = collider; msvc::multiset::insert(targetRef); npc->_state = 7; (npc->_velocity).x = g_vectorZero.x; (npc->_velocity).y = g_vectorZero.y; return 1; } // 006d0ec0 void NpcHelper::fireplace_moveable_update(Entity_NPC *npc) { uint8_t bVar1; EntityRef *damageSource; uint8_t *curAnimName; uint32_t uVar2; LayerState *layer; int iVar3; uint8_t *wantedAnimName; char *wantedAnimNameStr; float *damageEvent; bool isLess; float fVar4; float fVar5; EntityRef damageSourceRef; float local_10; float local_c; char isIgnoreDamage; uint8_t *animData; uint32_t damageEventsBegin; uint64_t flags; Manager *manager; ANM2 *sprite; if ((npc->_variant == 0xc) || (npc->_variant == 0xd)) { isIgnoreDamage = '\x01'; } else { isIgnoreDamage = '\0'; if ((0.2 < *GHIDRA_CAST((GHIDRA_CAST(g_game->_room) + 0x7240))) && (bVar1 = Entity::IsFrame(GHIDRA_CAST(npc),5,npc->_index), bVar1 != 0)) { damageSource = EntityRef::EntityRef(&damageSourceRef); (**(code **)(*GHIDRA_CAST(npc) + 0x20))(0x3f800000,0,0,damageSource,0x1e); } } iVar3 = npc->_state; if (iVar3 != 0) { if (iVar3 != 3) { if (iVar3 == 0x10) { fVar4 = npc->_health - 1.0; if (fVar4 <= 0.01) { fVar4 = 0.01; } npc->_health = fVar4; if (((npc->_sprite)._animState._animData == (void *)0x0) || ((npc->_sprite)._animState._isPlaying == 0)) { (**(code **)(*GHIDRA_CAST(npc) + 0x28))(); } } goto LAB_006d1556; } sprite = &npc->_sprite; if (((npc->_sprite)._animState._animData == (void *)0x0) || ((npc->_sprite)._animState._isPlaying == 0)) { animData = (npc->_sprite)._animState._animData; if (animData != GHIDRA_CAST(0x0)) { curAnimName = animData; if (0xf < *GHIDRA_CAST((animData + 0x14))) { curAnimName = *GHIDRA_CAST(animData); } wantedAnimName = s_Idle; do { bVar1 = *curAnimName; isLess = bVar1 < *wantedAnimName; if (bVar1 != *wantedAnimName) { LAB_006d0fd0: uVar2 = -GHIDRA_UINT(isLess) | 1; goto LAB_006d0fd5; } if (bVar1 == 0) break; bVar1 = curAnimName[1]; isLess = bVar1 < wantedAnimName[1]; if (bVar1 != wantedAnimName[1]) goto LAB_006d0fd0; curAnimName = curAnimName + 2; wantedAnimName = wantedAnimName + 2; } while (bVar1 != 0); uVar2 = 0; LAB_006d0fd5: if ((uVar2 == 0) && ((animData[0x34] == 0 || ((npc->_sprite)._animState._isPlaying != 0)))) goto LAB_006d1001; } bVar1 = ANM2::SetAnimation(sprite,s_Idle,1); if (bVar1 != 0) { AnimationState::Rewind(&(npc->_sprite)._animState); (npc->_sprite)._animState._isPlaying = 1; } } LAB_006d1001: fVar4 = (npc->_targetPosition).x; if ((fVar4 == g_vectorZero.x) && ((npc->_targetPosition).y == g_vectorZero.y)) { if (npc->_spawnerType != 0x3b7) { fVar4 = npc->_friction * 0.95; goto LAB_006d107e; } } else { fVar5 = (npc->_pos).x; (npc->_velocity).y = (npc->_targetPosition).y - (npc->_pos).y; (npc->_velocity).x = fVar4 - fVar5; fVar4 = npc->_friction * 0.6; LAB_006d107e: npc->_friction = fVar4; } if (npc->_variant == 0xc) { fVar4 = npc->_speedMultiplier + (npc->_v1).x; (npc->_v1).x = fVar4; if (90.0 < fVar4) { fVar5 = npc->_health - 1.0; (npc->_v1).x = fVar4 - 90.0; if (fVar5 <= 1.0) { fVar5 = 1.0; } npc->_health = fVar5; local_c = (fVar5 * 0.9) / npc->_maxHitPoints + 0.1; local_10 = local_c * g_vectorOne.y; local_c = local_c * g_vectorOne.x; layer = ANM2::GetLayer(sprite,GHIDRA_CAST(0x0)); (layer->_size).x = local_c; (layer->_size).y = local_10; if (npc->_health <= 1.5 && npc->_health != 1.5) goto LAB_006d114a; } } else if (npc->_variant != 0xd) { iVar3 = 300; if (npc->_entityGridCollisionClass != 0) { iVar3 = 0xb4; } if (iVar3 < g_game->_frameCount - npc->_spawnFrame) { LAB_006d114a: npc->_state = 0x10; npc->_entityCollisionClass = 0; npc->_entityGridCollisionClass = 0; ANM2::Play(sprite,GHIDRA_CAST("Disappear"),0); goto LAB_006d1556; } } if (((npc->_spawnerType == 0x3b7) && (iVar3 = Entity::GetIntervalTicks(GHIDRA_CAST(npc),30.0,0.0), iVar3 != 0)) && (uVar2 = Random(), (uVar2 & 3) == 0)) { damageSource = EntityRef::EntityRef(&damageSourceRef); (**(code **)(*GHIDRA_CAST(npc) + 0x20))(0x3f800000,0x20000,0,damageSource,0x1e); } if (npc->_pendingDamage <= 0.0) goto LAB_006d1556; if ((npc->_pendingDamageFlags & 4) == 0) { if (isIgnoreDamage == '\0') { damageEvent = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((npc)) + 0x8)))); if (damageEvent == *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((npc)) + 0xc))))) { fVar4 = npc->_health; } else { do { if (10.0 < *damageEvent) { uVar2 = Random(); if (uVar2 % 3 == 0) { fVar4 = 3.0; } else { fVar4 = 2.0; } LAB_006d1299: fVar4 = npc->_health - fVar4; npc->_health = fVar4; } else { if (0.0 < *damageEvent) { uVar2 = Random(); if (uVar2 % 3 == 0) { fVar4 = 2.0; } else { fVar4 = 1.0; } goto LAB_006d1299; } fVar4 = npc->_health; } damageEvent = damageEvent + 0xe; } while (damageEvent != *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((npc)) + 0xc))))); } if (fVar4 < 1.0) goto LAB_006d12d6; } } else { LAB_006d12d6: npc->_health = 1.0; } local_10 = (npc->_health * 0.9) / npc->_maxHitPoints + 0.1; local_c = local_10 * g_vectorOne.y; local_10 = local_10 * g_vectorOne.x; layer = ANM2::GetLayer(&npc->_sprite,GHIDRA_CAST(0x0)); (layer->_size).x = local_10; (layer->_size).y = local_c; if (1.5 < npc->_health || npc->_health == 1.5) goto LAB_006d1556; npc->_state = 0x10; npc->_entityCollisionClass = 0; npc->_entityGridCollisionClass = 0; animData = (npc->_sprite)._animState._animData; if (animData == GHIDRA_CAST(0x0)) { LAB_006d13b6: bVar1 = ANM2::SetAnimation(&npc->_sprite,GHIDRA_CAST("Disappear"),1); if (bVar1 != 0) { AnimationState::Rewind(&(npc->_sprite)._animState); (npc->_sprite)._animState._isPlaying = 1; } } else { curAnimName = animData; if (0xf < *GHIDRA_CAST((animData + 0x14))) { curAnimName = *GHIDRA_CAST(animData); } wantedAnimNameStr = "Disappear"; do { bVar1 = *curAnimName; isLess = bVar1 < (uint8_t)*wantedAnimNameStr; if (bVar1 != *wantedAnimNameStr) { LAB_006d13a3: uVar2 = -GHIDRA_UINT(isLess) | 1; goto LAB_006d13a8; } if (bVar1 == 0) break; bVar1 = curAnimName[1]; isLess = bVar1 < (uint8_t)wantedAnimNameStr[1]; if (bVar1 != wantedAnimNameStr[1]) goto LAB_006d13a3; curAnimName = curAnimName + 2; wantedAnimNameStr = wantedAnimNameStr + 2; } while (bVar1 != 0); uVar2 = 0; LAB_006d13a8: if ((uVar2 != 0) || ((animData[0x34] != 0 && ((npc->_sprite)._animState._isPlaying == 0)))) goto LAB_006d13b6; } manager = g_manager; if ((npc->_pendingDamageFlags & 0x20000) == 0) { local_c = 3.65739e-43; seed_fart_sound_override(GHIDRA_CAST(&local_c)); (GHIDRA_CAST((&manager->_sfxManager)))->SoundEffects::Play(GHIDRA_INT(local_c),0.85,2,0,1.0,0.0); } goto LAB_006d1556; } fVar4 = npc->_health; flags = npc->_flags; *GHIDRA_CAST((GHIDRA_INT(&npc->_flags) + 4)) = *GHIDRA_CAST((GHIDRA_INT(&npc->_flags) + 4)); *GHIDRA_CAST(&npc->_flags) = GHIDRA_UINT(flags) & 0xfffffffb | 0x42050011; local_10 = (fVar4 * 0.9) / npc->_maxHitPoints + 0.1; local_c = local_10 * g_vectorOne.y; local_10 = local_10 * g_vectorOne.x; layer = ANM2::GetLayer(&npc->_sprite,GHIDRA_CAST(0x0)); (layer->_size).x = local_10; (layer->_size).y = local_c; animData = (npc->_sprite)._animState._animData; if (animData == GHIDRA_CAST(0x0)) { LAB_006d14f6: bVar1 = ANM2::SetAnimation(&npc->_sprite,GHIDRA_CAST("Appear"),1); if (bVar1 != 0) { AnimationState::Rewind(&(npc->_sprite)._animState); (npc->_sprite)._animState._isPlaying = 1; } } else { curAnimName = animData; if (0xf < *GHIDRA_CAST((animData + 0x14))) { curAnimName = *GHIDRA_CAST(animData); } wantedAnimNameStr = "Appear"; do { bVar1 = *curAnimName; isLess = bVar1 < (uint8_t)*wantedAnimNameStr; if (bVar1 != *wantedAnimNameStr) { LAB_006d14e0: uVar2 = -GHIDRA_UINT(isLess) | 1; goto LAB_006d14e5; } if (bVar1 == 0) break; bVar1 = curAnimName[1]; isLess = bVar1 < (uint8_t)wantedAnimNameStr[1]; if (bVar1 != wantedAnimNameStr[1]) goto LAB_006d14e0; curAnimName = curAnimName + 2; wantedAnimNameStr = wantedAnimNameStr + 2; } while (bVar1 != 0); uVar2 = 0; LAB_006d14e5: if ((uVar2 != 0) || ((animData[0x34] != 0 && ((npc->_sprite)._animState._isPlaying == 0)))) goto LAB_006d14f6; } npc->_state = 3; if (((npc->_targetPosition).x != g_vectorZero.x) || ((npc->_targetPosition).y != g_vectorZero.y)) { npc->_entityGridCollisionClass = 0; } LAB_006d1556: damageEventsBegin = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((npc)) + 0x8)))); npc->_pendingDamage = 0.0; *GHIDRA_CAST(&npc->_pendingDamageFlags) = 0; *GHIDRA_CAST((GHIDRA_INT(&npc->_pendingDamageFlags) + 4)) = 0; *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((npc)) + 0xc)))) = damageEventsBegin; return; }