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

1163 lines
41 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;
}
// 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;
}
// 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;
}