Files
isaac-port/generated-src/npc_helper.cpp
T

1713 lines
62 KiB
C++

#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<float *>((param_2 + 0x33c)) - *GHIDRA_CAST<float *>((rightSegment + 0x33c));
leftDx = *GHIDRA_CAST<float *>((param_2 + 0x33c)) - *GHIDRA_CAST<float *>((leftSegment + 0x33c));
fVar5 = *GHIDRA_CAST<float *>((param_2 + 0x340)) - *GHIDRA_CAST<float *>((rightSegment + 0x340));
leftDy = *GHIDRA_CAST<float *>((param_2 + 0x340)) - *GHIDRA_CAST<float *>((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<int *>(*leftNode);
if (leftNode == in_EDX) {
return in_ECX;
}
leftSegment = leftNode[2];
} while (leftSegment == param_2);
fVar6 = *GHIDRA_CAST<float *>((param_2 + 0x33c)) - *GHIDRA_CAST<float *>((rightSegment + 0x33c));
leftDx = *GHIDRA_CAST<float *>((param_2 + 0x33c)) - *GHIDRA_CAST<float *>((leftSegment + 0x33c));
fVar5 = *GHIDRA_CAST<float *>((param_2 + 0x340)) - *GHIDRA_CAST<float *>((rightSegment + 0x340));
leftDy = *GHIDRA_CAST<float *>((param_2 + 0x340)) - *GHIDRA_CAST<float *>((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<int *>(*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<float *>((param_2 + 0x33c)) - *GHIDRA_CAST<float *>((rightSegment + 0x33c));
leftDx = *GHIDRA_CAST<float *>((param_2 + 0x33c)) - *GHIDRA_CAST<float *>((leftSegment + 0x33c));
fVar5 = *GHIDRA_CAST<float *>((param_2 + 0x340)) - *GHIDRA_CAST<float *>((rightSegment + 0x340));
leftDy = *GHIDRA_CAST<float *>((param_2 + 0x340)) - *GHIDRA_CAST<float *>((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<uint32_t *>(piVar4[1]);
*puVar1 = in_EDX;
puVar2 = GHIDRA_CAST<uint32_t *>(in_EDX[1]);
*puVar2 = leftNode;
puVar3 = GHIDRA_CAST<uint32_t *>(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<int *>(*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<float *>((param_2 + 0x33c)) - *GHIDRA_CAST<float *>((rightSegment + 0x33c));
leftDx = *GHIDRA_CAST<float *>((param_2 + 0x33c)) - *GHIDRA_CAST<float *>((leftSegment + 0x33c));
fVar5 = *GHIDRA_CAST<float *>((param_2 + 0x340)) - *GHIDRA_CAST<float *>((rightSegment + 0x340));
leftDy = *GHIDRA_CAST<float *>((param_2 + 0x340)) - *GHIDRA_CAST<float *>((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<uint8_t *>(0x0)) {
currentName = animData;
if (0xf < *GHIDRA_CAST<uint32_t *>((animData + 0x14))) {
currentName = *GHIDRA_CAST<uint8_t **>(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<uint8_t *>("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<int *>(&local_c));
(GHIDRA_CAST<SoundEffects *>((&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<uint8_t *>(&npc->_i1) = 0;
(npc->_targetPosition).x = dirX * speed;
(npc->_targetPosition).y = local_c * speed;
return;
}
// 0055d070
uint8_t NpcHelper::polty_target_set(int gridIndex)
{
if (((gridIndex < 0) || (0x1bf < gridIndex)) ||
(*GHIDRA_CAST<short *>((GHIDRA_CAST<char *>(g_game->_room) + gridIndex * 2 + 0xe6c)) < 1)) {
*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(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<int *>((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<float *>((gridWidth + 0x340));
(npc->_pos).x = *GHIDRA_CAST<float *>((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<int *>((GHIDRA_CAST<char *>(g_game->_room) + gridIndex * 4 + 0x24));
if ((gridWidth != 0) &&
(((*GHIDRA_CAST<int *>((gridWidth + 4)) == 6 || (*GHIDRA_CAST<int *>((gridWidth + 4)) == 0x1a)) &&
(*GHIDRA_CAST<int *>((gridWidth + 0xc)) == 1)))) {
bVar1 = polty_target_set(npc,gridIndex);
if (bVar1 != 0) {
gridWidth = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(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<int *>((*GHIDRA_CAST<int *>((GHIDRA_INT((npc->_entityDeque)._map) +
((npc->_entityDeque)._mapSize - 1 & dequeBlock) * 4)) + dequeBlockSlot * 4))
!= 0) {
*GHIDRA_CAST<int *>((*GHIDRA_CAST<int *>((*GHIDRA_CAST<int *>((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<int *>((*GHIDRA_CAST<int *>((GHIDRA_INT((npc->_entityDeque)._map) +
((npc->_entityDeque)._mapSize - 1 & dequeBlock) * 4)) + dequeOffset * 4)) !=
0) {
*GHIDRA_CAST<int *>((*GHIDRA_CAST<int *>((*GHIDRA_CAST<int *>((GHIDRA_INT((npc->_entityDeque)._map) +
((npc->_entityDeque)._mapSize - 1 & dequeBlock) * 4)) +
dequeOffset * 4)) + 0x188)) = collisionClass;
}
}
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<Entity *>(0x0);
maxDistance = 0.0;
EntityList::QuerySublist(GHIDRA_CAST<EntityList *>((GHIDRA_INT(g_game->_room) + 0x1218)),&local_38,0x379,-1,-1,0,0);
uVar2 = 0;
tmpEntity = GHIDRA_CAST<Entity *>(0x0);
if (local_38._size != 0) {
enemiesData = (*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(local_38)) + 0x4)));
do {
tmpEntity = *GHIDRA_CAST<Entity **>((enemiesData + uVar2 * 4));
if (tmpEntity != GHIDRA_CAST<Entity *>(0x0)) {
if (((1 < *GHIDRA_CAST<int *>(&g_game->_deathmatchManager)) && (tmpEntity->_type == 1)) ||
(tmpEntity->_type - 10U < 0x3de)) {
local_24 = *GHIDRA_CAST<uint32_t *>((GHIDRA_INT(&tmpEntity->_flags) + 4));
isClutchFriendly = Entity::IsFriendly(GHIDRA_CAST<Entity *>(clutch));
if (((extraout_DL == isClutchFriendly) && (GHIDRA_CAST<Entity_NPC *>(tmpEntity->_parent) == clutch)) &&
((tmpEntity != GHIDRA_CAST<Entity *>(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<uint32_t *>((GHIDRA_CAST<char *>(&(local_38)) + 0x4)));
if (maxDistance < fVar3) {
maxDistance = fVar3;
local_18 = tmpEntity;
}
goto LAB_00572bab;
}
}
enemiesData = (*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(local_38)) + 0x4)));
}
LAB_00572bab:
uVar2 = uVar2 + 1;
tmpEntity = local_18;
} while (uVar2 < GHIDRA_UINT(local_38._size));
}
if ((*GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>(&(local_38)) + 0x0))) == '\0') {
if (g_mainHeap == (void *)0x0) {
heapAllocatedBytes = &g_allocatedBytesNoHeap;
}
else {
heapAllocatedBytes = GHIDRA_CAST<uint64_t *>((GHIDRA_INT(g_mainHeap) + 0x30));
}
if ((*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(local_38)) + 0x4))) != 0) {
uVar2 = *GHIDRA_CAST<uint32_t *>(((*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(local_38)) + 0x4))) + -4));
qVar1 = *heapAllocatedBytes;
*GHIDRA_CAST<uint32_t *>(heapAllocatedBytes) = GHIDRA_UINT(*heapAllocatedBytes) - uVar2;
*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(heapAllocatedBytes) + 4)) =
*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(heapAllocatedBytes) + 4)) - GHIDRA_UINT((GHIDRA_UINT(qVar1) < uVar2));
free(GHIDRA_CAST<uint32_t *>(((*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(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<uint32_t *>((GHIDRA_INT(&target->_flags) + 4));
*GHIDRA_CAST<uint32_t *>(&target->_flags) = GHIDRA_UINT(target->_flags) | 0x10;
*GHIDRA_CAST<uint32_t *>((GHIDRA_INT(&target->_flags) + 4)) = uVar1;
addFlagsFn = *(code **)(*GHIDRA_CAST<int *>(target) + 0x24);
local_54 = npc;
local_24 = uVar5;
EntityRef::constructor(GHIDRA_CAST<EntityRef *>(local_4c),GHIDRA_CAST<Entity *>(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<Entity *>(npc),0,uVar5);
animPathSize = 0;
fireSprite = &fire->_sprite;
animPathCapacity = &DAT_0000000f;
(*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(local_4c)) + 0x10))) = 0.0;
local_5c = fireSprite;
local_50 = fire;
(*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(local_4c)) + 0x10))) = msvc::_Allocate(0x30);
animPathSize = 0x20;
animPathCapacity = &DAT_0000002f;
builtin_strncpy((*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(GHIDRA_CAST<char *>(local_4c))) + 0x10))),"gfx/009.002_Fire Projectile.anm2",0x21);
local_14 = 0;
ANM2::Load(fireSprite,GHIDRA_CAST<std_string *>((local_4c + 0x10)),1);
local_14 = 0xffffffff;
if (&DAT_0000000f < animPathCapacity) {
size = animPathCapacity + 1;
pcVar7 = (*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(GHIDRA_CAST<char *>(local_4c))) + 0x10)));
if (GHIDRA_CAST<uint8_t *>(0xfff) < size) {
pcVar7 = *GHIDRA_CAST<char **>(((*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(local_4c)) + 0x10))) + -4));
size = animPathCapacity + 0x24;
if (GHIDRA_CAST<char *>(0x1f) < GHIDRA_CAST<char *>(((*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(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<uint8_t *>(0x0)) {
if (0xf < *GHIDRA_CAST<uint32_t *>((pbVar6 + 0x14))) {
pbVar6 = *GHIDRA_CAST<uint8_t **>(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<char *>((GHIDRA_INT((fire->_sprite)._animState._animData) + 0x34)) == '\0' ||
((fire->_sprite)._animState._isPlaying != 0)))) goto LAB_00572e7c;
}
bVar4 = ANM2::SetAnimation(fireSprite,GHIDRA_CAST<uint8_t *>("Flickering"),1);
if (bVar4 != 0) {
AnimationState::Rewind(&(fire->_sprite)._animState);
(fire->_sprite)._animState._isPlaying = 1;
}
LAB_00572e7c:
fireSprite = local_5c;
pbVar6 = GHIDRA_CAST<uint8_t *>(0x0);
if ((local_50->_sprite)._layerCount != 0) {
do {
layer = ANM2::GetLayer(fireSprite,pbVar6);
fVar3 = fRam00c34e34;
fVar2 = fRam00c34e30;
fVar9 = fRam00c34e2c;
if (&layer->_color != GHIDRA_CAST<ColorMod *>(&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<uint64_t *>((layer->_color)._offset) = DAT_00c34e48;
(layer->_color)._offset[2] = DAT_00c34e50;
}
pbVar6 = pbVar6 + 1;
} while (pbVar6 < GHIDRA_CAST<uint8_t *>((local_50->_sprite)._layerCount));
npc = local_54;
}
(**(code **)(*GHIDRA_CAST<int *>(local_50) + 0xc))();
local_50 = GHIDRA_CAST<Entity *>(0x2);
do {
uVar5 = Random();
local_54 = GHIDRA_CAST<Entity_NPC *>((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<ANM2 *>((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<Entity *>(npc),0,uVar5);
parentSlot = &local_54->_parent;
if (local_54->_parent != 0) {
local_64.y = (float)parentSlot;
msvc::multiset<unsigned_int>::erase(&local_64.y);
}
*parentSlot = npc;
if (npc != GHIDRA_CAST<Entity_NPC *>(0x0)) {
msvc::multiset<unsigned_int>::insert(parentSlot);
}
uVar5 = Random();
local_50 = GHIDRA_CAST<Entity *>((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<Entity *>(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<uint8_t *>(0x1));
if ((0.0 < (pLVar1->_color)._tint[3]) && ((npc->_vectorDeque1)._size != 0)) {
pLVar1 = ANM2::GetLayer(&npc->_sprite,GHIDRA_CAST<uint8_t *>(0x1));
pLVar1->_visible = 1;
pLVar1 = ANM2::GetLayer(&npc->_sprite,GHIDRA_CAST<uint8_t *>(0x2));
layerId = GHIDRA_CAST<uint8_t *>(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<int *>(0x0)) {
iVar3 = 0;
}
else {
iVar3 = *pointDeque;
}
pointBlock = GHIDRA_UINT(pointIndex) >> 1;
pointSlotOffset = (pointIndex & 1U) * 8;
pfVar2 = GHIDRA_CAST<float *>((*GHIDRA_CAST<int *>((*GHIDRA_CAST<int *>((iVar3 + 4)) +
(*GHIDRA_CAST<int *>((iVar3 + 8)) - 1U & pointBlock) * 4)) + pointSlotOffset))
;
if (pointDeque == GHIDRA_CAST<int *>(0x0)) {
iVar3 = 0;
}
else {
iVar3 = *pointDeque;
}
nextPointBlock = nextPointIndex >> 1;
fVar7 = g_displayPixelRatio * g_screenPointScale;
iVar6 = (nextPointIndex & 1) * 8;
nextPoint = GHIDRA_CAST<float *>((*GHIDRA_CAST<int *>((*GHIDRA_CAST<int *>((iVar3 + 4)) +
(*GHIDRA_CAST<int *>((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<int *>(0x0)) {
iVar3 = 0;
}
else {
iVar3 = *pointDeque;
}
if (pointDeque == GHIDRA_CAST<int *>(0x0)) {
iVar5 = 0;
}
else {
iVar5 = *pointDeque;
}
iVar3 = GHIDRA_INT((8.0 - (*GHIDRA_CAST<float *>((*GHIDRA_CAST<int *>((*GHIDRA_CAST<int *>((iVar5 + 4)) +
(nextPointIndex + 2 >> 1 &
*GHIDRA_CAST<int *>((iVar5 + 8)) - 1U) * 4)) +
(nextPointIndex + 2 & 1) * 8)) +
*GHIDRA_CAST<float *>((*GHIDRA_CAST<int *>((*GHIDRA_CAST<int *>((iVar3 + 4)) +
(nextPointIndex - 1 >> 1 & *GHIDRA_CAST<int *>((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<int *>(0x0)) {
iVar5 = 0;
}
else {
iVar5 = *pointDeque;
}
pfVar2 = GHIDRA_CAST<float *>((*GHIDRA_CAST<int *>((*GHIDRA_CAST<int *>((iVar5 + 4)) +
(*GHIDRA_CAST<int *>((iVar5 + 8)) - 1U & nextPointBlock) * 4)) + iVar6));
if (pointDeque == GHIDRA_CAST<int *>(0x0)) {
iVar6 = 0;
}
else {
iVar6 = *pointDeque;
}
iVar6 = *GHIDRA_CAST<int *>((*GHIDRA_CAST<int *>((iVar6 + 4)) + (*GHIDRA_CAST<int *>((iVar6 + 8)) - 1U & pointBlock) * 4));
fVar7 = atan2f(pfVar2[1] - *GHIDRA_CAST<float *>((iVar6 + 4 + pointSlotOffset)),
*pfVar2 - *GHIDRA_CAST<float *>((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<int *>((layerOffset + GHIDRA_INT(animData))), -1 < iVar3)) {
AnimationLayer::RenderFrame
(GHIDRA_CAST<AnimationLayer *>((iVar3 * 0x10 + *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(animData) + 0x18)))),
segmentPos,
*GHIDRA_CAST<int *>((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<int *>((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<int *>((layerOffset + GHIDRA_INT(animData))), -1 < iVar3)) {
AnimationLayer::RenderFrame
(GHIDRA_CAST<AnimationLayer *>((iVar3 * 0x10 + *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(animData) + 0x18)))),
segmentPos,
*GHIDRA_CAST<int *>((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<int *>((layerOffset + GHIDRA_INT(animData))), -1 < iVar3)) {
layerFrames = (npc->_sprite)._animState._layerFrames;
LAB_00575ed0:
AnimationLayer::RenderFrame
(GHIDRA_CAST<AnimationLayer *>((iVar3 * 0x10 + *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(animData) + 0x18)))),
segmentPos,*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(layerFrames) + iVar3 * 4)),&g_vectorZero,
&g_vectorZero,animation);
}
}
}
pointIndex = pointIndex + 3;
nextPointIndex = nextPointIndex + 3;
}
else {
if (pointDeque == GHIDRA_CAST<int *>(0x0)) {
iVar5 = 0;
}
else {
iVar5 = *pointDeque;
}
iVar5 = *GHIDRA_CAST<int *>((*GHIDRA_CAST<int *>((iVar5 + 4)) + (*GHIDRA_CAST<int *>((iVar5 + 8)) - 1U & pointBlock) * 4));
if (pointDeque == GHIDRA_CAST<int *>(0x0)) {
iVar4 = 0;
}
else {
iVar4 = *pointDeque;
}
pfVar2 = GHIDRA_CAST<float *>((*GHIDRA_CAST<int *>((*GHIDRA_CAST<int *>((iVar4 + 4)) +
(*GHIDRA_CAST<int *>((iVar4 + 8)) - 1U & nextPointBlock) * 4)) + iVar6));
fVar7 = pfVar2[1] - *GHIDRA_CAST<float *>((iVar5 + 4 + pointSlotOffset));
deltaX = *pfVar2 - *GHIDRA_CAST<float *>((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<uint8_t *>(0x1));
pLVar1->_visible = 0;
pLVar1 = ANM2::GetLayer(&npc->_sprite,GHIDRA_CAST<uint8_t *>(0x2));
pLVar1->_visible = 0;
}
}
Entity::Render(GHIDRA_CAST<Entity *>(npc),offset);
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<Entity_NPC *>(segment->_child), nextSegment != GHIDRA_CAST<Entity_NPC *>(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<Entity_NPC *>(segment->_parent), nextSegment != GHIDRA_CAST<Entity_NPC *>(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<uint8_t *>(0x0)) {
animNameCursor = animData;
if (0xf < *GHIDRA_CAST<uint32_t *>((animData + 0x14))) {
animNameCursor = *GHIDRA_CAST<uint8_t **>(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<Entity_NPC *>(0x48);
seed_fart_sound_override(GHIDRA_CAST<int *>(&local_c));
(GHIDRA_CAST<SoundEffects *>((&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<int *>((chainEnd + 0x3c0)), nextSegment != 0 &&
(*GHIDRA_CAST<int *>((nextSegment + 0x28)) == 0x38d)) && (*GHIDRA_CAST<int *>((nextSegment + 0x2c)) == 10))) {
chainEnd = nextSegment;
}
local_e8 = (in_ECX->_pos).x;
local_ec = (in_ECX->_pos).y;
childChainOffsetX = *GHIDRA_CAST<float *>((chainEnd + 0x33c)) - local_e8;
childChainOffsetY = *GHIDRA_CAST<float *>((chainEnd + 0x340)) - local_ec;
chainEnd = in_ECX->_entityRef;
while (((nextSegment = *GHIDRA_CAST<int *>((chainEnd + 0x3c0)), nextSegment != 0 &&
(*GHIDRA_CAST<int *>((nextSegment + 0x28)) == 0x38d)) && (*GHIDRA_CAST<int *>((nextSegment + 0x2c)) == 10))) {
chainEnd = nextSegment;
}
local_e8 = *GHIDRA_CAST<float *>((chainEnd + 0x33c)) - local_e8;
local_ec = *GHIDRA_CAST<float *>((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<uint32_t *>((GHIDRA_CAST<char *>(&(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<ProjectileParams *>(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<Entity *>(0x0),1,rngResult);
(**(code **)(*GHIDRA_CAST<int *>(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<int *>(&local_cc));
(GHIDRA_CAST<SoundEffects *>((&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<Entity *>(npc),1.15,1,4,0);
Game::ButterBeanFart(g_game,position,120.0,GHIDRA_CAST<Entity *>(npc),0,0);
Game::ShakeScreen(g_game,10);
game = g_game;
npc->_projectileCooldown = npc->_projectileCooldown + 1;
EntityList::QueryRadius(GHIDRA_CAST<EntityList *>((GHIDRA_INT(game->_room) + 0x1218)),&nearby,position,100.0,8);
local_8 = 0.0;
uVar3 = 0;
if (nearby._size != 0) {
do {
iVar1 = *GHIDRA_CAST<int *>(((*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(nearby)) + 0x4))) + uVar3 * 4));
if ((*GHIDRA_CAST<int *>((iVar1 + 0x28)) == 0x393) && (*GHIDRA_CAST<int *>((iVar1 + 0x2c)) == 1)) {
npc->_projectileCooldown = 0;
break;
}
uVar3 = uVar3 + 1;
} while (uVar3 < GHIDRA_UINT(nearby._size));
}
EntityList::QuerySublist(GHIDRA_CAST<EntityList *>((GHIDRA_INT(g_game->_room) + 0x1218)),&minions,0x393,1,-1,0,0);
local_8 = (float)CONCAT31((*GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>(&(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<Entity *>(npc),0,uVar3);
flagsHigh = *GHIDRA_CAST<uint32_t *>((GHIDRA_INT(&minion->_flags) + 4));
iVar1 = *GHIDRA_CAST<int *>(minion);
*GHIDRA_CAST<uint32_t *>(&minion->_flags) = GHIDRA_UINT(minion->_flags) & 0xfffffffb;
*GHIDRA_CAST<uint32_t *>((GHIDRA_INT(&minion->_flags) + 4)) = flagsHigh;
(**(code **)(iVar1 + 0xc))();
iVar1 = *GHIDRA_CAST<int *>(minion);
minion[2]._speedMultiplier = -500.0;
minion[2]._prevVelocity.x = 10.0;
(**(code **)(iVar1 + 0xc))();
}
if ((*GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>(&(minions)) + 0x0))) == '\0') {
heapCounter = GHIDRA_CAST<uint64_t *>((GHIDRA_INT(g_mainHeap) + 0x30));
if (g_mainHeap == (void *)0x0) {
heapCounter = &g_allocatedBytesNoHeap;
}
if ((*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(minions)) + 0x4))) != 0) {
uVar3 = *GHIDRA_CAST<uint32_t *>(((*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(minions)) + 0x4))) + -4));
qVar2 = *heapCounter;
*GHIDRA_CAST<uint32_t *>(heapCounter) = GHIDRA_UINT(*heapCounter) - uVar3;
*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(heapCounter) + 4)) =
*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(heapCounter) + 4)) - GHIDRA_UINT((GHIDRA_UINT(qVar2) < uVar3));
free((void *)((*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(minions)) + 0x4))) + -4));
}
}
if ((*GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>(&(nearby)) + 0x0))) == '\0') {
heapCounter = GHIDRA_CAST<uint64_t *>((GHIDRA_INT(g_mainHeap) + 0x30));
if (g_mainHeap == (void *)0x0) {
heapCounter = &g_allocatedBytesNoHeap;
}
if ((*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(nearby)) + 0x4))) != 0) {
uVar3 = *GHIDRA_CAST<uint32_t *>(((*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(nearby)) + 0x4))) + -4));
qVar2 = *heapCounter;
*GHIDRA_CAST<uint32_t *>(heapCounter) = GHIDRA_UINT(*heapCounter) - uVar3;
*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(heapCounter) + 4)) =
*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(heapCounter) + 4)) - GHIDRA_UINT((GHIDRA_UINT(qVar2) < uVar3));
free((void *)((*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(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<Entity *>(npc),0,seed);
*GHIDRA_CAST<uint32_t *>(&(*GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>((familiar)) + 0x45c)))) = 0x4b;
refSlot = &familiar->_parent;
*GHIDRA_CAST<uint32_t *>(&(*GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>((familiar)) + 0x460)))) = 0x4b;
if (familiar->_parent != 0) {
eraseRef[0] = refSlot;
msvc::multiset<unsigned_int>::erase(eraseRef);
}
*refSlot = npc;
if (npc != GHIDRA_CAST<Entity_NPC *>(0x0)) {
msvc::multiset<unsigned_int>::insert(refSlot);
}
refSlot = &familiar->_target;
if (*refSlot != 0) {
eraseRef[0] = refSlot;
msvc::multiset<unsigned_int>::erase(eraseRef);
}
*refSlot = pEVar3;
msvc::multiset<unsigned_int>::insert(refSlot);
local_14.y = (float)npc->_sirenPlayerEntity;
refSlot = &familiar->_child;
if (*refSlot != 0) {
eraseRef[0] = refSlot;
msvc::multiset<unsigned_int>::erase(eraseRef);
}
*refSlot = local_14.y;
if ((void *)local_14.y != (void *)0x0) {
msvc::multiset<unsigned_int>::insert(refSlot);
}
(**(code **)(*GHIDRA_CAST<int *>(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<Entity *>(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<Entity_Familiar *>(&secondEffect->_parent);
msvc::multiset<unsigned_int>::erase(&familiar);
}
secondEffect->_parent = npc;
msvc::multiset<unsigned_int>::insert(&secondEffect->_parent);
if (secondEffect->_target != 0) {
familiar = GHIDRA_CAST<Entity_Familiar *>(&secondEffect->_target);
msvc::multiset<unsigned_int>::erase(&familiar);
}
secondEffect->_target = pEVar3;
msvc::multiset<unsigned_int>::insert(&secondEffect->_target);
pvVar1 = npc->_sirenPlayerEntity;
refSlot = &secondEffect->_child;
if (*refSlot != 0) {
familiar = GHIDRA_CAST<Entity_Familiar *>(refSlot);
msvc::multiset<unsigned_int>::erase(&familiar);
}
*refSlot = pvVar1;
if (pvVar1 != (void *)0x0) {
msvc::multiset<unsigned_int>::insert(refSlot);
}
(**(code **)(*GHIDRA_CAST<int *>(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<EntityList *>((GHIDRA_INT(game->_room) + 0x1218)),&local_24,3,-1,-1,0,0);
uVar2 = 0;
if (local_24._size != 0) {
familiarsData = (*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(local_24)) + 0x4)));
do {
familiar = *GHIDRA_CAST<int *>((familiarsData + uVar2 * 4));
if ((familiar != 0) && (*GHIDRA_CAST<int *>((familiar + 0x28)) == 3)) {
isCharmable = FUN_0060dae0(uVar1);
if (isCharmable != '\0') {
if ((*GHIDRA_CAST<uint32_t *>((extraout_ECX + 0x168)) & 0x100) == 0) {
*outFreeCount = *outFreeCount + 1;
}
else {
*outCharmedCount = *outCharmedCount + 1;
}
*outTotalCount = *outTotalCount + 1;
}
familiarsData = (*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(local_24)) + 0x4)));
uVar2 = extraout_EDX;
}
uVar2 = uVar2 + 1;
} while (uVar2 < GHIDRA_UINT(local_24._size));
}
if ((*GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>(&(local_24)) + 0x0))) == '\0') {
if (g_mainHeap == (void *)0x0) {
heapAllocatedBytes = &g_allocatedBytesNoHeap;
}
else {
heapAllocatedBytes = GHIDRA_CAST<uint64_t *>((GHIDRA_INT(g_mainHeap) + 0x30));
}
if ((*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(local_24)) + 0x4))) != 0) {
uVar2 = *GHIDRA_CAST<uint32_t *>(((*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(local_24)) + 0x4))) + -4));
oldAllocatedBytes = *heapAllocatedBytes;
*GHIDRA_CAST<uint32_t *>(heapAllocatedBytes) = GHIDRA_UINT(*heapAllocatedBytes) - uVar2;
*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(heapAllocatedBytes) + 4)) =
*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(heapAllocatedBytes) + 4)) - GHIDRA_UINT((GHIDRA_UINT(oldAllocatedBytes) < uVar2));
free(GHIDRA_CAST<uint32_t *>(((*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(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<EntityList *>((GHIDRA_INT(g_game->_room) + 0x1218)),&local_24,3,-1,-1,0,0);
uVar2 = 0;
if (local_24._size != 0) {
do {
familiar = *GHIDRA_CAST<Entity_Familiar **>(((*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(local_24)) + 0x4))) + uVar2 * 4));
if ((((familiar != GHIDRA_CAST<Entity_Familiar *>(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<uint8_t *>((GHIDRA_CAST<char *>(&(local_24)) + 0x0))) == '\0') {
if (g_mainHeap == (void *)0x0) {
allocatedBytes = &g_allocatedBytesNoHeap;
}
else {
allocatedBytes = GHIDRA_CAST<uint64_t *>((GHIDRA_INT(g_mainHeap) + 0x30));
}
if ((*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(local_24)) + 0x4))) != 0) {
uVar2 = *GHIDRA_CAST<uint32_t *>(((*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(local_24)) + 0x4))) + -4));
qVar1 = *allocatedBytes;
*GHIDRA_CAST<uint32_t *>(allocatedBytes) = GHIDRA_UINT(*allocatedBytes) - uVar2;
*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(allocatedBytes) + 4)) =
*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(allocatedBytes) + 4)) - GHIDRA_UINT((GHIDRA_UINT(qVar1) < uVar2));
free((void *)((*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(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<uint8_t *>((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<uint32_t *>(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<uint32_t *>(0x0);
outcomesEnd = GHIDRA_CAST<uint32_t *>(0x0);
outcomesCapacity = GHIDRA_CAST<uint32_t *>(0x0);
local_14 = 0;
local_54 = npc;
siren_familiar_counts(GHIDRA_CAST<int *>(&local_40),GHIDRA_CAST<int *>(&local_44),&local_64._size);
charmedCount = siren_charmed_count(local_54);
controlledTotal = GHIDRA_CAST<uint32_t *>(0x0);
EntityList::QuerySublist(GHIDRA_CAST<EntityList *>((GHIDRA_INT(g_game->_room) + 0x1218)),&local_64,3,-1,-1,0,0);
fVar4 = 0.0;
outcomesBegin = controlledCount;
outcomeCursor = GHIDRA_CAST<uint32_t *>(0x0);
if ((float)local_64._size != 0.0) {
do {
familiar = *GHIDRA_CAST<int *>(((*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(local_64)) + 0x4))) + GHIDRA_INT(fVar4) * 4));
if ((familiar == 0) || (*GHIDRA_CAST<int *>((familiar + 0x28)) != 3)) {
familiar = 0;
}
if (((*GHIDRA_CAST<uint32_t *>((familiar + 0x168)) & 0x100) != 0) &&
(*(void **)(familiar + 0x410) == local_54->_sirenPlayerEntity)) {
controlledCount = GHIDRA_CAST<uint32_t *>((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<uint8_t *>((GHIDRA_CAST<char *>(&(local_64)) + 0x0))) == '\0') {
if (g_mainHeap == (void *)0x0) {
heapCounter = &g_allocatedBytesNoHeap;
}
else {
heapCounter = GHIDRA_CAST<uint64_t *>((GHIDRA_INT(g_mainHeap) + 0x30));
}
if ((*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(local_64)) + 0x4))) != 0) {
uVar2 = *GHIDRA_CAST<uint32_t *>(((*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(local_64)) + 0x4))) + -4));
qVar1 = *heapCounter;
*GHIDRA_CAST<uint32_t *>(heapCounter) = GHIDRA_UINT(*heapCounter) - uVar2;
*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(heapCounter) + 4)) =
*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(heapCounter) + 4)) - GHIDRA_UINT((GHIDRA_UINT(qVar1) < uVar2));
free(GHIDRA_CAST<uint32_t *>(((*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(local_64)) + 0x4))) + -4)));
}
local_14 = local_14 & 0xffffff00;
}
if ((*GHIDRA_CAST<char *>((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<char *>((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<char *>(&(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<char *>((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<float *>((GHIDRA_CAST<char *>(room) + 0x1c));
fVar3 = *GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(room) + 0x20));
rightEdgeStart = fVar4 - 80.0;
local_40 = *GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(room) + 0x14));
leftEdgeStart = local_40 + 80.0;
roomCenterY = (fVar3 - *GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(room) + 0x18))) * 0.5 + *GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(room) + 0x18));
local_44 = (local_54->_pos).x;
if (rightEdgeStart == fVar4) {
KAGE_LogMessage(0x10,GHIDRA_CAST<uint8_t *>("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<uint8_t *>("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<uint8_t *>("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<uint64_t *>((GHIDRA_CAST<char *>(&(local_64)) + 0x4))) = (*GHIDRA_CAST<uint64_t *>((GHIDRA_CAST<char *>(&(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<uint32_t *>((GHIDRA_CAST<char *>(&(local_64)) + 0x0))) = Random();
(*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(local_64)) + 0x0))) = (*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(local_64)) + 0x0))) | 1;
(*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(local_64)) + 0x4))) = 5;
local_64._capacity = 9;
local_64._size = 7;
rng._shift1 = 5;
rng._seed = (*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(local_64)) + 0x0)));
rng._shift2 = 9;
rng._shift3 = 7;
uVar2 = WeightedOutcomePicker::PickOutcome(GHIDRA_CAST<WeightedOutcomePicker *>(&picker),rng);
if (uVar2 == 0) {
*GHIDRA_CAST<uint16_t *>((GHIDRA_INT(&local_54->_projectileCooldown) + 2)) = 0;
}
else {
charmedCount = local_3c[uVar2];
*GHIDRA_CAST<uint16_t *>(&local_54->_projectileCooldown) = 0xffff;
local_54->_state = charmedCount;
}
if (picker != GHIDRA_CAST<uint32_t *>(0x0)) {
uVar2 = GHIDRA_INT(outcomesCapacity) - GHIDRA_INT(picker) & 0xfffffff8;
outcomesBegin = picker;
if (0xfff < uVar2) {
outcomesBegin = GHIDRA_CAST<uint32_t *>(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;
}