The decompiled C++ tree moves to generated-src/ (classes.h, C++20); src/ is for code written by hand. A curated function defines the generated declaration and starts its comment with its address, and source_tree.py stops emitting that body. src/rng.cpp takes over RNG (SetSeed, the constructor, Next, RandomInt, RandomFloat, Shuffle) with the shift table read from the exe as a constexpr array; src/log.h names KAGE_LogMessage's levels (1 INFO, 2 NET, 4 WARN, 8 ERROR, 16 ASSERT, from its prefix jump table). CMakeLists.txt builds src/*.cpp against generated-src/classes.h (clean with -Wall -Wextra). structs.hpp and headers.py are retired: scripts/merge_fields.py writes the merged field list, classes.h checks the layout. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
13377 lines
496 KiB
C++
13377 lines
496 KiB
C++
#include "classes.h"
|
|
|
|
// 004830e0
|
|
void NpcHelper::the_lamb_pattern(Entity_NPC *npc, int pattern, int frame)
|
|
{
|
|
Entity *target;
|
|
uint uVar1;
|
|
int projectileCount;
|
|
bool isEighthFrame;
|
|
float fVar2;
|
|
float pitch;
|
|
Vector local_c8;
|
|
float dirY;
|
|
float dirX;
|
|
float projectileSpeed;
|
|
ProjectileParams params;
|
|
float local_8;
|
|
Manager *manager;
|
|
|
|
local_8 = (float)(__security_cookie ^ GHIDRA_UINT(&(¶ms)[1].CircleAngle));
|
|
(GHIDRA_CAST<ProjectileParams *>((¶ms)))->ProjectileParams::ProjectileParams();
|
|
params.HeightModifier = 5.0;
|
|
params.Scale = 1.8;
|
|
params.FallingAccelModifier = -0.06;
|
|
params.FallingSpeedModifier = -2.0;
|
|
target = (GHIDRA_CAST<Entity_NPC *>((npc)))->Entity_NPC::GetPlayerTarget();
|
|
dirX = (target->_pos).x - (npc->_pos).x;
|
|
dirY = (target->_pos).y - (npc->_pos).y;
|
|
fVar2 = sqrtf(dirX * dirX + dirY * dirY);
|
|
pitch = 1.0;
|
|
if (0.0 < fVar2) {
|
|
dirY = (1.0 / fVar2) * dirY;
|
|
dirX = (1.0 / fVar2) * dirX;
|
|
}
|
|
local_c8.y = atan2f(dirY,dirX);
|
|
if (pattern < 4) {
|
|
params.Color._colorize[0] = (float)0x3f333333;
|
|
params.Color._colorize[1] = (float)0x3f333333;
|
|
params.Color._colorize[2] = 1.0;
|
|
params.Color._colorize[3] = 1.0;
|
|
if (pattern == 0) {
|
|
if (frame != (frame / 3) * 3) {
|
|
return;
|
|
}
|
|
fVar2 = (float)frame * 0.125;
|
|
}
|
|
else {
|
|
if (pattern != 1) {
|
|
if (pattern == 2) {
|
|
if (frame % 0x16 != 0) {
|
|
return;
|
|
}
|
|
projectileCount = 3;
|
|
projectileSpeed = 8.0;
|
|
(*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(params.BulletFlags)) + 0x0))) = GHIDRA_UINT(params.BulletFlags) | 0x10000;
|
|
params.FallingSpeedModifier = 0.0;
|
|
params.FallingAccelModifier = 0.0;
|
|
}
|
|
else {
|
|
if (pattern != 3) {
|
|
return;
|
|
}
|
|
if (frame % 0x16 != 0) {
|
|
return;
|
|
}
|
|
projectileSpeed = 9.0;
|
|
projectileCount = 10;
|
|
}
|
|
goto LAB_00483620;
|
|
}
|
|
if (frame != (frame / 3) * 3) {
|
|
return;
|
|
}
|
|
fVar2 = (float)frame * -0.125;
|
|
}
|
|
projectileSpeed = 12.0;
|
|
projectileCount = 5;
|
|
params.CircleAngle = (fVar2 / 30.0) * 6.2831855;
|
|
}
|
|
else {
|
|
(*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(params.BulletFlags)) + 0x0))) = GHIDRA_UINT(params.BulletFlags) | 1;
|
|
params.HomingStrength = 0.3;
|
|
if (pattern == 4) {
|
|
uVar1 = frame & 0x80000007;
|
|
isEighthFrame = uVar1 == 0;
|
|
if (GHIDRA_INT(uVar1) < 0) {
|
|
isEighthFrame = (uVar1 - 1 | 0xfffffff8) == 0xffffffff;
|
|
}
|
|
if (!isEighthFrame) {
|
|
return;
|
|
}
|
|
projectileSpeed = 9.0;
|
|
projectileCount = 7;
|
|
params.FireDirectionLimit.x = dirX;
|
|
params.FireDirectionLimit.y = dirY;
|
|
params.DotProductLimit = 0.4;
|
|
params.CircleAngle = 0.0;
|
|
}
|
|
else if (pattern == 5) {
|
|
uVar1 = frame & 0x80000007;
|
|
isEighthFrame = uVar1 == 0;
|
|
if (GHIDRA_INT(uVar1) < 0) {
|
|
isEighthFrame = (uVar1 - 1 | 0xfffffff8) == 0xffffffff;
|
|
}
|
|
if (!isEighthFrame) {
|
|
return;
|
|
}
|
|
projectileSpeed = 9.0;
|
|
projectileCount = 7;
|
|
params.FireDirectionLimit.x = dirX;
|
|
params.FireDirectionLimit.y = dirY;
|
|
params.DotProductLimit = 0.4;
|
|
params.CircleAngle = local_c8.y;
|
|
}
|
|
else if (pattern == 6) {
|
|
uVar1 = frame & 0x80000007;
|
|
isEighthFrame = uVar1 == 0;
|
|
if (GHIDRA_INT(uVar1) < 0) {
|
|
isEighthFrame = (uVar1 - 1 | 0xfffffff8) == 0xffffffff;
|
|
}
|
|
if (!isEighthFrame) {
|
|
return;
|
|
}
|
|
projectileSpeed = 9.0;
|
|
projectileCount = 7;
|
|
params.FireDirectionLimit.x = dirX;
|
|
params.FireDirectionLimit.y = dirY;
|
|
params.DotProductLimit = 0.4;
|
|
uVar1 = Random();
|
|
params.CircleAngle =
|
|
((float)((double)GHIDRA_INT(uVar1) + __uint_to_double_fixup[-(GHIDRA_INT(uVar1) >> 0x1f)]) *
|
|
2.3283064e-10 - 0.5) * 3.1415927 * 0.1 + local_c8.y + 0.44879895;
|
|
}
|
|
else if (pattern == 7) {
|
|
uVar1 = frame & 0x80000007;
|
|
isEighthFrame = uVar1 == 0;
|
|
if (GHIDRA_INT(uVar1) < 0) {
|
|
isEighthFrame = (uVar1 - 1 | 0xfffffff8) == 0xffffffff;
|
|
}
|
|
if (!isEighthFrame) {
|
|
return;
|
|
}
|
|
projectileSpeed = 9.0;
|
|
projectileCount = 7;
|
|
params.FireDirectionLimit.y = dirY;
|
|
params.DotProductLimit = 0.4;
|
|
params.FireDirectionLimit.x = dirX;
|
|
fVar2 = sin(((float)frame + (float)frame) / 30.0);
|
|
params.CircleAngle = fVar2 * 0.44879895 + local_c8.y + 0.44879895;
|
|
}
|
|
else if (pattern == 8) {
|
|
if (frame % 0xd != 0) {
|
|
return;
|
|
}
|
|
projectileSpeed = 9.0;
|
|
projectileCount = 8;
|
|
params.FireDirectionLimit.x = dirX;
|
|
params.FireDirectionLimit.y = dirY;
|
|
params.DotProductLimit = 0.0;
|
|
}
|
|
else {
|
|
if (pattern != 9) {
|
|
return;
|
|
}
|
|
if (frame % 10 != 0) {
|
|
return;
|
|
}
|
|
projectileCount = 3;
|
|
projectileSpeed = 9.0;
|
|
params.HomingStrength = 0.65;
|
|
params.CircleAngle = (((float)frame * -0.125) / 30.0) * 6.2831855;
|
|
}
|
|
}
|
|
LAB_00483620:
|
|
uVar1 = Random();
|
|
manager = g_manager;
|
|
if (npc->_championColorIdx == 0x12) {
|
|
pitch = 1.5;
|
|
}
|
|
else if (npc->_championColorIdx == 0x13) {
|
|
pitch = 0.5;
|
|
}
|
|
local_c8.y = 1.62551e-43;
|
|
seed_fart_sound_override(GHIDRA_CAST<int *>(&local_c8.y));
|
|
(GHIDRA_CAST<SoundEffects *>((&manager->_sfxManager)))->SoundEffects::Play(GHIDRA_INT(local_c8.y),0.6,uVar1 % 0x1e + 0x14,0,pitch,0.0);
|
|
local_c8.x = projectileSpeed;
|
|
local_c8.y = (float)projectileCount;
|
|
Entity_NPC::FireProjectiles(npc,&npc->_pos,&local_c8,9,¶ms);
|
|
return;
|
|
}
|
|
|
|
// 00499a50
|
|
int * NpcHelper::chub_nearest_segment(int *param_1, int param_2)
|
|
{
|
|
undefined4 *puVar1;
|
|
undefined4 *puVar2;
|
|
undefined4 *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<undefined4 *>(piVar4[1]);
|
|
*puVar1 = in_EDX;
|
|
puVar2 = GHIDRA_CAST<undefined4 *>(in_EDX[1]);
|
|
*puVar2 = leftNode;
|
|
puVar3 = GHIDRA_CAST<undefined4 *>(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)
|
|
{
|
|
byte bVar1;
|
|
byte *currentName;
|
|
uint compareResult;
|
|
char *chargeBeginName;
|
|
bool isLess;
|
|
float length;
|
|
float dirX;
|
|
float local_c;
|
|
float local_8;
|
|
byte *animData;
|
|
Manager *manager;
|
|
|
|
animData = (npc->_sprite)._animState._animData;
|
|
if (animData != GHIDRA_CAST<byte *>(0x0)) {
|
|
currentName = animData;
|
|
if (0xf < *GHIDRA_CAST<uint *>((animData + 0x14))) {
|
|
currentName = *GHIDRA_CAST<byte **>(animData);
|
|
}
|
|
chargeBeginName = "ChargeBegin";
|
|
do {
|
|
bVar1 = *currentName;
|
|
isLess = bVar1 < (byte)*chargeBeginName;
|
|
if (bVar1 != *chargeBeginName) {
|
|
LAB_0049f8b6:
|
|
compareResult = -GHIDRA_UINT(isLess) | 1;
|
|
goto LAB_0049f8bb;
|
|
}
|
|
if (bVar1 == 0) break;
|
|
bVar1 = currentName[1];
|
|
isLess = bVar1 < (byte)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 = (GHIDRA_CAST<ANM2 *>((&npc->_sprite)))->ANM2::SetAnimation(GHIDRA_CAST<byte *>("ChargeBegin"),1);
|
|
if (bVar1 != 0) {
|
|
(GHIDRA_CAST<AnimationState *>((&(npc->_sprite)._animState)))->AnimationState::Rewind();
|
|
(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<undefined1 *>(&npc->_i1) = 0;
|
|
(npc->_targetPosition).x = dirX * speed;
|
|
(npc->_targetPosition).y = local_c * speed;
|
|
return;
|
|
}
|
|
|
|
// 004a1000
|
|
void NpcHelper::chimera_render_child(Entity_NPC *npc, Vector *offset)
|
|
{
|
|
int iVar1;
|
|
int iVar2;
|
|
int iVar3;
|
|
int iVar4;
|
|
int iVar5;
|
|
int iVar6;
|
|
EntityPtr EVar7;
|
|
void *layerFrame;
|
|
LayerState *pLVar8;
|
|
uint frameX;
|
|
|
|
if (((((npc->_type == 0x38e) && (npc->_variant == 1)) && (npc->_state == 0x10)) &&
|
|
((EVar7 = npc->_child, EVar7 != (EntityPtr)0x0 && (*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(EVar7) + 0xb64)) == 0x10)))) &&
|
|
(*GHIDRA_CAST<char *>((GHIDRA_CAST<char *>(EVar7) + 0x171)) == '\0')) {
|
|
layerFrame = (GHIDRA_CAST<AnimationState *>((&(npc->_sprite)._animState)))->AnimationState::GetLayerFrame(2);
|
|
if ((layerFrame != (void *)0x0) && (*GHIDRA_CAST<char *>((GHIDRA_CAST<char *>(layerFrame) + 0x2c)) != '\0')) {
|
|
iVar1 = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(EVar7) + 0x33c));
|
|
iVar2 = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(EVar7) + 0xdc));
|
|
iVar3 = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(EVar7) + 0xe0));
|
|
iVar4 = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(EVar7) + 0xe4));
|
|
iVar5 = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(EVar7) + 0xe8));
|
|
*GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(EVar7) + 0x33c)) = (npc->_pos).x;
|
|
*GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(EVar7) + 0x340)) = (npc->_pos).y;
|
|
iVar6 = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(layerFrame) + 0x14));
|
|
pLVar8 = (GHIDRA_CAST<ANM2 *>((&npc->_sprite)))->ANM2::GetLayer(GHIDRA_CAST<byte *>(0x2));
|
|
frameX = *GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(layerFrame) + 0x10));
|
|
if (pLVar8->_flipX != 0) {
|
|
frameX = frameX ^ 0x80000000;
|
|
}
|
|
*GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(EVar7) + 0xdc)) = frameX;
|
|
*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(EVar7) + 0xe0)) = iVar6;
|
|
*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(EVar7) + 0xe4)) = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(layerFrame) + 0x18));
|
|
*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(EVar7) + 0xe8)) = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(layerFrame) + 0x1c));
|
|
*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(EVar7) + 0x171)) = 1;
|
|
(**(code **)(*GHIDRA_CAST<int *>(EVar7) + 0x14))(offset);
|
|
*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(EVar7) + 0xe4)) = iVar6;
|
|
*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(EVar7) + 0xe8)) = iVar4;
|
|
*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(EVar7) + 0xdc)) = iVar5;
|
|
*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(EVar7) + 0xe0)) = iVar2;
|
|
*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(EVar7) + 0x33c)) = iVar3;
|
|
*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(EVar7) + 0x171)) = 0;
|
|
*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(EVar7) + 0x340)) = iVar1;
|
|
}
|
|
}
|
|
return;
|
|
}
|
|
|
|
// 004a2940
|
|
Vector * NpcHelper::colostomia_pick_target(Entity_NPC *npc, Vector *outTarget, byte *isPlayerPos)
|
|
{
|
|
qword qVar1;
|
|
Entity *playerTarget;
|
|
qword *allocCounter;
|
|
int gridWidth;
|
|
uint uVar3;
|
|
uint uVar4;
|
|
int iVar5;
|
|
float score;
|
|
float dy;
|
|
float cellX;
|
|
float cellY;
|
|
float fVar6;
|
|
float fVar7;
|
|
float bestY;
|
|
EntityList_EL effects;
|
|
Entity_NPC *local_720;
|
|
byte *local_71c;
|
|
Vector *local_718;
|
|
int cellCounts [448];
|
|
uint local_14;
|
|
void *local_10;
|
|
undefined1 *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<EntityList *>((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<int *>((GHIDRA_CAST<char *>(effects._data) + uVar4 * 4));
|
|
fVar6 = *GHIDRA_CAST<float *>((iVar5 + 0x33c));
|
|
fVar7 = *GHIDRA_CAST<float *>((iVar5 + 0x340));
|
|
do {
|
|
iVar5 = GHIDRA_INT((((fVar6 + *GHIDRA_CAST<float *>((GHIDRA_INT(&DAT_00c5c5e8) + uVar3))) - 40.0) / 40.0 + 0.5));
|
|
gridWidth = GHIDRA_INT((((fVar7 + *GHIDRA_CAST<float *>((GHIDRA_INT(&DAT_00c5c5ec) + uVar3))) - 120.0) / 40.0 + 0.5));
|
|
if ((((-1 < iVar5) && (gridWidth = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(room) + 0xc)), iVar5 < gridWidth)) &&
|
|
(-1 < gridWidth)) &&
|
|
((gridWidth < *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(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 = (GHIDRA_CAST<Entity_NPC *>((local_720)))->Entity_NPC::GetPlayerTarget();
|
|
game = g_game;
|
|
local_718 = GHIDRA_CAST<Vector *>((playerTarget->_pos).x);
|
|
local_720 = GHIDRA_CAST<Entity_NPC *>((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<int *>((GHIDRA_CAST<char *>(g_game->_room) + 0xc)), gridWidth <= iVar5)) ||
|
|
((gridWidth < 0 || (*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(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<int *>((GHIDRA_CAST<char *>(game->_room) + 0xc));
|
|
uVar3 = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(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<undefined1 *>((GHIDRA_CAST<char *>(&(effects)) + 0x0))) != '\0') {
|
|
ExceptionList = local_10;
|
|
return outTarget;
|
|
}
|
|
if (g_mainHeap == (void *)0x0) {
|
|
allocCounter = &g_allocatedBytesNoHeap;
|
|
}
|
|
else {
|
|
allocCounter = GHIDRA_CAST<qword *>((GHIDRA_INT(g_mainHeap) + 0x30));
|
|
}
|
|
if (effects._data == (void *)0x0) {
|
|
ExceptionList = local_10;
|
|
return outTarget;
|
|
}
|
|
uVar4 = *GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(effects._data) + -4));
|
|
qVar1 = *allocCounter;
|
|
*GHIDRA_CAST<uint *>(allocCounter) = GHIDRA_UINT(*allocCounter) - uVar4;
|
|
*GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(allocCounter) + 4)) =
|
|
*GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(allocCounter) + 4)) - GHIDRA_UINT((GHIDRA_UINT(qVar1) < uVar4));
|
|
goto LAB_004a2cad;
|
|
}
|
|
}
|
|
outTarget->x = (float)local_718;
|
|
outTarget->y = (float)local_720;
|
|
if ((*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(&(effects)) + 0x0))) != '\0') {
|
|
ExceptionList = local_10;
|
|
return outTarget;
|
|
}
|
|
if (g_mainHeap == (void *)0x0) {
|
|
allocCounter = &g_allocatedBytesNoHeap;
|
|
}
|
|
else {
|
|
allocCounter = GHIDRA_CAST<qword *>((GHIDRA_INT(g_mainHeap) + 0x30));
|
|
}
|
|
if (effects._data == (void *)0x0) {
|
|
ExceptionList = local_10;
|
|
return outTarget;
|
|
}
|
|
uVar4 = *GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(effects._data) + -4));
|
|
qVar1 = *allocCounter;
|
|
*GHIDRA_CAST<uint *>(allocCounter) = GHIDRA_UINT(*allocCounter) - uVar4;
|
|
*GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(allocCounter) + 4)) = *GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(allocCounter) + 4)) - GHIDRA_UINT((GHIDRA_UINT(qVar1) < uVar4));
|
|
LAB_004a2cad:
|
|
free((void *)(GHIDRA_INT(effects._data) + -4));
|
|
ExceptionList = local_10;
|
|
return outTarget;
|
|
}
|
|
|
|
// 004a2ce0
|
|
void NpcHelper::colostomia_pick_dive_target(Entity_NPC *npc)
|
|
{
|
|
EntityPtr EVar1;
|
|
byte bVar2;
|
|
void **roomRef;
|
|
Vector *candidatePos;
|
|
Entity_Player *nearestPlayer;
|
|
uint uVar3;
|
|
byte *pbVar4;
|
|
int iVar5;
|
|
byte *pbVar6;
|
|
int iVar7;
|
|
Entity_NPC *nearestPlayer;
|
|
bool bVar9;
|
|
float fVar10;
|
|
float fVar11;
|
|
Vector freePos;
|
|
Vector randomPos;
|
|
EntityPtr *local_24;
|
|
EntityPtr local_20;
|
|
void **roomSlot;
|
|
uint attempt;
|
|
Entity_NPC *npcLocal;
|
|
byte *animData;
|
|
EntityPtr *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 = (GHIDRA_CAST<Room *>((room)))->Room::GetRandomPosition(&randomPos,0.0);
|
|
candidatePos = Room::FindFreePickupSpawnPosition(room,&freePos,candidatePos,0.0,0,0,0);
|
|
nearestPlayer = npcLocal;
|
|
fVar11 = candidatePos->x;
|
|
diveTarget->x = fVar11;
|
|
fVar10 = candidatePos->y;
|
|
(npc->_v1).y = fVar10;
|
|
fVar11 = (npcLocal->_pos).x - fVar11;
|
|
fVar10 = (npcLocal->_pos).y - fVar10;
|
|
local_20 = (EntityPtr)sqrtf(fVar10 * fVar10 + fVar11 * fVar11);
|
|
nearestPlayer = (GHIDRA_CAST<Game *>((g_game)))->Game::GetNearestPlayer(diveTarget);
|
|
fVar11 = (nearestPlayer->_pos).y - (npc->_v1).y;
|
|
fVar10 = (nearestPlayer->_pos).x - diveTarget->x;
|
|
local_24 = GHIDRA_CAST<EntityPtr *>(sqrtf(fVar11 * fVar11 + fVar10 * fVar10));
|
|
roomSlot = &g_game->_room;
|
|
bVar2 = (GHIDRA_CAST<Room *>((*roomSlot)))->Room::IsPositionInRoom(diveTarget,60.0);
|
|
if (bVar2 != 0) {
|
|
room = *roomSlot;
|
|
iVar7 = GHIDRA_INT(((diveTarget->x - 40.0) / 40.0 + 0.5));
|
|
iVar5 = GHIDRA_INT((((npc->_v1).y - 120.0) / 40.0 + 0.5));
|
|
if ((((iVar7 < 0) || (room->_gridWidth <= iVar7)) || (iVar5 < 0)) ||
|
|
(room->_gridHeight <= iVar5)) {
|
|
iVar7 = -1;
|
|
}
|
|
else {
|
|
iVar7 = room->_gridWidth * iVar5 + iVar7;
|
|
}
|
|
uVar3 = (GHIDRA_CAST<Room *>((room)))->Room::GetGridCollision(iVar7);
|
|
nearestPlayer = npcLocal;
|
|
if ((((uVar3 == 0) && (80.0 <= (float)local_20)) &&
|
|
(((float)local_20 <= 200.0 && (120.0 < (float)local_24)))) &&
|
|
((EVar1 = npcLocal->_entityRef, EVar1 == (EntityPtr)0x0 ||
|
|
(fVar11 = (npc->_v1).y - *GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(EVar1) + 0x340)),
|
|
fVar10 = diveTarget->x - *GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(EVar1) + 0x33c)),
|
|
10000.0 < fVar11 * fVar11 + fVar10 * fVar10)))) break;
|
|
}
|
|
attempt = attempt + 1;
|
|
roomRef = roomSlot;
|
|
} while (attempt < 0xf);
|
|
childRef = &nearestPlayer->_entityRef;
|
|
if (nearestPlayer->_entityRef != (EntityPtr)0x0) {
|
|
local_20 = (EntityPtr)(GHIDRA_INT(nearestPlayer->_entityRef) + 0x3bc);
|
|
if (*GHIDRA_CAST<EntityPtr *>(local_20) != (EntityPtr)0x0) {
|
|
local_24 = GHIDRA_CAST<EntityPtr *>(local_20);
|
|
std::multiset<unsigned_int>::erase(&local_24);
|
|
}
|
|
*GHIDRA_CAST<EntityPtr *>(local_20) = (EntityPtr)0x0;
|
|
if (*childRef != (EntityPtr)0x0) {
|
|
local_24 = childRef;
|
|
std::multiset<unsigned_int>::erase(&local_24);
|
|
}
|
|
*childRef = (EntityPtr)0x0;
|
|
}
|
|
local_20 = nearestPlayer->_child;
|
|
if (local_20 != (EntityPtr)0x0) {
|
|
*childRef = local_20;
|
|
std::multiset<unsigned_int>::insert(childRef);
|
|
if (nearestPlayer->_child != (EntityPtr)0x0) {
|
|
local_24 = &nearestPlayer->_child;
|
|
std::multiset<unsigned_int>::erase(&local_24);
|
|
}
|
|
nearestPlayer->_child = (EntityPtr)0x0;
|
|
}
|
|
animData = (nearestPlayer->_sprite)._animState._animData;
|
|
if (animData != GHIDRA_CAST<byte *>(0x0)) {
|
|
pbVar4 = animData;
|
|
if (0xf < *GHIDRA_CAST<uint *>((animData + 0x14))) {
|
|
pbVar4 = *GHIDRA_CAST<byte **>(animData);
|
|
}
|
|
pbVar6 = &DAT_00b1d33c;
|
|
do {
|
|
bVar2 = *pbVar4;
|
|
bVar9 = bVar2 < *pbVar6;
|
|
if (bVar2 != *pbVar6) {
|
|
LAB_004a2fd4:
|
|
uVar3 = -GHIDRA_UINT(bVar9) | 1;
|
|
goto LAB_004a2fd9;
|
|
}
|
|
if (bVar2 == 0) break;
|
|
bVar2 = pbVar4[1];
|
|
bVar9 = bVar2 < pbVar6[1];
|
|
if (bVar2 != pbVar6[1]) goto LAB_004a2fd4;
|
|
pbVar4 = pbVar4 + 2;
|
|
pbVar6 = pbVar6 + 2;
|
|
} while (bVar2 != 0);
|
|
uVar3 = 0;
|
|
LAB_004a2fd9:
|
|
if ((uVar3 == 0) && ((animData[0x34] == 0 || ((nearestPlayer->_sprite)._animState._isPlaying != 0))))
|
|
goto LAB_004a2fed;
|
|
}
|
|
bVar2 = (GHIDRA_CAST<ANM2 *>((&nearestPlayer->_sprite)))->ANM2::SetAnimation(&DAT_00b1d33c,1);
|
|
if (bVar2 != 0) {
|
|
(GHIDRA_CAST<AnimationState *>((&(nearestPlayer->_sprite)._animState)))->AnimationState::Rewind();
|
|
(nearestPlayer->_sprite)._animState._isPlaying = 1;
|
|
npcLocal->_state = 6;
|
|
return;
|
|
}
|
|
LAB_004a2fed:
|
|
nearestPlayer->_state = 6;
|
|
return;
|
|
}
|
|
|
|
// 004a6240
|
|
void NpcHelper::delirium_remove_minions(int type, int variant, Entity *self, Entity *other)
|
|
{
|
|
void *pvVar1;
|
|
int *tmpEntity;
|
|
qword qVar3;
|
|
char cVar4;
|
|
uint uVar5;
|
|
int iVar6;
|
|
qword *allocCounter;
|
|
code *freeFn;
|
|
uint npcIdx;
|
|
EntityList_EL laserList;
|
|
EntityList_EL tmpList;
|
|
int targetVariant;
|
|
int targetType;
|
|
void *local_10;
|
|
undefined1 *puStack_c;
|
|
undefined4 local_8;
|
|
int roomEntity;
|
|
Entity *tmpEntity;
|
|
|
|
local_8 = 0xffffffff;
|
|
puStack_c = &LAB_00af30b5;
|
|
local_10 = ExceptionList;
|
|
uVar5 = __security_cookie ^ GHIDRA_INT(register0x00000010) - 4U;
|
|
ExceptionList = &local_10;
|
|
npcIdx = 0;
|
|
pvVar1 = g_game->_room;
|
|
targetVariant = variant;
|
|
targetType = type;
|
|
if (*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(pvVar1) + 0x1264)) != 0) {
|
|
do {
|
|
tmpEntity = *GHIDRA_CAST<Entity **>((*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(pvVar1) + 0x125c)) + npcIdx * 4));
|
|
if ((tmpEntity == self) ||
|
|
(cVar4 = tmpEntity->IsBoss(uVar5), cVar4 == '\0')) {
|
|
LAB_004a62c2:
|
|
if (other != GHIDRA_CAST<Entity *>(0x0)) {
|
|
iVar6 = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(pvVar1) + 0x125c));
|
|
roomEntity = *GHIDRA_CAST<int *>((iVar6 + npcIdx * 4));
|
|
if ((*GHIDRA_CAST<int *>((roomEntity + 0x28)) == other->_type) &&
|
|
(*GHIDRA_CAST<int *>((roomEntity + 0x2c)) == other->_variant)) goto LAB_004a62df;
|
|
}
|
|
}
|
|
else {
|
|
iVar6 = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(pvVar1) + 0x125c));
|
|
roomEntity = *GHIDRA_CAST<int *>((iVar6 + npcIdx * 4));
|
|
if ((*GHIDRA_CAST<int *>((roomEntity + 0x28)) != targetType) ||
|
|
(*GHIDRA_CAST<int *>((roomEntity + 0x2c)) != targetVariant)) goto LAB_004a62c2;
|
|
LAB_004a62df:
|
|
(**(code **)(**GHIDRA_CAST<int **>((iVar6 + npcIdx * 4)) + 0x28))();
|
|
}
|
|
npcIdx = npcIdx + 1;
|
|
} while (npcIdx < *GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(pvVar1) + 0x1264)));
|
|
}
|
|
if (targetType == 0x4f) {
|
|
EntityList::QuerySublist(GHIDRA_CAST<EntityList *>((GHIDRA_INT(g_game->_room) + 0x1218)),&tmpList,0x4f,0x14,-1,0,0);
|
|
iVar6 = tmpList._size;
|
|
pvVar1 = tmpList._data;
|
|
local_8 = 0;
|
|
uVar5 = 0;
|
|
if (tmpList._size != 0) {
|
|
do {
|
|
(**(code **)(**GHIDRA_CAST<int **>((GHIDRA_CAST<char *>(pvVar1) + uVar5 * 4)) + 0x28))();
|
|
uVar5 = uVar5 + 1;
|
|
} while (uVar5 < GHIDRA_UINT(iVar6));
|
|
}
|
|
joined_r0x004a63ae:
|
|
local_8 = 0xffffffff;
|
|
if ((*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(&(tmpList)) + 0x0))) == '\0') {
|
|
local_8 = 0xffffffff;
|
|
if (g_mainHeap == (void *)0x0) {
|
|
allocCounter = &g_allocatedBytesNoHeap;
|
|
}
|
|
else {
|
|
allocCounter = GHIDRA_CAST<qword *>((GHIDRA_INT(g_mainHeap) + 0x30));
|
|
}
|
|
if (pvVar1 != (void *)0x0) {
|
|
uVar5 = *GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(pvVar1) + -4));
|
|
qVar3 = *allocCounter;
|
|
*GHIDRA_CAST<uint *>(allocCounter) = GHIDRA_UINT(*allocCounter) - uVar5;
|
|
*GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(allocCounter) + 4)) =
|
|
*GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(allocCounter) + 4)) - GHIDRA_UINT((GHIDRA_UINT(qVar3) < uVar5));
|
|
free((void *)(GHIDRA_INT(pvVar1) + -4));
|
|
}
|
|
local_8 = 0xffffffff;
|
|
}
|
|
}
|
|
else if (targetType == 0x197) {
|
|
EntityList::QuerySublist(GHIDRA_CAST<EntityList *>((GHIDRA_INT(g_game->_room) + 0x1218)),&tmpList,1000,0x65,-1,0,0);
|
|
iVar6 = tmpList._size;
|
|
pvVar1 = tmpList._data;
|
|
local_8 = 2;
|
|
uVar5 = 0;
|
|
if (tmpList._size != 0) {
|
|
do {
|
|
(**(code **)(**GHIDRA_CAST<int **>((GHIDRA_CAST<char *>(pvVar1) + uVar5 * 4)) + 0x28))();
|
|
uVar5 = uVar5 + 1;
|
|
} while (uVar5 < GHIDRA_UINT(iVar6));
|
|
}
|
|
goto joined_r0x004a63ae;
|
|
}
|
|
EntityList::QuerySublist(GHIDRA_CAST<EntityList *>((GHIDRA_INT(g_game->_room) + 0x1218)),&laserList,7,-1,-1,0,0);
|
|
local_8 = 4;
|
|
uVar5 = 0;
|
|
if (laserList._size != 0) {
|
|
do {
|
|
tmpEntity = *GHIDRA_CAST<int **>((GHIDRA_CAST<char *>(laserList._data) + uVar5 * 4));
|
|
if (tmpEntity[0xd] != 1) {
|
|
(**(code **)(*tmpEntity + 0x28))();
|
|
}
|
|
uVar5 = uVar5 + 1;
|
|
} while (uVar5 < GHIDRA_UINT(laserList._size));
|
|
}
|
|
EntityList::QuerySublist(GHIDRA_CAST<EntityList *>((GHIDRA_INT(g_game->_room) + 0x1218)),&tmpList,0x60,0,-1,0,0);
|
|
local_8 = CONCAT31((*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(&(local_8)) + 0x1))),5);
|
|
uVar5 = 0;
|
|
if (tmpList._size != 0) {
|
|
do {
|
|
(**(code **)(**GHIDRA_CAST<int **>((GHIDRA_CAST<char *>(tmpList._data) + uVar5 * 4)) + 0x28))();
|
|
uVar5 = uVar5 + 1;
|
|
} while (uVar5 < GHIDRA_UINT(tmpList._size));
|
|
}
|
|
if ((*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(&(tmpList)) + 0x0))) == '\0') {
|
|
allocCounter = GHIDRA_CAST<qword *>((GHIDRA_INT(g_mainHeap) + 0x30));
|
|
if (g_mainHeap == (void *)0x0) {
|
|
allocCounter = &g_allocatedBytesNoHeap;
|
|
}
|
|
if (tmpList._data != (void *)0x0) {
|
|
uVar5 = *GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(tmpList._data) + -4));
|
|
qVar3 = *allocCounter;
|
|
*GHIDRA_CAST<uint *>(allocCounter) = GHIDRA_UINT(*allocCounter) - uVar5;
|
|
freeFn = free_exref;
|
|
*GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(allocCounter) + 4)) =
|
|
*GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(allocCounter) + 4)) - GHIDRA_UINT((GHIDRA_UINT(qVar3) < uVar5));
|
|
free((void *)(GHIDRA_INT(tmpList._data) + -4));
|
|
goto LAB_004a64bb;
|
|
}
|
|
}
|
|
freeFn = free_exref;
|
|
LAB_004a64bb:
|
|
if ((*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(&(laserList)) + 0x0))) == '\0') {
|
|
allocCounter = GHIDRA_CAST<qword *>((GHIDRA_INT(g_mainHeap) + 0x30));
|
|
if (g_mainHeap == (void *)0x0) {
|
|
allocCounter = &g_allocatedBytesNoHeap;
|
|
}
|
|
if (laserList._data != (void *)0x0) {
|
|
uVar5 = *GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(laserList._data) + -4));
|
|
qVar3 = *allocCounter;
|
|
*GHIDRA_CAST<uint *>(allocCounter) = GHIDRA_UINT(*allocCounter) - uVar5;
|
|
*GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(allocCounter) + 4)) =
|
|
*GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(allocCounter) + 4)) - GHIDRA_UINT((GHIDRA_UINT(qVar3) < uVar5));
|
|
(*freeFn)(GHIDRA_INT(laserList._data) + -4);
|
|
}
|
|
}
|
|
ExceptionList = local_10;
|
|
return;
|
|
}
|
|
|
|
// 004a8680
|
|
void NpcHelper::delirium_spawn_form_parts(Entity_NPC *npc, float maxHealth)
|
|
{
|
|
undefined4 uVar1;
|
|
undefined4 uVar2;
|
|
byte bVar3;
|
|
uint uVar4;
|
|
Entity *target;
|
|
EntityPtr EVar5;
|
|
void *newBlock;
|
|
byte *curAnimChar;
|
|
uint uVar6;
|
|
char *expectedAnimChar;
|
|
Entity_NPC *spawner;
|
|
bool isCharLess;
|
|
float fVar7;
|
|
Vector spawnPos;
|
|
float dirX;
|
|
EntityPtr local_24;
|
|
float formMaxHealth;
|
|
Entity_NPC *formNpc;
|
|
int segmentCount;
|
|
float segmentIndex;
|
|
EntityPtr *local_10;
|
|
float local_c;
|
|
float dirY;
|
|
byte *animData;
|
|
EntityPtr *linkSlot;
|
|
EntityPtr posBlock;
|
|
int velBlock;
|
|
|
|
formMaxHealth = maxHealth;
|
|
formNpc = npc;
|
|
if (npc->_type == 0x13) {
|
|
uVar4 = Random();
|
|
segmentCount = uVar4 % 6 + 4;
|
|
target = (GHIDRA_CAST<Entity_NPC *>((npc)))->Entity_NPC::GetPlayerTarget();
|
|
dirY = (npc->_pos).x - (target->_pos).x;
|
|
local_c = (npc->_pos).y - (target->_pos).y;
|
|
fVar7 = sqrtf(dirY * dirY + local_c * local_c);
|
|
if (0.0 < fVar7) {
|
|
dirY = dirY * (1.0 / fVar7);
|
|
local_c = local_c * (1.0 / fVar7);
|
|
}
|
|
uVar4 = Random();
|
|
segmentIndex = (float)GHIDRA_INT((uVar4 % 0x5a - 0x2d)) * 0.017453292;
|
|
local_10 = GHIDRA_CAST<EntityPtr *>(cos(segmentIndex));
|
|
fVar7 = sin(segmentIndex);
|
|
segmentIndex = 1.4013e-45;
|
|
dirX = dirY * (float)local_10 - local_c * fVar7;
|
|
dirY = dirY * fVar7 + local_c * (float)local_10;
|
|
spawner = npc;
|
|
if (0 < segmentCount) {
|
|
do {
|
|
fVar7 = segmentIndex;
|
|
spawnPos.y = (float)GHIDRA_INT(segmentIndex) * 20.0 * dirY + (spawner->_pos).y;
|
|
spawnPos.x = (float)GHIDRA_INT(segmentIndex) * 20.0 * dirX + (spawner->_pos).x;
|
|
uVar4 = Random();
|
|
local_10 = GHIDRA_CAST<EntityPtr *>((((float)(uVar4 % 5000) + 0.0) / 1000.0));
|
|
uVar4 = Random();
|
|
spawnPos.x = ((float)(uVar4 % 5000) + 0.0) / 1000.0 + spawnPos.x;
|
|
spawnPos.y = spawnPos.y + (float)local_10;
|
|
uVar4 = Random();
|
|
EVar5 = (EntityPtr)
|
|
(GHIDRA_CAST<Game *>((g_game)))->Game::Spawn(spawner->_type,spawner->_variant,&spawnPos,&g_vectorZero,
|
|
GHIDRA_CAST<Entity *>(spawner),0,uVar4);
|
|
if (fVar7 == 1.4013e-45) {
|
|
*GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(EVar5) + 0x380)) = formMaxHealth;
|
|
*GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(EVar5) + 900)) = formMaxHealth;
|
|
*GHIDRA_CAST<byte *>((GHIDRA_CAST<char *>(EVar5) + 0x3b0)) = 1;
|
|
}
|
|
linkSlot = GHIDRA_CAST<EntityPtr *>((GHIDRA_INT(EVar5) + 0x3bc));
|
|
if (*GHIDRA_CAST<EntityPtr *>((GHIDRA_CAST<char *>(EVar5) + 0x3bc)) != (EntityPtr)0x0) {
|
|
local_10 = linkSlot;
|
|
std::multiset<unsigned_int>::erase(&local_10);
|
|
}
|
|
*linkSlot = (EntityPtr)npc;
|
|
if ((EntityPtr)npc != (EntityPtr)0x0) {
|
|
std::multiset<unsigned_int>::insert(linkSlot);
|
|
}
|
|
linkSlot = GHIDRA_CAST<EntityPtr *>((GHIDRA_INT(npc) + 0x3c0));
|
|
if (*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(npc) + 0x3c0)) != 0) {
|
|
local_10 = linkSlot;
|
|
std::multiset<unsigned_int>::erase(&local_10);
|
|
}
|
|
*linkSlot = EVar5;
|
|
std::multiset<unsigned_int>::insert(linkSlot);
|
|
uVar6 = *GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(EVar5) + 0x168)) & 0xfffffffb | 0x80040000;
|
|
*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(EVar5) + 0x16c)) = *GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(EVar5) + 0x16c));
|
|
*GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(EVar5) + 0x168)) = uVar6;
|
|
*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(EVar5) + 0xb64)) = 4;
|
|
uVar4 = *GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(EVar5) + 0xc10));
|
|
if (((uVar4 & 1) == 0) &&
|
|
(*GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(EVar5) + 0xc0c)) <= *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(EVar5) + 0xc14)) + 2U >> 1)) {
|
|
std::deque<int>::_Growmap(uVar6);
|
|
uVar4 = *GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(EVar5) + 0xc10));
|
|
}
|
|
uVar6 = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(EVar5) + 0xc0c)) * 2;
|
|
uVar4 = uVar6 - 1 & uVar4;
|
|
*GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(EVar5) + 0xc10)) = uVar4;
|
|
if (uVar4 == 0) {
|
|
uVar4 = uVar6;
|
|
}
|
|
uVar4 = uVar4 - 1;
|
|
local_c = (float)(*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(EVar5) + 0xc0c)) - 1U & uVar4 >> 1);
|
|
local_10 = *GHIDRA_CAST<EntityPtr **>((GHIDRA_CAST<char *>(EVar5) + 0xc08));
|
|
local_24 = (EntityPtr)uVar4;
|
|
if (local_10[GHIDRA_INT(local_c)] == (EntityPtr)0x0) {
|
|
newBlock = operator_new(0x10);
|
|
*(void **)(*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(EVar5) + 0xc08)) + GHIDRA_INT(local_c) * 4) = newBlock;
|
|
local_10 = *GHIDRA_CAST<EntityPtr **>((GHIDRA_CAST<char *>(EVar5) + 0xc08));
|
|
}
|
|
uVar1 = *GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(EVar5) + 0x340));
|
|
uVar2 = *GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(EVar5) + 0x33c));
|
|
posBlock = local_10[GHIDRA_INT(local_c)];
|
|
*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(posBlock) + (uVar4 & 1) * 8)) = uVar2;
|
|
*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(posBlock) + 4 + (uVar4 & 1) * 8)) = uVar1;
|
|
*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(EVar5) + 0xc14)) = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(EVar5) + 0xc14)) + 1;
|
|
*GHIDRA_CAST<EntityPtr *>((GHIDRA_CAST<char *>(EVar5) + 0xc10)) = local_24;
|
|
uVar4 = *GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(EVar5) + 0xc24));
|
|
if (((uVar4 & 1) == 0) &&
|
|
(*GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(EVar5) + 0xc20)) <= *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(EVar5) + 0xc28)) + 2U >> 1)) {
|
|
std::deque<int>::_Growmap(uVar2);
|
|
uVar4 = *GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(EVar5) + 0xc24));
|
|
}
|
|
uVar6 = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(EVar5) + 0xc20)) * 2;
|
|
uVar4 = uVar6 - 1 & uVar4;
|
|
*GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(EVar5) + 0xc24)) = uVar4;
|
|
if (uVar4 == 0) {
|
|
uVar4 = uVar6;
|
|
}
|
|
uVar4 = uVar4 - 1;
|
|
local_10 = GHIDRA_CAST<EntityPtr *>((*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(EVar5) + 0xc20)) - 1U & uVar4 >> 1));
|
|
local_c = *GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(EVar5) + 0xc1c));
|
|
local_24 = (EntityPtr)uVar4;
|
|
if (*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(local_c) + GHIDRA_INT(local_10) * 4)) == 0) {
|
|
newBlock = operator_new(0x10);
|
|
*(void **)(*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(EVar5) + 0xc1c)) + GHIDRA_INT(local_10) * 4) = newBlock;
|
|
local_c = *GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(EVar5) + 0xc1c));
|
|
}
|
|
uVar1 = *GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(EVar5) + 0x360));
|
|
velBlock = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(local_c) + GHIDRA_INT(local_10) * 4));
|
|
*GHIDRA_CAST<undefined4 *>((velBlock + 4 + (uVar4 & 1) * 8)) = *GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(EVar5) + 0x364));
|
|
*GHIDRA_CAST<undefined4 *>((velBlock + (uVar4 & 1) * 8)) = uVar1;
|
|
*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(EVar5) + 0xc28)) = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(EVar5) + 0xc28)) + 1;
|
|
*GHIDRA_CAST<EntityPtr *>((GHIDRA_CAST<char *>(EVar5) + 0xc24)) = local_24;
|
|
*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(EVar5) + 0xc7c)) = formNpc->_groupIdx;
|
|
ANM2::LoadDeliriumForm(GHIDRA_CAST<ANM2 *>((GHIDRA_INT(EVar5) + 0x48)),formNpc->_type,formNpc->_variant,1);
|
|
animData = *GHIDRA_CAST<byte **>((GHIDRA_CAST<char *>(EVar5) + 0x7c));
|
|
local_24 = EVar5;
|
|
if (animData == GHIDRA_CAST<byte *>(0x0)) {
|
|
LAB_004a8acc:
|
|
bVar3 = (GHIDRA_CAST<ANM2 *>((GHIDRA_CAST<ANM2 *>((GHIDRA_INT(EVar5) + 0x48)))))->ANM2::SetAnimation(GHIDRA_CAST<byte *>("WalkBodyHori"),1);
|
|
if (bVar3 != 0) {
|
|
(GHIDRA_CAST<AnimationState *>((GHIDRA_CAST<AnimationState *>((GHIDRA_INT(EVar5) + 0x78)))))->AnimationState::Rewind();
|
|
*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(EVar5) + 0x8c)) = 1;
|
|
}
|
|
}
|
|
else {
|
|
curAnimChar = animData;
|
|
if (0xf < *GHIDRA_CAST<uint *>((animData + 0x14))) {
|
|
curAnimChar = *GHIDRA_CAST<byte **>(animData);
|
|
}
|
|
expectedAnimChar = "WalkBodyHori";
|
|
do {
|
|
bVar3 = *curAnimChar;
|
|
isCharLess = bVar3 < (byte)*expectedAnimChar;
|
|
if (bVar3 != *expectedAnimChar) {
|
|
LAB_004a8ab6:
|
|
uVar4 = -GHIDRA_UINT(isCharLess) | 1;
|
|
goto LAB_004a8abb;
|
|
}
|
|
if (bVar3 == 0) break;
|
|
bVar3 = curAnimChar[1];
|
|
isCharLess = bVar3 < (byte)expectedAnimChar[1];
|
|
if (bVar3 != expectedAnimChar[1]) goto LAB_004a8ab6;
|
|
curAnimChar = curAnimChar + 2;
|
|
expectedAnimChar = expectedAnimChar + 2;
|
|
} while (bVar3 != 0);
|
|
uVar4 = 0;
|
|
LAB_004a8abb:
|
|
if ((uVar4 != 0) || ((animData[0x34] != 0 && (*GHIDRA_CAST<char *>((GHIDRA_CAST<char *>(EVar5) + 0x8c)) == '\0'))))
|
|
goto LAB_004a8acc;
|
|
}
|
|
(**(code **)(*GHIDRA_CAST<int *>(EVar5) + 0xc))();
|
|
segmentIndex = (float)(GHIDRA_INT(segmentIndex) + 1);
|
|
npc = GHIDRA_CAST<Entity_NPC *>(local_24);
|
|
spawner = formNpc;
|
|
if (segmentCount < GHIDRA_INT(segmentIndex)) {
|
|
return;
|
|
}
|
|
} while( true );
|
|
}
|
|
}
|
|
else if (npc->_type == 0x10a) {
|
|
uVar4 = Random();
|
|
(GHIDRA_CAST<Game *>((g_game)))->Game::Spawn(npc->_type,1,&npc->_pos,&g_vectorZero,GHIDRA_CAST<Entity *>(npc),0,uVar4);
|
|
uVar4 = Random();
|
|
(GHIDRA_CAST<Game *>((g_game)))->Game::Spawn(npc->_type,2,&npc->_pos,&g_vectorZero,GHIDRA_CAST<Entity *>(npc),0,uVar4);
|
|
}
|
|
return;
|
|
}
|
|
|
|
// 004a8b70
|
|
void NpcHelper::delirium_fire_pattern(Entity_NPC *npc)
|
|
{
|
|
byte bVar1;
|
|
int iVar2;
|
|
Entity *target;
|
|
int iVar3;
|
|
uint uVar4;
|
|
byte *animNameCh;
|
|
char *expectedNameCh;
|
|
char repeatByte;
|
|
uint uVar5;
|
|
int iVar6;
|
|
bool bVar7;
|
|
float fVar8;
|
|
undefined1 auVar9 [16];
|
|
undefined1 auVar10 [16];
|
|
int fireInterval;
|
|
uint keepPatternChance;
|
|
uint patternId;
|
|
float altColorizeR;
|
|
Vector projVelocity;
|
|
undefined8 local_16c;
|
|
float local_164;
|
|
uint repeatsLeft;
|
|
int burstCount;
|
|
float local_158;
|
|
uint extraBulletFlags;
|
|
float colorizeB;
|
|
float colorizeG;
|
|
float colorizeR;
|
|
uint local_144;
|
|
uint local_140;
|
|
uint attackAngle;
|
|
char isAlternating;
|
|
ProjectileParams projParams;
|
|
undefined1 local_9c;
|
|
undefined1 *local_98;
|
|
undefined4 local_94;
|
|
undefined1 local_90;
|
|
float angleTable [16];
|
|
int delayTable [17];
|
|
uint local_8;
|
|
uint attackId;
|
|
byte *curAnimData;
|
|
|
|
local_8 = __security_cookie ^ GHIDRA_UINT((delayTable + 0x12));
|
|
if (npc->_type == 0x2d) {
|
|
return;
|
|
}
|
|
if ((npc->_deliriumBossType == 0x54) && (npc->_deliriumBossVariant == 10)) {
|
|
return;
|
|
}
|
|
attackId = npc->_deliriumAttackID;
|
|
patternId = attackId & 0xff;
|
|
local_140 = attackId >> 8;
|
|
keepPatternChance = attackId >> 0x10 & 0xff;
|
|
attackAngle = GHIDRA_UINT(npc->_deliriumAttackAngle);
|
|
uVar5 = local_140 & 0xff;
|
|
repeatsLeft = uVar5;
|
|
if (patternId == 0xff) {
|
|
patternId = Random();
|
|
patternId = patternId % 0xb;
|
|
}
|
|
iVar2 = 0;
|
|
colorizeB = 0.0;
|
|
local_144 = 6;
|
|
burstCount = 4;
|
|
projVelocity.x = 3.0;
|
|
projVelocity.y = 0.0;
|
|
isAlternating = '\0';
|
|
local_164 = 1.26117e-44;
|
|
local_158 = 1.0;
|
|
colorizeR = 1.0;
|
|
colorizeG = 0.4;
|
|
altColorizeR = 1.0;
|
|
if (__isa_available < 2) {
|
|
iVar6 = 0;
|
|
do {
|
|
delayTable[iVar2] = iVar6;
|
|
iVar6 = iVar6 + 5;
|
|
angleTable[iVar2] = (float)iVar2 * 3.1415927;
|
|
iVar2 = iVar2 + 1;
|
|
} while (iVar6 < 0x50);
|
|
}
|
|
else {
|
|
iVar2 = 0;
|
|
do {
|
|
(*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(auVar10)) + 0x4))) = iVar2 + 1;
|
|
(*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(auVar10)) + 0x0))) = iVar2;
|
|
(*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(auVar10)) + 0x8))) = iVar2 + 2;
|
|
(*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(auVar10)) + 0xc))) = iVar2 + 3;
|
|
auVar9 = pmulld(auVar10,_DAT_00bab470);
|
|
angleTable[iVar2] = (float)iVar2 * 3.1415927;
|
|
angleTable[iVar2 + 1] = (*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&((float)auVar10)) + 0x4))) * 3.1415927;
|
|
angleTable[iVar2 + 2] = (*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&((float)auVar10)) + 0x8))) * 3.1415927;
|
|
angleTable[iVar2 + 3] = (*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&((float)auVar10)) + 0xc))) * 3.1415927;
|
|
delayTable[iVar2] = GHIDRA_INT(((-GHIDRA_UINT(((*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(auVar9)) + 0x0))) < 0)) & 1) + (*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(auVar9)) + 0x0))))) >> 1;
|
|
delayTable[iVar2 + 1] = GHIDRA_INT(((-GHIDRA_UINT(((*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(auVar9)) + 0x4))) < 0)) & 1) + (*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(auVar9)) + 0x4))))) >> 1;
|
|
delayTable[iVar2 + 2] = GHIDRA_INT(((-GHIDRA_UINT(((*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(auVar9)) + 0x8))) < 0)) & 1) + (*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(auVar9)) + 0x8))))) >> 1;
|
|
delayTable[iVar2 + 3] = GHIDRA_INT(((-GHIDRA_UINT(((*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(auVar9)) + 0xc))) < 0)) & 1) + (*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(auVar9)) + 0xc))))) >> 1;
|
|
(*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(auVar9)) + 0x4))) = iVar2 + 5;
|
|
(*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(auVar9)) + 0x0))) = iVar2 + 4;
|
|
(*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(auVar9)) + 0x8))) = iVar2 + 6;
|
|
(*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(auVar9)) + 0xc))) = iVar2 + 7;
|
|
auVar10 = pmulld(auVar9,_DAT_00bab470);
|
|
angleTable[iVar2 + 4] = (float)(iVar2 + 4) * 3.1415927;
|
|
angleTable[iVar2 + 5] = (*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&((float)auVar9)) + 0x4))) * 3.1415927;
|
|
angleTable[iVar2 + 6] = (*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&((float)auVar9)) + 0x8))) * 3.1415927;
|
|
angleTable[iVar2 + 7] = (*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&((float)auVar9)) + 0xc))) * 3.1415927;
|
|
delayTable[iVar2 + 4] = GHIDRA_INT(((-GHIDRA_UINT(((*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(auVar10)) + 0x0))) < 0)) & 1) + (*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(auVar10)) + 0x0))))) >> 1;
|
|
delayTable[iVar2 + 5] = GHIDRA_INT(((-GHIDRA_UINT(((*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(auVar10)) + 0x4))) < 0)) & 1) + (*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(auVar10)) + 0x4))))) >> 1;
|
|
delayTable[iVar2 + 6] = GHIDRA_INT(((-GHIDRA_UINT(((*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(auVar10)) + 0x8))) < 0)) & 1) + (*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(auVar10)) + 0x8))))) >> 1;
|
|
delayTable[iVar2 + 7] = GHIDRA_INT(((-GHIDRA_UINT(((*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(auVar10)) + 0xc))) < 0)) & 1) + (*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(auVar10)) + 0xc))))) >> 1;
|
|
iVar2 = iVar2 + 8;
|
|
} while (iVar2 < 0x10);
|
|
}
|
|
local_16c = 0;
|
|
repeatByte = (char)local_140;
|
|
switch(patternId) {
|
|
case 0:
|
|
fireInterval = 0x12;
|
|
local_144 = 0x14;
|
|
burstCount = 1;
|
|
if (uVar5 == 0xff) {
|
|
uVar5 = 2;
|
|
}
|
|
projVelocity.x = 2.5;
|
|
isAlternating = '\x01';
|
|
colorizeR = 2.0;
|
|
colorizeG = 2.0;
|
|
colorizeB = 2.0;
|
|
altColorizeR = 3.0;
|
|
extraBulletFlags = 0x8000000;
|
|
local_158 = 3.0;
|
|
break;
|
|
case 1:
|
|
fireInterval = 0x19;
|
|
local_144 = 8;
|
|
burstCount = 1;
|
|
projVelocity.x = 4.0;
|
|
colorizeR = 2.0;
|
|
colorizeG = 2.8;
|
|
colorizeB = 2.0;
|
|
extraBulletFlags = 2;
|
|
goto LAB_004a9349;
|
|
case 2:
|
|
fireInterval = 5;
|
|
local_144 = 6;
|
|
projVelocity.x = 4.5;
|
|
burstCount = 1;
|
|
delayTable[0] = 0;
|
|
angleTable[0] = 0.3926991;
|
|
colorizeR = 2.6;
|
|
colorizeG = 2.6;
|
|
colorizeB = 2.6;
|
|
extraBulletFlags = 0x800000;
|
|
goto LAB_004a9349;
|
|
case 3:
|
|
iVar3 = 0;
|
|
local_144 = 1;
|
|
fireInterval = 0x19;
|
|
iVar6 = 0;
|
|
projVelocity.x = 4.0;
|
|
burstCount = 0xc;
|
|
iVar2 = 0;
|
|
do {
|
|
*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(delayTable) + iVar6)) = iVar3;
|
|
*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(delayTable) + iVar6 + 0xc)) = iVar3;
|
|
iVar3 = iVar3 + 10;
|
|
*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(delayTable) + iVar6 + 0x18)) = *GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(delayTable) + iVar6));
|
|
fVar8 = (float)iVar2 * 1.0471976;
|
|
*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(delayTable) + iVar6 + 0x24)) = *GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(delayTable) + iVar6));
|
|
*GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(angleTable) + iVar6)) = fVar8;
|
|
*GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(angleTable) + iVar6 + 0xc)) = fVar8 + 3.1415927;
|
|
*GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(angleTable) + iVar6 + 0x18)) = fVar8 + 1.5707964;
|
|
*GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(angleTable) + iVar6 + 0x24)) = fVar8 + 3.1415927 + 1.5707964;
|
|
iVar6 = iVar6 + 4;
|
|
iVar2 = iVar2 + 1;
|
|
} while (iVar6 < 0xc);
|
|
if (repeatByte == -1) {
|
|
uVar5 = 3;
|
|
}
|
|
colorizeR = 3.4;
|
|
colorizeG = 3.4;
|
|
colorizeB = 3.4;
|
|
local_158 = 1.0;
|
|
extraBulletFlags = 0;
|
|
break;
|
|
case 4:
|
|
fireInterval = 0x14;
|
|
attackAngle = attackAngle + 3;
|
|
local_144 = 0x14;
|
|
burstCount = 1;
|
|
if (repeatByte == -1) {
|
|
uVar5 = 4;
|
|
}
|
|
projVelocity.x = 5.0;
|
|
colorizeR = 2.4;
|
|
colorizeG = 2.4;
|
|
colorizeB = 2.4;
|
|
extraBulletFlags = 0x20;
|
|
local_158 = 1.0;
|
|
repeatsLeft = uVar5;
|
|
goto LAB_004a9394;
|
|
case 5:
|
|
attackAngle = attackAngle + 2;
|
|
fireInterval = 0x14;
|
|
local_144 = 10;
|
|
if (repeatByte == -1) {
|
|
uVar5 = 2;
|
|
}
|
|
burstCount = 1;
|
|
isAlternating = '\x01';
|
|
colorizeR = 3.6;
|
|
colorizeG = 3.6;
|
|
colorizeB = 3.6;
|
|
altColorizeR = 2.2;
|
|
extraBulletFlags = 0x400000;
|
|
local_158 = 2.2;
|
|
break;
|
|
case 6:
|
|
colorizeB = 3.8;
|
|
extraBulletFlags = 0x800;
|
|
goto LAB_004a9111;
|
|
case 7:
|
|
colorizeB = 4.0;
|
|
extraBulletFlags = 0x1000;
|
|
LAB_004a9111:
|
|
uVar4 = 2;
|
|
projVelocity.x = 5.0;
|
|
local_144 = 0xe;
|
|
fireInterval = 0x19;
|
|
LAB_004a912d:
|
|
burstCount = 1;
|
|
if (repeatByte == -1) {
|
|
uVar5 = uVar4;
|
|
}
|
|
local_158 = 1.0;
|
|
colorizeG = colorizeB;
|
|
colorizeR = colorizeB;
|
|
break;
|
|
case 8:
|
|
attackAngle = attackAngle + 4;
|
|
fireInterval = 10;
|
|
colorizeB = 2.6;
|
|
local_144 = 10;
|
|
projVelocity.x = 4.0;
|
|
uVar4 = 3;
|
|
extraBulletFlags = 0x200000;
|
|
goto LAB_004a912d;
|
|
case 9:
|
|
fireInterval = 0x1e;
|
|
attackAngle = attackAngle + 2;
|
|
local_144 = 0xe;
|
|
projVelocity.x = 4.0;
|
|
colorizeR = 2.6;
|
|
colorizeG = 2.6;
|
|
colorizeB = 2.6;
|
|
goto LAB_004a933d;
|
|
case 10:
|
|
burstCount = 1;
|
|
fireInterval = 0x12;
|
|
target = (GHIDRA_CAST<Entity_NPC *>((npc)))->Entity_NPC::GetPlayerTarget();
|
|
local_158 = (target->_pos).y - (npc->_pos).y;
|
|
local_164 = (target->_pos).x - (npc->_pos).x;
|
|
fVar8 = sqrtf(local_158 * local_158 + local_164 * local_164);
|
|
if (0.0 < fVar8) {
|
|
local_158 = local_158 * (1.0 / fVar8);
|
|
local_164 = local_164 * (1.0 / fVar8);
|
|
}
|
|
colorizeB = 3.6;
|
|
projVelocity.x = local_164 * 4.0;
|
|
if ((char)local_140 == -1) {
|
|
uVar5 = 4;
|
|
}
|
|
local_164 = 7.00649e-45;
|
|
projVelocity.y = local_158 * 4.0;
|
|
local_158 = 1.0;
|
|
extraBulletFlags = 0;
|
|
colorizeG = colorizeB;
|
|
colorizeR = colorizeB;
|
|
break;
|
|
default:
|
|
fireInterval = 10;
|
|
LAB_004a933d:
|
|
extraBulletFlags = 0;
|
|
LAB_004a9349:
|
|
isAlternating = '\0';
|
|
local_164 = 1.26117e-44;
|
|
altColorizeR = 1.0;
|
|
if (uVar5 == 0xff) {
|
|
uVar5 = 1;
|
|
isAlternating = '\0';
|
|
local_164 = 1.26117e-44;
|
|
altColorizeR = 1.0;
|
|
break;
|
|
}
|
|
goto LAB_004a938e;
|
|
}
|
|
repeatsLeft = uVar5;
|
|
LAB_004a938e:
|
|
LAB_004a9394:
|
|
uVar5 = local_144;
|
|
local_140 = 0;
|
|
iVar2 = 4;
|
|
if (npc->_type == 0x19c) {
|
|
iVar2 = 1;
|
|
}
|
|
bVar7 = false;
|
|
iVar6 = 0;
|
|
local_16c = (ulonglong)GHIDRA_UINT((((float)GHIDRA_INT(attackAngle) / 255.0) * 6.2831855)) << 0x20;
|
|
do {
|
|
iVar3 = (attackId >> 0x18) - delayTable[iVar6];
|
|
local_144 = iVar3 / (iVar2 * fireInterval);
|
|
if (iVar3 % (iVar2 * fireInterval) == 0) {
|
|
projParams.GridCollision = 1;
|
|
projParams.HeightModifier = 0.0;
|
|
projParams.FallingSpeedModifier = 0.0;
|
|
projParams.FallingAccelModifier = 0.0;
|
|
projParams.VelocityMulti = 1.0;
|
|
projParams.Scale = 1.0;
|
|
uVar4 = Random();
|
|
projParams.Color._offset[0] = 0.0;
|
|
projParams.Color._offset[1] = 0.0;
|
|
projParams.Color._offset[2] = 0.0;
|
|
projParams.DotProductLimit = -1000.0;
|
|
projParams.WiggleFrameOffset = 0;
|
|
projParams.ChangeVelocity = 0.0;
|
|
projParams.PositionOffset.x = g_vectorZero.x;
|
|
projParams.TargetPosition.x = g_vectorZero.x;
|
|
projParams.FireDirectionLimit.x = g_vectorZero.x;
|
|
projParams.ChangeTimeout = 0x1e;
|
|
projParams.DepthOffset = 0.0;
|
|
projParams.Variant = 0;
|
|
local_9c = 0;
|
|
local_98 = &DAT_bf800000;
|
|
local_94 = 0;
|
|
local_90 = 0;
|
|
projParams.HeightModifier = 5.0;
|
|
projParams.CircleAngle =
|
|
(float)((double)GHIDRA_INT(uVar4) + __uint_to_double_fixup[-(GHIDRA_INT(uVar4) >> 0x1f)]) *
|
|
2.3283064e-10 * 3.1415927;
|
|
projParams.HomingStrength = 1.0;
|
|
projParams.CurvingStrength = 0.005;
|
|
projParams.Acceleration = 1.01;
|
|
projParams.Spread = 1.0;
|
|
projParams.Color._tint[0] = 1.0;
|
|
projParams.Color._tint[1] = 1.0;
|
|
projParams.Color._tint[2] = 1.0;
|
|
projParams.Color._tint[3] = 1.0;
|
|
projParams.Color._colorize[0] = 0.0;
|
|
projParams.Color._colorize[1] = 0.0;
|
|
projParams.Color._colorize[2] = 0.0;
|
|
projParams.Color._colorize[3] = 0.0;
|
|
projParams.BulletFlags = 0;
|
|
projParams.PositionOffset.y = g_vectorZero.y;
|
|
projParams.TargetPosition.y = g_vectorZero.y;
|
|
projParams.FireDirectionLimit.y = g_vectorZero.y;
|
|
projParams.ChangeFlags = 0;
|
|
uVar4 = Random();
|
|
projParams.FallingAccelModifier = -0.06;
|
|
projParams.FallingSpeedModifier = -3.2;
|
|
(*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(projParams.BulletFlags)) + 0x0))) = GHIDRA_UINT(projParams.BulletFlags) | extraBulletFlags;
|
|
projParams.Color._colorize[3] = 1.0;
|
|
projParams.Scale =
|
|
(float)((double)GHIDRA_INT((uVar4 % 0xffffffff)) +
|
|
__uint_to_double_fixup[-(GHIDRA_INT((uVar4 % 0xffffffff)) >> 0x1f)]) * 2.3283064e-10 +
|
|
1.5;
|
|
projParams.TargetPosition.x = (npc->_pos).x;
|
|
projParams.TargetPosition.y = (npc->_pos).y;
|
|
projParams.CircleAngle = (*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(local_16c)) + 0x4))) + angleTable[iVar6];
|
|
projParams.Color._colorize[0] = colorizeR;
|
|
projParams.Color._colorize[1] = colorizeG;
|
|
projParams.Color._colorize[2] = colorizeB;
|
|
if (isAlternating != '\0') {
|
|
if ((local_144 & 1) == 0) {
|
|
(*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(projParams.BulletFlags)) + 0x0))) = GHIDRA_UINT(projParams.BulletFlags) | 0x80000;
|
|
projParams.Color._colorize[0] = altColorizeR;
|
|
projParams.Color._colorize[1] = local_158;
|
|
projParams.Color._colorize[2] = local_158;
|
|
}
|
|
else {
|
|
(*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(projParams.BulletFlags)) + 0x0))) = GHIDRA_UINT(projParams.BulletFlags) | 0x40000;
|
|
}
|
|
}
|
|
projParams.BulletFlags =
|
|
CONCAT44((*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(projParams.BulletFlags)) + 0x4))) | local_140,GHIDRA_UINT(projParams.BulletFlags));
|
|
if (local_164 == 1.26117e-44) {
|
|
projVelocity.y = (float)GHIDRA_INT(uVar5);
|
|
}
|
|
Entity_NPC::FireProjectiles(npc,&npc->_pos,&projVelocity,GHIDRA_UINT(local_164),&projParams);
|
|
bVar7 = true;
|
|
}
|
|
uVar4 = repeatsLeft;
|
|
iVar6 = iVar6 + 1;
|
|
} while (iVar6 < burstCount);
|
|
if (!bVar7) goto LAB_004a97bc;
|
|
if (npc->_type == 0x19c) {
|
|
curAnimData = (npc->_sprite)._animState._animData;
|
|
if (curAnimData != GHIDRA_CAST<byte *>(0x0)) {
|
|
animNameCh = curAnimData;
|
|
if (0xf < *GHIDRA_CAST<uint *>((curAnimData + 0x14))) {
|
|
animNameCh = *GHIDRA_CAST<byte **>(curAnimData);
|
|
}
|
|
expectedNameCh = "Blink";
|
|
do {
|
|
bVar1 = *animNameCh;
|
|
bVar7 = bVar1 < (byte)*expectedNameCh;
|
|
if (bVar1 != *expectedNameCh) {
|
|
LAB_004a9717:
|
|
uVar5 = -GHIDRA_UINT(bVar7) | 1;
|
|
goto LAB_004a971c;
|
|
}
|
|
if (bVar1 == 0) break;
|
|
bVar1 = animNameCh[1];
|
|
bVar7 = bVar1 < (byte)expectedNameCh[1];
|
|
if (bVar1 != expectedNameCh[1]) goto LAB_004a9717;
|
|
animNameCh = animNameCh + 2;
|
|
expectedNameCh = expectedNameCh + 2;
|
|
} while (bVar1 != 0);
|
|
uVar5 = 0;
|
|
LAB_004a971c:
|
|
if ((uVar5 == 0) && ((curAnimData[0x34] == 0 || ((npc->_sprite)._animState._isPlaying != 0))))
|
|
goto LAB_004a9753;
|
|
}
|
|
bVar1 = (GHIDRA_CAST<ANM2 *>((&npc->_sprite)))->ANM2::SetAnimation(GHIDRA_CAST<byte *>("Blink"),1);
|
|
if (bVar1 != 0) {
|
|
(GHIDRA_CAST<AnimationState *>((&(npc->_sprite)._animState)))->AnimationState::Rewind();
|
|
(npc->_sprite)._animState._isPlaying = 1;
|
|
}
|
|
}
|
|
LAB_004a9753:
|
|
uVar4 = uVar4 - 1;
|
|
if (GHIDRA_INT(uVar4) < 1) {
|
|
uVar5 = Random();
|
|
if (uVar5 % 100 < keepPatternChance) {
|
|
keepPatternChance = keepPatternChance - 10;
|
|
}
|
|
else {
|
|
do {
|
|
uVar5 = Random();
|
|
} while (uVar5 % 0xb == patternId);
|
|
keepPatternChance = 0x1e;
|
|
attackAngle = Random();
|
|
attackAngle = attackAngle % 0xff;
|
|
patternId = uVar5 % 0xb;
|
|
}
|
|
uVar4 = 0xff;
|
|
}
|
|
LAB_004a97bc:
|
|
*GHIDRA_CAST<uint *>(&npc->_deliriumAttackAngle) = attackAngle & 0xff;
|
|
npc->_deliriumAttackID =
|
|
((((attackId >> 0x18) + 1 & 0xff) << 8 | keepPatternChance & 0xff) << 8 | uVar4 & 0xff) << 8
|
|
| patternId;
|
|
/* WARNING: Read-only address (ram,0x00bab470) is written */
|
|
return;
|
|
}
|
|
|
|
// 004a9860
|
|
void NpcHelper::delirium_morph_update(Entity_NPC *npc)
|
|
{
|
|
int iVar1;
|
|
byte isAnimSet;
|
|
uint nextCycleCount;
|
|
int iVar2;
|
|
uint uVar3;
|
|
uint uVar4;
|
|
float fVar5;
|
|
float stepFraction;
|
|
double dVar6;
|
|
float fVar7;
|
|
byte *anim;
|
|
float local_28;
|
|
float local_24;
|
|
uint chanceDivisor;
|
|
float local_1c;
|
|
uint aiUpdateCount;
|
|
int step;
|
|
float stepVelocityY;
|
|
float stepVelocityX;
|
|
uint cycleTime;
|
|
uint cycleId;
|
|
Manager *manager;
|
|
|
|
local_28 = npc->_health;
|
|
if (local_28 == 0.0) {
|
|
return;
|
|
}
|
|
cycleId = npc->_deliriumCycleID;
|
|
local_24 = npc->_maxHitPoints;
|
|
uVar4 = cycleId >> 7 & 0xff;
|
|
cycleTime = cycleId >> 0x19 | (npc->_deliriumCycleIDHigh & 7U) << 7;
|
|
if (local_24 == 0.0) {
|
|
KAGE_LogMessage(0x10,GHIDRA_CAST<byte *>("Start and End parameters cannot be the same!"));
|
|
}
|
|
local_1c = (float)__ftoui3();
|
|
uVar3 = cycleTime;
|
|
stepVelocityX = (npc->_velocity).x;
|
|
stepVelocityY = (npc->_velocity).y;
|
|
aiUpdateCount = GHIDRA_INT(local_1c) + 1;
|
|
chanceDivisor = 3 - GHIDRA_INT(local_1c);
|
|
nextCycleCount = uVar4 - 1;
|
|
if (uVar4 == 0) {
|
|
nextCycleCount = 0;
|
|
fVar7 = local_1c;
|
|
}
|
|
else {
|
|
fVar7 = 4.2039e-45;
|
|
}
|
|
iVar2 = npc->_type;
|
|
iVar1 = GHIDRA_INT(fVar7) >> 0x1f;
|
|
if (iVar2 < 0x194) {
|
|
if (iVar2 == 0x193) {
|
|
switchD_004a998d_caseD_45:
|
|
fVar5 = (float)((double)GHIDRA_INT(fVar7) + __uint_to_double_fixup[-iVar1]) / 3.0;
|
|
stepVelocityX = stepVelocityX * fVar5;
|
|
stepVelocityY = stepVelocityY * fVar5;
|
|
goto switchD_004a998d_caseD_15;
|
|
}
|
|
switch(iVar2) {
|
|
case 0x13:
|
|
case 0x1c:
|
|
case 0x61:
|
|
case 99:
|
|
case 100:
|
|
case 0xed:
|
|
case 0x10b:
|
|
fVar5 = (float)((double)GHIDRA_INT(fVar7) + __uint_to_double_fixup[-iVar1]) / 3.0;
|
|
stepVelocityX = stepVelocityX * 0.20000005 * fVar5;
|
|
stepVelocityY = stepVelocityY * 0.20000005 * fVar5;
|
|
break;
|
|
case 0x14:
|
|
case 0x52:
|
|
goto switchD_004a998d_caseD_14;
|
|
case 0x24:
|
|
case 0x2b:
|
|
case 0x4e:
|
|
case 0x106:
|
|
if (cycleTime < 0x1e) {
|
|
if (npc->_state == 8) {
|
|
npc->_state = 3;
|
|
}
|
|
}
|
|
else if (npc->_state != 8) goto LAB_004a9b6d;
|
|
local_24 = npc->_maxHitPoints;
|
|
local_28 = npc->_health;
|
|
if (local_24 == 0.0) {
|
|
KAGE_LogMessage(0x10,GHIDRA_CAST<byte *>("Start and End parameters cannot be the same!"));
|
|
}
|
|
fVar7 = (float)__ftoui3();
|
|
aiUpdateCount = GHIDRA_INT(fVar7) + 1;
|
|
local_1c = fVar7;
|
|
goto LAB_004a9b6d;
|
|
case 0x2d:
|
|
if ((0x3c < cycleTime) && (iVar2 = Isaac::Random(chanceDivisor), iVar2 == 0)) {
|
|
npc->_projectileCooldown = 0;
|
|
}
|
|
local_24 = npc->_maxHitPoints;
|
|
local_28 = npc->_health;
|
|
if (local_24 == 0.0) {
|
|
KAGE_LogMessage(0x10,GHIDRA_CAST<byte *>("Start and End parameters cannot be the same!"));
|
|
}
|
|
goto LAB_004a9d83;
|
|
case 0x3e:
|
|
if (npc->_variant == 0) {
|
|
fVar5 = 1.2;
|
|
}
|
|
else {
|
|
fVar5 = 2.0;
|
|
}
|
|
stepFraction = (float)((double)GHIDRA_INT(fVar7) + __uint_to_double_fixup[-iVar1]) / 3.0;
|
|
stepVelocityX = stepVelocityX * (fVar5 - 1.0) * stepFraction;
|
|
stepVelocityY = stepVelocityY * (fVar5 - 1.0) * stepFraction;
|
|
break;
|
|
case 0x3f:
|
|
fVar5 = (float)((double)GHIDRA_INT(fVar7) + __uint_to_double_fixup[-iVar1]) / 3.0;
|
|
stepVelocityX = stepVelocityX * 1.5 * fVar5;
|
|
stepVelocityY = stepVelocityY * 1.5 * fVar5;
|
|
break;
|
|
case 0x41:
|
|
fVar5 = (float)((double)GHIDRA_INT(fVar7) + __uint_to_double_fixup[-iVar1]) / 3.0;
|
|
if (npc->_variant == 10) {
|
|
stepVelocityX = stepVelocityX * 0.0 * fVar5;
|
|
stepVelocityY = stepVelocityY * 0.0 * fVar5;
|
|
break;
|
|
}
|
|
if (npc->_variant == 1) goto LAB_004a9b8f;
|
|
stepVelocityX = stepVelocityX * 1.5;
|
|
stepVelocityY = stepVelocityY * 1.5;
|
|
goto LAB_004a9b9f;
|
|
case 0x43:
|
|
if (npc->_variant != 1) goto LAB_004aa3d4;
|
|
LAB_004a9b6d:
|
|
fVar5 = (float)((double)GHIDRA_INT(fVar7) + __uint_to_double_fixup[-(GHIDRA_INT(fVar7) >> 0x1f)]) / 3.0;
|
|
LAB_004a9b8f:
|
|
stepVelocityX = stepVelocityX * 0.39999998;
|
|
stepVelocityY = stepVelocityY * 0.39999998;
|
|
LAB_004a9b9f:
|
|
stepVelocityX = stepVelocityX * fVar5;
|
|
stepVelocityY = stepVelocityY * fVar5;
|
|
goto LAB_004aa3d4;
|
|
case 0x44:
|
|
if (npc->_variant != 1) goto LAB_004aa3d4;
|
|
iVar2 = npc->_state;
|
|
if (cycleTime < 0x1e) {
|
|
if ((iVar2 == 9) || (iVar2 == 10)) {
|
|
npc->_state = 3;
|
|
}
|
|
}
|
|
else if ((iVar2 != 9) && (iVar2 != 10)) goto LAB_004aa3d4;
|
|
local_24 = npc->_maxHitPoints;
|
|
local_28 = npc->_health;
|
|
if (local_24 == 0.0) {
|
|
KAGE_LogMessage(0x10,GHIDRA_CAST<byte *>("Start and End parameters cannot be the same!"));
|
|
}
|
|
LAB_004a9d83:
|
|
fVar7 = (float)__ftoui3();
|
|
aiUpdateCount = GHIDRA_INT(fVar7) + 1;
|
|
local_1c = fVar7;
|
|
goto LAB_004aa3d4;
|
|
case 0x45:
|
|
goto switchD_004a998d_caseD_45;
|
|
case 0x4a:
|
|
goto switchD_004a998d_caseD_4a;
|
|
case 0x4f:
|
|
if (npc->_variant == 2) {
|
|
fVar5 = 1.1;
|
|
}
|
|
else {
|
|
fVar5 = 1.2;
|
|
}
|
|
stepFraction = (float)((double)GHIDRA_INT(fVar7) + __uint_to_double_fixup[-iVar1]) / 3.0;
|
|
stepVelocityX = stepVelocityX * (fVar5 - 1.0) * stepFraction;
|
|
stepVelocityY = stepVelocityY * (fVar5 - 1.0) * stepFraction;
|
|
break;
|
|
case 0x51:
|
|
npc->_maxHitPoints = npc->_health;
|
|
goto switchD_004a998d_caseD_4a;
|
|
case 0x54:
|
|
if (npc->_variant == 10) {
|
|
iVar2 = Isaac::Random(chanceDivisor);
|
|
if (iVar2 == 0) {
|
|
npc->_stateFrame = 0;
|
|
}
|
|
fVar7 = (float)((double)GHIDRA_INT(fVar7) + __uint_to_double_fixup[-iVar1]) / 3.0;
|
|
stepVelocityX = stepVelocityX * 0.20000005 * fVar7;
|
|
stepVelocityY = stepVelocityY * 0.20000005 * fVar7;
|
|
local_28 = npc->_health;
|
|
local_24 = npc->_maxHitPoints;
|
|
if (local_24 == 0.0) {
|
|
KAGE_LogMessage(0x10,GHIDRA_CAST<byte *>("Start and End parameters cannot be the same!"));
|
|
}
|
|
}
|
|
else {
|
|
fVar7 = (float)((double)GHIDRA_INT(fVar7) + __uint_to_double_fixup[-iVar1]) / 3.0;
|
|
stepVelocityX = stepVelocityX * 0.0 * fVar7;
|
|
stepVelocityY = stepVelocityY * 0.0 * fVar7;
|
|
local_28 = npc->_health;
|
|
local_24 = npc->_maxHitPoints;
|
|
if (local_24 == 0.0) {
|
|
KAGE_LogMessage(0x10,GHIDRA_CAST<byte *>("Start and End parameters cannot be the same!"));
|
|
}
|
|
}
|
|
goto LAB_004aa3bf;
|
|
case 0x65:
|
|
local_1c = 0.0;
|
|
break;
|
|
case 0x66:
|
|
local_24 = npc->_maxHitPoints;
|
|
local_28 = npc->_health;
|
|
if (local_24 == 0.0) {
|
|
KAGE_LogMessage(0x10,GHIDRA_CAST<byte *>("Start and End parameters cannot be the same!"));
|
|
}
|
|
fVar7 = (float)__ftoui3();
|
|
fVar5 = (float)((double)GHIDRA_INT(fVar7) + __uint_to_double_fixup[-(GHIDRA_INT(fVar7) >> 0x1f)]) / 3.0;
|
|
stepVelocityX = stepVelocityX * 0.6 * fVar5;
|
|
stepVelocityY = stepVelocityY * 0.6 * fVar5;
|
|
goto LAB_004aa3cc;
|
|
case 0x105:
|
|
aiUpdateCount = 2;
|
|
fVar5 = (float)((double)GHIDRA_INT(fVar7) + __uint_to_double_fixup[-iVar1]) / 3.0;
|
|
stepVelocityX = stepVelocityX * 0.20000005 * fVar5;
|
|
stepVelocityY = stepVelocityY * 0.20000005 * fVar5;
|
|
break;
|
|
case 0x107:
|
|
dVar6 = __uint_to_double_fixup[-iVar1];
|
|
(npc->_pos).x = (npc->_targetPosition).x;
|
|
(npc->_pos).y = (npc->_targetPosition).y;
|
|
fVar5 = (float)((double)GHIDRA_INT(fVar7) + dVar6) / 3.0;
|
|
stepVelocityX = stepVelocityX * -1.0 * fVar5;
|
|
stepVelocityY = stepVelocityY * -1.0 * fVar5;
|
|
break;
|
|
case 0x109:
|
|
if (npc->_state == 6) goto switchD_004aa2e2_caseD_197;
|
|
break;
|
|
case 0x10c:
|
|
fVar7 = (float)((double)GHIDRA_INT(fVar7) + __uint_to_double_fixup[-iVar1]) / 3.0;
|
|
stepVelocityX = stepVelocityX * 0.20000005 * fVar7;
|
|
stepVelocityY = stepVelocityY * 0.20000005 * fVar7;
|
|
local_24 = npc->_health;
|
|
local_1c = npc->_maxHitPoints;
|
|
if (npc->_state == 8) {
|
|
if (local_1c == 0.0) {
|
|
KAGE_LogMessage(0x10,GHIDRA_CAST<byte *>("Start and End parameters cannot be the same!"));
|
|
}
|
|
}
|
|
else if (local_1c == 0.0) {
|
|
KAGE_LogMessage(0x10,GHIDRA_CAST<byte *>("Start and End parameters cannot be the same!"));
|
|
}
|
|
goto LAB_004aa3bf;
|
|
case 0x10f:
|
|
case 0x110:
|
|
case 0x111:
|
|
aiUpdateCount = 1;
|
|
fVar5 = (float)((double)GHIDRA_INT(fVar7) + __uint_to_double_fixup[-iVar1]) / 3.0;
|
|
stepVelocityX = stepVelocityX * 0.20000005 * fVar5;
|
|
stepVelocityY = stepVelocityY * 0.20000005 * fVar5;
|
|
}
|
|
goto switchD_004a998d_caseD_15;
|
|
}
|
|
switch(iVar2) {
|
|
case 0x194:
|
|
fVar7 = (float)((double)GHIDRA_INT(fVar7) + __uint_to_double_fixup[-iVar1]) / 3.0;
|
|
stepVelocityX = stepVelocityX * fVar7;
|
|
stepVelocityY = stepVelocityY * fVar7;
|
|
goto LAB_004aa34b;
|
|
case 0x195:
|
|
switchD_004a998d_caseD_14:
|
|
fVar5 = (float)((double)GHIDRA_INT(fVar7) + __uint_to_double_fixup[-iVar1]) / 3.0;
|
|
stepVelocityX = stepVelocityX * 0.39999998 * fVar5;
|
|
stepVelocityY = stepVelocityY * 0.39999998 * fVar5;
|
|
break;
|
|
case 0x197:
|
|
switchD_004aa2e2_caseD_197:
|
|
local_24 = npc->_maxHitPoints;
|
|
local_28 = npc->_health;
|
|
if (local_24 == 0.0) {
|
|
KAGE_LogMessage(0x10,GHIDRA_CAST<byte *>("Start and End parameters cannot be the same!"));
|
|
}
|
|
goto LAB_004aa3bf;
|
|
case 0x19a:
|
|
fVar7 = (float)((double)GHIDRA_INT(fVar7) + __uint_to_double_fixup[-iVar1]) / 3.0;
|
|
stepVelocityX = stepVelocityX * 0.6 * fVar7;
|
|
stepVelocityY = stepVelocityY * 0.6 * fVar7;
|
|
LAB_004aa34b:
|
|
local_28 = npc->_health;
|
|
local_24 = npc->_maxHitPoints;
|
|
if (local_24 == 0.0) {
|
|
KAGE_LogMessage(0x10,GHIDRA_CAST<byte *>("Start and End parameters cannot be the same!"));
|
|
}
|
|
LAB_004aa3bf:
|
|
fVar7 = (float)__ftoui3();
|
|
LAB_004aa3cc:
|
|
aiUpdateCount = GHIDRA_INT(fVar7) + 1;
|
|
local_1c = fVar7;
|
|
}
|
|
switchD_004a998d_caseD_15:
|
|
uVar3 = cycleTime;
|
|
LAB_004aa3d4:
|
|
if (GHIDRA_UINT((GHIDRA_INT(fVar7) * 4)) < uVar3) {
|
|
step = 0;
|
|
do {
|
|
uVar4 = chanceDivisor;
|
|
dVar6 = 10.0;
|
|
switch(npc->_type) {
|
|
case 0x14:
|
|
case 0x2b:
|
|
if ((npc->_state == 3) && ((chanceDivisor == 0 || (uVar3 = Random(), uVar3 % uVar4 == 0))))
|
|
{
|
|
uVar4 = Random();
|
|
if ((uVar4 & 1) == 0) {
|
|
npc->_state = 8;
|
|
anim = GHIDRA_CAST<byte *>("Taunt");
|
|
}
|
|
else {
|
|
if ((uVar4 & 1) != 1) break;
|
|
local_24 = 1.0;
|
|
npc->_state = 6;
|
|
manager = g_manager;
|
|
if (npc->_championColorIdx == 0x12) {
|
|
local_24 = 1.5;
|
|
}
|
|
else if (npc->_championColorIdx == 0x13) {
|
|
local_24 = 0.5;
|
|
}
|
|
local_28 = 1.96182e-44;
|
|
seed_fart_sound_override(GHIDRA_CAST<int *>(&local_28));
|
|
(GHIDRA_CAST<SoundEffects *>((&manager->_sfxManager)))->SoundEffects::Play(GHIDRA_INT(local_28),1.0,2,0,local_24,0.0);
|
|
anim = &DAT_00b1e0e4;
|
|
}
|
|
LAB_004aa517:
|
|
isAnimSet = (GHIDRA_CAST<ANM2 *>((&npc->_sprite)))->ANM2::SetAnimation(anim,1);
|
|
if (isAnimSet != 0) {
|
|
(GHIDRA_CAST<AnimationState *>((&(npc->_sprite)._animState)))->AnimationState::Rewind();
|
|
(npc->_sprite)._animState._isPlaying = 1;
|
|
}
|
|
}
|
|
break;
|
|
case 0x1c:
|
|
if ((((npc->_variant == 0) && (npc->_state == 4)) &&
|
|
((chanceDivisor == 0 || (uVar3 = Random(), uVar3 % uVar4 == 0)))) &&
|
|
(npc->_stateFrame == 0)) {
|
|
npc->_state = 0xd;
|
|
}
|
|
break;
|
|
case 0x40:
|
|
if (npc->_state == 4) {
|
|
libm_sse2_pow_precise();
|
|
if ((GHIDRA_INT(dVar6) == 0) || (uVar4 = Random(), uVar4 % GHIDRA_UINT(GHIDRA_INT(dVar6)) == 0)) {
|
|
uVar4 = Random();
|
|
npc->_stateFrame = 0;
|
|
if ((uVar4 & 1) == 0) {
|
|
npc->_state = 0xd;
|
|
anim = s_Attack2;
|
|
if (npc->_i1 != 0) {
|
|
anim = GHIDRA_CAST<byte *>("HeadlessAttack2");
|
|
}
|
|
}
|
|
else {
|
|
npc->_state = 8;
|
|
anim = s_Attack1;
|
|
if (npc->_i1 != 0) {
|
|
anim = GHIDRA_CAST<byte *>("HeadlessAttack1");
|
|
}
|
|
}
|
|
goto LAB_004aa517;
|
|
}
|
|
}
|
|
break;
|
|
case 0x41:
|
|
if ((npc->_state == 4) && (npc->_variant != 10)) {
|
|
libm_sse2_pow_precise();
|
|
if ((GHIDRA_INT(dVar6) == 0) || (uVar4 = Random(), uVar4 % GHIDRA_UINT(GHIDRA_INT(dVar6)) == 0)) {
|
|
uVar4 = Random();
|
|
if ((uVar4 & 1) == 0) {
|
|
npc->_state = 8;
|
|
npc->_stateFrame = 0;
|
|
anim = s_Attack1;
|
|
}
|
|
else {
|
|
uVar4 = Random();
|
|
manager = g_manager;
|
|
local_24 = 1.0;
|
|
if (npc->_championColorIdx == 0x12) {
|
|
local_24 = 1.5;
|
|
}
|
|
else if (npc->_championColorIdx == 0x13) {
|
|
local_24 = 0.5;
|
|
}
|
|
local_28 = (float)((uVar4 & 3) + 0x73);
|
|
seed_fart_sound_override(GHIDRA_CAST<int *>(&local_28));
|
|
(GHIDRA_CAST<SoundEffects *>((&manager->_sfxManager)))->SoundEffects::Play(GHIDRA_INT(local_28),1.0,2,0,local_24,0.0);
|
|
npc->_state = 6;
|
|
npc->_stateFrame = 0;
|
|
anim = s_Attack2;
|
|
}
|
|
goto LAB_004aa517;
|
|
}
|
|
}
|
|
break;
|
|
case 0x42:
|
|
if ((npc->_state == 4) && (npc->_variant != 10)) {
|
|
libm_sse2_pow_precise();
|
|
if ((GHIDRA_INT(dVar6) == 0) || (uVar4 = Random(), uVar4 % GHIDRA_UINT(GHIDRA_INT(dVar6)) == 0)) {
|
|
if (npc->_variant == 0x1e) {
|
|
LAB_004aa7f9:
|
|
npc->_state = 0xd;
|
|
}
|
|
else {
|
|
uVar4 = Random();
|
|
uVar4 = uVar4 % 3;
|
|
if (uVar4 == 0) goto LAB_004aa7f9;
|
|
if (uVar4 == 1) {
|
|
npc->_state = 8;
|
|
}
|
|
else if (uVar4 == 2) {
|
|
npc->_state = 0xe;
|
|
}
|
|
}
|
|
npc->_stateFrame = 0;
|
|
}
|
|
}
|
|
break;
|
|
case 0x4a:
|
|
if (npc->_state == 0x10) {
|
|
npc->_state = 3;
|
|
}
|
|
}
|
|
if (step != 0) {
|
|
if ((GHIDRA_UINT(step) <= GHIDRA_UINT(local_1c)) && ((npc->_sprite)._loaded != 0)) {
|
|
(GHIDRA_CAST<AnimationState *>((&(npc->_sprite)._animState)))->AnimationState::Update();
|
|
(GHIDRA_CAST<AnimationState *>((&(npc->_sprite)._overlayAnimState)))->AnimationState::Update();
|
|
}
|
|
(npc->_pos).x = stepVelocityX + (npc->_pos).x;
|
|
(npc->_pos).y = stepVelocityY + (npc->_pos).y;
|
|
}
|
|
if (GHIDRA_UINT(step) < aiUpdateCount) {
|
|
Entity_NPC_UpdateAI_dispatch(npc);
|
|
}
|
|
step = step + 1;
|
|
} while (GHIDRA_UINT(step) <= GHIDRA_UINT(fVar7));
|
|
npc->_deliriumCycleIDHigh = 0;
|
|
npc->_deliriumCycleID =
|
|
((cycleId >> 0xf & 0x3ff | cycleTime << 10) << 8 | nextCycleCount & 0xff) << 7 |
|
|
cycleId & 0x7f;
|
|
}
|
|
else if ((npc->_sprite)._loaded != 0) {
|
|
(GHIDRA_CAST<AnimationState *>((&(npc->_sprite)._animState)))->AnimationState::Update();
|
|
(GHIDRA_CAST<AnimationState *>((&(npc->_sprite)._overlayAnimState)))->AnimationState::Update();
|
|
return;
|
|
}
|
|
return;
|
|
switchD_004a998d_caseD_4a:
|
|
fVar5 = (float)((double)GHIDRA_INT(fVar7) + __uint_to_double_fixup[-iVar1]) / 3.0;
|
|
stepVelocityX = stepVelocityX * 0.6 * fVar5;
|
|
stepVelocityY = stepVelocityY * 0.6 * fVar5;
|
|
goto switchD_004a998d_caseD_15;
|
|
}
|
|
|
|
// 004b0fe0
|
|
void NpcHelper::gideon_spawn_stairs(Entity_NPC *npc)
|
|
{
|
|
code *pcVar1;
|
|
Room *pRVar2;
|
|
RoomConfig_Room *crawlspaceConfig;
|
|
uint gridCollision;
|
|
GridEntity *stairs;
|
|
uint uVar3;
|
|
RoomDescriptor *crawlspaceDesc;
|
|
RNG rng;
|
|
Room *local_18;
|
|
uint local_14;
|
|
void *local_10;
|
|
undefined1 *puStack_c;
|
|
undefined4 local_8;
|
|
Game *game;
|
|
undefined4 *oldGridEntity;
|
|
|
|
game = g_game;
|
|
local_8 = 0xffffffff;
|
|
puStack_c = &LAB_00af3203;
|
|
local_10 = ExceptionList;
|
|
ExceptionList = &local_10;
|
|
if (-1 < npc->_projectileDelay) {
|
|
if (*GHIDRA_CAST<int *>((*GHIDRA_CAST<int *>(ThreadLocalStoragePointer) + 0xc)) < g_invalidRoomDescriptorGuard) {
|
|
_Init_thread_header(&g_invalidRoomDescriptorGuard,
|
|
__security_cookie ^ GHIDRA_INT(register0x00000010) - 4U);
|
|
if (g_invalidRoomDescriptorGuard == -1) {
|
|
local_8 = 0;
|
|
(GHIDRA_CAST<RoomDescriptor *>((&g_roomDescriptorDummy)))->RoomDescriptor::constructor();
|
|
_atexit(FUN_00b15b30);
|
|
local_8 = 0xffffffff;
|
|
_Init_thread_footer(&g_invalidRoomDescriptorGuard);
|
|
}
|
|
}
|
|
crawlspaceDesc = &g_roomDescriptorDummy;
|
|
if (GHIDRA_UINT(game->_currentDimensionIdx) < 3) {
|
|
crawlspaceDesc = game->_roomList + 0x205;
|
|
}
|
|
if (crawlspaceDesc->Data == (void *)0x0) {
|
|
rng._seed = (game->_devilAngelRoomRNG)._seed;
|
|
rng._shift3 = 0x1b;
|
|
rng._shift1 = 1;
|
|
rng._shift2 = 0x1b;
|
|
(GHIDRA_CAST<Seeds *>((GHIDRA_CAST<Seeds *>(crawlspaceDesc))))->Seeds::Init3(&rng);
|
|
local_18 = GHIDRA_CAST<Room *>(&g_game->_roomConfig);
|
|
local_14 = 0;
|
|
if (rng._seed == 0) {
|
|
KAGE_LogMessage(0x10,GHIDRA_CAST<byte *>("RNG Seed is zero!\n"));
|
|
pcVar1 = (code *)swi(3);
|
|
(*pcVar1)();
|
|
return;
|
|
}
|
|
uVar3 = GHIDRA_UINT(rng._seed) >> ((byte)rng._shift1 & 0x1f) ^ rng._seed;
|
|
uVar3 = uVar3 << ((byte)rng._shift2 & 0x1f) ^ uVar3;
|
|
crawlspaceConfig =
|
|
RoomConfig::GetRandomRoom
|
|
(GHIDRA_CAST<RoomConfig *>(local_18),uVar3 >> ((byte)rng._shift3 & 0x1f) ^ uVar3,0,0,0x10,
|
|
0xd,0,-1,0,0,&local_14,1,-1);
|
|
crawlspaceDesc->Data = crawlspaceConfig;
|
|
}
|
|
local_18 = g_game->_room;
|
|
local_14 = Random();
|
|
uVar3 = npc->_projectileDelay;
|
|
if ((GHIDRA_INT(uVar3) < 0) || (0x1bf < GHIDRA_INT(uVar3))) {
|
|
KAGE_LogMessage(0x10,GHIDRA_CAST<byte *>("SpawnGridEntity: Grid index invalid\n"));
|
|
}
|
|
pRVar2 = local_18;
|
|
if (uVar3 < 0x1c0) {
|
|
gridCollision = (GHIDRA_CAST<Room *>((local_18)))->Room::GetGridCollision(uVar3);
|
|
if (GHIDRA_INT(gridCollision) < 1) {
|
|
stairs = operator_new(0x154);
|
|
local_8 = 0x12;
|
|
local_18 = GHIDRA_CAST<Room *>(stairs);
|
|
if (stairs == GHIDRA_CAST<GridEntity *>(0x0)) {
|
|
stairs = GHIDRA_CAST<GridEntity *>(0x0);
|
|
}
|
|
else {
|
|
(GHIDRA_CAST<GridEntity *>((stairs)))->GridEntity::GridEntity();
|
|
*GHIDRA_CAST<undefined ***>(stairs) = IsaacRepentancePlus::GridEntity_Stairs::vftable;
|
|
}
|
|
local_8 = 0xffffffff;
|
|
if (stairs != GHIDRA_CAST<GridEntity *>(0x0)) {
|
|
(stairs->_desc)._type = 0x12;
|
|
stairs->_gridIndex = uVar3;
|
|
oldGridEntity = pRVar2->_gridEntities[uVar3];
|
|
if (oldGridEntity != GHIDRA_CAST<undefined4 *>(0x0)) {
|
|
(**(code **)*oldGridEntity)(1);
|
|
}
|
|
pRVar2->_gridEntities[uVar3] = stairs;
|
|
(stairs->_desc)._variant = 1;
|
|
(stairs->_desc)._varData = 0;
|
|
(GHIDRA_CAST<GridEntity *>((stairs)))->GridEntity::Init(local_14);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
ExceptionList = local_10;
|
|
return;
|
|
}
|
|
|
|
// 004b1210
|
|
void NpcHelper::gideon_choose_attack(Entity_NPC *npc)
|
|
{
|
|
EntityPtr EVar1;
|
|
RNG rng;
|
|
undefined1 *puVar2;
|
|
EntityPtr EVar3;
|
|
byte bVar4;
|
|
uint *puVar5;
|
|
uint uVar6;
|
|
int iVar7;
|
|
byte *curAnimName;
|
|
uint outcomeCount;
|
|
int iVar8;
|
|
byte *wantedAnimName;
|
|
char *wantedAnimNameStr;
|
|
ushort newCooldown;
|
|
WeightedOutcomePicker ptr;
|
|
bool isLess;
|
|
undefined8 uStack_40;
|
|
uint uStack_38;
|
|
WeightedOutcomePicker picker;
|
|
undefined4 *outcomesEnd;
|
|
undefined4 *outcomesCapacity;
|
|
float pitch;
|
|
uint local_24;
|
|
undefined1 *puStack_20;
|
|
void *local_1c;
|
|
undefined1 *puStack_18;
|
|
undefined4 local_14;
|
|
byte *animData;
|
|
uint *attack4Cooldown;
|
|
Manager *manager;
|
|
EntityPtr parent;
|
|
int *weight;
|
|
|
|
puStack_20 = GHIDRA_CAST<undefined1 *>((GHIDRA_INT(register0x00000010) + -4));
|
|
local_14 = 0xffffffff;
|
|
puStack_18 = &LAB_00af322d;
|
|
local_1c = ExceptionList;
|
|
local_24 = __security_cookie ^ GHIDRA_INT(register0x00000010) - 0x10U;
|
|
ExceptionList = &local_1c;
|
|
EVar3 = npc->_parent;
|
|
EVar1 = (EntityPtr)npc;
|
|
while (parent = EVar3, parent != (EntityPtr)0x0) {
|
|
EVar1 = parent;
|
|
EVar3 = *GHIDRA_CAST<EntityPtr *>((GHIDRA_CAST<char *>(parent) + 0x3bc));
|
|
}
|
|
iVar7 = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(EVar1) + 0x3c0));
|
|
while (puVar2 = GHIDRA_CAST<undefined1 *>((GHIDRA_INT(register0x00000010) + -4)), iVar7 != 0) {
|
|
if ((EVar1 != (EntityPtr)npc) &&
|
|
((*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(EVar1) + 0xb64)) == 0xb || (*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(EVar1) + 0xb64)) == 7)))) {
|
|
uVar6 = Random();
|
|
attack4Cooldown = GHIDRA_CAST<uint *>((GHIDRA_INT(&npc->_i2) + 2));
|
|
newCooldown = (short)(uVar6 % 0x96) + 0x5a;
|
|
uStack_38 = GHIDRA_UINT(newCooldown);
|
|
puVar5 = &uStack_38;
|
|
if (newCooldown <= *GHIDRA_CAST<ushort *>(attack4Cooldown)) {
|
|
puVar5 = attack4Cooldown;
|
|
}
|
|
*GHIDRA_CAST<ushort *>(attack4Cooldown) = (ushort)*puVar5;
|
|
puVar2 = puStack_20;
|
|
break;
|
|
}
|
|
EVar1 = *GHIDRA_CAST<EntityPtr *>((GHIDRA_CAST<char *>(EVar1) + 0x3c0));
|
|
iVar7 = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(EVar1) + 0x3c0));
|
|
}
|
|
puStack_20 = puVar2;
|
|
picker = (WeightedOutcomePicker)0x0;
|
|
outcomesEnd = GHIDRA_CAST<undefined4 *>(0x0);
|
|
outcomesCapacity = GHIDRA_CAST<undefined4 *>(0x0);
|
|
local_14 = 0;
|
|
uStack_40 = (ulonglong)GHIDRA_UINT(uStack_40);
|
|
uStack_38 = 1;
|
|
std::vector<8byte>::_Emplace_reallocate(0,GHIDRA_INT(&uStack_40) + 4);
|
|
if ((short)npc->_i2 == 0) {
|
|
uVar6 = 0;
|
|
outcomeCount = GHIDRA_INT(outcomesEnd) - GHIDRA_INT(picker) >> 3;
|
|
if (outcomeCount != 0) {
|
|
do {
|
|
if (*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(picker) + uVar6 * 8)) == 1) {
|
|
weight = GHIDRA_CAST<int *>((GHIDRA_INT(picker) + 4 + uVar6 * 8));
|
|
*weight = *weight + 1;
|
|
if (*weight < 0) {
|
|
*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(picker) + 4 + uVar6 * 8)) = 0;
|
|
}
|
|
goto LAB_004b137f;
|
|
}
|
|
uVar6 = uVar6 + 1;
|
|
} while (uVar6 < outcomeCount);
|
|
}
|
|
uStack_40 = CONCAT44(1,GHIDRA_UINT(uStack_40));
|
|
uStack_38 = 1;
|
|
if (outcomesEnd == outcomesCapacity) {
|
|
std::vector<8byte>::_Emplace_reallocate(outcomesEnd,GHIDRA_INT(&uStack_40) + 4);
|
|
}
|
|
else {
|
|
*outcomesEnd = 1;
|
|
outcomesEnd[1] = 1;
|
|
outcomesEnd = outcomesEnd + 2;
|
|
}
|
|
}
|
|
LAB_004b137f:
|
|
if ((3 < npc->_stateFrame) && (*GHIDRA_CAST<char *>((GHIDRA_INT(&npc->_i1) + 1)) == '\0')) {
|
|
uVar6 = 0;
|
|
outcomeCount = GHIDRA_INT(outcomesEnd) - GHIDRA_INT(picker) >> 3;
|
|
if (outcomeCount != 0) {
|
|
do {
|
|
if (*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(picker) + uVar6 * 8)) == 2) {
|
|
weight = GHIDRA_CAST<int *>((GHIDRA_INT(picker) + 4 + uVar6 * 8));
|
|
*weight = *weight + 6;
|
|
if (*weight < 0) {
|
|
*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(picker) + 4 + uVar6 * 8)) = 0;
|
|
}
|
|
goto LAB_004b13f7;
|
|
}
|
|
uVar6 = uVar6 + 1;
|
|
} while (uVar6 < outcomeCount);
|
|
}
|
|
uStack_40 = CONCAT44(2,GHIDRA_UINT(uStack_40));
|
|
uStack_38 = 6;
|
|
if (outcomesEnd == outcomesCapacity) {
|
|
std::vector<8byte>::_Emplace_reallocate(outcomesEnd,GHIDRA_INT(&uStack_40) + 4);
|
|
}
|
|
else {
|
|
*outcomesEnd = 2;
|
|
outcomesEnd[1] = 6;
|
|
outcomesEnd = outcomesEnd + 2;
|
|
}
|
|
}
|
|
LAB_004b13f7:
|
|
if (*GHIDRA_CAST<short *>((GHIDRA_INT(&npc->_i2) + 2)) == 0) {
|
|
iVar8 = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(g_game->_room) + 0x12c4)) + *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(g_game->_room) + 0x12c0));
|
|
iVar7 = 0;
|
|
if (0 < iVar8) {
|
|
iVar7 = iVar8;
|
|
}
|
|
if (iVar7 < 5) {
|
|
uVar6 = 0;
|
|
outcomeCount = GHIDRA_INT(outcomesEnd) - GHIDRA_INT(picker) >> 3;
|
|
if (outcomeCount != 0) {
|
|
do {
|
|
if (*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(picker) + uVar6 * 8)) == 3) {
|
|
weight = GHIDRA_CAST<int *>((GHIDRA_INT(picker) + 4 + uVar6 * 8));
|
|
*weight = *weight + 1;
|
|
if (*weight < 0) {
|
|
*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(picker) + 4 + uVar6 * 8)) = 0;
|
|
}
|
|
goto LAB_004b1488;
|
|
}
|
|
uVar6 = uVar6 + 1;
|
|
} while (uVar6 < outcomeCount);
|
|
}
|
|
uStack_40 = CONCAT44(3,GHIDRA_UINT(uStack_40));
|
|
uStack_38 = 1;
|
|
if (outcomesEnd == outcomesCapacity) {
|
|
std::vector<8byte>::_Emplace_reallocate(outcomesEnd,GHIDRA_INT(&uStack_40) + 4);
|
|
}
|
|
else {
|
|
*outcomesEnd = 3;
|
|
outcomesEnd[1] = 1;
|
|
outcomesEnd = outcomesEnd + 2;
|
|
}
|
|
}
|
|
}
|
|
LAB_004b1488:
|
|
uVar6 = Random();
|
|
uStack_40 = 0x900000005;
|
|
uStack_38 = 7;
|
|
rng._shift1 = 5;
|
|
rng._seed = uVar6 | 1;
|
|
rng._shift2 = 9;
|
|
rng._shift3 = 7;
|
|
uVar6 = (GHIDRA_CAST<WeightedOutcomePicker *>((&picker)))->WeightedOutcomePicker::PickOutcome(rng);
|
|
manager = g_manager;
|
|
switch(uVar6) {
|
|
case 0:
|
|
npc->_state = 8;
|
|
animData = (npc->_sprite)._animState._animData;
|
|
if (animData == GHIDRA_CAST<byte *>(0x0)) {
|
|
LAB_004b152e:
|
|
bVar4 = (GHIDRA_CAST<ANM2 *>((&npc->_sprite)))->ANM2::SetAnimation(s_Attack1,1);
|
|
if (bVar4 != 0) {
|
|
(GHIDRA_CAST<AnimationState *>((&(npc->_sprite)._animState)))->AnimationState::Rewind();
|
|
(npc->_sprite)._animState._isPlaying = 1;
|
|
}
|
|
}
|
|
else {
|
|
curAnimName = animData;
|
|
if (0xf < *GHIDRA_CAST<uint *>((animData + 0x14))) {
|
|
curAnimName = *GHIDRA_CAST<byte **>(animData);
|
|
}
|
|
wantedAnimName = s_Attack1;
|
|
do {
|
|
bVar4 = *curAnimName;
|
|
isLess = bVar4 < *wantedAnimName;
|
|
if (bVar4 != *wantedAnimName) {
|
|
LAB_004b1510:
|
|
uVar6 = -GHIDRA_UINT(isLess) | 1;
|
|
goto LAB_004b1515;
|
|
}
|
|
if (bVar4 == 0) break;
|
|
bVar4 = curAnimName[1];
|
|
isLess = bVar4 < wantedAnimName[1];
|
|
if (bVar4 != wantedAnimName[1]) goto LAB_004b1510;
|
|
curAnimName = curAnimName + 2;
|
|
wantedAnimName = wantedAnimName + 2;
|
|
} while (bVar4 != 0);
|
|
uVar6 = 0;
|
|
LAB_004b1515:
|
|
if ((uVar6 != 0) || ((animData[0x34] != 0 && ((npc->_sprite)._animState._isPlaying == 0))))
|
|
goto LAB_004b152e;
|
|
}
|
|
pitch = 0.9;
|
|
if (npc->_championColorIdx == 0x12) {
|
|
pitch = 1.4;
|
|
}
|
|
else if (npc->_championColorIdx == 0x13) {
|
|
pitch = 0.45;
|
|
}
|
|
uStack_38 = 0x136;
|
|
break;
|
|
case 1:
|
|
npc->_state = 9;
|
|
animData = (npc->_sprite)._animState._animData;
|
|
if (animData == GHIDRA_CAST<byte *>(0x0)) {
|
|
LAB_004b162e:
|
|
bVar4 = (GHIDRA_CAST<ANM2 *>((&npc->_sprite)))->ANM2::SetAnimation(GHIDRA_CAST<byte *>("Attack2Start"),1);
|
|
if (bVar4 != 0) {
|
|
(GHIDRA_CAST<AnimationState *>((&(npc->_sprite)._animState)))->AnimationState::Rewind();
|
|
(npc->_sprite)._animState._isPlaying = 1;
|
|
}
|
|
}
|
|
else {
|
|
curAnimName = animData;
|
|
if (0xf < *GHIDRA_CAST<uint *>((animData + 0x14))) {
|
|
curAnimName = *GHIDRA_CAST<byte **>(animData);
|
|
}
|
|
wantedAnimNameStr = "Attack2Start";
|
|
do {
|
|
bVar4 = *curAnimName;
|
|
isLess = bVar4 < (byte)*wantedAnimNameStr;
|
|
if (bVar4 != *wantedAnimNameStr) {
|
|
LAB_004b1610:
|
|
uVar6 = -GHIDRA_UINT(isLess) | 1;
|
|
goto LAB_004b1615;
|
|
}
|
|
if (bVar4 == 0) break;
|
|
bVar4 = curAnimName[1];
|
|
isLess = bVar4 < (byte)wantedAnimNameStr[1];
|
|
if (bVar4 != wantedAnimNameStr[1]) goto LAB_004b1610;
|
|
curAnimName = curAnimName + 2;
|
|
wantedAnimNameStr = wantedAnimNameStr + 2;
|
|
} while (bVar4 != 0);
|
|
uVar6 = 0;
|
|
LAB_004b1615:
|
|
if ((uVar6 != 0) || ((animData[0x34] != 0 && ((npc->_sprite)._animState._isPlaying == 0))))
|
|
goto LAB_004b162e;
|
|
}
|
|
pitch = 0.9;
|
|
*GHIDRA_CAST<undefined2 *>(&npc->_i2) = 0x1c2;
|
|
if (npc->_championColorIdx == 0x12) {
|
|
pitch = 1.4;
|
|
uStack_38 = 0x138;
|
|
}
|
|
else {
|
|
if (npc->_championColorIdx == 0x13) {
|
|
pitch = 0.45;
|
|
}
|
|
uStack_38 = 0x138;
|
|
}
|
|
break;
|
|
case 2:
|
|
pitch = 0.9;
|
|
npc->_state = 10;
|
|
manager = g_manager;
|
|
if (npc->_championColorIdx == 0x12) {
|
|
pitch = 1.4;
|
|
}
|
|
else if (npc->_championColorIdx == 0x13) {
|
|
pitch = 0.45;
|
|
}
|
|
uStack_38 = 0x133;
|
|
seed_fart_sound_override(GHIDRA_CAST<int *>(&uStack_38));
|
|
(GHIDRA_CAST<SoundEffects *>((&manager->_sfxManager)))->SoundEffects::Play(uStack_38,1.0,2,0,pitch,0.0);
|
|
animData = (npc->_sprite)._animState._animData;
|
|
if (animData == GHIDRA_CAST<byte *>(0x0)) {
|
|
LAB_004b177e:
|
|
bVar4 = (GHIDRA_CAST<ANM2 *>((&npc->_sprite)))->ANM2::SetAnimation(&DAT_00b1d2e4,1);
|
|
if (bVar4 != 0) {
|
|
(GHIDRA_CAST<AnimationState *>((&(npc->_sprite)._animState)))->AnimationState::Rewind();
|
|
(npc->_sprite)._animState._isPlaying = 1;
|
|
}
|
|
}
|
|
else {
|
|
curAnimName = animData;
|
|
if (0xf < *GHIDRA_CAST<uint *>((animData + 0x14))) {
|
|
curAnimName = *GHIDRA_CAST<byte **>(animData);
|
|
}
|
|
wantedAnimName = &DAT_00b1d2e4;
|
|
do {
|
|
bVar4 = *curAnimName;
|
|
isLess = bVar4 < *wantedAnimName;
|
|
if (bVar4 != *wantedAnimName) {
|
|
LAB_004b1760:
|
|
uVar6 = -GHIDRA_UINT(isLess) | 1;
|
|
goto LAB_004b1765;
|
|
}
|
|
if (bVar4 == 0) break;
|
|
bVar4 = curAnimName[1];
|
|
isLess = bVar4 < wantedAnimName[1];
|
|
if (bVar4 != wantedAnimName[1]) goto LAB_004b1760;
|
|
curAnimName = curAnimName + 2;
|
|
wantedAnimName = wantedAnimName + 2;
|
|
} while (bVar4 != 0);
|
|
uVar6 = 0;
|
|
LAB_004b1765:
|
|
if ((uVar6 != 0) || ((animData[0x34] != 0 && ((npc->_sprite)._animState._isPlaying == 0))))
|
|
goto LAB_004b177e;
|
|
}
|
|
*GHIDRA_CAST<undefined1 *>((GHIDRA_INT(&npc->_i1) + 1)) = 1;
|
|
goto switchD_004b14c5_default;
|
|
case 3:
|
|
pitch = 1.0;
|
|
if (npc->_championColorIdx == 0x12) {
|
|
pitch = 1.5;
|
|
}
|
|
else if (npc->_championColorIdx == 0x13) {
|
|
pitch = 0.5;
|
|
}
|
|
uStack_38 = 0x74;
|
|
seed_fart_sound_override(GHIDRA_CAST<int *>(&uStack_38));
|
|
(GHIDRA_CAST<SoundEffects *>((&manager->_sfxManager)))->SoundEffects::Play(uStack_38,1.0,2,0,pitch,0.0);
|
|
animData = (npc->_sprite)._animState._animData;
|
|
if (animData == GHIDRA_CAST<byte *>(0x0)) {
|
|
LAB_004b1874:
|
|
bVar4 = (GHIDRA_CAST<ANM2 *>((&npc->_sprite)))->ANM2::SetAnimation(GHIDRA_CAST<byte *>("Attack4Start"),1);
|
|
if (bVar4 != 0) {
|
|
(GHIDRA_CAST<AnimationState *>((&(npc->_sprite)._animState)))->AnimationState::Rewind();
|
|
(npc->_sprite)._animState._isPlaying = 1;
|
|
}
|
|
}
|
|
else {
|
|
curAnimName = animData;
|
|
if (0xf < *GHIDRA_CAST<uint *>((animData + 0x14))) {
|
|
curAnimName = *GHIDRA_CAST<byte **>(animData);
|
|
}
|
|
wantedAnimNameStr = "Attack4Start";
|
|
do {
|
|
bVar4 = *curAnimName;
|
|
isLess = bVar4 < (byte)*wantedAnimNameStr;
|
|
if (bVar4 != *wantedAnimNameStr) {
|
|
LAB_004b1856:
|
|
uVar6 = -GHIDRA_UINT(isLess) | 1;
|
|
goto LAB_004b185b;
|
|
}
|
|
if (bVar4 == 0) break;
|
|
bVar4 = curAnimName[1];
|
|
isLess = bVar4 < (byte)wantedAnimNameStr[1];
|
|
if (bVar4 != wantedAnimNameStr[1]) goto LAB_004b1856;
|
|
curAnimName = curAnimName + 2;
|
|
wantedAnimNameStr = wantedAnimNameStr + 2;
|
|
} while (bVar4 != 0);
|
|
uVar6 = 0;
|
|
LAB_004b185b:
|
|
if ((uVar6 != 0) || ((animData[0x34] != 0 && ((npc->_sprite)._animState._isPlaying == 0))))
|
|
goto LAB_004b1874;
|
|
}
|
|
npc->_state = 0xb;
|
|
*GHIDRA_CAST<undefined2 *>((GHIDRA_INT(&npc->_i2) + 2)) = 600;
|
|
default:
|
|
goto switchD_004b14c5_default;
|
|
}
|
|
manager = g_manager;
|
|
seed_fart_sound_override(GHIDRA_CAST<int *>(&uStack_38));
|
|
(GHIDRA_CAST<SoundEffects *>((&manager->_sfxManager)))->SoundEffects::Play(uStack_38,1.0,2,0,pitch,0.0);
|
|
switchD_004b14c5_default:
|
|
if (picker != (WeightedOutcomePicker)0x0) {
|
|
uVar6 = GHIDRA_INT(outcomesCapacity) - GHIDRA_INT(picker) & 0xfffffff8;
|
|
ptr = picker;
|
|
if (0xfff < uVar6) {
|
|
ptr = *GHIDRA_CAST<WeightedOutcomePicker *>((GHIDRA_CAST<char *>(picker) + -4));
|
|
uVar6 = uVar6 + 0x23;
|
|
if (0x1f < (GHIDRA_INT(picker) - GHIDRA_INT(ptr)) - 4U) {
|
|
/* WARNING: Subroutine does not return */
|
|
_invalid_parameter_noinfo_noreturn();
|
|
}
|
|
}
|
|
operator_delete((void *)ptr,uVar6);
|
|
}
|
|
ExceptionList = local_1c;
|
|
return;
|
|
}
|
|
|
|
// 004b1910
|
|
void NpcHelper::gideon_spawn_wave()
|
|
{
|
|
code *pcVar1;
|
|
uint spawnVariant;
|
|
uint stageType;
|
|
void **gridEntityCursor;
|
|
int gridX;
|
|
uint *nextEntry;
|
|
int iVar3;
|
|
uint *puVar4;
|
|
short *roomSpawn;
|
|
uint uVar5;
|
|
uint in_stack_ffffff38;
|
|
int in_stack_ffffff3c;
|
|
Vector local_9c;
|
|
undefined8 local_90;
|
|
Vector local_84;
|
|
uint pitCount;
|
|
uint waveDifficulty;
|
|
uint *entriesCapacityEnd;
|
|
void *gideon;
|
|
uint *entriesBegin;
|
|
uint *entriesEnd;
|
|
uint *local_64;
|
|
uint local_60;
|
|
int local_5c;
|
|
uint local_58;
|
|
Room *room;
|
|
uint *local_50;
|
|
Game *local_4c;
|
|
uint spawnEntry;
|
|
uint uStack_44;
|
|
uint local_40 [8];
|
|
undefined1 *puStack_20;
|
|
void *local_1c;
|
|
undefined1 *puStack_18;
|
|
uint local_14;
|
|
Game *game;
|
|
Manager *manager;
|
|
float maxHitPoints;
|
|
undefined2 spawnVariant;
|
|
|
|
puStack_20 = GHIDRA_CAST<undefined1 *>((local_40 + 0xf));
|
|
local_14 = 0xffffffff;
|
|
puStack_18 = &LAB_00af326d;
|
|
local_1c = ExceptionList;
|
|
local_40[7] = __security_cookie ^ GHIDRA_UINT((local_40 + 0xc));
|
|
ExceptionList = &local_1c;
|
|
if (*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(this) + 0x3bc)) == 0) {
|
|
spawnVariant = *GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(this) + 0x410));
|
|
local_4c = g_game;
|
|
if (6 < spawnVariant) {
|
|
spawnVariant = 6;
|
|
}
|
|
room = g_game->_room;
|
|
uVar5 = 0;
|
|
local_40[1] = 1;
|
|
local_40[2] = 5;
|
|
local_40[3] = 5;
|
|
local_40[4] = 10;
|
|
local_40[5] = 10;
|
|
local_40[6] = 0xf;
|
|
iVar3 = room->_gridWidth * room->_gridHeight;
|
|
waveDifficulty = local_40[spawnVariant];
|
|
spawnVariant = 0;
|
|
pitCount = 0;
|
|
if (0 < iVar3) {
|
|
gridEntityCursor = room->_gridEntities;
|
|
do {
|
|
if (((spawnVariant < 0x1c0) && (*gridEntityCursor != (void *)0x0)) &&
|
|
(*GHIDRA_CAST<int *>((GHIDRA_INT(*gridEntityCursor) + 4)) == 7)) {
|
|
uVar5 = uVar5 + 1;
|
|
}
|
|
spawnVariant = spawnVariant + 1;
|
|
gridEntityCursor = gridEntityCursor + 1;
|
|
} while (GHIDRA_INT(spawnVariant) < iVar3);
|
|
pitCount = uVar5;
|
|
}
|
|
spawnVariant = *GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(this) + 0x3dc));
|
|
gideon = this;
|
|
puVar4 = local_40 + 0xf;
|
|
if (spawnVariant == 0) {
|
|
KAGE_LogMessage(0x10,GHIDRA_CAST<byte *>("RNG Seed is zero!\n"));
|
|
spawnVariant = *GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(this) + 0x3dc));
|
|
local_4c = g_game;
|
|
puVar4 = GHIDRA_CAST<uint *>(puStack_20);
|
|
if (spawnVariant == 0) {
|
|
pcVar1 = (code *)swi(3);
|
|
(*pcVar1)();
|
|
return;
|
|
}
|
|
}
|
|
puStack_20 = GHIDRA_CAST<undefined1 *>(puVar4);
|
|
local_4c = g_game;
|
|
spawnVariant = spawnVariant >> ((byte)*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(this) + 0x3e0)) & 0x1f) ^ spawnVariant;
|
|
local_90 = 0x900000005;
|
|
spawnVariant = spawnVariant << ((byte)*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(this) + 0x3e4)) & 0x1f) ^ spawnVariant;
|
|
spawnVariant = spawnVariant >> ((byte)*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(this) + 1000)) & 0x1f) ^ spawnVariant;
|
|
local_5c = 7;
|
|
*GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(this) + 0x3dc)) = spawnVariant;
|
|
puVar4 = GHIDRA_CAST<uint *>(0x0);
|
|
local_50 = GHIDRA_CAST<uint *>(0x0);
|
|
entriesBegin = GHIDRA_CAST<uint *>(0x0);
|
|
entriesEnd = GHIDRA_CAST<uint *>(0x0);
|
|
entriesCapacityEnd = GHIDRA_CAST<uint *>(0x0);
|
|
local_64 = GHIDRA_CAST<uint *>(0x0);
|
|
local_14 = 0;
|
|
local_58 = 0;
|
|
while (local_50 == puVar4) {
|
|
local_84.y = (float)&local_4c->_roomConfig;
|
|
local_60 = 0;
|
|
local_9c.y = (float)(GHIDRA_CAST<Room *>((room)))->Room::GetRoomShape();
|
|
if (local_4c->_challenge == 0x2c) {
|
|
stageType = (GHIDRA_CAST<Level *>((GHIDRA_CAST<Level *>(local_4c))))->Level::GetRoomStageType(local_4c->_currentRoomIdx);
|
|
uVar5 = local_4c->_stage;
|
|
LAB_004b1ace:
|
|
local_4c = GHIDRA_CAST<Game *>(RoomConfig)::GetStageID(uVar5,stageType,-1);
|
|
}
|
|
else {
|
|
if (local_4c->_currentDimensionIdx != 2) {
|
|
stageType = local_4c->_stageType;
|
|
uVar5 = local_4c->_stage;
|
|
goto LAB_004b1ace;
|
|
}
|
|
local_4c = GHIDRA_CAST<Game *>(0x23);
|
|
}
|
|
if (spawnVariant == 0) {
|
|
KAGE_LogMessage(0x10,GHIDRA_CAST<byte *>("RNG Seed is zero!\n"));
|
|
pcVar1 = (code *)swi(3);
|
|
(*pcVar1)();
|
|
return;
|
|
}
|
|
spawnVariant = spawnVariant >> ((byte)local_90 & 0x1f) ^ spawnVariant;
|
|
spawnVariant = spawnVariant << ((byte)((ulonglong)local_90 >> 0x20) & 0x1f) ^ spawnVariant;
|
|
spawnVariant = spawnVariant >> ((byte)local_5c & 0x1f) ^ spawnVariant;
|
|
local_4c = RoomConfig::GetRandomRoomWithFallbackStage
|
|
(GHIDRA_CAST<RoomConfig *>(local_84.y),spawnVariant,1,GHIDRA_INT(local_4c),0,0xb,GHIDRA_INT(local_9c.y),
|
|
in_stack_ffffff38,in_stack_ffffff3c,waveDifficulty,waveDifficulty,
|
|
&local_60,0xc,local_5c);
|
|
if (local_4c == GHIDRA_CAST<Game *>(0x0)) {
|
|
KAGE_LogMessage(0x10,GHIDRA_CAST<byte *>("No enemy wave found for Gideon (difficulty: %d)\n"));
|
|
}
|
|
local_60 = 0;
|
|
if ((short)*GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(local_4c) + 0x44)) != 0) {
|
|
local_50 = GHIDRA_CAST<uint *>(0x0);
|
|
do {
|
|
roomSpawn = GHIDRA_CAST<short *>((*GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(local_4c) + 0x40)) + GHIDRA_INT(local_50)));
|
|
if (spawnVariant == 0) {
|
|
KAGE_LogMessage(0x10,GHIDRA_CAST<byte *>("RNG Seed is zero!\n"));
|
|
pcVar1 = (code *)swi(3);
|
|
(*pcVar1)();
|
|
return;
|
|
}
|
|
spawnVariant = spawnVariant >> ((byte)local_90 & 0x1f) ^ spawnVariant;
|
|
spawnVariant = spawnVariant << ((byte)((ulonglong)local_90 >> 0x20) & 0x1f) ^ spawnVariant;
|
|
spawnVariant = spawnVariant >> ((byte)local_5c & 0x1f) ^ spawnVariant;
|
|
puVar4 = (GHIDRA_CAST<Spawn *>((roomSpawn)))->Spawn::PickEntry((float)((double)GHIDRA_INT(spawnVariant) +
|
|
__uint_to_double_fixup[-(GHIDRA_INT(spawnVariant) >> 0x1f)]) *
|
|
2.3283062e-10);
|
|
spawnEntry = *puVar4;
|
|
uStack_44 = puVar4[1];
|
|
local_40[0] = puVar4[2];
|
|
iVar3 = roomSpawn[1] + 1;
|
|
gridX = *roomSpawn + 1;
|
|
if (((gridX < 0) || (room->_gridWidth <= gridX)) ||
|
|
((iVar3 < 0 || (room->_gridHeight <= iVar3)))) {
|
|
uVar5 = 0xffffffff;
|
|
}
|
|
else {
|
|
uVar5 = room->_gridWidth * iVar3 + gridX;
|
|
}
|
|
if (spawnVariant == 0) {
|
|
KAGE_LogMessage(0x10,GHIDRA_CAST<byte *>("RNG Seed is zero!\n"));
|
|
pcVar1 = (code *)swi(3);
|
|
(*pcVar1)();
|
|
return;
|
|
}
|
|
spawnVariant = spawnVariant >> ((byte)local_90 & 0x1f) ^ spawnVariant;
|
|
spawnVariant = spawnVariant << ((byte)((ulonglong)local_90 >> 0x20) & 0x1f) ^ spawnVariant;
|
|
spawnVariant = spawnVariant >> ((byte)local_5c & 0x1f) ^ spawnVariant;
|
|
(GHIDRA_CAST<Room *>((room)))->Room::TransformEntry(&spawnEntry,uVar5,spawnVariant);
|
|
if (GHIDRA_INT(spawnEntry) < 1000) {
|
|
if ((spawnEntry == 0x339) && (pitCount < 6)) {
|
|
local_50 = entriesBegin;
|
|
entriesEnd = entriesBegin;
|
|
puVar4 = entriesBegin;
|
|
goto LAB_004b1ccf;
|
|
}
|
|
local_40[4] = spawnEntry;
|
|
local_40[5] = uStack_44;
|
|
local_40[6] = local_40[0];
|
|
local_40[3] = uVar5;
|
|
if (entriesEnd == entriesCapacityEnd) {
|
|
std::vector<Vec16>::_Emplace_reallocate(entriesEnd,local_40 + 3);
|
|
entriesCapacityEnd = local_64;
|
|
}
|
|
else {
|
|
*entriesEnd = uVar5;
|
|
entriesEnd[1] = spawnEntry;
|
|
entriesEnd[2] = uStack_44;
|
|
entriesEnd[3] = local_40[0];
|
|
entriesEnd = entriesEnd + 4;
|
|
}
|
|
}
|
|
local_60 = local_60 + 1;
|
|
local_50 = GHIDRA_CAST<uint *>((GHIDRA_INT(local_50) + 0x10));
|
|
} while (local_60 < (ushort)*GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(local_4c) + 0x44)));
|
|
local_50 = entriesBegin;
|
|
puVar4 = entriesEnd;
|
|
}
|
|
LAB_004b1ccf:
|
|
local_58 = local_58 + 1;
|
|
if (9 < local_58) {
|
|
if (local_50 == puVar4) goto LAB_004b1e08;
|
|
break;
|
|
}
|
|
local_4c = g_game;
|
|
}
|
|
local_4c = GHIDRA_CAST<Game *>((local_50 + 1));
|
|
do {
|
|
local_84.x = (float)(GHIDRA_INT(*GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(local_4c) + -4))) % room->_gridWidth) * 40.0 + 40.0;
|
|
local_84.y = (float)(GHIDRA_INT(*GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(local_4c) + -4))) / room->_gridWidth) * 40.0 + 120.0;
|
|
(GHIDRA_CAST<Room *>((room)))->Room::FindFreeTilePosition(&local_9c,&local_84,0.0);
|
|
if (spawnVariant == 0) {
|
|
KAGE_LogMessage(0x10,GHIDRA_CAST<byte *>("RNG Seed is zero!\n"));
|
|
pcVar1 = (code *)swi(3);
|
|
(*pcVar1)();
|
|
return;
|
|
}
|
|
spawnVariant = spawnVariant >> ((byte)local_90 & 0x1f) ^ spawnVariant;
|
|
spawnVariant = spawnVariant << ((byte)((ulonglong)local_90 >> 0x20) & 0x1f) ^ spawnVariant;
|
|
spawnVariant = spawnVariant >> ((byte)local_5c & 0x1f) ^ spawnVariant;
|
|
spawnVariant = (undefined2)*GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(local_4c) + 4));
|
|
iVar3 = spawn_enemy_spawner_effect
|
|
(*GHIDRA_CAST<uint *>(local_4c),spawnVariant,&local_9c,spawnVariant,gideon,
|
|
*GHIDRA_CAST<undefined2 *>((GHIDRA_CAST<char *>(local_4c) + 6)),spawnVariant,spawnVariant,0xffffffff);
|
|
if ((((g_game != GHIDRA_CAST<Game *>(0x0)) && (1 < *GHIDRA_CAST<int *>(&g_game->_deathmatchManager))) &&
|
|
(*GHIDRA_CAST<uint *>(local_4c) == 1)) || (*GHIDRA_CAST<uint *>(local_4c) - 10 < 0x3de)) {
|
|
*GHIDRA_CAST<uint *>((iVar3 + 0x16c)) = *GHIDRA_CAST<uint *>((iVar3 + 0x16c)) | 0x80;
|
|
*GHIDRA_CAST<undefined4 *>((iVar3 + 0x168)) = *GHIDRA_CAST<undefined4 *>((iVar3 + 0x168));
|
|
}
|
|
nextEntry = GHIDRA_CAST<uint *>((GHIDRA_INT(local_4c) + 0x10));
|
|
puVar4 = GHIDRA_CAST<uint *>((GHIDRA_INT(local_4c) + 0xc));
|
|
local_4c = GHIDRA_CAST<Game *>(nextEntry);
|
|
} while (puVar4 != entriesEnd);
|
|
LAB_004b1e08:
|
|
manager = g_manager;
|
|
local_58 = 0x367;
|
|
seed_fart_sound_override(GHIDRA_CAST<int *>(&local_58));
|
|
(GHIDRA_CAST<SoundEffects *>((&manager->_sfxManager)))->SoundEffects::Play(local_58,1.0,2,0,1.0,0.0);
|
|
game = g_game;
|
|
maxHitPoints = *GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(gideon) + 900));
|
|
*GHIDRA_CAST<short *>(&(*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(&((g_game->_hud))) + 0x54b8)))) =
|
|
(short)GHIDRA_INT(((maxHitPoints - *GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(gideon) + 0x380))) + 1.0));
|
|
*GHIDRA_CAST<short *>(&(*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(&((game->_hud))) + 0x54ba)))) = (short)GHIDRA_INT(maxHitPoints);
|
|
if (local_50 != GHIDRA_CAST<uint *>(0x0)) {
|
|
spawnVariant = GHIDRA_INT(entriesCapacityEnd) - GHIDRA_INT(local_50) & 0xfffffff0;
|
|
puVar4 = local_50;
|
|
if (0xfff < spawnVariant) {
|
|
puVar4 = GHIDRA_CAST<uint *>(local_50[-1]);
|
|
spawnVariant = spawnVariant + 0x23;
|
|
if (0x1f < GHIDRA_UINT((GHIDRA_INT(local_50) + (-4 - GHIDRA_INT(puVar4))))) {
|
|
/* WARNING: Subroutine does not return */
|
|
_invalid_parameter_noinfo_noreturn();
|
|
}
|
|
}
|
|
operator_delete(puVar4,spawnVariant);
|
|
}
|
|
}
|
|
ExceptionList = local_1c;
|
|
return;
|
|
}
|
|
|
|
// 004b3610
|
|
void NpcHelper::gideon_update_death(Entity_NPC *npc)
|
|
{
|
|
float fVar1;
|
|
float fVar2;
|
|
byte bVar3;
|
|
ColorMod *color;
|
|
Entity *explosion;
|
|
ColorMod *color_00;
|
|
Color *pCVar4;
|
|
int *gridSlot;
|
|
uint uVar5;
|
|
int gridSize;
|
|
int unusedInt;
|
|
undefined1 auStack_4c [7];
|
|
byte isDeathAnim;
|
|
int soundId;
|
|
float eventPitch;
|
|
float pitch;
|
|
Color local_38;
|
|
uint local_c;
|
|
Game *game;
|
|
int gridEntity;
|
|
Manager *manager;
|
|
void *room;
|
|
|
|
local_c = __security_cookie ^ GHIDRA_UINT(auStack_4c);
|
|
room = (npc->_sprite)._animState._animData;
|
|
if (room == (void *)0x0) {
|
|
local_38._tint[0] = 0.0;
|
|
local_38._colorize[1] = 2.10195e-44;
|
|
local_38._colorize[0] = 0.0;
|
|
}
|
|
else {
|
|
(GHIDRA_CAST<std::string *>((GHIDRA_CAST<char *>(&local_38))))->std::string::string(room);
|
|
}
|
|
fVar2 = local_38._colorize[1];
|
|
fVar1 = local_38._tint[0];
|
|
pCVar4 = &local_38;
|
|
if (0xf < GHIDRA_UINT(local_38._colorize[1])) {
|
|
pCVar4 = GHIDRA_CAST<Color *>(local_38._tint[0]);
|
|
}
|
|
isDeathAnim = str_eq(GHIDRA_CAST<byte *>(pCVar4),GHIDRA_UINT(local_38._colorize[0]),GHIDRA_CAST<byte *>("Death"),5);
|
|
if (0xf < GHIDRA_UINT(fVar2)) {
|
|
uVar5 = GHIDRA_INT(fVar2) + 1;
|
|
pCVar4 = GHIDRA_CAST<Color *>(fVar1);
|
|
if (0xfff < uVar5) {
|
|
pCVar4 = GHIDRA_CAST<Color *>((GHIDRA_CAST<Color *>((GHIDRA_INT(fVar1) + -0x2c)))->_offset[2]);
|
|
uVar5 = GHIDRA_INT(fVar2) + 0x24;
|
|
if (GHIDRA_CAST<byte *>(0x1f) < GHIDRA_CAST<byte *>((GHIDRA_INT(fVar1) + (-4 - GHIDRA_INT(pCVar4))))) {
|
|
/* WARNING: Subroutine does not return */
|
|
_invalid_parameter_noinfo_noreturn();
|
|
}
|
|
}
|
|
operator_delete(pCVar4,uVar5);
|
|
}
|
|
if (isDeathAnim == 0) {
|
|
return;
|
|
}
|
|
pitch = 1.0;
|
|
if ((npc->_sprite)._animState._animData != (void *)0x0) {
|
|
bVar3 = (GHIDRA_CAST<AnimationState *>((&(npc->_sprite)._animState)))->AnimationState::IsEventTriggered(GHIDRA_CAST<byte *>("Sound"));
|
|
manager = g_manager;
|
|
if (bVar3 != 0) {
|
|
eventPitch = 1.0;
|
|
if (npc->_championColorIdx == 0x12) {
|
|
eventPitch = 1.5;
|
|
}
|
|
else if (npc->_championColorIdx == 0x13) {
|
|
eventPitch = 0.5;
|
|
}
|
|
soundId = 0x89;
|
|
seed_fart_sound_override(&soundId);
|
|
(GHIDRA_CAST<SoundEffects *>((&manager->_sfxManager)))->SoundEffects::Play(soundId,1.0,2,0,eventPitch,0.0);
|
|
(GHIDRA_CAST<Color *>((&local_38)))->Color::Color();
|
|
Random();
|
|
Game::SpawnParticles(g_game,&npc->_pos,4,4,5.0,color,100000.0,7);
|
|
}
|
|
if (((npc->_sprite)._animState._animData != (void *)0x0) &&
|
|
((npc->_sprite)._animState._isPlaying != 0)) {
|
|
return;
|
|
}
|
|
}
|
|
uVar5 = Random();
|
|
explosion = (GHIDRA_CAST<Game *>((g_game)))->Game::SpawnEx(1000,1,&npc->_pos,&g_vectorZero,GHIDRA_CAST<Entity *>(0x0),0,uVar5,0);
|
|
game = g_game;
|
|
(explosion->_sprite)._scale.x = 2.0;
|
|
(explosion->_sprite)._scale.y = 2.0;
|
|
(GHIDRA_CAST<Game *>((game)))->Game::ShakeScreen(0xe);
|
|
manager = g_manager;
|
|
if (npc->_championColorIdx == 0x12) {
|
|
pitch = 1.5;
|
|
}
|
|
else if (npc->_championColorIdx == 0x13) {
|
|
pitch = 0.5;
|
|
}
|
|
soundId = 0x89;
|
|
seed_fart_sound_override(&soundId);
|
|
(GHIDRA_CAST<SoundEffects *>((&manager->_sfxManager)))->SoundEffects::Play(soundId,1.0,2,0,pitch,0.0);
|
|
(GHIDRA_CAST<Color *>((&local_38)))->Color::Color();
|
|
uVar5 = Random();
|
|
bVar3 = 7;
|
|
unusedInt = 0x47c35000;
|
|
Game::SpawnParticles(g_game,&npc->_pos,4,uVar5 % 3 + 0xc,9.0,color_00,100000.0,7);
|
|
if (npc->_deliriumBossType == 0) {
|
|
uVar5 = 0;
|
|
room = g_game->_room;
|
|
gridSize = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(room) + 0x10)) * *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(room) + 0xc));
|
|
if (0 < gridSize) {
|
|
gridSlot = GHIDRA_CAST<int *>((GHIDRA_INT(room) + 0x24));
|
|
do {
|
|
if ((((uVar5 < 0x1c0) && (gridEntity = *gridSlot, gridEntity != 0)) &&
|
|
(*GHIDRA_CAST<int *>((gridEntity + 4)) == 0x12)) && (*GHIDRA_CAST<int *>((gridEntity + 8)) == 1)) {
|
|
return;
|
|
}
|
|
uVar5 = uVar5 + 1;
|
|
gridSlot = gridSlot + 1;
|
|
} while (GHIDRA_INT(uVar5) < gridSize);
|
|
}
|
|
uVar5 = npc->_projectileDelay;
|
|
if ((-1 < GHIDRA_INT(uVar5)) && (uVar5 < 0x1c0)) {
|
|
*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(room) + uVar5 * 4 + 0x76c)) = 900;
|
|
}
|
|
(GHIDRA_CAST<Music *>((GHIDRA_CAST<Music *>(&g_manager->_musicManager))))->Music::PlayJingle(0x55,unusedInt,bVar3);
|
|
gideon_spawn_stairs(npc);
|
|
}
|
|
return;
|
|
}
|
|
|
|
// 004b3af0
|
|
Entity * NpcHelper::heretic_spawn_afterimage(Entity_NPC *npc)
|
|
{
|
|
byte bVar1;
|
|
Entity *afterimage;
|
|
byte *afterimageAnimChar;
|
|
uint uVar2;
|
|
LayerState *afterimageLayer;
|
|
LayerState *npcLayer;
|
|
byte *****animNameData;
|
|
byte *****animNameChar;
|
|
bool isLess;
|
|
undefined4 local_38;
|
|
byte *****animName [4];
|
|
undefined4 animNameSize;
|
|
uint animNameCapacity;
|
|
uint securityCookie;
|
|
void *local_10;
|
|
undefined1 *puStack_c;
|
|
byte ****local_8;
|
|
undefined4 flagsHi;
|
|
void *npcAnimData;
|
|
|
|
local_8 = GHIDRA_CAST<byte ****>(0xffffffff);
|
|
puStack_c = &LAB_00af32ed;
|
|
local_10 = ExceptionList;
|
|
securityCookie = __security_cookie ^ GHIDRA_UINT((animName + 10));
|
|
ExceptionList = &local_10;
|
|
afterimage = (GHIDRA_CAST<Game *>((g_game)))->Game::Spawn(0x389,0,&npc->_pos,&npc->_velocity,GHIDRA_CAST<Entity *>(npc),
|
|
(npc->_state == 0xb) + 1,npc->_initSeed);
|
|
flagsHi = *GHIDRA_CAST<undefined4 *>((GHIDRA_INT(&npc->_flags) + 4));
|
|
*GHIDRA_CAST<int *>(&afterimage->_flags) = GHIDRA_INT(npc->_flags);
|
|
*GHIDRA_CAST<undefined4 *>((GHIDRA_INT(&afterimage->_flags) + 4)) = flagsHi;
|
|
FUN_004b6b20((afterimage->_colorParams)._begin,(npc->_colorParams)._begin,(npc->_colorParams)._end
|
|
,local_38);
|
|
flagsHi = *GHIDRA_CAST<undefined4 *>((GHIDRA_INT(&afterimage->_flags) + 4));
|
|
*GHIDRA_CAST<uint *>(&afterimage->_flags) = GHIDRA_UINT(afterimage->_flags) | 0x11;
|
|
afterimage->_isInvicible = 1;
|
|
*GHIDRA_CAST<undefined4 *>((GHIDRA_INT(&afterimage->_flags) + 4)) = flagsHi;
|
|
npcAnimData = (npc->_sprite)._animState._animData;
|
|
if (npcAnimData == (void *)0x0) {
|
|
animNameCapacity = 0xf;
|
|
animNameSize = 0;
|
|
animName[0] = GHIDRA_CAST<byte *****>(0x0);
|
|
}
|
|
else {
|
|
(GHIDRA_CAST<std::string *>((GHIDRA_CAST<char *>(animName))))->std::string::string(npcAnimData);
|
|
}
|
|
local_8 = GHIDRA_CAST<byte ****>(0x0);
|
|
animNameData = GHIDRA_CAST<byte *****>(animName);
|
|
if (0xf < animNameCapacity) {
|
|
animNameData = animName[0];
|
|
}
|
|
afterimageAnimChar = (afterimage->_sprite)._animState._animData;
|
|
if (afterimageAnimChar != GHIDRA_CAST<byte *>(0x0)) {
|
|
if (0xf < *GHIDRA_CAST<uint *>((afterimageAnimChar + 0x14))) {
|
|
afterimageAnimChar = *GHIDRA_CAST<byte **>(afterimageAnimChar);
|
|
}
|
|
animNameChar = animNameData;
|
|
do {
|
|
bVar1 = *afterimageAnimChar;
|
|
isLess = bVar1 < *GHIDRA_CAST<byte *>(animNameChar);
|
|
if (bVar1 != *GHIDRA_CAST<byte *>(animNameChar)) {
|
|
LAB_004b3c27:
|
|
uVar2 = -GHIDRA_UINT(isLess) | 1;
|
|
goto LAB_004b3c2c;
|
|
}
|
|
if (bVar1 == 0) break;
|
|
bVar1 = afterimageAnimChar[1];
|
|
isLess = bVar1 < *GHIDRA_CAST<byte *>((GHIDRA_CAST<char *>(animNameChar) + 1));
|
|
if (bVar1 != *GHIDRA_CAST<byte *>((GHIDRA_CAST<char *>(animNameChar) + 1))) goto LAB_004b3c27;
|
|
afterimageAnimChar = afterimageAnimChar + 2;
|
|
animNameChar = GHIDRA_CAST<byte *****>((GHIDRA_INT(animNameChar) + 2));
|
|
} while (bVar1 != 0);
|
|
uVar2 = 0;
|
|
LAB_004b3c2c:
|
|
if ((uVar2 == 0) &&
|
|
((*GHIDRA_CAST<char *>((GHIDRA_INT((afterimage->_sprite)._animState._animData) + 0x34)) == '\0' ||
|
|
((afterimage->_sprite)._animState._isPlaying != 0)))) goto LAB_004b3c68;
|
|
}
|
|
bVar1 = (GHIDRA_CAST<ANM2 *>((&afterimage->_sprite)))->ANM2::SetAnimation(GHIDRA_CAST<byte *>(animNameData),1);
|
|
if (bVar1 != 0) {
|
|
(GHIDRA_CAST<AnimationState *>((&(afterimage->_sprite)._animState)))->AnimationState::Rewind();
|
|
(afterimage->_sprite)._animState._isPlaying = 1;
|
|
}
|
|
LAB_004b3c68:
|
|
local_8 = GHIDRA_CAST<byte ****>(0xffffffff);
|
|
if (0xf < animNameCapacity) {
|
|
uVar2 = animNameCapacity + 1;
|
|
animNameData = animName[0];
|
|
if (0xfff < uVar2) {
|
|
animNameData = GHIDRA_CAST<byte *****>(animName[0][-1]);
|
|
uVar2 = animNameCapacity + 0x24;
|
|
if (GHIDRA_CAST<byte *>(0x1f) < GHIDRA_CAST<byte *>((GHIDRA_INT(animName[0]) + (-4 - GHIDRA_INT(animNameData))))) {
|
|
/* WARNING: Subroutine does not return */
|
|
_invalid_parameter_noinfo_noreturn();
|
|
}
|
|
}
|
|
operator_delete(animNameData,uVar2);
|
|
}
|
|
animNameSize = 0;
|
|
animNameCapacity = 0xf;
|
|
animName[0] = GHIDRA_CAST<byte *****>((GHIDRA_UINT(animName[0]) & 0xffffff00));
|
|
if ((afterimage->_sprite)._animState._animData != (void *)0x0) {
|
|
AnimationState::SetFrameFloat
|
|
(&(afterimage->_sprite)._animState,(npc->_sprite)._animState._animFrame);
|
|
}
|
|
afterimageLayer = (GHIDRA_CAST<ANM2 *>((&afterimage->_sprite)))->ANM2::GetLayer(GHIDRA_CAST<byte *>(0x0));
|
|
npcLayer = (GHIDRA_CAST<ANM2 *>((&npc->_sprite)))->ANM2::GetLayer(GHIDRA_CAST<byte *>(0x0));
|
|
(afterimageLayer->_color)._tint[3] = (npcLayer->_color)._tint[3];
|
|
afterimage->_entityGridCollisionClass = 0;
|
|
afterimage->_entityCollisionClass = 0;
|
|
afterimage[2]._preInterpolatePos.x = 1.82169e-44;
|
|
*GHIDRA_CAST<undefined1 *>((GHIDRA_INT(&afterimage[2]._health) + 2)) =
|
|
*GHIDRA_CAST<undefined1 *>((GHIDRA_INT(&npc->_projectileCooldown) + 2));
|
|
*GHIDRA_CAST<undefined2 *>((afterimage + 1)) = 0;
|
|
afterimage->_health = 0.0;
|
|
afterimage->_maxHitPoints = 0.0;
|
|
afterimage->Update();
|
|
ExceptionList = local_10;
|
|
return afterimage;
|
|
}
|
|
|
|
// 004b3ec0
|
|
int NpcHelper::heretic_count_out_fires()
|
|
{
|
|
int *entityIt;
|
|
int outFireCount;
|
|
int remaining;
|
|
int entity;
|
|
|
|
outFireCount = 0;
|
|
remaining = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(g_game->_room) + 0x1264));
|
|
if (remaining != 0) {
|
|
entityIt = *GHIDRA_CAST<int **>((GHIDRA_CAST<char *>(g_game->_room) + 0x125c));
|
|
do {
|
|
entity = *entityIt;
|
|
if (((*GHIDRA_CAST<int *>((entity + 0x28)) == 0x21) && (*GHIDRA_CAST<int *>((entity + 0x2c)) == 3)) &&
|
|
(*GHIDRA_CAST<float *>((entity + 0x380)) <= 1.5 && *GHIDRA_CAST<float *>((entity + 0x380)) != 1.5)) {
|
|
outFireCount = outFireCount + 1;
|
|
}
|
|
entityIt = entityIt + 1;
|
|
remaining = remaining + -1;
|
|
} while (remaining != 0);
|
|
}
|
|
return outFireCount;
|
|
}
|
|
|
|
// 004b40d0
|
|
void NpcHelper::heretic_choose_attack(Entity_NPC *npc)
|
|
{
|
|
RNG rng;
|
|
Entity_NPC *pEVar1;
|
|
uint uVar2;
|
|
uint outcomeCount;
|
|
WeightedOutcomePicker WVar3;
|
|
undefined4 *outcomesCursor;
|
|
float halfHealth;
|
|
undefined8 uStack_44;
|
|
undefined4 uStack_3c;
|
|
EntityPtr *local_38;
|
|
Entity_NPC *npcLocal;
|
|
WeightedOutcomePicker outcomes;
|
|
undefined4 *outcomesEnd;
|
|
undefined4 *outcomesCapacityEnd;
|
|
uint local_24;
|
|
undefined1 *puStack_20;
|
|
void *local_1c;
|
|
undefined1 *puStack_18;
|
|
undefined4 local_14;
|
|
int *weight;
|
|
|
|
puStack_20 = GHIDRA_CAST<undefined1 *>((GHIDRA_INT(register0x00000010) + -4));
|
|
puStack_18 = &LAB_00af332d;
|
|
local_1c = ExceptionList;
|
|
local_24 = __security_cookie ^ GHIDRA_INT(register0x00000010) - 0x10U;
|
|
ExceptionList = &local_1c;
|
|
outcomes = (WeightedOutcomePicker)0x0;
|
|
outcomesEnd = GHIDRA_CAST<undefined4 *>(0x0);
|
|
outcomesCapacityEnd = GHIDRA_CAST<undefined4 *>(0x0);
|
|
local_14 = 0;
|
|
npcLocal = npc;
|
|
local_38 = GHIDRA_CAST<EntityPtr *>(heretic_count_out_fires());
|
|
WVar3 = (WeightedOutcomePicker)0x0;
|
|
outcomesCursor = GHIDRA_CAST<undefined4 *>(0x0);
|
|
if (*GHIDRA_CAST<char *>((GHIDRA_INT(&npcLocal->_projectileDelay) + 1)) < '\x01') {
|
|
uStack_44 = CONCAT44(0xe,(undefined4)uStack_44);
|
|
uStack_3c = 10;
|
|
std::vector<8byte>::_Emplace_reallocate(0,GHIDRA_INT(&uStack_44) + 4);
|
|
WVar3 = outcomes;
|
|
outcomesCursor = outcomesEnd;
|
|
}
|
|
if (*GHIDRA_CAST<char *>((GHIDRA_INT(&npcLocal->_projectileDelay) + 2)) < '\x01') {
|
|
uVar2 = 0;
|
|
outcomeCount = GHIDRA_INT(outcomesCursor) - GHIDRA_INT(WVar3) >> 3;
|
|
if (outcomeCount != 0) {
|
|
do {
|
|
if (*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(WVar3) + uVar2 * 8)) == 9) {
|
|
weight = GHIDRA_CAST<int *>((GHIDRA_INT(WVar3) + 4 + uVar2 * 8));
|
|
*weight = *weight + 10;
|
|
if (*weight < 0) {
|
|
*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(WVar3) + 4 + uVar2 * 8)) = 0;
|
|
}
|
|
goto LAB_004b41d2;
|
|
}
|
|
uVar2 = uVar2 + 1;
|
|
} while (uVar2 < outcomeCount);
|
|
}
|
|
uStack_44 = CONCAT44(9,(undefined4)uStack_44);
|
|
uStack_3c = 10;
|
|
if (outcomesCursor == outcomesCapacityEnd) {
|
|
std::vector<8byte>::_Emplace_reallocate(outcomesCursor,GHIDRA_INT(&uStack_44) + 4);
|
|
WVar3 = outcomes;
|
|
outcomesCursor = outcomesEnd;
|
|
}
|
|
else {
|
|
*outcomesCursor = 9;
|
|
outcomesCursor[1] = 10;
|
|
outcomesCursor = outcomesCursor + 2;
|
|
outcomesEnd = outcomesCursor;
|
|
}
|
|
}
|
|
LAB_004b41d2:
|
|
if (*GHIDRA_CAST<char *>((GHIDRA_INT(&npcLocal->_projectileDelay) + 3)) < '\x01') {
|
|
if (GHIDRA_CAST<EntityPtr *>(0x2) < local_38) {
|
|
uVar2 = 0;
|
|
outcomeCount = GHIDRA_INT(outcomesCursor) - GHIDRA_INT(WVar3) >> 3;
|
|
if (outcomeCount != 0) {
|
|
do {
|
|
if (*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(WVar3) + uVar2 * 8)) == 7) {
|
|
weight = GHIDRA_CAST<int *>((GHIDRA_INT(WVar3) + 4 + uVar2 * 8));
|
|
*weight = *weight + 10;
|
|
if (*weight < 0) {
|
|
*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(WVar3) + 4 + uVar2 * 8)) = 0;
|
|
}
|
|
goto LAB_004b4249;
|
|
}
|
|
uVar2 = uVar2 + 1;
|
|
} while (uVar2 < outcomeCount);
|
|
}
|
|
uStack_44 = CONCAT44(7,(undefined4)uStack_44);
|
|
uStack_3c = 10;
|
|
if (outcomesCursor == outcomesCapacityEnd) {
|
|
std::vector<8byte>::_Emplace_reallocate(outcomesCursor,GHIDRA_INT(&uStack_44) + 4);
|
|
WVar3 = outcomes;
|
|
outcomesCursor = outcomesEnd;
|
|
}
|
|
else {
|
|
*outcomesCursor = 7;
|
|
outcomesCursor[1] = 10;
|
|
outcomesEnd = outcomesCursor + 2;
|
|
outcomesCursor = outcomesEnd;
|
|
}
|
|
}
|
|
}
|
|
LAB_004b4249:
|
|
uVar2 = 0;
|
|
outcomeCount = GHIDRA_INT(outcomesCursor) - GHIDRA_INT(WVar3) >> 3;
|
|
if (outcomeCount != 0) {
|
|
do {
|
|
if (*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(WVar3) + uVar2 * 8)) == 3) {
|
|
weight = GHIDRA_CAST<int *>((GHIDRA_INT(WVar3) + 4 + uVar2 * 8));
|
|
*weight = *weight + 1;
|
|
if (*weight < 0) {
|
|
*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(WVar3) + 4 + uVar2 * 8)) = 0;
|
|
}
|
|
goto LAB_004b42a6;
|
|
}
|
|
uVar2 = uVar2 + 1;
|
|
} while (uVar2 < outcomeCount);
|
|
}
|
|
uStack_44 = CONCAT44(3,(undefined4)uStack_44);
|
|
uStack_3c = 1;
|
|
if (outcomesCursor == outcomesCapacityEnd) {
|
|
std::vector<8byte>::_Emplace_reallocate(outcomesCursor,GHIDRA_INT(&uStack_44) + 4);
|
|
}
|
|
else {
|
|
*outcomesCursor = 3;
|
|
outcomesCursor[1] = 1;
|
|
outcomesEnd = outcomesCursor + 2;
|
|
}
|
|
LAB_004b42a6:
|
|
uVar2 = Random();
|
|
uStack_44 = 0x900000005;
|
|
uStack_3c = 7;
|
|
rng._shift1 = 5;
|
|
rng._seed = uVar2 | 1;
|
|
rng._shift2 = 9;
|
|
rng._shift3 = 7;
|
|
uVar2 = (GHIDRA_CAST<WeightedOutcomePicker *>((&outcomes)))->WeightedOutcomePicker::PickOutcome(rng);
|
|
pEVar1 = npcLocal;
|
|
if (uVar2 == 3) {
|
|
*GHIDRA_CAST<undefined2 *>((GHIDRA_INT(&npcLocal->_stateFrame) + 2)) = 0;
|
|
}
|
|
else {
|
|
*GHIDRA_CAST<undefined2 *>(&npcLocal->_stateFrame) = 0xffff;
|
|
npcLocal->_state = uVar2;
|
|
if (uVar2 == 7) {
|
|
(GHIDRA_CAST<Entity_NPC *>((npcLocal)))->Entity_NPC::ClearDequeRefs();
|
|
if (pEVar1->_child != (EntityPtr)0x0) {
|
|
local_38 = &pEVar1->_child;
|
|
std::multiset<unsigned_int>::erase(&local_38);
|
|
}
|
|
halfHealth = pEVar1->_maxHitPoints * 0.5;
|
|
pEVar1->_child = (EntityPtr)0x0;
|
|
*GHIDRA_CAST<char *>(&pEVar1->_projectileCooldown) =
|
|
(pEVar1->_health <= halfHealth && halfHealth != pEVar1->_health) + '\x05';
|
|
}
|
|
*GHIDRA_CAST<undefined1 *>((GHIDRA_INT(&pEVar1->_projectileCooldown) + 1)) = 0;
|
|
}
|
|
if (outcomes != (WeightedOutcomePicker)0x0) {
|
|
uVar2 = GHIDRA_INT(outcomesCapacityEnd) - GHIDRA_INT(outcomes) & 0xfffffff8;
|
|
WVar3 = outcomes;
|
|
if (0xfff < uVar2) {
|
|
WVar3 = *GHIDRA_CAST<WeightedOutcomePicker *>((GHIDRA_CAST<char *>(outcomes) + -4));
|
|
uVar2 = uVar2 + 0x23;
|
|
if (0x1f < (GHIDRA_INT(outcomes) - GHIDRA_INT(WVar3)) - 4U) {
|
|
/* WARNING: Subroutine does not return */
|
|
_invalid_parameter_noinfo_noreturn();
|
|
}
|
|
}
|
|
operator_delete((void *)WVar3,uVar2);
|
|
}
|
|
ExceptionList = local_1c;
|
|
return;
|
|
}
|
|
|
|
// 004b70c0
|
|
void NpcHelper::hornfel_spawn_doors()
|
|
{
|
|
byte isCanStep;
|
|
uint uVar1;
|
|
int iVar2;
|
|
int fromIndex;
|
|
uint seed;
|
|
EntityPtr EVar3;
|
|
EntityPtr *fromIndex_00;
|
|
uint startIndex;
|
|
undefined1 *toIndex;
|
|
EntityPtr toIndex_00;
|
|
EntityPtr *toIndex_01;
|
|
Room *room;
|
|
int iVar4;
|
|
EntityPtr EVar5;
|
|
EntityPtr *pEVar6;
|
|
float fVar7;
|
|
float fVar8;
|
|
EntityPtr *doors;
|
|
EntityPtr *doorsEnd;
|
|
Vector spawnPos;
|
|
Vector leftSpawnPos;
|
|
EntityPtr local_2c;
|
|
EntityPtr local_28;
|
|
EntityPtr local_24;
|
|
EntityPtr local_20;
|
|
EntityPtr local_1c;
|
|
EntityPtr local_18;
|
|
EntityPtr *doorsCapacity;
|
|
void *local_10;
|
|
undefined1 *puStack_c;
|
|
undefined4 local_8;
|
|
|
|
puStack_c = &LAB_00af336d;
|
|
local_10 = ExceptionList;
|
|
uVar1 = __security_cookie ^ GHIDRA_INT(register0x00000010) - 4U;
|
|
ExceptionList = &local_10;
|
|
doors = GHIDRA_CAST<EntityPtr *>(0x0);
|
|
doorsEnd = GHIDRA_CAST<EntityPtr *>(0x0);
|
|
doorsCapacity = GHIDRA_CAST<EntityPtr *>(0x0);
|
|
room = g_game->_room;
|
|
local_20 = *GHIDRA_CAST<EntityPtr *>((GHIDRA_CAST<char *>(room) + 0xc));
|
|
local_1c = *GHIDRA_CAST<EntityPtr *>((GHIDRA_CAST<char *>(room) + 0x10));
|
|
local_8 = 0;
|
|
iVar4 = 1;
|
|
local_2c = (EntityPtr)room;
|
|
if (1 < GHIDRA_INT(local_1c) + -1) {
|
|
local_28 = (EntityPtr)(GHIDRA_INT(local_20) + -2);
|
|
do {
|
|
fVar8 = 120.0;
|
|
fVar7 = 40.0;
|
|
EVar5 = *GHIDRA_CAST<EntityPtr *>((GHIDRA_CAST<char *>(room) + 0xc));
|
|
if ((GHIDRA_INT(EVar5) < 1) || (GHIDRA_INT(*GHIDRA_CAST<EntityPtr *>((GHIDRA_CAST<char *>(room) + 0x10))) <= iVar4)) {
|
|
iVar2 = -1;
|
|
}
|
|
else {
|
|
iVar2 = GHIDRA_INT(EVar5) * iVar4;
|
|
}
|
|
local_18 = (EntityPtr)(GHIDRA_INT(EVar5) * iVar4);
|
|
if ((GHIDRA_INT(EVar5) < 2) || (GHIDRA_INT(*GHIDRA_CAST<EntityPtr *>((GHIDRA_CAST<char *>(room) + 0x10))) <= iVar4)) {
|
|
fromIndex = -1;
|
|
}
|
|
else {
|
|
fromIndex = GHIDRA_INT(local_18) + 1;
|
|
}
|
|
isCanStep = (GHIDRA_CAST<RoomGridPath *>((GHIDRA_CAST<EntityPtr *>((GHIDRA_INT(room) + 0x7468)))))->RoomGridPath::can_step(fromIndex,iVar2);
|
|
if (isCanStep != 0) {
|
|
if ((GHIDRA_INT(*GHIDRA_CAST<EntityPtr *>((GHIDRA_CAST<char *>(room) + 0xc))) < 1) ||
|
|
(GHIDRA_INT(*GHIDRA_CAST<EntityPtr *>((GHIDRA_CAST<char *>(room) + 0x10))) <= iVar4)) {
|
|
local_18 = (EntityPtr)0xffffffff;
|
|
}
|
|
iVar2 = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(g_game->_room) + 0xc));
|
|
leftSpawnPos.x = (float)(GHIDRA_INT(local_18) % iVar2) * fVar7 + fVar7;
|
|
leftSpawnPos.y = (float)(GHIDRA_INT(local_18) / iVar2) * fVar7 + fVar8;
|
|
seed = Random();
|
|
local_24 = (EntityPtr)
|
|
(GHIDRA_CAST<Game *>((g_game)))->Game::Spawn(0x3c7,0,&leftSpawnPos,&g_vectorZero,GHIDRA_CAST<Entity *>(0x0),0,seed);
|
|
*GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(local_24) + 0xec)) = -90.0;
|
|
local_18 = (EntityPtr)cos(-1.5707964);
|
|
fVar7 = sin(-1.5707964);
|
|
(GHIDRA_CAST<Vector *>((GHIDRA_INT(local_24) + 0xdc)))->x = (float)local_18 * 0.0 - fVar7 * 15.0;
|
|
*GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(local_24) + 0xe0)) = fVar7 * 0.0 + (float)local_18 * 15.0;
|
|
if (doorsEnd == doorsCapacity) {
|
|
std::vector<unsigned_int>::_Emplace_reallocate(doorsEnd,&local_24);
|
|
doorsCapacity = GHIDRA_CAST<EntityPtr *>(0x0);
|
|
}
|
|
else {
|
|
*doorsEnd = local_24;
|
|
doorsEnd = doorsEnd + 1;
|
|
}
|
|
fVar8 = 120.0;
|
|
fVar7 = 40.0;
|
|
}
|
|
if (((GHIDRA_INT(local_20) + -1 < 0) ||
|
|
(GHIDRA_INT(*GHIDRA_CAST<EntityPtr *>((GHIDRA_CAST<char *>(room) + 0xc))) <= GHIDRA_INT((GHIDRA_INT(local_20) + -1)))) ||
|
|
(GHIDRA_INT(*GHIDRA_CAST<EntityPtr *>((GHIDRA_CAST<char *>(room) + 0x10))) <= iVar4)) {
|
|
toIndex = GHIDRA_CAST<undefined1 *>(0xffffffff);
|
|
}
|
|
else {
|
|
toIndex = GHIDRA_CAST<undefined1 *>((GHIDRA_INT(local_20) + -1)) + GHIDRA_INT(*GHIDRA_CAST<EntityPtr *>((GHIDRA_CAST<char *>(room) + 0xc))) * iVar4;
|
|
}
|
|
if (((GHIDRA_INT((GHIDRA_INT(local_20) + -2)) < 0) ||
|
|
(GHIDRA_INT(*GHIDRA_CAST<EntityPtr *>((GHIDRA_CAST<char *>(room) + 0xc))) <= GHIDRA_INT(local_28))) ||
|
|
(GHIDRA_INT(*GHIDRA_CAST<EntityPtr *>((GHIDRA_CAST<char *>(room) + 0x10))) <= iVar4)) {
|
|
iVar2 = -1;
|
|
}
|
|
else {
|
|
iVar2 = GHIDRA_INT(*GHIDRA_CAST<EntityPtr *>((GHIDRA_CAST<char *>(room) + 0xc))) * iVar4 + -2 + GHIDRA_INT(local_20);
|
|
}
|
|
isCanStep = (GHIDRA_CAST<RoomGridPath *>((GHIDRA_CAST<EntityPtr *>((GHIDRA_INT(room) + 0x7468)))))->RoomGridPath::can_step(iVar2,GHIDRA_INT(toIndex));
|
|
if (isCanStep != 0) {
|
|
if (((GHIDRA_INT(local_20) + -1 < 0) ||
|
|
(GHIDRA_INT(*GHIDRA_CAST<EntityPtr *>((GHIDRA_CAST<char *>(room) + 0xc))) <= GHIDRA_INT((GHIDRA_INT(local_20) + -1)))) ||
|
|
(GHIDRA_INT(*GHIDRA_CAST<EntityPtr *>((GHIDRA_CAST<char *>(room) + 0x10))) <= iVar4)) {
|
|
local_18 = (EntityPtr)0xffffffff;
|
|
}
|
|
else {
|
|
local_18 = (EntityPtr)
|
|
(GHIDRA_CAST<undefined1 *>((GHIDRA_INT(local_20) + -1)) +
|
|
GHIDRA_INT(*GHIDRA_CAST<EntityPtr *>((GHIDRA_CAST<char *>(room) + 0xc))) * iVar4);
|
|
}
|
|
iVar2 = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(g_game->_room) + 0xc));
|
|
spawnPos.x = (float)(GHIDRA_INT(local_18) % iVar2) * fVar7 + fVar7;
|
|
spawnPos.y = (float)(GHIDRA_INT(local_18) / iVar2) * fVar7 + fVar8;
|
|
seed = Random();
|
|
local_18 = (EntityPtr)
|
|
(GHIDRA_CAST<Game *>((g_game)))->Game::Spawn(0x3c7,0,&spawnPos,&g_vectorZero,GHIDRA_CAST<Entity *>(0x0),0,seed);
|
|
*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(local_18) + 0xec)) = 0x42b40000;
|
|
local_24 = (EntityPtr)cos(1.5707964);
|
|
fVar7 = sin(1.5707964);
|
|
EVar5 = local_24;
|
|
local_24 = local_18;
|
|
*GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(local_18) + 0xdc)) = (float)EVar5 * 0.0 - fVar7 * 15.0;
|
|
*GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(local_18) + 0xe0)) = fVar7 * 0.0 + (float)EVar5 * 15.0;
|
|
if (doorsEnd == doorsCapacity) {
|
|
std::vector<unsigned_int>::_Emplace_reallocate(doorsEnd,&local_24);
|
|
doorsCapacity = GHIDRA_CAST<EntityPtr *>(0x0);
|
|
}
|
|
else {
|
|
*doorsEnd = local_18;
|
|
doorsEnd = doorsEnd + 1;
|
|
}
|
|
}
|
|
iVar4 = iVar4 + 1;
|
|
} while (iVar4 < GHIDRA_INT(local_1c) + -1);
|
|
}
|
|
local_18 = (EntityPtr)(GHIDRA_INT(local_20) + -1);
|
|
EVar5 = (EntityPtr)0x1;
|
|
if (1 < GHIDRA_INT(local_18)) {
|
|
do {
|
|
fVar8 = 120.0;
|
|
fVar7 = 40.0;
|
|
if ((GHIDRA_INT(EVar5) < GHIDRA_INT(*GHIDRA_CAST<EntityPtr *>((GHIDRA_CAST<char *>(room) + 0xc)))) &&
|
|
(0 < GHIDRA_INT(*GHIDRA_CAST<EntityPtr *>((GHIDRA_CAST<char *>(room) + 0x10))))) {
|
|
EVar3 = *GHIDRA_CAST<EntityPtr *>((GHIDRA_CAST<char *>(room) + 0xc));
|
|
toIndex_00 = EVar5;
|
|
LAB_004b747c:
|
|
if (GHIDRA_INT(*GHIDRA_CAST<EntityPtr *>((GHIDRA_CAST<char *>(room) + 0x10))) < 2) goto LAB_004b7486;
|
|
iVar4 = GHIDRA_INT(EVar3) + GHIDRA_INT(EVar5);
|
|
}
|
|
else {
|
|
EVar3 = *GHIDRA_CAST<EntityPtr *>((GHIDRA_CAST<char *>(room) + 0xc));
|
|
toIndex_00 = (EntityPtr)0xffffffff;
|
|
if (GHIDRA_INT(EVar5) < GHIDRA_INT(EVar3)) goto LAB_004b747c;
|
|
LAB_004b7486:
|
|
iVar4 = -1;
|
|
}
|
|
isCanStep = (GHIDRA_CAST<RoomGridPath *>((GHIDRA_CAST<EntityPtr *>((GHIDRA_INT(room) + 0x7468)))))->RoomGridPath::can_step(iVar4,GHIDRA_INT(toIndex_00));
|
|
if (isCanStep != 0) {
|
|
if ((GHIDRA_INT(EVar5) < GHIDRA_INT(*GHIDRA_CAST<EntityPtr *>((GHIDRA_CAST<char *>(room) + 0xc)))) &&
|
|
(0 < GHIDRA_INT(*GHIDRA_CAST<EntityPtr *>((GHIDRA_CAST<char *>(room) + 0x10))))) {
|
|
local_20 = EVar5;
|
|
}
|
|
else {
|
|
local_20 = (EntityPtr)0xffffffff;
|
|
}
|
|
iVar4 = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(g_game->_room) + 0xc));
|
|
spawnPos.x = (float)(GHIDRA_INT(local_20) % iVar4) * fVar7 + fVar7;
|
|
spawnPos.y = (float)(GHIDRA_INT(local_20) / iVar4) * fVar7 + fVar8;
|
|
seed = Random();
|
|
local_24 = (EntityPtr)
|
|
(GHIDRA_CAST<Game *>((g_game)))->Game::Spawn(0x3c7,0,&spawnPos,&g_vectorZero,GHIDRA_CAST<Entity *>(0x0),0,seed);
|
|
*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(local_24) + 0xec)) = 0;
|
|
local_28 = (EntityPtr)cos(0.0);
|
|
fVar7 = sin(0.0);
|
|
EVar3 = local_28;
|
|
local_28 = local_24;
|
|
(GHIDRA_CAST<Vector *>((GHIDRA_INT(local_24) + 0xdc)))->x = (float)EVar3 * 0.0 - fVar7 * 15.0;
|
|
*GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(local_24) + 0xe0)) = fVar7 * 0.0 + (float)EVar3 * 15.0;
|
|
if (doorsEnd == doorsCapacity) {
|
|
std::vector<unsigned_int>::_Emplace_reallocate(doorsEnd,&local_28);
|
|
doorsCapacity = GHIDRA_CAST<EntityPtr *>(0x0);
|
|
}
|
|
else {
|
|
*doorsEnd = local_24;
|
|
doorsEnd = doorsEnd + 1;
|
|
}
|
|
}
|
|
EVar3 = *GHIDRA_CAST<EntityPtr *>((GHIDRA_CAST<char *>(room) + 0xc));
|
|
pEVar6 = GHIDRA_CAST<EntityPtr *>((GHIDRA_INT(room) + 0x7468));
|
|
if (((GHIDRA_INT(EVar5) < GHIDRA_INT(EVar3)) && (iVar4 = GHIDRA_INT(local_1c) + -1, -1 < iVar4)) &&
|
|
(iVar4 < GHIDRA_INT(*GHIDRA_CAST<EntityPtr *>((GHIDRA_CAST<char *>(room) + 0x10))))) {
|
|
toIndex_01 = GHIDRA_CAST<EntityPtr *>((iVar4 * GHIDRA_INT(EVar3) + GHIDRA_INT(EVar5)));
|
|
LAB_004b75cf:
|
|
iVar4 = GHIDRA_INT(local_1c) + -2;
|
|
room = GHIDRA_CAST<Room *>(local_2c);
|
|
if ((iVar4 < 0) || (GHIDRA_INT(*GHIDRA_CAST<EntityPtr *>((GHIDRA_CAST<char *>(local_2c) + 0x10))) <= iVar4)) goto LAB_004b75e6;
|
|
fromIndex_00 = GHIDRA_CAST<EntityPtr *>((iVar4 * GHIDRA_INT(EVar3) + GHIDRA_INT(EVar5)));
|
|
}
|
|
else {
|
|
toIndex_01 = GHIDRA_CAST<EntityPtr *>(0xffffffff);
|
|
if (GHIDRA_INT(EVar5) < GHIDRA_INT(EVar3)) goto LAB_004b75cf;
|
|
LAB_004b75e6:
|
|
fromIndex_00 = GHIDRA_CAST<EntityPtr *>(0xffffffff);
|
|
}
|
|
isCanStep = (GHIDRA_CAST<RoomGridPath *>((pEVar6)))->RoomGridPath::can_step(GHIDRA_INT(fromIndex_00),GHIDRA_INT(toIndex_01));
|
|
if (isCanStep != 0) {
|
|
local_28 = (EntityPtr)FUN_004bb230();
|
|
if (doorsEnd == doorsCapacity) {
|
|
std::vector<unsigned_int>::_Emplace_reallocate(doorsEnd,&local_28);
|
|
doorsCapacity = GHIDRA_CAST<EntityPtr *>(0x0);
|
|
}
|
|
else {
|
|
*doorsEnd = local_28;
|
|
doorsEnd = doorsEnd + 1;
|
|
}
|
|
}
|
|
EVar5 = (EntityPtr)(GHIDRA_INT(EVar5) + 1);
|
|
} while (GHIDRA_INT(EVar5) < GHIDRA_INT(local_18));
|
|
}
|
|
local_18 = (EntityPtr)0x0;
|
|
pEVar6 = doors;
|
|
if (doorsEnd != GHIDRA_CAST<EntityPtr *>(0x0)) {
|
|
do {
|
|
local_18 = (EntityPtr)pEVar6;
|
|
local_1c = *GHIDRA_CAST<EntityPtr *>(local_18);
|
|
EVar5 = (EntityPtr)(GHIDRA_INT(local_1c) + 0x3bc);
|
|
local_2c = EVar5;
|
|
if ((*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(local_1c) + 0x3bc)) == 0) &&
|
|
(pEVar6 = GHIDRA_CAST<EntityPtr *>((GHIDRA_INT(local_18) + 4)), pEVar6 < doorsEnd)) {
|
|
do {
|
|
local_28 = *pEVar6;
|
|
local_20 = (EntityPtr)(GHIDRA_INT(local_28) + 0x3bc);
|
|
if (*GHIDRA_CAST<EntityPtr *>((GHIDRA_CAST<char *>(local_28) + 0x3bc)) == (EntityPtr)0x0) {
|
|
iVar4 = GHIDRA_INT(((*GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(local_28) + 0x33c)) - 40.0) / 40.0 + 0.5));
|
|
iVar2 = GHIDRA_INT(((*GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(local_28) + 0x340)) - 120.0) / 40.0 + 0.5));
|
|
if ((((iVar4 < 0) || (GHIDRA_INT(*GHIDRA_CAST<EntityPtr *>((GHIDRA_CAST<char *>(room) + 0xc))) <= iVar4)) || (iVar2 < 0)) ||
|
|
(GHIDRA_INT(*GHIDRA_CAST<EntityPtr *>((GHIDRA_CAST<char *>(room) + 0x10))) <= iVar2)) {
|
|
seed = 0xffffffff;
|
|
}
|
|
else {
|
|
seed = iVar2 * GHIDRA_INT(*GHIDRA_CAST<EntityPtr *>((GHIDRA_CAST<char *>(room) + 0xc))) + iVar4;
|
|
}
|
|
iVar2 = GHIDRA_INT(((*GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(local_1c) + 0x33c)) - 40.0) / 40.0 + 0.5));
|
|
iVar4 = GHIDRA_INT(((*GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(local_1c) + 0x340)) - 120.0) / 40.0 + 0.5));
|
|
if (((iVar2 < 0) || (GHIDRA_INT(*GHIDRA_CAST<EntityPtr *>((GHIDRA_CAST<char *>(room) + 0xc))) <= iVar2)) ||
|
|
((iVar4 < 0 || (GHIDRA_INT(*GHIDRA_CAST<EntityPtr *>((GHIDRA_CAST<char *>(room) + 0x10))) <= iVar4)))) {
|
|
startIndex = 0xffffffff;
|
|
}
|
|
else {
|
|
startIndex = iVar4 * GHIDRA_INT(*GHIDRA_CAST<EntityPtr *>((GHIDRA_CAST<char *>(room) + 0xc))) + iVar2;
|
|
}
|
|
isCanStep = room_grid_flood_fill(GHIDRA_CAST<EntityPtr *>((GHIDRA_INT(room) + 0x7468)),startIndex,seed);
|
|
if (isCanStep != 0) {
|
|
if (*GHIDRA_CAST<EntityPtr *>(EVar5) != (EntityPtr)0x0) {
|
|
local_2c = EVar5;
|
|
std::multiset<unsigned_int>::erase(&local_2c);
|
|
}
|
|
*GHIDRA_CAST<EntityPtr *>(EVar5) = local_28;
|
|
std::multiset<unsigned_int>::insert(EVar5);
|
|
if (*GHIDRA_CAST<EntityPtr *>(local_20) != (EntityPtr)0x0) {
|
|
local_2c = local_20;
|
|
std::multiset<unsigned_int>::erase(&local_2c);
|
|
}
|
|
*GHIDRA_CAST<EntityPtr *>(local_20) = local_1c;
|
|
std::multiset<unsigned_int>::insert(local_20);
|
|
}
|
|
}
|
|
pEVar6 = pEVar6 + 1;
|
|
} while (pEVar6 < doorsEnd);
|
|
}
|
|
local_18 = (EntityPtr)(GHIDRA_INT(local_18) + 4);
|
|
pEVar6 = GHIDRA_CAST<EntityPtr *>(local_18);
|
|
} while (GHIDRA_UINT(local_18) < doorsEnd);
|
|
}
|
|
if (doorsEnd != GHIDRA_CAST<EntityPtr *>(0x0)) {
|
|
do {
|
|
(**(code **)(*GHIDRA_CAST<int *>(*doors) + 0xc))(uVar1);
|
|
doors = doors + 1;
|
|
} while (doors < doorsEnd);
|
|
}
|
|
if (*GHIDRA_CAST<EntityPtr *>((GHIDRA_CAST<char *>(room) + 0x724)) != (EntityPtr)0x0) {
|
|
*GHIDRA_CAST<undefined4 *>((GHIDRA_INT(*GHIDRA_CAST<EntityPtr *>((GHIDRA_CAST<char *>(room) + 0x724))) + 0xf4)) = 0;
|
|
}
|
|
if (*GHIDRA_CAST<EntityPtr *>((GHIDRA_CAST<char *>(room) + 0x728)) != (EntityPtr)0x0) {
|
|
*GHIDRA_CAST<undefined4 *>((GHIDRA_INT(*GHIDRA_CAST<EntityPtr *>((GHIDRA_CAST<char *>(room) + 0x728))) + 0xf4)) = 0;
|
|
}
|
|
if (*GHIDRA_CAST<EntityPtr *>((GHIDRA_CAST<char *>(room) + 0x72c)) != (EntityPtr)0x0) {
|
|
*GHIDRA_CAST<undefined4 *>((GHIDRA_INT(*GHIDRA_CAST<EntityPtr *>((GHIDRA_CAST<char *>(room) + 0x72c))) + 0xf4)) = 0;
|
|
}
|
|
if (*GHIDRA_CAST<EntityPtr *>((GHIDRA_CAST<char *>(room) + 0x730)) != (EntityPtr)0x0) {
|
|
*GHIDRA_CAST<undefined4 *>((GHIDRA_INT(*GHIDRA_CAST<EntityPtr *>((GHIDRA_CAST<char *>(room) + 0x730))) + 0xf4)) = 0;
|
|
}
|
|
if (*GHIDRA_CAST<EntityPtr *>((GHIDRA_CAST<char *>(room) + 0x734)) != (EntityPtr)0x0) {
|
|
*GHIDRA_CAST<undefined4 *>((GHIDRA_INT(*GHIDRA_CAST<EntityPtr *>((GHIDRA_CAST<char *>(room) + 0x734))) + 0xf4)) = 0;
|
|
}
|
|
if (*GHIDRA_CAST<EntityPtr *>((GHIDRA_CAST<char *>(room) + 0x738)) != (EntityPtr)0x0) {
|
|
*GHIDRA_CAST<undefined4 *>((GHIDRA_INT(*GHIDRA_CAST<EntityPtr *>((GHIDRA_CAST<char *>(room) + 0x738))) + 0xf4)) = 0;
|
|
}
|
|
if (*GHIDRA_CAST<EntityPtr *>((GHIDRA_CAST<char *>(room) + 0x73c)) != (EntityPtr)0x0) {
|
|
*GHIDRA_CAST<undefined4 *>((GHIDRA_INT(*GHIDRA_CAST<EntityPtr *>((GHIDRA_CAST<char *>(room) + 0x73c))) + 0xf4)) = 0;
|
|
}
|
|
if (*GHIDRA_CAST<EntityPtr *>((GHIDRA_CAST<char *>(room) + 0x740)) != (EntityPtr)0x0) {
|
|
*GHIDRA_CAST<undefined4 *>((GHIDRA_INT(*GHIDRA_CAST<EntityPtr *>((GHIDRA_CAST<char *>(room) + 0x740))) + 0xf4)) = 0;
|
|
}
|
|
ExceptionList = local_10;
|
|
return;
|
|
}
|
|
|
|
// 004b78f0
|
|
void NpcHelper::hornfel_remove_doors()
|
|
{
|
|
void *pvVar1;
|
|
int *hornfelDoorIter;
|
|
uint uVar3;
|
|
int *linkedIter;
|
|
uint seed;
|
|
Entity *pEVar4;
|
|
int *linkedIter;
|
|
int *piVar6;
|
|
int *local_70;
|
|
int *local_64;
|
|
Vector scratchVec;
|
|
int *local_44;
|
|
undefined4 local_40;
|
|
undefined4 uStack_3c;
|
|
undefined4 uStack_38;
|
|
undefined4 uStack_34;
|
|
undefined4 local_30;
|
|
undefined4 uStack_2c;
|
|
undefined4 uStack_28;
|
|
undefined4 uStack_24;
|
|
undefined4 local_20;
|
|
undefined4 local_1c;
|
|
undefined4 local_18;
|
|
uint local_14;
|
|
void *local_10;
|
|
undefined1 *puStack_c;
|
|
undefined4 local_8;
|
|
int *hornfelDoorIter;
|
|
|
|
puStack_c = &LAB_00af33a5;
|
|
local_10 = ExceptionList;
|
|
uVar3 = __security_cookie ^ GHIDRA_INT(register0x00000010) - 4U;
|
|
ExceptionList = &local_10;
|
|
linkedIter = GHIDRA_CAST<int *>(0x0);
|
|
local_64 = GHIDRA_CAST<int *>(0x0);
|
|
pvVar1 = g_game->_room;
|
|
piVar6 = GHIDRA_CAST<int *>(0x0);
|
|
local_70 = GHIDRA_CAST<int *>(0x0);
|
|
local_8 = 1;
|
|
scratchVec.y = 0.0;
|
|
local_14 = uVar3;
|
|
if (*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(pvVar1) + 0x1264)) != 0) {
|
|
do {
|
|
local_44 = *GHIDRA_CAST<int **>((*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(pvVar1) + 0x125c)) + GHIDRA_INT(scratchVec.y) * 4));
|
|
if (local_44[10] == 0x3c7) {
|
|
if (linkedIter == GHIDRA_CAST<int *>(0x0)) {
|
|
std::vector<unsigned_int>::_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<int *>(0x0)) {
|
|
std::vector<unsigned_int>::_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<float *>((GHIDRA_CAST<char *>(pvVar1) + 0x1264))));
|
|
}
|
|
local_44 = GHIDRA_CAST<int *>(0x0);
|
|
linkedIter = GHIDRA_CAST<int *>(0x0);
|
|
hornfelDoorIter = local_44;
|
|
hornfelDoorIter = local_44;
|
|
if (piVar6 != GHIDRA_CAST<int *>(0x0)) {
|
|
do {
|
|
seed = Random();
|
|
scratchVec.x = *GHIDRA_CAST<float *>((*linkedIter + 0x33c));
|
|
scratchVec.y = *GHIDRA_CAST<float *>((*linkedIter + 0x340));
|
|
(GHIDRA_CAST<Game *>((g_game)))->Game::Spawn(1000,0xf,&scratchVec,&g_vectorZero,GHIDRA_CAST<Entity *>(0x0),0,seed);
|
|
(**(code **)(*GHIDRA_CAST<int *>(*linkedIter) + 0x28))(uVar3);
|
|
(**(code **)(**GHIDRA_CAST<int **>((*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<float *>((*hornfelDoorIter + 0x33c));
|
|
scratchVec.y = *GHIDRA_CAST<float *>((*hornfelDoorIter + 0x340));
|
|
pEVar4 = (GHIDRA_CAST<Game *>((g_game)))->Game::Spawn(1000,0xf,&scratchVec,&g_vectorZero,GHIDRA_CAST<Entity *>(0x0),0,uVar3);
|
|
pEVar4->SetColor(&local_40,0xffffffff,0xff,0,1);
|
|
(**(code **)(*GHIDRA_CAST<int *>(*hornfelDoorIter) + 0x28))();
|
|
hornfelDoorIter = local_44;
|
|
local_44 = piVar6;
|
|
}
|
|
if (*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(pvVar1) + 0x724)) != 0) {
|
|
*GHIDRA_CAST<undefined4 *>((*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(pvVar1) + 0x724)) + 0xf4)) = 0x3f800000;
|
|
}
|
|
if (*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(pvVar1) + 0x728)) != 0) {
|
|
*GHIDRA_CAST<undefined4 *>((*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(pvVar1) + 0x728)) + 0xf4)) = 0x3f800000;
|
|
}
|
|
if (*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(pvVar1) + 0x72c)) != 0) {
|
|
*GHIDRA_CAST<undefined4 *>((*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(pvVar1) + 0x72c)) + 0xf4)) = 0x3f800000;
|
|
}
|
|
if (*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(pvVar1) + 0x730)) != 0) {
|
|
*GHIDRA_CAST<undefined4 *>((*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(pvVar1) + 0x730)) + 0xf4)) = 0x3f800000;
|
|
}
|
|
if (*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(pvVar1) + 0x734)) != 0) {
|
|
*GHIDRA_CAST<undefined4 *>((*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(pvVar1) + 0x734)) + 0xf4)) = 0x3f800000;
|
|
}
|
|
if (*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(pvVar1) + 0x738)) != 0) {
|
|
*GHIDRA_CAST<undefined4 *>((*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(pvVar1) + 0x738)) + 0xf4)) = 0x3f800000;
|
|
}
|
|
if (*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(pvVar1) + 0x73c)) != 0) {
|
|
*GHIDRA_CAST<undefined4 *>((*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(pvVar1) + 0x73c)) + 0xf4)) = 0x3f800000;
|
|
}
|
|
if (*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(pvVar1) + 0x740)) != 0) {
|
|
*GHIDRA_CAST<undefined4 *>((*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(pvVar1) + 0x740)) + 0xf4)) = 0x3f800000;
|
|
}
|
|
if (local_44 != GHIDRA_CAST<int *>(0x0)) {
|
|
uVar3 = -GHIDRA_INT(local_44) & 0xfffffffc;
|
|
linkedIter = local_44;
|
|
if (0xfff < uVar3) {
|
|
linkedIter = GHIDRA_CAST<int *>(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;
|
|
}
|
|
|
|
// 004b7c30
|
|
void NpcHelper::hornfel_render_minecart(Entity_NPC *npc, ANM2 *minecartSprite, Vector *renderPos)
|
|
{
|
|
void *pvVar1;
|
|
LayerState *pLVar2;
|
|
float *npcFrame;
|
|
ANM2 *npcSprite;
|
|
AnimationLayer renderLayer;
|
|
AnimationState *local_88;
|
|
undefined4 local_84;
|
|
undefined1 local_80;
|
|
Vector *renderPosLocal;
|
|
AnimationState *cartFrame;
|
|
AnimationState frameCopy [3];
|
|
float local_8;
|
|
int frameIndex;
|
|
int layerIndex;
|
|
|
|
local_8 = (float)(__security_cookie ^ GHIDRA_UINT(&frameCopy[3]._animFrame));
|
|
renderPosLocal = renderPos;
|
|
if (npc->_visible != 0) {
|
|
if ((minecartSprite->_animState)._animData == (void *)0x0) {
|
|
KAGE_LogMessage(0x10,GHIDRA_CAST<byte *>("AnimationData is NULL\n"));
|
|
}
|
|
if (*GHIDRA_CAST<int *>((GHIDRA_INT((minecartSprite->_animState)._animation) + 0x80)) < 2) {
|
|
KAGE_LogMessage(0x10,GHIDRA_CAST<byte *>("LayerId out of bounds\n"));
|
|
}
|
|
pvVar1 = (minecartSprite->_animState)._animData;
|
|
if ((((pvVar1 != (void *)0x0) &&
|
|
(0 < *GHIDRA_CAST<int *>((GHIDRA_INT((minecartSprite->_animState)._animation) + 0x80)))) &&
|
|
(layerIndex = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(pvVar1) + 0x3c)), -1 < layerIndex)) &&
|
|
(((layerIndex < *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(pvVar1) + 0x1c)) &&
|
|
(frameIndex = *GHIDRA_CAST<int *>((GHIDRA_INT((minecartSprite->_animState)._layerFrames) + layerIndex * 4)),
|
|
-1 < frameIndex)) &&
|
|
((layerIndex = layerIndex * 0x10 + *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(pvVar1) + 0x18)),
|
|
frameIndex < *GHIDRA_CAST<int *>((layerIndex + 8)) &&
|
|
(cartFrame = GHIDRA_CAST<AnimationState *>((frameIndex * 0x6c + *GHIDRA_CAST<int *>((layerIndex + 4)))),
|
|
cartFrame != GHIDRA_CAST<AnimationState *>(0x0))))))) {
|
|
if ((npc->_sprite)._animState._animData == (void *)0x0) {
|
|
KAGE_LogMessage(0x10,GHIDRA_CAST<byte *>("AnimationData is NULL\n"));
|
|
}
|
|
if (*GHIDRA_CAST<int *>((GHIDRA_INT((npc->_sprite)._animState._animation) + 0x80)) < 5) {
|
|
KAGE_LogMessage(0x10,GHIDRA_CAST<byte *>("LayerId out of bounds\n"));
|
|
}
|
|
pvVar1 = (npc->_sprite)._animState._animData;
|
|
if ((((pvVar1 != (void *)0x0) &&
|
|
(3 < *GHIDRA_CAST<int *>((GHIDRA_INT((npc->_sprite)._animState._animation) + 0x80)))) &&
|
|
((layerIndex = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(pvVar1) + 0x48)), -1 < layerIndex &&
|
|
(((layerIndex < *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(pvVar1) + 0x1c)) &&
|
|
(frameIndex = *GHIDRA_CAST<int *>((GHIDRA_INT((npc->_sprite)._animState._layerFrames) + layerIndex * 4)),
|
|
-1 < frameIndex)) &&
|
|
(layerIndex = layerIndex * 0x10 + *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(pvVar1) + 0x18)),
|
|
frameIndex < *GHIDRA_CAST<int *>((layerIndex + 8)))))))) &&
|
|
(npcFrame = GHIDRA_CAST<float *>((frameIndex * 0x6c + *GHIDRA_CAST<int *>((layerIndex + 4)))),
|
|
npcFrame != GHIDRA_CAST<float *>(0x0))) {
|
|
(GHIDRA_CAST<AnimationState *>((frameCopy)))->AnimationState::copy_assign(cartFrame);
|
|
local_88 = frameCopy;
|
|
npcSprite = &npc->_sprite;
|
|
local_84 = 1;
|
|
renderLayer = (AnimationLayer)0x4;
|
|
frameCopy[0]._animation = (void *)(((float)frameCopy[0]._animation - 0.0) + *npcFrame);
|
|
frameCopy[0]._animData = (void *)(((float)frameCopy[0]._animData - 224.0) + npcFrame[1]);
|
|
local_80 = 1;
|
|
pLVar2 = (GHIDRA_CAST<ANM2 *>((npcSprite)))->ANM2::GetLayer(&DAT_00000004);
|
|
pLVar2->_visible = 1;
|
|
pLVar2 = (GHIDRA_CAST<ANM2 *>((npcSprite)))->ANM2::GetLayer(&DAT_00000004);
|
|
(pLVar2->_color)._tint[3] = (minecartSprite->_color)._tint[3];
|
|
AnimationLayer::RenderFrame
|
|
(&renderLayer,renderPosLocal,0,&g_vectorZero,&g_vectorZero,npcSprite);
|
|
pLVar2 = (GHIDRA_CAST<ANM2 *>((npcSprite)))->ANM2::GetLayer(&DAT_00000004);
|
|
pLVar2->_visible = 0;
|
|
}
|
|
}
|
|
}
|
|
return;
|
|
}
|
|
|
|
// 004b7e30
|
|
void NpcHelper::hornfel_charge(Entity_NPC *npc)
|
|
{
|
|
char *animName;
|
|
float cartVelocityX;
|
|
float cartVelocityY;
|
|
ANM2 *sprite;
|
|
|
|
sprite = &npc->_sprite;
|
|
cartVelocityX = *GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(npc->_minecart) + 0x360));
|
|
cartVelocityY = *GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(npc->_minecart) + 0x364));
|
|
if (npc->_state != 10) {
|
|
if (ABS(cartVelocityY) < ABS(cartVelocityX)) {
|
|
animName = "IdleLeft";
|
|
if (0.0 <= cartVelocityX) {
|
|
animName = "IdleRight";
|
|
}
|
|
(GHIDRA_CAST<ANM2 *>((sprite)))->ANM2::Play(GHIDRA_CAST<byte *>(animName),0);
|
|
return;
|
|
}
|
|
animName = "IdleUp";
|
|
if (0.0 <= cartVelocityY) {
|
|
animName = "IdleDown";
|
|
}
|
|
(GHIDRA_CAST<ANM2 *>((sprite)))->ANM2::Play(GHIDRA_CAST<byte *>(animName),0);
|
|
return;
|
|
}
|
|
if (ABS(cartVelocityY) < ABS(cartVelocityX)) {
|
|
animName = "ChargeLeft";
|
|
if (0.0 <= cartVelocityX) {
|
|
animName = "ChargeRight";
|
|
}
|
|
(GHIDRA_CAST<ANM2 *>((sprite)))->ANM2::Play(GHIDRA_CAST<byte *>(animName),0);
|
|
return;
|
|
}
|
|
animName = "ChargeUp";
|
|
if (0.0 <= cartVelocityY) {
|
|
animName = "ChargeDown";
|
|
}
|
|
(GHIDRA_CAST<ANM2 *>((sprite)))->ANM2::Play(GHIDRA_CAST<byte *>(animName),0);
|
|
return;
|
|
}
|
|
|
|
// 004b7ee0
|
|
Entity * NpcHelper::hornfel_pick_spawn()
|
|
{
|
|
int *piVar1;
|
|
undefined4 uVar2;
|
|
RNG rng;
|
|
uint uVar3;
|
|
Entity *spawned;
|
|
EntityPtr in_ECX;
|
|
WeightedOutcomePicker freeBlock;
|
|
uint uVar4;
|
|
BitSet128 BVar5;
|
|
EntityPtr *local_44;
|
|
uint rngSeed;
|
|
undefined8 uStack_3c;
|
|
uint uStack_34;
|
|
WeightedOutcomePicker outcomes;
|
|
undefined4 *outcomesEnd;
|
|
undefined4 *outcomesCapacity;
|
|
uint securityCookie;
|
|
undefined1 *puStack_20;
|
|
void *local_1c;
|
|
undefined1 *puStack_18;
|
|
undefined4 local_14;
|
|
EntityPtr oldParent;
|
|
EntityPtr *parentRef;
|
|
|
|
puStack_20 = GHIDRA_CAST<undefined1 *>((GHIDRA_INT(register0x00000010) + -4));
|
|
puStack_18 = &LAB_00af332d;
|
|
local_1c = ExceptionList;
|
|
securityCookie = __security_cookie ^ GHIDRA_INT(register0x00000010) - 0x10U;
|
|
ExceptionList = &local_1c;
|
|
outcomes = (WeightedOutcomePicker)0x0;
|
|
outcomesEnd = GHIDRA_CAST<undefined4 *>(0x0);
|
|
outcomesCapacity = GHIDRA_CAST<undefined4 *>(0x0);
|
|
local_14 = 0;
|
|
uStack_3c = (ulonglong)GHIDRA_UINT(uStack_3c);
|
|
uStack_34 = 6;
|
|
std::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<int *>((GHIDRA_CAST<char *>(outcomes) + uVar3 * 8)) == 8) {
|
|
piVar1 = GHIDRA_CAST<int *>((GHIDRA_INT(outcomes) + 4 + uVar3 * 8));
|
|
*piVar1 = *piVar1 + 3;
|
|
if (*piVar1 < 0) {
|
|
*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(outcomes) + 4 + uVar3 * 8)) = 0;
|
|
}
|
|
goto LAB_004b7fc7;
|
|
}
|
|
uVar3 = uVar3 + 1;
|
|
} while (uVar3 < uVar4);
|
|
}
|
|
uStack_3c = CONCAT44(8,GHIDRA_UINT(uStack_3c));
|
|
uStack_34 = 3;
|
|
if (outcomesEnd == outcomesCapacity) {
|
|
std::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<int *>((GHIDRA_CAST<char *>(outcomes) + uVar3 * 8)) == 0x10) {
|
|
piVar1 = GHIDRA_CAST<int *>((GHIDRA_INT(outcomes) + 4 + uVar3 * 8));
|
|
*piVar1 = *piVar1 + 1;
|
|
if (*piVar1 < 0) {
|
|
*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(outcomes) + 4 + uVar3 * 8)) = 0;
|
|
}
|
|
goto LAB_004b8025;
|
|
}
|
|
uVar3 = uVar3 + 1;
|
|
} while (uVar3 < uVar4);
|
|
}
|
|
uStack_3c = CONCAT44(0x10,GHIDRA_UINT(uStack_3c));
|
|
uStack_34 = 1;
|
|
if (outcomesEnd == outcomesCapacity) {
|
|
std::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 = (GHIDRA_CAST<WeightedOutcomePicker *>((&outcomes)))->WeightedOutcomePicker::PickOutcome(rng);
|
|
local_14 = 0xffffffff;
|
|
uStack_34 = uVar3;
|
|
if (outcomes != (WeightedOutcomePicker)0x0) {
|
|
uVar4 = GHIDRA_INT(outcomesCapacity) - GHIDRA_INT(outcomes) & 0xfffffff8;
|
|
freeBlock = outcomes;
|
|
if (0xfff < uVar4) {
|
|
freeBlock = *GHIDRA_CAST<WeightedOutcomePicker *>((GHIDRA_CAST<char *>(outcomes) + -4));
|
|
uVar4 = uVar4 + 0x23;
|
|
if (0x1f < (GHIDRA_INT(outcomes) - GHIDRA_INT(freeBlock)) - 4U) {
|
|
/* WARNING: Subroutine does not return */
|
|
_invalid_parameter_noinfo_noreturn();
|
|
}
|
|
}
|
|
operator_delete((void *)freeBlock,uVar4);
|
|
}
|
|
uVar4 = Random();
|
|
spawned = (GHIDRA_CAST<Game *>((g_game)))->Game::Spawn(4,uVar3,GHIDRA_CAST<Vector *>((GHIDRA_INT(in_ECX) + 0x33c)),&g_vectorZero,
|
|
GHIDRA_CAST<Entity *>(in_ECX),0,uVar4);
|
|
oldParent = spawned->_parent;
|
|
parentRef = &spawned->_parent;
|
|
spawned->_visible = 0;
|
|
spawned->_entityCollisionClass = 0;
|
|
spawned->_entityGridCollisionClass = 0;
|
|
*GHIDRA_CAST<undefined4 *>((spawned + 1)) = 0x23;
|
|
*GHIDRA_CAST<undefined4 *>(&(*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(&(spawned[1])) + 0x4)))) = 0x23;
|
|
if (oldParent != (EntityPtr)0x0) {
|
|
local_44 = parentRef;
|
|
std::multiset<unsigned_int>::erase(&local_44);
|
|
}
|
|
*parentRef = in_ECX;
|
|
if (in_ECX != (EntityPtr)0x0) {
|
|
std::multiset<unsigned_int>::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<BitSet128 *>(&spawned[1]._type) = BVar5;
|
|
LAB_004b814e:
|
|
uVar2 = *GHIDRA_CAST<undefined4 *>((GHIDRA_INT(&spawned->_flags) + 4));
|
|
*GHIDRA_CAST<uint *>(&spawned->_flags) = GHIDRA_UINT(spawned->_flags) | 0x20;
|
|
*GHIDRA_CAST<undefined4 *>((GHIDRA_INT(&spawned->_flags) + 4)) = uVar2;
|
|
ExceptionList = local_1c;
|
|
return spawned;
|
|
}
|
|
|
|
// 004b8190
|
|
void NpcHelper::hornfel_minecart(Entity_NPC *npc)
|
|
{
|
|
uint uVar1;
|
|
int iVar2;
|
|
int iVar3;
|
|
EntityPtr EVar4;
|
|
Vector *velocity;
|
|
int *piVar5;
|
|
Entity_Player *player;
|
|
uint rngResult;
|
|
Entity *spawned;
|
|
char *ptr;
|
|
int iVar6;
|
|
EntityPtr *remaining;
|
|
float fVar7;
|
|
float deltaX;
|
|
Vector railDirOut;
|
|
Vector local_60;
|
|
Vector local_58;
|
|
Vector local_50;
|
|
EntityPtr local_48;
|
|
EntityPtr *local_44;
|
|
EntityPtr local_40;
|
|
std_string anm2Path;
|
|
uint local_24;
|
|
undefined1 *puStack_20;
|
|
void *local_1c;
|
|
undefined1 *puStack_18;
|
|
undefined4 local_14;
|
|
ANM2 *minecartSprite;
|
|
void *room;
|
|
|
|
puStack_20 = GHIDRA_CAST<undefined1 *>((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 = (EntityPtr)npc;
|
|
if (npc->_state == 7) {
|
|
EVar4 = npc->_entityRef;
|
|
local_60.y = (float)EVar4;
|
|
if (EVar4 != (EntityPtr)0x0) {
|
|
local_40 = (EntityPtr)&npc->_entityRef;
|
|
puStack_20 = GHIDRA_CAST<undefined1 *>((GHIDRA_INT(register0x00000010) + -4));
|
|
std::multiset<unsigned_int>::erase(&local_40);
|
|
npc->_entityRef = (EntityPtr)0x0;
|
|
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<int *>((GHIDRA_CAST<char *>(local_50.y) + 0x1264)) != 0) {
|
|
do {
|
|
iVar6 = *GHIDRA_CAST<int *>((*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(local_50.y) + 0x125c)) + GHIDRA_INT(local_58.y) * 4));
|
|
if (*GHIDRA_CAST<int *>((iVar6 + 0x28)) == 0x3c7) {
|
|
if (*GHIDRA_CAST<Entity_NPC **>((iVar6 + 0x3c4)) == npc) {
|
|
if (*GHIDRA_CAST<Entity_NPC **>((iVar6 + 0x3c4)) == GHIDRA_CAST<Entity_NPC *>(0x0)) {
|
|
if ((*GHIDRA_CAST<int *>((iVar6 + 0x3bc)) == 0) || (*GHIDRA_CAST<int *>((*GHIDRA_CAST<int *>((iVar6 + 0x3bc)) + 0x3c4)) == 0))
|
|
goto LAB_004b8675;
|
|
}
|
|
else {
|
|
local_40 = (EntityPtr)(iVar6 + 0x3c4);
|
|
std::multiset<unsigned_int>::erase(&local_40);
|
|
}
|
|
iVar2 = *GHIDRA_CAST<int *>((iVar6 + 0x3bc));
|
|
*GHIDRA_CAST<undefined4 *>((iVar6 + 0x3c4)) = 0;
|
|
if (iVar2 != 0) {
|
|
if (*GHIDRA_CAST<int *>((iVar2 + 0x3c4)) != 0) {
|
|
local_40 = (EntityPtr)(iVar2 + 0x3c4);
|
|
std::multiset<unsigned_int>::erase(&local_40);
|
|
}
|
|
*GHIDRA_CAST<EntityPtr *>((iVar2 + 0x3c4)) = (EntityPtr)0x0;
|
|
}
|
|
}
|
|
}
|
|
LAB_004b8675:
|
|
local_58.y = (float)(GHIDRA_INT(local_58.y) + 1);
|
|
} while (GHIDRA_UINT(local_58.y) < GHIDRA_UINT(*GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(local_50.y) + 0x1264))));
|
|
}
|
|
EVar4 = (EntityPtr)local_60.y;
|
|
if ((EntityPtr)local_60.y == (EntityPtr)0x0) {
|
|
KAGE_LogMessage(4,GHIDRA_CAST<byte *>("no doors to enter from!\n"));
|
|
*GHIDRA_CAST<undefined2 *>(&npc->_stateFrame) = 0xf;
|
|
ExceptionList = local_1c;
|
|
return;
|
|
}
|
|
LAB_004b8213:
|
|
hornfel_get_rail_direction(GHIDRA_CAST<Entity_NPC *>(EVar4),&local_50);
|
|
if ((local_50.x == g_vectorZero.x) && (local_50.y == g_vectorZero.y)) {
|
|
KAGE_LogMessage(0x10,GHIDRA_CAST<byte *>("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<float *>((GHIDRA_CAST<char *>(npc->_config) + 0x24));
|
|
local_58.y = *GHIDRA_CAST<float *>(&npc->_minecart);
|
|
if ((EntityPtr)local_58.y != (EntityPtr)0x0) {
|
|
FUN_004cf0f0(1);
|
|
Entity_NPC::SetMinecartPosVel
|
|
(GHIDRA_CAST<Entity_NPC *>(local_58.y),GHIDRA_CAST<Vector *>((GHIDRA_INT(EVar4) + 0x334)),&local_50);
|
|
fVar7 = *GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(local_58.y) + 0x340));
|
|
(npc->_pos).x = *GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(local_58.y) + 0x33c));
|
|
(npc->_pos).y = fVar7;
|
|
hornfel_claim_target(GHIDRA_CAST<Entity_NPC *>(EVar4),GHIDRA_CAST<Entity *>(npc));
|
|
local_40 = npc->_parent;
|
|
if (npc->_state == 6) {
|
|
if (*GHIDRA_CAST<char *>((GHIDRA_INT(&npc->_projectileCooldown) + 1)) == '\0') {
|
|
uVar1 = Random();
|
|
if (((uVar1 & 7) == 0) &&
|
|
((local_40 == (EntityPtr)0x0 || (4 < *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(local_40) + 0x45c)))))) {
|
|
room = g_game->_room;
|
|
iVar2 = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(room) + 0x12c0)) + *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(room) + 0x12c4));
|
|
iVar6 = 0;
|
|
if (0 < iVar2) {
|
|
iVar6 = iVar2;
|
|
}
|
|
iVar3 = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(room) + 0x12c8)) + *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(room) + 0x12cc));
|
|
iVar2 = 0;
|
|
if (0 < iVar3) {
|
|
iVar2 = iVar3;
|
|
}
|
|
if ((iVar6 - iVar2 < 2) && (spawned = hornfel_free_door(), spawned != GHIDRA_CAST<Entity *>(0x0))) {
|
|
local_58.y = 0.0;
|
|
local_44 = (EntityPtr *)
|
|
((0x87 < *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(g_game->_room) + 0x10)) *
|
|
*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(g_game->_room) + 0xc))) + 2);
|
|
do {
|
|
local_60.y = (float)hornfel_free_door();
|
|
if (GHIDRA_CAST<Entity *>(local_60.y) == GHIDRA_CAST<Entity *>(0x0)) break;
|
|
uVar1 = Random();
|
|
EVar4 = (EntityPtr)
|
|
(GHIDRA_CAST<Game *>((g_game)))->Game::Spawn(0x38a,1,&g_vectorZero,&g_vectorZero,GHIDRA_CAST<Entity *>(npc),0,uVar1);
|
|
*GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(EVar4) + 0x168)) = *GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(EVar4) + 0x168)) & 0xfffffffb;
|
|
*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(EVar4) + 0x16c)) = *GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(EVar4) + 0x16c));
|
|
local_48 = EVar4;
|
|
(**(code **)(*GHIDRA_CAST<int *>(EVar4) + 0xc))();
|
|
velocity = hornfel_get_rail_direction(GHIDRA_CAST<Entity_NPC *>(local_60.y),&railDirOut);
|
|
local_50.y = (float)Entity::GiveMinecart
|
|
(GHIDRA_CAST<Entity *>(EVar4),GHIDRA_CAST<Vector *>((GHIDRA_INT(local_60.y) + 0x334)),
|
|
velocity);
|
|
anm2Path._size = 0;
|
|
minecartSprite = GHIDRA_CAST<ANM2 *>((GHIDRA_INT(local_50.y) + 0x48));
|
|
anm2Path._capacity = 0xf;
|
|
anm2Path._buf[0] = '\0';
|
|
anm2Path._buf[1] = '\0';
|
|
anm2Path._buf[2] = '\0';
|
|
anm2Path._buf[3] = '\0';
|
|
(*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(anm2Path._buf)) + 0x0))) = std::_Allocate(0x30);
|
|
anm2Path._size = 0x21;
|
|
anm2Path._capacity = 0x2f;
|
|
builtin_strncpy((*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(GHIDRA_CAST<char *>(anm2Path._buf))) + 0x0))),"gfx/965.001_hornfel minecart.anm2",0x22
|
|
);
|
|
local_14 = 0;
|
|
(GHIDRA_CAST<ANM2 *>((minecartSprite)))->ANM2::Load(&anm2Path,1);
|
|
local_14 = 0xffffffff;
|
|
if (0xf < anm2Path._capacity) {
|
|
uVar1 = anm2Path._capacity + 1;
|
|
ptr = (*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(GHIDRA_CAST<char *>(anm2Path._buf))) + 0x0)));
|
|
if (0xfff < uVar1) {
|
|
ptr = *GHIDRA_CAST<char **>(((*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(anm2Path._buf)) + 0x0))) + -4));
|
|
uVar1 = anm2Path._capacity + 0x24;
|
|
if (GHIDRA_CAST<char *>(0x1f) < GHIDRA_CAST<char *>(((*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(anm2Path._buf)) + 0x0))) + (-4 - GHIDRA_INT(ptr))))) {
|
|
/* WARNING: Subroutine does not return */
|
|
_invalid_parameter_noinfo_noreturn();
|
|
}
|
|
}
|
|
operator_delete(ptr,uVar1);
|
|
}
|
|
(**(code **)(*GHIDRA_CAST<int *>(local_50.y) + 0xc))();
|
|
EVar4 = local_48;
|
|
if ((*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(local_60.y) + 0x3c4)) == 0) &&
|
|
((*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(local_60.y) + 0x3bc)) == 0 ||
|
|
(*GHIDRA_CAST<int *>((*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(local_60.y) + 0x3bc)) + 0x3c4)) == 0)))) {
|
|
*GHIDRA_CAST<EntityPtr *>((GHIDRA_CAST<char *>(local_60.y) + 0x3c4)) = local_48;
|
|
std::multiset<unsigned_int>::insert(GHIDRA_CAST<EntityPtr *>((GHIDRA_INT(local_60.y) + 0x3c4)));
|
|
iVar6 = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(local_60.y) + 0x3bc));
|
|
if (iVar6 != 0) {
|
|
local_50.y = (float)(iVar6 + 0x3c4);
|
|
if (*GHIDRA_CAST<int *>((iVar6 + 0x3c4)) != 0) {
|
|
local_48 = (EntityPtr)local_50.y;
|
|
std::multiset<unsigned_int>::erase(&local_48);
|
|
}
|
|
*GHIDRA_CAST<EntityPtr *>(local_50.y) = EVar4;
|
|
std::multiset<unsigned_int>::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;
|
|
uVar1 = Random();
|
|
*GHIDRA_CAST<undefined1 *>((GHIDRA_INT(&npc->_projectileCooldown) + 1)) = 100;
|
|
*GHIDRA_CAST<short *>(&npc->_projectileDelay) = (short)(uVar1 % 0x1e) + 0x1e;
|
|
if (local_40 == (EntityPtr)0x0) {
|
|
ExceptionList = local_1c;
|
|
return;
|
|
}
|
|
if (*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(local_40) + 0x45c)) < 0x96) {
|
|
*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(local_40) + 0x45c)) = 0x96;
|
|
*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(local_40) + 0x460)) = 0x96;
|
|
ExceptionList = local_1c;
|
|
return;
|
|
}
|
|
ExceptionList = local_1c;
|
|
return;
|
|
}
|
|
EVar4 = (EntityPtr)local_60.y;
|
|
}
|
|
}
|
|
if ((((npc->_state == 6) && (*GHIDRA_CAST<char *>((GHIDRA_INT(&npc->_projectileCooldown) + 2)) == '\0')) &&
|
|
(uVar1 = Random(), (uVar1 & 7) == 0)) &&
|
|
((*GHIDRA_CAST<EntityPtr *>((GHIDRA_CAST<char *>(EVar4) + 0x3bc)) != (EntityPtr)0x0 &&
|
|
(*GHIDRA_CAST<EntityPtr *>((GHIDRA_CAST<char *>(EVar4) + 0x3bc)) != EVar4)))) {
|
|
npc->_state = 10;
|
|
*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(local_58.y) + 3000)) = 0x3dcccccd;
|
|
if (npc->_entityRef != (EntityPtr)0x0) {
|
|
local_44 = &npc->_entityRef;
|
|
std::multiset<unsigned_int>::erase(&local_44);
|
|
}
|
|
npc->_entityRef = EVar4;
|
|
std::multiset<unsigned_int>::insert(&npc->_entityRef);
|
|
*GHIDRA_CAST<undefined1 *>((GHIDRA_INT(&npc->_projectileCooldown) + 2)) = 100;
|
|
uVar1 = Random();
|
|
*GHIDRA_CAST<char *>((GHIDRA_INT(&npc->_projectileDelay) + 2)) = (char)(uVar1 % 3) + '\x06';
|
|
ExceptionList = local_1c;
|
|
return;
|
|
}
|
|
}
|
|
if (npc->_state == 7) {
|
|
npc->_state = 0xb;
|
|
}
|
|
else {
|
|
npc->_state = 3;
|
|
uVar1 = Random();
|
|
*GHIDRA_CAST<short *>(&npc->_projectileDelay) = (short)(uVar1 % 0xf) + 0xf;
|
|
uVar1 = Random();
|
|
if (uVar1 % 3 == 0) {
|
|
local_44 = *GHIDRA_CAST<EntityPtr **>((GHIDRA_CAST<char *>(g_game->_room) + 0x1264));
|
|
if (local_44 != GHIDRA_CAST<EntityPtr *>(0x0)) {
|
|
piVar5 = *GHIDRA_CAST<int **>((GHIDRA_CAST<char *>(g_game->_room) + 0x125c));
|
|
uVar1 = 0;
|
|
remaining = local_44;
|
|
do {
|
|
iVar6 = *GHIDRA_CAST<int *>((*piVar5 + 0x28));
|
|
if ((iVar6 == 0x333) || ((iVar6 == 4 && (*GHIDRA_CAST<int *>((*piVar5 + 0x2c)) == 0xe)))) {
|
|
uVar1 = uVar1 + 1;
|
|
}
|
|
piVar5 = piVar5 + 1;
|
|
remaining = GHIDRA_CAST<EntityPtr *>(&(*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(&(remaining[-1])) + 0x3))));
|
|
} while (remaining != GHIDRA_CAST<EntityPtr *>(0x0));
|
|
npc = GHIDRA_CAST<Entity_NPC *>(local_48);
|
|
if (3 < uVar1) {
|
|
ExceptionList = local_1c;
|
|
return;
|
|
}
|
|
}
|
|
uVar1 = 0;
|
|
local_40 = (EntityPtr)0x7149f2ca;
|
|
if (GHIDRA_INT((g_game->_playerManager)._playerList._end) -
|
|
GHIDRA_INT((g_game->_playerManager)._playerList._begin) >> 2 != 0) {
|
|
do {
|
|
player = (GHIDRA_CAST<Game *>((g_game)))->Game::GetPlayer(uVar1);
|
|
uVar1 = uVar1 + 1;
|
|
fVar7 = *GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(npc) + 0x340)) - (player->_pos).y;
|
|
deltaX = (GHIDRA_CAST<Vector *>((GHIDRA_INT(npc) + 0x33c)))->x - (player->_pos).x;
|
|
EVar4 = (EntityPtr)(fVar7 * fVar7 + deltaX * deltaX);
|
|
if ((float)local_40 <= (float)EVar4) {
|
|
EVar4 = local_40;
|
|
}
|
|
local_40 = EVar4;
|
|
} while (uVar1 < GHIDRA_UINT((GHIDRA_INT((g_game->_playerManager)._playerList._end) -
|
|
GHIDRA_INT((g_game->_playerManager)._playerList._begin) >> 2)));
|
|
if ((float)EVar4 <= 57600.0) {
|
|
ExceptionList = local_1c;
|
|
return;
|
|
}
|
|
}
|
|
local_40 = (EntityPtr)0x2;
|
|
do {
|
|
uVar1 = Random();
|
|
rngResult = Random();
|
|
local_44 = (EntityPtr *)
|
|
(((float)((double)GHIDRA_INT(rngResult) +
|
|
__uint_to_double_fixup[-(GHIDRA_INT(rngResult) >> 0x1f)]) * 2.3283064e-10 *
|
|
40.0 - 20.0) * 0.017453292);
|
|
local_48 = (EntityPtr)cos((float)local_44);
|
|
fVar7 = sin((float)local_44);
|
|
local_58.x = local_50.x * (float)local_48 - local_50.y * fVar7;
|
|
local_58.y = local_50.y * (float)local_48 + local_50.x * fVar7;
|
|
rngResult = Random();
|
|
fVar7 = (float)((double)GHIDRA_INT(rngResult) +
|
|
__uint_to_double_fixup[-(GHIDRA_INT(rngResult) >> 0x1f)]) * 2.3283064e-10 * 3.14
|
|
;
|
|
local_44 = GHIDRA_CAST<EntityPtr *>((fVar7 + fVar7));
|
|
fVar7 = cos((float)local_44);
|
|
local_60.x = fVar7 * 6.0 + (GHIDRA_CAST<Vector *>((GHIDRA_INT(npc) + 0x33c)))->x;
|
|
fVar7 = sin((float)local_44);
|
|
local_60.y = fVar7 * 6.0 + *GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(npc) + 0x340));
|
|
spawned = (GHIDRA_CAST<Game *>((g_game)))->Game::Spawn(0x333,0,&local_60,&local_58,GHIDRA_CAST<Entity *>(npc),0,uVar1);
|
|
if (spawned->_parent != (EntityPtr)0x0) {
|
|
local_44 = &spawned->_parent;
|
|
std::multiset<unsigned_int>::erase(&local_44);
|
|
}
|
|
spawned->_parent = (EntityPtr)npc;
|
|
std::multiset<unsigned_int>::insert(&spawned->_parent);
|
|
*GHIDRA_CAST<uint *>(&spawned->_flags) = GHIDRA_UINT(spawned->_flags) & 0xfffffffb;
|
|
local_40 = (EntityPtr)(GHIDRA_INT(local_40) + -1);
|
|
*GHIDRA_CAST<undefined4 *>((GHIDRA_INT(&spawned->_flags) + 4)) = *GHIDRA_CAST<undefined4 *>((GHIDRA_INT(&spawned->_flags) + 4));
|
|
} while (local_40 != (EntityPtr)0x0);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
ExceptionList = local_1c;
|
|
return;
|
|
}
|
|
|
|
// 004b8a30
|
|
void NpcHelper::hornfel_ride_minecart(Entity_NPC *linkedNpc)
|
|
{
|
|
char *pcVar1;
|
|
qword qVar2;
|
|
float *pfVar3;
|
|
void *flyBombData;
|
|
float fVar4;
|
|
qword *allocatedBytes;
|
|
uint uVar5;
|
|
float fVar6;
|
|
EntityList_EL flyBombs;
|
|
Vector scratchVec;
|
|
undefined4 *local_14;
|
|
void *local_10;
|
|
undefined1 *puStack_c;
|
|
undefined4 uStack_8;
|
|
Game *game;
|
|
EntityPtr linkedNpc;
|
|
EntityPtr minecart;
|
|
undefined4 *parentRef;
|
|
|
|
uStack_8 = 0xffffffff;
|
|
puStack_c = &LAB_00af341d;
|
|
local_10 = ExceptionList;
|
|
minecart = linkedNpc->_minecart;
|
|
if ((linkedNpc->_state == 10) && (linkedNpc = linkedNpc->_entityRef, linkedNpc != (EntityPtr)0x0)) {
|
|
if ('\0' < *GHIDRA_CAST<char *>((GHIDRA_INT(&linkedNpc->_projectileDelay) + 2))) {
|
|
ExceptionList = &local_10;
|
|
hornfel_get_rail_direction(GHIDRA_CAST<Entity_NPC *>(linkedNpc),&scratchVec);
|
|
Entity_NPC::SetMinecartPosVel
|
|
(GHIDRA_CAST<Entity_NPC *>(minecart),GHIDRA_CAST<Vector *>((GHIDRA_INT(linkedNpc) + 0x334)),&scratchVec);
|
|
fVar4 = (GHIDRA_CAST<Vector *>((GHIDRA_INT(minecart) + 0x33c)))->x;
|
|
fVar6 = *GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(minecart) + 0x340));
|
|
pcVar1 = GHIDRA_CAST<char *>((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<undefined2 *>(&linkedNpc->_stateFrame) = 1;
|
|
(linkedNpc->_targetPosition).x = (linkedNpc->_pos).x;
|
|
(linkedNpc->_targetPosition).y = (linkedNpc->_pos).y;
|
|
linkedNpc->_shadowSize = 0.0;
|
|
fVar4 = (GHIDRA_CAST<Vector *>((GHIDRA_INT(minecart) + 3000)))->x;
|
|
fVar6 = 6.0;
|
|
if (fVar4 <= 6.0) {
|
|
fVar6 = fVar4;
|
|
}
|
|
*GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(minecart) + 0x15c)) = 0.0;
|
|
(GHIDRA_CAST<Vector *>((GHIDRA_INT(minecart) + 3000)))->x = fVar6;
|
|
return;
|
|
}
|
|
ExceptionList = &local_10;
|
|
linkedNpc->_state = 6;
|
|
*GHIDRA_CAST<undefined2 *>(&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;
|
|
*GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(minecart) + 0x15c)) = 0.0;
|
|
EntityList::QuerySublist(GHIDRA_CAST<EntityList *>((GHIDRA_INT(game->_room) + 0x1218)),&flyBombs,0x333,-1,-1,0,0);
|
|
uVar5 = 0;
|
|
if (flyBombs._size != 0) {
|
|
flyBombData = flyBombs._data;
|
|
do {
|
|
scratchVec.y = *GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(flyBombData) + uVar5 * 4));
|
|
parentRef = GHIDRA_CAST<undefined4 *>((GHIDRA_INT(scratchVec.y) + 0x3bc));
|
|
if (*GHIDRA_CAST<Entity_NPC **>((GHIDRA_CAST<char *>(scratchVec.y) + 0x3bc)) == linkedNpc) {
|
|
fVar4 = scratchVec.y;
|
|
if (*GHIDRA_CAST<Entity_NPC **>((GHIDRA_CAST<char *>(scratchVec.y) + 0x3bc)) != GHIDRA_CAST<Entity_NPC *>(0x0)) {
|
|
local_14 = parentRef;
|
|
std::multiset<unsigned_int>::erase(&local_14);
|
|
fVar4 = scratchVec.y;
|
|
}
|
|
local_14 = *GHIDRA_CAST<undefined4 **>((GHIDRA_CAST<char *>(fVar4) + 0x380));
|
|
scratchVec.y = 3.5;
|
|
*parentRef = 0;
|
|
pfVar3 = &scratchVec.y;
|
|
if ((float)local_14 <= 3.5) {
|
|
pfVar3 = GHIDRA_CAST<float *>(&local_14);
|
|
}
|
|
*GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(fVar4) + 0x380)) = *pfVar3;
|
|
flyBombData = flyBombs._data;
|
|
}
|
|
uVar5 = uVar5 + 1;
|
|
} while (uVar5 < GHIDRA_UINT(flyBombs._size));
|
|
}
|
|
if ((*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(&(flyBombs)) + 0x0))) == '\0') {
|
|
if (g_mainHeap == (void *)0x0) {
|
|
allocatedBytes = &g_allocatedBytesNoHeap;
|
|
}
|
|
else {
|
|
allocatedBytes = GHIDRA_CAST<qword *>((GHIDRA_INT(g_mainHeap) + 0x30));
|
|
}
|
|
if (flyBombs._data != (void *)0x0) {
|
|
uVar5 = *GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(flyBombs._data) + -4));
|
|
qVar2 = *allocatedBytes;
|
|
*GHIDRA_CAST<uint *>(allocatedBytes) = GHIDRA_UINT(*allocatedBytes) - uVar5;
|
|
*GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(allocatedBytes) + 4)) =
|
|
*GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(allocatedBytes) + 4)) - GHIDRA_UINT((GHIDRA_UINT(qVar2) < uVar5));
|
|
free(GHIDRA_CAST<uint *>((GHIDRA_INT(flyBombs._data) + -4)));
|
|
}
|
|
}
|
|
ExceptionList = local_10;
|
|
return;
|
|
}
|
|
|
|
// 004b8ca0
|
|
void NpcHelper::hornfel_attack(Entity_NPC *npc)
|
|
{
|
|
RNG rng;
|
|
uint uVar1;
|
|
Entity *target;
|
|
undefined4 extraout_ECX;
|
|
undefined4 extraout_ECX_00;
|
|
undefined4 extraout_ECX_01;
|
|
undefined4 uVar2;
|
|
WeightedOutcomePicker ptr;
|
|
uint uVar3;
|
|
float targetDist;
|
|
undefined8 uStack_48;
|
|
float fStack_40;
|
|
float targetDirY;
|
|
WeightedOutcomePicker picker;
|
|
undefined4 *outcomesEnd;
|
|
undefined4 *outcomesCapacity;
|
|
float *local_2c;
|
|
undefined4 *local_28;
|
|
uint local_24;
|
|
undefined1 *puStack_20;
|
|
void *local_1c;
|
|
undefined1 *puStack_18;
|
|
undefined4 local_14;
|
|
char *animName;
|
|
float *childSlot;
|
|
int dequeBlock;
|
|
undefined4 *firstChildSlot;
|
|
int *outcomeWeight;
|
|
|
|
puStack_20 = GHIDRA_CAST<undefined1 *>((GHIDRA_INT(register0x00000010) + -4));
|
|
puStack_18 = &LAB_00af344d;
|
|
local_1c = ExceptionList;
|
|
local_24 = __security_cookie ^ GHIDRA_INT(register0x00000010) - 0x10U;
|
|
ExceptionList = &local_1c;
|
|
picker = (WeightedOutcomePicker)0x0;
|
|
outcomesEnd = GHIDRA_CAST<undefined4 *>(0x0);
|
|
outcomesCapacity = GHIDRA_CAST<undefined4 *>(0x0);
|
|
local_14 = 0;
|
|
uStack_48 = (ulonglong)GHIDRA_UINT(uStack_48);
|
|
fStack_40 = 4.2039e-45;
|
|
std::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<int *>((GHIDRA_CAST<char *>(picker) + uVar1 * 8)) == 1) {
|
|
outcomeWeight = GHIDRA_CAST<int *>((GHIDRA_INT(picker) + 4 + uVar1 * 8));
|
|
*outcomeWeight = *outcomeWeight + 1;
|
|
if (*outcomeWeight < 0) {
|
|
*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(picker) + 4 + uVar1 * 8)) = 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) {
|
|
std::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<int *>((GHIDRA_CAST<char *>(picker) + uVar1 * 8)) == 2) {
|
|
outcomeWeight = GHIDRA_CAST<int *>((GHIDRA_INT(picker) + 4 + uVar1 * 8));
|
|
*outcomeWeight = *outcomeWeight + 1;
|
|
if (*outcomeWeight < 0) {
|
|
*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(picker) + 4 + uVar1 * 8)) = 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) {
|
|
std::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 = (GHIDRA_CAST<WeightedOutcomePicker *>((&picker)))->WeightedOutcomePicker::PickOutcome(rng);
|
|
target = (GHIDRA_CAST<Entity_NPC *>((npc)))->Entity_NPC::GetPlayerTarget();
|
|
local_28 = GHIDRA_CAST<undefined4 *>(((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<undefined4 *>(((float)local_28 * (1.0 / targetDist)));
|
|
targetDirY = targetDirY * (1.0 / targetDist);
|
|
}
|
|
*GHIDRA_CAST<undefined1 *>((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<int *>((GHIDRA_INT((npc->_entityDeque)._map) +
|
|
((npc->_entityDeque)._mapSize - 1 & uVar1 >> 2) * 4));
|
|
childSlot = GHIDRA_CAST<float *>((dequeBlock + uVar3 * 4));
|
|
if (*GHIDRA_CAST<int *>((dequeBlock + uVar3 * 4)) != 0) {
|
|
local_2c = childSlot;
|
|
std::multiset<unsigned_int>::erase(&local_2c);
|
|
}
|
|
*childSlot = fStack_40;
|
|
if (fStack_40 != 0.0) {
|
|
std::multiset<unsigned_int>::insert(childSlot);
|
|
}
|
|
if (-0.2 <= targetDirY) {
|
|
if (0.0 <= (float)local_28) {
|
|
animName = "Attack1Right";
|
|
}
|
|
else {
|
|
animName = "Attack1Left";
|
|
}
|
|
LAB_004b9068:
|
|
(GHIDRA_CAST<ANM2 *>((&npc->_sprite)))->ANM2::Play(GHIDRA_CAST<byte *>(animName),0);
|
|
}
|
|
else {
|
|
animName = "Attack1Left_Back";
|
|
if (0.0 <= (float)local_28) {
|
|
animName = "Attack1Right_Back";
|
|
}
|
|
(GHIDRA_CAST<ANM2 *>((&npc->_sprite)))->ANM2::Play(GHIDRA_CAST<byte *>(animName),0);
|
|
*GHIDRA_CAST<undefined1 *>((GHIDRA_INT(&npc->_projectileDelay) + 3)) = 0;
|
|
}
|
|
}
|
|
else {
|
|
if (uVar1 != 1) {
|
|
if (uVar1 == 2) {
|
|
(GHIDRA_CAST<ANM2 *>((&npc->_sprite)))->ANM2::Play(s_Attack2,0);
|
|
npc->_state = 9;
|
|
*GHIDRA_CAST<undefined1 *>(&npc->_projectileCooldown) = 0x96;
|
|
}
|
|
goto LAB_004b9077;
|
|
}
|
|
local_2c = GHIDRA_CAST<float *>(hornfel_pick_spawn(extraout_ECX));
|
|
uVar1 = (npc->_entityDeque)._offset;
|
|
uVar3 = uVar1 & 3;
|
|
dequeBlock = *GHIDRA_CAST<int *>((GHIDRA_INT((npc->_entityDeque)._map) +
|
|
((npc->_entityDeque)._mapSize - 1 & uVar1 >> 2) * 4));
|
|
firstChildSlot = GHIDRA_CAST<undefined4 *>((dequeBlock + uVar3 * 4));
|
|
uVar2 = 0;
|
|
if (*GHIDRA_CAST<int *>((dequeBlock + uVar3 * 4)) != 0) {
|
|
local_28 = firstChildSlot;
|
|
std::multiset<unsigned_int>::erase(&local_28);
|
|
uVar2 = extraout_ECX_00;
|
|
}
|
|
*firstChildSlot = local_2c;
|
|
if (local_2c != GHIDRA_CAST<float *>(0x0)) {
|
|
std::multiset<unsigned_int>::insert(firstChildSlot);
|
|
uVar2 = extraout_ECX_01;
|
|
}
|
|
local_28 = GHIDRA_CAST<undefined4 *>(hornfel_pick_spawn(uVar2));
|
|
uVar1 = (npc->_entityDeque)._offset + 1;
|
|
uVar3 = uVar1 & 3;
|
|
dequeBlock = *GHIDRA_CAST<int *>((GHIDRA_INT((npc->_entityDeque)._map) +
|
|
((npc->_entityDeque)._mapSize - 1 & uVar1 >> 2) * 4));
|
|
childSlot = GHIDRA_CAST<float *>((dequeBlock + uVar3 * 4));
|
|
if (*GHIDRA_CAST<int *>((dequeBlock + uVar3 * 4)) != 0) {
|
|
local_2c = childSlot;
|
|
std::multiset<unsigned_int>::erase(&local_2c);
|
|
}
|
|
*childSlot = (float)local_28;
|
|
if (local_28 != GHIDRA_CAST<undefined4 *>(0x0)) {
|
|
std::multiset<unsigned_int>::insert(childSlot);
|
|
}
|
|
if (-0.2 <= targetDirY) {
|
|
animName = "Attack1Double";
|
|
goto LAB_004b9068;
|
|
}
|
|
(GHIDRA_CAST<ANM2 *>((&npc->_sprite)))->ANM2::Play(GHIDRA_CAST<byte *>("Attack1Double_Back"),0);
|
|
*GHIDRA_CAST<undefined1 *>((GHIDRA_INT(&npc->_projectileDelay) + 3)) = 0;
|
|
}
|
|
npc->_state = 8;
|
|
LAB_004b9077:
|
|
*GHIDRA_CAST<undefined1 *>((GHIDRA_INT(&npc->_projectileDelay) + 2)) = 0;
|
|
if (picker != (WeightedOutcomePicker)0x0) {
|
|
uVar1 = GHIDRA_INT(outcomesCapacity) - GHIDRA_INT(picker) & 0xfffffff8;
|
|
ptr = picker;
|
|
if (0xfff < uVar1) {
|
|
ptr = *GHIDRA_CAST<WeightedOutcomePicker *>((GHIDRA_CAST<char *>(picker) + -4));
|
|
uVar1 = uVar1 + 0x23;
|
|
if (0x1f < (GHIDRA_INT(picker) - GHIDRA_INT(ptr)) - 4U) {
|
|
/* WARNING: Subroutine does not return */
|
|
_invalid_parameter_noinfo_noreturn();
|
|
}
|
|
}
|
|
operator_delete((void *)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;
|
|
EntityPtr *refSlot;
|
|
|
|
fVar3 = targetPos->y;
|
|
deltaX = (npc->_pos).x - targetPos->x;
|
|
npcPosY = (npc->_pos).y - fVar3;
|
|
targetPos = GHIDRA_CAST<Vector *>(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<Vector *>(((float)targetPos - (npc->_pos).x));
|
|
npcPosY = sqrtf(fVar3 * fVar3 + (float)targetPos * (float)targetPos);
|
|
if (0.0 < npcPosY) {
|
|
targetPos = GHIDRA_CAST<Vector *>(((float)targetPos * (1.0 / npcPosY)));
|
|
fVar3 = fVar3 * (1.0 / npcPosY);
|
|
}
|
|
targetPos = GHIDRA_CAST<Vector *>(((float)targetPos * launchSpeed));
|
|
refSlot = &pEVar2->_spawnerEntity;
|
|
if (*refSlot != (EntityPtr)0x0) {
|
|
entity = GHIDRA_CAST<Entity *>(refSlot);
|
|
std::multiset<unsigned_int>::erase(&entity);
|
|
}
|
|
*refSlot = (EntityPtr)npc;
|
|
if (npc != GHIDRA_CAST<Entity_NPC *>(0x0)) {
|
|
std::multiset<unsigned_int>::insert(refSlot);
|
|
}
|
|
refSlot = &pEVar2->_parent;
|
|
pEVar2->_spawnerType = npc->_type;
|
|
pEVar2->_spawnerVariant = npc->_variant;
|
|
if (*refSlot != (EntityPtr)0x0) {
|
|
entity = GHIDRA_CAST<Entity *>(refSlot);
|
|
std::multiset<unsigned_int>::erase(&entity);
|
|
}
|
|
*refSlot = (EntityPtr)npc;
|
|
std::multiset<unsigned_int>::insert(refSlot);
|
|
pEVar2->_entityCollisionClass = 4;
|
|
pEVar2->_visible = 1;
|
|
pEVar2[1]._damageEvents._end = (void *)0xc0800000;
|
|
(pEVar2->_posOffset).x = 0.0;
|
|
(pEVar2->_posOffset).y = -24.0;
|
|
(pEVar2->_pos).x = (npc->_pos).x;
|
|
npcPosY = (npc->_pos).y;
|
|
*GHIDRA_CAST<uint *>(&pEVar2->_flags) = GHIDRA_UINT(pEVar2->_flags) & 0xffffffdf;
|
|
(pEVar2->_pos).y = npcPosY;
|
|
*GHIDRA_CAST<undefined4 *>((GHIDRA_INT(&pEVar2->_flags) + 4)) = *GHIDRA_CAST<undefined4 *>((GHIDRA_INT(&pEVar2->_flags) + 4));
|
|
iVar1 = *GHIDRA_CAST<int *>(pEVar2);
|
|
(pEVar2->_velocity).x = (float)targetPos;
|
|
(pEVar2->_velocity).y = fVar3 * launchSpeed;
|
|
(**(code **)(iVar1 + 0xc))();
|
|
return;
|
|
}
|
|
|
|
// 004bb350
|
|
Entity * NpcHelper::hornfel_free_door()
|
|
{
|
|
uint rngResult;
|
|
int *candidatesEnd;
|
|
float fVar1;
|
|
float fVar2;
|
|
int *candidatesEndCopy;
|
|
int railDoor;
|
|
uint i;
|
|
void *local_10;
|
|
undefined1 *puStack_c;
|
|
undefined4 local_8;
|
|
char *currentRoom;
|
|
int enterDoor;
|
|
void *room;
|
|
|
|
puStack_c = &LAB_00af34dd;
|
|
local_10 = ExceptionList;
|
|
ExceptionList = &local_10;
|
|
candidatesEnd = GHIDRA_CAST<int *>(0x0);
|
|
candidatesEndCopy = GHIDRA_CAST<int *>(0x0);
|
|
room = g_game->_room;
|
|
local_8 = 0;
|
|
i = 0;
|
|
if (*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(room) + 0x1264)) != 0) {
|
|
do {
|
|
railDoor = *GHIDRA_CAST<int *>((*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(room) + 0x125c)) + i * 4));
|
|
if (((*GHIDRA_CAST<int *>((railDoor + 0x28)) == 0x3c7) && (*GHIDRA_CAST<int *>((railDoor + 0x3c4)) == 0)) &&
|
|
((*GHIDRA_CAST<int *>((railDoor + 0x3bc)) == 0 || (*GHIDRA_CAST<int *>((*GHIDRA_CAST<int *>((railDoor + 0x3bc)) + 0x3c4)) == 0))))
|
|
{
|
|
currentRoom = g_game->_room;
|
|
if (((*currentRoom == '\0') || (g_game->_frameCount - *GHIDRA_CAST<int *>((currentRoom + 0x11f0)) < 0x1e)
|
|
) && (enterDoor = g_game->_enterDoor, -1 < enterDoor)) {
|
|
if (enterDoor < 8) {
|
|
fVar1 = (float)(*GHIDRA_CAST<int *>((currentRoom + enterDoor * 4 + 0x744)) %
|
|
*GHIDRA_CAST<int *>((currentRoom + 0xc))) * 40.0 + 40.0;
|
|
fVar2 = (float)(*GHIDRA_CAST<int *>((currentRoom + enterDoor * 4 + 0x744)) /
|
|
*GHIDRA_CAST<int *>((currentRoom + 0xc))) * 40.0 + 120.0;
|
|
}
|
|
else {
|
|
fVar1 = g_vectorZero.x;
|
|
fVar2 = g_vectorZero.y;
|
|
}
|
|
fVar1 = *GHIDRA_CAST<float *>((railDoor + 0x33c)) - fVar1;
|
|
fVar2 = *GHIDRA_CAST<float *>((railDoor + 0x340)) - fVar2;
|
|
if (fVar2 * fVar2 + fVar1 * fVar1 <= 3600.0) goto LAB_004bb4af;
|
|
}
|
|
if (candidatesEnd == GHIDRA_CAST<int *>(0x0)) {
|
|
std::vector<unsigned_int>::_Emplace_reallocate(0,&railDoor);
|
|
candidatesEnd = candidatesEndCopy;
|
|
}
|
|
else {
|
|
*candidatesEnd = railDoor;
|
|
candidatesEndCopy = candidatesEnd + 1;
|
|
candidatesEnd = candidatesEndCopy;
|
|
}
|
|
}
|
|
LAB_004bb4af:
|
|
i = i + 1;
|
|
} while (i < *GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(room) + 0x1264)));
|
|
if (candidatesEnd != GHIDRA_CAST<int *>(0x0)) {
|
|
if (GHIDRA_INT(candidatesEnd) >> 2 == 0) {
|
|
ExceptionList = local_10;
|
|
return pERam00000000;
|
|
}
|
|
rngResult = Random();
|
|
ExceptionList = local_10;
|
|
return *GHIDRA_CAST<Entity **>(((rngResult % GHIDRA_UINT((GHIDRA_INT(candidatesEnd) >> 2))) * 4));
|
|
}
|
|
}
|
|
ExceptionList = local_10;
|
|
return GHIDRA_CAST<Entity *>(0x0);
|
|
}
|
|
|
|
// 004bb550
|
|
Vector * NpcHelper::hornfel_get_rail_direction(Entity_NPC *npc, Vector *outDirection)
|
|
{
|
|
int gridY;
|
|
uint railSign;
|
|
uint gridIdx;
|
|
int gridX;
|
|
byte 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<int *>((GHIDRA_CAST<char *>(room) + 0xc)))) &&
|
|
(gridY = GHIDRA_INT((((npc->_targetPosition).y - 120.0) / 40.0 + 0.5)), -1 < gridY)) &&
|
|
(((gridY < *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(room) + 0x10)) &&
|
|
(gridIdx = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(room) + 0xc)) * gridY + gridX, gridIdx < 0x1c0)) &&
|
|
(railFlags = *GHIDRA_CAST<byte *>((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<byte *>((GHIDRA_CAST<char *>(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;
|
|
uint railDirection;
|
|
uint gridIndex;
|
|
int iVar1;
|
|
undefined1 *directionSign;
|
|
Vector nextPos;
|
|
byte 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<undefined1 *>(0x3f800000);
|
|
}
|
|
nextPos.x = (float)directionSign * 40.0 + (npc->_targetPosition).x;
|
|
nextPos.y = (npc->_targetPosition).y + 0.0;
|
|
iVar1 = (GHIDRA_CAST<Room *>((room)))->Room::GetGridIndex(&nextPos);
|
|
return iVar1;
|
|
}
|
|
if (GHIDRA_INT(railDirection) < 0) {
|
|
directionSign = &DAT_bf800000;
|
|
}
|
|
else {
|
|
directionSign = GHIDRA_CAST<undefined1 *>(0x3f800000);
|
|
}
|
|
nextPos.x = (npc->_targetPosition).x + 0.0;
|
|
nextPos.y = (float)directionSign * 40.0 + (npc->_targetPosition).y;
|
|
iVar1 = (GHIDRA_CAST<Room *>((room)))->Room::GetGridIndex(&nextPos);
|
|
return iVar1;
|
|
}
|
|
}
|
|
return -1;
|
|
}
|
|
|
|
// 004bb830
|
|
void NpcHelper::hornfel_set_anim(Entity_NPC *npc, int stateFrame)
|
|
{
|
|
byte bVar1;
|
|
byte *curAnimChar;
|
|
uint animCompare;
|
|
byte *openAnimChar;
|
|
bool isLess;
|
|
int soundId;
|
|
byte *animData;
|
|
Manager *manager;
|
|
|
|
if (npc->_state != 3) goto LAB_004bb903;
|
|
animData = (npc->_sprite)._animState._animData;
|
|
if (animData == GHIDRA_CAST<byte *>(0x0)) {
|
|
LAB_004bb896:
|
|
bVar1 = (GHIDRA_CAST<ANM2 *>((&npc->_sprite)))->ANM2::SetAnimation(s_Open,1);
|
|
if (bVar1 != 0) {
|
|
(GHIDRA_CAST<AnimationState *>((&(npc->_sprite)._animState)))->AnimationState::Rewind();
|
|
(npc->_sprite)._animState._isPlaying = 1;
|
|
}
|
|
}
|
|
else {
|
|
curAnimChar = animData;
|
|
if (0xf < *GHIDRA_CAST<uint *>((animData + 0x14))) {
|
|
curAnimChar = *GHIDRA_CAST<byte **>(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<SoundEffects *>((&manager->_sfxManager)))->SoundEffects::Play(soundId,0.5,10,0,1.3,0.0);
|
|
npc->_state = 4;
|
|
LAB_004bb903:
|
|
npc->_stateFrame = stateFrame;
|
|
return;
|
|
}
|
|
|
|
// 004bb920
|
|
byte NpcHelper::hornfel_claim_target(Entity_NPC *npc, Entity *target)
|
|
{
|
|
EntityPtr EVar1;
|
|
Entity *parentTargetRef;
|
|
Entity *targetLocal;
|
|
|
|
targetLocal = target;
|
|
if ((npc->_target != (EntityPtr)0x0) ||
|
|
((EVar1 = npc->_parent, EVar1 != (EntityPtr)0x0 && (*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(EVar1) + 0x3c4)) != 0)))) {
|
|
return 0;
|
|
}
|
|
npc->_target = (EntityPtr)target;
|
|
if (target != GHIDRA_CAST<Entity *>(0x0)) {
|
|
std::multiset<unsigned_int>::insert(&npc->_target);
|
|
EVar1 = npc->_parent;
|
|
}
|
|
if (EVar1 != (EntityPtr)0x0) {
|
|
parentTargetRef = GHIDRA_CAST<Entity *>((GHIDRA_INT(EVar1) + 0x3c4));
|
|
if (*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(EVar1) + 0x3c4)) != 0) {
|
|
target = parentTargetRef;
|
|
std::multiset<unsigned_int>::erase(&target);
|
|
}
|
|
*GHIDRA_CAST<Entity **>(parentTargetRef) = targetLocal;
|
|
if (targetLocal != GHIDRA_CAST<Entity *>(0x0)) {
|
|
std::multiset<unsigned_int>::insert(parentTargetRef);
|
|
}
|
|
}
|
|
return 1;
|
|
}
|
|
|
|
// 004bc460
|
|
void NpcHelper::hornfel_room_controller(Entity_Effect *effect)
|
|
{
|
|
undefined4 uVar1;
|
|
uint uVar2;
|
|
Entity_NPC *npc;
|
|
uint uVar3;
|
|
Entity *cart;
|
|
int iVar4;
|
|
Vector railDirection;
|
|
uint 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<byte *>((*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(room) + 4)) + 0x44)) & 1) != 0) {
|
|
hornfel_remove_doors();
|
|
effect->Remove();
|
|
}
|
|
roomWidth = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(room) + 0x12cc)) + *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(room) + 0x12c8));
|
|
iVar4 = 0;
|
|
if (0 < roomWidth) {
|
|
iVar4 = roomWidth;
|
|
}
|
|
if ((0 < iVar4) && (effect->_dead != 0)) {
|
|
npc = GHIDRA_CAST<Entity_NPC *>(hornfel_free_door());
|
|
if (npc != GHIDRA_CAST<Entity_NPC *>(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 = (GHIDRA_CAST<Game *>((g_game)))->Game::SpawnEx(cartTypeChoices[(uVar2 % 7) * 2],
|
|
cartTypeChoices[(uVar2 % 7) * 2 + 1],&g_vectorZero,&g_vectorZero,
|
|
GHIDRA_CAST<Entity *>(0x0),0,uVar3,0);
|
|
uVar1 = *GHIDRA_CAST<undefined4 *>((GHIDRA_INT(&cart->_flags) + 4));
|
|
*GHIDRA_CAST<uint *>(&cart->_flags) = GHIDRA_UINT(cart->_flags) & 0xfffffffb;
|
|
*GHIDRA_CAST<undefined4 *>((GHIDRA_INT(&cart->_flags) + 4)) = uVar1;
|
|
cart->_spawnerType = 0x38a;
|
|
(GHIDRA_CAST<Entity *>((cart)))->Entity::GiveMinecart(&npc->_targetPosition,&railDirection);
|
|
hornfel_claim_target(npc,cart);
|
|
}
|
|
}
|
|
uVar2 = Random();
|
|
uVar2 = uVar2 % 0xd2 + 0x96;
|
|
iVar4 = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(g_game->_room) + 0x10));
|
|
roomWidth = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(g_game->_room) + 0xc));
|
|
effect->_dead = 0;
|
|
uVar3 = uVar2 / 2;
|
|
if (iVar4 * roomWidth < 0x88) {
|
|
uVar3 = uVar2;
|
|
}
|
|
effect->_timeout = uVar3;
|
|
effect->_lifespan = uVar3;
|
|
}
|
|
return;
|
|
}
|
|
|
|
// 004bc680
|
|
byte NpcHelper::horny_boys_pick_position(Entity_NPC *npc)
|
|
{
|
|
Entity_Player *nearestPlayer;
|
|
Game *game;
|
|
int gridWidth;
|
|
int iVar1;
|
|
int gridX;
|
|
uint 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 {
|
|
(GHIDRA_CAST<Room *>((game->_room)))->Room::GetRandomPosition(&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<int *>((GHIDRA_CAST<char *>(room) + 0xc)), gridWidth <= gridX)) || (iVar1 < 0)
|
|
) || (*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(room) + 0x10)) <= iVar1)) {
|
|
gridWidth = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(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 = (GHIDRA_CAST<Game *>((g_game)))->Game::GetNearestPlayer(&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<int *>((GHIDRA_CAST<char *>(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;
|
|
uint uVar2;
|
|
uint blockSlot;
|
|
Entity *pEVar3;
|
|
float fVar4;
|
|
float dx;
|
|
EntityPtr *local_c;
|
|
float local_8;
|
|
EntityPtr *parentSlot;
|
|
undefined4 *ringSlot;
|
|
|
|
local_c = GHIDRA_CAST<EntityPtr *>((npc->_entityDeque)._offset);
|
|
uVar2 = GHIDRA_UINT((&(*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>((local_c)) + 0x0))) + slot)) >> 2;
|
|
blockSlot = GHIDRA_UINT((&(*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>((local_c)) + 0x0))) + slot)) & 3;
|
|
if (*GHIDRA_CAST<int *>((*GHIDRA_CAST<int *>((GHIDRA_INT((npc->_entityDeque)._map) +
|
|
((npc->_entityDeque)._mapSize - 1 & uVar2) * 4)) + blockSlot * 4)) == 0) {
|
|
return GHIDRA_CAST<Entity *>(0x0);
|
|
}
|
|
pEVar3 = *(Entity **)
|
|
(*GHIDRA_CAST<int *>((GHIDRA_INT((npc->_entityDeque)._map) + ((npc->_entityDeque)._mapSize - 1 & uVar2) * 4
|
|
)) + blockSlot * 4);
|
|
if ((pEVar3 == GHIDRA_CAST<Entity *>(0x0)) || (pEVar3->_type != 4)) {
|
|
pEVar3 = GHIDRA_CAST<Entity *>(0x0);
|
|
}
|
|
else {
|
|
dx = (npc->_pos).x - targetPos->x;
|
|
local_8 = targetPos->y;
|
|
fVar4 = (npc->_pos).y - local_8;
|
|
targetPos = GHIDRA_CAST<Vector *>(targetPos->x);
|
|
fVar4 = sqrtf(fVar4 * fVar4 + dx * dx);
|
|
targetPos = GHIDRA_CAST<Vector *>(((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<EntityPtr *>((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<Vector *>(((1.0 / fVar4) * (float)targetPos));
|
|
}
|
|
targetPos = GHIDRA_CAST<Vector *>(((float)targetPos * (float)local_c));
|
|
parentSlot = &pEVar3->_parent;
|
|
local_8 = local_8 * (float)local_c;
|
|
if (*parentSlot != (EntityPtr)0x0) {
|
|
local_c = parentSlot;
|
|
std::multiset<unsigned_int>::erase(&local_c);
|
|
}
|
|
*parentSlot = (EntityPtr)npc;
|
|
if (npc != GHIDRA_CAST<Entity_NPC *>(0x0)) {
|
|
std::multiset<unsigned_int>::insert(parentSlot);
|
|
}
|
|
pEVar3->_entityCollisionClass = 4;
|
|
pEVar3->_visible = 1;
|
|
pEVar3[1]._damageEvents._end = (void *)0xc0800000;
|
|
(pEVar3->_posOffset).x = 0.0;
|
|
(pEVar3->_posOffset).y = -24.0;
|
|
(pEVar3->_pos).x = (npc->_pos).x;
|
|
fVar4 = (npc->_pos).y;
|
|
*GHIDRA_CAST<uint *>(&pEVar3->_flags) = GHIDRA_UINT(pEVar3->_flags) & 0xffffffdf;
|
|
(pEVar3->_pos).y = fVar4;
|
|
*GHIDRA_CAST<undefined4 *>((GHIDRA_INT(&pEVar3->_flags) + 4)) = *GHIDRA_CAST<undefined4 *>((GHIDRA_INT(&pEVar3->_flags) + 4));
|
|
iVar1 = *GHIDRA_CAST<int *>(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<int *>((GHIDRA_INT((npc->_entityDeque)._map) +
|
|
(uVar2 >> 2 & (npc->_entityDeque)._mapSize - 1) * 4));
|
|
ringSlot = GHIDRA_CAST<undefined4 *>((iVar1 + blockSlot * 4));
|
|
if (*GHIDRA_CAST<int *>((iVar1 + blockSlot * 4)) != 0) {
|
|
slot = GHIDRA_INT(ringSlot);
|
|
std::multiset<unsigned_int>::erase(&slot);
|
|
}
|
|
*ringSlot = 0;
|
|
return pEVar3;
|
|
}
|
|
|
|
// 004bcc70
|
|
Entity * NpcHelper::horny_boys_spawn_bomb(Entity_NPC *npc, int slot)
|
|
{
|
|
int iVar1;
|
|
RNG rng;
|
|
undefined1 *puVar2;
|
|
EntityPtr EVar3;
|
|
uint uVar4;
|
|
WeightedOutcomePicker ptr;
|
|
uint uVar5;
|
|
BitSet128 bombTearFlags0;
|
|
undefined8 uStack_3c;
|
|
EntityPtr *pEStack_34;
|
|
WeightedOutcomePicker picker;
|
|
undefined4 *outcomesEnd;
|
|
undefined4 *outcomesCapacity;
|
|
uint local_24;
|
|
undefined1 *puStack_20;
|
|
void *local_1c;
|
|
undefined *puStack_18;
|
|
undefined4 local_14;
|
|
EntityPtr *bombSlot;
|
|
int *outcomeWeight;
|
|
|
|
puStack_20 = GHIDRA_CAST<undefined1 *>((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;
|
|
uVar4 = slot + (npc->_entityDeque)._offset;
|
|
uVar5 = uVar4 >> 2;
|
|
uVar4 = uVar4 & 3;
|
|
puVar2 = GHIDRA_CAST<undefined1 *>((GHIDRA_INT(register0x00000010) + -4));
|
|
if (*GHIDRA_CAST<int *>((*GHIDRA_CAST<int *>((GHIDRA_INT((npc->_entityDeque)._map) +
|
|
((npc->_entityDeque)._mapSize - 1 & uVar5) * 4)) + uVar4 * 4)) != 0) {
|
|
pEStack_34 = GHIDRA_CAST<EntityPtr *>((npc->_entityDeque)._offset);
|
|
(**(code **)(**GHIDRA_CAST<int **>((*GHIDRA_CAST<int *>((GHIDRA_INT((npc->_entityDeque)._map) +
|
|
((npc->_entityDeque)._mapSize - 1 & uVar5) * 4)) + uVar4 * 4)) +
|
|
0x28))(local_24);
|
|
puVar2 = puStack_20;
|
|
}
|
|
puStack_20 = puVar2;
|
|
picker = (WeightedOutcomePicker)0x0;
|
|
outcomesEnd = GHIDRA_CAST<undefined4 *>(0x0);
|
|
outcomesCapacity = GHIDRA_CAST<undefined4 *>(0x0);
|
|
local_14 = 0;
|
|
uStack_3c = (ulonglong)GHIDRA_UINT(uStack_3c);
|
|
pEStack_34 = GHIDRA_CAST<EntityPtr *>(0x6);
|
|
std::vector<8byte>::_Emplace_reallocate(0,GHIDRA_INT(&uStack_3c) + 4);
|
|
uVar4 = 0;
|
|
uVar5 = GHIDRA_INT(outcomesEnd) - GHIDRA_INT(picker) >> 3;
|
|
if (uVar5 != 0) {
|
|
do {
|
|
if (*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(picker) + uVar4 * 8)) == 8) {
|
|
outcomeWeight = GHIDRA_CAST<int *>((GHIDRA_INT(picker) + 4 + uVar4 * 8));
|
|
*outcomeWeight = *outcomeWeight + 3;
|
|
if (*outcomeWeight < 0) {
|
|
*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(picker) + 4 + uVar4 * 8)) = 0;
|
|
}
|
|
goto LAB_004bcda7;
|
|
}
|
|
uVar4 = uVar4 + 1;
|
|
} while (uVar4 < uVar5);
|
|
}
|
|
uStack_3c = CONCAT44(8,GHIDRA_UINT(uStack_3c));
|
|
pEStack_34 = GHIDRA_CAST<EntityPtr *>(0x3);
|
|
if (outcomesEnd == outcomesCapacity) {
|
|
std::vector<8byte>::_Emplace_reallocate(outcomesEnd,GHIDRA_INT(&uStack_3c) + 4);
|
|
}
|
|
else {
|
|
*outcomesEnd = 8;
|
|
outcomesEnd[1] = 3;
|
|
outcomesEnd = outcomesEnd + 2;
|
|
}
|
|
LAB_004bcda7:
|
|
uVar4 = 0;
|
|
uVar5 = GHIDRA_INT(outcomesEnd) - GHIDRA_INT(picker) >> 3;
|
|
if (uVar5 != 0) {
|
|
do {
|
|
if (*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(picker) + uVar4 * 8)) == 0x10) {
|
|
outcomeWeight = GHIDRA_CAST<int *>((GHIDRA_INT(picker) + 4 + uVar4 * 8));
|
|
*outcomeWeight = *outcomeWeight + 1;
|
|
if (*outcomeWeight < 0) {
|
|
*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(picker) + 4 + uVar4 * 8)) = 0;
|
|
}
|
|
goto LAB_004bce05;
|
|
}
|
|
uVar4 = uVar4 + 1;
|
|
} while (uVar4 < uVar5);
|
|
}
|
|
uStack_3c = CONCAT44(0x10,GHIDRA_UINT(uStack_3c));
|
|
pEStack_34 = GHIDRA_CAST<EntityPtr *>(0x1);
|
|
if (outcomesEnd == outcomesCapacity) {
|
|
std::vector<8byte>::_Emplace_reallocate(outcomesEnd,GHIDRA_INT(&uStack_3c) + 4);
|
|
}
|
|
else {
|
|
*outcomesEnd = 0x10;
|
|
outcomesEnd[1] = 1;
|
|
outcomesEnd = outcomesEnd + 2;
|
|
}
|
|
LAB_004bce05:
|
|
uVar4 = Random();
|
|
uStack_3c = 0x900000005;
|
|
pEStack_34 = GHIDRA_CAST<EntityPtr *>(&DAT_00000007);
|
|
rng._shift1 = 5;
|
|
rng._seed = uVar4 | 1;
|
|
rng._shift2 = 9;
|
|
rng._shift3 = 7;
|
|
uVar4 = (GHIDRA_CAST<WeightedOutcomePicker *>((&picker)))->WeightedOutcomePicker::PickOutcome(rng);
|
|
bombTearFlags0 = (BitSet128)ZEXT816(0);
|
|
if (uVar4 == 8) {
|
|
bombTearFlags0 = g_tearFlagBurn;
|
|
}
|
|
else if (uVar4 == 0x10) {
|
|
bombTearFlags0 = g_tearFlagSadBomb;
|
|
}
|
|
else {
|
|
}
|
|
uVar5 = Random();
|
|
EVar3 = (EntityPtr)(GHIDRA_CAST<Game *>((g_game)))->Game::Spawn(4,uVar4,&npc->_pos,&g_vectorZero,GHIDRA_CAST<Entity *>(npc),0,uVar5);
|
|
*GHIDRA_CAST<byte *>((GHIDRA_CAST<char *>(EVar3) + 0x171)) = 0;
|
|
*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(EVar3) + 0x188)) = 0;
|
|
*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(EVar3) + 0x184)) = 0;
|
|
if (*GHIDRA_CAST<EntityPtr *>((GHIDRA_CAST<char *>(EVar3) + 0x3bc)) != (EntityPtr)0x0) {
|
|
pEStack_34 = GHIDRA_CAST<EntityPtr *>((GHIDRA_INT(EVar3) + 0x3bc));
|
|
std::multiset<unsigned_int>::erase(&pEStack_34);
|
|
}
|
|
*GHIDRA_CAST<EntityPtr *>((GHIDRA_CAST<char *>(EVar3) + 0x3bc)) = (EntityPtr)npc;
|
|
if (npc != GHIDRA_CAST<Entity_NPC *>(0x0)) {
|
|
std::multiset<unsigned_int>::insert(GHIDRA_CAST<EntityPtr *>((GHIDRA_INT(EVar3) + 0x3bc)));
|
|
}
|
|
*GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(EVar3) + 0x168)) = *GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(EVar3) + 0x168)) | 0x20;
|
|
*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(EVar3) + 0x16c)) = *GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(EVar3) + 0x16c));
|
|
iVar1 = *GHIDRA_CAST<int *>(EVar3);
|
|
*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(EVar3) + 0x410)) = 0x23;
|
|
*GHIDRA_CAST<undefined4 *>(&(*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(((GHIDRA_CAST<Entity *>((GHIDRA_INT(EVar3) + 0x410))))) + 0x4)))) = 0x23;
|
|
(GHIDRA_CAST<Entity *>((GHIDRA_INT(EVar3) + 0x410)))->_type = GHIDRA_INT(bombTearFlags0._l);
|
|
(GHIDRA_CAST<Entity *>((GHIDRA_INT(EVar3) + 0x410)))->_variant = (*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(bombTearFlags0._l)) + 0x4)));
|
|
(GHIDRA_CAST<Entity *>((GHIDRA_INT(EVar3) + 0x410)))->_subtype = GHIDRA_INT(bombTearFlags0._h);
|
|
(GHIDRA_CAST<Entity *>((GHIDRA_INT(EVar3) + 0x410)))->_spawnerType = (*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(bombTearFlags0._h)) + 0x4)));
|
|
((GHIDRA_CAST<Entity *>((GHIDRA_INT(EVar3) + 0x410)))->_sprite)._filename._buf[0xb] = '\x01';
|
|
(**(code **)(iVar1 + 0xc))();
|
|
pEStack_34 = GHIDRA_CAST<EntityPtr *>((npc->_entityDeque)._offset);
|
|
uVar4 = GHIDRA_INT(&(*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>((pEStack_34)) + 0x0)))) + slot;
|
|
uVar5 = uVar4 & 3;
|
|
iVar1 = *GHIDRA_CAST<int *>((GHIDRA_INT((npc->_entityDeque)._map) +
|
|
(uVar4 >> 2 & (npc->_entityDeque)._mapSize - 1) * 4));
|
|
bombSlot = GHIDRA_CAST<EntityPtr *>((iVar1 + uVar5 * 4));
|
|
if (*GHIDRA_CAST<int *>((iVar1 + uVar5 * 4)) != 0) {
|
|
pEStack_34 = bombSlot;
|
|
std::multiset<unsigned_int>::erase(&pEStack_34);
|
|
}
|
|
*bombSlot = EVar3;
|
|
std::multiset<unsigned_int>::insert(bombSlot);
|
|
if (picker != (WeightedOutcomePicker)0x0) {
|
|
uVar4 = GHIDRA_INT(outcomesCapacity) - GHIDRA_INT(picker) & 0xfffffff8;
|
|
ptr = picker;
|
|
if (0xfff < uVar4) {
|
|
ptr = *GHIDRA_CAST<WeightedOutcomePicker *>((GHIDRA_CAST<char *>(picker) + -4));
|
|
uVar4 = uVar4 + 0x23;
|
|
if (0x1f < (GHIDRA_INT(picker) - GHIDRA_INT(ptr)) - 4U) {
|
|
/* WARNING: Subroutine does not return */
|
|
_invalid_parameter_noinfo_noreturn();
|
|
}
|
|
}
|
|
operator_delete((void *)ptr,uVar4);
|
|
}
|
|
ExceptionList = local_1c;
|
|
return GHIDRA_CAST<Entity *>(EVar3);
|
|
}
|
|
|
|
// 004bcfd0
|
|
void NpcHelper::horny_boys_render(Entity_NPC *npc, Vector *offset)
|
|
{
|
|
Vector *position;
|
|
int iVar1;
|
|
void *layerFrame;
|
|
AnimationState *secondState;
|
|
uint dequeIndex;
|
|
float renderScale;
|
|
double dVar2;
|
|
double dVar3;
|
|
uint layerIdx;
|
|
int layerOffset;
|
|
void *animData;
|
|
float offsetY;
|
|
|
|
(GHIDRA_CAST<Entity *>((GHIDRA_CAST<Entity *>(npc))))->Entity::Render(offset);
|
|
renderScale = g_displayPixelRatio * g_screenPointScale;
|
|
dVar2 = floor((double)(((((npc->_posOffset).x + (npc->_pos).x) - 60.0) * 0.65 +
|
|
(g_screenWidth - 338.0) * 0.5) * renderScale + 0.5));
|
|
dVar3 = floor((double)(((((npc->_pos).y + (npc->_posOffset).y) - 140.0) * 0.65 +
|
|
(g_screenHeight - 182.0) * 0.5) * renderScale + 0.5));
|
|
position = &npc->_renderPosition;
|
|
offsetY = offset->y;
|
|
position->x = (float)dVar2 / renderScale + offset->x;
|
|
(npc->_renderPosition).y = (float)dVar3 / renderScale + offsetY;
|
|
animData = (npc->_sprite)._animState._animData;
|
|
if ((animData != (void *)0x0) && (layerIdx = 0, *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(animData) + 0x1c)) != 0)) {
|
|
layerOffset = 0;
|
|
do {
|
|
iVar1 = *GHIDRA_CAST<int *>((layerOffset + *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(animData) + 0x18))));
|
|
layerFrame = (GHIDRA_CAST<AnimationState *>((&(npc->_sprite)._animState)))->AnimationState::GetLayerFrame(iVar1);
|
|
if ((((layerFrame != (void *)0x0) && (*GHIDRA_CAST<char *>((GHIDRA_CAST<char *>(layerFrame) + 0x2c)) != '\0')) &&
|
|
(iVar1 - 3U < 3)) &&
|
|
(dequeIndex = ((npc->_entityDeque)._offset - 3) + iVar1,
|
|
iVar1 = *GHIDRA_CAST<int *>((*GHIDRA_CAST<int *>((GHIDRA_INT((npc->_entityDeque)._map) +
|
|
(dequeIndex >> 2 & (npc->_entityDeque)._mapSize - 1) * 4)) +
|
|
(dequeIndex & 3) * 4)), iVar1 != 0)) {
|
|
*GHIDRA_CAST<undefined4 *>((iVar1 + 0xdc)) = *GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(layerFrame) + 0x10));
|
|
*GHIDRA_CAST<undefined4 *>((iVar1 + 0xe0)) = *GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(layerFrame) + 0x14));
|
|
*GHIDRA_CAST<undefined4 *>((iVar1 + 0xec)) = *GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(layerFrame) + 0x5c));
|
|
*GHIDRA_CAST<undefined4 *>((iVar1 + 0xe4)) = *GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(layerFrame) + 0x18));
|
|
*GHIDRA_CAST<undefined4 *>((iVar1 + 0xe8)) = *GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(layerFrame) + 0x1c));
|
|
if (*GHIDRA_CAST<char *>((iVar1 + 0x151)) != '\0') {
|
|
if (*GHIDRA_CAST<char *>((iVar1 + 0xb8)) == '\0') {
|
|
AnimationState::Render
|
|
(GHIDRA_CAST<AnimationState *>((iVar1 + 0x78)),position,&g_vectorZero,&g_vectorZero);
|
|
secondState = GHIDRA_CAST<AnimationState *>((iVar1 + 0x98));
|
|
}
|
|
else {
|
|
AnimationState::Render
|
|
(GHIDRA_CAST<AnimationState *>((iVar1 + 0x98)),position,&g_vectorZero,&g_vectorZero);
|
|
secondState = GHIDRA_CAST<AnimationState *>((iVar1 + 0x78));
|
|
}
|
|
AnimationState::Render(secondState,position,&g_vectorZero,&g_vectorZero);
|
|
}
|
|
*GHIDRA_CAST<float *>((iVar1 + 0xdc)) = g_vectorZero.x;
|
|
*GHIDRA_CAST<float *>((iVar1 + 0xe0)) = g_vectorZero.y;
|
|
*GHIDRA_CAST<undefined4 *>((iVar1 + 0xec)) = 0;
|
|
*GHIDRA_CAST<float *>((iVar1 + 0xe4)) = g_vectorOne.x;
|
|
*GHIDRA_CAST<float *>((iVar1 + 0xe8)) = g_vectorOne.y;
|
|
}
|
|
layerIdx = layerIdx + 1;
|
|
layerOffset = layerOffset + 0x10;
|
|
} while (layerIdx < *GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(animData) + 0x1c)));
|
|
}
|
|
return;
|
|
}
|
|
|
|
// 004be670
|
|
Entity * NpcHelper::query_nearest_other(void *queryList, Entity *exclude, Vector position)
|
|
{
|
|
int *entityIt;
|
|
Entity *pEVar1;
|
|
int remaining;
|
|
float fVar2;
|
|
float dy;
|
|
float nearestDistSq;
|
|
Entity *candidate;
|
|
|
|
remaining = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(queryList) + 0xc));
|
|
pEVar1 = GHIDRA_CAST<Entity *>(0x0);
|
|
nearestDistSq = 0.0;
|
|
if (remaining != 0) {
|
|
entityIt = *GHIDRA_CAST<int **>((GHIDRA_CAST<char *>(queryList) + 4));
|
|
do {
|
|
candidate = GHIDRA_CAST<Entity *>(*entityIt);
|
|
if ((candidate != exclude) &&
|
|
((dy = position.y - (candidate->_pos).y, fVar2 = position.x - (candidate->_pos).x,
|
|
fVar2 = dy * dy + fVar2 * fVar2, fVar2 < nearestDistSq || (pEVar1 == GHIDRA_CAST<Entity *>(0x0))))) {
|
|
pEVar1 = candidate;
|
|
nearestDistSq = fVar2;
|
|
}
|
|
entityIt = entityIt + 1;
|
|
remaining = remaining + -1;
|
|
} while (remaining != 0);
|
|
}
|
|
return pEVar1;
|
|
}
|
|
|
|
// 004cee90
|
|
void NpcHelper::minecart_break(Entity_NPC *minecart)
|
|
{
|
|
uint rngResult;
|
|
EntityPtr *local_44;
|
|
ColorMod particleColor;
|
|
float local_14;
|
|
Manager *manager;
|
|
|
|
local_14 = (float)(__security_cookie ^ GHIDRA_UINT(((&particleColor)[1]._tint + 1)));
|
|
minecart->Remove();
|
|
manager = g_manager;
|
|
local_44 = GHIDRA_CAST<EntityPtr *>(0x1e1);
|
|
seed_fart_sound_override(GHIDRA_CAST<int *>(&local_44));
|
|
(GHIDRA_CAST<SoundEffects *>((&manager->_sfxManager)))->SoundEffects::Play(GHIDRA_INT(local_44),1.0,10,0,1.0,0.0);
|
|
particleColor._tint[0] = 1.0;
|
|
particleColor._tint[1] = 1.0;
|
|
particleColor._tint[2] = 1.0;
|
|
particleColor._tint[3] = 1.0;
|
|
particleColor._colorize[0] = 0.0;
|
|
particleColor._colorize[1] = 0.0;
|
|
particleColor._colorize[2] = 0.0;
|
|
particleColor._colorize[3] = 0.0;
|
|
if (*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(g_game->_room) + 0x1d18)) == 0x2e) {
|
|
particleColor._tint[0] = 0.9;
|
|
particleColor._tint[1] = 0.9;
|
|
particleColor._tint[2] = 0.9;
|
|
particleColor._colorize[0] = 1.0;
|
|
particleColor._colorize[1] = 1.0;
|
|
particleColor._colorize[2] = 1.0;
|
|
particleColor._colorize[3] = 0.7;
|
|
}
|
|
particleColor._offset[0] = 0.0;
|
|
particleColor._offset[1] = 0.0;
|
|
particleColor._offset[2] = 0.0;
|
|
rngResult = Random();
|
|
local_44 = (EntityPtr *)
|
|
((float)((double)GHIDRA_INT(rngResult) + __uint_to_double_fixup[-(GHIDRA_INT(rngResult) >> 0x1f)]) *
|
|
2.3283064e-10 * 4.0 + 3.0);
|
|
rngResult = Random();
|
|
Game::SpawnParticles
|
|
(g_game,&minecart->_pos,0x1b,rngResult % 3 + 6,(float)local_44,&particleColor,100000.0,0
|
|
);
|
|
if (minecart->_child != (EntityPtr)0x0) {
|
|
local_44 = &minecart->_child;
|
|
std::multiset<unsigned_int>::erase(&local_44);
|
|
}
|
|
minecart->_child = (EntityPtr)0x0;
|
|
return;
|
|
}
|
|
|
|
// 004cf5b0
|
|
void NpcHelper::min_min_willo_count(Entity_NPC *minMin, int *outWilloCount, int *outOwnedCount)
|
|
{
|
|
uint uVar1;
|
|
qword *allocCounter;
|
|
EntityList_EL willoList;
|
|
void *local_10;
|
|
undefined1 *puStack_c;
|
|
undefined4 uStack_8;
|
|
qword allocatedBytes;
|
|
|
|
uStack_8 = 0xffffffff;
|
|
puStack_c = &LAB_00af1690;
|
|
local_10 = ExceptionList;
|
|
ExceptionList = &local_10;
|
|
EntityList::QuerySublist(GHIDRA_CAST<EntityList *>((GHIDRA_INT(g_game->_room) + 0x1218)),&willoList,0x328,-1,-1,0,0);
|
|
uVar1 = 0;
|
|
*outWilloCount = willoList._size;
|
|
*outOwnedCount = 0;
|
|
if (willoList._size != 0) {
|
|
do {
|
|
if (*GHIDRA_CAST<Entity_NPC **>((*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(willoList._data) + uVar1 * 4)) + 0x3bc)) == minMin) {
|
|
*outOwnedCount = *outOwnedCount + 1;
|
|
}
|
|
uVar1 = uVar1 + 1;
|
|
} while (uVar1 < GHIDRA_UINT(willoList._size));
|
|
}
|
|
if ((*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(&(willoList)) + 0x0))) == '\0') {
|
|
if (g_mainHeap == (void *)0x0) {
|
|
allocCounter = &g_allocatedBytesNoHeap;
|
|
}
|
|
else {
|
|
allocCounter = GHIDRA_CAST<qword *>((GHIDRA_INT(g_mainHeap) + 0x30));
|
|
}
|
|
if (willoList._data != (void *)0x0) {
|
|
uVar1 = *GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(willoList._data) + -4));
|
|
allocatedBytes = *allocCounter;
|
|
*GHIDRA_CAST<uint *>(allocCounter) = GHIDRA_UINT(*allocCounter) - uVar1;
|
|
*GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(allocCounter) + 4)) =
|
|
*GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(allocCounter) + 4)) - GHIDRA_UINT((GHIDRA_UINT(allocatedBytes) < uVar1));
|
|
free((void *)(GHIDRA_INT(willoList._data) + -4));
|
|
}
|
|
}
|
|
ExceptionList = local_10;
|
|
return;
|
|
}
|
|
|
|
// 004d33d0
|
|
void NpcHelper::moms_heart_attack_pattern(Entity_NPC *npc, int pattern, int stateFrame)
|
|
{
|
|
byte isHeartbeat;
|
|
Entity *target;
|
|
int iVar1;
|
|
uint frameMod4;
|
|
int framesLeft;
|
|
uint uVar2;
|
|
Entity_Laser *laser;
|
|
int updateTime;
|
|
uint baseBulletFlags;
|
|
bool isOnBeat;
|
|
float fVar3;
|
|
double dVar4;
|
|
float fVar5;
|
|
undefined1 auStack_f8 [4];
|
|
float local_f4;
|
|
float local_f0;
|
|
Vector local_ec;
|
|
float local_e4;
|
|
float local_e0;
|
|
Vector firePos;
|
|
float local_d4;
|
|
Vector local_d0;
|
|
float rotationSpeed;
|
|
Vector laserOffset;
|
|
uint isPositiveRotation;
|
|
ProjectileParams projParams;
|
|
code *projectileCallback;
|
|
uint stackCookie;
|
|
|
|
stackCookie = __security_cookie ^ GHIDRA_UINT(auStack_f8);
|
|
(GHIDRA_CAST<ProjectileParams *>((&projParams)))->ProjectileParams::ProjectileParams();
|
|
projParams.HeightModifier = 5.0;
|
|
projParams.Scale = 1.5;
|
|
projParams.FallingAccelModifier = -0.06;
|
|
projParams.FallingSpeedModifier = -2.0;
|
|
target = (GHIDRA_CAST<Entity_NPC *>((npc)))->Entity_NPC::GetPlayerTarget();
|
|
local_f4 = (target->_pos).x - (npc->_pos).x;
|
|
local_e4 = (target->_pos).y - (npc->_pos).y;
|
|
fVar3 = sqrtf(local_e4 * local_e4 + local_f4 * local_f4);
|
|
if (fVar3 <= 0.0) {
|
|
fVar5 = local_e4;
|
|
fVar3 = local_f4;
|
|
}
|
|
else {
|
|
fVar5 = local_e4 * (1.0 / fVar3);
|
|
fVar3 = local_f4 * (1.0 / fVar3);
|
|
}
|
|
projParams.CircleAngle = atan2f(fVar5,fVar3);
|
|
uVar2 = GHIDRA_UINT(projParams.BulletFlags);
|
|
iVar1 = GHIDRA_INT(npc->_prevUpdateTime);
|
|
baseBulletFlags = GHIDRA_UINT(projParams.BulletFlags) | 0x80;
|
|
updateTime = GHIDRA_INT(npc->_updateTime);
|
|
firePos.x = (npc->_pos).x;
|
|
firePos.y = (npc->_pos).y;
|
|
switch(pattern) {
|
|
case 0:
|
|
fVar3 = (float)stateFrame;
|
|
local_f0 = (fVar3 * fVar3 - fVar3) * 0.01 + fVar3;
|
|
fVar3 = (fVar3 - 0.0) / 180.0;
|
|
if (fVar3 <= 0.0) {
|
|
fVar3 = 0.0;
|
|
}
|
|
if (1.0 <= fVar3) {
|
|
fVar3 = 1.0;
|
|
}
|
|
if (updateTime == iVar1) {
|
|
return;
|
|
}
|
|
local_f4 = 3.0;
|
|
fVar3 = (6.0 - fVar3 * 3.0) + 0.5;
|
|
(*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(projParams.BulletFlags)) + 0x0))) = baseBulletFlags;
|
|
FUN_008370b0();
|
|
if (stateFrame % GHIDRA_INT(fVar3) != 0) {
|
|
return;
|
|
}
|
|
fVar5 = local_f0;
|
|
goto LAB_004d358e;
|
|
case 1:
|
|
if (updateTime == iVar1) {
|
|
return;
|
|
}
|
|
if (stateFrame != (stateFrame / 0x12) * 0x12) {
|
|
return;
|
|
}
|
|
dVar4 = (double)((((float)stateFrame / 30.0) / 6.0) * 6.2831855);
|
|
(*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(projParams.BulletFlags)) + 0x0))) = baseBulletFlags;
|
|
libm_sse2_cos_precise();
|
|
fVar3 = 1.12104e-44;
|
|
local_ec.x = 3.0;
|
|
projParams.CircleAngle = ((((float)dVar4 * 10.0) / 6.0) / 30.0) * 6.2831855;
|
|
break;
|
|
case 2:
|
|
case 3:
|
|
if ((npc->_sprite)._animState._animData == (void *)0x0) {
|
|
return;
|
|
}
|
|
(*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(projParams.BulletFlags)) + 0x0))) = baseBulletFlags;
|
|
isHeartbeat = (GHIDRA_CAST<AnimationState *>((&(npc->_sprite)._animState)))->AnimationState::IsEventTriggered(GHIDRA_CAST<byte *>("Heartbeat"));
|
|
if (isHeartbeat == 0) {
|
|
return;
|
|
}
|
|
if (npc->_aiCounter == 3) {
|
|
fVar3 = 5.60519e-45;
|
|
}
|
|
else {
|
|
fVar3 = 1.4013e-44;
|
|
}
|
|
local_ec.x = 5.0;
|
|
projParams.CircleAngle = (((float)stateFrame / 6.0) / 30.0) * 6.2831855;
|
|
if (pattern == 3) {
|
|
(*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(projParams.BulletFlags)) + 0x0))) = GHIDRA_UINT(projParams.BulletFlags) | 0x200000;
|
|
}
|
|
break;
|
|
case 4:
|
|
if (updateTime == iVar1) {
|
|
return;
|
|
}
|
|
if (stateFrame % 6 != 0) {
|
|
return;
|
|
}
|
|
fVar3 = 4.2039e-45;
|
|
(*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(projParams.BulletFlags)) + 0x0))) = GHIDRA_UINT(projParams.BulletFlags) | 0x200080;
|
|
local_ec.x = 3.0;
|
|
projParams.CircleAngle = (((float)stateFrame / 6.0) / 30.0) * 6.2831855;
|
|
break;
|
|
case 5:
|
|
if (updateTime == iVar1) {
|
|
return;
|
|
}
|
|
frameMod4 = stateFrame & 0x80000003;
|
|
isOnBeat = frameMod4 == 0;
|
|
if (GHIDRA_INT(frameMod4) < 0) {
|
|
isOnBeat = (frameMod4 - 1 | 0xfffffffc) == 0xffffffff;
|
|
}
|
|
if (!isOnBeat) {
|
|
return;
|
|
}
|
|
(*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(projParams.BulletFlags)) + 0x0))) = baseBulletFlags;
|
|
fVar5 = cos(((float)stateFrame * 0.9424779) / 30.0);
|
|
(*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(projParams.BulletFlags)) + 0x0))) = uVar2 | 0x200080;
|
|
fVar3 = 4.2039e-45;
|
|
local_ec.x = 3.5;
|
|
projParams.CircleAngle = (fVar5 * 6.2831855) / 3.0;
|
|
break;
|
|
case 6:
|
|
if (updateTime == iVar1) {
|
|
return;
|
|
}
|
|
uVar2 = stateFrame & 0x80000003;
|
|
isOnBeat = uVar2 == 0;
|
|
if (GHIDRA_INT(uVar2) < 0) {
|
|
isOnBeat = (uVar2 - 1 | 0xfffffffc) == 0xffffffff;
|
|
}
|
|
if (!isOnBeat) {
|
|
return;
|
|
}
|
|
fVar3 = 1.4013e-45;
|
|
fVar5 = ((float)npc->_stateFrame - 0.0) / 60.0;
|
|
if (fVar5 <= 0.0) {
|
|
fVar5 = 0.0;
|
|
}
|
|
if (1.0 <= fVar5) {
|
|
fVar5 = 1.0;
|
|
}
|
|
local_ec.x = fVar5 * 7.0 + 8.0;
|
|
goto LAB_004d417d;
|
|
case 7:
|
|
if (updateTime == iVar1) {
|
|
return;
|
|
}
|
|
uVar2 = stateFrame & 0x80000003;
|
|
isOnBeat = uVar2 == 0;
|
|
if (GHIDRA_INT(uVar2) < 0) {
|
|
isOnBeat = (uVar2 - 1 | 0xfffffffc) == 0xffffffff;
|
|
}
|
|
if (!isOnBeat) {
|
|
return;
|
|
}
|
|
local_ec.x = 6.0;
|
|
fVar3 = 7.00649e-45;
|
|
projParams.CircleAngle = projParams.CircleAngle * -1.0;
|
|
goto LAB_004d417d;
|
|
case 8:
|
|
(*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(projParams.BulletFlags)) + 0x0))) = baseBulletFlags;
|
|
isHeartbeat = (GHIDRA_CAST<Sprite *>((GHIDRA_CAST<Sprite *>(&npc->_sprite))))->Sprite::IsEventTriggered("Heartbeat");
|
|
if (isHeartbeat == 0) {
|
|
return;
|
|
}
|
|
projParams.FireDirectionLimit.x = 0.0;
|
|
projParams.FireDirectionLimit.y = 1.0;
|
|
projParams.DotProductLimit = 0.0;
|
|
firePos.x = (npc->_pos).x;
|
|
fVar3 = (float)((npc->_aiCounter != 3) + 7);
|
|
if (npc->_aiCounter == 3) {
|
|
fVar3 = 5.60519e-45;
|
|
}
|
|
local_ec.x = 5.0;
|
|
projParams.CircleAngle = (((float)stateFrame / 6.0) / 30.0) * 6.2831855;
|
|
firePos.y = *GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(g_game->_room) + 0x18)) + 20.0;
|
|
break;
|
|
case 9:
|
|
if (updateTime == iVar1) {
|
|
return;
|
|
}
|
|
if (stateFrame != 2) {
|
|
return;
|
|
}
|
|
(*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(projParams.BulletFlags)) + 0x0))) = baseBulletFlags;
|
|
uVar2 = Random();
|
|
local_f4 = (float)(uVar2 % 0x1e + 0xf);
|
|
isPositiveRotation = Random();
|
|
isPositiveRotation = isPositiveRotation & 1;
|
|
uVar2 = Random();
|
|
local_d4 = 30.0;
|
|
local_e0 = 90.0;
|
|
local_f0 = 0.0;
|
|
local_e4 = ((float)((uVar2 & 3) + 1) + 0.0) * 180.0;
|
|
do {
|
|
local_ec.x = (npc->_pos).x + 0.0;
|
|
local_ec.y = (npc->_pos).y - local_d4;
|
|
laserOffset.x = 0.0;
|
|
laserOffset.y = 0.0;
|
|
laser = Entity_Laser::ShootAngle
|
|
(1,&local_ec,(float)GHIDRA_INT(local_f0) * local_e0 - 135.0,0x5a,&laserOffset,
|
|
GHIDRA_CAST<Entity *>(npc),0);
|
|
laser->_isActiveRotating = 1;
|
|
laser->_rotationDelay = GHIDRA_INT(local_f4);
|
|
if (isPositiveRotation == 0) {
|
|
local_d0.x = -local_e4;
|
|
rotationSpeed = -2.0;
|
|
}
|
|
else {
|
|
rotationSpeed = 2.0;
|
|
local_d0.x = local_e4;
|
|
}
|
|
iVar1 = __ftoui3();
|
|
laser->_rotationDegrees = local_d0.x;
|
|
laser->_rotationSpd = rotationSpeed;
|
|
laser->_timeout = iVar1 + GHIDRA_INT(local_f4) + 1;
|
|
laser->Update();
|
|
local_f0 = (float)(GHIDRA_INT(local_f0) + 1);
|
|
} while (GHIDRA_INT(local_f0) < 4);
|
|
return;
|
|
case 10:
|
|
framesLeft = 0xb4 - stateFrame;
|
|
local_e0 = ((float)(framesLeft * framesLeft) - (float)framesLeft) * 0.01 + (float)framesLeft;
|
|
fVar3 = ((float)stateFrame - 0.0) / 180.0;
|
|
if (fVar3 <= 0.0) {
|
|
fVar3 = 0.0;
|
|
}
|
|
if (1.0 <= fVar3) {
|
|
fVar3 = 1.0;
|
|
}
|
|
if (updateTime == iVar1) {
|
|
return;
|
|
}
|
|
local_f4 = 3.0;
|
|
fVar3 = fVar3 * 0.0 + 3.0 + 0.5;
|
|
(*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(projParams.BulletFlags)) + 0x0))) = baseBulletFlags;
|
|
FUN_008370b0();
|
|
if (stateFrame % GHIDRA_INT(fVar3) != 0) {
|
|
return;
|
|
}
|
|
fVar5 = local_e0;
|
|
LAB_004d358e:
|
|
fVar3 = 2.8026e-45;
|
|
projParams.CircleAngle = ((fVar5 / 6.0) / 30.0) * 6.2831855;
|
|
local_ec.x = local_f4;
|
|
break;
|
|
case 0xb:
|
|
if (updateTime == iVar1) {
|
|
return;
|
|
}
|
|
uVar2 = stateFrame & 0x8000000f;
|
|
isOnBeat = uVar2 == 0;
|
|
if (GHIDRA_INT(uVar2) < 0) {
|
|
isOnBeat = (uVar2 - 1 | 0xfffffff0) == 0xffffffff;
|
|
}
|
|
if (!isOnBeat) {
|
|
return;
|
|
}
|
|
fVar3 = 1.12104e-44;
|
|
projParams.CircleAngle = (float)stateFrame * 0.62831855 * 0.0625;
|
|
uVar2 = stateFrame & 0x8000001f;
|
|
isOnBeat = uVar2 == 0;
|
|
if (GHIDRA_INT(uVar2) < 0) {
|
|
isOnBeat = (uVar2 - 1 | 0xffffffe0) == 0xffffffff;
|
|
}
|
|
(*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(projParams.BulletFlags)) + 0x0))) = 0x40000;
|
|
if (!isOnBeat) {
|
|
(*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(projParams.BulletFlags)) + 0x0))) = 0x80000;
|
|
}
|
|
(*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(projParams.BulletFlags)) + 0x0))) = baseBulletFlags | GHIDRA_UINT(projParams.BulletFlags);
|
|
local_ec.x = 5.0;
|
|
break;
|
|
case 0xc:
|
|
case 0xd:
|
|
if ((npc->_sprite)._animState._animData == (void *)0x0) {
|
|
return;
|
|
}
|
|
(*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(projParams.BulletFlags)) + 0x0))) = baseBulletFlags;
|
|
isHeartbeat = (GHIDRA_CAST<AnimationState *>((&(npc->_sprite)._animState)))->AnimationState::IsEventTriggered(GHIDRA_CAST<byte *>("Heartbeat"));
|
|
if (isHeartbeat == 0) {
|
|
return;
|
|
}
|
|
local_f4 = 6.0;
|
|
projParams.FallingAccelModifier = -0.08;
|
|
projParams.CircleAngle = (((float)stateFrame / 6.0) / 30.0) * 6.2831855;
|
|
if ((pattern == 0xd) && (npc->_aiCounter != 3)) {
|
|
(*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(projParams.BulletFlags)) + 0x0))) = GHIDRA_UINT(projParams.BulletFlags) | 0x200000;
|
|
}
|
|
local_f0 = 4.2039e-45;
|
|
if (npc->_aiCounter == 3) {
|
|
local_ec.x = 0.8;
|
|
}
|
|
else {
|
|
local_f0 = 1.12104e-44;
|
|
local_ec.x = 0.5;
|
|
}
|
|
local_ec.x = local_ec.x * 6.0;
|
|
local_ec.y = (float)GHIDRA_INT(local_f0);
|
|
Entity_NPC::FireProjectiles(npc,&firePos,&local_ec,9,&projParams);
|
|
projParams.Scale = 1.0;
|
|
fVar3 = local_f0;
|
|
local_ec.x = local_f4;
|
|
if (npc->_aiCounter == 3) {
|
|
projParams.CircleAngle = (((float)-stateFrame / local_f4) / 30.0) * 6.2831855;
|
|
}
|
|
else {
|
|
projParams.CircleAngle = 3.1415927 / (float)GHIDRA_INT(local_f0) + projParams.CircleAngle;
|
|
}
|
|
break;
|
|
case 0xe:
|
|
if (updateTime == iVar1) {
|
|
return;
|
|
}
|
|
uVar2 = stateFrame & 0x80000003;
|
|
isOnBeat = uVar2 == 0;
|
|
if (GHIDRA_INT(uVar2) < 0) {
|
|
isOnBeat = (uVar2 - 1 | 0xfffffffc) == 0xffffffff;
|
|
}
|
|
if (!isOnBeat) {
|
|
return;
|
|
}
|
|
(*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(projParams.BulletFlags)) + 0x0))) = GHIDRA_UINT(projParams.BulletFlags) | 0x280080;
|
|
projectileCallback = FUN_004d4210;
|
|
fVar3 = (float)stateFrame / 180.0 + (float)stateFrame / 180.0;
|
|
projParams.CircleAngle = ((fVar3 + fVar3) * 3.1415927) / 3.0;
|
|
fVar3 = 7.00649e-45;
|
|
local_ec.x = 3.0;
|
|
break;
|
|
case 0xf:
|
|
if (updateTime == iVar1) {
|
|
return;
|
|
}
|
|
uVar2 = stateFrame & 0x80000007;
|
|
isOnBeat = uVar2 == 0;
|
|
if (GHIDRA_INT(uVar2) < 0) {
|
|
isOnBeat = (uVar2 - 1 | 0xfffffff8) == 0xffffffff;
|
|
}
|
|
if (!isOnBeat) {
|
|
return;
|
|
}
|
|
projParams.Scale = 1.0;
|
|
projParams.CircleAngle = 0.06981317;
|
|
projectileCallback = FUN_004d43b0;
|
|
local_ec.x = 6.0;
|
|
local_ec.y = 8.0;
|
|
(*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(projParams.BulletFlags)) + 0x0))) = baseBulletFlags;
|
|
Entity_NPC::FireProjectiles(npc,&firePos,&local_ec,9,&projParams);
|
|
projParams.CircleAngle = projParams.CircleAngle - 0.13962634;
|
|
projParams.WiggleFrameOffset = 0x14;
|
|
fVar3 = 1.12104e-44;
|
|
local_ec.x = 6.0;
|
|
break;
|
|
case 0x10:
|
|
if (updateTime == iVar1) {
|
|
return;
|
|
}
|
|
if (stateFrame != (stateFrame / 0x1e) * 0x1e) {
|
|
return;
|
|
}
|
|
(*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(projParams.BulletFlags)) + 0x0))) = GHIDRA_UINT(projParams.BulletFlags) | 0x2080;
|
|
projParams.Scale = 1.0;
|
|
projParams.FallingAccelModifier = -0.085;
|
|
projectileCallback = FUN_004d4480;
|
|
projParams.CurvingStrength = 2.0;
|
|
local_ec.x = 3.0;
|
|
local_ec.y = 4.0;
|
|
projParams.CircleAngle = (((float)stateFrame + (float)stateFrame) * 3.1415927) / 600.0;
|
|
projParams.TargetPosition.x = (npc->_pos).x;
|
|
projParams.TargetPosition.y = (npc->_pos).y;
|
|
Entity_NPC::FireProjectiles(npc,&firePos,&local_ec,9,&projParams);
|
|
projParams.CurvingStrength = -2.0;
|
|
local_ec.x = 3.0;
|
|
local_ec.y = 4.0;
|
|
Entity_NPC::FireProjectiles(npc,&firePos,&local_ec,9,&projParams);
|
|
(*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(projParams.BulletFlags)) + 0x0))) = GHIDRA_UINT(projParams.BulletFlags) & 0xffffdfff;
|
|
projParams.CircleAngle = 0.0;
|
|
projParams.Scale = 1.5;
|
|
projectileCallback = (code *)0x0;
|
|
fVar3 = 1.68156e-44;
|
|
local_ec.x = 3.0;
|
|
break;
|
|
case 0x11:
|
|
if (updateTime == iVar1) {
|
|
return;
|
|
}
|
|
uVar2 = stateFrame & 0x80000007;
|
|
isOnBeat = uVar2 == 0;
|
|
if (GHIDRA_INT(uVar2) < 0) {
|
|
isOnBeat = (uVar2 - 1 | 0xfffffff8) == 0xffffffff;
|
|
}
|
|
if (!isOnBeat) {
|
|
return;
|
|
}
|
|
(*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(projParams.BulletFlags)) + 0x0))) = GHIDRA_UINT(projParams.BulletFlags) | 0x2080;
|
|
projParams.CircleAngle = 0.0;
|
|
projectileCallback = FUN_004d42f0;
|
|
fVar3 = 1.12104e-44;
|
|
local_ec.x = 8.0;
|
|
break;
|
|
case 0x12:
|
|
if (updateTime == iVar1) {
|
|
return;
|
|
}
|
|
if (stateFrame == 2) {
|
|
(*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(projParams.BulletFlags)) + 0x0))) = baseBulletFlags;
|
|
uVar2 = Random();
|
|
local_f0 = (float)(uVar2 % 0x1e + 0xf);
|
|
uVar2 = Random();
|
|
local_e0 = (float)(uVar2 & 1);
|
|
iVar1 = 0;
|
|
local_d4 = (float)(GHIDRA_INT(local_f0) + -0x39515eff);
|
|
do {
|
|
local_d0.x = (npc->_pos).x + 0.0;
|
|
local_d0.y = (npc->_pos).y - 30.0;
|
|
laserOffset.x = 0.0;
|
|
laserOffset.y = 0.0;
|
|
laser = Entity_Laser::ShootAngle
|
|
(1,&local_d0,(float)iVar1 * 180.0 + 90.0,0x78,&laserOffset,GHIDRA_CAST<Entity *>(npc),0
|
|
);
|
|
laser->_isActiveRotating = 1;
|
|
laser->_rotationDelay = GHIDRA_INT(local_f0);
|
|
if (local_e0 == 0.0) {
|
|
fVar3 = -0.3;
|
|
fVar5 = -1e+09;
|
|
}
|
|
else {
|
|
fVar3 = 0.3;
|
|
fVar5 = 1e+09;
|
|
}
|
|
laser->_rotationDegrees = fVar5;
|
|
laser->_rotationSpd = fVar3;
|
|
laser->_timeout = GHIDRA_INT(local_d4);
|
|
laser->Update();
|
|
iVar1 = iVar1 + 1;
|
|
} while (iVar1 < 2);
|
|
return;
|
|
}
|
|
if (stateFrame != (stateFrame / 9) * 9) {
|
|
return;
|
|
}
|
|
local_ec.x = 8.0;
|
|
fVar3 = 2.8026e-45;
|
|
LAB_004d417d:
|
|
(*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(projParams.BulletFlags)) + 0x0))) = baseBulletFlags;
|
|
break;
|
|
default:
|
|
goto switchD_004d34fb_default;
|
|
}
|
|
local_ec.y = (float)GHIDRA_INT(fVar3);
|
|
Entity_NPC::FireProjectiles(npc,&firePos,&local_ec,9,&projParams);
|
|
switchD_004d34fb_default:
|
|
return;
|
|
}
|
|
|
|
// 004d4610
|
|
void NpcHelper::moms_heart_pick_attack(Entity_NPC *npc)
|
|
{
|
|
uint attackRoll;
|
|
int maxAttack;
|
|
uint attackRange;
|
|
int iVar1;
|
|
float fVar2;
|
|
Vector local_48;
|
|
Vector local_40;
|
|
float local_38;
|
|
ColorMod splatColor;
|
|
float local_8;
|
|
|
|
local_8 = (float)(__security_cookie ^ GHIDRA_UINT(((&splatColor)[1]._tint + 1)));
|
|
iVar1 = 0;
|
|
maxAttack = 7;
|
|
local_38 = (float)npc->_subtype;
|
|
if (local_38 == 1.4013e-45) {
|
|
iVar1 = 10;
|
|
maxAttack = 0x11;
|
|
}
|
|
if (npc->_i1 == 5) {
|
|
iVar1 = 8;
|
|
attackRange = 1;
|
|
}
|
|
else {
|
|
npc->_state = 8;
|
|
if (npc->_aiCounter == 1) {
|
|
maxAttack = 3;
|
|
if (local_38 == 1.4013e-45) {
|
|
maxAttack = 0xd;
|
|
}
|
|
}
|
|
else if ((npc->_aiCounter == 2) && (iVar1 = 2, local_38 == 1.4013e-45)) {
|
|
iVar1 = 0xe;
|
|
}
|
|
attackRange = (maxAttack - iVar1) + 1;
|
|
if (attackRange == 0) {
|
|
attackRoll = 0;
|
|
goto LAB_004d4664;
|
|
}
|
|
}
|
|
attackRoll = Random();
|
|
attackRoll = attackRoll % attackRange;
|
|
LAB_004d4664:
|
|
(npc->_v1).y = (float)((double)GHIDRA_INT(attackRoll) +
|
|
__uint_to_double_fixup[-(GHIDRA_INT(attackRoll) >> 0x1f)]) + (float)iVar1;
|
|
npc->_stateFrame = 0;
|
|
if (npc->_health / npc->_maxHitPoints <= 0.2) {
|
|
iVar1 = 9;
|
|
if (local_38 == 1.4013e-45) {
|
|
iVar1 = 0x12;
|
|
}
|
|
fVar2 = (float)iVar1;
|
|
(npc->_v1).y = fVar2;
|
|
if (fVar2 == 9.0) {
|
|
iVar1 = 0;
|
|
local_48.y = -20.0;
|
|
local_48.x = 0.0;
|
|
do {
|
|
splatColor._offset[0] = 0.0;
|
|
splatColor._colorize[0] = 0.0;
|
|
splatColor._colorize[1] = 0.0;
|
|
splatColor._colorize[2] = 0.0;
|
|
splatColor._colorize[3] = 0.0;
|
|
splatColor._offset[1] = 0.0;
|
|
splatColor._tint[0] = 0.6;
|
|
splatColor._tint[1] = 0.05;
|
|
splatColor._tint[2] = 0.0;
|
|
splatColor._tint[3] = 0.8;
|
|
splatColor._offset[2] = 0.0;
|
|
local_38 = ((float)iVar1 * 90.0 - 135.0) * 0.017453292;
|
|
local_40.x = cos(local_38);
|
|
local_40.y = sin(local_38);
|
|
Entity::SpawnFollowingEffect198(GHIDRA_CAST<Entity *>(npc),&local_48,&local_40,0xc,&splatColor,4.0);
|
|
iVar1 = iVar1 + 1;
|
|
} while (iVar1 < 4);
|
|
return;
|
|
}
|
|
if (fVar2 == 18.0) {
|
|
iVar1 = 0;
|
|
local_40.y = -20.0;
|
|
local_40.x = 0.0;
|
|
do {
|
|
splatColor._offset[0] = 0.0;
|
|
splatColor._colorize[0] = 0.0;
|
|
splatColor._colorize[1] = 0.0;
|
|
splatColor._colorize[2] = 0.0;
|
|
splatColor._colorize[3] = 0.0;
|
|
splatColor._offset[1] = 0.0;
|
|
splatColor._tint[0] = 0.6;
|
|
splatColor._tint[1] = 0.05;
|
|
splatColor._tint[2] = 0.0;
|
|
splatColor._tint[3] = 0.8;
|
|
splatColor._offset[2] = 0.0;
|
|
local_38 = ((float)iVar1 * 180.0 + 90.0) * 0.017453292;
|
|
local_48.x = cos(local_38);
|
|
local_48.y = sin(local_38);
|
|
Entity::SpawnFollowingEffect198(GHIDRA_CAST<Entity *>(npc),&local_40,&local_48,0xc,&splatColor,4.0);
|
|
iVar1 = iVar1 + 1;
|
|
} while (iVar1 < 2);
|
|
}
|
|
}
|
|
return;
|
|
}
|
|
|
|
// 004d8d10
|
|
Entity_NPC * NpcHelper::gaper_l2_spawn_maggot(Vector *origin, float yOffset, Vector *velocity, float fallingSpeed)
|
|
{
|
|
void *pvVar1;
|
|
code *pcVar2;
|
|
uint seed;
|
|
Entity_NPC *maggot;
|
|
float fVar3;
|
|
float fVar4;
|
|
float dirY;
|
|
qword flags;
|
|
undefined4 flagsHigh;
|
|
|
|
pvVar1 = g_game->_room;
|
|
seed = Random();
|
|
maggot = GHIDRA_CAST<Entity_NPC *>((GHIDRA_CAST<Game *>((g_game)))->Game)::Spawn(0x355,0,origin,&g_vectorZero,GHIDRA_CAST<Entity *>(0x0),0,seed);
|
|
*GHIDRA_CAST<uint *>(&maggot->_flags) = GHIDRA_UINT(maggot->_flags) & 0xfffffffb;
|
|
flagsHigh = *GHIDRA_CAST<undefined4 *>((GHIDRA_INT(&maggot->_flags) + 4));
|
|
flags = maggot->_flags;
|
|
(maggot->_v1).x = fallingSpeed;
|
|
*GHIDRA_CAST<undefined4 *>((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<uint *>(&maggot->_flags) = GHIDRA_UINT(flags) | 0x4000000;
|
|
*GHIDRA_CAST<undefined4 *>((GHIDRA_INT(&maggot->_flags) + 4)) = flagsHigh;
|
|
if (*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(pvVar1) + 8)) == 0x10) {
|
|
(maggot->_pos).y = yOffset + (maggot->_pos).y;
|
|
(maggot->_velocity).y = fallingSpeed + (maggot->_velocity).y;
|
|
}
|
|
else {
|
|
(maggot->_posOffset).y = yOffset;
|
|
}
|
|
maggot->Update();
|
|
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<byte *>("RNG Seed is zero!\n"));
|
|
pcVar2 = (code *)swi(3);
|
|
maggot = GHIDRA_CAST<Entity_NPC *>((*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)
|
|
{
|
|
uint 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;
|
|
uint 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;
|
|
(GHIDRA_CAST<Entity_NPC *>((npc)))->Entity_NPC::CalcTargetPosition(outTarget,0.0);
|
|
playerTarget = (GHIDRA_CAST<Entity_NPC *>((npc)))->Entity_NPC::GetPlayerTarget();
|
|
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 = (GHIDRA_CAST<Room *>((room)))->Room::GetGridCollision(gridIndex);
|
|
if (0 < GHIDRA_INT(gridCollision)) {
|
|
resultPos = (GHIDRA_CAST<Room *>((room)))->Room::FindFreeTilePosition(&scratchVec,outTarget,64.0);
|
|
outTarget->x = resultPos->x;
|
|
outTarget->y = resultPos->y;
|
|
}
|
|
return;
|
|
}
|
|
|
|
// 004e0930
|
|
void NpcHelper::gutted_fatty_burst_projectiles(Entity *timer)
|
|
{
|
|
uint rngResult;
|
|
uint 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 *)
|
|
(GHIDRA_CAST<Game *>((g_game)))->Game::SpawnEx(9,0,&local_10,&local_18,GHIDRA_CAST<Entity *>(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<int *>(&(*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(&(timer[1])) + 0x40)))),
|
|
*GHIDRA_CAST<float *>((timer[1]._sprite._animDefaultName._buf + 8)),timer->_flags,GHIDRA_CAST<Entity *>(0x0));
|
|
pEVar1->Update();
|
|
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 *)
|
|
(GHIDRA_CAST<Game *>((g_game)))->Game::SpawnEx(9,0,&local_18,&local_10,GHIDRA_CAST<Entity *>(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<int *>(&(*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(&(timer[1])) + 0x40)))),
|
|
*GHIDRA_CAST<float *>((timer[1]._sprite._animDefaultName._buf + 8)),timer->_flags,GHIDRA_CAST<Entity *>(0x0));
|
|
pEVar1->Update();
|
|
projectilesLeft = projectilesLeft + -1;
|
|
} while (projectilesLeft != 0);
|
|
return;
|
|
}
|
|
|
|
// 004e4870
|
|
byte NpcHelper::candler_is_free_cell(Vector *position)
|
|
{
|
|
uint 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 = (GHIDRA_CAST<Room *>((room)))->Room::GetGridCollision(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<int *>((GHIDRA_INT(room->_gridEntities[gridY]) + 4)) != 0x17)))) {
|
|
return 1;
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
// 004e50d0
|
|
byte NpcHelper::whipper_is_target(Entity_NPC *npc, Entity *entity)
|
|
{
|
|
int iVar1;
|
|
byte bVar2;
|
|
bool isHostile;
|
|
|
|
isHostile = (npc->_flags & 0x20000100) == 0;
|
|
if (GHIDRA_CAST<Entity_NPC *>(entity) != npc) {
|
|
iVar1 = entity->_type;
|
|
if (iVar1 == 4) {
|
|
if (isHostile) {
|
|
return 1;
|
|
}
|
|
}
|
|
else if (isHostile) {
|
|
if (iVar1 == 1) {
|
|
return 1;
|
|
}
|
|
if (iVar1 != 3) {
|
|
return 0;
|
|
}
|
|
iVar1 = entity->_variant;
|
|
if (iVar1 == 0x3e) {
|
|
return 1;
|
|
}
|
|
if (iVar1 == 0x43) {
|
|
return 1;
|
|
}
|
|
if (iVar1 == 0xc9) {
|
|
return 1;
|
|
}
|
|
if (iVar1 == 0xe4) {
|
|
return 1;
|
|
}
|
|
if (iVar1 == 0xee) {
|
|
return 1;
|
|
}
|
|
if (iVar1 == 0xce) {
|
|
return 1;
|
|
}
|
|
if (iVar1 == 0xed) {
|
|
return 1;
|
|
}
|
|
if (iVar1 == 0xd3) {
|
|
return 1;
|
|
}
|
|
return 0;
|
|
}
|
|
bVar2 = (GHIDRA_CAST<Entity *>((entity)))->Entity::IsVulnerableEnemy(GHIDRA_CAST<Entity *>(0x0));
|
|
if (bVar2 != 0) {
|
|
return 1;
|
|
}
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
// 004f5f20
|
|
void NpcHelper::ball_and_chain_render_chain(float *param_1)
|
|
{
|
|
LayerState *pLVar1;
|
|
ColorMod *color;
|
|
ColorMod *extraout_EAX;
|
|
int in_ECX;
|
|
float fVar2;
|
|
float fVar3;
|
|
float anchorOffsetX;
|
|
float anchorOffsetX;
|
|
double dVar5;
|
|
ColorMod *color_00;
|
|
undefined1 auStack_b4 [24];
|
|
float local_9c;
|
|
Vector local_98;
|
|
float local_90;
|
|
float local_8c;
|
|
float snappedX;
|
|
float dirX;
|
|
float dirY;
|
|
float pixelScale;
|
|
Vector renderPos;
|
|
Color beamColor;
|
|
uint securityCookie;
|
|
ANM2 *sprite;
|
|
|
|
securityCookie = __security_cookie ^ GHIDRA_UINT(auStack_b4);
|
|
if ((*GHIDRA_CAST<float *>((in_ECX + 0x334)) != g_vectorZero.x) ||
|
|
(*GHIDRA_CAST<float *>((in_ECX + 0x338)) != g_vectorZero.y)) {
|
|
local_8c = *GHIDRA_CAST<float *>((in_ECX + 0x33c)) - *GHIDRA_CAST<float *>((in_ECX + 0x334));
|
|
local_90 = *GHIDRA_CAST<float *>((in_ECX + 0x340)) - *GHIDRA_CAST<float *>((in_ECX + 0x338));
|
|
dirX = local_8c;
|
|
dirY = local_90;
|
|
fVar2 = sqrtf(local_90 * local_90 + local_8c * local_8c);
|
|
if (fVar2 <= 0.0) {
|
|
fVar3 = local_8c;
|
|
anchorOffsetX = local_90;
|
|
}
|
|
else {
|
|
local_90 = (1.0 / fVar2) * dirY;
|
|
local_8c = (1.0 / fVar2) * dirX;
|
|
fVar3 = dirX;
|
|
anchorOffsetX = dirY;
|
|
}
|
|
anchorOffsetX = local_8c * 4.0;
|
|
local_90 = (local_90 * 4.0 * 0.6 + *GHIDRA_CAST<float *>((in_ECX + 0x338))) - 8.0;
|
|
if (0.0 < fVar2) {
|
|
dirY = anchorOffsetX * (1.0 / fVar2);
|
|
dirX = fVar3 * (1.0 / fVar2);
|
|
}
|
|
local_8c = (g_screenHeight - 182.0) * 0.5;
|
|
local_98.x = (g_screenWidth - 338.0) * 0.5;
|
|
pixelScale = g_displayPixelRatio * g_screenPointScale;
|
|
local_9c = (((anchorOffsetX + *GHIDRA_CAST<float *>((in_ECX + 0x334)) + 0.0) - 60.0) * 0.65 + local_98.x) *
|
|
pixelScale + 0.5;
|
|
dVar5 = floor((double)local_9c);
|
|
snappedX = (float)dVar5 / pixelScale;
|
|
local_9c = ((local_90 - 140.0) * 0.65 + local_8c) * pixelScale + 0.5;
|
|
dVar5 = floor((double)local_9c);
|
|
local_90 = *param_1;
|
|
local_9c = param_1[1];
|
|
renderPos.x = local_90 + snappedX;
|
|
renderPos.y = local_9c + (float)dVar5 / pixelScale;
|
|
local_98.x = ((((*GHIDRA_CAST<float *>((in_ECX + 0x33c)) - dirX * 10.0) + *GHIDRA_CAST<float *>((in_ECX + 0x34c))) - 60.0)
|
|
* 0.65 + local_98.x) * pixelScale + 0.5;
|
|
dVar5 = floor((double)local_98.x);
|
|
snappedX = (float)dVar5 / pixelScale;
|
|
local_98.x = ((((*GHIDRA_CAST<float *>((in_ECX + 0x340)) - dirY * 10.0) + *GHIDRA_CAST<float *>((in_ECX + 0x350))) - 140.0
|
|
) * 0.65 + local_8c) * pixelScale + 0.5;
|
|
dVar5 = floor((double)local_98.x);
|
|
sprite = GHIDRA_CAST<ANM2 *>((in_ECX + 0x48));
|
|
local_98.x = local_90 + snappedX;
|
|
local_9c = local_9c + (float)dVar5 / pixelScale;
|
|
local_98.y = local_9c;
|
|
local_90 = local_98.x;
|
|
pLVar1 = (GHIDRA_CAST<ANM2 *>((sprite)))->ANM2::GetLayer(GHIDRA_CAST<byte *>(0x1));
|
|
pLVar1->_visible = 1;
|
|
DAT_00c78ef4 = 1;
|
|
(*GHIDRA_CAST<undefined2 *>((GHIDRA_CAST<char *>(&(DAT_00c78ef8)) + 0x0))) = 1;
|
|
g_beamRendererPointsEnd = g_beamRendererPoints;
|
|
DAT_00c78ef0 = sprite;
|
|
(GHIDRA_CAST<Color *>((&beamColor)))->Color::Color();
|
|
BeamRenderer::Add(&renderPos,color,1.0,0.0);
|
|
(GHIDRA_CAST<Color *>((&beamColor)))->Color::Color();
|
|
color_00 = extraout_EAX;
|
|
fVar2 = sqrtf((local_9c - renderPos.y) * (local_9c - renderPos.y) +
|
|
(local_90 - renderPos.x) * (local_90 - renderPos.x));
|
|
BeamRenderer::Add(&local_98,color_00,1.0,fVar2);
|
|
BeamRenderer::End();
|
|
pLVar1 = (GHIDRA_CAST<ANM2 *>((sprite)))->ANM2::GetLayer(GHIDRA_CAST<byte *>(0x1));
|
|
local_8c = g_displayPixelRatio;
|
|
pLVar1->_visible = 0;
|
|
local_8c = local_8c * g_screenPointScale;
|
|
local_98.x = (((*GHIDRA_CAST<float *>((in_ECX + 0x334)) + 0.0) - 60.0) * 0.65 + (g_screenWidth - 338.0) * 0.5
|
|
) * local_8c + 0.5;
|
|
dVar5 = floor((double)local_98.x);
|
|
snappedX = (float)dVar5 / local_8c;
|
|
local_98.x = (((*GHIDRA_CAST<float *>((in_ECX + 0x338)) - 8.0) - 140.0) * 0.65 +
|
|
(g_screenHeight - 182.0) * 0.5) * local_8c + 0.5;
|
|
dVar5 = floor((double)local_98.x);
|
|
renderPos.y = (float)dVar5 / local_8c + param_1[1];
|
|
renderPos.x = snappedX + *param_1;
|
|
local_98.x = *GHIDRA_CAST<float *>((in_ECX + 0xec));
|
|
*GHIDRA_CAST<undefined4 *>((in_ECX + 0xec)) = 0;
|
|
pLVar1 = (GHIDRA_CAST<ANM2 *>((sprite)))->ANM2::GetLayer(GHIDRA_CAST<byte *>(0x2));
|
|
pLVar1->_visible = 1;
|
|
(GHIDRA_CAST<Sprite *>((GHIDRA_CAST<Sprite *>(sprite))))->Sprite::RenderLayer(2,&renderPos,&g_vectorZero,&g_vectorZero);
|
|
pLVar1 = (GHIDRA_CAST<ANM2 *>((sprite)))->ANM2::GetLayer(GHIDRA_CAST<byte *>(0x2));
|
|
pLVar1->_visible = 0;
|
|
*GHIDRA_CAST<float *>((in_ECX + 0xec)) = local_98.x;
|
|
}
|
|
return;
|
|
}
|
|
|
|
// 00501e10
|
|
void NpcHelper::bouncer_death_gib(Entity_Effect *timer)
|
|
{
|
|
uint 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 = (GHIDRA_CAST<Game *>((g_game)))->Game::SpawnEx(1000,2,&local_20,&gibVelocity,GHIDRA_CAST<Entity *>(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)
|
|
{
|
|
longlong lVar1;
|
|
longlong lVar2;
|
|
longlong lVar3;
|
|
float fVar4;
|
|
byte isErased;
|
|
char cVar5;
|
|
uint uVar6;
|
|
uint uVar7;
|
|
int *piVar8;
|
|
int iVar9;
|
|
Entity *pEVar10;
|
|
int unusedArg;
|
|
int unusedArg_00;
|
|
void *pvVar11;
|
|
uint uVar12;
|
|
uint uVar13;
|
|
PlayerManager *playerManager;
|
|
bool bVar14;
|
|
float fVar15;
|
|
float fVar16;
|
|
ulonglong timeNs;
|
|
EntityPtr *pEVar17;
|
|
float local_124;
|
|
Entity *local_120;
|
|
Game *local_11c;
|
|
void *local_118;
|
|
float local_114;
|
|
float local_110;
|
|
float local_10c;
|
|
uint local_108;
|
|
uint local_104;
|
|
float spawnVelX;
|
|
float fStack_fc;
|
|
Game *local_f4;
|
|
Entity *owner;
|
|
Vector spawnPos;
|
|
uint local_e4;
|
|
uint local_e0;
|
|
Vector local_d4;
|
|
uint uStack_cc;
|
|
uint spawnSeed;
|
|
void *pvStack_c4;
|
|
EntityPtr *apEStack_bc [4];
|
|
Vector particleVel;
|
|
EntityPtr *local_a4;
|
|
Vector spawnVel [2];
|
|
int iStack_8c;
|
|
uint uStack_88;
|
|
int iStack_84;
|
|
undefined4 uStack_80;
|
|
Vector bloodVel [2];
|
|
undefined4 uStack_6c;
|
|
undefined4 local_68;
|
|
undefined4 uStack_64;
|
|
undefined4 local_60 [5];
|
|
undefined1 auStack_4c [8];
|
|
int foundNode2;
|
|
int foundNode;
|
|
undefined1 auStack_30 [8];
|
|
int iStack_28;
|
|
int iStack_24;
|
|
undefined4 uStack_20;
|
|
uint stackCookie;
|
|
code *fnPtr;
|
|
Game *game;
|
|
EntityPtr *spawnerRef;
|
|
ColorMod *spriteColor;
|
|
|
|
stackCookie = __security_cookie ^ GHIDRA_UINT(&local_124);
|
|
spawnPos.x = (timer->_pos).x;
|
|
spawnPos.y = (timer->_pos).y;
|
|
owner = timer;
|
|
uVar6 = Random();
|
|
fVar15 = (float)((double)GHIDRA_INT(uVar6) + __uint_to_double_fixup[-(GHIDRA_INT(uVar6) >> 0x1f)]) *
|
|
2.3283064e-10 * 3.14;
|
|
local_120 = GHIDRA_CAST<Entity *>((fVar15 + fVar15));
|
|
uVar6 = Random();
|
|
local_110 = (float)((double)GHIDRA_INT(uVar6) + __uint_to_double_fixup[-(GHIDRA_INT(uVar6) >> 0x1f)]) *
|
|
2.3283064e-10 * 4.0 + 6.0;
|
|
spawnVelX = cos((float)local_120);
|
|
spawnVelX = spawnVelX * local_110;
|
|
spawnVel[0].x = spawnVelX;
|
|
fVar15 = sin((float)local_120);
|
|
local_118 = (void *)(fVar15 * 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<Game *>(&DAT_00000004);
|
|
lua_callback_run_pre_entity_spawn
|
|
(GHIDRA_CAST<int *>(&local_f4),GHIDRA_CAST<int *>(&local_e4),&spawnPos,spawnVel,GHIDRA_CAST<Entity *>(0x0),GHIDRA_CAST<int *>(&local_114),
|
|
&spawnSeed);
|
|
uVar6 = local_e4;
|
|
if (*GHIDRA_CAST<int *>(&g_game->_deathmatchManager) < 2) {
|
|
LAB_0052926a:
|
|
local_124 = local_114;
|
|
}
|
|
else {
|
|
pEVar10 = (g_game->_deathmatchManager)._type;
|
|
local_120 = pEVar10;
|
|
uVar7 = Random();
|
|
fVar15 = local_114;
|
|
local_68 = 5;
|
|
uStack_64 = 9;
|
|
local_110 = 9.80909e-45;
|
|
local_60[0] = 7;
|
|
if (local_f4 != GHIDRA_CAST<Game *>(&DAT_00000005)) goto LAB_0052926a;
|
|
if (uVar6 < 0x12d) {
|
|
if (uVar6 == 300) {
|
|
while ((local_124 = local_114, local_114 == 0.0 ||
|
|
(cVar5 = pEVar10->Kill(), cVar5 != '\0'))) {
|
|
if (uVar7 == 0) {
|
|
KAGE_LogMessage(0x10,GHIDRA_CAST<byte *>("RNG Seed is zero!\n"));
|
|
fnPtr = (code *)swi(3);
|
|
(*fnPtr)();
|
|
return;
|
|
}
|
|
uVar7 = uVar7 >> ((byte)local_68 & 0x1f) ^ uVar7;
|
|
uVar7 = uVar7 << ((byte)uStack_64 & 0x1f) ^ uVar7;
|
|
uVar7 = uVar7 >> (SUB41(local_110,0) & 0x1f) ^ uVar7;
|
|
iVar9 = ItemPool::GetCardEx(uVar7,0x19,10,10,1);
|
|
iStack_28 = 5;
|
|
iStack_24 = 9;
|
|
uStack_20 = 7;
|
|
(*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(auStack_30)) + 0x4))) = uVar7;
|
|
local_114 = (float)lua_callback_run_get_card(GHIDRA_CAST<RNG *>((auStack_30 + 4)),iVar9,1,1,0);
|
|
}
|
|
}
|
|
else {
|
|
if (uVar6 == 0x46) {
|
|
local_d4.x = (float)(GHIDRA_UINT(local_114) >> 0xb);
|
|
do {
|
|
local_124 = local_114;
|
|
if (local_114 != 0.0) {
|
|
fnPtr = *(code **)(*GHIDRA_CAST<int *>(pEVar10) + 0x28);
|
|
(GHIDRA_CAST<ItemPool *>((&g_game->_itemPool)))->ItemPool::GetPillEffect(GHIDRA_UINT(local_114),GHIDRA_CAST<Entity_Player *>(0x0));
|
|
cVar5 = (*fnPtr)();
|
|
if (cVar5 == '\0') goto LAB_00529272;
|
|
pEVar10 = local_120;
|
|
}
|
|
if (uVar7 == 0) {
|
|
KAGE_LogMessage(0x10,GHIDRA_CAST<byte *>("RNG Seed is zero!\n"));
|
|
fnPtr = (code *)swi(3);
|
|
(*fnPtr)();
|
|
return;
|
|
}
|
|
uVar7 = uVar7 >> ((byte)local_68 & 0x1f) ^ uVar7;
|
|
uVar7 = uVar7 << ((byte)uStack_64 & 0x1f) ^ uVar7;
|
|
uVar7 = uVar7 >> (SUB41(local_110,0) & 0x1f) ^ uVar7;
|
|
uVar6 = ItemPool::GetPill(uVar7);
|
|
local_114 = (float)(uVar6 | (GHIDRA_UINT(local_d4.x) & 1) << 0xb);
|
|
} while( true );
|
|
}
|
|
if (uVar6 != 100) goto LAB_0052926a;
|
|
local_124 = local_114;
|
|
if (local_114 == 3.50325e-44) {
|
|
LAB_005290ba:
|
|
bVar14 = false;
|
|
}
|
|
else {
|
|
local_d4.x = local_114;
|
|
std::set<int>::find_node();
|
|
if (((*GHIDRA_CAST<char *>((foundNode + 0xd)) == '\0') && (*GHIDRA_CAST<int *>((foundNode + 0x10)) <= GHIDRA_INT(fVar15)))
|
|
&& (foundNode != pEVar10->_index)) goto LAB_005290ba;
|
|
bVar14 = true;
|
|
}
|
|
if ((fVar15 == 0.0) || (bVar14)) {
|
|
local_124 = (float)(**(code **)(*GHIDRA_CAST<int *>(pEVar10) + 0x84))();
|
|
local_114 = local_124;
|
|
}
|
|
}
|
|
}
|
|
else {
|
|
if (uVar6 != 0x15e) goto LAB_0052926a;
|
|
while ((local_124 = local_114, local_114 == 0.0 ||
|
|
(cVar5 = pEVar10->guard_check_icall(), cVar5 != '\0'))) {
|
|
local_114 = (float)(GHIDRA_CAST<ItemPool *>((&g_game->_itemPool)))->ItemPool::GetTrinket(0);
|
|
}
|
|
}
|
|
}
|
|
LAB_00529272:
|
|
local_120 = (GHIDRA_CAST<EntityFactory *>((local_11c->_entityFactory)))->EntityFactory::Create(GHIDRA_UINT(local_f4),0);
|
|
if (local_120 == GHIDRA_CAST<Entity *>(0x0)) goto LAB_00529568;
|
|
timeNs = GetTimeNs();
|
|
pEVar10 = local_120;
|
|
local_108 = GHIDRA_UINT((timeNs >> 0x20));
|
|
lVar1 = (timeNs & 0xffffffff) * 0x431bde82;
|
|
local_104 = GHIDRA_UINT(((ulonglong)lVar1 >> 0x20));
|
|
lVar2 = (ulonglong)local_108 * 0xd7b634db + ((timeNs & 0xffffffff) * 0xd7b634db >> 0x20);
|
|
local_d4.y = (float)(lVar2 + lVar1);
|
|
lVar1 = (ulonglong)local_108 * 0x431bde82 +
|
|
(ulonglong)
|
|
CONCAT14(CARRY4(GHIDRA_UINT(((ulonglong)lVar2 >> 0x20)),
|
|
local_104 + CARRY4(GHIDRA_UINT(lVar1),GHIDRA_UINT(lVar2))),
|
|
GHIDRA_INT(((ulonglong)(lVar2 + lVar1) >> 0x20)));
|
|
local_e0 = GHIDRA_UINT(((ulonglong)lVar1 >> 0x20));
|
|
pEVar17 = &local_120->_spawnerEntity;
|
|
local_10c = (float)(GHIDRA_UINT(lVar1) >> 0x12 | local_e0 * 0x4000);
|
|
local_e0 = local_e0 >> 0x12;
|
|
local_120->_spawnerType = 0;
|
|
local_120->_spawnerVariant = 0;
|
|
if (*pEVar17 != (EntityPtr)0x0) {
|
|
local_a4 = pEVar17;
|
|
std::multiset<unsigned_int>::erase();
|
|
}
|
|
iVar9 = *GHIDRA_CAST<int *>(pEVar10);
|
|
*pEVar17 = (EntityPtr)0x0;
|
|
(pEVar10->_pos).x = spawnPos.x;
|
|
(pEVar10->_pos).y = spawnPos.y;
|
|
(pEVar10->_velocity).x = spawnVelX;
|
|
(pEVar10->_velocity).y = (float)local_118;
|
|
(**(code **)(iVar9 + 4))(local_f4,local_e4);
|
|
game = local_11c;
|
|
pvVar11 = local_11c->_room;
|
|
iVar9 = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(pvVar11) + 0x1214));
|
|
*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(pvVar11) + 0x1214)) = iVar9 + 1;
|
|
pEVar10->_index = iVar9;
|
|
(GHIDRA_CAST<EntityList *>((GHIDRA_CAST<EntityList *>((GHIDRA_INT(pvVar11) + 0x1218)))))->EntityList::AddEntity(pEVar10);
|
|
isErased = Game::ShouldEraseEnemy(pEVar10);
|
|
if (isErased != 0) {
|
|
Entity::RemoveWithPoof(pEVar10,unusedArg);
|
|
}
|
|
if ((pEVar10->_exists != 0) &&
|
|
((game->_proceduralItemManager)._proceduralItems._begin !=
|
|
(game->_proceduralItemManager)._proceduralItems._end)) {
|
|
uStack_88 = pEVar10->_variant;
|
|
iStack_8c = pEVar10->_type;
|
|
std::map<unsigned_long_long>::find();
|
|
pvVar11 = (game->_proceduralItemManager)._spawnTriggerTargets._head;
|
|
if (pvStack_c4 == pvVar11) {
|
|
iStack_84 = pEVar10->_type;
|
|
uStack_80 = 0xffffffff;
|
|
piVar8 = GHIDRA_CAST<int *>(std)::map<unsigned_long_long>::find();
|
|
pvStack_c4 = (void *)*piVar8;
|
|
if (pvStack_c4 == pvVar11) goto LAB_005294e4;
|
|
}
|
|
uVar6 = 0;
|
|
playerManager = &g_game->_playerManager;
|
|
if (GHIDRA_INT((g_game->_playerManager)._playerList._end) - GHIDRA_INT((playerManager->_playerList)._begin) >>
|
|
2 != 0) {
|
|
do {
|
|
pvVar11 = (playerManager->_playerList)._end;
|
|
if (GHIDRA_INT(pvVar11) - GHIDRA_INT((playerManager->_playerList)._begin) >> 2 == 0) {
|
|
KAGE_LogMessage(0x10,GHIDRA_CAST<byte *>("(GHIDRA_CAST<PlayerManager *>(()))->PlayerManager::GetPlayer() : There are no players! \n"));
|
|
pvVar11 = (playerManager->_playerList)._end;
|
|
}
|
|
piVar8 = (playerManager->_playerList)._begin;
|
|
if (uVar6 < GHIDRA_UINT((GHIDRA_INT(pvVar11) - GHIDRA_INT(piVar8) >> 2))) {
|
|
piVar8 = piVar8 + uVar6;
|
|
}
|
|
trigger_set_dispatch((void *)(*piVar8 + 0x1fc8),6,pEVar10,&spawnPos,spawnVel);
|
|
uVar6 = uVar6 + 1;
|
|
playerManager = &g_game->_playerManager;
|
|
} while (uVar6 < GHIDRA_UINT((GHIDRA_INT((g_game->_playerManager)._playerList._end) -
|
|
GHIDRA_INT((playerManager->_playerList)._begin) >> 2)));
|
|
}
|
|
}
|
|
LAB_005294e4:
|
|
timeNs = GetTimeNs();
|
|
uVar6 = GHIDRA_UINT((timeNs >> 0x20));
|
|
lVar1 = (timeNs & 0xffffffff) * 0x431bde82;
|
|
local_104 = GHIDRA_UINT(((ulonglong)lVar1 >> 0x20));
|
|
lVar2 = (ulonglong)uVar6 * 0x431bde82;
|
|
local_108 = GHIDRA_UINT(lVar2);
|
|
lVar3 = (ulonglong)uVar6 * 0xd7b634db + ((timeNs & 0xffffffff) * 0xd7b634db >> 0x20);
|
|
local_d4.y = (float)(lVar3 + lVar1);
|
|
lVar2 = lVar2 + (ulonglong)
|
|
CONCAT14(CARRY4(GHIDRA_UINT(((ulonglong)lVar3 >> 0x20)),
|
|
local_104 + CARRY4(GHIDRA_UINT(lVar1),GHIDRA_UINT(lVar3))),
|
|
GHIDRA_INT(((ulonglong)(lVar3 + lVar1) >> 0x20)));
|
|
uVar7 = GHIDRA_UINT(((ulonglong)lVar2 >> 0x20));
|
|
fVar15 = (float)(GHIDRA_UINT(lVar2) >> 0x12 | uVar7 * 0x4000);
|
|
uVar6 = GHIDRA_INT(fVar15) - GHIDRA_INT(local_10c);
|
|
bVar14 = CARRY4(GHIDRA_UINT(g_entitySpawnTimeMs),uVar6);
|
|
(*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(g_entitySpawnTimeMs)) + 0x0))) = GHIDRA_UINT(g_entitySpawnTimeMs) + uVar6;
|
|
(*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(g_entitySpawnTimeMs)) + 0x4))) =
|
|
(*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(g_entitySpawnTimeMs)) + 0x4))) +
|
|
(((uVar7 >> 0x12) - local_e0) - GHIDRA_UINT((GHIDRA_UINT(fVar15) < GHIDRA_UINT(local_10c)))) + GHIDRA_UINT(bVar14);
|
|
LAB_00529568:
|
|
bloodVel[0].x = spawnVelX * 0.4;
|
|
bloodVel[0].y = (float)local_118 * 0.4;
|
|
iVar9 = GHIDRA_INT(owner[1]._pendingDamageFlags) * -7 + 0x42;
|
|
*GHIDRA_CAST<int *>((local_120 + 1)) = iVar9;
|
|
*GHIDRA_CAST<int *>(&(*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(&(local_120[1])) + 0x4)))) = iVar9;
|
|
uVar6 = Random();
|
|
pEVar10 = (GHIDRA_CAST<Game *>((g_game)))->Game::Spawn(1000,2,&spawnPos,bloodVel,GHIDRA_CAST<Entity *>(0x0),1,uVar6);
|
|
pEVar10->SetColor(&DAT_00c5c800,0xffffffff,0xff);
|
|
(pEVar10->_sprite)._offset.x = 0.0;
|
|
(pEVar10->_sprite)._offset.y = -5.0;
|
|
pEVar10->_renderDepthOffset = 10.0;
|
|
uVar6 = Random();
|
|
local_11c = GHIDRA_CAST<Game *>(((uVar6 & 1) + 1));
|
|
do {
|
|
if (local_11c == GHIDRA_CAST<Game *>(0x0)) {
|
|
return;
|
|
}
|
|
uVar6 = Random();
|
|
fVar15 = (float)((double)GHIDRA_INT(uVar6) + __uint_to_double_fixup[-(GHIDRA_INT(uVar6) >> 0x1f)]) *
|
|
2.3283064e-10 * 3.14;
|
|
local_f4 = GHIDRA_CAST<Game *>((fVar15 + fVar15));
|
|
fVar15 = cos((float)local_f4);
|
|
local_d4.x = fVar15 * 12.0 * 0.5 + spawnVelX;
|
|
fVar15 = sin((float)local_f4);
|
|
local_d4.y = fVar15 * 12.0 * 0.5 + fStack_fc;
|
|
uVar6 = Random();
|
|
fVar15 = (float)((double)GHIDRA_INT(uVar6) + __uint_to_double_fixup[-(GHIDRA_INT(uVar6) >> 0x1f)]) *
|
|
2.3283064e-10 * 3.14;
|
|
fVar15 = fVar15 + fVar15;
|
|
uVar6 = Random();
|
|
local_114 = (float)((double)GHIDRA_INT(uVar6) + __uint_to_double_fixup[-(GHIDRA_INT(uVar6) >> 0x1f)]) *
|
|
2.3283064e-10 * 4.0 + 2.0;
|
|
fVar16 = cos(fVar15);
|
|
pvStack_c4 = (void *)(fVar16 * local_114);
|
|
particleVel.x = (float)pvStack_c4;
|
|
local_10c = sin(fVar15);
|
|
local_10c = local_10c * local_114;
|
|
particleVel.y = local_10c;
|
|
local_104 = Random();
|
|
local_f4 = g_game;
|
|
pEVar17 = GHIDRA_CAST<EntityPtr *>(0x0);
|
|
local_124 = 7.00649e-45;
|
|
local_120 = GHIDRA_CAST<Entity *>(0x3e8);
|
|
lua_callback_run_pre_entity_spawn
|
|
(GHIDRA_CAST<int *>(&local_120),GHIDRA_CAST<int *>(&local_124),&local_d4,&particleVel,GHIDRA_CAST<Entity *>(0x0),
|
|
GHIDRA_CAST<int *>((apEStack_bc + -0x1f)),&local_104);
|
|
fVar15 = local_124;
|
|
if (1 < *GHIDRA_CAST<int *>(&g_game->_deathmatchManager)) {
|
|
piVar8 = (g_game->_deathmatchManager)._type;
|
|
uVar6 = Random();
|
|
uStack_6c = 5;
|
|
local_68 = 9;
|
|
local_114 = 9.80909e-45;
|
|
uStack_64 = 7;
|
|
if (local_120 == GHIDRA_CAST<Entity *>(&DAT_00000005)) {
|
|
if (GHIDRA_UINT(fVar15) < 0x12d) {
|
|
if (fVar15 == 4.2039e-43) {
|
|
while ((pEVar17 == GHIDRA_CAST<EntityPtr *>(0x0) ||
|
|
(cVar5 = (**(code **)(*piVar8 + 0x24))(pEVar17), cVar5 != '\0'))) {
|
|
if (uVar6 == 0) {
|
|
KAGE_LogMessage(0x10,GHIDRA_CAST<byte *>("RNG Seed is zero!\n"));
|
|
fnPtr = (code *)swi(3);
|
|
(*fnPtr)();
|
|
return;
|
|
}
|
|
uVar6 = uVar6 >> ((byte)uStack_6c & 0x1f) ^ uVar6;
|
|
uVar6 = uVar6 << ((byte)local_68 & 0x1f) ^ uVar6;
|
|
uVar6 = uVar6 >> (SUB41(local_114,0) & 0x1f) ^ uVar6;
|
|
iVar9 = ItemPool::GetCardEx(uVar6,0x19,10,10,1);
|
|
(*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(auStack_30)) + 0x4))) = 5;
|
|
iStack_28 = 9;
|
|
iStack_24 = 7;
|
|
(*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(auStack_30)) + 0x0))) = uVar6;
|
|
pEVar17 = GHIDRA_CAST<EntityPtr *>(lua_callback_run_get_card(GHIDRA_CAST<RNG *>(auStack_30),iVar9,1,1,0));
|
|
}
|
|
}
|
|
else {
|
|
if (fVar15 == 9.80909e-44) {
|
|
uVar7 = GHIDRA_UINT(pEVar17) >> 0xb;
|
|
do {
|
|
if (pEVar17 != GHIDRA_CAST<EntityPtr *>(0x0)) {
|
|
fnPtr = *(code **)(*piVar8 + 0x28);
|
|
iVar9 = ItemPool::GetPillEffect
|
|
(&g_game->_itemPool,GHIDRA_UINT(pEVar17),GHIDRA_CAST<Entity_Player *>(0x0));
|
|
cVar5 = (*fnPtr)(iVar9);
|
|
if (cVar5 == '\0') goto LAB_00529a2e;
|
|
}
|
|
if (uVar6 == 0) {
|
|
KAGE_LogMessage(0x10,GHIDRA_CAST<byte *>("RNG Seed is zero!\n"));
|
|
fnPtr = (code *)swi(3);
|
|
(*fnPtr)();
|
|
return;
|
|
}
|
|
uVar6 = uVar6 >> ((byte)uStack_6c & 0x1f) ^ uVar6;
|
|
uVar6 = uVar6 << ((byte)local_68 & 0x1f) ^ uVar6;
|
|
uVar6 = uVar6 >> (SUB41(local_114,0) & 0x1f) ^ uVar6;
|
|
uVar12 = ItemPool::GetPill(uVar6);
|
|
pEVar17 = GHIDRA_CAST<EntityPtr *>((uVar12 | (uVar7 & 1) << 0xb));
|
|
} while( true );
|
|
}
|
|
if (fVar15 == 1.4013e-43) {
|
|
if (pEVar17 == GHIDRA_CAST<EntityPtr *>(0x19)) {
|
|
LAB_00529876:
|
|
bVar14 = false;
|
|
}
|
|
else {
|
|
local_a4 = pEVar17;
|
|
std::set<int>::find_node(auStack_4c,&local_a4);
|
|
if (((*GHIDRA_CAST<char *>((foundNode2 + 0xd)) == '\0') &&
|
|
(*GHIDRA_CAST<int *>((foundNode2 + 0x10)) <= GHIDRA_INT(pEVar17))) && (foundNode2 != piVar8[8]))
|
|
goto LAB_00529876;
|
|
bVar14 = true;
|
|
}
|
|
if ((pEVar17 == GHIDRA_CAST<EntityPtr *>(0x0)) || (bVar14)) {
|
|
pEVar17 = GHIDRA_CAST<EntityPtr *>((**(code **)(*piVar8 + 0x84))(0));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else if (fVar15 == 4.90454e-43) {
|
|
while ((pEVar17 == GHIDRA_CAST<EntityPtr *>(0x0) ||
|
|
(cVar5 = (**(code **)(*piVar8 + 0x2c))(pEVar17), cVar5 != '\0'))) {
|
|
pEVar17 = GHIDRA_CAST<EntityPtr *>((GHIDRA_CAST<ItemPool *>((&g_game->_itemPool)))->ItemPool)::GetTrinket(0);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
LAB_00529a2e:
|
|
pEVar10 = (GHIDRA_CAST<EntityFactory *>((local_f4->_entityFactory)))->EntityFactory::Create(GHIDRA_UINT(local_120),0);
|
|
if (pEVar10 != GHIDRA_CAST<Entity *>(0x0)) {
|
|
timeNs = GetTimeNs();
|
|
uVar6 = GHIDRA_UINT((timeNs >> 0x20));
|
|
lVar1 = (timeNs & 0xffffffff) * 0x431bde82;
|
|
lVar2 = (ulonglong)uVar6 * 0xd7b634db + ((timeNs & 0xffffffff) * 0xd7b634db >> 0x20);
|
|
local_114 = (float)(lVar2 + lVar1);
|
|
lVar1 = (ulonglong)uVar6 * 0x431bde82 +
|
|
(ulonglong)
|
|
CONCAT14(CARRY4(GHIDRA_UINT(((ulonglong)lVar2 >> 0x20)),
|
|
GHIDRA_INT(((ulonglong)lVar1 >> 0x20)) +
|
|
GHIDRA_UINT(CARRY4(GHIDRA_UINT(lVar1),GHIDRA_UINT(lVar2)))),
|
|
GHIDRA_INT(((ulonglong)(lVar2 + lVar1) >> 0x20)));
|
|
uStack_cc = GHIDRA_UINT(((ulonglong)lVar1 >> 0x20));
|
|
spawnerRef = &pEVar10->_spawnerEntity;
|
|
uVar6 = GHIDRA_UINT(lVar1) >> 0x12 | uStack_cc * 0x4000;
|
|
uStack_cc = uStack_cc >> 0x12;
|
|
pEVar10->_spawnerType = 0;
|
|
pEVar10->_spawnerVariant = 0;
|
|
if (*spawnerRef != (EntityPtr)0x0) {
|
|
apEStack_bc[0] = spawnerRef;
|
|
std::multiset<unsigned_int>::erase(apEStack_bc);
|
|
}
|
|
iVar9 = *GHIDRA_CAST<int *>(pEVar10);
|
|
*spawnerRef = (EntityPtr)0x0;
|
|
(pEVar10->_pos).x = local_d4.x;
|
|
(pEVar10->_pos).y = local_d4.y;
|
|
(pEVar10->_velocity).x = (float)pvStack_c4;
|
|
(pEVar10->_velocity).y = local_10c;
|
|
(**(code **)(iVar9 + 4))(local_120,local_124,pEVar17,local_104);
|
|
game = local_f4;
|
|
pvVar11 = local_f4->_room;
|
|
iVar9 = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(pvVar11) + 0x1214));
|
|
*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(pvVar11) + 0x1214)) = iVar9 + 1;
|
|
pEVar10->_index = iVar9;
|
|
(GHIDRA_CAST<EntityList *>((GHIDRA_CAST<EntityList *>((GHIDRA_INT(pvVar11) + 0x1218)))))->EntityList::AddEntity(pEVar10);
|
|
isErased = Game::ShouldEraseEnemy(pEVar10);
|
|
if (isErased != 0) {
|
|
Entity::RemoveWithPoof(pEVar10,unusedArg_00);
|
|
}
|
|
if ((pEVar10->_exists != 0) &&
|
|
((game->_proceduralItemManager)._proceduralItems._begin !=
|
|
(game->_proceduralItemManager)._proceduralItems._end)) {
|
|
iStack_84 = pEVar10->_variant;
|
|
uVar7 = pEVar10->_type;
|
|
uStack_88 = uVar7;
|
|
std::map<unsigned_long_long>::find(&local_118,&uStack_88);
|
|
if (local_118 == (game->_proceduralItemManager)._spawnTriggerTargets._head) {
|
|
local_e0 = 0xffffffff;
|
|
local_e4 = uVar7;
|
|
piVar8 = GHIDRA_CAST<int *>(std)::map<unsigned_long_long>::find(local_60,&local_e4);
|
|
local_118 = (void *)*piVar8;
|
|
if (local_118 == (game->_proceduralItemManager)._spawnTriggerTargets._head)
|
|
goto LAB_00529ca4;
|
|
}
|
|
uVar7 = 0;
|
|
playerManager = &g_game->_playerManager;
|
|
if (GHIDRA_INT((g_game->_playerManager)._playerList._end) -
|
|
GHIDRA_INT((playerManager->_playerList)._begin) >> 2 != 0) {
|
|
do {
|
|
pvVar11 = (playerManager->_playerList)._end;
|
|
if (GHIDRA_INT(pvVar11) - GHIDRA_INT((playerManager->_playerList)._begin) >> 2 == 0) {
|
|
KAGE_LogMessage(0x10,GHIDRA_CAST<byte *>("(GHIDRA_CAST<PlayerManager *>(()))->PlayerManager::GetPlayer() : There are no players! \n"));
|
|
pvVar11 = (playerManager->_playerList)._end;
|
|
}
|
|
piVar8 = (playerManager->_playerList)._begin;
|
|
if (uVar7 < GHIDRA_UINT((GHIDRA_INT(pvVar11) - GHIDRA_INT(piVar8) >> 2))) {
|
|
piVar8 = piVar8 + uVar7;
|
|
}
|
|
trigger_set_dispatch((void *)(*piVar8 + 0x1fc8),6,pEVar10,&local_d4,&particleVel);
|
|
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_00529ca4:
|
|
timeNs = GetTimeNs();
|
|
uVar7 = GHIDRA_UINT((timeNs >> 0x20));
|
|
lVar1 = (timeNs & 0xffffffff) * 0x431bde82;
|
|
pvStack_c4 = (void *)((ulonglong)lVar1 >> 0x20);
|
|
lVar2 = (ulonglong)uVar7 * 0x431bde82;
|
|
local_10c = (float)lVar2;
|
|
lVar3 = (ulonglong)uVar7 * 0xd7b634db + ((timeNs & 0xffffffff) * 0xd7b634db >> 0x20);
|
|
local_f4 = GHIDRA_CAST<Game *>((lVar3 + lVar1));
|
|
lVar2 = lVar2 + (ulonglong)
|
|
CONCAT14(CARRY4(GHIDRA_UINT(((ulonglong)lVar3 >> 0x20)),
|
|
GHIDRA_INT(pvStack_c4) + GHIDRA_UINT(CARRY4(GHIDRA_UINT(lVar1),GHIDRA_UINT(lVar3)))),
|
|
GHIDRA_INT(((ulonglong)(lVar3 + lVar1) >> 0x20)));
|
|
uVar13 = GHIDRA_UINT(((ulonglong)lVar2 >> 0x20));
|
|
uVar7 = GHIDRA_UINT(lVar2) >> 0x12 | uVar13 * 0x4000;
|
|
uVar12 = uVar7 - uVar6;
|
|
bVar14 = CARRY4(GHIDRA_UINT(g_entitySpawnTimeMs),uVar12);
|
|
(*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(g_entitySpawnTimeMs)) + 0x0))) = GHIDRA_UINT(g_entitySpawnTimeMs) + uVar12;
|
|
(*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(g_entitySpawnTimeMs)) + 0x4))) =
|
|
(*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(g_entitySpawnTimeMs)) + 0x4))) + (((uVar13 >> 0x12) - uStack_cc) - GHIDRA_UINT((uVar7 < uVar6))) +
|
|
GHIDRA_UINT(bVar14);
|
|
}
|
|
pEVar10->SetColor(&DAT_00c5c800,0xffffffff,0xff,0,1);
|
|
spriteColor = &(pEVar10->_sprite)._color;
|
|
if (&pEVar10->_splatColor != spriteColor) {
|
|
fVar15 = (pEVar10->_sprite)._color._tint[1];
|
|
fVar16 = (pEVar10->_sprite)._color._tint[2];
|
|
fVar4 = (pEVar10->_sprite)._color._tint[3];
|
|
(pEVar10->_splatColor)._tint[0] = spriteColor->_tint[0];
|
|
(pEVar10->_splatColor)._tint[1] = fVar15;
|
|
(pEVar10->_splatColor)._tint[2] = fVar16;
|
|
(pEVar10->_splatColor)._tint[3] = fVar4;
|
|
fVar15 = (pEVar10->_sprite)._color._colorize[1];
|
|
fVar16 = (pEVar10->_sprite)._color._colorize[2];
|
|
fVar4 = (pEVar10->_sprite)._color._colorize[3];
|
|
(pEVar10->_splatColor)._colorize[0] = (pEVar10->_sprite)._color._colorize[0];
|
|
(pEVar10->_splatColor)._colorize[1] = fVar15;
|
|
(pEVar10->_splatColor)._colorize[2] = fVar16;
|
|
(pEVar10->_splatColor)._colorize[3] = fVar4;
|
|
*GHIDRA_CAST<undefined8 *>((pEVar10->_splatColor)._offset) =
|
|
*GHIDRA_CAST<undefined8 *>((pEVar10->_sprite)._color._offset);
|
|
(pEVar10->_splatColor)._offset[2] = (pEVar10->_sprite)._color._offset[2];
|
|
}
|
|
pEVar10->Update();
|
|
local_11c = GHIDRA_CAST<Game *>((GHIDRA_INT(local_11c) + -1));
|
|
} while( true );
|
|
}
|
|
|
|
// 005441e0
|
|
byte NpcHelper::tarboy_is_creep_near(Entity_NPC *npc, Vector *position)
|
|
{
|
|
int iVar1;
|
|
uint i;
|
|
int *entityIt;
|
|
float deltaY;
|
|
float deltaX;
|
|
uint entityCount;
|
|
bool isFriendly;
|
|
|
|
if ((npc == GHIDRA_CAST<Entity_NPC *>(0x0)) || ((npc->_flags & 0x20000000) == 0)) {
|
|
isFriendly = false;
|
|
}
|
|
else {
|
|
isFriendly = true;
|
|
}
|
|
i = 0;
|
|
entityCount = *GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(g_game->_room) + 0x1264));
|
|
if (entityCount != 0) {
|
|
entityIt = *GHIDRA_CAST<int **>((GHIDRA_CAST<char *>(g_game->_room) + 0x125c));
|
|
do {
|
|
iVar1 = *entityIt;
|
|
if ((*GHIDRA_CAST<int *>((iVar1 + 0x28)) == 1000) &&
|
|
(((*GHIDRA_CAST<int *>((iVar1 + 0x2c)) == 0x1a || ((isFriendly && (*GHIDRA_CAST<int *>((iVar1 + 0x2c)) == 0x2d)))) &&
|
|
(deltaX = position->x - *GHIDRA_CAST<float *>((iVar1 + 0x33c)),
|
|
deltaY = position->y - *GHIDRA_CAST<float *>((iVar1 + 0x340)),
|
|
deltaX * deltaX + deltaY * deltaY < 676.0)))) {
|
|
return 1;
|
|
}
|
|
i = i + 1;
|
|
entityIt = entityIt + 1;
|
|
} while (i < entityCount);
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
// 00548720
|
|
void NpcHelper::leper_flesh_ai(Entity_NPC *npc)
|
|
{
|
|
code *pcVar1;
|
|
byte bVar2;
|
|
Vector *pVVar3;
|
|
uint uVar4;
|
|
byte *pbVar5;
|
|
uint uVar6;
|
|
Entity *pEVar7;
|
|
byte *expectedName;
|
|
int extraout_ECX;
|
|
int extraout_ECX_00;
|
|
int unused;
|
|
bool isLess;
|
|
float fVar8;
|
|
float fVar9;
|
|
undefined4 sourceRef;
|
|
undefined4 local_114;
|
|
undefined4 local_110;
|
|
undefined4 local_10c;
|
|
float local_108;
|
|
float local_104;
|
|
float local_100;
|
|
float local_fc;
|
|
undefined4 local_f8;
|
|
undefined4 local_f4;
|
|
float local_f0;
|
|
undefined4 uStack_ec;
|
|
undefined4 uStack_e8;
|
|
undefined4 uStack_e4;
|
|
Vector local_d4;
|
|
float local_cc;
|
|
byte *local_c8;
|
|
float local_c4;
|
|
ProjectileParams projParams;
|
|
float local_14;
|
|
|
|
local_14 = (float)(__security_cookie ^ GHIDRA_UINT(&(&projParams)[1].CircleAngle));
|
|
if (npc->_state != 0) {
|
|
if (npc->_state == 4) {
|
|
npc->_friction = npc->_friction * 0.95;
|
|
pVVar3 = (GHIDRA_CAST<Entity_NPC *>((npc)))->Entity_NPC::CalcTargetPosition(&local_d4,0.0);
|
|
local_c8 = GHIDRA_CAST<byte *>((pVVar3->y - (npc->_pos).y));
|
|
local_c4 = pVVar3->x - (npc->_pos).x;
|
|
fVar8 = sqrtf((float)local_c8 * (float)local_c8 + local_c4 * local_c4);
|
|
if (0.0 < fVar8) {
|
|
local_c4 = local_c4 * (1.0 / fVar8);
|
|
local_c8 = GHIDRA_CAST<byte *>(((float)local_c8 * (1.0 / fVar8)));
|
|
}
|
|
if (npc->_controllerID != -1) {
|
|
pVVar3 = (GHIDRA_CAST<Entity_NPC *>((npc)))->Entity_NPC::GetControllerInput(&local_d4,0.0);
|
|
local_c4 = pVVar3->x;
|
|
local_c8 = GHIDRA_CAST<byte *>(pVVar3->y);
|
|
}
|
|
uVar4 = Random();
|
|
local_cc = (float)((double)GHIDRA_INT(uVar4) + __uint_to_double_fixup[-(GHIDRA_INT(uVar4) >> 0x1f)]) *
|
|
2.3283064e-10 * 3.14;
|
|
local_cc = local_cc + local_cc;
|
|
local_d4.y = cos(local_cc);
|
|
fVar9 = sin(local_cc);
|
|
fVar8 = npc->_speedMultiplier;
|
|
(npc->_velocity).y = (fVar9 + fVar9 + (float)local_c8) * 0.15 * fVar8 + (npc->_velocity).y;
|
|
(npc->_velocity).x = (local_d4.y + local_d4.y + local_c4) * 0.15 * fVar8 + (npc->_velocity).x;
|
|
}
|
|
goto LAB_00548a4b;
|
|
}
|
|
uVar4 = npc->_initSeed;
|
|
local_c4 = 2.10195e-44;
|
|
local_d4.y = (float)&npc->_sprite;
|
|
uStack_ec = 2;
|
|
uStack_e8 = 5;
|
|
if (uVar4 == 0) {
|
|
KAGE_LogMessage(0x10,GHIDRA_CAST<byte *>("RNG Seed is zero!\n"));
|
|
pcVar1 = (code *)swi(3);
|
|
(*pcVar1)();
|
|
return;
|
|
}
|
|
uVar4 = uVar4 >> 2 ^ uVar4;
|
|
uVar4 = uVar4 << 5 ^ uVar4;
|
|
uVar4 = uVar4 >> 0xf ^ uVar4;
|
|
local_c8 = (&PTR_DAT_00b614c0)[uVar4 % 6];
|
|
pbVar5 = (npc->_sprite)._animState._animData;
|
|
if (pbVar5 == GHIDRA_CAST<byte *>(0x0)) {
|
|
LAB_005489d8:
|
|
bVar2 = (GHIDRA_CAST<ANM2 *>((&npc->_sprite)))->ANM2::SetAnimation(local_c8,1);
|
|
if (bVar2 != 0) {
|
|
(GHIDRA_CAST<AnimationState *>((&(npc->_sprite)._animState)))->AnimationState::Rewind();
|
|
(npc->_sprite)._animState._isPlaying = 1;
|
|
}
|
|
}
|
|
else {
|
|
if (0xf < *GHIDRA_CAST<uint *>((pbVar5 + 0x14))) {
|
|
pbVar5 = *GHIDRA_CAST<byte **>(pbVar5);
|
|
}
|
|
expectedName = local_c8;
|
|
do {
|
|
bVar2 = *pbVar5;
|
|
isLess = bVar2 < *expectedName;
|
|
if (bVar2 != *expectedName) {
|
|
LAB_005489b8:
|
|
uVar6 = -GHIDRA_UINT(isLess) | 1;
|
|
goto LAB_005489bd;
|
|
}
|
|
if (bVar2 == 0) break;
|
|
bVar2 = pbVar5[1];
|
|
isLess = bVar2 < expectedName[1];
|
|
if (bVar2 != expectedName[1]) goto LAB_005489b8;
|
|
pbVar5 = pbVar5 + 2;
|
|
expectedName = expectedName + 2;
|
|
} while (bVar2 != 0);
|
|
uVar6 = 0;
|
|
LAB_005489bd:
|
|
if ((uVar6 != 0) ||
|
|
((*GHIDRA_CAST<char *>((GHIDRA_INT((npc->_sprite)._animState._animData) + 0x34)) != '\0' &&
|
|
((npc->_sprite)._animState._isPlaying == 0)))) goto LAB_005489d8;
|
|
}
|
|
npc->_state = 4;
|
|
if (uVar4 == 0) {
|
|
KAGE_LogMessage(0x10,GHIDRA_CAST<byte *>("RNG Seed is zero!\n"));
|
|
pcVar1 = (code *)swi(3);
|
|
(*pcVar1)();
|
|
return;
|
|
}
|
|
uVar4 = uVar4 >> ((byte)uStack_ec & 0x1f) ^ uVar4;
|
|
uVar4 = uVar4 << ((byte)uStack_e8 & 0x1f) ^ uVar4;
|
|
(npc->_sprite)._flipX = ~((byte)(uVar4 >> (SUB41(local_c4,0) & 0x1f)) ^ (byte)uVar4) & 1;
|
|
npc->_isKillOnTouch = 1;
|
|
LAB_00548a4b:
|
|
bVar2 = (GHIDRA_CAST<Entity *>((GHIDRA_CAST<Entity *>(npc))))->Entity::IsFrame(10,0);
|
|
if (bVar2 != 0) {
|
|
uVar4 = Random();
|
|
Entity_NPC::MakeSplat
|
|
(npc,(float)((double)GHIDRA_INT(uVar4) + __uint_to_double_fixup[-(GHIDRA_INT(uVar4) >> 0x1f)]) *
|
|
2.3283064e-10 * 0.4 + 0.4);
|
|
}
|
|
bVar2 = (GHIDRA_CAST<Entity *>((GHIDRA_CAST<Entity *>(npc))))->Entity::IsFrame(6,0);
|
|
local_f0 = 0.3;
|
|
uStack_ec = 0;
|
|
uStack_e8 = 0;
|
|
uStack_e4 = 0;
|
|
unused = extraout_ECX;
|
|
if (bVar2 != 0) {
|
|
uVar4 = Random();
|
|
local_d4.y = (npc->_velocity).x;
|
|
local_cc = (npc->_velocity).y;
|
|
uVar6 = Random();
|
|
fVar8 = (float)((double)GHIDRA_INT(uVar6) + __uint_to_double_fixup[-(GHIDRA_INT(uVar6) >> 0x1f)]) *
|
|
2.3283064e-10 * 3.14;
|
|
local_c8 = GHIDRA_CAST<byte *>((fVar8 + fVar8));
|
|
uVar6 = Random();
|
|
local_c4 = (float)((double)GHIDRA_INT(uVar6) + __uint_to_double_fixup[-(GHIDRA_INT(uVar6) >> 0x1f)]) *
|
|
2.3283064e-10;
|
|
fVar8 = cos((float)local_c8);
|
|
local_d4.x = fVar8 * local_c4 * 3.0 + local_d4.y * local_f0;
|
|
fVar8 = sin((float)local_c8);
|
|
local_d4.y = fVar8 * local_c4 * 3.0 + local_cc * local_f0;
|
|
pEVar7 = (GHIDRA_CAST<Game *>((g_game)))->Game::Spawn(1000,0x6f,&npc->_pos,&local_d4,GHIDRA_CAST<Entity *>(0x0),0,uVar4);
|
|
uVar4 = Random();
|
|
(pEVar7->_sprite)._playbackSpeed =
|
|
(float)((double)GHIDRA_INT(uVar4) + __uint_to_double_fixup[-(GHIDRA_INT(uVar4) >> 0x1f)]) * 2.3283064e-10
|
|
* 0.6 + 0.5;
|
|
local_cc = npc->_scale * g_vectorOne.y;
|
|
local_d4.y = npc->_scale * g_vectorOne.x;
|
|
uVar4 = Random();
|
|
fVar8 = (float)((double)GHIDRA_INT(uVar4) + __uint_to_double_fixup[-(GHIDRA_INT(uVar4) >> 0x1f)]) *
|
|
2.3283064e-10 * 0.6 + 0.6;
|
|
(pEVar7->_sprite)._scale.x = local_d4.y * 0.5 * fVar8;
|
|
(pEVar7->_sprite)._scale.y = local_cc * 0.5 * fVar8;
|
|
(pEVar7->_posOffset).x = 0.0;
|
|
(pEVar7->_posOffset).y = -22.0;
|
|
pEVar7->_renderZOffset = -400;
|
|
unused = extraout_ECX_00;
|
|
}
|
|
if ((npc->_controllerID != -1) &&
|
|
(bVar2 = input_is_action_pressed(9,npc->_controllerID,GHIDRA_CAST<Entity *>(npc),unused), bVar2 != 0)) {
|
|
sourceRef = 0;
|
|
local_114 = 0;
|
|
local_110 = 0;
|
|
local_10c = 0;
|
|
local_108 = g_vectorZero.x;
|
|
local_104 = g_vectorZero.y;
|
|
local_100 = g_vectorZero.x;
|
|
local_fc = g_vectorZero.y;
|
|
local_f8 = 0;
|
|
local_f4 = 0;
|
|
npc->Kill(&sourceRef);
|
|
}
|
|
if ((npc->_dead != 0) && ((npc->_flags & 0x1000000) == 0)) {
|
|
pEVar7 = (GHIDRA_CAST<Entity_NPC *>((npc)))->Entity_NPC::GetPlayerTarget();
|
|
local_c8 = GHIDRA_CAST<byte *>((pEVar7->_velocity).x);
|
|
fVar8 = (npc->_pos).y - (pEVar7->_pos).y;
|
|
local_c4 = (pEVar7->_velocity).y;
|
|
fVar9 = (npc->_pos).x - (pEVar7->_pos).x;
|
|
fVar8 = sqrtf(fVar8 * fVar8 + fVar9 * fVar9);
|
|
local_c8 = GHIDRA_CAST<byte *>((((float)local_c8 * 0.1 * fVar8 + (pEVar7->_pos).x) - (npc->_pos).x));
|
|
local_c4 = (local_c4 * 0.1 * fVar8 + (pEVar7->_pos).y) - (npc->_pos).y;
|
|
fVar8 = sqrtf(local_c4 * local_c4 + (float)local_c8 * (float)local_c8);
|
|
if (fVar8 <= 0.0) {
|
|
pbVar5 = local_c8;
|
|
fVar8 = local_c4;
|
|
}
|
|
else {
|
|
pbVar5 = GHIDRA_CAST<byte *>(((float)local_c8 * (1.0 / fVar8)));
|
|
fVar8 = local_c4 * (1.0 / fVar8);
|
|
}
|
|
local_d4.x = (float)pbVar5 * 10.0;
|
|
local_d4.y = fVar8 * 10.0;
|
|
(GHIDRA_CAST<ProjectileParams *>((&projParams)))->ProjectileParams::ProjectileParams();
|
|
projParams.Color._offset[2] = 0.0;
|
|
projParams.Color._tint[0] = 1.0;
|
|
projParams.Color._tint[1] = 1.0;
|
|
projParams.Color._tint[2] = 1.0;
|
|
projParams.Color._tint[3] = 1.0;
|
|
(*GHIDRA_CAST<undefined8 *>((GHIDRA_CAST<char *>(&(projParams.Color._offset)) + 0x0))) = ZEXT48(GHIDRA_UINT(local_f0));
|
|
projParams.Color._colorize[0] = 0.0;
|
|
projParams.Color._colorize[1] = 0.0;
|
|
projParams.Color._colorize[2] = 0.0;
|
|
projParams.Color._colorize[3] = 0.0;
|
|
Entity_NPC::FireProjectiles(npc,&npc->_pos,&local_d4,0,&projParams);
|
|
}
|
|
return;
|
|
}
|
|
|
|
// 0054ccc0
|
|
void NpcHelper::bulb_player_collision(Entity_NPC *npc, Entity *collider)
|
|
{
|
|
EntityRef *sourceRef;
|
|
uint uVar1;
|
|
int chargeChange;
|
|
Entity *effect;
|
|
uint uVar2;
|
|
float proceduralIdx;
|
|
float fVar3;
|
|
Game *game;
|
|
bool bVar4;
|
|
float fVar5;
|
|
int itemConfig;
|
|
Vector local_3c;
|
|
Entity_NPC *npcLocal;
|
|
EntityRef damageSource;
|
|
Manager *manager;
|
|
|
|
npcLocal = npc;
|
|
if (npc->_variant == 6) {
|
|
if ((collider->_type == 1) || (collider->_type == 3)) {
|
|
damageSource._position.x = (npc->_pos).x;
|
|
damageSource._position.y = (npc->_pos).y;
|
|
damageSource._type = npc->_type;
|
|
damageSource._spawnerType = npc->_spawnerType;
|
|
damageSource._spawnerVariant = npc->_spawnerVariant;
|
|
damageSource._velocity.x = (npc->_velocity).x;
|
|
damageSource._velocity.y = (npc->_velocity).y;
|
|
damageSource._variant = 6;
|
|
local_3c.x = (float)GHIDRA_UINT(((npc->_flags & 0x100) != 0));
|
|
if ((npc->_flags & 0x20000000) == 0) {
|
|
uVar2 = 0;
|
|
}
|
|
else {
|
|
uVar2 = 2;
|
|
}
|
|
if ((npc->_flags & 0x40000000000000) == 0) {
|
|
uVar1 = 0;
|
|
}
|
|
else {
|
|
uVar1 = 4;
|
|
}
|
|
damageSource._flags = uVar1 | uVar2 | GHIDRA_UINT(local_3c.x);
|
|
damageSource._entity = npc;
|
|
collider->TakeDamage(0x3f800000,0,0,&damageSource,0x1e);
|
|
}
|
|
else {
|
|
sourceRef = (GHIDRA_CAST<EntityRef *>((&damageSource)))->EntityRef::EntityRef();
|
|
collider->TakeDamage(0x41200000,0,0,sourceRef,0x1e);
|
|
}
|
|
npc->_state = 6;
|
|
fVar5 = -(npc->_v1).x;
|
|
proceduralIdx = -(npc->_v1).y;
|
|
(npc->_v1).x = fVar5;
|
|
(npc->_v1).y = proceduralIdx;
|
|
npc->_stateFrame = 4;
|
|
fVar3 = (npc->_pos).y;
|
|
(npc->_targetPosition).x = fVar5 * 80.0 + (npc->_pos).x;
|
|
(npc->_targetPosition).y = proceduralIdx * 80.0 + fVar3;
|
|
fVar3 = (npc->_v1).y;
|
|
proceduralIdx = npc->_speedMultiplier;
|
|
(npc->_velocity).x = (npc->_v1).x * 16.0 * proceduralIdx + (npc->_velocity).x;
|
|
(npc->_velocity).y = fVar3 * 16.0 * proceduralIdx + (npc->_velocity).y;
|
|
return;
|
|
}
|
|
if ((collider == GHIDRA_CAST<Entity *>(0x0)) || (collider->_type != 1)) {
|
|
return;
|
|
}
|
|
npc->_state = 6;
|
|
proceduralIdx = -(npc->_v1).x;
|
|
fVar5 = -(npc->_v1).y;
|
|
npc->_stateFrame = 4;
|
|
(npc->_v1).x = proceduralIdx;
|
|
(npc->_v1).y = fVar5;
|
|
fVar3 = (npc->_pos).x;
|
|
(npc->_targetPosition).y = fVar5 * 80.0 + (npc->_pos).y;
|
|
(npc->_targetPosition).x = proceduralIdx * 80.0 + fVar3;
|
|
fVar3 = npc->_speedMultiplier;
|
|
(npc->_velocity).x = proceduralIdx * 16.0 * fVar3 + (npc->_velocity).x;
|
|
(npc->_velocity).y = fVar5 * 16.0 * fVar3 + (npc->_velocity).y;
|
|
(GHIDRA_CAST<Entity_Player *>((GHIDRA_CAST<Entity_Player *>(collider))))->Entity_Player::PlayExtraAnimation(&DAT_00b1d3b0);
|
|
(GHIDRA_CAST<Entity_Player *>((GHIDRA_CAST<Entity_Player *>(collider))))->Entity_Player::ResetItemState();
|
|
uVar2 = 0;
|
|
game = g_game;
|
|
do {
|
|
fVar3 = collider[5]._sprite._championColor._colorize[uVar2 * 8 + 1];
|
|
if (game == GHIDRA_CAST<Game *>(0x0)) {
|
|
if (-1 < GHIDRA_INT(fVar3)) goto LAB_0054cfd6;
|
|
LAB_0054d012:
|
|
itemConfig = 0;
|
|
}
|
|
else if (GHIDRA_INT(fVar3) < 0) {
|
|
proceduralIdx = (float)~GHIDRA_UINT(fVar3);
|
|
bVar4 = -1 < GHIDRA_INT(fVar3);
|
|
fVar3 = proceduralIdx;
|
|
if ((bVar4) ||
|
|
(GHIDRA_INT((game->_proceduralItemManager)._proceduralItems._end) -
|
|
GHIDRA_INT((game->_proceduralItemManager)._proceduralItems._begin) >> 2 <= GHIDRA_INT(proceduralIdx)))
|
|
goto LAB_0054d012;
|
|
itemConfig = **GHIDRA_CAST<int **>((GHIDRA_INT((game->_proceduralItemManager)._proceduralItems._begin) +
|
|
GHIDRA_INT(proceduralIdx) * 4));
|
|
}
|
|
else {
|
|
LAB_0054cfd6:
|
|
if (GHIDRA_INT((g_manager->_itemConfig)._collectibles._end) -
|
|
GHIDRA_INT((g_manager->_itemConfig)._collectibles._begin) >> 2 <= GHIDRA_INT(fVar3)) goto LAB_0054d012;
|
|
itemConfig = *GHIDRA_CAST<int *>((GHIDRA_INT((g_manager->_itemConfig)._collectibles._begin) + GHIDRA_INT(fVar3) * 4));
|
|
game = g_game;
|
|
}
|
|
if (uVar2 == 3) {
|
|
local_3c.x = 0.0;
|
|
}
|
|
else if (((uVar2 == 2) &&
|
|
((*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(&(chargeChange)) + 0x0))) = collider[5]._valid, (*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(&(chargeChange)) + 0x1))) = collider[5]._visible,
|
|
(*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(&(chargeChange)) + 0x2))) = collider[5]._exists, (*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(&(chargeChange)) + 0x3))) = collider[5]._dead,
|
|
chargeChange == 0x244)) && (game->_challenge == 0x2c)) {
|
|
local_3c.x = 0.0;
|
|
}
|
|
else {
|
|
local_3c.x = (float)Entity_Player::GetCollectibleMaxCharge
|
|
(GHIDRA_CAST<Entity_Player *>(collider),
|
|
GHIDRA_INT(collider[5]._sprite._championColor._colorize)
|
|
[uVar2 * 8 + 1],
|
|
*GHIDRA_CAST<int *>((GHIDRA_INT((&collider[5]._sprite._championColor + 1)) +
|
|
uVar2 * 0x20 + 4)),GHIDRA_INT(fVar3));
|
|
game = g_game;
|
|
}
|
|
if (((itemConfig != 0) && (0 < GHIDRA_INT(local_3c.x))) &&
|
|
((uVar2 < 4 && (0 < GHIDRA_INT(collider[5]._sprite._championColor._colorize[uVar2 * 8 + 3]))))) {
|
|
chargeChange = (GHIDRA_CAST<Entity_Player *>((GHIDRA_CAST<Entity_Player *>(collider))))->Entity_Player::GetActiveMaxCharge(uVar2);
|
|
if (chargeChange == 1) {
|
|
chargeChange = -1000;
|
|
}
|
|
else if (GHIDRA_INT(local_3c.x) < 0xd) {
|
|
chargeChange = -2;
|
|
}
|
|
else {
|
|
chargeChange = GHIDRA_INT(((ulonglong)((longlong)GHIDRA_INT(local_3c.x) * 0x55555555) >> 0x20)) -
|
|
GHIDRA_INT(local_3c.x);
|
|
chargeChange = (chargeChange >> 1) - (chargeChange >> 0x1f);
|
|
}
|
|
Entity_Player::AddActiveCharge(GHIDRA_CAST<Entity_Player *>(collider),chargeChange,uVar2,0,0,0);
|
|
(GHIDRA_CAST<HUD *>((&g_game->_hud)))->HUD::FlashChargeBar(GHIDRA_CAST<Entity_Player *>(collider),uVar2);
|
|
manager = g_manager;
|
|
local_3c.x = 6.9084e-43;
|
|
seed_fart_sound_override(GHIDRA_CAST<int *>(&local_3c));
|
|
(GHIDRA_CAST<SoundEffects *>((&manager->_sfxManager)))->SoundEffects::Play(GHIDRA_INT(local_3c.x),1.0,2,0,1.0,0.0);
|
|
uVar2 = Random();
|
|
local_3c.x = (collider->_pos).x;
|
|
local_3c.y = (collider->_pos).y;
|
|
effect = (GHIDRA_CAST<Game *>((g_game)))->Game::SpawnEx(1000,0x31,&local_3c,&g_vectorZero,GHIDRA_CAST<Entity *>(0x0),3,uVar2,0);
|
|
(effect->_sprite)._offset.x = 0.0;
|
|
(effect->_sprite)._offset.y = -24.0;
|
|
effect->_renderDepthOffset = 1.0;
|
|
npcLocal->_projectileCooldown = npcLocal->_projectileCooldown + 1;
|
|
return;
|
|
}
|
|
uVar2 = uVar2 + 1;
|
|
if (3 < uVar2) {
|
|
return;
|
|
}
|
|
} while( true );
|
|
}
|
|
|
|
// 0054f670
|
|
void NpcHelper::needle_render(Entity_NPC *npc)
|
|
{
|
|
float fVar1;
|
|
double dVar2;
|
|
uint trailStart;
|
|
int iVar4;
|
|
float *pfVar5;
|
|
int iVar6;
|
|
LayerState *layer;
|
|
int iVar7;
|
|
uint uVar8;
|
|
int iVar9;
|
|
uint uVar10;
|
|
uint heightIndex;
|
|
int segmentCount;
|
|
float *segmentPosCursor;
|
|
uint trailIndex;
|
|
float fVar11;
|
|
float fVar12;
|
|
float fVar13;
|
|
float fVar14;
|
|
float fVar15;
|
|
float prevHeight;
|
|
float remainingSpacing;
|
|
Vector prevPos;
|
|
byte *layerIndex;
|
|
int segmentsLeft;
|
|
float segmentData [7];
|
|
int *trailHeights;
|
|
int *trailPositions;
|
|
uint trailStart;
|
|
|
|
if ((npc->_state == 6) && (2 < GHIDRA_UINT((npc->_sprite)._layerCount))) {
|
|
pfVar5 = segmentData;
|
|
iVar7 = 2;
|
|
do {
|
|
pfVar5 = pfVar5 + 2;
|
|
pfVar5[1] = 0.0;
|
|
*pfVar5 = 0.0;
|
|
iVar7 = iVar7 + -1;
|
|
} while (iVar7 != 0);
|
|
segmentCount = 0;
|
|
remainingSpacing = 15.0;
|
|
trailStart = (npc->_vectorDeque1)._offset;
|
|
prevPos.x = (npc->_pos).x;
|
|
prevPos.y = (npc->_pos).y;
|
|
prevHeight = (npc->_v1).y;
|
|
iVar7 = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(g_game->_room) + 0x12bc));
|
|
trailPositions = (npc->_vectorDeque1)._proxy;
|
|
heightIndex = (npc->_vectorDeque2)._offset;
|
|
trailHeights = (npc->_vectorDeque2)._proxy;
|
|
trailStart = (npc->_vectorDeque1)._size;
|
|
trailIndex = trailStart;
|
|
while (trailIndex != trailStart + trailStart) {
|
|
if (trailPositions == GHIDRA_CAST<int *>(0x0)) {
|
|
iVar6 = 0;
|
|
}
|
|
else {
|
|
iVar6 = *trailPositions;
|
|
}
|
|
iVar4 = (trailIndex & 1) * 8;
|
|
pfVar5 = GHIDRA_CAST<float *>((*GHIDRA_CAST<int *>((*GHIDRA_CAST<int *>((iVar6 + 4)) +
|
|
(*GHIDRA_CAST<int *>((iVar6 + 8)) - 1U & trailIndex >> 1) * 4)) + iVar4));
|
|
fVar14 = *pfVar5 - prevPos.x;
|
|
fVar12 = pfVar5[1] - prevPos.y;
|
|
if (trailHeights == GHIDRA_CAST<int *>(0x0)) {
|
|
iVar6 = 0;
|
|
}
|
|
else {
|
|
iVar6 = *trailHeights;
|
|
}
|
|
uVar8 = heightIndex >> 1;
|
|
iVar9 = (heightIndex & 1) * 8;
|
|
fVar15 = *GHIDRA_CAST<float *>((*GHIDRA_CAST<int *>((*GHIDRA_CAST<int *>((iVar6 + 4)) + (*GHIDRA_CAST<int *>((iVar6 + 8)) - 1U & uVar8) * 4)) + 4
|
|
+ iVar9)) - prevHeight;
|
|
fVar11 = sqrtf(fVar12 * fVar12 + fVar14 * fVar14 + fVar15 * fVar15);
|
|
remainingSpacing = remainingSpacing - fVar11;
|
|
if (0.0 < remainingSpacing) {
|
|
if (trailPositions == GHIDRA_CAST<int *>(0x0)) {
|
|
iVar6 = 0;
|
|
}
|
|
else {
|
|
iVar6 = *trailPositions;
|
|
}
|
|
pfVar5 = GHIDRA_CAST<float *>((*GHIDRA_CAST<int *>((*GHIDRA_CAST<int *>((iVar6 + 4)) +
|
|
(*GHIDRA_CAST<int *>((iVar6 + 8)) - 1U & trailIndex >> 1) * 4)) + iVar4));
|
|
prevPos.x = *pfVar5;
|
|
prevPos.y = pfVar5[1];
|
|
if (trailHeights == GHIDRA_CAST<int *>(0x0)) {
|
|
iVar6 = 0;
|
|
}
|
|
else {
|
|
iVar6 = *trailHeights;
|
|
}
|
|
trailIndex = trailIndex + 1;
|
|
heightIndex = heightIndex + 1;
|
|
prevHeight = *GHIDRA_CAST<float *>((*GHIDRA_CAST<int *>((*GHIDRA_CAST<int *>((iVar6 + 4)) +
|
|
(*GHIDRA_CAST<int *>((iVar6 + 8)) - 1U & uVar8) * 4)) + 4 + iVar9));
|
|
}
|
|
else {
|
|
fVar11 = (fVar11 + remainingSpacing) / fVar11;
|
|
prevPos.x = fVar14 * fVar11 + prevPos.x;
|
|
prevPos.y = fVar12 * fVar11 + prevPos.y;
|
|
prevHeight = fVar11 * fVar15 + prevHeight;
|
|
segmentData[segmentCount * 2 + 2] = prevPos.x;
|
|
segmentData[segmentCount * 2 + 3] = prevPos.y;
|
|
segmentData[segmentCount] = prevHeight;
|
|
segmentCount = segmentCount + 1;
|
|
remainingSpacing = 15.0;
|
|
if (1 < segmentCount) goto LAB_0054f962;
|
|
uVar10 = heightIndex - 1;
|
|
uVar8 = trailIndex - 1;
|
|
if (trailIndex <= trailStart) {
|
|
uVar10 = heightIndex;
|
|
uVar8 = trailIndex;
|
|
}
|
|
trailIndex = uVar8 + 1;
|
|
heightIndex = uVar10 + 1;
|
|
}
|
|
}
|
|
if (segmentCount < 2) {
|
|
pfVar5 = segmentData + segmentCount;
|
|
for (iVar6 = 2 - segmentCount; iVar6 != 0; iVar6 = iVar6 + -1) {
|
|
*pfVar5 = prevHeight;
|
|
pfVar5 = pfVar5 + 1;
|
|
}
|
|
do {
|
|
segmentData[segmentCount * 2 + 2] = prevPos.x;
|
|
segmentData[segmentCount * 2 + 3] = prevPos.y;
|
|
segmentCount = segmentCount + 1;
|
|
} while (segmentCount < 2);
|
|
}
|
|
LAB_0054f962:
|
|
pfVar5 = segmentData;
|
|
segmentPosCursor = segmentData;
|
|
segmentsLeft = 2;
|
|
layerIndex = GHIDRA_CAST<byte *>(0x1);
|
|
do {
|
|
segmentPosCursor = segmentPosCursor + 2;
|
|
fVar12 = *segmentPosCursor;
|
|
fVar14 = segmentPosCursor[1];
|
|
fVar11 = (npc->_pos).x;
|
|
fVar15 = (npc->_pos).y;
|
|
fVar1 = *pfVar5;
|
|
fVar13 = (npc->_posOffset).y;
|
|
if (iVar7 == 5) {
|
|
fVar13 = -fVar13;
|
|
}
|
|
layer = (GHIDRA_CAST<ANM2 *>((&npc->_sprite)))->ANM2::GetLayer(layerIndex);
|
|
(layer->_pos).x = (fVar12 - fVar11) * 0.65;
|
|
(layer->_pos).y = ((fVar14 - fVar15) + (fVar1 - fVar13)) * 0.65;
|
|
dVar2 = __uint_to_double_fixup[-(GHIDRA_INT(layerIndex) >> 0x1f)];
|
|
fVar12 = *pfVar5;
|
|
layer = (GHIDRA_CAST<ANM2 *>((&npc->_sprite)))->ANM2::GetLayer(layerIndex);
|
|
pfVar5 = pfVar5 + 1;
|
|
layer->_visible = fVar12 <= -6.0 - (float)((double)GHIDRA_INT(layerIndex) + dVar2) * 3.0;
|
|
layerIndex = layerIndex + 1;
|
|
segmentsLeft = segmentsLeft + -1;
|
|
} while (segmentsLeft != 0);
|
|
}
|
|
return;
|
|
}
|
|
|
|
// 00557f70
|
|
Vector * NpcHelper::willo_slot(Entity_NPC *npc, Vector *outPos, int slot)
|
|
{
|
|
uint frameParity;
|
|
float radius;
|
|
float fVar1;
|
|
float local_14;
|
|
Vector targetPos;
|
|
|
|
willo_get_target_pos(npc,&targetPos,&local_14);
|
|
frameParity = g_manager->_framecount & 0x80000001;
|
|
if (GHIDRA_INT(frameParity) < 0) {
|
|
frameParity = (frameParity - 1 | 0xfffffffe) + 1;
|
|
}
|
|
if (npc->_state == 8) {
|
|
local_14 = (npc->_v2).y;
|
|
}
|
|
else {
|
|
local_14 = (npc->_v2).x;
|
|
}
|
|
radius = (npc->_v1).y * (npc->_v1).x;
|
|
local_14 = local_14 -
|
|
((float)GHIDRA_INT(frameParity) * 0.5 + (float)g_game->_frameCount + (float)slot) * 0.5 *
|
|
3.1415927 * 0.035;
|
|
fVar1 = cos(local_14);
|
|
outPos->x = fVar1 * radius + targetPos.x;
|
|
fVar1 = sin(local_14);
|
|
outPos->y = fVar1 * radius * 0.84 + targetPos.y;
|
|
return outPos;
|
|
}
|
|
|
|
// 00558070
|
|
void NpcHelper::willo_get_target_pos(Entity_NPC *npc, Vector *outPos, float *outSpread)
|
|
{
|
|
int iVar1;
|
|
int *playerSlot;
|
|
EntityPtr EVar2;
|
|
int iVar3;
|
|
int *spreadSlot;
|
|
float averageX;
|
|
float deltaX;
|
|
float averageY;
|
|
float fVar4;
|
|
float maxSpread;
|
|
int *playersEnd;
|
|
|
|
EVar2 = npc->_parent;
|
|
if (EVar2 != (EntityPtr)0x0) {
|
|
if (outSpread != GHIDRA_CAST<float *>(0x0)) {
|
|
*outSpread = 0.0;
|
|
EVar2 = npc->_parent;
|
|
}
|
|
fVar4 = *GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(EVar2) + 0x340));
|
|
outPos->x = *GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(EVar2) + 0x33c));
|
|
outPos->y = fVar4;
|
|
return;
|
|
}
|
|
iVar3 = 0;
|
|
fVar4 = 0.0;
|
|
maxSpread = 0.0;
|
|
playersEnd = (g_game->_playerManager)._playerList._end;
|
|
spreadSlot = (g_game->_playerManager)._playerList._begin;
|
|
averageX = g_vectorZero.x;
|
|
averageY = g_vectorZero.y;
|
|
for (playerSlot = spreadSlot; playerSlot != playersEnd; playerSlot = playerSlot + 1) {
|
|
iVar1 = *playerSlot;
|
|
if ((*GHIDRA_CAST<int *>((iVar1 + 0x2c)) == 0) && (*GHIDRA_CAST<int *>((iVar1 + 0x13c0)) != 0x23)) {
|
|
averageX = averageX + *GHIDRA_CAST<float *>((iVar1 + 0x33c));
|
|
averageY = averageY + *GHIDRA_CAST<float *>((iVar1 + 0x340));
|
|
iVar3 = iVar3 + 1;
|
|
}
|
|
}
|
|
averageX = averageX / (float)iVar3;
|
|
averageY = averageY / (float)iVar3;
|
|
if (outSpread != GHIDRA_CAST<float *>(0x0)) {
|
|
if (1 < iVar3) {
|
|
for (; spreadSlot != playersEnd; spreadSlot = spreadSlot + 1) {
|
|
iVar3 = *spreadSlot;
|
|
if ((*GHIDRA_CAST<int *>((iVar3 + 0x2c)) == 0) && (*GHIDRA_CAST<int *>((iVar3 + 0x13c0)) != 0x23)) {
|
|
deltaX = averageX - *GHIDRA_CAST<float *>((iVar3 + 0x33c));
|
|
fVar4 = averageY - *GHIDRA_CAST<float *>((iVar3 + 0x340));
|
|
fVar4 = sqrtf(fVar4 * fVar4 + deltaX * deltaX);
|
|
if (fVar4 <= maxSpread) {
|
|
fVar4 = maxSpread;
|
|
}
|
|
maxSpread = fVar4;
|
|
}
|
|
}
|
|
}
|
|
*outSpread = fVar4;
|
|
}
|
|
outPos->x = averageX;
|
|
outPos->y = averageY;
|
|
return;
|
|
}
|
|
|
|
// 005581b0
|
|
void NpcHelper::willo_orbit(Entity_NPC *npc)
|
|
{
|
|
EntityPtr EVar1;
|
|
int *playerIt;
|
|
int iVar2;
|
|
float fVar3;
|
|
float fVar4;
|
|
float fVar5;
|
|
float fVar6;
|
|
float fVar7;
|
|
Vector slotPos;
|
|
int player;
|
|
|
|
if (npc->_subtype == 0) {
|
|
willo_slot(npc,&slotPos,0);
|
|
fVar4 = (npc->_pos).x;
|
|
fVar5 = slotPos.x - fVar4;
|
|
fVar3 = slotPos.y - (npc->_pos).y;
|
|
fVar3 = sqrtf(fVar3 * fVar3 + fVar5 * fVar5);
|
|
if ((fVar3 < 20.0) && (npc->_projectileDelay == 1)) {
|
|
npc->_projectileDelay = 0;
|
|
}
|
|
EVar1 = npc->_parent;
|
|
if (EVar1 == (EntityPtr)0x0) {
|
|
iVar2 = 0;
|
|
fVar3 = g_vectorZero.x;
|
|
fVar5 = g_vectorZero.y;
|
|
for (playerIt = (g_game->_playerManager)._playerList._begin;
|
|
playerIt != (g_game->_playerManager)._playerList._end; playerIt = playerIt + 1) {
|
|
player = *playerIt;
|
|
if (*GHIDRA_CAST<int *>((player + 0x2c)) == 0) {
|
|
iVar2 = iVar2 + 1;
|
|
fVar6 = *GHIDRA_CAST<float *>((player + 0x360)) / *GHIDRA_CAST<float *>((player + 0x36c));
|
|
fVar7 = *GHIDRA_CAST<float *>((player + 0x364)) / *GHIDRA_CAST<float *>((player + 0x36c));
|
|
fVar3 = fVar3 + fVar6 + fVar6;
|
|
fVar5 = fVar5 + fVar7 + fVar7;
|
|
}
|
|
}
|
|
fVar3 = fVar3 / (float)iVar2;
|
|
fVar5 = fVar5 / (float)iVar2;
|
|
}
|
|
else {
|
|
fVar3 = *GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(EVar1) + 0x360)) / *GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(EVar1) + 0x36c));
|
|
fVar5 = *GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(EVar1) + 0x364)) / *GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(EVar1) + 0x36c));
|
|
fVar3 = fVar3 + fVar3 + g_vectorZero.x;
|
|
fVar5 = fVar5 + fVar5 + g_vectorZero.y;
|
|
}
|
|
fVar6 = (slotPos.x - (fVar4 + fVar3)) * 0.5;
|
|
fVar7 = (slotPos.y - (fVar5 + (npc->_pos).y)) * 0.5;
|
|
fVar4 = sqrtf(fVar7 * fVar7 + fVar6 * fVar6);
|
|
if (10.0 < fVar4) {
|
|
if (fVar4 <= 0.0) {
|
|
fVar6 = fVar6 * 10.0;
|
|
fVar7 = fVar7 * 10.0;
|
|
}
|
|
else {
|
|
fVar6 = fVar6 * (1.0 / fVar4) * 10.0;
|
|
fVar7 = fVar7 * (1.0 / fVar4) * 10.0;
|
|
}
|
|
}
|
|
fVar4 = npc->_friction;
|
|
(npc->_velocity).x = (fVar6 + fVar3) / fVar4;
|
|
(npc->_velocity).y = (fVar7 + fVar5) / fVar4;
|
|
}
|
|
return;
|
|
}
|
|
|
|
// 005583d0
|
|
void NpcHelper::willo_attack(Entity_NPC *npc)
|
|
{
|
|
byte isEventTriggered;
|
|
Entity *target;
|
|
float distance;
|
|
Vector shotVelocity;
|
|
float local_bc;
|
|
float local_b8;
|
|
ProjectileParams projParams;
|
|
float local_8;
|
|
Manager *manager;
|
|
|
|
local_8 = (float)(__security_cookie ^ GHIDRA_UINT(&(&projParams)[1].CircleAngle));
|
|
if (((npc->_sprite)._animState._animData == (void *)0x0) ||
|
|
((npc->_sprite)._animState._isPlaying == 0)) {
|
|
npc->_state = 3;
|
|
return;
|
|
}
|
|
isEventTriggered = (GHIDRA_CAST<AnimationState *>((&(npc->_sprite)._animState)))->AnimationState::IsEventTriggered(&DAT_00b6166c);
|
|
manager = g_manager;
|
|
if (isEventTriggered != 0) {
|
|
local_b8 = 1.0;
|
|
if (npc->_championColorIdx == 0x12) {
|
|
local_b8 = 1.5;
|
|
}
|
|
else if (npc->_championColorIdx == 0x13) {
|
|
local_b8 = 0.5;
|
|
}
|
|
local_bc = 6.60012e-43;
|
|
seed_fart_sound_override(GHIDRA_CAST<int *>(&local_bc));
|
|
(GHIDRA_CAST<SoundEffects *>((&manager->_sfxManager)))->SoundEffects::Play(GHIDRA_INT(local_bc),1.0,2,0,local_b8,0.0);
|
|
}
|
|
if ((npc->_sprite)._animState._animData == (void *)0x0) {
|
|
return;
|
|
}
|
|
isEventTriggered = (GHIDRA_CAST<AnimationState *>((&(npc->_sprite)._animState)))->AnimationState::IsEventTriggered(GHIDRA_CAST<byte *>("Shoot"));
|
|
manager = g_manager;
|
|
if (isEventTriggered == 0) {
|
|
return;
|
|
}
|
|
local_b8 = 1.0;
|
|
if (npc->_championColorIdx == 0x12) {
|
|
local_b8 = 1.5;
|
|
}
|
|
else if (npc->_championColorIdx == 0x13) {
|
|
local_b8 = 0.5;
|
|
}
|
|
local_bc = 2.14399e-43;
|
|
seed_fart_sound_override(GHIDRA_CAST<int *>(&local_bc));
|
|
(GHIDRA_CAST<SoundEffects *>((&manager->_sfxManager)))->SoundEffects::Play(GHIDRA_INT(local_bc),1.0,2,0,local_b8,0.0);
|
|
target = (GHIDRA_CAST<Entity_NPC *>((npc)))->Entity_NPC::GetPlayerTarget();
|
|
(GHIDRA_CAST<ProjectileParams *>((&projParams)))->ProjectileParams::ProjectileParams();
|
|
local_bc = ((target->_pos).x + (target->_velocity).x) - (npc->_pos).x;
|
|
local_b8 = ((target->_pos).y + (target->_velocity).y) - (npc->_pos).y;
|
|
distance = sqrtf(local_bc * local_bc + local_b8 * local_b8);
|
|
shotVelocity.x = local_bc;
|
|
shotVelocity.y = local_b8;
|
|
if (0.0 < distance) {
|
|
shotVelocity.y = local_b8 * (1.0 / distance);
|
|
shotVelocity.x = local_bc * (1.0 / distance);
|
|
}
|
|
shotVelocity.x = shotVelocity.x * 10.0;
|
|
projParams.Color._offset[2] = DAT_00c33cd8;
|
|
shotVelocity.y = shotVelocity.y * 10.0;
|
|
projParams.Variant = 4;
|
|
projParams.Color._tint[0] = _DAT_00c33cb0;
|
|
projParams.Color._tint[1] = fRam00c33cb4;
|
|
projParams.Color._tint[2] = fRam00c33cb8;
|
|
projParams.Color._tint[3] = fRam00c33cbc;
|
|
(*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(projParams.BulletFlags)) + 0x0))) = 0x2000;
|
|
(*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(projParams.BulletFlags)) + 0x4))) = 0;
|
|
projParams.Color._colorize[0] = _DAT_00c33cc0;
|
|
projParams.Color._colorize[1] = fRam00c33cc4;
|
|
projParams.Color._colorize[2] = fRam00c33cc8;
|
|
projParams.Color._colorize[3] = fRam00c33ccc;
|
|
projParams.Color._offset[0] = (float)DAT_00c33cd0;
|
|
projParams.Color._offset[1] = (*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(DAT_00c33cd0)) + 0x4)));
|
|
if ((npc->_parent == (EntityPtr)0x0) && (npc->_subtype == 0)) {
|
|
projParams.FallingSpeedModifier = projParams.FallingSpeedModifier + 4.0;
|
|
}
|
|
Entity_NPC::FireProjectiles(npc,&npc->_pos,&shotVelocity,0,&projParams);
|
|
return;
|
|
}
|
|
|
|
// 00558fe0
|
|
Entity_NPC * NpcHelper::min_min_spawn_willo(Vector *position, Entity_NPC *spawner, float v1X, int subType)
|
|
{
|
|
byte bVar1;
|
|
uint flagsHigh;
|
|
Entity_NPC *willo;
|
|
byte *curAnimName;
|
|
char *targetAnimName;
|
|
bool bVar3;
|
|
EntityPtr *eraseKey;
|
|
float v1XLocal;
|
|
Vector *spawnPos;
|
|
byte *animData;
|
|
undefined4 flagsHigh;
|
|
EntityPtr *parentSlot;
|
|
|
|
v1XLocal = v1X;
|
|
spawnPos = position;
|
|
flagsHigh = Random();
|
|
willo = (Entity_NPC *)
|
|
(GHIDRA_CAST<Game *>((g_game)))->Game::SpawnEx(0x328,0,position,&g_vectorZero,GHIDRA_CAST<Entity *>(spawner),subType & 0xff,flagsHigh
|
|
,0);
|
|
if (spawner != GHIDRA_CAST<Entity_NPC *>(0x0)) {
|
|
parentSlot = &willo->_parent;
|
|
if (willo->_parent != (EntityPtr)0x0) {
|
|
eraseKey = parentSlot;
|
|
std::multiset<unsigned_int>::erase(&eraseKey);
|
|
}
|
|
*parentSlot = (EntityPtr)spawner;
|
|
std::multiset<unsigned_int>::insert(parentSlot);
|
|
}
|
|
*GHIDRA_CAST<uint *>(&willo->_flags) = GHIDRA_UINT(willo->_flags) & 0xfffffffb;
|
|
flagsHigh = *GHIDRA_CAST<undefined4 *>((GHIDRA_INT(&willo->_flags) + 4));
|
|
(willo->_v1).x = v1XLocal;
|
|
(willo->_v1).y = 1.0;
|
|
*GHIDRA_CAST<undefined4 *>((GHIDRA_INT(&willo->_flags) + 4)) = flagsHigh;
|
|
if ((char)subType == '\0') {
|
|
willo->_state = 6;
|
|
animData = (willo->_sprite)._animState._animData;
|
|
if (animData != GHIDRA_CAST<byte *>(0x0)) {
|
|
curAnimName = animData;
|
|
if (0xf < *GHIDRA_CAST<uint *>((animData + 0x14))) {
|
|
curAnimName = *GHIDRA_CAST<byte **>(animData);
|
|
}
|
|
targetAnimName = "UnderwaterSpawn";
|
|
do {
|
|
bVar1 = *curAnimName;
|
|
bVar3 = bVar1 < (byte)*targetAnimName;
|
|
if (bVar1 != *targetAnimName) {
|
|
LAB_00559170:
|
|
flagsHigh = -GHIDRA_UINT(bVar3) | 1;
|
|
goto LAB_00559175;
|
|
}
|
|
if (bVar1 == 0) break;
|
|
bVar1 = curAnimName[1];
|
|
bVar3 = bVar1 < (byte)targetAnimName[1];
|
|
if (bVar1 != targetAnimName[1]) goto LAB_00559170;
|
|
curAnimName = curAnimName + 2;
|
|
targetAnimName = targetAnimName + 2;
|
|
} while (bVar1 != 0);
|
|
flagsHigh = 0;
|
|
LAB_00559175:
|
|
if (flagsHigh == 0) {
|
|
if (animData[0x34] == 0) {
|
|
return willo;
|
|
}
|
|
if ((willo->_sprite)._animState._isPlaying != 0) {
|
|
return willo;
|
|
}
|
|
}
|
|
}
|
|
bVar1 = (GHIDRA_CAST<ANM2 *>((&willo->_sprite)))->ANM2::SetAnimation(GHIDRA_CAST<byte *>("UnderwaterSpawn"),1);
|
|
if (bVar1 != 0) {
|
|
(GHIDRA_CAST<AnimationState *>((&(willo->_sprite)._animState)))->AnimationState::Rewind();
|
|
(willo->_sprite)._animState._isPlaying = 1;
|
|
}
|
|
return willo;
|
|
}
|
|
willo->_state = 7;
|
|
animData = (willo->_sprite)._animState._animData;
|
|
if (animData != GHIDRA_CAST<byte *>(0x0)) {
|
|
curAnimName = animData;
|
|
if (0xf < *GHIDRA_CAST<uint *>((animData + 0x14))) {
|
|
curAnimName = *GHIDRA_CAST<byte **>(animData);
|
|
}
|
|
targetAnimName = "UnderwaterAttack";
|
|
do {
|
|
bVar1 = *curAnimName;
|
|
bVar3 = bVar1 < (byte)*targetAnimName;
|
|
if (bVar1 != *targetAnimName) {
|
|
LAB_005590d0:
|
|
flagsHigh = -GHIDRA_UINT(bVar3) | 1;
|
|
goto LAB_005590d5;
|
|
}
|
|
if (bVar1 == 0) break;
|
|
bVar1 = curAnimName[1];
|
|
bVar3 = bVar1 < (byte)targetAnimName[1];
|
|
if (bVar1 != targetAnimName[1]) goto LAB_005590d0;
|
|
curAnimName = curAnimName + 2;
|
|
targetAnimName = targetAnimName + 2;
|
|
} while (bVar1 != 0);
|
|
flagsHigh = 0;
|
|
LAB_005590d5:
|
|
if ((flagsHigh == 0) && ((animData[0x34] == 0 || ((willo->_sprite)._animState._isPlaying != 0))))
|
|
goto LAB_00559108;
|
|
}
|
|
bVar1 = (GHIDRA_CAST<ANM2 *>((&willo->_sprite)))->ANM2::SetAnimation(GHIDRA_CAST<byte *>("UnderwaterAttack"),1);
|
|
if (bVar1 != 0) {
|
|
(GHIDRA_CAST<AnimationState *>((&(willo->_sprite)._animState)))->AnimationState::Rewind();
|
|
(willo->_sprite)._animState._isPlaying = 1;
|
|
}
|
|
LAB_00559108:
|
|
(willo->_targetPosition).x = spawnPos->x;
|
|
(willo->_targetPosition).y = spawnPos->y;
|
|
willo->_projectileDelay = 0;
|
|
return willo;
|
|
}
|
|
|
|
// 0055a850
|
|
void NpcHelper::bubbles_death_geyser_tick(Entity *owner)
|
|
{
|
|
uint projVariant;
|
|
uint rngResult;
|
|
uint rngFactor;
|
|
Entity_Projectile *projectile;
|
|
float originX;
|
|
float cosAngle;
|
|
float randScale;
|
|
int highShotsLeft;
|
|
int lowShotsLeft;
|
|
Vector local_18;
|
|
Vector local_10;
|
|
float originX;
|
|
float originY;
|
|
|
|
originX = (owner->_pos).x;
|
|
originY = (owner->_pos).y;
|
|
projVariant = Level::GetStageID();
|
|
if (projVariant == 0x1b) {
|
|
projVariant = 4;
|
|
}
|
|
else if (projVariant == 0x1c) {
|
|
projVariant = 3;
|
|
}
|
|
else {
|
|
projVariant = 0;
|
|
}
|
|
lowShotsLeft = 2;
|
|
do {
|
|
rngResult = Random();
|
|
originX = (float)((double)GHIDRA_INT(rngResult) + __uint_to_double_fixup[-(GHIDRA_INT(rngResult) >> 0x1f)]) *
|
|
2.3283064e-10 * 3.14;
|
|
originX = originX + originX;
|
|
cosAngle = cos(originX);
|
|
originX = sin(originX);
|
|
rngResult = Random();
|
|
rngFactor = Random();
|
|
randScale = (float)((double)GHIDRA_INT(rngFactor) + __uint_to_double_fixup[-(GHIDRA_INT(rngFactor) >> 0x1f)])
|
|
* 2.3283064e-10;
|
|
local_18.y = randScale * originX * 2.8;
|
|
local_18.x = randScale * cosAngle * 2.8;
|
|
rngFactor = Random();
|
|
randScale = (float)((double)GHIDRA_INT(rngFactor) + __uint_to_double_fixup[-(GHIDRA_INT(rngFactor) >> 0x1f)])
|
|
* 2.3283064e-10;
|
|
local_10.x = cosAngle * 5.0 * randScale + originX;
|
|
local_10.y = originX * 5.0 * randScale + originY;
|
|
projectile = (Entity_Projectile *)
|
|
(GHIDRA_CAST<Game *>((g_game)))->Game::SpawnEx(9,projVariant,&local_10,&local_18,GHIDRA_CAST<Entity *>(0x0),0,rngResult,0)
|
|
;
|
|
projectile->_spawnerType = 0x326;
|
|
rngResult = Random();
|
|
projectile->_fallingAccel = 2.0;
|
|
projectile->_scale =
|
|
(float)((double)GHIDRA_INT(rngResult) + __uint_to_double_fixup[-(GHIDRA_INT(rngResult) >> 0x1f)]) *
|
|
2.3283064e-10 * 1.4;
|
|
rngResult = Random();
|
|
projectile->_fallingSpeed =
|
|
-15.0 - (float)((double)GHIDRA_INT(rngResult) + __uint_to_double_fixup[-(GHIDRA_INT(rngResult) >> 0x1f)])
|
|
* 2.3283064e-10 * 60.0;
|
|
rngResult = Random();
|
|
projectile->_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
|
|
(projectile,*GHIDRA_CAST<int *>(&(*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(&(owner[1])) + 0x40)))),
|
|
*GHIDRA_CAST<float *>((owner[1]._sprite._animDefaultName._buf + 8)),owner->_flags,GHIDRA_CAST<Entity *>(0x0));
|
|
projectile->Update();
|
|
lowShotsLeft = lowShotsLeft + -1;
|
|
} while (lowShotsLeft != 0);
|
|
highShotsLeft = 2;
|
|
do {
|
|
rngResult = Random();
|
|
originX = (float)((double)GHIDRA_INT(rngResult) + __uint_to_double_fixup[-(GHIDRA_INT(rngResult) >> 0x1f)]) *
|
|
2.3283064e-10 * 3.14;
|
|
originX = originX + originX;
|
|
cosAngle = cos(originX);
|
|
originX = sin(originX);
|
|
rngResult = Random();
|
|
rngFactor = Random();
|
|
randScale = (float)((double)GHIDRA_INT(rngFactor) + __uint_to_double_fixup[-(GHIDRA_INT(rngFactor) >> 0x1f)])
|
|
* 2.3283064e-10;
|
|
local_10.y = randScale * originX * 2.8;
|
|
local_10.x = randScale * cosAngle * 2.8;
|
|
rngFactor = Random();
|
|
randScale = (float)((double)GHIDRA_INT(rngFactor) + __uint_to_double_fixup[-(GHIDRA_INT(rngFactor) >> 0x1f)])
|
|
* 2.3283064e-10;
|
|
local_18.x = cosAngle * 5.0 * randScale + originX;
|
|
local_18.y = originX * 5.0 * randScale + originY;
|
|
projectile = (Entity_Projectile *)
|
|
(GHIDRA_CAST<Game *>((g_game)))->Game::SpawnEx(9,projVariant,&local_18,&local_10,GHIDRA_CAST<Entity *>(0x0),0,rngResult,0)
|
|
;
|
|
projectile->_spawnerType = 0x326;
|
|
rngResult = Random();
|
|
projectile->_fallingAccel = 2.0;
|
|
projectile->_scale =
|
|
(float)((double)GHIDRA_INT(rngResult) + __uint_to_double_fixup[-(GHIDRA_INT(rngResult) >> 0x1f)]) *
|
|
2.3283064e-10 * 1.4;
|
|
rngResult = Random();
|
|
projectile->_fallingSpeed =
|
|
-15.0 - (float)((double)GHIDRA_INT(rngResult) + __uint_to_double_fixup[-(GHIDRA_INT(rngResult) >> 0x1f)])
|
|
* 2.3283064e-10 * 60.0;
|
|
rngResult = Random();
|
|
projectile->_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
|
|
(projectile,*GHIDRA_CAST<int *>(&(*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(&(owner[1])) + 0x40)))),
|
|
*GHIDRA_CAST<float *>((owner[1]._sprite._animDefaultName._buf + 8)),owner->_flags,GHIDRA_CAST<Entity *>(0x0));
|
|
projectile->Update();
|
|
highShotsLeft = highShotsLeft + -1;
|
|
} while (highShotsLeft != 0);
|
|
return;
|
|
}
|
|
|
|
// 0055d070
|
|
byte 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
|
|
byte NpcHelper::polty_is_target_liftable(Entity_NPC *npc)
|
|
{
|
|
EntityPtr EVar1;
|
|
byte local_AL_113;
|
|
int extraout_EDX;
|
|
float snapY;
|
|
int gridWidth;
|
|
Room *room;
|
|
|
|
EVar1 = npc->_spawnerEntity;
|
|
if ((EVar1 == (EntityPtr)0x0) || (*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(EVar1) + 0x28)) != 5)) {
|
|
if (npc->_i2 < 0) {
|
|
return 0;
|
|
}
|
|
room = g_game->_room;
|
|
local_AL_113 = (GHIDRA_CAST<Room *>((room)))->Room::CanPickupGridEntity(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 *>((GHIDRA_CAST<char *>(EVar1) + 0x340));
|
|
(npc->_pos).x = *GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(EVar1) + 0x33c));
|
|
}
|
|
(npc->_pos).y = snapY;
|
|
(npc->_velocity).x = g_vectorZero.x;
|
|
(npc->_velocity).y = g_vectorZero.y;
|
|
return 1;
|
|
}
|
|
|
|
// 0055d180
|
|
byte NpcHelper::polty_is_pot_cell(Entity_NPC *npc, int gridIndex)
|
|
{
|
|
byte 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)
|
|
{
|
|
uint dequeBlock;
|
|
uint dequeBlockSlot;
|
|
uint 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;
|
|
}
|
|
|
|
// 00568cc0
|
|
void NpcHelper::mother_spawn_parts()
|
|
{
|
|
EntityPtr EVar1;
|
|
Entity *part2;
|
|
EntityPtr in_ECX;
|
|
uint uVar2;
|
|
uint blockSlot;
|
|
EntityPtr *childRef;
|
|
float offsetY;
|
|
Vector part3Pos;
|
|
Vector part2Pos;
|
|
Vector part1Pos;
|
|
EntityPtr local_24;
|
|
float local_20;
|
|
EntityPtr local_1c;
|
|
EntityPtr *local_18;
|
|
Entity *local_14;
|
|
int dequeBlock;
|
|
qword flags;
|
|
|
|
part1Pos.x = DAT_00c33d3c + *GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(in_ECX) + 0x33c));
|
|
part1Pos.y = DAT_00c33d40 + *GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(in_ECX) + 0x340));
|
|
EVar1 = (EntityPtr)
|
|
(GHIDRA_CAST<Game *>((g_game)))->Game::Spawn(0x390,0,&part1Pos,&g_vectorZero,GHIDRA_CAST<Entity *>(in_ECX),1,
|
|
*GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(in_ECX) + 0x3ec)));
|
|
offsetY = *GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(in_ECX) + 0x350)) - DAT_00c33d40;
|
|
(GHIDRA_CAST<Vector *>((GHIDRA_INT(EVar1) + 0x34c)))->x = *GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(in_ECX) + 0x34c)) - DAT_00c33d3c;
|
|
*GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(EVar1) + 0x350)) = offsetY;
|
|
local_24 = EVar1;
|
|
mother_set_collision_class(GHIDRA_CAST<Entity_NPC *>(EVar1),0);
|
|
*GHIDRA_CAST<byte *>((GHIDRA_CAST<char *>(EVar1) + 0x3b0)) = 1;
|
|
*GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(EVar1) + 0x168)) = *GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(EVar1) + 0x168)) & 0xfffffffb | 0x80100011;
|
|
*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(EVar1) + 0x16c)) = *GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(EVar1) + 0x16c));
|
|
(GHIDRA_CAST<Entity *>((GHIDRA_CAST<Entity *>(EVar1))))->Entity::SetVisibleFlag(0);
|
|
if (*GHIDRA_CAST<EntityPtr *>((GHIDRA_CAST<char *>(EVar1) + 0x3bc)) != (EntityPtr)0x0) {
|
|
local_14 = GHIDRA_CAST<Entity *>((GHIDRA_INT(EVar1) + 0x3bc));
|
|
std::multiset<unsigned_int>::erase(&local_14);
|
|
}
|
|
*GHIDRA_CAST<EntityPtr *>((GHIDRA_CAST<char *>(EVar1) + 0x3bc)) = in_ECX;
|
|
std::multiset<unsigned_int>::insert(GHIDRA_CAST<EntityPtr *>((GHIDRA_INT(EVar1) + 0x3bc)));
|
|
(**(code **)(*GHIDRA_CAST<int *>(EVar1) + 0xc))();
|
|
part2Pos.x = DAT_00c33d44 + *GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(in_ECX) + 0x33c));
|
|
part2Pos.y = DAT_00c33d48 + *GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(in_ECX) + 0x340));
|
|
part2 = (GHIDRA_CAST<Game *>((g_game)))->Game::Spawn(0x390,0,&part2Pos,&g_vectorZero,GHIDRA_CAST<Entity *>(in_ECX),2,
|
|
*GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(in_ECX) + 0x3ec)));
|
|
local_20 = -g_vectorOne.x;
|
|
local_1c = (EntityPtr)-g_vectorOne.y;
|
|
local_14 = part2;
|
|
(GHIDRA_CAST<Entity *>((part2)))->Entity::SetSize(70.0,(Vector)(CONCAT44(g_vectorOne.y,g_vectorOne.x) ^ 0x8000000080000000),-1);
|
|
offsetY = *GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(in_ECX) + 0x350)) - DAT_00c33d48;
|
|
(part2->_posOffset).x = *GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(in_ECX) + 0x34c)) - DAT_00c33d44;
|
|
(part2->_posOffset).y = offsetY;
|
|
if (part2->_parent != (EntityPtr)0x0) {
|
|
local_18 = &part2->_parent;
|
|
std::multiset<unsigned_int>::erase(&local_18);
|
|
}
|
|
part2->_parent = in_ECX;
|
|
std::multiset<unsigned_int>::insert(&part2->_parent);
|
|
flags = part2->_flags;
|
|
*GHIDRA_CAST<undefined4 *>((GHIDRA_INT(&part2->_flags) + 4)) = *GHIDRA_CAST<undefined4 *>((GHIDRA_INT(&part2->_flags) + 4));
|
|
*GHIDRA_CAST<uint *>(&part2->_flags) = GHIDRA_UINT(flags) & 0xfffffffb | 0x80000000;
|
|
part2->Update();
|
|
part3Pos.x = DAT_00c33d4c + *GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(in_ECX) + 0x33c));
|
|
part3Pos.y = DAT_00c33d50 + *GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(in_ECX) + 0x340));
|
|
EVar1 = (EntityPtr)
|
|
(GHIDRA_CAST<Game *>((g_game)))->Game::Spawn(0x390,0,&part3Pos,&g_vectorZero,GHIDRA_CAST<Entity *>(in_ECX),3,
|
|
*GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(in_ECX) + 0x3ec)));
|
|
local_20 = -g_vectorOne.x;
|
|
local_1c = (EntityPtr)-g_vectorOne.y;
|
|
(GHIDRA_CAST<Entity *>((GHIDRA_CAST<Entity *>(EVar1))))->Entity::SetSize(70.0,
|
|
(Vector)(CONCAT44(g_vectorOne.y,g_vectorOne.x) ^ 0x8000000080000000),-1);
|
|
offsetY = *GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(in_ECX) + 0x350)) - DAT_00c33d50;
|
|
*GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(EVar1) + 0x34c)) = *GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(in_ECX) + 0x34c)) - DAT_00c33d4c;
|
|
*GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(EVar1) + 0x350)) = offsetY;
|
|
if (*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(EVar1) + 0x3bc)) != 0) {
|
|
local_18 = GHIDRA_CAST<EntityPtr *>((GHIDRA_INT(EVar1) + 0x3bc));
|
|
std::multiset<unsigned_int>::erase(&local_18);
|
|
}
|
|
*GHIDRA_CAST<EntityPtr *>((GHIDRA_CAST<char *>(EVar1) + 0x3bc)) = in_ECX;
|
|
std::multiset<unsigned_int>::insert(GHIDRA_INT(EVar1) + 0x3bc);
|
|
*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(EVar1) + 0x16c)) = *GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(EVar1) + 0x16c));
|
|
*GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(EVar1) + 0x168)) = *GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(EVar1) + 0x168)) & 0xfffffffb | 0x80000000;
|
|
(**(code **)(*GHIDRA_CAST<int *>(EVar1) + 0xc))();
|
|
local_18 = GHIDRA_CAST<EntityPtr *>(0x0);
|
|
std::deque<int>::resize(3,&local_18);
|
|
uVar2 = *GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(in_ECX) + 0xbfc)) & 3;
|
|
dequeBlock = *GHIDRA_CAST<int *>((*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(in_ECX) + 0xbf4)) +
|
|
(*GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(in_ECX) + 0xbfc)) >> 2 & *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(in_ECX) + 0xbf8)) - 1U) *
|
|
4));
|
|
local_1c = (EntityPtr)(dequeBlock + uVar2 * 4);
|
|
if (*GHIDRA_CAST<int *>((dequeBlock + uVar2 * 4)) != 0) {
|
|
local_18 = GHIDRA_CAST<EntityPtr *>(local_1c);
|
|
std::multiset<unsigned_int>::erase(&local_18);
|
|
}
|
|
*GHIDRA_CAST<EntityPtr *>(local_1c) = local_24;
|
|
std::multiset<unsigned_int>::insert(local_1c);
|
|
uVar2 = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(in_ECX) + 0xbfc)) + 1;
|
|
blockSlot = uVar2 & 3;
|
|
dequeBlock = *GHIDRA_CAST<int *>((*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(in_ECX) + 0xbf4)) +
|
|
(uVar2 >> 2 & *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(in_ECX) + 0xbf8)) - 1U) * 4));
|
|
local_1c = (EntityPtr)(dequeBlock + blockSlot * 4);
|
|
if (*GHIDRA_CAST<int *>((dequeBlock + blockSlot * 4)) != 0) {
|
|
local_24 = local_1c;
|
|
std::multiset<unsigned_int>::erase(&local_24);
|
|
}
|
|
*GHIDRA_CAST<Entity **>(local_1c) = local_14;
|
|
std::multiset<unsigned_int>::insert(local_1c);
|
|
uVar2 = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(in_ECX) + 0xbfc)) + 2;
|
|
blockSlot = uVar2 & 3;
|
|
dequeBlock = *GHIDRA_CAST<int *>((*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(in_ECX) + 0xbf4)) +
|
|
(uVar2 >> 2 & *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(in_ECX) + 0xbf8)) - 1U) * 4));
|
|
local_1c = (EntityPtr)(dequeBlock + blockSlot * 4);
|
|
if (*GHIDRA_CAST<int *>((dequeBlock + blockSlot * 4)) != 0) {
|
|
local_24 = local_1c;
|
|
std::multiset<unsigned_int>::erase(&local_24);
|
|
}
|
|
*GHIDRA_CAST<EntityPtr *>(local_1c) = EVar1;
|
|
std::multiset<unsigned_int>::insert(local_1c);
|
|
local_1c = (EntityPtr)(GHIDRA_INT(in_ECX) + 0x3c0);
|
|
if (*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(in_ECX) + 0x3c0)) != 0) {
|
|
local_24 = local_1c;
|
|
std::multiset<unsigned_int>::erase(&local_24);
|
|
}
|
|
part2 = local_14;
|
|
*GHIDRA_CAST<Entity **>(local_1c) = local_14;
|
|
std::multiset<unsigned_int>::insert(local_1c);
|
|
childRef = &part2->_child;
|
|
if (part2->_child != (EntityPtr)0x0) {
|
|
local_24 = (EntityPtr)childRef;
|
|
std::multiset<unsigned_int>::erase(&local_24);
|
|
}
|
|
*childRef = EVar1;
|
|
std::multiset<unsigned_int>::insert(childRef);
|
|
return;
|
|
}
|
|
|
|
// 0056c800
|
|
void NpcHelper::mother_2_slam_burst(float *param_1)
|
|
{
|
|
uint rngResult;
|
|
Entity *spawnedEffect;
|
|
uint 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<Vector *>((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<int *>(&local_18));
|
|
(GHIDRA_CAST<SoundEffects *>((&manager->_sfxManager)))->SoundEffects::Play(GHIDRA_INT(local_18),1.0,2,0,1.0,0.0);
|
|
(GHIDRA_CAST<Game *>((g_game)))->Game::ShakeScreen(0xc);
|
|
rngResult = Random();
|
|
spawnedEffect = (GHIDRA_CAST<Game *>((g_game)))->Game::Spawn(1000,2,&slamPos,&g_vectorZero,GHIDRA_CAST<Entity *>(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;
|
|
spawnedEffect->SetColor(&g_colorGreenSplat,0xffffffff,0xff,0,1);
|
|
spawnedEffect->Update();
|
|
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 = (GHIDRA_CAST<Game *>((g_game)))->Game::Spawn(1000,4,&local_3c,&local_34,GHIDRA_CAST<Entity *>(0x0),0,rngResult);
|
|
spawnedEffect->Update();
|
|
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 = (GHIDRA_CAST<Game *>((g_game)))->Game::Spawn(1000,2,&local_34,&local_3c,GHIDRA_CAST<Entity *>(0x0),uVar1,rngResult);
|
|
rngResult = Random();
|
|
(spawnedEffect->_posOffset).x = 0.0;
|
|
(spawnedEffect->_posOffset).y = -10.0;
|
|
iVar2 = *GHIDRA_CAST<int *>(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);
|
|
spawnedEffect->Update();
|
|
iVar3 = iVar3 + -1;
|
|
} while (iVar3 != 0);
|
|
return;
|
|
}
|
|
|
|
// 0056fcf0
|
|
void NpcHelper::mother_render(Entity_NPC *npc, Vector *offset)
|
|
{
|
|
ColorMod *pCVar1;
|
|
ColorMod *pCVar2;
|
|
undefined8 uVar3;
|
|
float fVar4;
|
|
float fVar5;
|
|
float fVar6;
|
|
float fVar7;
|
|
float fVar8;
|
|
float fVar9;
|
|
float fVar10;
|
|
float fVar11;
|
|
float fVar12;
|
|
float fVar13;
|
|
EntityPtr colorTarget;
|
|
int layerId;
|
|
float pixelScale;
|
|
double dVar14;
|
|
double dVar15;
|
|
undefined4 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 = npc->_parent, npc->_parent == (EntityPtr)0x0)) {
|
|
colorTarget = (EntityPtr)npc;
|
|
}
|
|
pixelScale = (GHIDRA_CAST<ColorMod *>((GHIDRA_INT(colorTarget) + 0xf0)))->_tint[0];
|
|
fVar4 = *GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(colorTarget) + 0xf4));
|
|
fVar5 = *GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(colorTarget) + 0xf8));
|
|
fVar6 = *GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(colorTarget) + 0xfc));
|
|
offsetY = *GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(colorTarget) + 0x118));
|
|
pCVar1 = GHIDRA_CAST<ColorMod *>((GHIDRA_INT(colorTarget) + 0xf0));
|
|
pCVar2 = &(npc->_sprite)._color;
|
|
fVar7 = *GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(colorTarget) + 0x100));
|
|
fVar8 = *GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(colorTarget) + 0x104));
|
|
fVar9 = *GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(colorTarget) + 0x108));
|
|
fVar10 = *GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(colorTarget) + 0x10c));
|
|
uVar3 = *GHIDRA_CAST<undefined8 *>((GHIDRA_CAST<char *>(colorTarget) + 0x110));
|
|
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];
|
|
*GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(colorTarget) + 0xf4)) = fVar11;
|
|
*GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(colorTarget) + 0xf8)) = fVar12;
|
|
*GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(colorTarget) + 0xfc)) = fVar13;
|
|
fVar11 = (npc->_sprite)._color._colorize[1];
|
|
fVar12 = (npc->_sprite)._color._colorize[2];
|
|
fVar13 = (npc->_sprite)._color._colorize[3];
|
|
*GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(colorTarget) + 0x100)) = (npc->_sprite)._color._colorize[0];
|
|
*GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(colorTarget) + 0x104)) = fVar11;
|
|
*GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(colorTarget) + 0x108)) = fVar12;
|
|
*GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(colorTarget) + 0x10c)) = fVar13;
|
|
*GHIDRA_CAST<undefined8 *>((GHIDRA_CAST<char *>(colorTarget) + 0x110)) = *GHIDRA_CAST<undefined8 *>((npc->_sprite)._color._offset);
|
|
*GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(colorTarget) + 0x118)) = (npc->_sprite)._color._offset[2];
|
|
layerId = npc->_subtype;
|
|
}
|
|
(GHIDRA_CAST<Sprite *>((GHIDRA_CAST<Sprite *>((GHIDRA_INT(colorTarget) + 0x48)))))->Sprite::RenderLayer(layerId,&npc->_renderPosition,
|
|
&g_vectorZero,&g_vectorZero);
|
|
if (pCVar1 != GHIDRA_CAST<ColorMod *>(local_6c)) {
|
|
pCVar1->_tint[0] = pixelScale;
|
|
*GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(colorTarget) + 0xf4)) = fVar4;
|
|
*GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(colorTarget) + 0xf8)) = fVar5;
|
|
*GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(colorTarget) + 0xfc)) = fVar6;
|
|
*GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(colorTarget) + 0x100)) = fVar7;
|
|
*GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(colorTarget) + 0x104)) = fVar8;
|
|
*GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(colorTarget) + 0x108)) = fVar9;
|
|
*GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(colorTarget) + 0x10c)) = fVar10;
|
|
*GHIDRA_CAST<undefined8 *>((GHIDRA_CAST<char *>(colorTarget) + 0x110)) = uVar3;
|
|
*GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(colorTarget) + 0x118)) = offsetY;
|
|
return;
|
|
}
|
|
}
|
|
else {
|
|
(GHIDRA_CAST<Entity *>((GHIDRA_CAST<Entity *>(npc))))->Entity::Render(offset);
|
|
}
|
|
return;
|
|
}
|
|
|
|
// 00572a70
|
|
Entity * NpcHelper::clutch_find_farthest_orbital(Entity_NPC *clutch, int unused)
|
|
{
|
|
qword qVar1;
|
|
byte isClutchFriendly;
|
|
void *enemiesData;
|
|
qword *heapAllocatedBytes;
|
|
byte extraout_DL;
|
|
EntityPtr tmpEntity;
|
|
uint uVar2;
|
|
float fVar3;
|
|
float deltaX;
|
|
EntityList_EL local_38;
|
|
undefined4 local_24;
|
|
float maxDistance;
|
|
EntityPtr local_18;
|
|
void *local_10;
|
|
undefined1 *puStack_c;
|
|
undefined4 uStack_8;
|
|
|
|
uStack_8 = 0xffffffff;
|
|
puStack_c = &LAB_00af1840;
|
|
local_10 = ExceptionList;
|
|
ExceptionList = &local_10;
|
|
local_18 = (EntityPtr)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 = (EntityPtr)0x0;
|
|
if (local_38._size != 0) {
|
|
enemiesData = local_38._data;
|
|
do {
|
|
tmpEntity = *GHIDRA_CAST<EntityPtr *>((GHIDRA_CAST<char *>(enemiesData) + uVar2 * 4));
|
|
if (tmpEntity != (EntityPtr)0x0) {
|
|
if (((1 < *GHIDRA_CAST<int *>(&g_game->_deathmatchManager)) && (*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(tmpEntity) + 0x28)) == 1)) ||
|
|
(*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(tmpEntity) + 0x28)) - 10U < 0x3de)) {
|
|
local_24 = *GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(tmpEntity) + 0x16c));
|
|
isClutchFriendly = (GHIDRA_CAST<Entity *>((GHIDRA_CAST<Entity *>(clutch))))->Entity::IsFriendly();
|
|
if (((extraout_DL == isClutchFriendly) &&
|
|
(*GHIDRA_CAST<EntityPtr *>((GHIDRA_CAST<char *>(tmpEntity) + 0x3bc)) == (EntityPtr)clutch)) &&
|
|
((tmpEntity != clutch->_child &&
|
|
((*GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(tmpEntity) + 0xbc4)) != 1.38729e-43 &&
|
|
(fVar3 = (clutch->_pos).y - *GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(tmpEntity) + 0x340)),
|
|
deltaX = (clutch->_pos).x - (GHIDRA_CAST<Vector *>((GHIDRA_INT(tmpEntity) + 0x33c)))->x,
|
|
fVar3 = sqrtf(fVar3 * fVar3 + deltaX * deltaX),
|
|
(*GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(tmpEntity) + 0x168)) & 0x10) == 0)))))) {
|
|
enemiesData = local_38._data;
|
|
if (maxDistance < fVar3) {
|
|
maxDistance = fVar3;
|
|
local_18 = tmpEntity;
|
|
}
|
|
goto LAB_00572bab;
|
|
}
|
|
}
|
|
enemiesData = local_38._data;
|
|
}
|
|
LAB_00572bab:
|
|
uVar2 = uVar2 + 1;
|
|
tmpEntity = local_18;
|
|
} while (uVar2 < GHIDRA_UINT(local_38._size));
|
|
}
|
|
if ((*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(&(local_38)) + 0x0))) == '\0') {
|
|
if (g_mainHeap == (void *)0x0) {
|
|
heapAllocatedBytes = &g_allocatedBytesNoHeap;
|
|
}
|
|
else {
|
|
heapAllocatedBytes = GHIDRA_CAST<qword *>((GHIDRA_INT(g_mainHeap) + 0x30));
|
|
}
|
|
if (local_38._data != (void *)0x0) {
|
|
uVar2 = *GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(local_38._data) + -4));
|
|
qVar1 = *heapAllocatedBytes;
|
|
*GHIDRA_CAST<uint *>(heapAllocatedBytes) = GHIDRA_UINT(*heapAllocatedBytes) - uVar2;
|
|
*GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(heapAllocatedBytes) + 4)) =
|
|
*GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(heapAllocatedBytes) + 4)) - GHIDRA_UINT((GHIDRA_UINT(qVar1) < uVar2));
|
|
free(GHIDRA_CAST<uint *>((GHIDRA_INT(local_38._data) + -4)));
|
|
}
|
|
}
|
|
ExceptionList = local_10;
|
|
return GHIDRA_CAST<Entity *>(tmpEntity);
|
|
}
|
|
|
|
// 00572cc0
|
|
void NpcHelper::clutch_spawn_fire(Entity_NPC *npc, Entity *target)
|
|
{
|
|
undefined4 uVar1;
|
|
float fVar2;
|
|
float fVar3;
|
|
byte bVar4;
|
|
uint uVar5;
|
|
Entity *fire;
|
|
byte *pbVar6;
|
|
LayerState *layer;
|
|
uint angleRoll;
|
|
char *pcVar7;
|
|
undefined1 *size;
|
|
bool bVar8;
|
|
float fVar9;
|
|
Vector spawnPos;
|
|
Vector local_64;
|
|
ANM2 *local_5c;
|
|
Entity *local_58;
|
|
EntityPtr local_54;
|
|
Entity *local_50;
|
|
undefined1 local_4c [32];
|
|
int animPathSize;
|
|
undefined1 *animPathCapacity;
|
|
uint local_24;
|
|
undefined1 *puStack_20;
|
|
void *local_1c;
|
|
undefined1 *puStack_18;
|
|
undefined4 local_14;
|
|
code *addFlagsFn;
|
|
ANM2 *fireSprite;
|
|
EntityPtr *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<undefined4 *>((GHIDRA_INT(&target->_flags) + 4));
|
|
*GHIDRA_CAST<uint *>(&target->_flags) = GHIDRA_UINT(target->_flags) | 0x10;
|
|
*GHIDRA_CAST<undefined4 *>((GHIDRA_INT(&target->_flags) + 4)) = uVar1;
|
|
addFlagsFn = *(code **)(*GHIDRA_CAST<int *>(target) + 0x24);
|
|
local_54 = (EntityPtr)npc;
|
|
local_24 = uVar5;
|
|
(GHIDRA_CAST<EntityRef *>((GHIDRA_CAST<EntityRef *>(local_4c))))->EntityRef::constructor(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 = (GHIDRA_CAST<Game *>((g_game)))->Game::Spawn(0x21,0xd,&local_64,&g_vectorZero,GHIDRA_CAST<Entity *>(npc),0,uVar5);
|
|
animPathSize = 0;
|
|
fireSprite = &fire->_sprite;
|
|
animPathCapacity = &DAT_0000000f;
|
|
(*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(local_4c)) + 0x10))) = 0.0;
|
|
local_5c = fireSprite;
|
|
local_50 = fire;
|
|
(*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(local_4c)) + 0x10))) = std::_Allocate(0x30);
|
|
animPathSize = 0x20;
|
|
animPathCapacity = &DAT_0000002f;
|
|
builtin_strncpy((*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(GHIDRA_CAST<char *>(local_4c))) + 0x10))),"gfx/009.002_Fire Projectile.anm2",0x21);
|
|
local_14 = 0;
|
|
(GHIDRA_CAST<ANM2 *>((fireSprite)))->ANM2::Load(GHIDRA_CAST<std_string *>((local_4c + 0x10)),1);
|
|
local_14 = 0xffffffff;
|
|
if (&DAT_0000000f < animPathCapacity) {
|
|
size = animPathCapacity + 1;
|
|
pcVar7 = (*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(GHIDRA_CAST<char *>(local_4c))) + 0x10)));
|
|
if (GHIDRA_CAST<undefined1 *>(0xfff) < size) {
|
|
pcVar7 = *GHIDRA_CAST<char **>(((*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(local_4c)) + 0x10))) + -4));
|
|
size = animPathCapacity + 0x24;
|
|
if (GHIDRA_CAST<char *>(0x1f) < GHIDRA_CAST<char *>(((*GHIDRA_CAST<undefined4 *>((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<byte *>(0x0)) {
|
|
if (0xf < *GHIDRA_CAST<uint *>((pbVar6 + 0x14))) {
|
|
pbVar6 = *GHIDRA_CAST<byte **>(pbVar6);
|
|
}
|
|
pcVar7 = "Flickering";
|
|
do {
|
|
bVar4 = *pbVar6;
|
|
bVar8 = bVar4 < (byte)*pcVar7;
|
|
if (bVar4 != *pcVar7) {
|
|
LAB_00572e46:
|
|
uVar5 = -GHIDRA_UINT(bVar8) | 1;
|
|
goto LAB_00572e4b;
|
|
}
|
|
if (bVar4 == 0) break;
|
|
bVar4 = pbVar6[1];
|
|
bVar8 = bVar4 < (byte)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 = (GHIDRA_CAST<ANM2 *>((fireSprite)))->ANM2::SetAnimation(GHIDRA_CAST<byte *>("Flickering"),1);
|
|
if (bVar4 != 0) {
|
|
(GHIDRA_CAST<AnimationState *>((&(fire->_sprite)._animState)))->AnimationState::Rewind();
|
|
(fire->_sprite)._animState._isPlaying = 1;
|
|
}
|
|
LAB_00572e7c:
|
|
fireSprite = local_5c;
|
|
pbVar6 = GHIDRA_CAST<byte *>(0x0);
|
|
if ((local_50->_sprite)._layerCount != 0) {
|
|
do {
|
|
layer = (GHIDRA_CAST<ANM2 *>((fireSprite)))->ANM2::GetLayer(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<undefined8 *>((layer->_color)._offset) = DAT_00c34e48;
|
|
(layer->_color)._offset[2] = DAT_00c34e50;
|
|
}
|
|
pbVar6 = pbVar6 + 1;
|
|
} while (pbVar6 < GHIDRA_CAST<byte *>((local_50->_sprite)._layerCount));
|
|
npc = GHIDRA_CAST<Entity_NPC *>(local_54);
|
|
}
|
|
local_50->Update();
|
|
local_50 = GHIDRA_CAST<Entity *>(0x2);
|
|
do {
|
|
uVar5 = Random();
|
|
local_54 = (EntityPtr)(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 = (EntityPtr)(GHIDRA_CAST<Game *>((g_game)))->Game::Spawn(0x399,1,&spawnPos,&g_vectorZero,GHIDRA_CAST<Entity *>(npc),0,uVar5);
|
|
parentSlot = GHIDRA_CAST<EntityPtr *>((GHIDRA_INT(local_54) + 0x3bc));
|
|
if (*GHIDRA_CAST<EntityPtr *>((GHIDRA_CAST<char *>(local_54) + 0x3bc)) != (EntityPtr)0x0) {
|
|
local_64.y = (float)parentSlot;
|
|
std::multiset<unsigned_int>::erase(&local_64.y);
|
|
}
|
|
*parentSlot = (EntityPtr)npc;
|
|
if ((EntityPtr)npc != (EntityPtr)0x0) {
|
|
std::multiset<unsigned_int>::insert(parentSlot);
|
|
}
|
|
uVar5 = Random();
|
|
local_50 = GHIDRA_CAST<Entity *>((GHIDRA_INT(local_50) + -1));
|
|
*GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(local_54) + 0xbb0)) =
|
|
(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;
|
|
uint pointBlock;
|
|
uint nextPointBlock;
|
|
float *nextPoint;
|
|
float flipSign;
|
|
float deltaX;
|
|
float fVar7;
|
|
double dVar8;
|
|
double dVar9;
|
|
int layerOffset;
|
|
uint nextPointIndex;
|
|
byte *layerId;
|
|
float segmentStretch;
|
|
Vector segmentPos [8];
|
|
ANM2 *animation;
|
|
int *pointDeque;
|
|
|
|
if (npc->_variant == 0) {
|
|
pLVar1 = (GHIDRA_CAST<ANM2 *>((&npc->_sprite)))->ANM2::GetLayer(GHIDRA_CAST<byte *>(0x1));
|
|
if ((0.0 < (pLVar1->_color)._tint[3]) && ((npc->_vectorDeque1)._size != 0)) {
|
|
pLVar1 = (GHIDRA_CAST<ANM2 *>((&npc->_sprite)))->ANM2::GetLayer(GHIDRA_CAST<byte *>(0x1));
|
|
pLVar1->_visible = 1;
|
|
pLVar1 = (GHIDRA_CAST<ANM2 *>((&npc->_sprite)))->ANM2::GetLayer(GHIDRA_CAST<byte *>(0x2));
|
|
layerId = GHIDRA_CAST<byte *>(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 = (GHIDRA_CAST<ANM2 *>((&npc->_sprite)))->ANM2::GetLayer(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 = (GHIDRA_CAST<ANM2 *>((&npc->_sprite)))->ANM2::GetLayer(layerId);
|
|
pLVar1->_rotation = fVar7 * 57.295776 * flipSign;
|
|
if ((npc->_sprite)._overlayAnimState._animData != (void *)0x0) {
|
|
(GHIDRA_CAST<AnimationState *>((&(npc->_sprite)._overlayAnimState)))->AnimationState::SetFrameFloat((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 = (GHIDRA_CAST<ANM2 *>((&npc->_sprite)))->ANM2::GetLayer(GHIDRA_CAST<byte *>(0x1));
|
|
pLVar1->_visible = 0;
|
|
pLVar1 = (GHIDRA_CAST<ANM2 *>((&npc->_sprite)))->ANM2::GetLayer(GHIDRA_CAST<byte *>(0x2));
|
|
pLVar1->_visible = 0;
|
|
}
|
|
}
|
|
(GHIDRA_CAST<Entity *>((GHIDRA_CAST<Entity *>(npc))))->Entity::Render(offset);
|
|
return;
|
|
}
|
|
|
|
// 00576090
|
|
void NpcHelper::raglich_pick_target_pos(Entity_NPC *npc, float speed)
|
|
{
|
|
float fVar1;
|
|
float fVar2;
|
|
byte isInRoom;
|
|
int gridWidth;
|
|
uint 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<char *>((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 = (GHIDRA_CAST<Room *>((room)))->Room::IsPositionInRoom(&local_c,0.0);
|
|
if (isInRoom == 0) {
|
|
direction = (GHIDRA_INT((short)npc->_i1) - GHIDRA_INT(*GHIDRA_CAST<char *>((GHIDRA_INT(&npc->_i1) + 2)))) + 4U & 0x80000003;
|
|
if (GHIDRA_INT(direction) < 0) {
|
|
direction = (direction - 1 | 0xfffffffc) + 1;
|
|
}
|
|
*GHIDRA_CAST<short *>(&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<int *>((*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(room->_descriptor) + 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 = (GHIDRA_CAST<Room *>((room)))->Room::IsPositionInRoom(&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 = (GHIDRA_CAST<Room *>((room)))->Room::IsPositionInRoom(&probePos,0.0);
|
|
if (isInRoom != 0) goto LAB_00576404;
|
|
direction = (short)npc->_i1 + 4 + GHIDRA_INT(*GHIDRA_CAST<char *>((GHIDRA_INT(&npc->_i1) + 2))) & 0x80000003;
|
|
if (GHIDRA_INT(direction) < 0) {
|
|
direction = (direction - 1 | 0xfffffffc) + 1;
|
|
}
|
|
*GHIDRA_CAST<short *>(&npc->_i1) = (short)direction;
|
|
iVar3 = (GHIDRA_CAST<Room *>((room)))->Room::GetGridIndex(&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)
|
|
{
|
|
byte bVar1;
|
|
uint uVar2;
|
|
int gridX;
|
|
GridEntity *pit;
|
|
byte *animNameChar;
|
|
int gridY;
|
|
byte *wantedAnimChar;
|
|
int gridIndex;
|
|
bool isLess;
|
|
Vector particlePos;
|
|
Vector rightDamagePos;
|
|
Vector local_68;
|
|
int gridYCopy;
|
|
uint gridSeed;
|
|
Vector local_58;
|
|
int column;
|
|
void *room;
|
|
Vector slamOffset;
|
|
ColorMod particleColor;
|
|
uint local_14;
|
|
void *local_10;
|
|
undefined1 *puStack_c;
|
|
float local_8;
|
|
byte *animData;
|
|
qword flags;
|
|
int *gridAtIndex;
|
|
undefined4 *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;
|
|
(GHIDRA_CAST<Entity *>((GHIDRA_CAST<Entity *>(npc))))->Entity::GetNullOffset(&slamOffset,&DAT_00b1d3b0);
|
|
if ((slamOffset.x != g_vectorZero.x) || (slamOffset.y != g_vectorZero.y)) {
|
|
if (npc->_i1 == 0) {
|
|
npc->_i1 = 1;
|
|
(GHIDRA_CAST<Entity_NPC *>((npc)))->Entity_NPC::PlaySound(0x34,1.0,2,0,1.0);
|
|
(GHIDRA_CAST<Game *>((g_game)))->Game::ShakeScreen(0xe);
|
|
}
|
|
local_68.x = slamOffset.x + (npc->_pos).x;
|
|
local_68.y = slamOffset.y + (npc->_pos).y;
|
|
(GHIDRA_CAST<Game *>((g_game)))->Game::BombDamage(&local_68,10.0,20.0,0,GHIDRA_CAST<Entity *>(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;
|
|
(GHIDRA_CAST<Game *>((g_game)))->Game::BombDamage(&local_58,10.0,20.0,0,GHIDRA_CAST<Entity *>(npc),(BitSet128)ZEXT816(0),0x1000000,0)
|
|
;
|
|
rightDamagePos.x = slamOffset.x + (npc->_pos).x + 40.0;
|
|
rightDamagePos.y = slamOffset.y + (npc->_pos).y + 0.0;
|
|
(GHIDRA_CAST<Game *>((g_game)))->Game::BombDamage(&rightDamagePos,10.0,20.0,0,GHIDRA_CAST<Entity *>(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<int *>((GHIDRA_CAST<char *>(room) + 0xc)))) && (-1 < gridY)) &&
|
|
((gridY < *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(room) + 0x10)) &&
|
|
(gridIndex = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(room) + 0xc)) * gridY + column, -1 < gridIndex)))) {
|
|
gridSeed = Random();
|
|
if (gridIndex < 0x1c0) {
|
|
if (*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(room) + gridIndex * 4 + 0x76c)) < 0x385) {
|
|
pit = operator_new(0x158);
|
|
local_8 = 8.40779e-45;
|
|
local_68.y = (float)pit;
|
|
if (pit == GHIDRA_CAST<GridEntity *>(0x0)) {
|
|
pit = GHIDRA_CAST<GridEntity *>(0x0);
|
|
}
|
|
else {
|
|
(GHIDRA_CAST<GridEntity *>((pit)))->GridEntity::GridEntity();
|
|
*GHIDRA_CAST<undefined ***>(pit) = IsaacRepentancePlus::GridEntity_Pit::vftable;
|
|
}
|
|
local_8 = -NAN;
|
|
if (pit != GHIDRA_CAST<GridEntity *>(0x0)) {
|
|
(pit->_desc)._type = 7;
|
|
pit->_gridIndex = gridIndex;
|
|
oldGrid = *GHIDRA_CAST<undefined4 **>((GHIDRA_CAST<char *>(room) + gridIndex * 4 + 0x24));
|
|
if (oldGrid != GHIDRA_CAST<undefined4 *>(0x0)) {
|
|
(**(code **)*oldGrid)(1);
|
|
}
|
|
*GHIDRA_CAST<GridEntity **>((GHIDRA_CAST<char *>(room) + gridIndex * 4 + 0x24)) = pit;
|
|
(pit->_desc)._variant = 0;
|
|
(pit->_desc)._varData = 0;
|
|
(GHIDRA_CAST<GridEntity *>((pit)))->GridEntity::Init(gridSeed);
|
|
}
|
|
gridX = column;
|
|
}
|
|
gridAtIndex = *GHIDRA_CAST<int **>((GHIDRA_CAST<char *>(g_game->_room) + gridIndex * 4 + 0x24));
|
|
if ((gridAtIndex != GHIDRA_CAST<int *>(0x0)) && (gridAtIndex[1] == 7)) {
|
|
(**(code **)(*gridAtIndex + 4))();
|
|
}
|
|
}
|
|
else {
|
|
KAGE_LogMessage(0x10,GHIDRA_CAST<byte *>("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)) {
|
|
npc->Remove(uVar2);
|
|
ExceptionList = local_10;
|
|
return;
|
|
}
|
|
ExceptionList = local_10;
|
|
return;
|
|
}
|
|
animData = (npc->_sprite)._animState._animData;
|
|
if (animData != GHIDRA_CAST<byte *>(0x0)) {
|
|
animNameChar = animData;
|
|
if (0xf < *GHIDRA_CAST<uint *>((animData + 0x14))) {
|
|
animNameChar = *GHIDRA_CAST<byte **>(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 = (GHIDRA_CAST<ANM2 *>((&npc->_sprite)))->ANM2::SetAnimation(&DAT_00b61c98,1);
|
|
if (bVar1 != 0) {
|
|
(GHIDRA_CAST<AnimationState *>((&(npc->_sprite)._animState)))->AnimationState::Rewind();
|
|
(npc->_sprite)._animState._isPlaying = 1;
|
|
}
|
|
LAB_00576948:
|
|
flags = npc->_flags;
|
|
*GHIDRA_CAST<undefined4 *>((GHIDRA_INT(&npc->_flags) + 4)) = *GHIDRA_CAST<undefined4 *>((GHIDRA_INT(&npc->_flags) + 4));
|
|
*GHIDRA_CAST<uint *>(&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)
|
|
{
|
|
EntityPtr EVar1;
|
|
EntityPtr EVar2;
|
|
uint rngResult;
|
|
float distance;
|
|
float fVar3;
|
|
float distance;
|
|
float fVar5;
|
|
float dirY;
|
|
float dirX;
|
|
|
|
EVar1 = timer->_parent;
|
|
if (EVar1 == (EntityPtr)0x0) {
|
|
return;
|
|
}
|
|
if (*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(EVar1) + 0x28)) != 9) {
|
|
return;
|
|
}
|
|
distance = timer->_rotation;
|
|
EVar2 = timer->_target;
|
|
fVar3 = timer->_scale;
|
|
*GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(EVar1) + 0x43c)) = *GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(EVar1) + 0x43c)) & 0xfffffeff;
|
|
*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(EVar1) + 0x438)) = *GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(EVar1) + 0x438));
|
|
if (EVar2 == (EntityPtr)0x0) {
|
|
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<float *>((GHIDRA_CAST<char *>(EVar2) + 0x33c));
|
|
dirY = *GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(EVar2) + 0x340));
|
|
if (fVar3 <= 0.0) {
|
|
fVar5 = *GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(EVar1) + 0x33c));
|
|
}
|
|
else {
|
|
fVar5 = *GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(EVar1) + 0x33c));
|
|
distance = *GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(EVar1) + 0x340)) - dirY;
|
|
distance = sqrtf(distance * distance + (fVar5 - dirX) * (fVar5 - dirX));
|
|
dirY = dirY + distance * *GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(EVar2) + 0x364)) * fVar3;
|
|
dirX = dirX + distance * *GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(EVar2) + 0x360)) * fVar3;
|
|
}
|
|
dirY = dirY - *GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(EVar1) + 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<float *>((GHIDRA_CAST<char *>(EVar1) + 0x360)) = dirX * 10.0;
|
|
*GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(EVar1) + 0x364)) = dirY * 10.0;
|
|
return;
|
|
}
|
|
|
|
// 00579770
|
|
int NpcHelper::ReapCreep_CountOtherEnemies()
|
|
{
|
|
void *pvVar1;
|
|
int iVar2;
|
|
int bossCount;
|
|
int enemyCount;
|
|
|
|
pvVar1 = g_game->_room;
|
|
iVar2 = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(pvVar1) + 0x12c8)) + *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(pvVar1) + 0x12cc));
|
|
enemyCount = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(pvVar1) + 0x12c4)) + *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(pvVar1) + 0x12c0));
|
|
bossCount = 0;
|
|
if (0 < iVar2) {
|
|
bossCount = iVar2;
|
|
}
|
|
iVar2 = 0;
|
|
if (0 < enemyCount) {
|
|
iVar2 = enemyCount;
|
|
}
|
|
return iVar2 - bossCount;
|
|
}
|
|
|
|
// 005797b0
|
|
Entity_Laser * NpcHelper::ReapCreep_ThinLaser(Entity_NPC *npc, float startAngle, float endAngle, int unused)
|
|
{
|
|
Entity_Laser *pEVar1;
|
|
undefined1 *rotationSpeed;
|
|
Vector spawnPos;
|
|
Vector laserOffset;
|
|
float savedStartAngle;
|
|
float savedEndAngle;
|
|
|
|
spawnPos.x = (npc->_pos).x + 0.0;
|
|
spawnPos.y = (npc->_pos).y + 4.0;
|
|
laserOffset.x = 0.0;
|
|
laserOffset.y = -32.0;
|
|
savedStartAngle = startAngle;
|
|
savedEndAngle = endAngle;
|
|
pEVar1 = Entity_Laser::ShootAngle(1,&spawnPos,startAngle,100,&laserOffset,GHIDRA_CAST<Entity *>(npc),0);
|
|
if (savedEndAngle <= savedStartAngle) {
|
|
rotationSpeed = &DAT_bf800000;
|
|
}
|
|
else {
|
|
rotationSpeed = GHIDRA_CAST<undefined1 *>(0x3f800000);
|
|
}
|
|
pEVar1->_isActiveRotating = 1;
|
|
pEVar1->_rotationDelay = 0x1e;
|
|
pEVar1->_rotationSpd = (float)rotationSpeed;
|
|
pEVar1->_renderDepthOffset = 1000.0;
|
|
pEVar1->_rotationDegrees = savedEndAngle - savedStartAngle;
|
|
pEVar1->Update();
|
|
return pEVar1;
|
|
}
|
|
|
|
// 00582f60
|
|
void NpcHelper::scourge_whip(Entity_NPC *npc)
|
|
{
|
|
byte bVar1;
|
|
byte *animNameCursor;
|
|
uint uVar2;
|
|
EntityPtr segment;
|
|
byte *targetNameCursor;
|
|
byte *anim;
|
|
bool isLess;
|
|
Entity_NPC *local_c;
|
|
float pitch;
|
|
byte *animData;
|
|
Manager *manager;
|
|
EntityPtr nextSegment;
|
|
|
|
segment = (EntityPtr)npc;
|
|
while (((nextSegment = *GHIDRA_CAST<EntityPtr *>((GHIDRA_CAST<char *>(segment) + 0x3c0)), nextSegment != (EntityPtr)0x0 &&
|
|
(*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(nextSegment) + 0x28)) == 0x38d)) && (*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(nextSegment) + 0x2c)) == 10)
|
|
)) {
|
|
segment = nextSegment;
|
|
}
|
|
*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(segment) + 0xb64)) = 7;
|
|
*GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(segment) + 0x334)) = g_vectorZero.x;
|
|
*GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(segment) + 0x338)) = g_vectorZero.y;
|
|
segment = (EntityPtr)npc;
|
|
while (((nextSegment = *GHIDRA_CAST<EntityPtr *>((GHIDRA_CAST<char *>(segment) + 0x3bc)), nextSegment != (EntityPtr)0x0 &&
|
|
(*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(nextSegment) + 0x28)) == 0x38d)) && (*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(nextSegment) + 0x2c)) == 10)
|
|
)) {
|
|
segment = nextSegment;
|
|
}
|
|
animData = *GHIDRA_CAST<byte **>((GHIDRA_CAST<char *>(segment) + 0x7c));
|
|
anim = &DAT_00b62058;
|
|
if (npc->_subtype == 0) {
|
|
anim = &DAT_00b6208c;
|
|
}
|
|
local_c = npc;
|
|
if (animData != GHIDRA_CAST<byte *>(0x0)) {
|
|
animNameCursor = animData;
|
|
if (0xf < *GHIDRA_CAST<uint *>((animData + 0x14))) {
|
|
animNameCursor = *GHIDRA_CAST<byte **>(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 || (*GHIDRA_CAST<char *>((GHIDRA_CAST<char *>(segment) + 0x8c)) != '\0'))))
|
|
goto LAB_00583051;
|
|
}
|
|
bVar1 = (GHIDRA_CAST<ANM2 *>((GHIDRA_CAST<ANM2 *>((GHIDRA_INT(segment) + 0x48)))))->ANM2::SetAnimation(anim,1);
|
|
if (bVar1 != 0) {
|
|
(GHIDRA_CAST<AnimationState *>((GHIDRA_CAST<AnimationState *>((GHIDRA_INT(segment) + 0x78)))))->AnimationState::Rewind();
|
|
*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(segment) + 0x8c)) = 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;
|
|
uint rngResult;
|
|
Entity_NPC *in_ECX;
|
|
EntityPtr 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;
|
|
ProjectileParams projParams;
|
|
undefined1 local_28;
|
|
undefined1 *local_24;
|
|
undefined4 local_20;
|
|
undefined1 local_1c;
|
|
float local_14;
|
|
Manager *manager;
|
|
EntityPtr nextSegment;
|
|
|
|
local_14 = (float)(__security_cookie ^ GHIDRA_UINT(&(&projParams)[1].CircleAngle));
|
|
chainEnd = in_ECX->_child;
|
|
while (((nextSegment = *GHIDRA_CAST<EntityPtr *>((GHIDRA_CAST<char *>(chainEnd) + 0x3c0)), nextSegment != (EntityPtr)0x0 &&
|
|
(*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(nextSegment) + 0x28)) == 0x38d)) && (*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(nextSegment) + 0x2c)) == 10)
|
|
)) {
|
|
chainEnd = nextSegment;
|
|
}
|
|
local_e8 = (in_ECX->_pos).x;
|
|
local_ec = (in_ECX->_pos).y;
|
|
childChainOffsetX = *GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(chainEnd) + 0x33c)) - local_e8;
|
|
childChainOffsetY = *GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(chainEnd) + 0x340)) - local_ec;
|
|
chainEnd = in_ECX->_entityRef;
|
|
while (((nextSegment = *GHIDRA_CAST<EntityPtr *>((GHIDRA_CAST<char *>(chainEnd) + 0x3c0)), nextSegment != (EntityPtr)0x0 &&
|
|
(*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(nextSegment) + 0x28)) == 0x38d)) && (*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(nextSegment) + 0x2c)) == 10)
|
|
)) {
|
|
chainEnd = nextSegment;
|
|
}
|
|
local_e8 = *GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(chainEnd) + 0x33c)) - local_e8;
|
|
local_ec = *GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(chainEnd) + 0x340)) - local_ec;
|
|
pEVar1 = (GHIDRA_CAST<Entity_NPC *>((in_ECX)))->Entity_NPC::GetPlayerTarget();
|
|
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.GridCollision = 1;
|
|
projParams.HeightModifier = 0.0;
|
|
projParams.FallingSpeedModifier = 0.0;
|
|
projParams.FallingAccelModifier = 0.0;
|
|
projParams.VelocityMulti = 1.0;
|
|
projParams.Scale = 1.0;
|
|
rngResult = Random();
|
|
projParams.PositionOffset.x = g_vectorZero.x;
|
|
projParams.TargetPosition.x = g_vectorZero.x;
|
|
projParams.FireDirectionLimit.x = g_vectorZero.x;
|
|
projParams.DotProductLimit = -1000.0;
|
|
projParams.WiggleFrameOffset = 0;
|
|
projParams.ChangeVelocity = 0.0;
|
|
projParams.ChangeTimeout = 0x1e;
|
|
projParams.PositionOffset.y = g_vectorZero.y;
|
|
projParams.TargetPosition.y = g_vectorZero.y;
|
|
projParams.FireDirectionLimit.y = g_vectorZero.y;
|
|
projParams.DepthOffset = 0.0;
|
|
projParams.Variant = 0;
|
|
local_28 = 0;
|
|
local_24 = &DAT_bf800000;
|
|
local_20 = 0;
|
|
local_1c = 0;
|
|
projParams.Color._offset[2] = DAT_00c34cf0;
|
|
(*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(projParams.BulletFlags)) + 0x0))) = 0x2000;
|
|
projParams.CircleAngle =
|
|
(float)((double)GHIDRA_INT(rngResult) + __uint_to_double_fixup[-(GHIDRA_INT(rngResult) >> 0x1f)]) *
|
|
2.3283064e-10 * 3.1415927;
|
|
(*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(projParams.BulletFlags)) + 0x4))) = 0;
|
|
projParams.HomingStrength = 1.0;
|
|
projParams.CurvingStrength = 0.005;
|
|
projParams.Acceleration = 1.01;
|
|
projParams.Spread = 1.0;
|
|
projParams.ChangeFlags = 0;
|
|
projParams.HeightModifier = projParams.HeightModifier + 10.0;
|
|
projParams.FallingAccelModifier = projParams.FallingAccelModifier - 0.14;
|
|
projParams.Color._tint[0] = _DAT_00c34cc8;
|
|
projParams.Color._tint[1] = fRam00c34ccc;
|
|
projParams.Color._tint[2] = fRam00c34cd0;
|
|
projParams.Color._tint[3] = fRam00c34cd4;
|
|
projParams.Color._colorize[0] = _DAT_00c34cd8;
|
|
projParams.Color._colorize[1] = fRam00c34cdc;
|
|
projParams.Color._colorize[2] = fRam00c34ce0;
|
|
projParams.Color._colorize[3] = fRam00c34ce4;
|
|
projParams.Color._offset[0] = (float)DAT_00c34ce8;
|
|
projParams.Color._offset[1] = (*GHIDRA_CAST<undefined4 *>((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,&projParams);
|
|
effectPos.x = local_c4 * 4.0 + shootPos.x;
|
|
effectPos.y = local_c8 * 4.0 + shootPos.y;
|
|
rngResult = Random();
|
|
pEVar1 = (GHIDRA_CAST<Game *>((g_game)))->Game::Spawn(1000,2,&effectPos,&g_vectorZero,GHIDRA_CAST<Entity *>(0x0),1,rngResult);
|
|
pEVar1->SetColor(&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;
|
|
qword qVar2;
|
|
uint uVar3;
|
|
uint angleRoll;
|
|
Entity *minion;
|
|
qword *heapCounter;
|
|
float fVar4;
|
|
EntityList_EL minions;
|
|
EntityList_EL nearby;
|
|
Vector spawnPos;
|
|
float angle;
|
|
float angleSin;
|
|
ColorMod explosionColor;
|
|
uint local_18;
|
|
void *local_10;
|
|
undefined1 *puStack_c;
|
|
float local_8;
|
|
undefined4 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);
|
|
(GHIDRA_CAST<Game *>((g_game)))->Game::ShakeScreen(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<char *>(nearby._data) + 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<undefined1 *>((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 = (GHIDRA_CAST<Game *>((g_game)))->Game::Spawn(0x393,1,&spawnPos,&g_vectorZero,GHIDRA_CAST<Entity *>(npc),0,uVar3);
|
|
flagsHigh = *GHIDRA_CAST<undefined4 *>((GHIDRA_INT(&minion->_flags) + 4));
|
|
iVar1 = *GHIDRA_CAST<int *>(minion);
|
|
*GHIDRA_CAST<uint *>(&minion->_flags) = GHIDRA_UINT(minion->_flags) & 0xfffffffb;
|
|
*GHIDRA_CAST<undefined4 *>((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<undefined1 *>((GHIDRA_CAST<char *>(&(minions)) + 0x0))) == '\0') {
|
|
heapCounter = GHIDRA_CAST<qword *>((GHIDRA_INT(g_mainHeap) + 0x30));
|
|
if (g_mainHeap == (void *)0x0) {
|
|
heapCounter = &g_allocatedBytesNoHeap;
|
|
}
|
|
if (minions._data != (void *)0x0) {
|
|
uVar3 = *GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(minions._data) + -4));
|
|
qVar2 = *heapCounter;
|
|
*GHIDRA_CAST<uint *>(heapCounter) = GHIDRA_UINT(*heapCounter) - uVar3;
|
|
*GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(heapCounter) + 4)) =
|
|
*GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(heapCounter) + 4)) - GHIDRA_UINT((GHIDRA_UINT(qVar2) < uVar3));
|
|
free((void *)(GHIDRA_INT(minions._data) + -4));
|
|
}
|
|
}
|
|
if ((*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(&(nearby)) + 0x0))) == '\0') {
|
|
heapCounter = GHIDRA_CAST<qword *>((GHIDRA_INT(g_mainHeap) + 0x30));
|
|
if (g_mainHeap == (void *)0x0) {
|
|
heapCounter = &g_allocatedBytesNoHeap;
|
|
}
|
|
if (nearby._data != (void *)0x0) {
|
|
uVar3 = *GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(nearby._data) + -4));
|
|
qVar2 = *heapCounter;
|
|
*GHIDRA_CAST<uint *>(heapCounter) = GHIDRA_UINT(*heapCounter) - uVar3;
|
|
*GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(heapCounter) + 4)) =
|
|
*GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(heapCounter) + 4)) - GHIDRA_UINT((GHIDRA_UINT(qVar2) < uVar3));
|
|
free((void *)(GHIDRA_INT(nearby._data) + -4));
|
|
}
|
|
}
|
|
ExceptionList = local_10;
|
|
return;
|
|
}
|
|
|
|
// 0058e260
|
|
void NpcHelper::siren_charm_familiar(Entity_NPC *npc, Entity_Familiar *familiar)
|
|
{
|
|
ANM2 *pAVar1;
|
|
Entity_Familiar *pEVar2;
|
|
uint seed;
|
|
Entity *secondEffect;
|
|
EntityPtr *refSlot;
|
|
Vector local_1c;
|
|
Vector local_14;
|
|
EntityPtr *eraseRef [2];
|
|
EntityPtr temp_5f68b46de4;
|
|
|
|
pEVar2 = familiar;
|
|
if ((familiar->_flags & 0x100) == 0) {
|
|
seed = Random();
|
|
local_14.x = (pEVar2->_velocity).x;
|
|
local_14.y = (pEVar2->_velocity).y;
|
|
local_1c.x = (pEVar2->_pos).x;
|
|
local_1c.y = (pEVar2->_pos).y;
|
|
familiar = (Entity_Familiar *)
|
|
(GHIDRA_CAST<Game *>((g_game)))->Game::Spawn(1000,0xa5,&local_1c,&local_14,GHIDRA_CAST<Entity *>(npc),0,seed);
|
|
*GHIDRA_CAST<undefined4 *>(&(*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>((familiar)) + 0x45c)))) = 0x4b;
|
|
refSlot = &familiar->_parent;
|
|
*GHIDRA_CAST<undefined4 *>(&(*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>((familiar)) + 0x460)))) = 0x4b;
|
|
if (familiar->_parent != (EntityPtr)0x0) {
|
|
eraseRef[0] = refSlot;
|
|
std::multiset<unsigned_int>::erase(eraseRef);
|
|
}
|
|
*refSlot = (EntityPtr)npc;
|
|
if (npc != GHIDRA_CAST<Entity_NPC *>(0x0)) {
|
|
std::multiset<unsigned_int>::insert(refSlot);
|
|
}
|
|
refSlot = &familiar->_target;
|
|
if (*refSlot != (EntityPtr)0x0) {
|
|
eraseRef[0] = refSlot;
|
|
std::multiset<unsigned_int>::erase(eraseRef);
|
|
}
|
|
*refSlot = (EntityPtr)pEVar2;
|
|
std::multiset<unsigned_int>::insert(refSlot);
|
|
local_14.y = (float)npc->_sirenPlayerEntity;
|
|
refSlot = &familiar->_child;
|
|
if (*refSlot != (EntityPtr)0x0) {
|
|
eraseRef[0] = refSlot;
|
|
std::multiset<unsigned_int>::erase(eraseRef);
|
|
}
|
|
*refSlot = (EntityPtr)local_14.y;
|
|
if ((EntityPtr)local_14.y != (EntityPtr)0x0) {
|
|
std::multiset<unsigned_int>::insert(refSlot);
|
|
}
|
|
familiar->Update();
|
|
seed = Random();
|
|
local_1c.x = (pEVar2->_velocity).x;
|
|
local_1c.y = (pEVar2->_velocity).y;
|
|
local_14.x = (pEVar2->_pos).x;
|
|
local_14.y = (pEVar2->_pos).y;
|
|
secondEffect = (GHIDRA_CAST<Game *>((g_game)))->Game::Spawn(1000,0xa5,&local_14,&local_1c,GHIDRA_CAST<Entity *>(npc),1,seed);
|
|
temp_5f68b46de4 = secondEffect->_parent;
|
|
pAVar1 = &secondEffect[1]._sprite;
|
|
(pAVar1->_filename)._buf[4] = 'K';
|
|
(pAVar1->_filename)._buf[5] = '\0';
|
|
(pAVar1->_filename)._buf[6] = '\0';
|
|
(pAVar1->_filename)._buf[7] = '\0';
|
|
pAVar1 = &secondEffect[1]._sprite;
|
|
(pAVar1->_filename)._buf[8] = 'K';
|
|
(pAVar1->_filename)._buf[9] = '\0';
|
|
(pAVar1->_filename)._buf[10] = '\0';
|
|
(pAVar1->_filename)._buf[0xb] = '\0';
|
|
if (temp_5f68b46de4 != (EntityPtr)0x0) {
|
|
familiar = GHIDRA_CAST<Entity_Familiar *>(&secondEffect->_parent);
|
|
std::multiset<unsigned_int>::erase(&familiar);
|
|
}
|
|
secondEffect->_parent = (EntityPtr)npc;
|
|
std::multiset<unsigned_int>::insert(&secondEffect->_parent);
|
|
if (secondEffect->_target != (EntityPtr)0x0) {
|
|
familiar = GHIDRA_CAST<Entity_Familiar *>(&secondEffect->_target);
|
|
std::multiset<unsigned_int>::erase(&familiar);
|
|
}
|
|
secondEffect->_target = (EntityPtr)pEVar2;
|
|
std::multiset<unsigned_int>::insert(&secondEffect->_target);
|
|
temp_5f68b46de4 = (EntityPtr)npc->_sirenPlayerEntity;
|
|
refSlot = &secondEffect->_child;
|
|
if (*refSlot != (EntityPtr)0x0) {
|
|
familiar = GHIDRA_CAST<Entity_Familiar *>(refSlot);
|
|
std::multiset<unsigned_int>::erase(&familiar);
|
|
}
|
|
*refSlot = temp_5f68b46de4;
|
|
if (temp_5f68b46de4 != (EntityPtr)0x0) {
|
|
std::multiset<unsigned_int>::insert(refSlot);
|
|
}
|
|
secondEffect->Update();
|
|
}
|
|
return;
|
|
}
|
|
|
|
// 0058e490
|
|
void NpcHelper::siren_familiar_counts(int *outFreeCount, int *outCharmedCount, int *outTotalCount)
|
|
{
|
|
char isCharmable;
|
|
uint uVar1;
|
|
void *familiarsData;
|
|
int extraout_ECX;
|
|
uint uVar2;
|
|
uint extraout_EDX;
|
|
qword *heapAllocatedBytes;
|
|
EntityList_EL local_24;
|
|
void *local_10;
|
|
undefined1 *puStack_c;
|
|
undefined4 uStack_8;
|
|
int familiar;
|
|
Game *game;
|
|
qword 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 = local_24._data;
|
|
do {
|
|
familiar = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(familiarsData) + uVar2 * 4));
|
|
if ((familiar != 0) && (*GHIDRA_CAST<int *>((familiar + 0x28)) == 3)) {
|
|
isCharmable = FUN_0060dae0(uVar1);
|
|
if (isCharmable != '\0') {
|
|
if ((*GHIDRA_CAST<uint *>((extraout_ECX + 0x168)) & 0x100) == 0) {
|
|
*outFreeCount = *outFreeCount + 1;
|
|
}
|
|
else {
|
|
*outCharmedCount = *outCharmedCount + 1;
|
|
}
|
|
*outTotalCount = *outTotalCount + 1;
|
|
}
|
|
familiarsData = local_24._data;
|
|
uVar2 = extraout_EDX;
|
|
}
|
|
uVar2 = uVar2 + 1;
|
|
} while (uVar2 < GHIDRA_UINT(local_24._size));
|
|
}
|
|
if ((*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(&(local_24)) + 0x0))) == '\0') {
|
|
if (g_mainHeap == (void *)0x0) {
|
|
heapAllocatedBytes = &g_allocatedBytesNoHeap;
|
|
}
|
|
else {
|
|
heapAllocatedBytes = GHIDRA_CAST<qword *>((GHIDRA_INT(g_mainHeap) + 0x30));
|
|
}
|
|
if (local_24._data != (void *)0x0) {
|
|
uVar2 = *GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(local_24._data) + -4));
|
|
oldAllocatedBytes = *heapAllocatedBytes;
|
|
*GHIDRA_CAST<uint *>(heapAllocatedBytes) = GHIDRA_UINT(*heapAllocatedBytes) - uVar2;
|
|
*GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(heapAllocatedBytes) + 4)) =
|
|
*GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(heapAllocatedBytes) + 4)) - GHIDRA_UINT((GHIDRA_UINT(oldAllocatedBytes) < uVar2));
|
|
free(GHIDRA_CAST<uint *>((GHIDRA_INT(local_24._data) + -4)));
|
|
}
|
|
}
|
|
ExceptionList = local_10;
|
|
return;
|
|
}
|
|
|
|
// 0058e590
|
|
int NpcHelper::siren_charmed_count(Entity_NPC *npc)
|
|
{
|
|
qword qVar1;
|
|
byte isDetached;
|
|
qword *allocatedBytes;
|
|
int extraout_ECX;
|
|
uint uVar2;
|
|
uint extraout_EDX;
|
|
int count;
|
|
EntityList_EL local_24;
|
|
Entity_NPC *siren;
|
|
void *local_10;
|
|
undefined1 *puStack_c;
|
|
undefined4 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<char *>(local_24._data) + uVar2 * 4));
|
|
if ((((familiar != GHIDRA_CAST<Entity_Familiar *>(0x0)) && (familiar->_type == 3)) &&
|
|
((familiar->_flags & 0x100) != 0)) &&
|
|
((isDetached = (GHIDRA_CAST<Entity_Familiar *>((familiar)))->Entity_Familiar::is_detached_from_follow(), 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<undefined1 *>((GHIDRA_CAST<char *>(&(local_24)) + 0x0))) == '\0') {
|
|
if (g_mainHeap == (void *)0x0) {
|
|
allocatedBytes = &g_allocatedBytesNoHeap;
|
|
}
|
|
else {
|
|
allocatedBytes = GHIDRA_CAST<qword *>((GHIDRA_INT(g_mainHeap) + 0x30));
|
|
}
|
|
if (local_24._data != (void *)0x0) {
|
|
uVar2 = *GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(local_24._data) + -4));
|
|
qVar1 = *allocatedBytes;
|
|
*GHIDRA_CAST<uint *>(allocatedBytes) = GHIDRA_UINT(*allocatedBytes) - uVar2;
|
|
*GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(allocatedBytes) + 4)) =
|
|
*GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(allocatedBytes) + 4)) - GHIDRA_UINT((GHIDRA_UINT(qVar1) < uVar2));
|
|
free((void *)(GHIDRA_INT(local_24._data) + -4));
|
|
}
|
|
}
|
|
ExceptionList = local_10;
|
|
return count;
|
|
}
|
|
|
|
// 0058e680
|
|
void NpcHelper::siren_pick(Entity_NPC *npc)
|
|
{
|
|
RNG rng;
|
|
qword qVar1;
|
|
int charmedCount;
|
|
uint uVar2;
|
|
int familiar;
|
|
float fVar3;
|
|
uint outcomeCount;
|
|
float fVar4;
|
|
qword *heapCounter;
|
|
WeightedOutcomePicker outcomesBegin;
|
|
WeightedOutcomePicker controlledCount;
|
|
WeightedOutcomePicker outcomeCursor;
|
|
float roomCenterY;
|
|
float rightEdgeStart;
|
|
float leftEdgeStart;
|
|
WeightedOutcomePicker controlledTotal;
|
|
EntityList_EL local_64;
|
|
Entity_NPC *local_54;
|
|
WeightedOutcomePicker picker;
|
|
WeightedOutcomePicker outcomesEnd;
|
|
WeightedOutcomePicker outcomesCapacity;
|
|
float local_44;
|
|
float local_40;
|
|
int local_3c [7];
|
|
undefined1 *puStack_20;
|
|
void *local_1c;
|
|
undefined1 *puStack_18;
|
|
uint local_14;
|
|
void *room;
|
|
int *weight;
|
|
|
|
puStack_20 = GHIDRA_CAST<undefined1 *>((local_3c + 0xe));
|
|
puStack_18 = &LAB_00af55ad;
|
|
local_1c = ExceptionList;
|
|
local_3c[6] = __security_cookie ^ GHIDRA_UINT((local_3c + 0xb));
|
|
ExceptionList = &local_1c;
|
|
controlledCount = (WeightedOutcomePicker)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 = (WeightedOutcomePicker)0x0;
|
|
outcomesEnd = (WeightedOutcomePicker)0x0;
|
|
outcomesCapacity = (WeightedOutcomePicker)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 = (WeightedOutcomePicker)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 = (WeightedOutcomePicker)0x0;
|
|
if ((float)local_64._size != 0.0) {
|
|
do {
|
|
familiar = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(local_64._data) + GHIDRA_INT(fVar4) * 4));
|
|
if ((familiar == 0) || (*GHIDRA_CAST<int *>((familiar + 0x28)) != 3)) {
|
|
familiar = 0;
|
|
}
|
|
if (((*GHIDRA_CAST<uint *>((familiar + 0x168)) & 0x100) != 0) &&
|
|
(*(void **)(familiar + 0x410) == local_54->_sirenPlayerEntity)) {
|
|
controlledCount = (WeightedOutcomePicker)(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<undefined1 *>((GHIDRA_CAST<char *>(&(local_64)) + 0x0))) == '\0') {
|
|
if (g_mainHeap == (void *)0x0) {
|
|
heapCounter = &g_allocatedBytesNoHeap;
|
|
}
|
|
else {
|
|
heapCounter = GHIDRA_CAST<qword *>((GHIDRA_INT(g_mainHeap) + 0x30));
|
|
}
|
|
if (local_64._data != (void *)0x0) {
|
|
uVar2 = *GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(local_64._data) + -4));
|
|
qVar1 = *heapCounter;
|
|
*GHIDRA_CAST<uint *>(heapCounter) = GHIDRA_UINT(*heapCounter) - uVar2;
|
|
*GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(heapCounter) + 4)) =
|
|
*GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(heapCounter) + 4)) - GHIDRA_UINT((GHIDRA_UINT(qVar1) < uVar2));
|
|
free(GHIDRA_CAST<uint *>((GHIDRA_INT(local_64._data) + -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);
|
|
std::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 (*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(outcomesBegin) + uVar2 * 8)) == 3) {
|
|
weight = GHIDRA_CAST<undefined4 *>((GHIDRA_INT(outcomesBegin) + 4)) + uVar2 * 2;
|
|
*weight = *weight + GHIDRA_INT(local_40);
|
|
if (*weight < 0) {
|
|
(GHIDRA_CAST<undefined4 *>((GHIDRA_INT(outcomesBegin) + 4)))[uVar2 * 2] = 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) {
|
|
std::vector<8byte>::_Emplace_reallocate(outcomeCursor,&local_64._capacity);
|
|
outcomesBegin = picker;
|
|
outcomeCursor = outcomesEnd;
|
|
}
|
|
else {
|
|
*GHIDRA_CAST<undefined4 *>(outcomeCursor) = 3;
|
|
*GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(outcomeCursor) + 4)) = local_40;
|
|
outcomesEnd = (WeightedOutcomePicker)(GHIDRA_INT(outcomeCursor) + 8);
|
|
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 (*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(outcomesBegin) + uVar2 * 8)) == 4) {
|
|
weight = GHIDRA_CAST<undefined4 *>((GHIDRA_INT(outcomesBegin) + 4)) + uVar2 * 2;
|
|
*weight = *weight + GHIDRA_INT(local_40);
|
|
if (*weight < 0) {
|
|
(GHIDRA_CAST<undefined4 *>((GHIDRA_INT(outcomesBegin) + 4)))[uVar2 * 2] = 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) {
|
|
std::vector<8byte>::_Emplace_reallocate(outcomeCursor,&local_64._capacity);
|
|
outcomesBegin = picker;
|
|
outcomeCursor = outcomesEnd;
|
|
}
|
|
else {
|
|
*GHIDRA_CAST<undefined4 *>(outcomeCursor) = 4;
|
|
*GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(outcomeCursor) + 4)) = local_40;
|
|
outcomesEnd = (WeightedOutcomePicker)(GHIDRA_INT(outcomeCursor) + 8);
|
|
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<byte *>("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<byte *>("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<byte *>("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 (*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(outcomesBegin) + uVar2 * 8)) == 5) {
|
|
weight = GHIDRA_CAST<undefined4 *>((GHIDRA_INT(outcomesBegin) + 4)) + uVar2 * 2;
|
|
*weight = *weight + GHIDRA_INT(fVar4);
|
|
if (*weight < 0) {
|
|
(GHIDRA_CAST<undefined4 *>((GHIDRA_INT(outcomesBegin) + 4)))[uVar2 * 2] = 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) {
|
|
std::vector<8byte>::_Emplace_reallocate(outcomeCursor,&local_64._capacity);
|
|
outcomesBegin = picker;
|
|
outcomeCursor = outcomesEnd;
|
|
}
|
|
else {
|
|
*GHIDRA_CAST<undefined4 *>(outcomeCursor) = 5;
|
|
*GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(outcomeCursor) + 4)) = fVar4;
|
|
outcomesEnd = (WeightedOutcomePicker)(GHIDRA_INT(outcomeCursor) + 8);
|
|
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 (*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(outcomesBegin) + uVar2 * 8)) == 0) {
|
|
weight = GHIDRA_CAST<undefined4 *>((GHIDRA_INT(outcomesBegin) + 4)) + uVar2 * 2;
|
|
*weight = *weight + 100;
|
|
if (*weight < 0) {
|
|
(GHIDRA_CAST<undefined4 *>((GHIDRA_INT(outcomesBegin) + 4)))[uVar2 * 2] = 0;
|
|
}
|
|
goto LAB_0058ebbb;
|
|
}
|
|
uVar2 = uVar2 + 1;
|
|
} while (uVar2 < outcomeCount);
|
|
}
|
|
local_64._size = 100;
|
|
local_64._capacity = 0;
|
|
if (outcomeCursor == outcomesCapacity) {
|
|
std::vector<8byte>::_Emplace_reallocate(outcomeCursor,&local_64._capacity);
|
|
}
|
|
else {
|
|
*GHIDRA_CAST<undefined4 *>(outcomeCursor) = 0;
|
|
*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(outcomeCursor) + 4)) = 100;
|
|
outcomesEnd = (WeightedOutcomePicker)(GHIDRA_INT(outcomeCursor) + 8);
|
|
}
|
|
LAB_0058ebbb:
|
|
(*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(local_64)) + 0x0))) = Random();
|
|
(*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(local_64)) + 0x0))) = (*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(local_64)) + 0x0))) | 1;
|
|
local_64._data = (void *)0x5;
|
|
local_64._capacity = 9;
|
|
local_64._size = 7;
|
|
rng._shift1 = 5;
|
|
rng._seed = (*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(local_64)) + 0x0)));
|
|
rng._shift2 = 9;
|
|
rng._shift3 = 7;
|
|
uVar2 = (GHIDRA_CAST<WeightedOutcomePicker *>((&picker)))->WeightedOutcomePicker::PickOutcome(rng);
|
|
if (uVar2 == 0) {
|
|
*GHIDRA_CAST<undefined2 *>((GHIDRA_INT(&local_54->_projectileCooldown) + 2)) = 0;
|
|
}
|
|
else {
|
|
charmedCount = local_3c[uVar2];
|
|
*GHIDRA_CAST<undefined2 *>(&local_54->_projectileCooldown) = 0xffff;
|
|
local_54->_state = charmedCount;
|
|
}
|
|
if (picker != (WeightedOutcomePicker)0x0) {
|
|
uVar2 = GHIDRA_INT(outcomesCapacity) - GHIDRA_INT(picker) & 0xfffffff8;
|
|
outcomesBegin = picker;
|
|
if (0xfff < uVar2) {
|
|
outcomesBegin = *GHIDRA_CAST<WeightedOutcomePicker *>((GHIDRA_CAST<char *>(picker) + -4));
|
|
uVar2 = uVar2 + 0x23;
|
|
if (0x1f < (GHIDRA_INT(picker) - GHIDRA_INT(outcomesBegin)) - 4U) {
|
|
/* WARNING: Subroutine does not return */
|
|
_invalid_parameter_noinfo_noreturn();
|
|
}
|
|
}
|
|
operator_delete((void *)outcomesBegin,uVar2);
|
|
}
|
|
ExceptionList = local_1c;
|
|
return;
|
|
}
|
|
|
|
// 00592050
|
|
void NpcHelper::siren_familiar_orbit(Entity_NPC *siren, Entity_Familiar *familiar)
|
|
{
|
|
EntityPtr EVar1;
|
|
byte isDetached;
|
|
int extraout_ECX;
|
|
int extraout_ECX_00;
|
|
int orbitSlot;
|
|
int extraout_EDX;
|
|
int extraout_EDX_00;
|
|
EntityPtr orbitCenter;
|
|
int detachedAheadCount;
|
|
float fVar2;
|
|
float fVar3;
|
|
float fVar4;
|
|
float fVar5;
|
|
float deltaY;
|
|
EntityPtr chainFamiliar;
|
|
int chainType;
|
|
|
|
EVar1 = (EntityPtr)siren->_sirenPlayerEntity;
|
|
if (EVar1 != (EntityPtr)0x0) {
|
|
orbitCenter = EVar1;
|
|
if (siren->_child != (EntityPtr)0x0) {
|
|
orbitCenter = siren->_child;
|
|
}
|
|
orbitSlot = 0;
|
|
detachedAheadCount = 0;
|
|
chainFamiliar = familiar->_parent;
|
|
if (chainFamiliar != (EntityPtr)0x0) {
|
|
chainType = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(chainFamiliar) + 0x28));
|
|
while (chainType == 3) {
|
|
isDetached = (GHIDRA_CAST<Entity_Familiar *>((GHIDRA_CAST<Entity_Familiar *>(chainFamiliar))))->Entity_Familiar::is_detached_from_follow();
|
|
if (isDetached != 0) {
|
|
detachedAheadCount = detachedAheadCount + 1;
|
|
}
|
|
chainFamiliar = *GHIDRA_CAST<EntityPtr *>((extraout_ECX + 0x3bc));
|
|
orbitSlot = extraout_EDX;
|
|
if (chainFamiliar == (EntityPtr)0x0) break;
|
|
chainType = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(chainFamiliar) + 0x28));
|
|
}
|
|
}
|
|
chainFamiliar = familiar->_child;
|
|
if (chainFamiliar != (EntityPtr)0x0) {
|
|
chainType = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(chainFamiliar) + 0x28));
|
|
while (chainType == 3) {
|
|
isDetached = (GHIDRA_CAST<Entity_Familiar *>((GHIDRA_CAST<Entity_Familiar *>(chainFamiliar))))->Entity_Familiar::is_detached_from_follow();
|
|
orbitSlot = extraout_EDX_00;
|
|
if (isDetached != 0) {
|
|
orbitSlot = extraout_EDX_00 + 1;
|
|
}
|
|
chainFamiliar = *GHIDRA_CAST<EntityPtr *>((extraout_ECX_00 + 0x3c0));
|
|
if (chainFamiliar == (EntityPtr)0x0) break;
|
|
chainType = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(chainFamiliar) + 0x28));
|
|
}
|
|
}
|
|
fVar5 = (((float)orbitSlot * 360.0) / (float)(orbitSlot + 1 + detachedAheadCount) +
|
|
*GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(EVar1) + 0x334)) * 3.5) * 0.017453292;
|
|
fVar2 = cos(fVar5);
|
|
fVar3 = (fVar2 * 90.0 + *GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(orbitCenter) + 0x33c))) - (familiar->_pos).x;
|
|
fVar2 = sin(fVar5);
|
|
deltaY = (fVar2 * 90.0 + *GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(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<float *>((GHIDRA_CAST<char *>(orbitCenter) + 0x360));
|
|
(familiar->_velocity).y = fVar2 + *GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(orbitCenter) + 0x364));
|
|
(familiar->_velocity).x = fVar3 + fVar5;
|
|
}
|
|
return;
|
|
}
|
|
|
|
// 00597d00
|
|
void NpcHelper::beast_soul_render(Entity_NPC *npc, Vector *offset)
|
|
{
|
|
Vector *point;
|
|
int iVar1;
|
|
uint dequeIndex;
|
|
uint uVar2;
|
|
float fVar3;
|
|
float fVar4;
|
|
double dVar5;
|
|
float smoothedPointX;
|
|
float fStack_5c;
|
|
undefined4 uStack_58;
|
|
float fStack_54;
|
|
float firstPointX;
|
|
float fStack_4c;
|
|
float fStack_48;
|
|
float fStack_44;
|
|
float local_40;
|
|
float local_3c;
|
|
ColorMod pointColor;
|
|
uint local_c;
|
|
undefined1 auStack_8 [4];
|
|
float *screenPointsEnd;
|
|
void *trailPointsEnd;
|
|
|
|
local_c = __security_cookie ^ GHIDRA_UINT((auStack_8 + 4));
|
|
if (8 < (npc->_vectorDeque2)._size) {
|
|
iVar1 = *GHIDRA_CAST<int *>(ThreadLocalStoragePointer);
|
|
if ((*GHIDRA_CAST<int *>((iVar1 + 0xc)) < DAT_00c7f838) && (_Init_thread_header(), DAT_00c7f838 == -1)) {
|
|
_atexit(GHIDRA_CAST<_func_4879 *>(&LAB_00b15560));
|
|
_Init_thread_footer();
|
|
}
|
|
if ((*GHIDRA_CAST<int *>((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<int *>((GHIDRA_INT((npc->_vectorDeque2)._map) +
|
|
((npc->_vectorDeque2)._mapSize - 1 & GHIDRA_INT(fStack_54) + uVar2 >> 1) * 4));
|
|
fStack_48 = *GHIDRA_CAST<float *>((iVar1 + dequeIndex * 8));
|
|
fStack_44 = *GHIDRA_CAST<float *>((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) {
|
|
std::vector<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<float *>((*GHIDRA_CAST<int *>((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<float *>(g_beastTrailPointsEnd) = firstPointX;
|
|
*GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(trailPointsEnd) + 4)) = fStack_4c;
|
|
*GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(trailPointsEnd) + 8)) = fStack_48;
|
|
*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(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 = *(undefined4 *)
|
|
(*GHIDRA_CAST<int *>((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<float *>(g_beastTrailPointsEnd) = smoothedPointX;
|
|
*GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(trailPointsEnd) + 4)) = fStack_5c;
|
|
*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(trailPointsEnd) + 8)) = uStack_58;
|
|
*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(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<float *>((GHIDRA_CAST<char *>(g_beastTrailPoints) + (iVar1 + -2) * 0x10 + 4)) -
|
|
*GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(g_beastTrailPoints) + iVar1 * 0x10 + -0xc));
|
|
fVar4 = *GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(g_beastTrailPoints) + (iVar1 + -2) * 0x10)) -
|
|
*GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(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<float *>((GHIDRA_CAST<char *>(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<undefined2 *>((GHIDRA_CAST<char *>(&(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<Vector *>((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;
|
|
}
|
|
|
|
// 00599950
|
|
int NpcHelper::tuff_twins_spawn_count(Entity_NPC *npc)
|
|
{
|
|
int *entityIt;
|
|
int count;
|
|
int remaining;
|
|
int entityType;
|
|
|
|
count = 0;
|
|
remaining = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(g_game->_room) + 0x1264));
|
|
if (remaining != 0) {
|
|
entityIt = *GHIDRA_CAST<int **>((GHIDRA_CAST<char *>(g_game->_room) + 0x125c));
|
|
do {
|
|
if (npc->_variant == 2) {
|
|
entityType = *GHIDRA_CAST<int *>((*entityIt + 0x28));
|
|
if ((entityType == 0xd) || (entityType == 0x3d)) {
|
|
LAB_00599996:
|
|
count = count + 1;
|
|
}
|
|
}
|
|
else if ((npc->_variant == 3) && (*GHIDRA_CAST<int *>((*entityIt + 0x28)) == 0x333)) goto LAB_00599996;
|
|
entityIt = entityIt + 1;
|
|
remaining = remaining + -1;
|
|
} while (remaining != 0);
|
|
}
|
|
return count;
|
|
}
|
|
|
|
// 005999b0
|
|
void NpcHelper::tuff_twins_play_anim(Entity_NPC *npc, byte *animName, int unused)
|
|
{
|
|
byte bVar1;
|
|
byte ****ppppbVar2;
|
|
uint grownCapacity;
|
|
byte ****newBuffer;
|
|
byte *pbVar3;
|
|
uint uVar4;
|
|
byte ****ptr;
|
|
byte ****fullAnim [4];
|
|
uint fullAnimSize;
|
|
uint fullAnimCapacity;
|
|
uint local_14;
|
|
void *local_10;
|
|
undefined1 *puStack_c;
|
|
byte ***local_8;
|
|
uint oldCapacity;
|
|
uint oldSize;
|
|
|
|
local_8 = GHIDRA_CAST<byte ***>(0xffffffff);
|
|
puStack_c = &LAB_00af32ed;
|
|
local_10 = ExceptionList;
|
|
local_14 = __security_cookie ^ GHIDRA_UINT((fullAnim + 10));
|
|
ExceptionList = &local_10;
|
|
fullAnimSize = 0;
|
|
fullAnimCapacity = 0xf;
|
|
fullAnim[0] = GHIDRA_CAST<byte ****>(0x0);
|
|
pbVar3 = animName;
|
|
do {
|
|
bVar1 = *pbVar3;
|
|
pbVar3 = pbVar3 + 1;
|
|
} while (bVar1 != 0);
|
|
(GHIDRA_CAST<std::string *>((GHIDRA_CAST<char *>(fullAnim))))->std::string::assign(animName,GHIDRA_INT(pbVar3) - GHIDRA_INT((animName + 1)));
|
|
oldCapacity = fullAnimCapacity;
|
|
oldSize = fullAnimSize;
|
|
local_8 = GHIDRA_CAST<byte ***>(0x0);
|
|
if (npc->_i2 != 0) {
|
|
if (fullAnimSize < fullAnimCapacity) {
|
|
ppppbVar2 = GHIDRA_CAST<byte ****>(fullAnim);
|
|
if (0xf < fullAnimCapacity) {
|
|
ppppbVar2 = fullAnim[0];
|
|
}
|
|
pbVar3 = GHIDRA_CAST<byte *>((GHIDRA_INT(ppppbVar2) + fullAnimSize));
|
|
fullAnimSize = fullAnimSize + 1;
|
|
pbVar3[0] = 0x42;
|
|
pbVar3[1] = 0;
|
|
}
|
|
else {
|
|
if (fullAnimSize == 0x7fffffff) {
|
|
/* WARNING: Subroutine does not return */
|
|
std::string::_Xlen();
|
|
}
|
|
uVar4 = fullAnimSize + 1 | 0xf;
|
|
if (uVar4 < 0x80000000) {
|
|
if (0x7fffffff - (fullAnimCapacity >> 1) < fullAnimCapacity) {
|
|
uVar4 = 0x7fffffff;
|
|
}
|
|
else {
|
|
grownCapacity = (fullAnimCapacity >> 1) + fullAnimCapacity;
|
|
if (uVar4 < grownCapacity) {
|
|
uVar4 = grownCapacity;
|
|
}
|
|
}
|
|
}
|
|
else {
|
|
uVar4 = 0x7fffffff;
|
|
}
|
|
newBuffer = std::_Allocate(uVar4 + 1);
|
|
ppppbVar2 = fullAnim[0];
|
|
fullAnimSize = oldSize + 1;
|
|
pbVar3 = GHIDRA_CAST<byte *>((GHIDRA_INT(newBuffer) + oldSize + 1));
|
|
fullAnimCapacity = uVar4;
|
|
if (oldCapacity < 0x10) {
|
|
memcpy(newBuffer,fullAnim,oldSize);
|
|
*GHIDRA_CAST<byte *>((GHIDRA_CAST<char *>(newBuffer) + oldSize)) = 0x42;
|
|
*pbVar3 = 0;
|
|
}
|
|
else {
|
|
memcpy(newBuffer,fullAnim[0],oldSize);
|
|
uVar4 = oldCapacity + 1;
|
|
*GHIDRA_CAST<byte *>((GHIDRA_CAST<char *>(newBuffer) + oldSize)) = 0x42;
|
|
*pbVar3 = 0;
|
|
ptr = ppppbVar2;
|
|
if (0xfff < uVar4) {
|
|
ptr = GHIDRA_CAST<byte ****>(ppppbVar2[-1]);
|
|
uVar4 = oldCapacity + 0x24;
|
|
if (GHIDRA_CAST<byte *>(0x1f) < GHIDRA_CAST<byte *>((GHIDRA_INT(ppppbVar2) + (-4 - GHIDRA_INT(ptr))))) goto LAB_00599b4a;
|
|
}
|
|
operator_delete(ptr,uVar4);
|
|
}
|
|
fullAnim[0] = newBuffer;
|
|
}
|
|
}
|
|
ppppbVar2 = GHIDRA_CAST<byte ****>(fullAnim);
|
|
if (0xf < fullAnimCapacity) {
|
|
ppppbVar2 = fullAnim[0];
|
|
}
|
|
(GHIDRA_CAST<ANM2 *>((&npc->_sprite)))->ANM2::Play(GHIDRA_CAST<byte *>(ppppbVar2),0);
|
|
if (0xf < fullAnimCapacity) {
|
|
oldSize = fullAnimCapacity + 1;
|
|
ppppbVar2 = fullAnim[0];
|
|
if (0xfff < oldSize) {
|
|
ppppbVar2 = GHIDRA_CAST<byte ****>(fullAnim[0][-1]);
|
|
oldSize = fullAnimCapacity + 0x24;
|
|
if (GHIDRA_CAST<byte *>(0x1f) < GHIDRA_CAST<byte *>((GHIDRA_INT(fullAnim[0]) + (-4 - GHIDRA_INT(ppppbVar2))))) {
|
|
LAB_00599b4a:
|
|
/* WARNING: Subroutine does not return */
|
|
_invalid_parameter_noinfo_noreturn();
|
|
}
|
|
}
|
|
operator_delete(ppppbVar2,oldSize);
|
|
}
|
|
ExceptionList = local_10;
|
|
return;
|
|
}
|
|
|
|
// 00599f80
|
|
void NpcHelper::tuff_twins_body_attack_anim(Entity_NPC *npc)
|
|
{
|
|
byte bVar1;
|
|
byte *****pppppbVar2;
|
|
int prefixCmp;
|
|
uint uVar3;
|
|
byte *****pppppbVar4;
|
|
int extraout_ECX;
|
|
int extraout_ECX_00;
|
|
int extraout_ECX_01;
|
|
int unused;
|
|
char *pcVar5;
|
|
byte ****attackAnimEnd;
|
|
float dy;
|
|
float dx;
|
|
double dVar6;
|
|
int savedFrame;
|
|
byte *****local_2c;
|
|
char *local_28;
|
|
char *local_24;
|
|
char *local_20;
|
|
char *local_1c;
|
|
char *local_18;
|
|
undefined4 local_14;
|
|
void *animData;
|
|
byte ****attackAnim;
|
|
|
|
local_14 = __security_cookie ^ GHIDRA_INT(register0x00000010) - 0x10U;
|
|
local_2c = GHIDRA_CAST<byte *****>(0xb624dc);
|
|
local_28 = "Body1AttackVert";
|
|
local_24 = "Body2AttackHori";
|
|
local_20 = "Body2AttackVert";
|
|
local_1c = "Body3AttackHori";
|
|
local_18 = "Body3AttackVert";
|
|
dx = *GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(npc->_parent) + 0x33c)) - (npc->_pos).x;
|
|
dy = *GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(npc->_parent) + 0x340)) - (npc->_pos).y;
|
|
if (ABS(dx) <= ABS(dy)) {
|
|
uVar3 = GHIDRA_UINT((0.0 <= dy)) * 2 + 1;
|
|
}
|
|
else {
|
|
uVar3 = 2;
|
|
if (dx < 0.0) {
|
|
uVar3 = 0;
|
|
}
|
|
}
|
|
attackAnim = GHIDRA_CAST<byte ****>((&local_2c)[(uVar3 & 1) + (GHIDRA_UINT(npc->_initSeed) % 3) * 2]);
|
|
(npc->_sprite)._flipX = uVar3 == 0;
|
|
animData = (npc->_sprite)._animState._animData;
|
|
if (animData == (void *)0x0) {
|
|
local_18 = GHIDRA_CAST<char *>(0xf);
|
|
local_2c = GHIDRA_CAST<byte *****>(0x0);
|
|
local_1c = GHIDRA_CAST<char *>(0x0);
|
|
}
|
|
else {
|
|
(GHIDRA_CAST<std::string *>((GHIDRA_CAST<char *>(&local_2c))))->std::string::string(animData);
|
|
}
|
|
pppppbVar2 = local_2c;
|
|
attackAnimEnd = attackAnim;
|
|
do {
|
|
bVar1 = *GHIDRA_CAST<byte *>(attackAnimEnd);
|
|
attackAnimEnd = GHIDRA_CAST<byte ****>((GHIDRA_INT(attackAnimEnd) + 1));
|
|
} while (bVar1 != 0);
|
|
pppppbVar4 = GHIDRA_CAST<byte *****>(&local_2c);
|
|
if (GHIDRA_CAST<char *>(0xf) < local_18) {
|
|
pppppbVar4 = local_2c;
|
|
}
|
|
bVar1 = str_eq(GHIDRA_CAST<byte *>(pppppbVar4),GHIDRA_UINT(local_1c),GHIDRA_CAST<byte *>(attackAnim),
|
|
GHIDRA_INT(attackAnimEnd) - GHIDRA_INT((GHIDRA_INT(attackAnim) + 1)));
|
|
if (GHIDRA_CAST<char *>(0xf) < local_18) {
|
|
pcVar5 = local_18 + 1;
|
|
pppppbVar4 = pppppbVar2;
|
|
if (GHIDRA_CAST<char *>(0xfff) < pcVar5) {
|
|
pppppbVar4 = GHIDRA_CAST<byte *****>(pppppbVar2[-1]);
|
|
pcVar5 = local_18 + 0x24;
|
|
if (GHIDRA_CAST<byte *>(0x1f) < GHIDRA_CAST<byte *>((GHIDRA_INT(pppppbVar2) + (-4 - GHIDRA_INT(pppppbVar4))))) {
|
|
/* WARNING: Subroutine does not return */
|
|
_invalid_parameter_noinfo_noreturn();
|
|
}
|
|
}
|
|
operator_delete(pppppbVar4,GHIDRA_UINT(pcVar5));
|
|
}
|
|
if (bVar1 == 0) {
|
|
animData = (npc->_sprite)._animState._animData;
|
|
if (animData == (void *)0x0) {
|
|
local_2c = GHIDRA_CAST<byte *****>(0x0);
|
|
local_18 = GHIDRA_CAST<char *>(0xf);
|
|
local_1c = GHIDRA_CAST<char *>(0x0);
|
|
}
|
|
else {
|
|
(GHIDRA_CAST<std::string *>((GHIDRA_CAST<char *>(&local_2c))))->std::string::string(animData);
|
|
}
|
|
pppppbVar2 = GHIDRA_CAST<byte *****>(&local_2c);
|
|
if (GHIDRA_CAST<char *>(0xf) < local_18) {
|
|
pppppbVar2 = local_2c;
|
|
}
|
|
prefixCmp = strncmp(GHIDRA_CAST<char *>(pppppbVar2),GHIDRA_CAST<char *>(attackAnim),0xb);
|
|
unused = extraout_ECX;
|
|
if (GHIDRA_CAST<char *>(0xf) < local_18) {
|
|
pcVar5 = local_18 + 1;
|
|
pppppbVar2 = local_2c;
|
|
if (GHIDRA_CAST<char *>(0xfff) < pcVar5) {
|
|
pppppbVar2 = GHIDRA_CAST<byte *****>(local_2c[-1]);
|
|
pcVar5 = local_18 + 0x24;
|
|
if (GHIDRA_CAST<byte *>(0x1f) < GHIDRA_CAST<byte *>((GHIDRA_INT(local_2c) + (-4 - GHIDRA_INT(pppppbVar2))))) {
|
|
/* WARNING: Subroutine does not return */
|
|
_invalid_parameter_noinfo_noreturn();
|
|
}
|
|
}
|
|
operator_delete(pppppbVar2,GHIDRA_UINT(pcVar5));
|
|
unused = extraout_ECX_00;
|
|
}
|
|
if (prefixCmp == 0) {
|
|
if ((npc->_sprite)._animState._animData == (void *)0x0) {
|
|
savedFrame = -1;
|
|
}
|
|
else {
|
|
dVar6 = floor((double)(npc->_sprite)._animState._animFrame);
|
|
savedFrame = GHIDRA_INT(dVar6);
|
|
unused = extraout_ECX_01;
|
|
}
|
|
tuff_twins_play_anim(npc,GHIDRA_CAST<byte *>(attackAnim),unused);
|
|
if ((npc->_sprite)._animState._animData != (void *)0x0) {
|
|
(GHIDRA_CAST<AnimationState *>((&(npc->_sprite)._animState)))->AnimationState::SetFrameFloat((float)savedFrame);
|
|
return;
|
|
}
|
|
}
|
|
else {
|
|
tuff_twins_play_anim(npc,GHIDRA_CAST<byte *>(attackAnim),unused);
|
|
}
|
|
}
|
|
return;
|
|
}
|
|
|
|
// 0059e2a0
|
|
void NpcHelper::UltraGreed_Heal(Entity_NPC *npc, int amount)
|
|
{
|
|
int healStacks;
|
|
float newHealth;
|
|
float fVar1;
|
|
undefined4 healColor;
|
|
undefined4 uStack_30;
|
|
undefined4 uStack_2c;
|
|
undefined4 uStack_28;
|
|
undefined4 local_24;
|
|
undefined4 uStack_20;
|
|
undefined4 uStack_1c;
|
|
undefined4 uStack_18;
|
|
float flashIntensity;
|
|
float local_10;
|
|
float local_c;
|
|
undefined4 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;
|
|
npc->SetColor(&healColor,healStacks,0xff,1,1);
|
|
return;
|
|
}
|
|
|
|
// 0059e630
|
|
Entity_NPC * NpcHelper::UltraDoor_Opposite(Entity_NPC *door, EntityList_EL doors)
|
|
{
|
|
uint uVar1;
|
|
Entity_NPC *oppositeDoor;
|
|
qword *heapAllocatedBytes;
|
|
int oppositeSlot;
|
|
uint entityIdx;
|
|
int oppositeSlots [9];
|
|
void *local_10;
|
|
undefined1 *puStack_c;
|
|
int local_8;
|
|
qword 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<Entity_NPC *>(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<undefined4 *>((GHIDRA_CAST<char *>(doors._data) + entityIdx * 4)),0,
|
|
&IsaacRepentancePlus::Entity::RTTI_Type_Descriptor,
|
|
&IsaacRepentancePlus::Entity_NPC::RTTI_Type_Descriptor,0,
|
|
uVar1);
|
|
if ((oppositeDoor != GHIDRA_CAST<Entity_NPC *>(0x0)) && (oppositeDoor->_i1 == oppositeSlot))
|
|
goto LAB_0059e6d2;
|
|
entityIdx = entityIdx + 1;
|
|
} while (entityIdx < GHIDRA_UINT(doors._size));
|
|
}
|
|
}
|
|
oppositeDoor = GHIDRA_CAST<Entity_NPC *>(0x0);
|
|
LAB_0059e6d2:
|
|
if ((*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(&(doors)) + 0x0))) == '\0') {
|
|
if (g_mainHeap == (void *)0x0) {
|
|
heapAllocatedBytes = &g_allocatedBytesNoHeap;
|
|
}
|
|
else {
|
|
heapAllocatedBytes = GHIDRA_CAST<qword *>((GHIDRA_INT(g_mainHeap) + 0x30));
|
|
}
|
|
if (doors._data != (void *)0x0) {
|
|
uVar1 = *GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(doors._data) + -4));
|
|
oldAllocatedBytes = *heapAllocatedBytes;
|
|
*GHIDRA_CAST<uint *>(heapAllocatedBytes) = GHIDRA_UINT(*heapAllocatedBytes) - uVar1;
|
|
*GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(heapAllocatedBytes) + 4)) =
|
|
*GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(heapAllocatedBytes) + 4)) - GHIDRA_UINT((GHIDRA_UINT(oldAllocatedBytes) < uVar1));
|
|
free((void *)(GHIDRA_INT(doors._data) + -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;
|
|
qword qVar2;
|
|
uint uVar3;
|
|
Entity_NPC *oppositeDoor;
|
|
Entity_NPC *randomDoor;
|
|
uint outcomeCount;
|
|
WeightedOutcomePicker ptr;
|
|
Game *game;
|
|
qword *allocCounter;
|
|
undefined4 uVar4;
|
|
EntityList_EL ultraDoors;
|
|
WeightedOutcomePicker picker;
|
|
undefined4 *pickerEnd;
|
|
undefined4 *pickerCapacity;
|
|
Entity_NPC *boss;
|
|
uint pickSeed;
|
|
undefined8 uStack_8c;
|
|
Entity_NPC *pEStack_84;
|
|
float local_80;
|
|
ColorMod particleColor;
|
|
ColorMod explosionColor;
|
|
uint local_24;
|
|
undefined1 *puStack_20;
|
|
void *local_1c;
|
|
undefined1 *puStack_18;
|
|
float local_14;
|
|
Manager *manager;
|
|
int *outcomeWeight;
|
|
void *room;
|
|
|
|
puStack_20 = GHIDRA_CAST<undefined1 *>((&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;
|
|
(GHIDRA_CAST<Entity_NPC *>((npc)))->Entity_NPC::CreateGoldParticles(0x1e);
|
|
manager = g_manager;
|
|
local_80 = 1.93379e-43;
|
|
seed_fart_sound_override(GHIDRA_CAST<int *>(&local_80));
|
|
(GHIDRA_CAST<SoundEffects *>((&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<int *>(&local_80));
|
|
(GHIDRA_CAST<SoundEffects *>((&manager->_sfxManager)))->SoundEffects::Play(GHIDRA_INT(local_80),1.0,2,0,(float)pEStack_84,0.0);
|
|
game = g_game;
|
|
pEStack_84 = GHIDRA_CAST<Entity_NPC *>(position.x);
|
|
room = g_game->_room;
|
|
local_80 = position.y;
|
|
*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(room) + 0x70fc)) = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(room) + 0x70fc)) + 1;
|
|
uVar3 = *GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(room) + 0x70fc)) & 0x80000001;
|
|
if (GHIDRA_INT(uVar3) < 0) {
|
|
uVar3 = (uVar3 - 1 | 0xfffffffe) + 1;
|
|
}
|
|
if (1 < uVar3) {
|
|
KAGE_LogMessage(0x10,GHIDRA_CAST<byte *>("Shockwave id is too large!"));
|
|
game = g_game;
|
|
}
|
|
randomDoor = boss;
|
|
iVar1 = uVar3 + 0x407;
|
|
*GHIDRA_CAST<Entity_NPC **>((GHIDRA_CAST<char *>(room) + iVar1 * 0x1c)) = pEStack_84;
|
|
*GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(room) + iVar1 * 0x1c + 4)) = local_80;
|
|
*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(room) + iVar1 * 0x1c + 8)) = 0;
|
|
*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(room) + iVar1 * 0x1c + 0xc)) = 0x3ccccccd;
|
|
*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(room) + iVar1 * 0x1c + 0x10)) = 0x3ccccccd;
|
|
*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(room) + iVar1 * 0x1c + 0x14)) = 0;
|
|
*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(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<Entity *>(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<EntityList *>((GHIDRA_INT(g_game->_room) + 0x1218)),&ultraDoors,0x126,-1,-1,1,0);
|
|
local_14 = 0.0;
|
|
if ((randomDoor->_state == 700) || (randomDoor->_state == 0x10)) {
|
|
picker = (WeightedOutcomePicker)0x0;
|
|
pickerEnd = GHIDRA_CAST<undefined4 *>(0x0);
|
|
pickerCapacity = GHIDRA_CAST<undefined4 *>(0x0);
|
|
local_14 = 1.4013e-45;
|
|
uStack_8c = uStack_8c & 0xffffffff;
|
|
pEStack_84 = GHIDRA_CAST<Entity_NPC *>(0x64);
|
|
std::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<int *>((GHIDRA_CAST<char *>(picker) + uVar3 * 8)) == 1) {
|
|
outcomeWeight = GHIDRA_CAST<int *>((GHIDRA_INT(picker) + 4 + uVar3 * 8));
|
|
*outcomeWeight = *outcomeWeight + 0x46;
|
|
if (*outcomeWeight < 0) {
|
|
*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(picker) + 4 + uVar3 * 8)) = 0;
|
|
}
|
|
goto LAB_0059eaaa;
|
|
}
|
|
uVar3 = uVar3 + 1;
|
|
} while (uVar3 < outcomeCount);
|
|
}
|
|
uStack_8c = CONCAT44(1,(undefined4)uStack_8c);
|
|
pEStack_84 = GHIDRA_CAST<Entity_NPC *>(0x46);
|
|
if (pickerEnd == pickerCapacity) {
|
|
std::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<Entity_NPC *>(&DAT_00000007);
|
|
rng._shift1 = 5;
|
|
rng._seed = pickSeed;
|
|
rng._shift2 = 9;
|
|
rng._shift3 = 7;
|
|
uVar3 = (GHIDRA_CAST<WeightedOutcomePicker *>((&picker)))->WeightedOutcomePicker::PickOutcome(rng);
|
|
if ((uVar3 == 0) || (boss->_state == 0x10)) {
|
|
(GHIDRA_CAST<Game *>((g_game)))->Game::ShakeScreen(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(*(undefined4 *)
|
|
(GHIDRA_INT(ultraDoors._data) +
|
|
(uVar3 % GHIDRA_UINT(ultraDoors._size)) * 4),0,
|
|
&IsaacRepentancePlus::Entity::RTTI_Type_Descriptor,
|
|
&IsaacRepentancePlus::Entity_NPC::RTTI_Type_Descriptor,0);
|
|
(*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(&(doors_00)) + 0x1))) = (int3)(GHIDRA_UINT(uVar4) >> 8);
|
|
(*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(&(doors_00)) + 0x0))) = 1;
|
|
doors_00._data = ultraDoors._data;
|
|
doors_00._capacity = ultraDoors._capacity;
|
|
doors_00._size = ultraDoors._size;
|
|
oppositeDoor = UltraDoor_Opposite(randomDoor,doors_00);
|
|
if ((randomDoor != GHIDRA_CAST<Entity_NPC *>(0x0)) && (randomDoor->_state == 3)) {
|
|
randomDoor->_state = 8;
|
|
}
|
|
if ((oppositeDoor != GHIDRA_CAST<Entity_NPC *>(0x0)) && (oppositeDoor->_state == 3)) {
|
|
oppositeDoor->_state = 9;
|
|
}
|
|
local_80 = (float)(GHIDRA_INT(local_80) + -1);
|
|
} while (local_80 != 0.0);
|
|
}
|
|
}
|
|
}
|
|
else if ((uVar3 == 1) && ((GHIDRA_CAST<Game *>((g_game)))->Game::ShakeScreen(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<undefined4 *>((GHIDRA_CAST<char *>(ultraDoors._data) + uVar3 * 4)),0,
|
|
&IsaacRepentancePlus::Entity::RTTI_Type_Descriptor,
|
|
&IsaacRepentancePlus::Entity_NPC::RTTI_Type_Descriptor,0);
|
|
(*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(&(doors)) + 0x1))) = (int3)(GHIDRA_UINT(uVar4) >> 8);
|
|
(*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(&(doors)) + 0x0))) = 1;
|
|
doors._data = ultraDoors._data;
|
|
doors._capacity = ultraDoors._capacity;
|
|
doors._size = ultraDoors._size;
|
|
oppositeDoor = UltraDoor_Opposite(randomDoor,doors);
|
|
if ((randomDoor != GHIDRA_CAST<Entity_NPC *>(0x0)) && (randomDoor->_state == 3)) {
|
|
randomDoor->_state = 8;
|
|
}
|
|
if ((oppositeDoor != GHIDRA_CAST<Entity_NPC *>(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 != (WeightedOutcomePicker)0x0) {
|
|
uVar3 = (GHIDRA_INT(pickerCapacity) - GHIDRA_INT(picker) >> 3) * 8;
|
|
ptr = picker;
|
|
if (0xfff < uVar3) {
|
|
ptr = *GHIDRA_CAST<WeightedOutcomePicker *>((GHIDRA_CAST<char *>(picker) + -4));
|
|
uVar3 = uVar3 + 0x23;
|
|
if (0x1f < (GHIDRA_INT(picker) - GHIDRA_INT(ptr)) - 4U) {
|
|
/* WARNING: Subroutine does not return */
|
|
_invalid_parameter_noinfo_noreturn();
|
|
}
|
|
}
|
|
operator_delete((void *)ptr,uVar3);
|
|
}
|
|
}
|
|
if ((boss->_state == 0x2c6) && ((GHIDRA_CAST<Game *>((g_game)))->Game::ShakeScreen(10), (float)ultraDoors._size != 0.0)) {
|
|
uVar3 = Random();
|
|
uVar4 = 0;
|
|
randomDoor = (Entity_NPC *)
|
|
__RTDynamicCast(*(undefined4 *)
|
|
(GHIDRA_INT(ultraDoors._data) + (uVar3 % GHIDRA_UINT(ultraDoors._size)) * 4),0,
|
|
&IsaacRepentancePlus::Entity::RTTI_Type_Descriptor,
|
|
&IsaacRepentancePlus::Entity_NPC::RTTI_Type_Descriptor,0);
|
|
(*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(&(doors_01)) + 0x1))) = (int3)(GHIDRA_UINT(uVar4) >> 8);
|
|
(*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(&(doors_01)) + 0x0))) = 1;
|
|
doors_01._data = ultraDoors._data;
|
|
doors_01._capacity = ultraDoors._capacity;
|
|
doors_01._size = ultraDoors._size;
|
|
pEStack_84 = randomDoor;
|
|
oppositeDoor = UltraDoor_Opposite(randomDoor,doors_01);
|
|
if (randomDoor != GHIDRA_CAST<Entity_NPC *>(0x0)) {
|
|
randomDoor->_state = 8;
|
|
randomDoor->_stateFrame = 0;
|
|
}
|
|
if (oppositeDoor != GHIDRA_CAST<Entity_NPC *>(0x0)) {
|
|
oppositeDoor->_state = 9;
|
|
oppositeDoor->_stateFrame = 0;
|
|
}
|
|
}
|
|
if ((*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(&(ultraDoors)) + 0x0))) == '\0') {
|
|
if (g_mainHeap == (void *)0x0) {
|
|
allocCounter = &g_allocatedBytesNoHeap;
|
|
}
|
|
else {
|
|
allocCounter = GHIDRA_CAST<qword *>((GHIDRA_INT(g_mainHeap) + 0x30));
|
|
}
|
|
if (ultraDoors._data != (void *)0x0) {
|
|
uVar3 = *GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(ultraDoors._data) + -4));
|
|
qVar2 = *allocCounter;
|
|
*GHIDRA_CAST<uint *>(allocCounter) = GHIDRA_UINT(*allocCounter) - uVar3;
|
|
*GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(allocCounter) + 4)) =
|
|
*GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(allocCounter) + 4)) - GHIDRA_UINT((GHIDRA_UINT(qVar2) < uVar3));
|
|
free((void *)(GHIDRA_INT(ultraDoors._data) + -4));
|
|
}
|
|
}
|
|
ExceptionList = local_1c;
|
|
return;
|
|
}
|
|
|
|
// 005a7010
|
|
void NpcHelper::visage_spawn_particles(Vector *position, Vector *direction)
|
|
{
|
|
int iVar1;
|
|
uint rngResult;
|
|
uint rngValue;
|
|
Entity *particle;
|
|
int iVar2;
|
|
int particlesLeft;
|
|
float cosQuarterTurn;
|
|
float sinQuarterTurn;
|
|
float sideDirX;
|
|
float sideDirY;
|
|
float fVar5;
|
|
undefined1 *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 = (GHIDRA_CAST<Game *>((g_game)))->Game::SpawnEx(1000,0x3b,&spawnPos,&local_18,GHIDRA_CAST<Entity *>(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<undefined1 *>(0x3f800000);
|
|
}
|
|
else {
|
|
spinSign = &DAT_bf800000;
|
|
}
|
|
*GHIDRA_CAST<undefined1 **>((particle[1]._sprite._animDefaultName._buf + 4)) = spinSign;
|
|
rngResult = Random();
|
|
(particle->_posOffset).x = 0.0;
|
|
(particle->_posOffset).y = -16.0;
|
|
iVar1 = *GHIDRA_CAST<int *>(particle);
|
|
iVar2 = rngResult % 10 + 0x1e;
|
|
*GHIDRA_CAST<int *>((particle[1]._sprite._filename._buf + 4)) = iVar2;
|
|
*GHIDRA_CAST<int *>((particle[1]._sprite._filename._buf + 8)) = iVar2;
|
|
(**(code **)(iVar1 + 0xc))();
|
|
}
|
|
return;
|
|
}
|
|
|
|
// 005a7310
|
|
void NpcHelper::visage_spawn_chain(Entity_NPC *npc)
|
|
{
|
|
uint subType;
|
|
uint seed;
|
|
EntityPtr EVar1;
|
|
EntityPtr EVar2;
|
|
EntityPtr *pEVar3;
|
|
EntityPtr *linkIter;
|
|
EntityPtr *linksEnd;
|
|
EntityPtr local_28;
|
|
EntityPtr local_24;
|
|
Vector *spawnPos;
|
|
uint linkIndex;
|
|
EntityPtr *linksCapacityEnd;
|
|
Entity_NPC *visage;
|
|
void *local_10;
|
|
undefined1 *puStack_c;
|
|
undefined4 local_8;
|
|
|
|
puStack_c = &LAB_00af597d;
|
|
local_10 = ExceptionList;
|
|
ExceptionList = &local_10;
|
|
linkIter = GHIDRA_CAST<EntityPtr *>(0x0);
|
|
linksCapacityEnd = GHIDRA_CAST<EntityPtr *>(0x0);
|
|
linksEnd = GHIDRA_CAST<EntityPtr *>(0x0);
|
|
local_8 = 0;
|
|
spawnPos = &npc->_pos;
|
|
linkIndex = 0;
|
|
visage = npc;
|
|
do {
|
|
subType = linkIndex;
|
|
seed = Random();
|
|
EVar1 = (EntityPtr)
|
|
(GHIDRA_CAST<Game *>((g_game)))->Game::Spawn(0x387,10,spawnPos,&g_vectorZero,GHIDRA_CAST<Entity *>(visage),subType,seed);
|
|
*GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(EVar1) + 0x168)) = *GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(EVar1) + 0x168)) & 0xfffffffb;
|
|
*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(EVar1) + 0x16c)) = *GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(EVar1) + 0x16c));
|
|
local_28 = EVar1;
|
|
if (*GHIDRA_CAST<EntityPtr *>((GHIDRA_CAST<char *>(EVar1) + 0x3bc)) != (EntityPtr)0x0) {
|
|
local_24 = (EntityPtr)(GHIDRA_INT(EVar1) + 0x3bc);
|
|
std::multiset<unsigned_int>::erase(&local_24);
|
|
}
|
|
*GHIDRA_CAST<EntityPtr *>((GHIDRA_CAST<char *>(EVar1) + 0x3bc)) = (EntityPtr)npc;
|
|
if ((EntityPtr)npc != (EntityPtr)0x0) {
|
|
std::multiset<unsigned_int>::insert(GHIDRA_CAST<EntityPtr *>((GHIDRA_INT(EVar1) + 0x3bc)));
|
|
}
|
|
if (*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(npc) + 0x2c)) == 10) {
|
|
EVar2 = (EntityPtr)(GHIDRA_INT(npc) + 0x3c0);
|
|
if (*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(npc) + 0x3c0)) != 0) {
|
|
local_24 = EVar2;
|
|
std::multiset<unsigned_int>::erase(&local_24);
|
|
}
|
|
*GHIDRA_CAST<EntityPtr *>(EVar2) = EVar1;
|
|
std::multiset<unsigned_int>::insert(EVar2);
|
|
}
|
|
if (linksEnd == linksCapacityEnd) {
|
|
std::vector<4byte>::_Emplace_reallocate(linksEnd,&local_28);
|
|
linksCapacityEnd = GHIDRA_CAST<EntityPtr *>(0x0);
|
|
}
|
|
else {
|
|
*linksEnd = EVar1;
|
|
linksEnd = linksEnd + 1;
|
|
}
|
|
linkIndex = linkIndex + 1;
|
|
npc = GHIDRA_CAST<Entity_NPC *>(EVar1);
|
|
} while (GHIDRA_INT(linkIndex) < 0x28);
|
|
local_24 = linksEnd[-1];
|
|
pEVar3 = &visage->_entityRef;
|
|
if (*pEVar3 != (EntityPtr)0x0) {
|
|
local_28 = (EntityPtr)pEVar3;
|
|
std::multiset<unsigned_int>::erase(&local_28);
|
|
}
|
|
*pEVar3 = local_24;
|
|
if (local_24 != (EntityPtr)0x0) {
|
|
std::multiset<unsigned_int>::insert(pEVar3);
|
|
}
|
|
EVar1 = (EntityPtr)(GHIDRA_INT(EVar1) + 0x3c0);
|
|
EVar2 = visage->_child;
|
|
if (*GHIDRA_CAST<int *>(EVar1) != 0) {
|
|
local_28 = EVar1;
|
|
std::multiset<unsigned_int>::erase(&local_28);
|
|
}
|
|
*GHIDRA_CAST<EntityPtr *>(EVar1) = EVar2;
|
|
if (EVar2 != (EntityPtr)0x0) {
|
|
std::multiset<unsigned_int>::insert(EVar1);
|
|
}
|
|
if (linksEnd != GHIDRA_CAST<EntityPtr *>(0x0)) {
|
|
do {
|
|
(**(code **)(*GHIDRA_CAST<int *>(*linkIter) + 0xc))();
|
|
linkIter = linkIter + 1;
|
|
} while (linkIter != linksEnd);
|
|
}
|
|
ExceptionList = local_10;
|
|
return;
|
|
}
|
|
|
|
// 005a7510
|
|
int NpcHelper::visage_plasma_cap()
|
|
{
|
|
int iVar1;
|
|
|
|
iVar1 = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(g_game->_room) + 4));
|
|
if ((iVar1 != 0) && (iVar1 = *GHIDRA_CAST<int *>((iVar1 + 0x10)), iVar1 != 0)) {
|
|
switch(*GHIDRA_CAST<undefined4 *>((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)
|
|
{
|
|
EntityPtr EVar1;
|
|
Entity *pEVar2;
|
|
float fVar3;
|
|
float fVar4;
|
|
float fVar5;
|
|
float fVar6;
|
|
float fVar7;
|
|
float targetDistSq;
|
|
float local_1c;
|
|
float local_18;
|
|
|
|
pEVar2 = (GHIDRA_CAST<Entity_NPC *>((npc)))->Entity_NPC::GetPlayerTarget();
|
|
EVar1 = npc->_child;
|
|
if (EVar1 == (EntityPtr)0x0) {
|
|
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<float *>((GHIDRA_CAST<char *>(EVar1) + 0x340)) - position->y;
|
|
local_18 = *GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(EVar1) + 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<float *>((GHIDRA_CAST<char *>(EVar1) + 0x340)) - position->y;
|
|
local_1c = *GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(EVar1) + 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)
|
|
{
|
|
uint 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<int *>((*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(room->_descriptor) + 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)
|
|
{
|
|
byte bVar1;
|
|
Vector *pVVar2;
|
|
byte *curAnimChar;
|
|
uint animCompare;
|
|
Entity_Laser *laser;
|
|
byte *newAnimChar;
|
|
bool isLess;
|
|
float fVar3;
|
|
int iVar4;
|
|
Entity_NPC *source;
|
|
Vector local_18;
|
|
Vector VStack_10;
|
|
byte *animData;
|
|
undefined4 flagsHigh;
|
|
Manager *manager;
|
|
|
|
if (npc->_state == 0x6d) {
|
|
flagsHigh = *GHIDRA_CAST<undefined4 *>((GHIDRA_INT(&npc->_flags) + 4));
|
|
*GHIDRA_CAST<uint *>(&npc->_flags) = GHIDRA_UINT(npc->_flags) & 0xffffffee;
|
|
iVar4 = *GHIDRA_CAST<int *>(npc);
|
|
*GHIDRA_CAST<undefined4 *>((GHIDRA_INT(&npc->_flags) + 4)) = flagsHigh;
|
|
npc->_health = npc->_maxHitPoints;
|
|
npc->_isInvicible = 0;
|
|
(**(code **)(iVar4 + 0x40))(*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(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<int *>(&VStack_10));
|
|
(GHIDRA_CAST<SoundEffects *>((&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<byte *>("Charge2Loop%s"));
|
|
animData = (npc->_sprite)._animState._animData;
|
|
if (animData != GHIDRA_CAST<byte *>(0x0)) {
|
|
curAnimChar = animData;
|
|
if (0xf < *GHIDRA_CAST<uint *>((animData + 0x14))) {
|
|
curAnimChar = *GHIDRA_CAST<byte **>(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 = (GHIDRA_CAST<ANM2 *>((&npc->_sprite)))->ANM2::SetAnimation(&DAT_00c7f858,1);
|
|
if (bVar1 != 0) {
|
|
(GHIDRA_CAST<AnimationState *>((&(npc->_sprite)._animState)))->AnimationState::Rewind();
|
|
(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<Entity *>(source),bVar1);
|
|
fVar3 = 0.0;
|
|
if (0.0 <= VStack_10.x) {
|
|
fVar3 = 1000.0;
|
|
}
|
|
laser->_renderDepthOffset = fVar3;
|
|
laser->Update();
|
|
return;
|
|
}
|
|
|
|
// 005acd30
|
|
void NpcHelper::visage_chain_solve(Entity_NPC *npc, byte isInterpolate)
|
|
{
|
|
int iVar1;
|
|
EntityPtr EVar2;
|
|
EntityPtr EVar3;
|
|
byte isFlipX;
|
|
Vector *normalized;
|
|
float *pfVar4;
|
|
EntityPtr EVar5;
|
|
EntityPtr EVar6;
|
|
float fVar7;
|
|
float angleDeg;
|
|
Vector local_2c;
|
|
float headY;
|
|
float headX;
|
|
Vector normDir;
|
|
float dirX;
|
|
float anchorY;
|
|
float anchorX;
|
|
float *headPos;
|
|
EntityPtr *parentSlot;
|
|
int *state;
|
|
|
|
EVar2 = npc->_child;
|
|
if (((EVar2 == (EntityPtr)0x0) || (*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(EVar2) + 0x28)) != 0x387)) ||
|
|
(*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(EVar2) + 0x2c)) != 10)) {
|
|
parentSlot = &npc->_parent;
|
|
EVar6 = npc->_parent;
|
|
EVar5 = (EntityPtr)npc;
|
|
while (EVar3 = EVar6, EVar3 != (EntityPtr)0x0) {
|
|
EVar5 = EVar3;
|
|
EVar6 = *GHIDRA_CAST<EntityPtr *>((GHIDRA_CAST<char *>(EVar3) + 0x3bc));
|
|
}
|
|
EVar6 = (EntityPtr)npc;
|
|
if ((*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(EVar5) + 0x28)) != 0x387) || (*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(EVar5) + 0x2c)) != 0)) {
|
|
EVar5 = (EntityPtr)0x0;
|
|
}
|
|
while (EVar3 = EVar2, EVar3 != (EntityPtr)0x0) {
|
|
EVar6 = EVar3;
|
|
EVar2 = *GHIDRA_CAST<EntityPtr *>((GHIDRA_CAST<char *>(EVar3) + 0x3c0));
|
|
}
|
|
if (((EVar6 == (EntityPtr)0x0) || (*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(EVar6) + 0x28)) != 0x387)) ||
|
|
(*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(EVar6) + 0x2c)) != 1)) {
|
|
EVar6 = (EntityPtr)0x0;
|
|
}
|
|
if (EVar5 != (EntityPtr)0x0) {
|
|
headPos = GHIDRA_CAST<float *>((GHIDRA_INT(EVar5) + 0x33c));
|
|
headX = *headPos;
|
|
state = &npc->_state;
|
|
headY = *GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(EVar5) + 0x340));
|
|
if (npc->_state == 3) {
|
|
if (EVar6 == (EntityPtr)0x0) {
|
|
return;
|
|
}
|
|
normalized = &(GHIDRA_CAST<Entity_NPC *>(EVar6))->_pos;
|
|
anchorX = normalized->x;
|
|
anchorY = ((GHIDRA_CAST<Entity_NPC *>(EVar6))->_pos).y;
|
|
if (isInterpolate != 0) {
|
|
iVar1 = GHIDRA_UINT((*GHIDRA_CAST<char *>((GHIDRA_CAST<char *>(EVar5) + 0x175)) != '\0')) * 8;
|
|
headX = *GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(EVar5) + 0x360)) * 0.5 + *GHIDRA_CAST<float *>((iVar1 + 0x33c + GHIDRA_INT(EVar5)));
|
|
headY = *GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(EVar5) + 0x364)) * 0.5 + *GHIDRA_CAST<float *>((iVar1 + 0x340 + GHIDRA_INT(EVar5)));
|
|
if ((GHIDRA_CAST<Entity_NPC *>(EVar6))->_isInterpolating != 0) {
|
|
anchorX = ((GHIDRA_CAST<Entity_NPC *>(EVar6))->_preInterpolatePos).x;
|
|
normalized = &(GHIDRA_CAST<Entity_NPC *>(EVar6))->_preInterpolatePos;
|
|
}
|
|
anchorX = ((GHIDRA_CAST<Entity_NPC *>(EVar6))->_velocity).x * 0.5 + anchorX;
|
|
anchorY = ((GHIDRA_CAST<Entity_NPC *>(EVar6))->_velocity).y * 0.5 + normalized->y;
|
|
}
|
|
local_2c.x = headX - anchorX;
|
|
local_2c.y = headY - anchorY;
|
|
normalized = (GHIDRA_CAST<Vector *>((&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 (*GHIDRA_CAST<char *>((GHIDRA_CAST<char *>(EVar5) + 0x175)) == '\0') {
|
|
pfVar4 = headPos;
|
|
}
|
|
else {
|
|
headX = *GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(EVar5) + 0x344));
|
|
pfVar4 = GHIDRA_CAST<float *>((GHIDRA_INT(EVar5) + 0x344));
|
|
}
|
|
headX = *GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(EVar5) + 0x360)) * 0.5 + headX;
|
|
headY = *GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(EVar5) + 0x364)) * 0.5 + pfVar4[1];
|
|
}
|
|
dirX = headX - anchorX;
|
|
normDir.y = headY - anchorY;
|
|
fVar7 = sqrtf(dirX * dirX + normDir.y * normDir.y);
|
|
if (0.0 < fVar7) {
|
|
normDir.y = normDir.y * (1.0 / fVar7);
|
|
dirX = dirX * (1.0 / fVar7);
|
|
}
|
|
anchorX = anchorX - dirX * 8.0;
|
|
anchorY = anchorY - normDir.y * 8.0;
|
|
}
|
|
EVar2 = *parentSlot;
|
|
while (EVar2 != (EntityPtr)0x0) {
|
|
fVar7 = sqrtf((headY - anchorY) * (headY - anchorY) + (headX - anchorX) * (headX - anchorX))
|
|
;
|
|
if (8.0 < fVar7) {
|
|
if (16.0 <= fVar7) {
|
|
local_2c.y = dirX * 16.0 + anchorX;
|
|
fVar7 = normDir.y * 16.0 + anchorY;
|
|
}
|
|
else {
|
|
local_2c.y = *headPos;
|
|
fVar7 = *GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(EVar5) + 0x340));
|
|
}
|
|
if (isInterpolate == 0) {
|
|
*GHIDRA_CAST<byte *>((GHIDRA_CAST<char *>(npc) + 0x171)) = 1;
|
|
*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(npc) + 0x188)) = 4;
|
|
}
|
|
if ((*state == 3) ||
|
|
(((EVar2 = *GHIDRA_CAST<EntityPtr *>((GHIDRA_CAST<char *>(npc) + 0x3c0)), EVar2 != (EntityPtr)0x0 &&
|
|
(*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(EVar2) + 0x28)) == 0x387)) && (*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(EVar2) + 0x2c)) == 10)))) {
|
|
(GHIDRA_CAST<Vector *>((GHIDRA_INT(npc) + 0x33c)))->x = (anchorX + local_2c.y) * 0.5;
|
|
*GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(npc) + 0x340)) = (anchorY + fVar7) * 0.5;
|
|
(GHIDRA_CAST<Vector *>((GHIDRA_INT(npc) + 0x360)))->x = g_vectorZero.x;
|
|
*GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(npc) + 0x364)) = g_vectorZero.y;
|
|
}
|
|
*GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(npc) + 0x350)) = -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;
|
|
}
|
|
*GHIDRA_CAST<byte *>((GHIDRA_CAST<char *>(npc) + 0x148)) = isFlipX;
|
|
*GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(npc) + 0xec)) = angleDeg;
|
|
anchorX = local_2c.y;
|
|
anchorY = fVar7;
|
|
}
|
|
else if (isInterpolate == 0) {
|
|
(GHIDRA_CAST<Vector *>((GHIDRA_INT(npc) + 0x33c)))->x = *headPos;
|
|
*GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(npc) + 0x340)) = *GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(EVar5) + 0x340));
|
|
*GHIDRA_CAST<byte *>((GHIDRA_CAST<char *>(npc) + 0x171)) = 0;
|
|
*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(npc) + 0x188)) = 0;
|
|
}
|
|
npc = *GHIDRA_CAST<Entity_NPC **>(parentSlot);
|
|
parentSlot = GHIDRA_CAST<EntityPtr *>((GHIDRA_INT(npc) + 0x3bc));
|
|
EVar2 = *GHIDRA_CAST<EntityPtr *>((GHIDRA_CAST<char *>(npc) + 0x3bc));
|
|
}
|
|
}
|
|
}
|
|
return;
|
|
}
|
|
|
|
// 005add40
|
|
byte NpcHelper::visage_handle_collision(Entity_NPC *npc, Entity *collider, int unused)
|
|
{
|
|
Entity *targetRef;
|
|
float newHealth;
|
|
float healCap;
|
|
int iVar2;
|
|
float local_3c;
|
|
EntityPtr *local_38;
|
|
undefined4 local_34;
|
|
undefined4 uStack_30;
|
|
undefined4 uStack_2c;
|
|
undefined4 uStack_28;
|
|
undefined4 local_24;
|
|
undefined4 uStack_20;
|
|
undefined4 uStack_1c;
|
|
undefined4 uStack_18;
|
|
undefined4 local_14;
|
|
undefined4 local_10;
|
|
undefined4 local_c;
|
|
undefined4 local_8;
|
|
EntityPtr *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;
|
|
}
|
|
(GHIDRA_CAST<Entity_NPC *>((npc)))->Entity_NPC::PlaySound(0xb9,1.0,2,0,(float)npc->_stateFrame * 0.15 + 1.0);
|
|
npc->_stateFrame = npc->_stateFrame + 1;
|
|
collider->Remove();
|
|
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;
|
|
npc->SetColor(&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 (((EntityPtr)collider == 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)) {
|
|
collider->Remove();
|
|
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;
|
|
npc->SetColor(&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 ((EntityPtr)collider == 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<int *>((collider + 1));
|
|
*GHIDRA_CAST<int *>((collider + 1)) = iVar2 + 1;
|
|
*GHIDRA_CAST<int *>(&(*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(&(collider[1])) + 0x4)))) = iVar2 + 1;
|
|
goto LAB_005adfbb;
|
|
}
|
|
if (iVar2 != 0x387) {
|
|
return 0xff;
|
|
}
|
|
if (collider->_variant != 1) {
|
|
return 0xff;
|
|
}
|
|
iVar2 = 0x8a;
|
|
}
|
|
(GHIDRA_CAST<Entity_NPC *>((npc)))->Entity_NPC::PlaySound(iVar2,1.0,2,0,1.0);
|
|
LAB_005adfbb:
|
|
targetRef = GHIDRA_CAST<Entity *>(FUN_005acc70());
|
|
if ((collider == targetRef) && (collider[2]._preInterpolatePos.x == 1.48538e-43)) {
|
|
local_3c = (collider->_pos).x - *GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(collider->_parent) + 0x33c));
|
|
local_38 = GHIDRA_CAST<EntityPtr *>(((collider->_pos).y - *GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(collider->_parent) + 0x340))));
|
|
FUN_005aafd0(&local_3c);
|
|
collider[2]._preInterpolatePos.x = 1.49939e-43;
|
|
}
|
|
if (*targetRef != (EntityPtr)0x0) {
|
|
local_38 = targetRef;
|
|
std::multiset<unsigned_int>::erase(&local_38);
|
|
}
|
|
*targetRef = (EntityPtr)collider;
|
|
std::multiset<unsigned_int>::insert(targetRef);
|
|
npc->_state = 7;
|
|
(npc->_velocity).x = g_vectorZero.x;
|
|
(npc->_velocity).y = g_vectorZero.y;
|
|
return 1;
|
|
}
|
|
|
|
// 005ae140
|
|
Entity * NpcHelper::wormwood_spawn_splash(Entity_NPC *npc)
|
|
{
|
|
uint seed;
|
|
Entity *splash;
|
|
int soundId;
|
|
Manager *manager;
|
|
|
|
seed = Random();
|
|
splash = (GHIDRA_CAST<Game *>((g_game)))->Game::Spawn(1000,0x84,&npc->_pos,&g_vectorZero,GHIDRA_CAST<Entity *>(0x0),0,seed);
|
|
splash->Update();
|
|
manager = g_manager;
|
|
soundId = 0x1da;
|
|
seed_fart_sound_override(&soundId);
|
|
(GHIDRA_CAST<SoundEffects *>((&manager->_sfxManager)))->SoundEffects::Play(soundId,1.0,10,0,1.0,0.0);
|
|
return splash;
|
|
}
|
|
|
|
// 006be7e0
|
|
byte NpcHelper::is_target_valid(Entity *target)
|
|
{
|
|
byte bVar1;
|
|
bool isTargetable;
|
|
|
|
if ((*GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(this) + 0x168)) & 0x100) == 0) {
|
|
if (target->_type != 1) {
|
|
return 0;
|
|
}
|
|
bVar1 = (GHIDRA_CAST<Entity_Player *>((GHIDRA_CAST<Entity_Player *>(target))))->Entity_Player::IsInvisible();
|
|
isTargetable = bVar1 == 0;
|
|
}
|
|
else {
|
|
bVar1 = (GHIDRA_CAST<Entity *>((target)))->Entity::IsVulnerableEnemy(GHIDRA_CAST<Entity *>(0x0));
|
|
if (bVar1 == 0) {
|
|
return 0;
|
|
}
|
|
isTargetable = (target->_flags & 0x20000000) == 0;
|
|
}
|
|
if (isTargetable) {
|
|
return 1;
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
// 006bf120
|
|
void NpcHelper::ChampionDrop(Entity_NPC *npc)
|
|
{
|
|
code *pcVar1;
|
|
byte bVar2;
|
|
float fVar3;
|
|
int iVar4;
|
|
uint uVar5;
|
|
uint uVar6;
|
|
Vector *dropDir;
|
|
Entity_Pickup *pickup;
|
|
Entity *spawned;
|
|
Entity_Player *nearestPlayer;
|
|
ProjectileParams *params;
|
|
byte isDropAllowed;
|
|
float fVar7;
|
|
int gridY;
|
|
char isDropping;
|
|
uint extraout_EDX;
|
|
RNG *dropRng;
|
|
bool isIceFrozen;
|
|
float local_138;
|
|
uint dropVariant;
|
|
Vector *local_130;
|
|
PlayerManager *local_12c;
|
|
char local_125;
|
|
int dropCount;
|
|
Entity_NPC *local_120;
|
|
Vector local_11c;
|
|
Vector local_114;
|
|
Entity_Player *glyphOwner;
|
|
Vector randomDir;
|
|
Vector zeroDir;
|
|
Vector dropVelocity;
|
|
EntityRef sourceRef;
|
|
RNG local_c8;
|
|
ProjectileParams projParams;
|
|
uint stackCookie;
|
|
undefined4 flagsHigh;
|
|
Game *game;
|
|
Room *room;
|
|
|
|
stackCookie = __security_cookie ^ GHIDRA_UINT(&local_138);
|
|
dropVariant = 0;
|
|
local_130 = GHIDRA_CAST<Vector *>(0x0);
|
|
dropCount = 1;
|
|
local_125 = (npc->_killDamageFlags & 0x200000000) != 0;
|
|
fVar3 = 1.4013e-43;
|
|
local_138 = 1.4013e-43;
|
|
if (g_game->_difficulty == 1) {
|
|
if (!(bool)local_125) {
|
|
fVar3 = 4.62428e-44;
|
|
}
|
|
local_138 = fVar3;
|
|
}
|
|
fVar3 = local_138;
|
|
local_120 = npc;
|
|
bVar2 = (GHIDRA_CAST<PlayerManager *>((&g_game->_playerManager)))->PlayerManager::AnyoneHasTrinket(5);
|
|
if (bVar2 != 0) {
|
|
iVar4 = (GHIDRA_CAST<PlayerManager *>((&g_game->_playerManager)))->PlayerManager::GetTrinketMultiplier(5);
|
|
if (iVar4 < 3) {
|
|
fVar7 = 9.24857e-44;
|
|
if (iVar4 != 2) {
|
|
fVar7 = 7.00649e-44;
|
|
}
|
|
}
|
|
else {
|
|
fVar7 = 1.05097e-43;
|
|
}
|
|
local_138 = fVar3;
|
|
if (GHIDRA_UINT(fVar3) < GHIDRA_UINT(fVar7)) {
|
|
local_138 = fVar7;
|
|
}
|
|
}
|
|
uVar5 = (npc->_dropRNG)._seed;
|
|
dropRng = &npc->_dropRNG;
|
|
local_11c.x = (float)dropRng;
|
|
if (uVar5 == 0) {
|
|
KAGE_LogMessage(0x10,GHIDRA_CAST<byte *>("RNG Seed is zero!\n"));
|
|
uVar5 = dropRng->_seed;
|
|
if (uVar5 == 0) {
|
|
pcVar1 = (code *)swi(3);
|
|
(*pcVar1)();
|
|
return;
|
|
}
|
|
}
|
|
uVar5 = uVar5 >> ((byte)(npc->_dropRNG)._shift1 & 0x1f) ^ uVar5;
|
|
uVar5 = uVar5 << ((byte)(npc->_dropRNG)._shift2 & 0x1f) ^ uVar5;
|
|
uVar5 = uVar5 >> ((byte)(npc->_dropRNG)._shift3 & 0x1f) ^ uVar5;
|
|
(npc->_dropRNG)._seed = uVar5;
|
|
if ((g_game->_difficulty == 2) || (g_game->_difficulty == 3)) {
|
|
bVar2 = 0;
|
|
}
|
|
else {
|
|
bVar2 = 1;
|
|
}
|
|
isDropAllowed = 0;
|
|
if (npc->_spawnerType != 0x132) {
|
|
isDropAllowed = bVar2;
|
|
}
|
|
local_138 = (float)GHIDRA_UINT((isDropAllowed &
|
|
(g_game->_challenge != 0x22 &&
|
|
(uVar5 % 100 < GHIDRA_UINT(local_138) && g_game->_victoryLap < 1)) &
|
|
*GHIDRA_CAST<byte *>((GHIDRA_CAST<char *>(g_game->_room) + 1))));
|
|
bVar2 = (GHIDRA_CAST<PlayerManager *>((&g_game->_playerManager)))->PlayerManager::AnyoneHasTrinket(5);
|
|
if ((bVar2 == 0) && (g_game->_stage == 0xc)) {
|
|
uVar5 = 0x14;
|
|
if (local_125 != '\0') {
|
|
uVar5 = 7;
|
|
}
|
|
uVar5 = (GHIDRA_CAST<RNG *>((&npc->_dropRNG)))->RNG::RandomInt(uVar5);
|
|
if (uVar5 != 0) {
|
|
local_138 = (float)(extraout_EDX & 0xffffff00);
|
|
}
|
|
}
|
|
isIceFrozen = (npc->_flags & 0x2000000000000) != 0;
|
|
local_12c = GHIDRA_CAST<PlayerManager *>(CONCAT31((*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(&(local_12c)) + 0x1))),isIceFrozen));
|
|
isDropping = SUB41(local_138,0);
|
|
switch(npc->_championColorIdx) {
|
|
case 0:
|
|
case 0x14:
|
|
dropVariant = 10;
|
|
case 0x10:
|
|
local_130 = GHIDRA_CAST<Vector *>(0x1);
|
|
break;
|
|
case 1:
|
|
dropVariant = 0x5a;
|
|
break;
|
|
case 2:
|
|
dropVariant = 0x46;
|
|
break;
|
|
case 3:
|
|
uVar5 = Random();
|
|
dropVariant = 0x14;
|
|
dropCount = uVar5 % 3 + 1;
|
|
break;
|
|
case 4:
|
|
if (isDropping == '\0') {
|
|
return;
|
|
}
|
|
nearestPlayer = (GHIDRA_CAST<Game *>((g_game)))->Game::GetNearestPlayer(&npc->_pos);
|
|
(GHIDRA_CAST<Entity_Player *>((nearestPlayer)))->Entity_Player::AddBlueFlies(3,&npc->_pos,GHIDRA_CAST<Entity *>(0x0));
|
|
return;
|
|
case 5:
|
|
dropVariant = 0x28;
|
|
if (((!isIceFrozen) && (bVar2 = (GHIDRA_CAST<Entity *>((GHIDRA_CAST<Entity *>(npc))))->Entity::HasEntityFlags(0x1000000), bVar2 == 0)) &&
|
|
((dropDir = &npc->_pos, 0x1e < g_game->_frameCount - npc->_spawnFrame ||
|
|
(nearestPlayer = (GHIDRA_CAST<Game *>((g_game)))->Game::GetNearestPlayer(dropDir),
|
|
fVar3 = (npc->_pos).y - (nearestPlayer->_pos).y,
|
|
fVar7 = dropDir->x - (nearestPlayer->_pos).x, 6400.0 < fVar3 * fVar3 + fVar7 * fVar7)))) {
|
|
(GHIDRA_CAST<Game *>((g_game)))->Game::BombDamage(dropDir,40.0,60.0,1,GHIDRA_CAST<Entity *>(npc),g_tearFlagsNone,4,0);
|
|
(GHIDRA_CAST<Game *>((g_game)))->Game::spawn_bomb_crater(dropDir,GHIDRA_CAST<Entity *>(0x0),1.0);
|
|
uVar5 = Random();
|
|
(GHIDRA_CAST<Game *>((g_game)))->Game::SpawnEx(1000,1,dropDir,&g_vectorZero,GHIDRA_CAST<Entity *>(0x0),0,uVar5,0);
|
|
}
|
|
break;
|
|
case 6:
|
|
dropVariant = 10;
|
|
local_130 = GHIDRA_CAST<Vector *>(0x4);
|
|
break;
|
|
case 7:
|
|
dropVariant = 0x1e;
|
|
break;
|
|
case 8:
|
|
dropVariant = 0x3c;
|
|
break;
|
|
case 9:
|
|
dropVariant = 0x168;
|
|
break;
|
|
default:
|
|
goto switchD_006bf331_caseD_a;
|
|
case 0xb:
|
|
dropVariant = 0x15e;
|
|
break;
|
|
case 0xc:
|
|
dropVariant = 10;
|
|
local_130 = GHIDRA_CAST<Vector *>(0x5);
|
|
break;
|
|
case 0xd:
|
|
dropVariant = 10;
|
|
local_130 = GHIDRA_CAST<Vector *>(0x2);
|
|
if (((!isIceFrozen) && (bVar2 = (GHIDRA_CAST<Entity *>((GHIDRA_CAST<Entity *>(npc))))->Entity::HasEntityFlags(0x1000000), bVar2 == 0)) &&
|
|
((dropDir = &npc->_pos, 0x1e < g_game->_frameCount - npc->_spawnFrame ||
|
|
(nearestPlayer = (GHIDRA_CAST<Game *>((g_game)))->Game::GetNearestPlayer(dropDir),
|
|
fVar3 = (npc->_pos).y - (nearestPlayer->_pos).y,
|
|
fVar7 = dropDir->x - (nearestPlayer->_pos).x, 6400.0 < fVar3 * fVar3 + fVar7 * fVar7)))) {
|
|
params = (GHIDRA_CAST<ProjectileParams *>((&projParams)))->ProjectileParams::ProjectileParams();
|
|
local_11c.x = 7.0;
|
|
local_11c.y = 0.0;
|
|
Entity_NPC::FireProjectiles(npc,dropDir,&local_11c,8,params);
|
|
}
|
|
break;
|
|
case 0xe:
|
|
dropVariant = 300;
|
|
fVar3 = (float)(GHIDRA_CAST<RNG *>((&npc->_dropRNG)))->RNG::Next();
|
|
iVar4 = ItemPool::GetCardEx(GHIDRA_INT(fVar3),0,1,0,1);
|
|
local_c8._shift3 = 7;
|
|
local_c8._shift1 = 5;
|
|
local_c8._shift2 = 9;
|
|
local_c8._seed = GHIDRA_INT(fVar3);
|
|
local_130 = GHIDRA_CAST<Vector *>(lua_callback_run_get_card(&local_c8,iVar4,0,1,1));
|
|
break;
|
|
case 0xf:
|
|
if (!isIceFrozen) {
|
|
local_120 = GHIDRA_CAST<Entity_NPC *>(0x2);
|
|
do {
|
|
uVar5 = (npc->_dropRNG)._seed;
|
|
if (uVar5 == 0) {
|
|
KAGE_LogMessage(0x10,GHIDRA_CAST<byte *>("RNG Seed is zero!\n"));
|
|
uVar5 = (npc->_dropRNG)._seed;
|
|
if (uVar5 == 0) {
|
|
pcVar1 = (code *)swi(3);
|
|
(*pcVar1)();
|
|
return;
|
|
}
|
|
}
|
|
uVar5 = uVar5 >> ((byte)(npc->_dropRNG)._shift1 & 0x1f) ^ uVar5;
|
|
uVar5 = uVar5 << ((byte)(npc->_dropRNG)._shift2 & 0x1f) ^ uVar5;
|
|
uVar5 = uVar5 >> ((byte)(npc->_dropRNG)._shift3 & 0x1f) ^ uVar5;
|
|
(npc->_dropRNG)._seed = uVar5;
|
|
uVar6 = Random();
|
|
fVar3 = (float)((double)GHIDRA_INT(uVar6) + __uint_to_double_fixup[-(GHIDRA_INT(uVar6) >> 0x1f)]) *
|
|
2.3283064e-10 * 3.14;
|
|
local_12c = GHIDRA_CAST<PlayerManager *>((fVar3 + fVar3));
|
|
fVar3 = cos((float)local_12c);
|
|
local_11c.x = fVar3 * 14.0 + (npc->_pos).x;
|
|
fVar3 = sin((float)local_12c);
|
|
local_11c.y = fVar3 * 14.0 + (npc->_pos).y;
|
|
(GHIDRA_CAST<Game *>((g_game)))->Game::SpawnEx(npc->_type,npc->_variant,&local_11c,&g_vectorZero,GHIDRA_CAST<Entity *>(npc),0,uVar5
|
|
,0);
|
|
local_120 = GHIDRA_CAST<Entity_NPC *>((GHIDRA_INT(local_120) + -1));
|
|
} while (local_120 != GHIDRA_CAST<Entity_NPC *>(0x0));
|
|
}
|
|
break;
|
|
case 0x11:
|
|
if (!isIceFrozen) {
|
|
uVar5 = Random();
|
|
spawned = (GHIDRA_CAST<Game *>((g_game)))->Game::SpawnEx(0x12,0,&npc->_pos,&g_vectorZero,GHIDRA_CAST<Entity *>(npc),0,uVar5,0);
|
|
bVar2 = (GHIDRA_CAST<Entity *>((GHIDRA_CAST<Entity *>(npc))))->Entity::HasEntityFlags(0x1000000);
|
|
if (bVar2 != 0) {
|
|
*GHIDRA_CAST<uint *>(&spawned->_flags) = GHIDRA_UINT(spawned->_flags) & 0xfeffffff;
|
|
*GHIDRA_CAST<undefined4 *>((GHIDRA_INT(&spawned->_flags) + 4)) = *GHIDRA_CAST<undefined4 *>((GHIDRA_INT(&spawned->_flags) + 4));
|
|
sourceRef._type = npc->_type;
|
|
sourceRef._position.x = (npc->_pos).x;
|
|
sourceRef._position.y = (npc->_pos).y;
|
|
sourceRef._variant = npc->_variant;
|
|
sourceRef._spawnerType = npc->_spawnerType;
|
|
sourceRef._spawnerVariant = npc->_spawnerVariant;
|
|
sourceRef._velocity.x = (npc->_velocity).x;
|
|
sourceRef._velocity.y = (npc->_velocity).y;
|
|
local_120 = GHIDRA_CAST<Entity_NPC *>(GHIDRA_UINT(((npc->_flags & 0x100) != 0)));
|
|
if ((npc->_flags & 0x20000000) == 0) {
|
|
uVar5 = 0;
|
|
}
|
|
else {
|
|
uVar5 = 2;
|
|
}
|
|
if ((npc->_flags & 0x40000000000000) == 0) {
|
|
uVar6 = 0;
|
|
}
|
|
else {
|
|
uVar6 = 4;
|
|
}
|
|
sourceRef._flags = uVar6 | uVar5 | GHIDRA_UINT(local_120);
|
|
sourceRef._entity = npc;
|
|
(GHIDRA_CAST<Entity *>((spawned)))->Entity::AddShrink(&sourceRef,0x96,0,0);
|
|
if (0 < spawned->_shrinkCountdown) {
|
|
flagsHigh = *GHIDRA_CAST<undefined4 *>((GHIDRA_INT(&spawned->_flags) + 4));
|
|
*GHIDRA_CAST<uint *>(&spawned->_flags) = GHIDRA_UINT(spawned->_flags) | 0x1000000;
|
|
*GHIDRA_CAST<undefined4 *>((GHIDRA_INT(&spawned->_flags) + 4)) = flagsHigh;
|
|
spawned->_shrinkStatus1 = spawned->_shrinkStatus2;
|
|
}
|
|
}
|
|
}
|
|
break;
|
|
case 0x12:
|
|
dropRng = &npc->_dropRNG;
|
|
uVar5 = (GHIDRA_CAST<RNG *>((dropRng)))->RNG::RandomInt(5);
|
|
if (uVar5 != 0) {
|
|
return;
|
|
}
|
|
if ((*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(&(local_138)) + 0x0))) == '\0') {
|
|
return;
|
|
}
|
|
bVar2 = (GHIDRA_CAST<PlayerManager *>((&g_game->_playerManager)))->PlayerManager::AnyoneHasTrinket(5);
|
|
local_138 = 0.0;
|
|
dropCount = 1;
|
|
if (bVar2 != 0) {
|
|
dropCount = 2;
|
|
}
|
|
local_130 = &npc->_pos;
|
|
do {
|
|
uVar5 = dropRng->_seed;
|
|
if (uVar5 == 0) {
|
|
KAGE_LogMessage(0x10,GHIDRA_CAST<byte *>("RNG Seed is zero!\n"));
|
|
uVar5 = (npc->_dropRNG)._seed;
|
|
if (uVar5 == 0) {
|
|
pcVar1 = (code *)swi(3);
|
|
(*pcVar1)();
|
|
return;
|
|
}
|
|
}
|
|
game = g_game;
|
|
uVar5 = uVar5 >> ((byte)(npc->_dropRNG)._shift1 & 0x1f) ^ uVar5;
|
|
uVar5 = uVar5 << ((byte)(npc->_dropRNG)._shift2 & 0x1f) ^ uVar5;
|
|
uVar5 = uVar5 >> ((byte)(local_120->_dropRNG)._shift3 & 0x1f) ^ uVar5;
|
|
dropRng->_seed = uVar5;
|
|
uVar6 = (GHIDRA_CAST<ItemPool *>((&game->_itemPool)))->ItemPool::ForceAddPillEffect(0x21);
|
|
dropDir = Room::FindFreePickupSpawnPosition
|
|
(g_game->_room,GHIDRA_CAST<Vector *>(&local_c8),local_130,0.0,0,0,0);
|
|
npc = local_120;
|
|
local_11c.y = (float)((double)GHIDRA_INT(local_138) +
|
|
__uint_to_double_fixup[-(GHIDRA_INT(local_138) >> 0x1f)]) + dropDir->y;
|
|
local_11c.x = (float)((double)GHIDRA_INT(local_138) +
|
|
__uint_to_double_fixup[-(GHIDRA_INT(local_138) >> 0x1f)]) + dropDir->x;
|
|
(GHIDRA_CAST<Game *>((g_game)))->Game::SpawnEx(5,0x46,&local_11c,&g_vectorZero,GHIDRA_CAST<Entity *>(local_120),uVar6,uVar5,0);
|
|
dropRng = &npc->_dropRNG;
|
|
local_138 = (float)(GHIDRA_INT(local_138) + 1);
|
|
} while (GHIDRA_UINT(local_138) < GHIDRA_UINT(dropCount));
|
|
return;
|
|
case 0x13:
|
|
dropRng = &npc->_dropRNG;
|
|
uVar5 = (GHIDRA_CAST<RNG *>((dropRng)))->RNG::RandomInt(5);
|
|
if (uVar5 != 0) {
|
|
return;
|
|
}
|
|
if ((*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(&(local_138)) + 0x0))) == '\0') {
|
|
return;
|
|
}
|
|
bVar2 = (GHIDRA_CAST<PlayerManager *>((&g_game->_playerManager)))->PlayerManager::AnyoneHasTrinket(5);
|
|
local_138 = 0.0;
|
|
dropCount = 1;
|
|
if (bVar2 != 0) {
|
|
dropCount = 2;
|
|
}
|
|
local_130 = &npc->_pos;
|
|
do {
|
|
uVar5 = dropRng->_seed;
|
|
if (uVar5 == 0) {
|
|
KAGE_LogMessage(0x10,GHIDRA_CAST<byte *>("RNG Seed is zero!\n"));
|
|
uVar5 = (npc->_dropRNG)._seed;
|
|
if (uVar5 == 0) {
|
|
pcVar1 = (code *)swi(3);
|
|
(*pcVar1)();
|
|
return;
|
|
}
|
|
}
|
|
game = g_game;
|
|
uVar5 = uVar5 >> ((byte)(npc->_dropRNG)._shift1 & 0x1f) ^ uVar5;
|
|
uVar5 = uVar5 << ((byte)(npc->_dropRNG)._shift2 & 0x1f) ^ uVar5;
|
|
uVar5 = uVar5 >> ((byte)(local_120->_dropRNG)._shift3 & 0x1f) ^ uVar5;
|
|
dropRng->_seed = uVar5;
|
|
uVar6 = (GHIDRA_CAST<ItemPool *>((&game->_itemPool)))->ItemPool::ForceAddPillEffect(0x20);
|
|
dropDir = Room::FindFreePickupSpawnPosition
|
|
(g_game->_room,GHIDRA_CAST<Vector *>(&local_c8),local_130,0.0,0,0,0);
|
|
npc = local_120;
|
|
local_11c.y = (float)((double)GHIDRA_INT(local_138) +
|
|
__uint_to_double_fixup[-(GHIDRA_INT(local_138) >> 0x1f)]) + dropDir->y;
|
|
local_11c.x = (float)((double)GHIDRA_INT(local_138) +
|
|
__uint_to_double_fixup[-(GHIDRA_INT(local_138) >> 0x1f)]) + dropDir->x;
|
|
(GHIDRA_CAST<Game *>((g_game)))->Game::SpawnEx(5,0x46,&local_11c,&g_vectorZero,GHIDRA_CAST<Entity *>(local_120),uVar6,uVar5,0);
|
|
dropRng = &npc->_dropRNG;
|
|
local_138 = (float)(GHIDRA_INT(local_138) + 1);
|
|
} while (GHIDRA_UINT(local_138) < GHIDRA_UINT(dropCount));
|
|
return;
|
|
case 0x15:
|
|
if (isDropping == '\0') {
|
|
return;
|
|
}
|
|
nearestPlayer = (GHIDRA_CAST<Game *>((g_game)))->Game::GetNearestPlayer(&npc->_pos);
|
|
uVar5 = (GHIDRA_CAST<RNG *>((GHIDRA_CAST<RNG *>(local_11c.x))))->RNG::RandomInt(3);
|
|
(GHIDRA_CAST<Entity_Player *>((nearestPlayer)))->Entity_Player::AddBlueFlies(uVar5 + 4,&npc->_pos,GHIDRA_CAST<Entity *>(0x0));
|
|
return;
|
|
case 0x16:
|
|
if (isDropping == '\0') {
|
|
return;
|
|
}
|
|
uVar5 = (GHIDRA_CAST<RNG *>((&npc->_dropRNG)))->RNG::RandomInt(2);
|
|
local_138 = (float)(uVar5 + 2);
|
|
bVar2 = (GHIDRA_CAST<PlayerManager *>((&g_game->_playerManager)))->PlayerManager::AnyoneHasTrinket(5);
|
|
if (bVar2 != 0) {
|
|
local_138 = (float)(GHIDRA_INT(local_138) * 2);
|
|
}
|
|
if (GHIDRA_INT(local_138) < 1) {
|
|
return;
|
|
}
|
|
do {
|
|
uVar5 = (npc->_dropRNG)._seed;
|
|
if (uVar5 == 0) {
|
|
KAGE_LogMessage(0x10,GHIDRA_CAST<byte *>("RNG Seed is zero!\n"));
|
|
uVar5 = (npc->_dropRNG)._seed;
|
|
if (uVar5 == 0) {
|
|
pcVar1 = (code *)swi(3);
|
|
(*pcVar1)();
|
|
return;
|
|
}
|
|
}
|
|
game = g_game;
|
|
uVar5 = uVar5 >> ((byte)(npc->_dropRNG)._shift1 & 0x1f) ^ uVar5;
|
|
uVar5 = uVar5 << ((byte)(npc->_dropRNG)._shift2 & 0x1f) ^ uVar5;
|
|
uVar5 = uVar5 >> ((byte)(npc->_dropRNG)._shift3 & 0x1f) ^ uVar5;
|
|
(npc->_dropRNG)._seed = uVar5;
|
|
dropDir = Room::FindFreePickupSpawnPosition
|
|
(game->_room,GHIDRA_CAST<Vector *>(&local_c8),&npc->_pos,0.0,0,0,0);
|
|
(GHIDRA_CAST<Game *>((g_game)))->Game::SpawnEx(5,0,dropDir,&g_vectorZero,GHIDRA_CAST<Entity *>(npc),4,uVar5,0);
|
|
local_138 = (float)(GHIDRA_INT(local_138) + -1);
|
|
} while (local_138 != 0.0);
|
|
return;
|
|
case 0x17:
|
|
nearestPlayer = Game::GetNearestPlayerEx(&npc->_pos,1,0,1);
|
|
if (nearestPlayer == GHIDRA_CAST<Entity_Player *>(0x0)) {
|
|
nearestPlayer = (GHIDRA_CAST<Game *>((g_game)))->Game::GetPlayer(0);
|
|
}
|
|
Entity_Player::UseActiveItem(nearestPlayer,GHIDRA_CAST<short *>(&local_12c),0x23,1,-1,0);
|
|
(GHIDRA_CAST<ItemOverlay *>((&g_game->_itemOverlay)))->ItemOverlay::Show(0xc,3,GHIDRA_CAST<Entity_Player *>(0x0));
|
|
return;
|
|
case 0x19:
|
|
local_130 = GHIDRA_CAST<Vector *>(0x0);
|
|
dropRng = &npc->_dropRNG;
|
|
do {
|
|
if (SUB41(local_138,0) == '\0') {
|
|
uVar5 = dropRng->_seed;
|
|
if (uVar5 == 0) {
|
|
KAGE_LogMessage(0x10,GHIDRA_CAST<byte *>("RNG Seed is zero!\n"));
|
|
uVar5 = (npc->_dropRNG)._seed;
|
|
if (uVar5 == 0) {
|
|
pcVar1 = (code *)swi(3);
|
|
(*pcVar1)();
|
|
return;
|
|
}
|
|
}
|
|
uVar5 = uVar5 >> ((byte)(npc->_dropRNG)._shift1 & 0x1f) ^ uVar5;
|
|
uVar5 = uVar5 << ((byte)(npc->_dropRNG)._shift2 & 0x1f) ^ uVar5;
|
|
uVar5 = uVar5 >> ((byte)(npc->_dropRNG)._shift3 & 0x1f) ^ uVar5;
|
|
dropRng->_seed = uVar5;
|
|
if ((uVar5 & 1) == 0) goto LAB_006c0128;
|
|
}
|
|
else {
|
|
LAB_006c0128:
|
|
Room::FindFreePickupSpawnPosition(g_game->_room,&local_11c,&npc->_pos,40.0,0,0,0);
|
|
uVar5 = dropRng->_seed;
|
|
if (uVar5 == 0) {
|
|
KAGE_LogMessage(0x10,GHIDRA_CAST<byte *>("RNG Seed is zero!\n"));
|
|
uVar5 = (npc->_dropRNG)._seed;
|
|
if (uVar5 == 0) {
|
|
pcVar1 = (code *)swi(3);
|
|
(*pcVar1)();
|
|
return;
|
|
}
|
|
}
|
|
game = g_game;
|
|
uVar5 = uVar5 >> ((byte)(npc->_dropRNG)._shift1 & 0x1f) ^ uVar5;
|
|
uVar5 = uVar5 << ((byte)(npc->_dropRNG)._shift2 & 0x1f) ^ uVar5;
|
|
uVar5 = uVar5 >> ((byte)(npc->_dropRNG)._shift3 & 0x1f) ^ uVar5;
|
|
dropRng->_seed = uVar5;
|
|
spawned = (GHIDRA_CAST<Game *>((game)))->Game::SpawnEx(5,*GHIDRA_CAST<uint *>((&DAT_00b67400 + GHIDRA_INT(local_130) * 4)),&local_11c,
|
|
&g_vectorZero,GHIDRA_CAST<Entity *>(npc),0,uVar5,0);
|
|
spawned[1]._sprite._championColor._offset[2] = (float)local_130;
|
|
bVar2 = (GHIDRA_CAST<PlayerManager *>((&g_game->_playerManager)))->PlayerManager::AnyoneHasTrinket(5);
|
|
if (bVar2 != 0) {
|
|
dropDir = Room::FindFreePickupSpawnPosition
|
|
(g_game->_room,GHIDRA_CAST<Vector *>(&local_c8),&npc->_pos,40.0,0,0,0);
|
|
uVar5 = dropRng->_seed;
|
|
local_11c.x = dropDir->x;
|
|
local_11c.y = dropDir->y;
|
|
if (uVar5 == 0) {
|
|
KAGE_LogMessage(0x10,GHIDRA_CAST<byte *>("RNG Seed is zero!\n"));
|
|
uVar5 = (npc->_dropRNG)._seed;
|
|
if (uVar5 == 0) {
|
|
pcVar1 = (code *)swi(3);
|
|
(*pcVar1)();
|
|
return;
|
|
}
|
|
}
|
|
game = g_game;
|
|
uVar5 = uVar5 >> ((byte)(npc->_dropRNG)._shift1 & 0x1f) ^ uVar5;
|
|
uVar5 = uVar5 << ((byte)(npc->_dropRNG)._shift2 & 0x1f) ^ uVar5;
|
|
uVar5 = uVar5 >> ((byte)(npc->_dropRNG)._shift3 & 0x1f) ^ uVar5;
|
|
dropRng->_seed = uVar5;
|
|
spawned = (GHIDRA_CAST<Game *>((game)))->Game::SpawnEx(5,*GHIDRA_CAST<uint *>((&DAT_00b67400 + GHIDRA_INT(local_130) * 4)),&local_11c,
|
|
&g_vectorZero,GHIDRA_CAST<Entity *>(npc),0,uVar5,0);
|
|
spawned[1]._sprite._championColor._offset[2] = (float)local_130;
|
|
}
|
|
}
|
|
local_130 = GHIDRA_CAST<Vector *>((GHIDRA_INT(&local_130->x) + 1));
|
|
} while (local_130 < GHIDRA_CAST<Vector *>(0x7));
|
|
if ((char)local_12c == '\0') {
|
|
bVar2 = (GHIDRA_CAST<Entity *>((GHIDRA_CAST<Entity *>(npc))))->Entity::HasEntityFlags(0x1000000);
|
|
if ((bVar2 == 0) &&
|
|
((dropDir = &npc->_pos, 0x1e < g_game->_frameCount - npc->_spawnFrame ||
|
|
(nearestPlayer = (GHIDRA_CAST<Game *>((g_game)))->Game::GetNearestPlayer(dropDir),
|
|
fVar3 = (npc->_pos).y - (nearestPlayer->_pos).y,
|
|
fVar7 = dropDir->x - (nearestPlayer->_pos).x, 6400.0 < fVar3 * fVar3 + fVar7 * fVar7)))) {
|
|
(GHIDRA_CAST<Game *>((g_game)))->Game::BombDamage(dropDir,40.0,60.0,1,GHIDRA_CAST<Entity *>(npc),g_tearFlagsNone,4,0);
|
|
(GHIDRA_CAST<Game *>((g_game)))->Game::spawn_bomb_crater(dropDir,GHIDRA_CAST<Entity *>(0x0),1.0);
|
|
uVar5 = Random();
|
|
(GHIDRA_CAST<Game *>((g_game)))->Game::SpawnEx(1000,1,dropDir,&g_vectorZero,GHIDRA_CAST<Entity *>(0x0),0,uVar5,0);
|
|
}
|
|
bVar2 = (GHIDRA_CAST<Entity *>((GHIDRA_CAST<Entity *>(npc))))->Entity::HasEntityFlags(0x1000000);
|
|
if ((bVar2 == 0) &&
|
|
((dropDir = &npc->_pos, 0x1e < g_game->_frameCount - npc->_spawnFrame ||
|
|
(nearestPlayer = (GHIDRA_CAST<Game *>((g_game)))->Game::GetNearestPlayer(dropDir),
|
|
fVar3 = (npc->_pos).y - (nearestPlayer->_pos).y,
|
|
fVar7 = dropDir->x - (nearestPlayer->_pos).x, 6400.0 < fVar3 * fVar3 + fVar7 * fVar7)))) {
|
|
params = (GHIDRA_CAST<ProjectileParams *>((&projParams)))->ProjectileParams::ProjectileParams();
|
|
local_c8._seed = 0x40e00000;
|
|
(*GHIDRA_CAST<undefined8 *>((GHIDRA_CAST<char *>(&(local_c8)) + 0x4))) = (ulonglong)GHIDRA_UINT(local_c8._shift2) << 0x20;
|
|
Entity_NPC::FireProjectiles(npc,dropDir,GHIDRA_CAST<Vector *>(&local_c8),8,params);
|
|
}
|
|
}
|
|
goto switchD_006bf331_caseD_a;
|
|
}
|
|
if ((*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(&(local_138)) + 0x0))) != '\0') {
|
|
local_120 = GHIDRA_CAST<Entity_NPC *>((npc->_pos).x);
|
|
local_138 = (npc->_pos).y;
|
|
room = g_game->_room;
|
|
iVar4 = GHIDRA_INT((((npc->_pos).x - 40.0) / 40.0 + 0.5));
|
|
gridY = GHIDRA_INT(((local_138 - 120.0) / 40.0 + 0.5));
|
|
if ((((iVar4 < 0) || (room->_gridWidth <= iVar4)) || (gridY < 0)) ||
|
|
(room->_gridHeight <= gridY)) {
|
|
iVar4 = -1;
|
|
}
|
|
else {
|
|
iVar4 = room->_gridWidth * gridY + iVar4;
|
|
}
|
|
local_114.x = (float)local_120;
|
|
local_114.y = local_138;
|
|
uVar5 = (GHIDRA_CAST<Room *>((room)))->Room::GetGridCollision(iVar4);
|
|
if (0 < GHIDRA_INT(uVar5)) {
|
|
dropDir = (GHIDRA_CAST<Room *>((room)))->Room::FindFreeTilePosition(GHIDRA_CAST<Vector *>(&local_c8),&local_114,40.0);
|
|
local_120 = GHIDRA_CAST<Entity_NPC *>(dropDir->x);
|
|
local_138 = dropDir->y;
|
|
}
|
|
dropRng = &npc->_dropRNG;
|
|
uVar5 = dropRng->_seed;
|
|
local_12c = &g_game->_playerManager;
|
|
if (uVar5 == 0) {
|
|
KAGE_LogMessage(0x10,GHIDRA_CAST<byte *>("RNG Seed is zero!\n"));
|
|
uVar5 = dropRng->_seed;
|
|
if (uVar5 == 0) {
|
|
pcVar1 = (code *)swi(3);
|
|
(*pcVar1)();
|
|
return;
|
|
}
|
|
}
|
|
uVar5 = uVar5 >> ((byte)(npc->_dropRNG)._shift1 & 0x1f) ^ uVar5;
|
|
uVar5 = uVar5 << ((byte)(npc->_dropRNG)._shift2 & 0x1f) ^ uVar5;
|
|
uVar5 = uVar5 >> ((byte)(npc->_dropRNG)._shift3 & 0x1f) ^ uVar5;
|
|
dropRng->_seed = uVar5;
|
|
glyphOwner = (GHIDRA_CAST<PlayerManager *>((local_12c)))->PlayerManager::RandomCollectibleOwner(0x1d0,uVar5,GHIDRA_CAST<RNG **>(0x0));
|
|
if ((dropCount != 0) && (local_125 != '\0')) {
|
|
uVar5 = dropRng->_seed;
|
|
if (uVar5 == 0) {
|
|
KAGE_LogMessage(0x10,GHIDRA_CAST<byte *>("RNG Seed is zero!\n"));
|
|
uVar5 = dropRng->_seed;
|
|
if (uVar5 == 0) {
|
|
pcVar1 = (code *)swi(3);
|
|
(*pcVar1)();
|
|
return;
|
|
}
|
|
}
|
|
uVar5 = uVar5 >> ((byte)(npc->_dropRNG)._shift1 & 0x1f) ^ uVar5;
|
|
uVar5 = uVar5 << ((byte)(npc->_dropRNG)._shift2 & 0x1f) ^ uVar5;
|
|
uVar5 = uVar5 >> ((byte)(npc->_dropRNG)._shift3 & 0x1f) ^ uVar5;
|
|
dropRng->_seed = uVar5;
|
|
if ((uVar5 & 1) == 0) {
|
|
dropCount = dropCount + 1;
|
|
}
|
|
}
|
|
bVar2 = (GHIDRA_CAST<PlayerManager *>((&g_game->_playerManager)))->PlayerManager::AnyoneHasTrinket(5);
|
|
if ((bVar2 != 0) && (npc->_isChampion != 0)) {
|
|
dropCount = dropCount * 2;
|
|
}
|
|
if (dropCount != 0) {
|
|
uVar5 = dropVariant;
|
|
local_12c = GHIDRA_CAST<PlayerManager *>(dropCount);
|
|
do {
|
|
if (glyphOwner != GHIDRA_CAST<Entity_Player *>(0x0)) {
|
|
(GHIDRA_CAST<Entity_Player *>((glyphOwner)))->Entity_Player::GetGlyphOfBalanceDrop(GHIDRA_CAST<int *>(&dropVariant),GHIDRA_CAST<int *>(&local_130));
|
|
uVar5 = dropVariant;
|
|
}
|
|
if (uVar5 != 0) {
|
|
if (GHIDRA_UINT(dropCount) < 2) {
|
|
zeroDir.x = g_vectorZero.x;
|
|
dropDir = &zeroDir;
|
|
zeroDir.y = g_vectorZero.y;
|
|
}
|
|
else {
|
|
uVar5 = Random();
|
|
local_114.x = (float)((double)GHIDRA_INT(uVar5) + __uint_to_double_fixup[-(GHIDRA_INT(uVar5) >> 0x1f)]
|
|
) * 2.3283064e-10 * 3.14;
|
|
local_114.x = local_114.x + local_114.x;
|
|
randomDir.x = cos(local_114.x);
|
|
randomDir.y = sin(local_114.x);
|
|
dropDir = &randomDir;
|
|
}
|
|
local_114.x = dropDir->x;
|
|
local_11c.x = dropDir->y;
|
|
uVar5 = dropRng->_seed;
|
|
dropVelocity.x = local_114.x;
|
|
dropVelocity.y = local_11c.x;
|
|
if (uVar5 == 0) {
|
|
KAGE_LogMessage(0x10,GHIDRA_CAST<byte *>("RNG Seed is zero!\n"));
|
|
uVar5 = (npc->_dropRNG)._seed;
|
|
if (uVar5 == 0) {
|
|
pcVar1 = (code *)swi(3);
|
|
(*pcVar1)();
|
|
return;
|
|
}
|
|
}
|
|
game = g_game;
|
|
uVar5 = uVar5 >> ((byte)(npc->_dropRNG)._shift1 & 0x1f) ^ uVar5;
|
|
uVar5 = uVar5 << ((byte)(npc->_dropRNG)._shift2 & 0x1f) ^ uVar5;
|
|
local_c8._seed = GHIDRA_INT((local_114.x * 3.0 + (float)local_120));
|
|
uVar5 = uVar5 >> ((byte)(npc->_dropRNG)._shift3 & 0x1f) ^ uVar5;
|
|
dropRng->_seed = uVar5;
|
|
local_c8._shift1 = GHIDRA_INT((local_11c.x * 3.0 + local_138));
|
|
pickup = (Entity_Pickup *)
|
|
(GHIDRA_CAST<Game *>((game)))->Game::SpawnEx(5,dropVariant,GHIDRA_CAST<Vector *>(&local_c8),&dropVelocity,GHIDRA_CAST<Entity *>(npc),
|
|
GHIDRA_UINT(local_130),uVar5,0);
|
|
if ((pickup->_variant == 0x15e) &&
|
|
((((g_manager->_persistentGameData)._achievements[0x269] != 0 ||
|
|
(((g_manager->_state == 2 && (g_game != GHIDRA_CAST<Game *>(0x0))) &&
|
|
(((g_game->_dailyChallenge)._id != 0 || (g_game->_isDebug != 0)))))) &&
|
|
(((npc->_flags & 0x400) != 0 && ((pickup->_subtype & 0x8000U) == 0)))))) {
|
|
Entity_Pickup::Morph(pickup,pickup->_type,0x15e,pickup->_subtype | 0x8000,1,1,1);
|
|
}
|
|
uVar5 = dropVariant;
|
|
}
|
|
local_12c = GHIDRA_CAST<PlayerManager *>((GHIDRA_INT(&local_12c[-1]._extraPlayers._capacity) + 3));
|
|
} while (local_12c != GHIDRA_CAST<PlayerManager *>(0x0));
|
|
return;
|
|
}
|
|
}
|
|
switchD_006bf331_caseD_a:
|
|
return;
|
|
}
|
|
|
|
// 006d0ec0
|
|
void NpcHelper::fireplace_moveable_update(Entity_NPC *npc)
|
|
{
|
|
byte bVar1;
|
|
EntityRef *damageSource;
|
|
byte *curAnimName;
|
|
uint uVar2;
|
|
LayerState *layer;
|
|
int iVar3;
|
|
byte *wantedAnimName;
|
|
char *wantedAnimNameStr;
|
|
float *damageEvent;
|
|
bool isLess;
|
|
float fVar4;
|
|
float fVar5;
|
|
EntityRef damageSourceRef;
|
|
float local_10;
|
|
float local_c;
|
|
char isIgnoreDamage;
|
|
byte *animData;
|
|
void *damageEventsBegin;
|
|
qword flags;
|
|
Manager *manager;
|
|
ANM2 *sprite;
|
|
|
|
if ((npc->_variant == 0xc) || (npc->_variant == 0xd)) {
|
|
isIgnoreDamage = '\x01';
|
|
}
|
|
else {
|
|
isIgnoreDamage = '\0';
|
|
if ((0.2 < *GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(g_game->_room) + 0x7240))) &&
|
|
(bVar1 = (GHIDRA_CAST<Entity *>((GHIDRA_CAST<Entity *>(npc))))->Entity::IsFrame(5,npc->_index), bVar1 != 0)) {
|
|
damageSource = (GHIDRA_CAST<EntityRef *>((&damageSourceRef)))->EntityRef::EntityRef();
|
|
npc->TakeDamage(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)) {
|
|
npc->Remove();
|
|
}
|
|
}
|
|
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<byte *>(0x0)) {
|
|
curAnimName = animData;
|
|
if (0xf < *GHIDRA_CAST<uint *>((animData + 0x14))) {
|
|
curAnimName = *GHIDRA_CAST<byte **>(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 = (GHIDRA_CAST<ANM2 *>((sprite)))->ANM2::SetAnimation(s_Idle,1);
|
|
if (bVar1 != 0) {
|
|
(GHIDRA_CAST<AnimationState *>((&(npc->_sprite)._animState)))->AnimationState::Rewind();
|
|
(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 = (GHIDRA_CAST<ANM2 *>((sprite)))->ANM2::GetLayer(GHIDRA_CAST<byte *>(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;
|
|
(GHIDRA_CAST<ANM2 *>((sprite)))->ANM2::Play(GHIDRA_CAST<byte *>("Disappear"),0);
|
|
goto LAB_006d1556;
|
|
}
|
|
}
|
|
if (((npc->_spawnerType == 0x3b7) &&
|
|
(iVar3 = (GHIDRA_CAST<Entity *>((GHIDRA_CAST<Entity *>(npc))))->Entity::GetIntervalTicks(30.0,0.0), iVar3 != 0)) &&
|
|
(uVar2 = Random(), (uVar2 & 3) == 0)) {
|
|
damageSource = (GHIDRA_CAST<EntityRef *>((&damageSourceRef)))->EntityRef::EntityRef();
|
|
npc->TakeDamage(0x3f800000,0x20000,0,damageSource,0x1e);
|
|
}
|
|
if (npc->_pendingDamage <= 0.0) goto LAB_006d1556;
|
|
if ((npc->_pendingDamageFlags & 4) == 0) {
|
|
if (isIgnoreDamage == '\0') {
|
|
damageEvent = (npc->_damageEvents)._begin;
|
|
if (damageEvent == (npc->_damageEvents)._end) {
|
|
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 != (npc->_damageEvents)._end);
|
|
}
|
|
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 = (GHIDRA_CAST<ANM2 *>((&npc->_sprite)))->ANM2::GetLayer(GHIDRA_CAST<byte *>(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<byte *>(0x0)) {
|
|
LAB_006d13b6:
|
|
bVar1 = (GHIDRA_CAST<ANM2 *>((&npc->_sprite)))->ANM2::SetAnimation(GHIDRA_CAST<byte *>("Disappear"),1);
|
|
if (bVar1 != 0) {
|
|
(GHIDRA_CAST<AnimationState *>((&(npc->_sprite)._animState)))->AnimationState::Rewind();
|
|
(npc->_sprite)._animState._isPlaying = 1;
|
|
}
|
|
}
|
|
else {
|
|
curAnimName = animData;
|
|
if (0xf < *GHIDRA_CAST<uint *>((animData + 0x14))) {
|
|
curAnimName = *GHIDRA_CAST<byte **>(animData);
|
|
}
|
|
wantedAnimNameStr = "Disappear";
|
|
do {
|
|
bVar1 = *curAnimName;
|
|
isLess = bVar1 < (byte)*wantedAnimNameStr;
|
|
if (bVar1 != *wantedAnimNameStr) {
|
|
LAB_006d13a3:
|
|
uVar2 = -GHIDRA_UINT(isLess) | 1;
|
|
goto LAB_006d13a8;
|
|
}
|
|
if (bVar1 == 0) break;
|
|
bVar1 = curAnimName[1];
|
|
isLess = bVar1 < (byte)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<int *>(&local_c));
|
|
(GHIDRA_CAST<SoundEffects *>((&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<undefined4 *>((GHIDRA_INT(&npc->_flags) + 4)) = *GHIDRA_CAST<undefined4 *>((GHIDRA_INT(&npc->_flags) + 4));
|
|
*GHIDRA_CAST<uint *>(&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 = (GHIDRA_CAST<ANM2 *>((&npc->_sprite)))->ANM2::GetLayer(GHIDRA_CAST<byte *>(0x0));
|
|
(layer->_size).x = local_10;
|
|
(layer->_size).y = local_c;
|
|
animData = (npc->_sprite)._animState._animData;
|
|
if (animData == GHIDRA_CAST<byte *>(0x0)) {
|
|
LAB_006d14f6:
|
|
bVar1 = (GHIDRA_CAST<ANM2 *>((&npc->_sprite)))->ANM2::SetAnimation(GHIDRA_CAST<byte *>("Appear"),1);
|
|
if (bVar1 != 0) {
|
|
(GHIDRA_CAST<AnimationState *>((&(npc->_sprite)._animState)))->AnimationState::Rewind();
|
|
(npc->_sprite)._animState._isPlaying = 1;
|
|
}
|
|
}
|
|
else {
|
|
curAnimName = animData;
|
|
if (0xf < *GHIDRA_CAST<uint *>((animData + 0x14))) {
|
|
curAnimName = *GHIDRA_CAST<byte **>(animData);
|
|
}
|
|
wantedAnimNameStr = "Appear";
|
|
do {
|
|
bVar1 = *curAnimName;
|
|
isLess = bVar1 < (byte)*wantedAnimNameStr;
|
|
if (bVar1 != *wantedAnimNameStr) {
|
|
LAB_006d14e0:
|
|
uVar2 = -GHIDRA_UINT(isLess) | 1;
|
|
goto LAB_006d14e5;
|
|
}
|
|
if (bVar1 == 0) break;
|
|
bVar1 = curAnimName[1];
|
|
isLess = bVar1 < (byte)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 = (npc->_damageEvents)._begin;
|
|
npc->_pendingDamage = 0.0;
|
|
*GHIDRA_CAST<undefined4 *>(&npc->_pendingDamageFlags) = 0;
|
|
*GHIDRA_CAST<undefined4 *>((GHIDRA_INT(&npc->_pendingDamageFlags) + 4)) = 0;
|
|
(npc->_damageEvents)._end = damageEventsBegin;
|
|
return;
|
|
}
|
|
|
|
// 00860ac0
|
|
void NpcHelper::default_case_lua_callback(Entity_NPC *npc)
|
|
{
|
|
int in_stack_00000004;
|
|
uint uStack_40;
|
|
undefined4 luaState;
|
|
undefined4 callbackRef;
|
|
undefined1 *local_14;
|
|
void *local_10;
|
|
undefined1 *puStack_c;
|
|
undefined4 local_8;
|
|
|
|
puStack_c = &LAB_00b03ce0;
|
|
local_10 = ExceptionList;
|
|
uStack_40 = __security_cookie ^ GHIDRA_INT(register0x00000010) - 4U;
|
|
local_14 = GHIDRA_CAST<undefined1 *>(&uStack_40);
|
|
ExceptionList = &local_10;
|
|
if ((**GHIDRA_CAST<byte **>(g_luaEngine) & 1) != 0) {
|
|
local_8 = 0;
|
|
FUN_00872a20(&luaState,*GHIDRA_CAST<undefined4 *>((in_stack_00000004 + 0x28)),in_stack_00000004);
|
|
luaL_unref(luaState,0xfff0b9d8,callbackRef);
|
|
}
|
|
ExceptionList = local_10;
|
|
return;
|
|
}
|
|
|
|
// 009be990
|
|
uint NpcHelper::big_horn_is_any_hole_busy()
|
|
{
|
|
int *hole;
|
|
undefined4 *in_ECX;
|
|
|
|
hole = GHIDRA_CAST<int *>(*in_ECX);
|
|
while( true ) {
|
|
if (hole == GHIDRA_CAST<int *>(in_ECX[1])) {
|
|
return GHIDRA_UINT(hole) & 0xffffff00;
|
|
}
|
|
if ((*GHIDRA_CAST<int *>((*hole + 0x3fc)) != 0) && (*GHIDRA_CAST<int *>((*hole + 0x3fc)) != 3)) break;
|
|
hole = hole + 1;
|
|
}
|
|
return CONCAT31((int3)(GHIDRA_UINT(hole) >> 8),1);
|
|
}
|
|
|
|
// 009bfd40
|
|
float * NpcHelper::hush_fly_shape_build(float *outPath, int shape, float radius)
|
|
{
|
|
float fVar1;
|
|
undefined1 *puVar2;
|
|
uint pointCapacity;
|
|
float *pathEnd;
|
|
int iVar3;
|
|
float fVar4;
|
|
float distX;
|
|
float pointX;
|
|
float pointY;
|
|
float pointDistance;
|
|
float pointSegmentLength;
|
|
float sideCountF;
|
|
float angle;
|
|
float radiusLocal;
|
|
float *outPathLocal;
|
|
uint pointIdx;
|
|
float circleX;
|
|
int sideCount;
|
|
undefined1 *puStack_20;
|
|
void *local_1c;
|
|
undefined1 *puStack_18;
|
|
undefined4 local_14;
|
|
void *savedExceptionList;
|
|
|
|
savedExceptionList = ExceptionList;
|
|
puStack_20 = GHIDRA_CAST<undefined1 *>((GHIDRA_INT(register0x00000010) + -4));
|
|
puStack_18 = &LAB_00b0ebd0;
|
|
local_1c = ExceptionList;
|
|
ExceptionList = &local_1c;
|
|
outPath[1] = 0.0;
|
|
outPath[2] = 0.0;
|
|
outPath[3] = 0.0;
|
|
local_14 = 0;
|
|
*outPath = 0.0;
|
|
if (shape == 0) {
|
|
ExceptionList = savedExceptionList;
|
|
return outPath;
|
|
}
|
|
radiusLocal = radius;
|
|
outPathLocal = outPath;
|
|
if (shape == 6) {
|
|
pointCapacity = 0x20;
|
|
sideCount = 0x1f;
|
|
}
|
|
else if (shape == 3) {
|
|
sideCount = shape;
|
|
pointCapacity = 4;
|
|
}
|
|
else if (shape == 4) {
|
|
sideCount = shape;
|
|
pointCapacity = 5;
|
|
}
|
|
else if (shape == 5) {
|
|
sideCount = shape;
|
|
pointCapacity = 6;
|
|
}
|
|
else if (shape == 1) {
|
|
sideCount = 10;
|
|
pointCapacity = 0xb;
|
|
}
|
|
else if (shape == 2) {
|
|
sideCount = 0xc;
|
|
pointCapacity = 0xd;
|
|
}
|
|
else {
|
|
sideCount = GHIDRA_INT(sideCountF);
|
|
pointCapacity = GHIDRA_INT(sideCountF) + 1;
|
|
puVar2 = GHIDRA_CAST<undefined1 *>((GHIDRA_INT(register0x00000010) + -4));
|
|
if (pointCapacity == 0) goto LAB_009bfdd2;
|
|
if (0xfffffff < pointCapacity) {
|
|
/* WARNING: Subroutine does not return */
|
|
std::_Xlen();
|
|
}
|
|
}
|
|
iVar3 = sideCount;
|
|
puStack_20 = GHIDRA_CAST<undefined1 *>((GHIDRA_INT(register0x00000010) + -4));
|
|
FUN_009c00c0(pointCapacity);
|
|
sideCountF = (float)iVar3;
|
|
puVar2 = puStack_20;
|
|
LAB_009bfdd2:
|
|
puStack_20 = puVar2;
|
|
pointIdx = 0;
|
|
if (-1 < GHIDRA_INT(sideCountF)) {
|
|
iVar3 = GHIDRA_INT(sideCountF);
|
|
sideCountF = (float)GHIDRA_INT(sideCountF);
|
|
do {
|
|
angle = ((float)GHIDRA_INT(pointIdx) * 6.2831855) / sideCountF;
|
|
circleX = cos(angle);
|
|
circleX = circleX * radiusLocal;
|
|
pointY = sin(angle);
|
|
pointY = pointY * radiusLocal;
|
|
pointX = circleX;
|
|
if (shape == 1) {
|
|
if ((pointIdx & 1) != 0) {
|
|
pointY = pointY * 0.382;
|
|
pointX = circleX * 0.382;
|
|
}
|
|
}
|
|
else if ((shape == 2) && ((pointIdx & 1) != 0)) {
|
|
pointX = circleX * 0.577;
|
|
pointY = pointY * 0.577;
|
|
}
|
|
pathEnd = GHIDRA_CAST<float *>(outPath[2]);
|
|
pointSegmentLength = 0.0;
|
|
if (GHIDRA_INT(pathEnd) - GHIDRA_INT(outPath[1]) >> 4 != 0) {
|
|
fVar1 = outPathLocal[2];
|
|
fVar4 = pointY - *GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(fVar1) + -0xc));
|
|
distX = pointX - *GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(fVar1) + -0x10));
|
|
fVar4 = sqrtf(fVar4 * fVar4 + distX * distX);
|
|
*GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(fVar1) + -4)) = fVar4;
|
|
*outPathLocal = fVar4 + *outPathLocal;
|
|
pathEnd = GHIDRA_CAST<float *>(outPath[2]);
|
|
iVar3 = sideCount;
|
|
}
|
|
pointDistance = *outPathLocal;
|
|
if (pathEnd == GHIDRA_CAST<float *>(outPath[3])) {
|
|
std::vector<16byte>::_Emplace_reallocate(pathEnd,&pointX);
|
|
}
|
|
else {
|
|
*pathEnd = pointX;
|
|
pathEnd[1] = pointY;
|
|
pathEnd[2] = pointDistance;
|
|
pathEnd[3] = pointSegmentLength;
|
|
outPath[2] = (float)(GHIDRA_INT(outPath[2]) + 0x10);
|
|
}
|
|
pointIdx = pointIdx + 1;
|
|
} while (GHIDRA_INT(pointIdx) <= iVar3);
|
|
}
|
|
ExceptionList = local_1c;
|
|
return outPathLocal;
|
|
}
|
|
|
|
// 009bffb0
|
|
void NpcHelper::path_point_at(void *path, Vector *outPoint, float share)
|
|
{
|
|
float totalLength;
|
|
int pointIdx;
|
|
float *pointDistanceIt;
|
|
int points;
|
|
int segment;
|
|
int pointCount;
|
|
float segmentStart;
|
|
float segmentStart;
|
|
float totalLength;
|
|
|
|
pointIdx = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(path) + 8));
|
|
if (GHIDRA_UINT((pointIdx - *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(path) + 4)) >> 4)) < 2) {
|
|
KAGE_LogMessage(0x10,GHIDRA_CAST<byte *>("Path is incomplete"));
|
|
pointIdx = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(path) + 8));
|
|
}
|
|
segmentStart = fmodf(share,1.0);
|
|
points = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(path) + 4));
|
|
segment = 0;
|
|
totalLength = *GHIDRA_CAST<float *>(path);
|
|
pointCount = pointIdx - points >> 4;
|
|
pointIdx = 1;
|
|
if (1 < pointCount) {
|
|
pointDistanceIt = GHIDRA_CAST<float *>((points + 0x18));
|
|
do {
|
|
if (segmentStart * totalLength < *pointDistanceIt) {
|
|
segment = pointIdx + -1;
|
|
break;
|
|
}
|
|
pointIdx = pointIdx + 1;
|
|
pointDistanceIt = pointDistanceIt + 4;
|
|
} while (pointIdx < pointCount);
|
|
}
|
|
totalLength = *GHIDRA_CAST<float *>((points + 0xc + segment * 0x10));
|
|
segmentStart = *GHIDRA_CAST<float *>((points + 8 + segment * 0x10));
|
|
if (totalLength == 0.0) {
|
|
KAGE_LogMessage(0x10,GHIDRA_CAST<byte *>("Start and End parameters cannot be the same!"));
|
|
points = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(path) + 4));
|
|
}
|
|
totalLength = ((segmentStart * totalLength - segmentStart) - 0.0) / (totalLength - 0.0);
|
|
outPoint->x = (*GHIDRA_CAST<float *>((points + 0x10 + segment * 0x10)) - *GHIDRA_CAST<float *>((points + segment * 0x10))) *
|
|
totalLength + *GHIDRA_CAST<float *>((points + segment * 0x10));
|
|
outPoint->y = (*GHIDRA_CAST<float *>((points + 0x14 + segment * 0x10)) -
|
|
*GHIDRA_CAST<float *>((points + 4 + segment * 0x10))) * totalLength +
|
|
*GHIDRA_CAST<float *>((points + 4 + segment * 0x10));
|
|
return;
|
|
}
|