13374 lines
479 KiB
C++
13374 lines
479 KiB
C++
#include "classes.h"
|
|
|
|
// 004830e0
|
|
void NpcHelper::the_lamb_pattern(Entity_NPC *npc, int pattern, int frame)
|
|
{
|
|
Entity *target;
|
|
uint32_t 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));
|
|
ProjectileParams::ProjectileParams(¶ms);
|
|
(*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(params)) + 0x4))) = 0x40a00000;
|
|
params.Scale = 1.8;
|
|
params.FallingAccelModifier = -0.06;
|
|
params.FallingSpeedModifier = -2.0;
|
|
target = Entity_NPC::GetPlayerTarget(npc);
|
|
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<uint32_t *>((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<uint32_t *>((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)
|
|
{
|
|
uint32_t *puVar1;
|
|
uint32_t *puVar2;
|
|
uint32_t *puVar3;
|
|
int *in_ECX;
|
|
int rightSegment;
|
|
int *in_EDX;
|
|
int *leftNode;
|
|
int *piVar4;
|
|
float fVar5;
|
|
float fVar6;
|
|
float leftDy;
|
|
float leftDx;
|
|
int *firstNode;
|
|
int leftSegment;
|
|
|
|
rightSegment = in_EDX[2];
|
|
firstNode = in_EDX;
|
|
piVar4 = in_EDX;
|
|
leftNode = in_ECX;
|
|
if (rightSegment != param_2) {
|
|
leftSegment = in_ECX[2];
|
|
if (leftSegment != param_2) {
|
|
fVar6 = *GHIDRA_CAST<float *>((param_2 + 0x33c)) - *GHIDRA_CAST<float *>((rightSegment + 0x33c));
|
|
leftDx = *GHIDRA_CAST<float *>((param_2 + 0x33c)) - *GHIDRA_CAST<float *>((leftSegment + 0x33c));
|
|
fVar5 = *GHIDRA_CAST<float *>((param_2 + 0x340)) - *GHIDRA_CAST<float *>((rightSegment + 0x340));
|
|
leftDy = *GHIDRA_CAST<float *>((param_2 + 0x340)) - *GHIDRA_CAST<float *>((leftSegment + 0x340));
|
|
fVar5 = sqrtf(fVar5 * fVar5 + fVar6 * fVar6);
|
|
fVar6 = sqrtf(leftDy * leftDy + leftDx * leftDx);
|
|
if (fVar5 < fVar6) goto LAB_00499ba3;
|
|
rightSegment = in_EDX[2];
|
|
}
|
|
do {
|
|
do {
|
|
leftNode = GHIDRA_CAST<int *>(*leftNode);
|
|
if (leftNode == in_EDX) {
|
|
return in_ECX;
|
|
}
|
|
leftSegment = leftNode[2];
|
|
} while (leftSegment == param_2);
|
|
fVar6 = *GHIDRA_CAST<float *>((param_2 + 0x33c)) - *GHIDRA_CAST<float *>((rightSegment + 0x33c));
|
|
leftDx = *GHIDRA_CAST<float *>((param_2 + 0x33c)) - *GHIDRA_CAST<float *>((leftSegment + 0x33c));
|
|
fVar5 = *GHIDRA_CAST<float *>((param_2 + 0x340)) - *GHIDRA_CAST<float *>((rightSegment + 0x340));
|
|
leftDy = *GHIDRA_CAST<float *>((param_2 + 0x340)) - *GHIDRA_CAST<float *>((leftSegment + 0x340));
|
|
fVar5 = sqrtf(fVar5 * fVar5 + fVar6 * fVar6);
|
|
fVar6 = sqrtf(leftDy * leftDy + leftDx * leftDx);
|
|
rightSegment = in_EDX[2];
|
|
firstNode = in_ECX;
|
|
} while (fVar6 <= fVar5);
|
|
}
|
|
LAB_00499ba3:
|
|
in_EDX = GHIDRA_CAST<int *>(*in_EDX);
|
|
if (in_EDX != param_1) goto code_r0x00499bae;
|
|
goto LAB_00499c40;
|
|
code_r0x00499bae:
|
|
rightSegment = in_EDX[2];
|
|
if (rightSegment != param_2) {
|
|
leftSegment = leftNode[2];
|
|
if (leftSegment != param_2) {
|
|
fVar6 = *GHIDRA_CAST<float *>((param_2 + 0x33c)) - *GHIDRA_CAST<float *>((rightSegment + 0x33c));
|
|
leftDx = *GHIDRA_CAST<float *>((param_2 + 0x33c)) - *GHIDRA_CAST<float *>((leftSegment + 0x33c));
|
|
fVar5 = *GHIDRA_CAST<float *>((param_2 + 0x340)) - *GHIDRA_CAST<float *>((rightSegment + 0x340));
|
|
leftDy = *GHIDRA_CAST<float *>((param_2 + 0x340)) - *GHIDRA_CAST<float *>((leftSegment + 0x340));
|
|
fVar5 = sqrtf(fVar5 * fVar5 + fVar6 * fVar6);
|
|
fVar6 = sqrtf(leftDy * leftDy + leftDx * leftDx);
|
|
if (fVar5 < fVar6) goto LAB_00499ba3;
|
|
}
|
|
LAB_00499c40:
|
|
puVar1 = GHIDRA_CAST<uint32_t *>(piVar4[1]);
|
|
*puVar1 = in_EDX;
|
|
puVar2 = GHIDRA_CAST<uint32_t *>(in_EDX[1]);
|
|
*puVar2 = leftNode;
|
|
puVar3 = GHIDRA_CAST<uint32_t *>(leftNode[1]);
|
|
*puVar3 = piVar4;
|
|
leftNode[1] = GHIDRA_INT(puVar2);
|
|
in_EDX[1] = GHIDRA_INT(puVar1);
|
|
piVar4[1] = GHIDRA_INT(puVar3);
|
|
if (in_EDX == param_1) {
|
|
return firstNode;
|
|
}
|
|
do {
|
|
do {
|
|
leftNode = GHIDRA_CAST<int *>(*leftNode);
|
|
if (leftNode == in_EDX) {
|
|
return firstNode;
|
|
}
|
|
rightSegment = in_EDX[2];
|
|
piVar4 = in_EDX;
|
|
if (rightSegment == param_2) goto LAB_00499ba3;
|
|
leftSegment = leftNode[2];
|
|
} while (leftSegment == param_2);
|
|
fVar6 = *GHIDRA_CAST<float *>((param_2 + 0x33c)) - *GHIDRA_CAST<float *>((rightSegment + 0x33c));
|
|
leftDx = *GHIDRA_CAST<float *>((param_2 + 0x33c)) - *GHIDRA_CAST<float *>((leftSegment + 0x33c));
|
|
fVar5 = *GHIDRA_CAST<float *>((param_2 + 0x340)) - *GHIDRA_CAST<float *>((rightSegment + 0x340));
|
|
leftDy = *GHIDRA_CAST<float *>((param_2 + 0x340)) - *GHIDRA_CAST<float *>((leftSegment + 0x340));
|
|
fVar5 = sqrtf(fVar5 * fVar5 + fVar6 * fVar6);
|
|
fVar6 = sqrtf(leftDy * leftDy + leftDx * leftDx);
|
|
} while (fVar6 <= fVar5);
|
|
}
|
|
goto LAB_00499ba3;
|
|
}
|
|
|
|
// 0049f870
|
|
void NpcHelper::chimera_charge_begin(Entity_NPC *npc, Vector *target, float speed)
|
|
{
|
|
uint8_t bVar1;
|
|
uint8_t *currentName;
|
|
uint32_t compareResult;
|
|
char *chargeBeginName;
|
|
bool isLess;
|
|
float length;
|
|
float dirX;
|
|
float local_c;
|
|
float local_8;
|
|
uint8_t *animData;
|
|
Manager *manager;
|
|
|
|
animData = (npc->_sprite)._animState._animData;
|
|
if (animData != GHIDRA_CAST<uint8_t *>(0x0)) {
|
|
currentName = animData;
|
|
if (0xf < *GHIDRA_CAST<uint32_t *>((animData + 0x14))) {
|
|
currentName = *GHIDRA_CAST<uint8_t **>(animData);
|
|
}
|
|
chargeBeginName = "ChargeBegin";
|
|
do {
|
|
bVar1 = *currentName;
|
|
isLess = bVar1 < (uint8_t)*chargeBeginName;
|
|
if (bVar1 != *chargeBeginName) {
|
|
LAB_0049f8b6:
|
|
compareResult = -GHIDRA_UINT(isLess) | 1;
|
|
goto LAB_0049f8bb;
|
|
}
|
|
if (bVar1 == 0) break;
|
|
bVar1 = currentName[1];
|
|
isLess = bVar1 < (uint8_t)chargeBeginName[1];
|
|
if (bVar1 != chargeBeginName[1]) goto LAB_0049f8b6;
|
|
currentName = currentName + 2;
|
|
chargeBeginName = chargeBeginName + 2;
|
|
} while (bVar1 != 0);
|
|
compareResult = 0;
|
|
LAB_0049f8bb:
|
|
if ((compareResult == 0) &&
|
|
((animData[0x34] == 0 || ((npc->_sprite)._animState._isPlaying != 0)))) goto LAB_0049f8ee;
|
|
}
|
|
bVar1 = ANM2::SetAnimation(&npc->_sprite,GHIDRA_CAST<uint8_t *>("ChargeBegin"),1);
|
|
if (bVar1 != 0) {
|
|
AnimationState::Rewind(&(npc->_sprite)._animState);
|
|
(npc->_sprite)._animState._isPlaying = 1;
|
|
}
|
|
LAB_0049f8ee:
|
|
npc->_state = 10;
|
|
manager = g_manager;
|
|
local_8 = 1.0;
|
|
if (npc->_championColorIdx == 0x12) {
|
|
local_8 = 1.5;
|
|
}
|
|
else if (npc->_championColorIdx == 0x13) {
|
|
local_8 = 0.5;
|
|
}
|
|
local_c = 4.21791e-43;
|
|
seed_fart_sound_override(GHIDRA_CAST<int *>(&local_c));
|
|
(GHIDRA_CAST<SoundEffects *>((&manager->_sfxManager)))->SoundEffects::Play(GHIDRA_INT(local_c),1.0,2,0,local_8,0.0);
|
|
dirX = target->x - (npc->_pos).x;
|
|
local_c = target->y - (npc->_pos).y;
|
|
length = sqrtf(dirX * dirX + local_c * local_c);
|
|
if (0.0 < length) {
|
|
dirX = dirX * (1.0 / length);
|
|
local_c = local_c * (1.0 / length);
|
|
}
|
|
*GHIDRA_CAST<uint8_t *>(&npc->_i1) = 0;
|
|
(npc->_targetPosition).x = dirX * speed;
|
|
(npc->_targetPosition).y = local_c * speed;
|
|
return;
|
|
}
|
|
|
|
// 004a1000
|
|
void NpcHelper::chimera_render_child(Entity_NPC *npc, Vector *offset)
|
|
{
|
|
int iVar1;
|
|
int iVar2;
|
|
int iVar3;
|
|
int iVar4;
|
|
int iVar5;
|
|
int iVar6;
|
|
int *piVar7;
|
|
void *layerFrame;
|
|
LayerState *pLVar8;
|
|
uint32_t frameX;
|
|
|
|
if (((((npc->_type == 0x38e) && (npc->_variant == 1)) && (npc->_state == 0x10)) &&
|
|
((piVar7 = GHIDRA_CAST<int *>(npc->_child), piVar7 != GHIDRA_CAST<int *>(0x0) && (piVar7[0x2d9] == 0x10)))) &&
|
|
(*GHIDRA_CAST<char *>((GHIDRA_CAST<char *>(piVar7) + 0x171)) == '\0')) {
|
|
layerFrame = AnimationState::GetLayerFrame(&(npc->_sprite)._animState,2);
|
|
if ((layerFrame != (void *)0x0) && (*GHIDRA_CAST<char *>((GHIDRA_CAST<char *>(layerFrame) + 0x2c)) != '\0')) {
|
|
iVar1 = piVar7[0xcf];
|
|
iVar2 = piVar7[0x37];
|
|
iVar3 = piVar7[0x38];
|
|
iVar4 = piVar7[0x39];
|
|
iVar5 = piVar7[0x3a];
|
|
piVar7[0xcf] = GHIDRA_INT((npc->_pos).x);
|
|
piVar7[0xd0] = GHIDRA_INT((npc->_pos).y);
|
|
iVar6 = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(layerFrame) + 0x14));
|
|
pLVar8 = ANM2::GetLayer(&npc->_sprite,GHIDRA_CAST<uint8_t *>(0x2));
|
|
frameX = *GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(layerFrame) + 0x10));
|
|
if (pLVar8->_flipX != 0) {
|
|
frameX = frameX ^ 0x80000000;
|
|
}
|
|
piVar7[0x37] = frameX;
|
|
piVar7[0x38] = iVar6;
|
|
piVar7[0x39] = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(layerFrame) + 0x18));
|
|
piVar7[0x3a] = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(layerFrame) + 0x1c));
|
|
*GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>(piVar7) + 0x171)) = 1;
|
|
(**(code **)(*piVar7 + 0x14))(offset);
|
|
piVar7[0x39] = iVar6;
|
|
piVar7[0x3a] = iVar4;
|
|
piVar7[0x37] = iVar5;
|
|
piVar7[0x38] = iVar2;
|
|
piVar7[0xcf] = iVar3;
|
|
*GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>(piVar7) + 0x171)) = 0;
|
|
piVar7[0xd0] = iVar1;
|
|
}
|
|
}
|
|
return;
|
|
}
|
|
|
|
// 004a2940
|
|
Vector * NpcHelper::colostomia_pick_target(Entity_NPC *npc, Vector *outTarget, uint8_t *isPlayerPos)
|
|
{
|
|
uint64_t qVar1;
|
|
Entity *playerTarget;
|
|
uint64_t *allocCounter;
|
|
int gridWidth;
|
|
uint32_t uVar3;
|
|
uint32_t uVar4;
|
|
int iVar5;
|
|
float score;
|
|
float dy;
|
|
float cellX;
|
|
float cellY;
|
|
float fVar6;
|
|
float fVar7;
|
|
float bestY;
|
|
EntityList_EL effects;
|
|
Entity_NPC *local_720;
|
|
uint8_t *local_71c;
|
|
Vector *local_718;
|
|
int cellCounts [448];
|
|
uint32_t local_14;
|
|
void *local_10;
|
|
uint8_t *puStack_c;
|
|
int local_8;
|
|
Game *game;
|
|
int gridWidth;
|
|
void *room;
|
|
|
|
local_8 = 0xffffffff;
|
|
puStack_c = &LAB_00af2fd0;
|
|
local_10 = ExceptionList;
|
|
local_14 = __security_cookie ^ GHIDRA_UINT((cellCounts + 0x1c4));
|
|
ExceptionList = &local_10;
|
|
local_71c = isPlayerPos;
|
|
local_718 = outTarget;
|
|
local_720 = npc;
|
|
memset(cellCounts,0,0x700);
|
|
EntityList::QuerySublist(GHIDRA_CAST<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<uint32_t *>((GHIDRA_CAST<char *>(&(effects)) + 0x4))) + 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 = Entity_NPC::GetPlayerTarget(local_720);
|
|
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<uint8_t *>((GHIDRA_CAST<char *>(&(effects)) + 0x0))) != '\0') {
|
|
ExceptionList = local_10;
|
|
return outTarget;
|
|
}
|
|
if (g_mainHeap == (void *)0x0) {
|
|
allocCounter = &g_allocatedBytesNoHeap;
|
|
}
|
|
else {
|
|
allocCounter = GHIDRA_CAST<uint64_t *>((GHIDRA_INT(g_mainHeap) + 0x30));
|
|
}
|
|
if ((*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(effects)) + 0x4))) == 0) {
|
|
ExceptionList = local_10;
|
|
return outTarget;
|
|
}
|
|
uVar4 = *GHIDRA_CAST<uint32_t *>(((*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(effects)) + 0x4))) + -4));
|
|
qVar1 = *allocCounter;
|
|
*GHIDRA_CAST<uint32_t *>(allocCounter) = GHIDRA_UINT(*allocCounter) - uVar4;
|
|
*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(allocCounter) + 4)) =
|
|
*GHIDRA_CAST<uint32_t *>((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<uint8_t *>((GHIDRA_CAST<char *>(&(effects)) + 0x0))) != '\0') {
|
|
ExceptionList = local_10;
|
|
return outTarget;
|
|
}
|
|
if (g_mainHeap == (void *)0x0) {
|
|
allocCounter = &g_allocatedBytesNoHeap;
|
|
}
|
|
else {
|
|
allocCounter = GHIDRA_CAST<uint64_t *>((GHIDRA_INT(g_mainHeap) + 0x30));
|
|
}
|
|
if ((*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(effects)) + 0x4))) == 0) {
|
|
ExceptionList = local_10;
|
|
return outTarget;
|
|
}
|
|
uVar4 = *GHIDRA_CAST<uint32_t *>(((*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(effects)) + 0x4))) + -4));
|
|
qVar1 = *allocCounter;
|
|
*GHIDRA_CAST<uint32_t *>(allocCounter) = GHIDRA_UINT(*allocCounter) - uVar4;
|
|
*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(allocCounter) + 4)) = *GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(allocCounter) + 4)) - GHIDRA_UINT((GHIDRA_UINT(qVar1) < uVar4));
|
|
LAB_004a2cad:
|
|
free((void *)((*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(effects)) + 0x4))) + -4));
|
|
ExceptionList = local_10;
|
|
return outTarget;
|
|
}
|
|
|
|
// 004a2ce0
|
|
void NpcHelper::colostomia_pick_dive_target(Entity_NPC *npc)
|
|
{
|
|
uint8_t bVar1;
|
|
void **roomRef;
|
|
Vector *candidatePos;
|
|
Entity_Player *nearestPlayer;
|
|
uint32_t uVar2;
|
|
uint8_t *animData;
|
|
int iVar4;
|
|
uint8_t *pbVar5;
|
|
int iVar6;
|
|
Entity_NPC *pEVar7;
|
|
bool bVar8;
|
|
float fVar9;
|
|
float fVar10;
|
|
Vector freePos;
|
|
Vector randomPos;
|
|
int *local_24;
|
|
int *local_20;
|
|
void **roomSlot;
|
|
uint32_t attempt;
|
|
Entity_NPC *npcLocal;
|
|
uint8_t *animData;
|
|
uint32_t *childRef;
|
|
Vector *diveTarget;
|
|
Game *game;
|
|
Room *room;
|
|
|
|
game = g_game;
|
|
diveTarget = &npc->_v1;
|
|
diveTarget->x = g_vectorZero.x;
|
|
(npc->_v1).y = g_vectorZero.y;
|
|
attempt = 0;
|
|
roomRef = &game->_room;
|
|
npcLocal = npc;
|
|
do {
|
|
room = *roomRef;
|
|
candidatePos = Room::GetRandomPosition(room,&randomPos,0.0);
|
|
candidatePos = Room::FindFreePickupSpawnPosition(room,&freePos,candidatePos,0.0,0,0,0);
|
|
pEVar7 = npcLocal;
|
|
fVar10 = candidatePos->x;
|
|
diveTarget->x = fVar10;
|
|
fVar9 = candidatePos->y;
|
|
(npc->_v1).y = fVar9;
|
|
fVar10 = (npcLocal->_pos).x - fVar10;
|
|
fVar9 = (npcLocal->_pos).y - fVar9;
|
|
local_20 = GHIDRA_CAST<int *>(sqrtf(fVar9 * fVar9 + fVar10 * fVar10));
|
|
nearestPlayer = Game::GetNearestPlayer(g_game,diveTarget);
|
|
fVar10 = (nearestPlayer->_pos).y - (npc->_v1).y;
|
|
fVar9 = (nearestPlayer->_pos).x - diveTarget->x;
|
|
local_24 = GHIDRA_CAST<int *>(sqrtf(fVar10 * fVar10 + fVar9 * fVar9));
|
|
roomSlot = &g_game->_room;
|
|
bVar1 = Room::IsPositionInRoom(*roomSlot,diveTarget,60.0);
|
|
if (bVar1 != 0) {
|
|
room = *roomSlot;
|
|
iVar6 = GHIDRA_INT(((diveTarget->x - 40.0) / 40.0 + 0.5));
|
|
iVar4 = GHIDRA_INT((((npc->_v1).y - 120.0) / 40.0 + 0.5));
|
|
if ((((iVar6 < 0) || (room->_gridWidth <= iVar6)) || (iVar4 < 0)) ||
|
|
(room->_gridHeight <= iVar4)) {
|
|
iVar6 = -1;
|
|
}
|
|
else {
|
|
iVar6 = room->_gridWidth * iVar4 + iVar6;
|
|
}
|
|
uVar2 = Room::GetGridCollision(room,iVar6);
|
|
pEVar7 = npcLocal;
|
|
if ((((uVar2 == 0) && (80.0 <= (float)local_20)) &&
|
|
(((float)local_20 <= 200.0 && (120.0 < (float)local_24)))) &&
|
|
((iVar6 = npcLocal->_entityRef, iVar6 == 0 ||
|
|
(fVar10 = (npc->_v1).y - *GHIDRA_CAST<float *>((iVar6 + 0x340)),
|
|
fVar9 = diveTarget->x - *GHIDRA_CAST<float *>((iVar6 + 0x33c)),
|
|
10000.0 < fVar10 * fVar10 + fVar9 * fVar9)))) break;
|
|
}
|
|
attempt = attempt + 1;
|
|
roomRef = roomSlot;
|
|
} while (attempt < 0xf);
|
|
childRef = &pEVar7->_entityRef;
|
|
if (pEVar7->_entityRef != 0) {
|
|
local_20 = GHIDRA_CAST<int *>((pEVar7->_entityRef + 0x3bc));
|
|
if (*local_20 != 0) {
|
|
local_24 = local_20;
|
|
msvc::multiset<unsigned_int>::erase(&local_24);
|
|
}
|
|
*local_20 = 0;
|
|
if (*childRef != 0) {
|
|
local_24 = childRef;
|
|
msvc::multiset<unsigned_int>::erase(&local_24);
|
|
}
|
|
*childRef = 0;
|
|
}
|
|
local_20 = GHIDRA_CAST<int *>(pEVar7->_child);
|
|
if (local_20 != GHIDRA_CAST<int *>(0x0)) {
|
|
*childRef = local_20;
|
|
msvc::multiset<unsigned_int>::insert(childRef);
|
|
if (pEVar7->_child != 0) {
|
|
local_24 = &pEVar7->_child;
|
|
msvc::multiset<unsigned_int>::erase(&local_24);
|
|
}
|
|
pEVar7->_child = 0;
|
|
}
|
|
animData = (pEVar7->_sprite)._animState._animData;
|
|
if (animData != GHIDRA_CAST<uint8_t *>(0x0)) {
|
|
animData = animData;
|
|
if (0xf < *GHIDRA_CAST<uint32_t *>((animData + 0x14))) {
|
|
animData = *GHIDRA_CAST<uint8_t **>(animData);
|
|
}
|
|
pbVar5 = &DAT_00b1d33c;
|
|
do {
|
|
bVar1 = *animData;
|
|
bVar8 = bVar1 < *pbVar5;
|
|
if (bVar1 != *pbVar5) {
|
|
LAB_004a2fd4:
|
|
uVar2 = -GHIDRA_UINT(bVar8) | 1;
|
|
goto LAB_004a2fd9;
|
|
}
|
|
if (bVar1 == 0) break;
|
|
bVar1 = animData[1];
|
|
bVar8 = bVar1 < pbVar5[1];
|
|
if (bVar1 != pbVar5[1]) goto LAB_004a2fd4;
|
|
animData = animData + 2;
|
|
pbVar5 = pbVar5 + 2;
|
|
} while (bVar1 != 0);
|
|
uVar2 = 0;
|
|
LAB_004a2fd9:
|
|
if ((uVar2 == 0) && ((animData[0x34] == 0 || ((pEVar7->_sprite)._animState._isPlaying != 0))))
|
|
goto LAB_004a2fed;
|
|
}
|
|
bVar1 = ANM2::SetAnimation(&pEVar7->_sprite,&DAT_00b1d33c,1);
|
|
if (bVar1 != 0) {
|
|
AnimationState::Rewind(&(pEVar7->_sprite)._animState);
|
|
(pEVar7->_sprite)._animState._isPlaying = 1;
|
|
npcLocal->_state = 6;
|
|
return;
|
|
}
|
|
LAB_004a2fed:
|
|
pEVar7->_state = 6;
|
|
return;
|
|
}
|
|
|
|
// 004a6240
|
|
void NpcHelper::delirium_remove_minions(int type, int variant, Entity *self, Entity *other)
|
|
{
|
|
void *pvVar1;
|
|
int *tmpEntity;
|
|
uint64_t qVar3;
|
|
char cVar4;
|
|
uint32_t uVar5;
|
|
int iVar6;
|
|
uint64_t *allocCounter;
|
|
code *freeFn;
|
|
uint32_t npcIdx;
|
|
EntityList_EL laserList;
|
|
EntityList_EL tmpList;
|
|
int targetVariant;
|
|
int targetType;
|
|
void *local_10;
|
|
uint8_t *puStack_c;
|
|
uint32_t 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 = (**(code **)(*GHIDRA_CAST<int *>(tmpEntity) + 0x4c))(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<uint32_t *>((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);
|
|
roomEntity = tmpList._size;
|
|
iVar6 = (*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(tmpList)) + 0x4)));
|
|
local_8 = 0;
|
|
uVar5 = 0;
|
|
if (tmpList._size != 0) {
|
|
do {
|
|
(**(code **)(**GHIDRA_CAST<int **>((iVar6 + uVar5 * 4)) + 0x28))();
|
|
uVar5 = uVar5 + 1;
|
|
} while (uVar5 < GHIDRA_UINT(roomEntity));
|
|
}
|
|
joined_r0x004a63ae:
|
|
local_8 = 0xffffffff;
|
|
if ((*GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>(&(tmpList)) + 0x0))) == '\0') {
|
|
local_8 = 0xffffffff;
|
|
if (g_mainHeap == (void *)0x0) {
|
|
allocCounter = &g_allocatedBytesNoHeap;
|
|
}
|
|
else {
|
|
allocCounter = GHIDRA_CAST<uint64_t *>((GHIDRA_INT(g_mainHeap) + 0x30));
|
|
}
|
|
if (iVar6 != 0) {
|
|
uVar5 = *GHIDRA_CAST<uint32_t *>((iVar6 + -4));
|
|
qVar3 = *allocCounter;
|
|
*GHIDRA_CAST<uint32_t *>(allocCounter) = GHIDRA_UINT(*allocCounter) - uVar5;
|
|
*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(allocCounter) + 4)) =
|
|
*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(allocCounter) + 4)) - GHIDRA_UINT((GHIDRA_UINT(qVar3) < uVar5));
|
|
free((void *)(iVar6 + -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);
|
|
roomEntity = tmpList._size;
|
|
iVar6 = (*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(tmpList)) + 0x4)));
|
|
local_8 = 2;
|
|
uVar5 = 0;
|
|
if (tmpList._size != 0) {
|
|
do {
|
|
(**(code **)(**GHIDRA_CAST<int **>((iVar6 + uVar5 * 4)) + 0x28))();
|
|
uVar5 = uVar5 + 1;
|
|
} while (uVar5 < GHIDRA_UINT(roomEntity));
|
|
}
|
|
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<uint32_t *>((GHIDRA_CAST<char *>(&(laserList)) + 0x4))) + 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<uint8_t *>((GHIDRA_CAST<char *>(&(local_8)) + 0x1))),5);
|
|
uVar5 = 0;
|
|
if (tmpList._size != 0) {
|
|
do {
|
|
(**(code **)(**GHIDRA_CAST<int **>(((*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(tmpList)) + 0x4))) + uVar5 * 4)) + 0x28))();
|
|
uVar5 = uVar5 + 1;
|
|
} while (uVar5 < GHIDRA_UINT(tmpList._size));
|
|
}
|
|
if ((*GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>(&(tmpList)) + 0x0))) == '\0') {
|
|
allocCounter = GHIDRA_CAST<uint64_t *>((GHIDRA_INT(g_mainHeap) + 0x30));
|
|
if (g_mainHeap == (void *)0x0) {
|
|
allocCounter = &g_allocatedBytesNoHeap;
|
|
}
|
|
if ((*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(tmpList)) + 0x4))) != 0) {
|
|
uVar5 = *GHIDRA_CAST<uint32_t *>(((*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(tmpList)) + 0x4))) + -4));
|
|
qVar3 = *allocCounter;
|
|
*GHIDRA_CAST<uint32_t *>(allocCounter) = GHIDRA_UINT(*allocCounter) - uVar5;
|
|
freeFn = free_exref;
|
|
*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(allocCounter) + 4)) =
|
|
*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(allocCounter) + 4)) - GHIDRA_UINT((GHIDRA_UINT(qVar3) < uVar5));
|
|
free((void *)((*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(tmpList)) + 0x4))) + -4));
|
|
goto LAB_004a64bb;
|
|
}
|
|
}
|
|
freeFn = free_exref;
|
|
LAB_004a64bb:
|
|
if ((*GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>(&(laserList)) + 0x0))) == '\0') {
|
|
allocCounter = GHIDRA_CAST<uint64_t *>((GHIDRA_INT(g_mainHeap) + 0x30));
|
|
if (g_mainHeap == (void *)0x0) {
|
|
allocCounter = &g_allocatedBytesNoHeap;
|
|
}
|
|
if ((*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(laserList)) + 0x4))) != 0) {
|
|
uVar5 = *GHIDRA_CAST<uint32_t *>(((*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(laserList)) + 0x4))) + -4));
|
|
qVar3 = *allocCounter;
|
|
*GHIDRA_CAST<uint32_t *>(allocCounter) = GHIDRA_UINT(*allocCounter) - uVar5;
|
|
*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(allocCounter) + 4)) =
|
|
*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(allocCounter) + 4)) - GHIDRA_UINT((GHIDRA_UINT(qVar3) < uVar5));
|
|
(*freeFn)((*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(laserList)) + 0x4))) + -4);
|
|
}
|
|
}
|
|
ExceptionList = local_10;
|
|
return;
|
|
}
|
|
|
|
// 004a8680
|
|
void NpcHelper::delirium_spawn_form_parts(Entity_NPC *npc, float maxHealth)
|
|
{
|
|
uint32_t *puVar1;
|
|
float fVar2;
|
|
uint32_t uVar3;
|
|
uint8_t bVar4;
|
|
uint32_t uVar5;
|
|
Entity *target;
|
|
Entity_NPC *pEVar6;
|
|
void *newBlock;
|
|
uint8_t *curAnimChar;
|
|
uint32_t uVar7;
|
|
char *expectedAnimChar;
|
|
bool isCharLess;
|
|
float fVar8;
|
|
Vector spawnPos;
|
|
float dirX;
|
|
Entity_NPC *local_24;
|
|
float formMaxHealth;
|
|
Entity_NPC *formNpc;
|
|
int segmentCount;
|
|
float segmentIndex;
|
|
uint32_t *local_10;
|
|
void *local_c;
|
|
float dirY;
|
|
uint8_t *animData;
|
|
uint32_t *linkSlot;
|
|
int posBlock;
|
|
|
|
formMaxHealth = maxHealth;
|
|
formNpc = npc;
|
|
if (npc->_type == 0x13) {
|
|
uVar5 = Random();
|
|
segmentCount = uVar5 % 6 + 4;
|
|
target = Entity_NPC::GetPlayerTarget(npc);
|
|
dirY = (npc->_pos).x - (target->_pos).x;
|
|
local_c = (void *)((npc->_pos).y - (target->_pos).y);
|
|
fVar8 = sqrtf(dirY * dirY + (float)local_c * (float)local_c);
|
|
if (0.0 < fVar8) {
|
|
dirY = dirY * (1.0 / fVar8);
|
|
local_c = (void *)((float)local_c * (1.0 / fVar8));
|
|
}
|
|
uVar5 = Random();
|
|
segmentIndex = (float)GHIDRA_INT((uVar5 % 0x5a - 0x2d)) * 0.017453292;
|
|
local_10 = GHIDRA_CAST<uint32_t *>(cos(segmentIndex));
|
|
fVar8 = sin(segmentIndex);
|
|
segmentIndex = 1.4013e-45;
|
|
dirX = dirY * (float)local_10 - (float)local_c * fVar8;
|
|
dirY = dirY * fVar8 + (float)local_c * (float)local_10;
|
|
pEVar6 = npc;
|
|
if (0 < segmentCount) {
|
|
do {
|
|
fVar8 = segmentIndex;
|
|
spawnPos.y = (float)GHIDRA_INT(segmentIndex) * 20.0 * dirY + (pEVar6->_pos).y;
|
|
spawnPos.x = (float)GHIDRA_INT(segmentIndex) * 20.0 * dirX + (pEVar6->_pos).x;
|
|
uVar5 = Random();
|
|
local_10 = GHIDRA_CAST<uint32_t *>((((float)(uVar5 % 5000) + 0.0) / 1000.0));
|
|
uVar5 = Random();
|
|
spawnPos.x = ((float)(uVar5 % 5000) + 0.0) / 1000.0 + spawnPos.x;
|
|
spawnPos.y = spawnPos.y + (float)local_10;
|
|
uVar5 = Random();
|
|
pEVar6 = (Entity_NPC *)
|
|
Game::Spawn(g_game,pEVar6->_type,pEVar6->_variant,&spawnPos,&g_vectorZero,
|
|
GHIDRA_CAST<Entity *>(pEVar6),0,uVar5);
|
|
if (fVar8 == 1.4013e-45) {
|
|
pEVar6->_health = formMaxHealth;
|
|
pEVar6->_maxHitPoints = formMaxHealth;
|
|
pEVar6->_isInvicible = 1;
|
|
}
|
|
linkSlot = &pEVar6->_parent;
|
|
if (pEVar6->_parent != 0) {
|
|
local_10 = linkSlot;
|
|
msvc::multiset<unsigned_int>::erase(&local_10);
|
|
}
|
|
*linkSlot = npc;
|
|
if (npc != GHIDRA_CAST<Entity_NPC *>(0x0)) {
|
|
msvc::multiset<unsigned_int>::insert(linkSlot);
|
|
}
|
|
linkSlot = &npc->_child;
|
|
if (npc->_child != 0) {
|
|
local_10 = linkSlot;
|
|
msvc::multiset<unsigned_int>::erase(&local_10);
|
|
}
|
|
*linkSlot = pEVar6;
|
|
msvc::multiset<unsigned_int>::insert(linkSlot);
|
|
uVar7 = GHIDRA_UINT(pEVar6->_flags) & 0xfffffffb | 0x80040000;
|
|
*GHIDRA_CAST<uint32_t *>((GHIDRA_INT(&pEVar6->_flags) + 4)) = *GHIDRA_CAST<uint32_t *>((GHIDRA_INT(&pEVar6->_flags) + 4));
|
|
*GHIDRA_CAST<uint32_t *>(&pEVar6->_flags) = uVar7;
|
|
pEVar6->_state = 4;
|
|
uVar5 = (pEVar6->_vectorDeque1)._offset;
|
|
if (((uVar5 & 1) == 0) &&
|
|
((pEVar6->_vectorDeque1)._mapSize <= (pEVar6->_vectorDeque1)._size + 2 >> 1)) {
|
|
msvc::deque<int>::_Growmap(uVar7);
|
|
uVar5 = (pEVar6->_vectorDeque1)._offset;
|
|
}
|
|
uVar7 = (pEVar6->_vectorDeque1)._mapSize;
|
|
uVar3 = uVar7 * 2;
|
|
uVar5 = uVar3 - 1 & uVar5;
|
|
(pEVar6->_vectorDeque1)._offset = uVar5;
|
|
if (uVar5 == 0) {
|
|
uVar5 = uVar3;
|
|
}
|
|
uVar5 = uVar5 - 1;
|
|
local_c = (void *)(uVar7 - 1 & uVar5 >> 1);
|
|
local_10 = (pEVar6->_vectorDeque1)._map;
|
|
local_24 = GHIDRA_CAST<Entity_NPC *>(uVar5);
|
|
if (local_10[GHIDRA_INT(local_c)] == 0) {
|
|
newBlock = operator_new(0x10);
|
|
*(void **)(GHIDRA_INT((pEVar6->_vectorDeque1)._map) + GHIDRA_INT(local_c) * 4) = newBlock;
|
|
local_10 = (pEVar6->_vectorDeque1)._map;
|
|
}
|
|
fVar8 = (pEVar6->_pos).y;
|
|
fVar2 = (pEVar6->_pos).x;
|
|
posBlock = local_10[GHIDRA_INT(local_c)];
|
|
*GHIDRA_CAST<float *>((posBlock + (uVar5 & 1) * 8)) = fVar2;
|
|
*GHIDRA_CAST<float *>((posBlock + 4 + (uVar5 & 1) * 8)) = fVar8;
|
|
puVar1 = &(pEVar6->_vectorDeque1)._size;
|
|
*puVar1 = *puVar1 + 1;
|
|
(pEVar6->_vectorDeque1)._offset = GHIDRA_UINT(local_24);
|
|
uVar5 = (pEVar6->_vectorDeque2)._offset;
|
|
if (((uVar5 & 1) == 0) &&
|
|
((pEVar6->_vectorDeque2)._mapSize <= (pEVar6->_vectorDeque2)._size + 2 >> 1)) {
|
|
msvc::deque<int>::_Growmap(fVar2);
|
|
uVar5 = (pEVar6->_vectorDeque2)._offset;
|
|
}
|
|
uVar7 = (pEVar6->_vectorDeque2)._mapSize;
|
|
uVar3 = uVar7 * 2;
|
|
uVar5 = uVar3 - 1 & uVar5;
|
|
(pEVar6->_vectorDeque2)._offset = uVar5;
|
|
if (uVar5 == 0) {
|
|
uVar5 = uVar3;
|
|
}
|
|
uVar5 = uVar5 - 1;
|
|
local_10 = GHIDRA_CAST<uint32_t *>((uVar7 - 1 & uVar5 >> 1));
|
|
local_c = (pEVar6->_vectorDeque2)._map;
|
|
local_24 = GHIDRA_CAST<Entity_NPC *>(uVar5);
|
|
if (*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(local_c) + GHIDRA_INT(local_10) * 4)) == 0) {
|
|
newBlock = operator_new(0x10);
|
|
*(void **)(GHIDRA_INT((pEVar6->_vectorDeque2)._map) + GHIDRA_INT(local_10) * 4) = newBlock;
|
|
local_c = (pEVar6->_vectorDeque2)._map;
|
|
}
|
|
fVar8 = (pEVar6->_velocity).x;
|
|
posBlock = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(local_c) + GHIDRA_INT(local_10) * 4));
|
|
*GHIDRA_CAST<float *>((posBlock + 4 + (uVar5 & 1) * 8)) = (pEVar6->_velocity).y;
|
|
*GHIDRA_CAST<float *>((posBlock + (uVar5 & 1) * 8)) = fVar8;
|
|
puVar1 = &(pEVar6->_vectorDeque2)._size;
|
|
*puVar1 = *puVar1 + 1;
|
|
(pEVar6->_vectorDeque2)._offset = GHIDRA_UINT(local_24);
|
|
pEVar6->_groupIdx = formNpc->_groupIdx;
|
|
ANM2::LoadDeliriumForm(&pEVar6->_sprite,formNpc->_type,formNpc->_variant,1);
|
|
animData = (pEVar6->_sprite)._animState._animData;
|
|
local_24 = pEVar6;
|
|
if (animData == GHIDRA_CAST<uint8_t *>(0x0)) {
|
|
LAB_004a8acc:
|
|
bVar4 = ANM2::SetAnimation(&pEVar6->_sprite,GHIDRA_CAST<uint8_t *>("WalkBodyHori"),1);
|
|
if (bVar4 != 0) {
|
|
AnimationState::Rewind(&(pEVar6->_sprite)._animState);
|
|
(pEVar6->_sprite)._animState._isPlaying = 1;
|
|
}
|
|
}
|
|
else {
|
|
curAnimChar = animData;
|
|
if (0xf < *GHIDRA_CAST<uint32_t *>((animData + 0x14))) {
|
|
curAnimChar = *GHIDRA_CAST<uint8_t **>(animData);
|
|
}
|
|
expectedAnimChar = "WalkBodyHori";
|
|
do {
|
|
bVar4 = *curAnimChar;
|
|
isCharLess = bVar4 < (uint8_t)*expectedAnimChar;
|
|
if (bVar4 != *expectedAnimChar) {
|
|
LAB_004a8ab6:
|
|
uVar5 = -GHIDRA_UINT(isCharLess) | 1;
|
|
goto LAB_004a8abb;
|
|
}
|
|
if (bVar4 == 0) break;
|
|
bVar4 = curAnimChar[1];
|
|
isCharLess = bVar4 < (uint8_t)expectedAnimChar[1];
|
|
if (bVar4 != expectedAnimChar[1]) goto LAB_004a8ab6;
|
|
curAnimChar = curAnimChar + 2;
|
|
expectedAnimChar = expectedAnimChar + 2;
|
|
} while (bVar4 != 0);
|
|
uVar5 = 0;
|
|
LAB_004a8abb:
|
|
if ((uVar5 != 0) ||
|
|
((animData[0x34] != 0 && ((pEVar6->_sprite)._animState._isPlaying == 0))))
|
|
goto LAB_004a8acc;
|
|
}
|
|
(**(code **)(*GHIDRA_CAST<int *>(pEVar6) + 0xc))();
|
|
segmentIndex = (float)(GHIDRA_INT(segmentIndex) + 1);
|
|
npc = local_24;
|
|
pEVar6 = formNpc;
|
|
if (segmentCount < GHIDRA_INT(segmentIndex)) {
|
|
return;
|
|
}
|
|
} while( true );
|
|
}
|
|
}
|
|
else if (npc->_type == 0x10a) {
|
|
uVar5 = Random();
|
|
Game::Spawn(g_game,npc->_type,1,&npc->_pos,&g_vectorZero,GHIDRA_CAST<Entity *>(npc),0,uVar5);
|
|
uVar5 = Random();
|
|
Game::Spawn(g_game,npc->_type,2,&npc->_pos,&g_vectorZero,GHIDRA_CAST<Entity *>(npc),0,uVar5);
|
|
}
|
|
return;
|
|
}
|
|
|
|
// 004a8b70
|
|
void NpcHelper::delirium_fire_pattern(Entity_NPC *npc)
|
|
{
|
|
uint8_t bVar1;
|
|
int iVar2;
|
|
Entity *target;
|
|
int iVar3;
|
|
uint32_t uVar4;
|
|
uint8_t *animNameCh;
|
|
char *expectedNameCh;
|
|
char repeatByte;
|
|
uint32_t uVar5;
|
|
int iVar6;
|
|
bool bVar7;
|
|
float fVar8;
|
|
uint8_t auVar9 [16];
|
|
uint8_t auVar10 [16];
|
|
int fireInterval;
|
|
uint32_t keepPatternChance;
|
|
uint32_t patternId;
|
|
float altColorizeR;
|
|
Vector projVelocity;
|
|
uint64_t local_16c;
|
|
float local_164;
|
|
uint32_t repeatsLeft;
|
|
int burstCount;
|
|
float local_158;
|
|
uint32_t extraBulletFlags;
|
|
float colorizeB;
|
|
float colorizeG;
|
|
float colorizeR;
|
|
uint32_t local_144;
|
|
uint32_t local_140;
|
|
uint32_t attackAngle;
|
|
char isAlternating;
|
|
ProjectileParams projParams;
|
|
uint8_t local_9c;
|
|
uint8_t *local_98;
|
|
uint32_t local_94;
|
|
uint8_t local_90;
|
|
float angleTable [16];
|
|
int delayTable [17];
|
|
uint32_t local_8;
|
|
uint32_t attackId;
|
|
uint8_t *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<uint32_t *>((GHIDRA_CAST<char *>(&(auVar10)) + 0x4))) = iVar2 + 1;
|
|
(*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(auVar10)) + 0x0))) = iVar2;
|
|
(*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(auVar10)) + 0x8))) = iVar2 + 2;
|
|
(*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(auVar10)) + 0xc))) = iVar2 + 3;
|
|
auVar9 = pmulld(auVar10,_DAT_00bab470);
|
|
angleTable[iVar2] = (float)iVar2 * 3.1415927;
|
|
angleTable[iVar2 + 1] = (*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&((float)auVar10)) + 0x4))) * 3.1415927;
|
|
angleTable[iVar2 + 2] = (*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&((float)auVar10)) + 0x8))) * 3.1415927;
|
|
angleTable[iVar2 + 3] = (*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&((float)auVar10)) + 0xc))) * 3.1415927;
|
|
delayTable[iVar2] = GHIDRA_INT(((-GHIDRA_UINT(((*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(auVar9)) + 0x0))) < 0)) & 1) + (*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(auVar9)) + 0x0))))) >> 1;
|
|
delayTable[iVar2 + 1] = GHIDRA_INT(((-GHIDRA_UINT(((*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(auVar9)) + 0x4))) < 0)) & 1) + (*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(auVar9)) + 0x4))))) >> 1;
|
|
delayTable[iVar2 + 2] = GHIDRA_INT(((-GHIDRA_UINT(((*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(auVar9)) + 0x8))) < 0)) & 1) + (*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(auVar9)) + 0x8))))) >> 1;
|
|
delayTable[iVar2 + 3] = GHIDRA_INT(((-GHIDRA_UINT(((*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(auVar9)) + 0xc))) < 0)) & 1) + (*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(auVar9)) + 0xc))))) >> 1;
|
|
(*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(auVar9)) + 0x4))) = iVar2 + 5;
|
|
(*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(auVar9)) + 0x0))) = iVar2 + 4;
|
|
(*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(auVar9)) + 0x8))) = iVar2 + 6;
|
|
(*GHIDRA_CAST<uint32_t *>((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<uint32_t *>((GHIDRA_CAST<char *>(&((float)auVar9)) + 0x4))) * 3.1415927;
|
|
angleTable[iVar2 + 6] = (*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&((float)auVar9)) + 0x8))) * 3.1415927;
|
|
angleTable[iVar2 + 7] = (*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&((float)auVar9)) + 0xc))) * 3.1415927;
|
|
delayTable[iVar2 + 4] = GHIDRA_INT(((-GHIDRA_UINT(((*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(auVar10)) + 0x0))) < 0)) & 1) + (*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(auVar10)) + 0x0))))) >> 1;
|
|
delayTable[iVar2 + 5] = GHIDRA_INT(((-GHIDRA_UINT(((*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(auVar10)) + 0x4))) < 0)) & 1) + (*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(auVar10)) + 0x4))))) >> 1;
|
|
delayTable[iVar2 + 6] = GHIDRA_INT(((-GHIDRA_UINT(((*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(auVar10)) + 0x8))) < 0)) & 1) + (*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(auVar10)) + 0x8))))) >> 1;
|
|
delayTable[iVar2 + 7] = GHIDRA_INT(((-GHIDRA_UINT(((*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(auVar10)) + 0xc))) < 0)) & 1) + (*GHIDRA_CAST<uint32_t *>((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<uint32_t *>((GHIDRA_CAST<char *>(delayTable) + iVar6 + 0x18)) = *GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(delayTable) + iVar6));
|
|
fVar8 = (float)iVar2 * 1.0471976;
|
|
*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(delayTable) + iVar6 + 0x24)) = *GHIDRA_CAST<uint32_t *>((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 = Entity_NPC::GetPlayerTarget(npc);
|
|
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 = (uint64_t)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) {
|
|
(*GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>(&(projParams)) + 0x0))) = 1;
|
|
(*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(projParams)) + 0x4))) = 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;
|
|
(*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(projParams)) + 0x4))) = 0x40a00000;
|
|
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<uint32_t *>((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<uint32_t *>((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<uint32_t *>((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<uint32_t *>((GHIDRA_CAST<char *>(&(projParams.BulletFlags)) + 0x0))) = GHIDRA_UINT(projParams.BulletFlags) | 0x40000;
|
|
}
|
|
}
|
|
projParams.BulletFlags =
|
|
CONCAT44((*GHIDRA_CAST<uint32_t *>((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<uint8_t *>(0x0)) {
|
|
animNameCh = curAnimData;
|
|
if (0xf < *GHIDRA_CAST<uint32_t *>((curAnimData + 0x14))) {
|
|
animNameCh = *GHIDRA_CAST<uint8_t **>(curAnimData);
|
|
}
|
|
expectedNameCh = "Blink";
|
|
do {
|
|
bVar1 = *animNameCh;
|
|
bVar7 = bVar1 < (uint8_t)*expectedNameCh;
|
|
if (bVar1 != *expectedNameCh) {
|
|
LAB_004a9717:
|
|
uVar5 = -GHIDRA_UINT(bVar7) | 1;
|
|
goto LAB_004a971c;
|
|
}
|
|
if (bVar1 == 0) break;
|
|
bVar1 = animNameCh[1];
|
|
bVar7 = bVar1 < (uint8_t)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 = ANM2::SetAnimation(&npc->_sprite,GHIDRA_CAST<uint8_t *>("Blink"),1);
|
|
if (bVar1 != 0) {
|
|
AnimationState::Rewind(&(npc->_sprite)._animState);
|
|
(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<uint32_t *>(&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;
|
|
uint8_t isAnimSet;
|
|
uint32_t nextCycleCount;
|
|
int iVar2;
|
|
uint32_t uVar3;
|
|
uint32_t uVar4;
|
|
float fVar5;
|
|
float stepFraction;
|
|
double dVar6;
|
|
float fVar7;
|
|
uint8_t *anim;
|
|
float local_28;
|
|
float local_24;
|
|
uint32_t chanceDivisor;
|
|
float local_1c;
|
|
uint32_t aiUpdateCount;
|
|
int step;
|
|
float stepVelocityY;
|
|
float stepVelocityX;
|
|
uint32_t cycleTime;
|
|
uint32_t 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<uint8_t *>("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<uint8_t *>("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<uint8_t *>("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<uint8_t *>("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<uint8_t *>("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<uint8_t *>("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<uint8_t *>("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<uint8_t *>("Start and End parameters cannot be the same!"));
|
|
}
|
|
}
|
|
else if (local_1c == 0.0) {
|
|
KAGE_LogMessage(0x10,GHIDRA_CAST<uint8_t *>("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<uint8_t *>("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<uint8_t *>("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<uint8_t *>("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 = ANM2::SetAnimation(&npc->_sprite,anim,1);
|
|
if (isAnimSet != 0) {
|
|
AnimationState::Rewind(&(npc->_sprite)._animState);
|
|
(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<uint8_t *>("HeadlessAttack2");
|
|
}
|
|
}
|
|
else {
|
|
npc->_state = 8;
|
|
anim = s_Attack1;
|
|
if (npc->_i1 != 0) {
|
|
anim = GHIDRA_CAST<uint8_t *>("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)) {
|
|
AnimationState::Update(&(npc->_sprite)._animState);
|
|
AnimationState::Update(&(npc->_sprite)._overlayAnimState);
|
|
}
|
|
(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) {
|
|
AnimationState::Update(&(npc->_sprite)._animState);
|
|
AnimationState::Update(&(npc->_sprite)._overlayAnimState);
|
|
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;
|
|
uint32_t gridCollision;
|
|
GridEntity *stairs;
|
|
uint32_t uVar3;
|
|
RoomDescriptor *crawlspaceDesc;
|
|
RNG rng;
|
|
Room *local_18;
|
|
uint32_t local_14;
|
|
void *local_10;
|
|
uint8_t *puStack_c;
|
|
uint32_t local_8;
|
|
Game *game;
|
|
uint32_t *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;
|
|
RoomDescriptor::constructor(&g_roomDescriptorDummy);
|
|
_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;
|
|
Seeds::Init3(GHIDRA_CAST<Seeds *>(crawlspaceDesc),&rng);
|
|
local_18 = GHIDRA_CAST<Room *>(&g_game->_roomConfig);
|
|
local_14 = 0;
|
|
if (rng._seed == 0) {
|
|
KAGE_LogMessage(0x10,GHIDRA_CAST<uint8_t *>("RNG Seed is zero!\n"));
|
|
pcVar1 = (code *)swi(3);
|
|
(*pcVar1)();
|
|
return;
|
|
}
|
|
uVar3 = GHIDRA_UINT(rng._seed) >> ((uint8_t)rng._shift1 & 0x1f) ^ rng._seed;
|
|
uVar3 = uVar3 << ((uint8_t)rng._shift2 & 0x1f) ^ uVar3;
|
|
crawlspaceConfig =
|
|
RoomConfig::GetRandomRoom
|
|
(GHIDRA_CAST<RoomConfig *>(local_18),uVar3 >> ((uint8_t)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<uint8_t *>("SpawnGridEntity: Grid index invalid\n"));
|
|
}
|
|
pRVar2 = local_18;
|
|
if (uVar3 < 0x1c0) {
|
|
gridCollision = Room::GetGridCollision(local_18,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 {
|
|
GridEntity::GridEntity(stairs);
|
|
*GHIDRA_CAST<uint8_t ***>(stairs) = IsaacRepentancePlus::GridEntity_Stairs::vftable;
|
|
}
|
|
local_8 = 0xffffffff;
|
|
if (stairs != GHIDRA_CAST<GridEntity *>(0x0)) {
|
|
*GHIDRA_CAST<uint32_t *>(&(*GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>((stairs)) + 0x4)))) = 0x12;
|
|
stairs->_gridIndex = uVar3;
|
|
oldGridEntity = pRVar2->_gridEntities[uVar3];
|
|
if (oldGridEntity != GHIDRA_CAST<uint32_t *>(0x0)) {
|
|
(**(code **)*oldGridEntity)(1);
|
|
}
|
|
pRVar2->_gridEntities[uVar3] = stairs;
|
|
*GHIDRA_CAST<uint32_t *>(&(*GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>((stairs)) + 0x8)))) = 1;
|
|
stairs->_varData = 0;
|
|
GridEntity::Init(stairs,local_14);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
ExceptionList = local_10;
|
|
return;
|
|
}
|
|
|
|
// 004b1210
|
|
void NpcHelper::gideon_choose_attack(Entity_NPC *npc)
|
|
{
|
|
Entity_NPC *pEVar1;
|
|
RNG rng;
|
|
uint8_t *puVar2;
|
|
Entity_NPC *pEVar3;
|
|
uint8_t bVar4;
|
|
uint32_t *puVar5;
|
|
uint32_t uVar6;
|
|
int iVar7;
|
|
uint8_t *curAnimName;
|
|
uint32_t outcomeCount;
|
|
int iVar8;
|
|
uint8_t *wantedAnimName;
|
|
char *wantedAnimNameStr;
|
|
uint16_t newCooldown;
|
|
void *ptr;
|
|
bool isLess;
|
|
uint64_t uStack_40;
|
|
uint32_t uStack_38;
|
|
void *picker;
|
|
uint32_t *outcomesEnd;
|
|
uint32_t *outcomesCapacity;
|
|
float pitch;
|
|
uint32_t local_24;
|
|
uint8_t *puStack_20;
|
|
void *local_1c;
|
|
uint8_t *puStack_18;
|
|
uint32_t local_14;
|
|
uint8_t *animData;
|
|
uint32_t *attack4Cooldown;
|
|
Manager *manager;
|
|
Entity_NPC *parent;
|
|
int *weight;
|
|
|
|
puStack_20 = GHIDRA_CAST<uint8_t *>((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;
|
|
pEVar3 = GHIDRA_CAST<Entity_NPC *>(npc->_parent);
|
|
pEVar1 = npc;
|
|
while (parent = pEVar3, parent != GHIDRA_CAST<Entity_NPC *>(0x0)) {
|
|
pEVar1 = parent;
|
|
pEVar3 = GHIDRA_CAST<Entity_NPC *>(parent->_parent);
|
|
}
|
|
iVar7 = pEVar1->_child;
|
|
while (puVar2 = GHIDRA_CAST<uint8_t *>((GHIDRA_INT(register0x00000010) + -4)), iVar7 != 0) {
|
|
if ((pEVar1 != npc) && ((pEVar1->_state == 0xb || (pEVar1->_state == 7)))) {
|
|
uVar6 = Random();
|
|
attack4Cooldown = GHIDRA_CAST<uint32_t *>((GHIDRA_INT(&npc->_i2) + 2));
|
|
newCooldown = (short)(uVar6 % 0x96) + 0x5a;
|
|
uStack_38 = GHIDRA_UINT(newCooldown);
|
|
puVar5 = &uStack_38;
|
|
if (newCooldown <= *GHIDRA_CAST<uint16_t *>(attack4Cooldown)) {
|
|
puVar5 = attack4Cooldown;
|
|
}
|
|
*GHIDRA_CAST<uint16_t *>(attack4Cooldown) = (uint16_t)*puVar5;
|
|
puVar2 = puStack_20;
|
|
break;
|
|
}
|
|
pEVar1 = GHIDRA_CAST<Entity_NPC *>(pEVar1->_child);
|
|
iVar7 = pEVar1->_child;
|
|
}
|
|
puStack_20 = puVar2;
|
|
picker = (void *)0x0;
|
|
outcomesEnd = GHIDRA_CAST<uint32_t *>(0x0);
|
|
outcomesCapacity = GHIDRA_CAST<uint32_t *>(0x0);
|
|
local_14 = 0;
|
|
uStack_40 = (uint64_t)GHIDRA_UINT(uStack_40);
|
|
uStack_38 = 1;
|
|
msvc::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) + uVar6 * 8 + 4));
|
|
*weight = *weight + 1;
|
|
if (*weight < 0) {
|
|
*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(picker) + uVar6 * 8 + 4)) = 0;
|
|
}
|
|
goto LAB_004b137f;
|
|
}
|
|
uVar6 = uVar6 + 1;
|
|
} while (uVar6 < outcomeCount);
|
|
}
|
|
uStack_40 = CONCAT44(1,GHIDRA_UINT(uStack_40));
|
|
uStack_38 = 1;
|
|
if (outcomesEnd == outcomesCapacity) {
|
|
msvc::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) + uVar6 * 8 + 4));
|
|
*weight = *weight + 6;
|
|
if (*weight < 0) {
|
|
*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(picker) + uVar6 * 8 + 4)) = 0;
|
|
}
|
|
goto LAB_004b13f7;
|
|
}
|
|
uVar6 = uVar6 + 1;
|
|
} while (uVar6 < outcomeCount);
|
|
}
|
|
uStack_40 = CONCAT44(2,GHIDRA_UINT(uStack_40));
|
|
uStack_38 = 6;
|
|
if (outcomesEnd == outcomesCapacity) {
|
|
msvc::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) + uVar6 * 8 + 4));
|
|
*weight = *weight + 1;
|
|
if (*weight < 0) {
|
|
*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(picker) + uVar6 * 8 + 4)) = 0;
|
|
}
|
|
goto LAB_004b1488;
|
|
}
|
|
uVar6 = uVar6 + 1;
|
|
} while (uVar6 < outcomeCount);
|
|
}
|
|
uStack_40 = CONCAT44(3,GHIDRA_UINT(uStack_40));
|
|
uStack_38 = 1;
|
|
if (outcomesEnd == outcomesCapacity) {
|
|
msvc::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 *>((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<uint8_t *>(0x0)) {
|
|
LAB_004b152e:
|
|
bVar4 = ANM2::SetAnimation(&npc->_sprite,s_Attack1,1);
|
|
if (bVar4 != 0) {
|
|
AnimationState::Rewind(&(npc->_sprite)._animState);
|
|
(npc->_sprite)._animState._isPlaying = 1;
|
|
}
|
|
}
|
|
else {
|
|
curAnimName = animData;
|
|
if (0xf < *GHIDRA_CAST<uint32_t *>((animData + 0x14))) {
|
|
curAnimName = *GHIDRA_CAST<uint8_t **>(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<uint8_t *>(0x0)) {
|
|
LAB_004b162e:
|
|
bVar4 = ANM2::SetAnimation(&npc->_sprite,GHIDRA_CAST<uint8_t *>("Attack2Start"),1);
|
|
if (bVar4 != 0) {
|
|
AnimationState::Rewind(&(npc->_sprite)._animState);
|
|
(npc->_sprite)._animState._isPlaying = 1;
|
|
}
|
|
}
|
|
else {
|
|
curAnimName = animData;
|
|
if (0xf < *GHIDRA_CAST<uint32_t *>((animData + 0x14))) {
|
|
curAnimName = *GHIDRA_CAST<uint8_t **>(animData);
|
|
}
|
|
wantedAnimNameStr = "Attack2Start";
|
|
do {
|
|
bVar4 = *curAnimName;
|
|
isLess = bVar4 < (uint8_t)*wantedAnimNameStr;
|
|
if (bVar4 != *wantedAnimNameStr) {
|
|
LAB_004b1610:
|
|
uVar6 = -GHIDRA_UINT(isLess) | 1;
|
|
goto LAB_004b1615;
|
|
}
|
|
if (bVar4 == 0) break;
|
|
bVar4 = curAnimName[1];
|
|
isLess = bVar4 < (uint8_t)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<uint16_t *>(&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<uint8_t *>(0x0)) {
|
|
LAB_004b177e:
|
|
bVar4 = ANM2::SetAnimation(&npc->_sprite,&DAT_00b1d2e4,1);
|
|
if (bVar4 != 0) {
|
|
AnimationState::Rewind(&(npc->_sprite)._animState);
|
|
(npc->_sprite)._animState._isPlaying = 1;
|
|
}
|
|
}
|
|
else {
|
|
curAnimName = animData;
|
|
if (0xf < *GHIDRA_CAST<uint32_t *>((animData + 0x14))) {
|
|
curAnimName = *GHIDRA_CAST<uint8_t **>(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<uint8_t *>((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<uint8_t *>(0x0)) {
|
|
LAB_004b1874:
|
|
bVar4 = ANM2::SetAnimation(&npc->_sprite,GHIDRA_CAST<uint8_t *>("Attack4Start"),1);
|
|
if (bVar4 != 0) {
|
|
AnimationState::Rewind(&(npc->_sprite)._animState);
|
|
(npc->_sprite)._animState._isPlaying = 1;
|
|
}
|
|
}
|
|
else {
|
|
curAnimName = animData;
|
|
if (0xf < *GHIDRA_CAST<uint32_t *>((animData + 0x14))) {
|
|
curAnimName = *GHIDRA_CAST<uint8_t **>(animData);
|
|
}
|
|
wantedAnimNameStr = "Attack4Start";
|
|
do {
|
|
bVar4 = *curAnimName;
|
|
isLess = bVar4 < (uint8_t)*wantedAnimNameStr;
|
|
if (bVar4 != *wantedAnimNameStr) {
|
|
LAB_004b1856:
|
|
uVar6 = -GHIDRA_UINT(isLess) | 1;
|
|
goto LAB_004b185b;
|
|
}
|
|
if (bVar4 == 0) break;
|
|
bVar4 = curAnimName[1];
|
|
isLess = bVar4 < (uint8_t)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<uint16_t *>((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 != (void *)0x0) {
|
|
uVar6 = GHIDRA_INT(outcomesCapacity) - GHIDRA_INT(picker) & 0xfffffff8;
|
|
ptr = picker;
|
|
if (0xfff < uVar6) {
|
|
ptr = *(void **)(GHIDRA_CAST<char *>(picker) + -4);
|
|
uVar6 = uVar6 + 0x23;
|
|
if (0x1f < GHIDRA_UINT((GHIDRA_INT(picker) + (-4 - GHIDRA_INT(ptr))))) {
|
|
/* WARNING: Subroutine does not return */
|
|
_invalid_parameter_noinfo_noreturn();
|
|
}
|
|
}
|
|
operator_delete(ptr,uVar6);
|
|
}
|
|
ExceptionList = local_1c;
|
|
return;
|
|
}
|
|
|
|
// 004b1910
|
|
void NpcHelper::gideon_spawn_wave()
|
|
{
|
|
code *pcVar1;
|
|
uint32_t spawnVariant;
|
|
uint32_t stageType;
|
|
void **gridEntityCursor;
|
|
int gridX;
|
|
uint32_t *nextEntry;
|
|
int iVar3;
|
|
uint32_t *puVar4;
|
|
short *roomSpawn;
|
|
uint32_t uVar5;
|
|
uint32_t in_stack_ffffff38;
|
|
int in_stack_ffffff3c;
|
|
Vector local_9c;
|
|
uint64_t local_90;
|
|
Vector local_84;
|
|
uint32_t pitCount;
|
|
uint32_t waveDifficulty;
|
|
uint32_t *entriesCapacityEnd;
|
|
void *gideon;
|
|
uint32_t *entriesBegin;
|
|
uint32_t *entriesEnd;
|
|
uint32_t *local_64;
|
|
uint32_t local_60;
|
|
int local_5c;
|
|
uint32_t local_58;
|
|
Room *room;
|
|
uint32_t *local_50;
|
|
Game *local_4c;
|
|
uint32_t spawnEntry;
|
|
uint32_t uStack_44;
|
|
uint32_t local_40 [8];
|
|
uint8_t *puStack_20;
|
|
void *local_1c;
|
|
uint8_t *puStack_18;
|
|
uint32_t local_14;
|
|
Game *game;
|
|
Manager *manager;
|
|
float maxHitPoints;
|
|
uint16_t spawnVariant;
|
|
|
|
puStack_20 = GHIDRA_CAST<uint8_t *>((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<uint32_t *>((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<uint32_t *>((GHIDRA_CAST<char *>(this) + 0x3dc));
|
|
gideon = this;
|
|
puVar4 = local_40 + 0xf;
|
|
if (spawnVariant == 0) {
|
|
KAGE_LogMessage(0x10,GHIDRA_CAST<uint8_t *>("RNG Seed is zero!\n"));
|
|
spawnVariant = *GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(this) + 0x3dc));
|
|
local_4c = g_game;
|
|
puVar4 = GHIDRA_CAST<uint32_t *>(puStack_20);
|
|
if (spawnVariant == 0) {
|
|
pcVar1 = (code *)swi(3);
|
|
(*pcVar1)();
|
|
return;
|
|
}
|
|
}
|
|
puStack_20 = GHIDRA_CAST<uint8_t *>(puVar4);
|
|
local_4c = g_game;
|
|
spawnVariant = spawnVariant >> ((uint8_t)*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(this) + 0x3e0)) & 0x1f) ^ spawnVariant;
|
|
local_90 = 0x900000005;
|
|
spawnVariant = spawnVariant << ((uint8_t)*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(this) + 0x3e4)) & 0x1f) ^ spawnVariant;
|
|
spawnVariant = spawnVariant >> ((uint8_t)*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(this) + 1000)) & 0x1f) ^ spawnVariant;
|
|
local_5c = 7;
|
|
*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(this) + 0x3dc)) = spawnVariant;
|
|
puVar4 = GHIDRA_CAST<uint32_t *>(0x0);
|
|
local_50 = GHIDRA_CAST<uint32_t *>(0x0);
|
|
entriesBegin = GHIDRA_CAST<uint32_t *>(0x0);
|
|
entriesEnd = GHIDRA_CAST<uint32_t *>(0x0);
|
|
entriesCapacityEnd = GHIDRA_CAST<uint32_t *>(0x0);
|
|
local_64 = GHIDRA_CAST<uint32_t *>(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)Room::GetRoomShape(room);
|
|
if (local_4c->_challenge == 0x2c) {
|
|
stageType = Level::GetRoomStageType(GHIDRA_CAST<Level *>(local_4c),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<uint8_t *>("RNG Seed is zero!\n"));
|
|
pcVar1 = (code *)swi(3);
|
|
(*pcVar1)();
|
|
return;
|
|
}
|
|
spawnVariant = spawnVariant >> ((uint8_t)local_90 & 0x1f) ^ spawnVariant;
|
|
spawnVariant = spawnVariant << ((uint8_t)((uint64_t)local_90 >> 0x20) & 0x1f) ^ spawnVariant;
|
|
spawnVariant = spawnVariant >> ((uint8_t)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<uint8_t *>("No enemy wave found for Gideon (difficulty: %d)\n"));
|
|
}
|
|
local_60 = 0;
|
|
if ((short)*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(local_4c) + 0x44)) != 0) {
|
|
local_50 = GHIDRA_CAST<uint32_t *>(0x0);
|
|
do {
|
|
roomSpawn = GHIDRA_CAST<short *>((*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(local_4c) + 0x40)) + GHIDRA_INT(local_50)));
|
|
if (spawnVariant == 0) {
|
|
KAGE_LogMessage(0x10,GHIDRA_CAST<uint8_t *>("RNG Seed is zero!\n"));
|
|
pcVar1 = (code *)swi(3);
|
|
(*pcVar1)();
|
|
return;
|
|
}
|
|
spawnVariant = spawnVariant >> ((uint8_t)local_90 & 0x1f) ^ spawnVariant;
|
|
spawnVariant = spawnVariant << ((uint8_t)((uint64_t)local_90 >> 0x20) & 0x1f) ^ spawnVariant;
|
|
spawnVariant = spawnVariant >> ((uint8_t)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<uint8_t *>("RNG Seed is zero!\n"));
|
|
pcVar1 = (code *)swi(3);
|
|
(*pcVar1)();
|
|
return;
|
|
}
|
|
spawnVariant = spawnVariant >> ((uint8_t)local_90 & 0x1f) ^ spawnVariant;
|
|
spawnVariant = spawnVariant << ((uint8_t)((uint64_t)local_90 >> 0x20) & 0x1f) ^ spawnVariant;
|
|
spawnVariant = spawnVariant >> ((uint8_t)local_5c & 0x1f) ^ spawnVariant;
|
|
Room::TransformEntry(room,&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) {
|
|
msvc::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<uint32_t *>((GHIDRA_INT(local_50) + 0x10));
|
|
} while (local_60 < (uint16_t)*GHIDRA_CAST<uint32_t *>((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<uint32_t *>((GHIDRA_CAST<char *>(local_4c) + -4))) % room->_gridWidth) * 40.0 + 40.0;
|
|
local_84.y = (float)(GHIDRA_INT(*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(local_4c) + -4))) / room->_gridWidth) * 40.0 + 120.0;
|
|
Room::FindFreeTilePosition(room,&local_9c,&local_84,0.0);
|
|
if (spawnVariant == 0) {
|
|
KAGE_LogMessage(0x10,GHIDRA_CAST<uint8_t *>("RNG Seed is zero!\n"));
|
|
pcVar1 = (code *)swi(3);
|
|
(*pcVar1)();
|
|
return;
|
|
}
|
|
spawnVariant = spawnVariant >> ((uint8_t)local_90 & 0x1f) ^ spawnVariant;
|
|
spawnVariant = spawnVariant << ((uint8_t)((uint64_t)local_90 >> 0x20) & 0x1f) ^ spawnVariant;
|
|
spawnVariant = spawnVariant >> ((uint8_t)local_5c & 0x1f) ^ spawnVariant;
|
|
spawnVariant = (uint16_t)*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(local_4c) + 4));
|
|
iVar3 = spawn_enemy_spawner_effect
|
|
(*GHIDRA_CAST<uint32_t *>(local_4c),spawnVariant,&local_9c,spawnVariant,gideon,
|
|
*GHIDRA_CAST<uint16_t *>((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<uint32_t *>(local_4c) == 1)) || (*GHIDRA_CAST<uint32_t *>(local_4c) - 10 < 0x3de)) {
|
|
*GHIDRA_CAST<uint32_t *>((iVar3 + 0x16c)) = *GHIDRA_CAST<uint32_t *>((iVar3 + 0x16c)) | 0x80;
|
|
*GHIDRA_CAST<uint32_t *>((iVar3 + 0x168)) = *GHIDRA_CAST<uint32_t *>((iVar3 + 0x168));
|
|
}
|
|
nextEntry = GHIDRA_CAST<uint32_t *>((GHIDRA_INT(local_4c) + 0x10));
|
|
puVar4 = GHIDRA_CAST<uint32_t *>((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<uint8_t *>((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<uint8_t *>((GHIDRA_CAST<char *>(&((game->_hud))) + 0x54ba)))) = (short)GHIDRA_INT(maxHitPoints);
|
|
if (local_50 != GHIDRA_CAST<uint32_t *>(0x0)) {
|
|
spawnVariant = GHIDRA_INT(entriesCapacityEnd) - GHIDRA_INT(local_50) & 0xfffffff0;
|
|
puVar4 = local_50;
|
|
if (0xfff < spawnVariant) {
|
|
puVar4 = GHIDRA_CAST<uint32_t *>(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;
|
|
uint8_t bVar3;
|
|
ColorMod *color;
|
|
Entity *explosion;
|
|
ColorMod *color_00;
|
|
Color *pCVar4;
|
|
int *gridSlot;
|
|
uint32_t uVar5;
|
|
int gridSize;
|
|
int unusedInt;
|
|
uint8_t auStack_4c [7];
|
|
uint8_t isDeathAnim;
|
|
int soundId;
|
|
float eventPitch;
|
|
float pitch;
|
|
Color local_38;
|
|
uint32_t 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<msvc::string *>((GHIDRA_CAST<char *>(&local_38))))->msvc::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<uint8_t *>(pCVar4),GHIDRA_UINT(local_38._colorize[0]),GHIDRA_CAST<uint8_t *>("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<uint8_t *>(0x1f) < GHIDRA_CAST<uint8_t *>((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 = AnimationState::IsEventTriggered(&(npc->_sprite)._animState,GHIDRA_CAST<uint8_t *>("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 = Game::SpawnEx(g_game,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;
|
|
Game::ShakeScreen(game,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<uint32_t *>((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)
|
|
{
|
|
uint8_t bVar1;
|
|
Entity *afterimage;
|
|
uint8_t *afterimageAnimChar;
|
|
uint32_t uVar2;
|
|
LayerState *afterimageLayer;
|
|
LayerState *npcLayer;
|
|
uint8_t *****animNameData;
|
|
uint8_t *****animNameChar;
|
|
bool isLess;
|
|
uint32_t local_38;
|
|
uint8_t *****animName [4];
|
|
uint32_t animNameSize;
|
|
uint32_t animNameCapacity;
|
|
uint32_t securityCookie;
|
|
void *local_10;
|
|
uint8_t *puStack_c;
|
|
uint8_t ****local_8;
|
|
uint32_t flagsHi;
|
|
void *npcAnimData;
|
|
|
|
local_8 = GHIDRA_CAST<uint8_t ****>(0xffffffff);
|
|
puStack_c = &LAB_00af32ed;
|
|
local_10 = ExceptionList;
|
|
securityCookie = __security_cookie ^ GHIDRA_UINT((animName + 10));
|
|
ExceptionList = &local_10;
|
|
afterimage = Game::Spawn(g_game,0x389,0,&npc->_pos,&npc->_velocity,GHIDRA_CAST<Entity *>(npc),
|
|
(npc->_state == 0xb) + 1,npc->_initSeed);
|
|
flagsHi = *GHIDRA_CAST<uint32_t *>((GHIDRA_INT(&npc->_flags) + 4));
|
|
*GHIDRA_CAST<int *>(&afterimage->_flags) = GHIDRA_INT(npc->_flags);
|
|
*GHIDRA_CAST<uint32_t *>((GHIDRA_INT(&afterimage->_flags) + 4)) = flagsHi;
|
|
FUN_004b6b20((afterimage->_colorParams)._begin,(npc->_colorParams)._begin,(npc->_colorParams)._end
|
|
,local_38);
|
|
flagsHi = *GHIDRA_CAST<uint32_t *>((GHIDRA_INT(&afterimage->_flags) + 4));
|
|
*GHIDRA_CAST<uint32_t *>(&afterimage->_flags) = GHIDRA_UINT(afterimage->_flags) | 0x11;
|
|
afterimage->_isInvicible = 1;
|
|
*GHIDRA_CAST<uint32_t *>((GHIDRA_INT(&afterimage->_flags) + 4)) = flagsHi;
|
|
npcAnimData = (npc->_sprite)._animState._animData;
|
|
if (npcAnimData == (void *)0x0) {
|
|
animNameCapacity = 0xf;
|
|
animNameSize = 0;
|
|
animName[0] = GHIDRA_CAST<uint8_t *****>(0x0);
|
|
}
|
|
else {
|
|
(GHIDRA_CAST<msvc::string *>((GHIDRA_CAST<char *>(animName))))->msvc::string::string(npcAnimData);
|
|
}
|
|
local_8 = GHIDRA_CAST<uint8_t ****>(0x0);
|
|
animNameData = GHIDRA_CAST<uint8_t *****>(animName);
|
|
if (0xf < animNameCapacity) {
|
|
animNameData = animName[0];
|
|
}
|
|
afterimageAnimChar = (afterimage->_sprite)._animState._animData;
|
|
if (afterimageAnimChar != GHIDRA_CAST<uint8_t *>(0x0)) {
|
|
if (0xf < *GHIDRA_CAST<uint32_t *>((afterimageAnimChar + 0x14))) {
|
|
afterimageAnimChar = *GHIDRA_CAST<uint8_t **>(afterimageAnimChar);
|
|
}
|
|
animNameChar = animNameData;
|
|
do {
|
|
bVar1 = *afterimageAnimChar;
|
|
isLess = bVar1 < *GHIDRA_CAST<uint8_t *>(animNameChar);
|
|
if (bVar1 != *GHIDRA_CAST<uint8_t *>(animNameChar)) {
|
|
LAB_004b3c27:
|
|
uVar2 = -GHIDRA_UINT(isLess) | 1;
|
|
goto LAB_004b3c2c;
|
|
}
|
|
if (bVar1 == 0) break;
|
|
bVar1 = afterimageAnimChar[1];
|
|
isLess = bVar1 < *GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>(animNameChar) + 1));
|
|
if (bVar1 != *GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>(animNameChar) + 1))) goto LAB_004b3c27;
|
|
afterimageAnimChar = afterimageAnimChar + 2;
|
|
animNameChar = GHIDRA_CAST<uint8_t *****>((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 = ANM2::SetAnimation(&afterimage->_sprite,GHIDRA_CAST<uint8_t *>(animNameData),1);
|
|
if (bVar1 != 0) {
|
|
AnimationState::Rewind(&(afterimage->_sprite)._animState);
|
|
(afterimage->_sprite)._animState._isPlaying = 1;
|
|
}
|
|
LAB_004b3c68:
|
|
local_8 = GHIDRA_CAST<uint8_t ****>(0xffffffff);
|
|
if (0xf < animNameCapacity) {
|
|
uVar2 = animNameCapacity + 1;
|
|
animNameData = animName[0];
|
|
if (0xfff < uVar2) {
|
|
animNameData = GHIDRA_CAST<uint8_t *****>(animName[0][-1]);
|
|
uVar2 = animNameCapacity + 0x24;
|
|
if (GHIDRA_CAST<uint8_t *>(0x1f) < GHIDRA_CAST<uint8_t *>((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<uint8_t *****>((GHIDRA_UINT(animName[0]) & 0xffffff00));
|
|
if ((afterimage->_sprite)._animState._animData != (void *)0x0) {
|
|
AnimationState::SetFrameFloat
|
|
(&(afterimage->_sprite)._animState,(npc->_sprite)._animState._animFrame);
|
|
}
|
|
afterimageLayer = ANM2::GetLayer(&afterimage->_sprite,GHIDRA_CAST<uint8_t *>(0x0));
|
|
npcLayer = ANM2::GetLayer(&npc->_sprite,GHIDRA_CAST<uint8_t *>(0x0));
|
|
(afterimageLayer->_color)._tint[3] = (npcLayer->_color)._tint[3];
|
|
afterimage->_entityGridCollisionClass = 0;
|
|
afterimage->_entityCollisionClass = 0;
|
|
afterimage[2]._preInterpolatePos.x = 1.82169e-44;
|
|
*GHIDRA_CAST<uint8_t *>((GHIDRA_INT(&afterimage[2]._health) + 2)) =
|
|
*GHIDRA_CAST<uint8_t *>((GHIDRA_INT(&npc->_projectileCooldown) + 2));
|
|
*GHIDRA_CAST<uint16_t *>((afterimage + 1)) = 0;
|
|
afterimage->_health = 0.0;
|
|
afterimage->_maxHitPoints = 0.0;
|
|
(**(code **)(*GHIDRA_CAST<int *>(afterimage) + 0xc))();
|
|
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;
|
|
uint32_t uVar2;
|
|
uint32_t outcomeCount;
|
|
void *pvVar3;
|
|
uint32_t *outcomesCursor;
|
|
float halfHealth;
|
|
uint64_t uStack_44;
|
|
uint32_t uStack_3c;
|
|
uint32_t *local_38;
|
|
Entity_NPC *npcLocal;
|
|
void *outcomes;
|
|
uint32_t *outcomesEnd;
|
|
uint32_t *outcomesCapacityEnd;
|
|
uint32_t local_24;
|
|
uint8_t *puStack_20;
|
|
void *local_1c;
|
|
uint8_t *puStack_18;
|
|
uint32_t local_14;
|
|
int *weight;
|
|
|
|
puStack_20 = GHIDRA_CAST<uint8_t *>((GHIDRA_INT(register0x00000010) + -4));
|
|
puStack_18 = &LAB_00af332d;
|
|
local_1c = ExceptionList;
|
|
local_24 = __security_cookie ^ GHIDRA_INT(register0x00000010) - 0x10U;
|
|
ExceptionList = &local_1c;
|
|
outcomes = (void *)0x0;
|
|
outcomesEnd = GHIDRA_CAST<uint32_t *>(0x0);
|
|
outcomesCapacityEnd = GHIDRA_CAST<uint32_t *>(0x0);
|
|
local_14 = 0;
|
|
npcLocal = npc;
|
|
local_38 = GHIDRA_CAST<uint32_t *>(heretic_count_out_fires());
|
|
pvVar3 = (void *)0x0;
|
|
outcomesCursor = GHIDRA_CAST<uint32_t *>(0x0);
|
|
if (*GHIDRA_CAST<char *>((GHIDRA_INT(&npcLocal->_projectileDelay) + 1)) < '\x01') {
|
|
uStack_44 = CONCAT44(0xe,(uint32_t)uStack_44);
|
|
uStack_3c = 10;
|
|
msvc::vector<8byte>::_Emplace_reallocate(0,GHIDRA_INT(&uStack_44) + 4);
|
|
pvVar3 = outcomes;
|
|
outcomesCursor = outcomesEnd;
|
|
}
|
|
if (*GHIDRA_CAST<char *>((GHIDRA_INT(&npcLocal->_projectileDelay) + 2)) < '\x01') {
|
|
uVar2 = 0;
|
|
outcomeCount = GHIDRA_INT(outcomesCursor) - GHIDRA_INT(pvVar3) >> 3;
|
|
if (outcomeCount != 0) {
|
|
do {
|
|
if (*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(pvVar3) + uVar2 * 8)) == 9) {
|
|
weight = GHIDRA_CAST<int *>((GHIDRA_INT(pvVar3) + uVar2 * 8 + 4));
|
|
*weight = *weight + 10;
|
|
if (*weight < 0) {
|
|
*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(pvVar3) + uVar2 * 8 + 4)) = 0;
|
|
}
|
|
goto LAB_004b41d2;
|
|
}
|
|
uVar2 = uVar2 + 1;
|
|
} while (uVar2 < outcomeCount);
|
|
}
|
|
uStack_44 = CONCAT44(9,(uint32_t)uStack_44);
|
|
uStack_3c = 10;
|
|
if (outcomesCursor == outcomesCapacityEnd) {
|
|
msvc::vector<8byte>::_Emplace_reallocate(outcomesCursor,GHIDRA_INT(&uStack_44) + 4);
|
|
pvVar3 = 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<uint32_t *>(0x2) < local_38) {
|
|
uVar2 = 0;
|
|
outcomeCount = GHIDRA_INT(outcomesCursor) - GHIDRA_INT(pvVar3) >> 3;
|
|
if (outcomeCount != 0) {
|
|
do {
|
|
if (*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(pvVar3) + uVar2 * 8)) == 7) {
|
|
weight = GHIDRA_CAST<int *>((GHIDRA_INT(pvVar3) + uVar2 * 8 + 4));
|
|
*weight = *weight + 10;
|
|
if (*weight < 0) {
|
|
*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(pvVar3) + uVar2 * 8 + 4)) = 0;
|
|
}
|
|
goto LAB_004b4249;
|
|
}
|
|
uVar2 = uVar2 + 1;
|
|
} while (uVar2 < outcomeCount);
|
|
}
|
|
uStack_44 = CONCAT44(7,(uint32_t)uStack_44);
|
|
uStack_3c = 10;
|
|
if (outcomesCursor == outcomesCapacityEnd) {
|
|
msvc::vector<8byte>::_Emplace_reallocate(outcomesCursor,GHIDRA_INT(&uStack_44) + 4);
|
|
pvVar3 = outcomes;
|
|
outcomesCursor = outcomesEnd;
|
|
}
|
|
else {
|
|
*outcomesCursor = 7;
|
|
outcomesCursor[1] = 10;
|
|
outcomesEnd = outcomesCursor + 2;
|
|
outcomesCursor = outcomesEnd;
|
|
}
|
|
}
|
|
}
|
|
LAB_004b4249:
|
|
uVar2 = 0;
|
|
outcomeCount = GHIDRA_INT(outcomesCursor) - GHIDRA_INT(pvVar3) >> 3;
|
|
if (outcomeCount != 0) {
|
|
do {
|
|
if (*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(pvVar3) + uVar2 * 8)) == 3) {
|
|
weight = GHIDRA_CAST<int *>((GHIDRA_INT(pvVar3) + uVar2 * 8 + 4));
|
|
*weight = *weight + 1;
|
|
if (*weight < 0) {
|
|
*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(pvVar3) + uVar2 * 8 + 4)) = 0;
|
|
}
|
|
goto LAB_004b42a6;
|
|
}
|
|
uVar2 = uVar2 + 1;
|
|
} while (uVar2 < outcomeCount);
|
|
}
|
|
uStack_44 = CONCAT44(3,(uint32_t)uStack_44);
|
|
uStack_3c = 1;
|
|
if (outcomesCursor == outcomesCapacityEnd) {
|
|
msvc::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 *>((GHIDRA_CAST<WeightedOutcomePicker *>(&outcomes))))->WeightedOutcomePicker::PickOutcome(rng);
|
|
pEVar1 = npcLocal;
|
|
if (uVar2 == 3) {
|
|
*GHIDRA_CAST<uint16_t *>((GHIDRA_INT(&npcLocal->_stateFrame) + 2)) = 0;
|
|
}
|
|
else {
|
|
*GHIDRA_CAST<uint16_t *>(&npcLocal->_stateFrame) = 0xffff;
|
|
npcLocal->_state = uVar2;
|
|
if (uVar2 == 7) {
|
|
Entity_NPC::ClearDequeRefs(npcLocal);
|
|
if (pEVar1->_child != 0) {
|
|
local_38 = &pEVar1->_child;
|
|
msvc::multiset<unsigned_int>::erase(&local_38);
|
|
}
|
|
halfHealth = pEVar1->_maxHitPoints * 0.5;
|
|
pEVar1->_child = 0;
|
|
*GHIDRA_CAST<char *>(&pEVar1->_projectileCooldown) =
|
|
(pEVar1->_health <= halfHealth && halfHealth != pEVar1->_health) + '\x05';
|
|
}
|
|
*GHIDRA_CAST<uint8_t *>((GHIDRA_INT(&pEVar1->_projectileCooldown) + 1)) = 0;
|
|
}
|
|
if (outcomes != (void *)0x0) {
|
|
uVar2 = GHIDRA_INT(outcomesCapacityEnd) - GHIDRA_INT(outcomes) & 0xfffffff8;
|
|
pvVar3 = outcomes;
|
|
if (0xfff < uVar2) {
|
|
pvVar3 = *(void **)(GHIDRA_CAST<char *>(outcomes) + -4);
|
|
uVar2 = uVar2 + 0x23;
|
|
if (0x1f < GHIDRA_UINT((GHIDRA_INT(outcomes) + (-4 - GHIDRA_INT(pvVar3))))) {
|
|
/* WARNING: Subroutine does not return */
|
|
_invalid_parameter_noinfo_noreturn();
|
|
}
|
|
}
|
|
operator_delete(pvVar3,uVar2);
|
|
}
|
|
ExceptionList = local_1c;
|
|
return;
|
|
}
|
|
|
|
// 004b70c0
|
|
void NpcHelper::hornfel_spawn_doors()
|
|
{
|
|
RailManager *this;
|
|
Entity *pEVar1;
|
|
uint8_t isCanStep;
|
|
uint32_t uVar2;
|
|
int iVar3;
|
|
int iVar4;
|
|
uint32_t seed;
|
|
uint32_t startIndex;
|
|
Room *toIndex;
|
|
Room *room;
|
|
int iVar5;
|
|
Room *pRVar6;
|
|
int *piVar7;
|
|
float fVar8;
|
|
float fVar9;
|
|
int *doors;
|
|
int *doorsEnd;
|
|
Vector spawnPos;
|
|
Vector leftSpawnPos;
|
|
Room *local_2c;
|
|
Entity *local_28;
|
|
Entity *local_24;
|
|
Room *local_20;
|
|
int local_1c;
|
|
Entity *local_18;
|
|
int *doorsCapacity;
|
|
void *local_10;
|
|
uint8_t *puStack_c;
|
|
uint32_t local_8;
|
|
|
|
puStack_c = &LAB_00af336d;
|
|
local_10 = ExceptionList;
|
|
uVar2 = __security_cookie ^ GHIDRA_INT(register0x00000010) - 4U;
|
|
ExceptionList = &local_10;
|
|
doors = GHIDRA_CAST<int *>(0x0);
|
|
doorsEnd = GHIDRA_CAST<int *>(0x0);
|
|
doorsCapacity = GHIDRA_CAST<int *>(0x0);
|
|
room = g_game->_room;
|
|
local_20 = GHIDRA_CAST<Room *>(room->_gridWidth);
|
|
local_1c = room->_gridHeight;
|
|
local_8 = 0;
|
|
iVar5 = 1;
|
|
local_2c = room;
|
|
if (1 < local_1c + -1) {
|
|
local_28 = GHIDRA_CAST<Entity *>(&(*GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>(&(local_20[-1])) + 0x7896))));
|
|
do {
|
|
fVar9 = 120.0;
|
|
fVar8 = 40.0;
|
|
iVar4 = room->_gridWidth;
|
|
if ((iVar4 < 1) || (room->_gridHeight <= iVar5)) {
|
|
iVar3 = -1;
|
|
}
|
|
else {
|
|
iVar3 = iVar4 * iVar5;
|
|
}
|
|
local_18 = GHIDRA_CAST<Entity *>((iVar4 * iVar5));
|
|
if ((iVar4 < 2) || (room->_gridHeight <= iVar5)) {
|
|
iVar4 = -1;
|
|
}
|
|
else {
|
|
iVar4 = GHIDRA_INT(local_18) + 1;
|
|
}
|
|
isCanStep = (GHIDRA_CAST<RoomGridPath *>((&room->_railManager)))->RoomGridPath::can_step(iVar4,iVar3);
|
|
if (isCanStep != 0) {
|
|
if ((room->_gridWidth < 1) || (room->_gridHeight <= iVar5)) {
|
|
local_18 = GHIDRA_CAST<Entity *>(0xffffffff);
|
|
}
|
|
iVar4 = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(g_game->_room) + 0xc));
|
|
leftSpawnPos.x = (float)(GHIDRA_INT(local_18) % iVar4) * fVar8 + fVar8;
|
|
leftSpawnPos.y = (float)(GHIDRA_INT(local_18) / iVar4) * fVar8 + fVar9;
|
|
seed = Random();
|
|
local_24 = Game::Spawn(g_game,0x3c7,0,&leftSpawnPos,&g_vectorZero,GHIDRA_CAST<Entity *>(0x0),0,seed);
|
|
(local_24->_sprite)._rotation = -90.0;
|
|
local_18 = GHIDRA_CAST<Entity *>(cos(-1.5707964));
|
|
fVar8 = sin(-1.5707964);
|
|
(local_24->_sprite)._offset.x = (float)local_18 * 0.0 - fVar8 * 15.0;
|
|
(local_24->_sprite)._offset.y = fVar8 * 0.0 + (float)local_18 * 15.0;
|
|
if (doorsEnd == doorsCapacity) {
|
|
msvc::vector<unsigned_int>::_Emplace_reallocate(doorsEnd,&local_24);
|
|
doorsCapacity = GHIDRA_CAST<int *>(0x0);
|
|
}
|
|
else {
|
|
*doorsEnd = GHIDRA_INT(local_24);
|
|
doorsEnd = doorsEnd + 1;
|
|
}
|
|
fVar9 = 120.0;
|
|
fVar8 = 40.0;
|
|
}
|
|
if (((GHIDRA_INT(&(*GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>(&(local_20[-1])) + 0x7897)))) < 0) ||
|
|
(room->_gridWidth <= GHIDRA_INT(&(*GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>(&(local_20[-1])) + 0x7897)))))) || (room->_gridHeight <= iVar5)) {
|
|
iVar4 = -1;
|
|
}
|
|
else {
|
|
iVar4 = GHIDRA_INT(local_20->_gridEntities) + room->_gridWidth * iVar5 + -0x25;
|
|
}
|
|
if (((GHIDRA_INT(&(*GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>(&(local_20[-1])) + 0x7896)))) < 0) || (room->_gridWidth <= GHIDRA_INT(local_28))) ||
|
|
(room->_gridHeight <= iVar5)) {
|
|
iVar3 = -1;
|
|
}
|
|
else {
|
|
iVar3 = GHIDRA_INT(local_20->_gridEntities) + room->_gridWidth * iVar5 + -0x26;
|
|
}
|
|
isCanStep = (GHIDRA_CAST<RoomGridPath *>((&room->_railManager)))->RoomGridPath::can_step(iVar3,iVar4);
|
|
if (isCanStep != 0) {
|
|
if (((GHIDRA_INT(&(*GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>(&(local_20[-1])) + 0x7897)))) < 0) ||
|
|
(room->_gridWidth <= GHIDRA_INT(&(*GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>(&(local_20[-1])) + 0x7897)))))) || (room->_gridHeight <= iVar5))
|
|
{
|
|
local_18 = GHIDRA_CAST<Entity *>(0xffffffff);
|
|
}
|
|
else {
|
|
local_18 = GHIDRA_CAST<Entity *>((GHIDRA_INT(local_20->_gridEntities) + room->_gridWidth * iVar5 + -0x25));
|
|
}
|
|
iVar4 = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(g_game->_room) + 0xc));
|
|
spawnPos.x = (float)(GHIDRA_INT(local_18) % iVar4) * fVar8 + fVar8;
|
|
spawnPos.y = (float)(GHIDRA_INT(local_18) / iVar4) * fVar8 + fVar9;
|
|
seed = Random();
|
|
local_18 = Game::Spawn(g_game,0x3c7,0,&spawnPos,&g_vectorZero,GHIDRA_CAST<Entity *>(0x0),0,seed);
|
|
(local_18->_sprite)._rotation = 90.0;
|
|
local_24 = GHIDRA_CAST<Entity *>(cos(1.5707964));
|
|
fVar8 = sin(1.5707964);
|
|
pEVar1 = local_24;
|
|
local_24 = local_18;
|
|
(local_18->_sprite)._offset.x = (float)pEVar1 * 0.0 - fVar8 * 15.0;
|
|
(local_18->_sprite)._offset.y = fVar8 * 0.0 + (float)pEVar1 * 15.0;
|
|
if (doorsEnd == doorsCapacity) {
|
|
msvc::vector<unsigned_int>::_Emplace_reallocate(doorsEnd,&local_24);
|
|
doorsCapacity = GHIDRA_CAST<int *>(0x0);
|
|
}
|
|
else {
|
|
*doorsEnd = GHIDRA_INT(local_18);
|
|
doorsEnd = doorsEnd + 1;
|
|
}
|
|
}
|
|
iVar5 = iVar5 + 1;
|
|
} while (iVar5 < local_1c + -1);
|
|
}
|
|
local_18 = GHIDRA_CAST<Entity *>(&(*GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>(&(local_20[-1])) + 0x7897))));
|
|
pRVar6 = GHIDRA_CAST<Room *>(0x1);
|
|
if (1 < GHIDRA_INT(local_18)) {
|
|
do {
|
|
fVar9 = 120.0;
|
|
fVar8 = 40.0;
|
|
if ((GHIDRA_INT(pRVar6) < room->_gridWidth) && (0 < room->_gridHeight)) {
|
|
iVar5 = room->_gridWidth;
|
|
toIndex = pRVar6;
|
|
LAB_004b747c:
|
|
if (room->_gridHeight < 2) goto LAB_004b7486;
|
|
iVar5 = GHIDRA_INT(pRVar6->_gridEntities) + iVar5 + -0x24;
|
|
}
|
|
else {
|
|
iVar5 = room->_gridWidth;
|
|
toIndex = GHIDRA_CAST<Room *>(0xffffffff);
|
|
if (GHIDRA_INT(pRVar6) < iVar5) goto LAB_004b747c;
|
|
LAB_004b7486:
|
|
iVar5 = -1;
|
|
}
|
|
isCanStep = (GHIDRA_CAST<RoomGridPath *>((&room->_railManager)))->RoomGridPath::can_step(iVar5,GHIDRA_INT(toIndex));
|
|
if (isCanStep != 0) {
|
|
if ((GHIDRA_INT(pRVar6) < room->_gridWidth) && (0 < room->_gridHeight)) {
|
|
local_20 = pRVar6;
|
|
}
|
|
else {
|
|
local_20 = GHIDRA_CAST<Room *>(0xffffffff);
|
|
}
|
|
iVar5 = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(g_game->_room) + 0xc));
|
|
spawnPos.x = (float)(GHIDRA_INT(local_20) % iVar5) * fVar8 + fVar8;
|
|
spawnPos.y = (float)(GHIDRA_INT(local_20) / iVar5) * fVar8 + fVar9;
|
|
seed = Random();
|
|
local_24 = Game::Spawn(g_game,0x3c7,0,&spawnPos,&g_vectorZero,GHIDRA_CAST<Entity *>(0x0),0,seed);
|
|
(local_24->_sprite)._rotation = 0.0;
|
|
local_28 = GHIDRA_CAST<Entity *>(cos(0.0));
|
|
fVar8 = sin(0.0);
|
|
pEVar1 = local_28;
|
|
local_28 = local_24;
|
|
(local_24->_sprite)._offset.x = (float)pEVar1 * 0.0 - fVar8 * 15.0;
|
|
(local_24->_sprite)._offset.y = fVar8 * 0.0 + (float)pEVar1 * 15.0;
|
|
if (doorsEnd == doorsCapacity) {
|
|
msvc::vector<unsigned_int>::_Emplace_reallocate(doorsEnd,&local_28);
|
|
doorsCapacity = GHIDRA_CAST<int *>(0x0);
|
|
}
|
|
else {
|
|
*doorsEnd = GHIDRA_INT(local_24);
|
|
doorsEnd = doorsEnd + 1;
|
|
}
|
|
}
|
|
iVar5 = room->_gridWidth;
|
|
this = &room->_railManager;
|
|
if (((GHIDRA_INT(pRVar6) < iVar5) && (iVar4 = local_1c + -1, -1 < iVar4)) &&
|
|
(iVar4 < room->_gridHeight)) {
|
|
iVar4 = GHIDRA_INT(pRVar6->_gridEntities) + iVar4 * iVar5 + -0x24;
|
|
LAB_004b75cf:
|
|
iVar3 = local_1c + -2;
|
|
room = local_2c;
|
|
if ((iVar3 < 0) || (local_2c->_gridHeight <= iVar3)) goto LAB_004b75e6;
|
|
iVar5 = GHIDRA_INT(pRVar6->_gridEntities) + iVar3 * iVar5 + -0x24;
|
|
}
|
|
else {
|
|
iVar4 = -1;
|
|
if (GHIDRA_INT(pRVar6) < iVar5) goto LAB_004b75cf;
|
|
LAB_004b75e6:
|
|
iVar5 = -1;
|
|
}
|
|
isCanStep = this->RoomGridPath::can_step(iVar5,iVar4);
|
|
if (isCanStep != 0) {
|
|
local_28 = GHIDRA_CAST<Entity *>(FUN_004bb230());
|
|
if (doorsEnd == doorsCapacity) {
|
|
msvc::vector<unsigned_int>::_Emplace_reallocate(doorsEnd,&local_28);
|
|
doorsCapacity = GHIDRA_CAST<int *>(0x0);
|
|
}
|
|
else {
|
|
*doorsEnd = GHIDRA_INT(local_28);
|
|
doorsEnd = doorsEnd + 1;
|
|
}
|
|
}
|
|
pRVar6 = GHIDRA_CAST<Room *>(&(*GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>((pRVar6)) + 0x1))));
|
|
} while (GHIDRA_INT(pRVar6) < GHIDRA_INT(local_18));
|
|
}
|
|
local_18 = GHIDRA_CAST<Entity *>(0x0);
|
|
piVar7 = doors;
|
|
if (doorsEnd != GHIDRA_CAST<int *>(0x0)) {
|
|
do {
|
|
local_18 = GHIDRA_CAST<Entity *>(piVar7);
|
|
local_1c = *GHIDRA_CAST<int *>(local_18);
|
|
pRVar6 = GHIDRA_CAST<Room *>((local_1c + 0x3bc));
|
|
local_2c = pRVar6;
|
|
if ((*GHIDRA_CAST<int *>((local_1c + 0x3bc)) == 0) &&
|
|
(piVar7 = GHIDRA_CAST<int *>((GHIDRA_INT(local_18) + 4)), piVar7 < doorsEnd)) {
|
|
do {
|
|
local_28 = GHIDRA_CAST<Entity *>(*piVar7);
|
|
local_20 = GHIDRA_CAST<Room *>(&local_28->_parent);
|
|
if (local_28->_parent == 0) {
|
|
iVar5 = GHIDRA_INT((((local_28->_pos).x - 40.0) / 40.0 + 0.5));
|
|
iVar4 = GHIDRA_INT((((local_28->_pos).y - 120.0) / 40.0 + 0.5));
|
|
if ((((iVar5 < 0) || (room->_gridWidth <= iVar5)) || (iVar4 < 0)) ||
|
|
(room->_gridHeight <= iVar4)) {
|
|
seed = 0xffffffff;
|
|
}
|
|
else {
|
|
seed = iVar4 * room->_gridWidth + iVar5;
|
|
}
|
|
iVar4 = GHIDRA_INT(((*GHIDRA_CAST<float *>((local_1c + 0x33c)) - 40.0) / 40.0 + 0.5));
|
|
iVar5 = GHIDRA_INT(((*GHIDRA_CAST<float *>((local_1c + 0x340)) - 120.0) / 40.0 + 0.5));
|
|
if (((iVar4 < 0) || (room->_gridWidth <= iVar4)) ||
|
|
((iVar5 < 0 || (room->_gridHeight <= iVar5)))) {
|
|
startIndex = 0xffffffff;
|
|
}
|
|
else {
|
|
startIndex = iVar5 * room->_gridWidth + iVar4;
|
|
}
|
|
isCanStep = room_grid_flood_fill(&room->_railManager,startIndex,seed);
|
|
if (isCanStep != 0) {
|
|
if (*GHIDRA_CAST<int *>(pRVar6) != 0) {
|
|
local_2c = pRVar6;
|
|
msvc::multiset<unsigned_int>::erase(&local_2c);
|
|
}
|
|
*GHIDRA_CAST<Entity **>(pRVar6) = local_28;
|
|
msvc::multiset<unsigned_int>::insert(pRVar6);
|
|
if (*GHIDRA_CAST<int *>(local_20) != 0) {
|
|
local_2c = local_20;
|
|
msvc::multiset<unsigned_int>::erase(&local_2c);
|
|
}
|
|
*GHIDRA_CAST<int *>(local_20) = local_1c;
|
|
msvc::multiset<unsigned_int>::insert(local_20);
|
|
}
|
|
}
|
|
piVar7 = piVar7 + 1;
|
|
} while (piVar7 < doorsEnd);
|
|
}
|
|
local_18 = GHIDRA_CAST<Entity *>((GHIDRA_INT(local_18) + 4));
|
|
piVar7 = GHIDRA_CAST<int *>(local_18);
|
|
} while (local_18 < doorsEnd);
|
|
}
|
|
if (doorsEnd != GHIDRA_CAST<int *>(0x0)) {
|
|
do {
|
|
(**(code **)(*GHIDRA_CAST<int *>(*doors) + 0xc))(uVar2);
|
|
doors = doors + 1;
|
|
} while (doors < doorsEnd);
|
|
}
|
|
if (room->_doors[0] != (void *)0x0) {
|
|
*GHIDRA_CAST<uint32_t *>((GHIDRA_INT(room->_doors[0]) + 0xf4)) = 0;
|
|
}
|
|
if (room->_doors[1] != (void *)0x0) {
|
|
*GHIDRA_CAST<uint32_t *>((GHIDRA_INT(room->_doors[1]) + 0xf4)) = 0;
|
|
}
|
|
if (room->_doors[2] != (void *)0x0) {
|
|
*GHIDRA_CAST<uint32_t *>((GHIDRA_INT(room->_doors[2]) + 0xf4)) = 0;
|
|
}
|
|
if (room->_doors[3] != (void *)0x0) {
|
|
*GHIDRA_CAST<uint32_t *>((GHIDRA_INT(room->_doors[3]) + 0xf4)) = 0;
|
|
}
|
|
if (room->_doors[4] != (void *)0x0) {
|
|
*GHIDRA_CAST<uint32_t *>((GHIDRA_INT(room->_doors[4]) + 0xf4)) = 0;
|
|
}
|
|
if (room->_doors[5] != (void *)0x0) {
|
|
*GHIDRA_CAST<uint32_t *>((GHIDRA_INT(room->_doors[5]) + 0xf4)) = 0;
|
|
}
|
|
if (room->_doors[6] != (void *)0x0) {
|
|
*GHIDRA_CAST<uint32_t *>((GHIDRA_INT(room->_doors[6]) + 0xf4)) = 0;
|
|
}
|
|
if (room->_doors[7] != (void *)0x0) {
|
|
*GHIDRA_CAST<uint32_t *>((GHIDRA_INT(room->_doors[7]) + 0xf4)) = 0;
|
|
}
|
|
ExceptionList = local_10;
|
|
return;
|
|
}
|
|
|
|
// 004b78f0
|
|
void NpcHelper::hornfel_remove_doors()
|
|
{
|
|
void *pvVar1;
|
|
int *hornfelDoorIter;
|
|
uint32_t uVar3;
|
|
int *linkedIter;
|
|
uint32_t seed;
|
|
Entity *pEVar4;
|
|
int *linkedIter;
|
|
int *piVar6;
|
|
int *local_70;
|
|
int *local_64;
|
|
Vector scratchVec;
|
|
int *local_44;
|
|
uint32_t local_40;
|
|
uint32_t uStack_3c;
|
|
uint32_t uStack_38;
|
|
uint32_t uStack_34;
|
|
uint32_t local_30;
|
|
uint32_t uStack_2c;
|
|
uint32_t uStack_28;
|
|
uint32_t uStack_24;
|
|
uint32_t local_20;
|
|
uint32_t local_1c;
|
|
uint32_t local_18;
|
|
uint32_t local_14;
|
|
void *local_10;
|
|
uint8_t *puStack_c;
|
|
uint32_t local_8;
|
|
int *hornfelDoorIter;
|
|
|
|
puStack_c = &LAB_00af33a5;
|
|
local_10 = ExceptionList;
|
|
uVar3 = __security_cookie ^ GHIDRA_INT(register0x00000010) - 4U;
|
|
ExceptionList = &local_10;
|
|
linkedIter = GHIDRA_CAST<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)) {
|
|
msvc::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)) {
|
|
msvc::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));
|
|
Game::Spawn(g_game,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 = Game::Spawn(g_game,1000,0xf,&scratchVec,&g_vectorZero,GHIDRA_CAST<Entity *>(0x0),0,uVar3);
|
|
(**(code **)(*GHIDRA_CAST<int *>(pEVar4) + 0x3c))(&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<uint32_t *>((*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(pvVar1) + 0x724)) + 0xf4)) = 0x3f800000;
|
|
}
|
|
if (*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(pvVar1) + 0x728)) != 0) {
|
|
*GHIDRA_CAST<uint32_t *>((*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(pvVar1) + 0x728)) + 0xf4)) = 0x3f800000;
|
|
}
|
|
if (*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(pvVar1) + 0x72c)) != 0) {
|
|
*GHIDRA_CAST<uint32_t *>((*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(pvVar1) + 0x72c)) + 0xf4)) = 0x3f800000;
|
|
}
|
|
if (*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(pvVar1) + 0x730)) != 0) {
|
|
*GHIDRA_CAST<uint32_t *>((*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(pvVar1) + 0x730)) + 0xf4)) = 0x3f800000;
|
|
}
|
|
if (*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(pvVar1) + 0x734)) != 0) {
|
|
*GHIDRA_CAST<uint32_t *>((*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(pvVar1) + 0x734)) + 0xf4)) = 0x3f800000;
|
|
}
|
|
if (*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(pvVar1) + 0x738)) != 0) {
|
|
*GHIDRA_CAST<uint32_t *>((*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(pvVar1) + 0x738)) + 0xf4)) = 0x3f800000;
|
|
}
|
|
if (*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(pvVar1) + 0x73c)) != 0) {
|
|
*GHIDRA_CAST<uint32_t *>((*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(pvVar1) + 0x73c)) + 0xf4)) = 0x3f800000;
|
|
}
|
|
if (*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(pvVar1) + 0x740)) != 0) {
|
|
*GHIDRA_CAST<uint32_t *>((*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;
|
|
uint32_t renderLayer;
|
|
AnimationState *local_88;
|
|
uint32_t local_84;
|
|
uint8_t 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<uint8_t *>("AnimationData is NULL\n"));
|
|
}
|
|
if (*GHIDRA_CAST<int *>((GHIDRA_INT((minecartSprite->_animState)._animation) + 0x80)) < 2) {
|
|
KAGE_LogMessage(0x10,GHIDRA_CAST<uint8_t *>("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<uint8_t *>("AnimationData is NULL\n"));
|
|
}
|
|
if (*GHIDRA_CAST<int *>((GHIDRA_INT((npc->_sprite)._animState._animation) + 0x80)) < 5) {
|
|
KAGE_LogMessage(0x10,GHIDRA_CAST<uint8_t *>("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))) {
|
|
AnimationState::copy_assign(frameCopy,cartFrame);
|
|
local_88 = frameCopy;
|
|
npcSprite = &npc->_sprite;
|
|
local_84 = 1;
|
|
renderLayer = 4;
|
|
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 = ANM2::GetLayer(npcSprite,&DAT_00000004);
|
|
pLVar2->_visible = 1;
|
|
pLVar2 = ANM2::GetLayer(npcSprite,&DAT_00000004);
|
|
(pLVar2->_color)._tint[3] = (minecartSprite->_color)._tint[3];
|
|
AnimationLayer::RenderFrame
|
|
(GHIDRA_CAST<AnimationLayer *>(&renderLayer),renderPosLocal,0,&g_vectorZero,&g_vectorZero,
|
|
npcSprite);
|
|
pLVar2 = ANM2::GetLayer(npcSprite,&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 *>((npc->_minecart + 0x360));
|
|
cartVelocityY = *GHIDRA_CAST<float *>((npc->_minecart + 0x364));
|
|
if (npc->_state != 10) {
|
|
if (ABS(cartVelocityY) < ABS(cartVelocityX)) {
|
|
animName = "IdleLeft";
|
|
if (0.0 <= cartVelocityX) {
|
|
animName = "IdleRight";
|
|
}
|
|
ANM2::Play(sprite,GHIDRA_CAST<uint8_t *>(animName),0);
|
|
return;
|
|
}
|
|
animName = "IdleUp";
|
|
if (0.0 <= cartVelocityY) {
|
|
animName = "IdleDown";
|
|
}
|
|
ANM2::Play(sprite,GHIDRA_CAST<uint8_t *>(animName),0);
|
|
return;
|
|
}
|
|
if (ABS(cartVelocityY) < ABS(cartVelocityX)) {
|
|
animName = "ChargeLeft";
|
|
if (0.0 <= cartVelocityX) {
|
|
animName = "ChargeRight";
|
|
}
|
|
ANM2::Play(sprite,GHIDRA_CAST<uint8_t *>(animName),0);
|
|
return;
|
|
}
|
|
animName = "ChargeUp";
|
|
if (0.0 <= cartVelocityY) {
|
|
animName = "ChargeDown";
|
|
}
|
|
ANM2::Play(sprite,GHIDRA_CAST<uint8_t *>(animName),0);
|
|
return;
|
|
}
|
|
|
|
// 004b7ee0
|
|
Entity * NpcHelper::hornfel_pick_spawn()
|
|
{
|
|
int *piVar1;
|
|
uint32_t uVar2;
|
|
RNG rng;
|
|
uint32_t uVar3;
|
|
Entity *spawned;
|
|
Entity *in_ECX;
|
|
void *freeBlock;
|
|
uint32_t uVar4;
|
|
BitSet128 BVar5;
|
|
uint32_t *local_44;
|
|
uint32_t rngSeed;
|
|
uint64_t uStack_3c;
|
|
uint32_t uStack_34;
|
|
void *outcomes;
|
|
uint32_t *outcomesEnd;
|
|
uint32_t *outcomesCapacity;
|
|
uint32_t securityCookie;
|
|
uint8_t *puStack_20;
|
|
void *local_1c;
|
|
uint8_t *puStack_18;
|
|
uint32_t local_14;
|
|
int oldParent;
|
|
uint32_t *parentRef;
|
|
|
|
puStack_20 = GHIDRA_CAST<uint8_t *>((GHIDRA_INT(register0x00000010) + -4));
|
|
puStack_18 = &LAB_00af332d;
|
|
local_1c = ExceptionList;
|
|
securityCookie = __security_cookie ^ GHIDRA_INT(register0x00000010) - 0x10U;
|
|
ExceptionList = &local_1c;
|
|
outcomes = (void *)0x0;
|
|
outcomesEnd = GHIDRA_CAST<uint32_t *>(0x0);
|
|
outcomesCapacity = GHIDRA_CAST<uint32_t *>(0x0);
|
|
local_14 = 0;
|
|
uStack_3c = (uint64_t)GHIDRA_UINT(uStack_3c);
|
|
uStack_34 = 6;
|
|
msvc::vector<8byte>::_Emplace_reallocate(0,GHIDRA_INT(&uStack_3c) + 4);
|
|
uVar3 = 0;
|
|
uVar4 = GHIDRA_INT(outcomesEnd) - GHIDRA_INT(outcomes) >> 3;
|
|
if (uVar4 != 0) {
|
|
do {
|
|
if (*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(outcomes) + uVar3 * 8)) == 8) {
|
|
piVar1 = GHIDRA_CAST<int *>((GHIDRA_INT(outcomes) + uVar3 * 8 + 4));
|
|
*piVar1 = *piVar1 + 3;
|
|
if (*piVar1 < 0) {
|
|
*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(outcomes) + uVar3 * 8 + 4)) = 0;
|
|
}
|
|
goto LAB_004b7fc7;
|
|
}
|
|
uVar3 = uVar3 + 1;
|
|
} while (uVar3 < uVar4);
|
|
}
|
|
uStack_3c = CONCAT44(8,GHIDRA_UINT(uStack_3c));
|
|
uStack_34 = 3;
|
|
if (outcomesEnd == outcomesCapacity) {
|
|
msvc::vector<8byte>::_Emplace_reallocate(outcomesEnd,GHIDRA_INT(&uStack_3c) + 4);
|
|
}
|
|
else {
|
|
*outcomesEnd = 8;
|
|
outcomesEnd[1] = 3;
|
|
outcomesEnd = outcomesEnd + 2;
|
|
}
|
|
LAB_004b7fc7:
|
|
uVar3 = 0;
|
|
uVar4 = GHIDRA_INT(outcomesEnd) - GHIDRA_INT(outcomes) >> 3;
|
|
if (uVar4 != 0) {
|
|
do {
|
|
if (*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(outcomes) + uVar3 * 8)) == 0x10) {
|
|
piVar1 = GHIDRA_CAST<int *>((GHIDRA_INT(outcomes) + uVar3 * 8 + 4));
|
|
*piVar1 = *piVar1 + 1;
|
|
if (*piVar1 < 0) {
|
|
*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(outcomes) + uVar3 * 8 + 4)) = 0;
|
|
}
|
|
goto LAB_004b8025;
|
|
}
|
|
uVar3 = uVar3 + 1;
|
|
} while (uVar3 < uVar4);
|
|
}
|
|
uStack_3c = CONCAT44(0x10,GHIDRA_UINT(uStack_3c));
|
|
uStack_34 = 1;
|
|
if (outcomesEnd == outcomesCapacity) {
|
|
msvc::vector<8byte>::_Emplace_reallocate(outcomesEnd,GHIDRA_INT(&uStack_3c) + 4);
|
|
}
|
|
else {
|
|
*outcomesEnd = 0x10;
|
|
outcomesEnd[1] = 1;
|
|
outcomesEnd = outcomesEnd + 2;
|
|
}
|
|
LAB_004b8025:
|
|
rngSeed = Random();
|
|
rngSeed = rngSeed | 1;
|
|
uStack_3c = 0x900000005;
|
|
uStack_34 = 7;
|
|
rng._shift1 = 5;
|
|
rng._seed = rngSeed;
|
|
rng._shift2 = 9;
|
|
rng._shift3 = 7;
|
|
uVar3 = (GHIDRA_CAST<WeightedOutcomePicker *>((GHIDRA_CAST<WeightedOutcomePicker *>(&outcomes))))->WeightedOutcomePicker::PickOutcome(rng);
|
|
local_14 = 0xffffffff;
|
|
uStack_34 = uVar3;
|
|
if (outcomes != (void *)0x0) {
|
|
uVar4 = GHIDRA_INT(outcomesCapacity) - GHIDRA_INT(outcomes) & 0xfffffff8;
|
|
freeBlock = outcomes;
|
|
if (0xfff < uVar4) {
|
|
freeBlock = *(void **)(GHIDRA_CAST<char *>(outcomes) + -4);
|
|
uVar4 = uVar4 + 0x23;
|
|
if (0x1f < GHIDRA_UINT((GHIDRA_INT(outcomes) + (-4 - GHIDRA_INT(freeBlock))))) {
|
|
/* WARNING: Subroutine does not return */
|
|
_invalid_parameter_noinfo_noreturn();
|
|
}
|
|
}
|
|
operator_delete(freeBlock,uVar4);
|
|
}
|
|
uVar4 = Random();
|
|
spawned = Game::Spawn(g_game,4,uVar3,&in_ECX->_pos,&g_vectorZero,in_ECX,0,uVar4);
|
|
oldParent = spawned->_parent;
|
|
parentRef = &spawned->_parent;
|
|
spawned->_visible = 0;
|
|
spawned->_entityCollisionClass = 0;
|
|
spawned->_entityGridCollisionClass = 0;
|
|
*GHIDRA_CAST<uint32_t *>((spawned + 1)) = 0x23;
|
|
*GHIDRA_CAST<uint32_t *>(&(*GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>(&(spawned[1])) + 0x4)))) = 0x23;
|
|
if (oldParent != 0) {
|
|
local_44 = parentRef;
|
|
msvc::multiset<unsigned_int>::erase(&local_44);
|
|
}
|
|
*parentRef = in_ECX;
|
|
if (in_ECX != GHIDRA_CAST<Entity *>(0x0)) {
|
|
msvc::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<uint32_t *>((GHIDRA_INT(&spawned->_flags) + 4));
|
|
*GHIDRA_CAST<uint32_t *>(&spawned->_flags) = GHIDRA_UINT(spawned->_flags) | 0x20;
|
|
*GHIDRA_CAST<uint32_t *>((GHIDRA_INT(&spawned->_flags) + 4)) = uVar2;
|
|
ExceptionList = local_1c;
|
|
return spawned;
|
|
}
|
|
|
|
// 004b8190
|
|
void NpcHelper::hornfel_minecart(Entity_NPC *npc)
|
|
{
|
|
uint32_t uVar1;
|
|
uint32_t uVar2;
|
|
int iVar3;
|
|
int iVar4;
|
|
Entity_NPC *pEVar5;
|
|
Vector *velocity;
|
|
int *piVar6;
|
|
Entity_Player *player;
|
|
uint32_t rngResult;
|
|
Entity *spawned;
|
|
char *ptr;
|
|
int iVar7;
|
|
int *remaining;
|
|
float fVar8;
|
|
uint32_t *puVar9;
|
|
float deltaX;
|
|
Vector railDirOut;
|
|
Vector local_60;
|
|
Vector local_58;
|
|
Vector local_50;
|
|
Entity_NPC *local_48;
|
|
int *local_44;
|
|
uint32_t *local_40;
|
|
std_string anm2Path;
|
|
uint32_t local_24;
|
|
uint8_t *puStack_20;
|
|
void *local_1c;
|
|
uint8_t *puStack_18;
|
|
uint32_t local_14;
|
|
ANM2 *minecartSprite;
|
|
void *room;
|
|
|
|
puStack_20 = GHIDRA_CAST<uint8_t *>((GHIDRA_INT(register0x00000010) + -4));
|
|
local_14 = 0xffffffff;
|
|
puStack_18 = &LAB_00af33dd;
|
|
local_1c = ExceptionList;
|
|
local_24 = __security_cookie ^ GHIDRA_INT(register0x00000010) - 0x10U;
|
|
ExceptionList = &local_1c;
|
|
local_48 = npc;
|
|
if (npc->_state == 7) {
|
|
pEVar5 = GHIDRA_CAST<Entity_NPC *>(npc->_entityRef);
|
|
local_60.y = (float)pEVar5;
|
|
if (pEVar5 != GHIDRA_CAST<Entity_NPC *>(0x0)) {
|
|
local_40 = &npc->_entityRef;
|
|
puStack_20 = GHIDRA_CAST<uint8_t *>((GHIDRA_INT(register0x00000010) + -4));
|
|
msvc::multiset<unsigned_int>::erase(&local_40);
|
|
npc->_entityRef = 0;
|
|
goto LAB_004b8213;
|
|
}
|
|
}
|
|
local_60.y = (float)hornfel_free_door();
|
|
local_50.y = (float)g_game->_room;
|
|
local_58.y = 0.0;
|
|
if ((GHIDRA_CAST<Entity_NPC *>((GHIDRA_INT(local_50.y) + 0xf60)))->_brimstoneMarkCountdown != 0) {
|
|
do {
|
|
iVar7 = *GHIDRA_CAST<int *>(((GHIDRA_CAST<Entity_NPC *>((GHIDRA_INT(local_50.y) + 0xf60)))->_weaknessCountdown +
|
|
GHIDRA_INT(local_58.y) * 4));
|
|
if (*GHIDRA_CAST<int *>((iVar7 + 0x28)) == 0x3c7) {
|
|
if (*GHIDRA_CAST<Entity_NPC **>((iVar7 + 0x3c4)) == npc) {
|
|
if (*GHIDRA_CAST<Entity_NPC **>((iVar7 + 0x3c4)) == GHIDRA_CAST<Entity_NPC *>(0x0)) {
|
|
if ((*GHIDRA_CAST<int *>((iVar7 + 0x3bc)) == 0) || (*GHIDRA_CAST<int *>((*GHIDRA_CAST<int *>((iVar7 + 0x3bc)) + 0x3c4)) == 0))
|
|
goto LAB_004b8675;
|
|
}
|
|
else {
|
|
local_40 = GHIDRA_CAST<uint32_t *>((iVar7 + 0x3c4));
|
|
msvc::multiset<unsigned_int>::erase(&local_40);
|
|
}
|
|
iVar3 = *GHIDRA_CAST<int *>((iVar7 + 0x3bc));
|
|
*GHIDRA_CAST<uint32_t *>((iVar7 + 0x3c4)) = 0;
|
|
if (iVar3 != 0) {
|
|
if (*GHIDRA_CAST<int *>((iVar3 + 0x3c4)) != 0) {
|
|
local_40 = GHIDRA_CAST<uint32_t *>((iVar3 + 0x3c4));
|
|
msvc::multiset<unsigned_int>::erase(&local_40);
|
|
}
|
|
*GHIDRA_CAST<uint32_t *>((iVar3 + 0x3c4)) = 0;
|
|
}
|
|
}
|
|
}
|
|
LAB_004b8675:
|
|
local_58.y = (float)(GHIDRA_INT(local_58.y) + 1);
|
|
} while (GHIDRA_UINT(local_58.y) <
|
|
GHIDRA_UINT((GHIDRA_CAST<Entity_NPC *>((GHIDRA_INT(local_50.y) + 0xf60)))->_brimstoneMarkCountdown));
|
|
}
|
|
pEVar5 = GHIDRA_CAST<Entity_NPC *>(local_60.y);
|
|
if (GHIDRA_CAST<Entity_NPC *>(local_60.y) == GHIDRA_CAST<Entity_NPC *>(0x0)) {
|
|
KAGE_LogMessage(4,GHIDRA_CAST<uint8_t *>("no doors to enter from!\n"));
|
|
*GHIDRA_CAST<uint16_t *>(&npc->_stateFrame) = 0xf;
|
|
ExceptionList = local_1c;
|
|
return;
|
|
}
|
|
LAB_004b8213:
|
|
hornfel_get_rail_direction(pEVar5,&local_50);
|
|
if ((local_50.x == g_vectorZero.x) && (local_50.y == g_vectorZero.y)) {
|
|
KAGE_LogMessage(0x10,GHIDRA_CAST<uint8_t *>("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 = (float)npc->_minecart;
|
|
if (GHIDRA_CAST<Entity_NPC *>(local_58.y) != GHIDRA_CAST<Entity_NPC *>(0x0)) {
|
|
FUN_004cf0f0(1);
|
|
Entity_NPC::SetMinecartPosVel(GHIDRA_CAST<Entity_NPC *>(local_58.y),&pEVar5->_targetPosition,&local_50);
|
|
fVar8 = (GHIDRA_CAST<Vector *>((GHIDRA_INT(local_58.y) + 0x33c)))->y;
|
|
(npc->_pos).x = (GHIDRA_CAST<Vector *>((GHIDRA_INT(local_58.y) + 0x33c)))->x;
|
|
(npc->_pos).y = fVar8;
|
|
hornfel_claim_target(pEVar5,GHIDRA_CAST<Entity *>(npc));
|
|
local_40 = GHIDRA_CAST<uint32_t *>(npc->_parent);
|
|
if (npc->_state == 6) {
|
|
if (*GHIDRA_CAST<char *>((GHIDRA_INT(&npc->_projectileCooldown) + 1)) == '\0') {
|
|
uVar2 = Random();
|
|
if (((uVar2 & 7) == 0) && ((local_40 == GHIDRA_CAST<uint32_t *>(0x0) || (4 < GHIDRA_INT(local_40[0x117])))))
|
|
{
|
|
room = g_game->_room;
|
|
iVar3 = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(room) + 0x12c0)) + *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(room) + 0x12c4));
|
|
iVar7 = 0;
|
|
if (0 < iVar3) {
|
|
iVar7 = iVar3;
|
|
}
|
|
iVar4 = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(room) + 0x12c8)) + *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(room) + 0x12cc));
|
|
iVar3 = 0;
|
|
if (0 < iVar4) {
|
|
iVar3 = iVar4;
|
|
}
|
|
if ((iVar7 - iVar3 < 2) && (spawned = hornfel_free_door(), spawned != GHIDRA_CAST<Entity *>(0x0))) {
|
|
local_58.y = 0.0;
|
|
local_44 = GHIDRA_CAST<int *>(((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_NPC *>(local_60.y) == GHIDRA_CAST<Entity_NPC *>(0x0)) break;
|
|
uVar2 = Random();
|
|
pEVar5 = (Entity_NPC *)
|
|
Game::Spawn(g_game,0x38a,1,&g_vectorZero,&g_vectorZero,GHIDRA_CAST<Entity *>(npc),0,
|
|
uVar2);
|
|
uVar1 = *GHIDRA_CAST<uint32_t *>((GHIDRA_INT(&pEVar5->_flags) + 4));
|
|
iVar7 = *GHIDRA_CAST<int *>(pEVar5);
|
|
*GHIDRA_CAST<uint32_t *>(&pEVar5->_flags) = GHIDRA_UINT(pEVar5->_flags) & 0xfffffffb;
|
|
*GHIDRA_CAST<uint32_t *>((GHIDRA_INT(&pEVar5->_flags) + 4)) = uVar1;
|
|
local_48 = pEVar5;
|
|
(**(code **)(iVar7 + 0xc))();
|
|
velocity = hornfel_get_rail_direction(GHIDRA_CAST<Entity_NPC *>(local_60.y),&railDirOut);
|
|
local_50.y = (float)Entity::GiveMinecart
|
|
(GHIDRA_CAST<Entity *>(pEVar5),GHIDRA_CAST<Vector *>((GHIDRA_INT(local_60.y) + 0x334)),
|
|
velocity);
|
|
anm2Path._size = 0;
|
|
minecartSprite = &(GHIDRA_CAST<Entity_NPC *>(local_50.y))->_sprite;
|
|
anm2Path._capacity = 0xf;
|
|
anm2Path._buf[0] = '\0';
|
|
anm2Path._buf[1] = '\0';
|
|
anm2Path._buf[2] = '\0';
|
|
anm2Path._buf[3] = '\0';
|
|
(*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(anm2Path._buf)) + 0x0))) = msvc::_Allocate(0x30);
|
|
anm2Path._size = 0x21;
|
|
anm2Path._capacity = 0x2f;
|
|
builtin_strncpy((*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(GHIDRA_CAST<char *>(anm2Path._buf))) + 0x0))),"gfx/965.001_hornfel minecart.anm2",0x22
|
|
);
|
|
local_14 = 0;
|
|
ANM2::Load(minecartSprite,&anm2Path,1);
|
|
local_14 = 0xffffffff;
|
|
if (0xf < anm2Path._capacity) {
|
|
uVar2 = anm2Path._capacity + 1;
|
|
ptr = (*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(GHIDRA_CAST<char *>(anm2Path._buf))) + 0x0)));
|
|
if (0xfff < uVar2) {
|
|
ptr = *GHIDRA_CAST<char **>(((*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(anm2Path._buf)) + 0x0))) + -4));
|
|
uVar2 = anm2Path._capacity + 0x24;
|
|
if (GHIDRA_CAST<char *>(0x1f) < GHIDRA_CAST<char *>(((*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(anm2Path._buf)) + 0x0))) + (-4 - GHIDRA_INT(ptr))))) {
|
|
/* WARNING: Subroutine does not return */
|
|
_invalid_parameter_noinfo_noreturn();
|
|
}
|
|
}
|
|
operator_delete(ptr,uVar2);
|
|
}
|
|
(**(code **)(*GHIDRA_CAST<int *>(local_50.y) + 0xc))();
|
|
pEVar5 = local_48;
|
|
if ((*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(local_60.y) + 0x3c4)) == 0) &&
|
|
((*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(local_60.y) + 0x3bc)) == 0 ||
|
|
(*GHIDRA_CAST<int *>((*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(local_60.y) + 0x3bc)) + 0x3c4)) == 0)))) {
|
|
*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(local_60.y) + 0x3c4)) = local_48;
|
|
msvc::multiset<unsigned_int>::insert(GHIDRA_CAST<uint32_t *>((GHIDRA_INT(local_60.y) + 0x3c4)));
|
|
iVar7 = *GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(local_60.y) + 0x3bc));
|
|
if (iVar7 != 0) {
|
|
local_50.y = (float)(iVar7 + 0x3c4);
|
|
if (*GHIDRA_CAST<int *>((iVar7 + 0x3c4)) != 0) {
|
|
local_48 = GHIDRA_CAST<Entity_NPC *>(local_50.y);
|
|
msvc::multiset<unsigned_int>::erase(&local_48);
|
|
}
|
|
*GHIDRA_CAST<Entity_NPC **>(local_50.y) = pEVar5;
|
|
msvc::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;
|
|
uVar2 = Random();
|
|
*GHIDRA_CAST<uint8_t *>((GHIDRA_INT(&npc->_projectileCooldown) + 1)) = 100;
|
|
*GHIDRA_CAST<short *>(&npc->_projectileDelay) = (short)(uVar2 % 0x1e) + 0x1e;
|
|
if (local_40 == GHIDRA_CAST<uint32_t *>(0x0)) {
|
|
ExceptionList = local_1c;
|
|
return;
|
|
}
|
|
if (GHIDRA_INT(local_40[0x117]) < 0x96) {
|
|
local_40[0x117] = 0x96;
|
|
local_40[0x118] = 0x96;
|
|
ExceptionList = local_1c;
|
|
return;
|
|
}
|
|
ExceptionList = local_1c;
|
|
return;
|
|
}
|
|
pEVar5 = GHIDRA_CAST<Entity_NPC *>(local_60.y);
|
|
}
|
|
}
|
|
if ((((npc->_state == 6) && (*GHIDRA_CAST<char *>((GHIDRA_INT(&npc->_projectileCooldown) + 2)) == '\0')) &&
|
|
(uVar2 = Random(), (uVar2 & 7) == 0)) &&
|
|
((GHIDRA_CAST<Entity_NPC *>(pEVar5->_parent) != GHIDRA_CAST<Entity_NPC *>(0x0) &&
|
|
(GHIDRA_CAST<Entity_NPC *>(pEVar5->_parent) != pEVar5)))) {
|
|
npc->_state = 10;
|
|
(GHIDRA_CAST<Vector *>((GHIDRA_INT(local_58.y) + 3000)))->x = 0.1;
|
|
if (npc->_entityRef != 0) {
|
|
local_44 = &npc->_entityRef;
|
|
msvc::multiset<unsigned_int>::erase(&local_44);
|
|
}
|
|
npc->_entityRef = pEVar5;
|
|
msvc::multiset<unsigned_int>::insert(&npc->_entityRef);
|
|
*GHIDRA_CAST<uint8_t *>((GHIDRA_INT(&npc->_projectileCooldown) + 2)) = 100;
|
|
uVar2 = Random();
|
|
*GHIDRA_CAST<char *>((GHIDRA_INT(&npc->_projectileDelay) + 2)) = (char)(uVar2 % 3) + '\x06';
|
|
ExceptionList = local_1c;
|
|
return;
|
|
}
|
|
}
|
|
if (npc->_state == 7) {
|
|
npc->_state = 0xb;
|
|
}
|
|
else {
|
|
npc->_state = 3;
|
|
uVar2 = Random();
|
|
*GHIDRA_CAST<short *>(&npc->_projectileDelay) = (short)(uVar2 % 0xf) + 0xf;
|
|
uVar2 = Random();
|
|
if (uVar2 % 3 == 0) {
|
|
local_44 = *GHIDRA_CAST<int **>((GHIDRA_CAST<char *>(g_game->_room) + 0x1264));
|
|
if (local_44 != GHIDRA_CAST<int *>(0x0)) {
|
|
piVar6 = *GHIDRA_CAST<int **>((GHIDRA_CAST<char *>(g_game->_room) + 0x125c));
|
|
uVar2 = 0;
|
|
remaining = local_44;
|
|
do {
|
|
iVar7 = *GHIDRA_CAST<int *>((*piVar6 + 0x28));
|
|
if ((iVar7 == 0x333) || ((iVar7 == 4 && (*GHIDRA_CAST<int *>((*piVar6 + 0x2c)) == 0xe)))) {
|
|
uVar2 = uVar2 + 1;
|
|
}
|
|
piVar6 = piVar6 + 1;
|
|
remaining = GHIDRA_CAST<int *>((GHIDRA_INT(remaining) + -1));
|
|
} while (remaining != GHIDRA_CAST<int *>(0x0));
|
|
npc = local_48;
|
|
if (3 < uVar2) {
|
|
ExceptionList = local_1c;
|
|
return;
|
|
}
|
|
}
|
|
uVar2 = 0;
|
|
local_40 = GHIDRA_CAST<uint32_t *>(0x7149f2ca);
|
|
if (GHIDRA_INT((g_game->_playerManager)._playerList._end) -
|
|
GHIDRA_INT((g_game->_playerManager)._playerList._begin) >> 2 != 0) {
|
|
do {
|
|
player = Game::GetPlayer(g_game,uVar2);
|
|
uVar2 = uVar2 + 1;
|
|
fVar8 = (npc->_pos).y - (player->_pos).y;
|
|
deltaX = (npc->_pos).x - (player->_pos).x;
|
|
puVar9 = GHIDRA_CAST<uint32_t *>((fVar8 * fVar8 + deltaX * deltaX));
|
|
if ((float)local_40 <= (float)puVar9) {
|
|
puVar9 = local_40;
|
|
}
|
|
local_40 = puVar9;
|
|
} while (uVar2 < GHIDRA_UINT((GHIDRA_INT((g_game->_playerManager)._playerList._end) -
|
|
GHIDRA_INT((g_game->_playerManager)._playerList._begin) >> 2)));
|
|
if ((float)puVar9 <= 57600.0) {
|
|
ExceptionList = local_1c;
|
|
return;
|
|
}
|
|
}
|
|
local_40 = GHIDRA_CAST<uint32_t *>(0x2);
|
|
do {
|
|
uVar2 = Random();
|
|
rngResult = Random();
|
|
local_44 = GHIDRA_CAST<int *>((((float)((double)GHIDRA_INT(rngResult) +
|
|
__uint_to_double_fixup[-(GHIDRA_INT(rngResult) >> 0x1f)]) *
|
|
2.3283064e-10 * 40.0 - 20.0) * 0.017453292));
|
|
local_48 = GHIDRA_CAST<Entity_NPC *>(cos((float)local_44));
|
|
fVar8 = sin((float)local_44);
|
|
local_58.x = local_50.x * (float)local_48 - local_50.y * fVar8;
|
|
local_58.y = local_50.y * (float)local_48 + local_50.x * fVar8;
|
|
rngResult = Random();
|
|
fVar8 = (float)((double)GHIDRA_INT(rngResult) +
|
|
__uint_to_double_fixup[-(GHIDRA_INT(rngResult) >> 0x1f)]) * 2.3283064e-10 * 3.14
|
|
;
|
|
local_44 = GHIDRA_CAST<int *>((fVar8 + fVar8));
|
|
fVar8 = cos((float)local_44);
|
|
local_60.x = fVar8 * 6.0 + (npc->_pos).x;
|
|
fVar8 = sin((float)local_44);
|
|
local_60.y = fVar8 * 6.0 + (npc->_pos).y;
|
|
spawned = Game::Spawn(g_game,0x333,0,&local_60,&local_58,GHIDRA_CAST<Entity *>(npc),0,uVar2);
|
|
if (spawned->_parent != 0) {
|
|
local_44 = &spawned->_parent;
|
|
msvc::multiset<unsigned_int>::erase(&local_44);
|
|
}
|
|
spawned->_parent = npc;
|
|
msvc::multiset<unsigned_int>::insert(&spawned->_parent);
|
|
*GHIDRA_CAST<uint32_t *>(&spawned->_flags) = GHIDRA_UINT(spawned->_flags) & 0xfffffffb;
|
|
local_40 = GHIDRA_CAST<uint32_t *>((GHIDRA_INT(local_40) + -1));
|
|
*GHIDRA_CAST<uint32_t *>((GHIDRA_INT(&spawned->_flags) + 4)) = *GHIDRA_CAST<uint32_t *>((GHIDRA_INT(&spawned->_flags) + 4));
|
|
} while (local_40 != GHIDRA_CAST<uint32_t *>(0x0));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
ExceptionList = local_1c;
|
|
return;
|
|
}
|
|
|
|
// 004b8a30
|
|
void NpcHelper::hornfel_ride_minecart(Entity_NPC *linkedNpc)
|
|
{
|
|
char *pcVar1;
|
|
uint64_t qVar2;
|
|
float *pfVar3;
|
|
int flyBombData;
|
|
float fVar4;
|
|
uint64_t *allocatedBytes;
|
|
uint32_t uVar5;
|
|
float fVar6;
|
|
EntityList_EL flyBombs;
|
|
Vector scratchVec;
|
|
uint32_t *local_14;
|
|
void *local_10;
|
|
uint8_t *puStack_c;
|
|
uint32_t uStack_8;
|
|
Game *game;
|
|
Entity_NPC *linkedNpc;
|
|
Entity_NPC *minecart;
|
|
uint32_t *parentRef;
|
|
|
|
uStack_8 = 0xffffffff;
|
|
puStack_c = &LAB_00af341d;
|
|
local_10 = ExceptionList;
|
|
minecart = GHIDRA_CAST<Entity_NPC *>(linkedNpc->_minecart);
|
|
if ((linkedNpc->_state == 10) &&
|
|
(linkedNpc = GHIDRA_CAST<Entity_NPC *>(linkedNpc->_entityRef), linkedNpc != GHIDRA_CAST<Entity_NPC *>(0x0))) {
|
|
if ('\0' < *GHIDRA_CAST<char *>((GHIDRA_INT(&linkedNpc->_projectileDelay) + 2))) {
|
|
ExceptionList = &local_10;
|
|
hornfel_get_rail_direction(linkedNpc,&scratchVec);
|
|
Entity_NPC::SetMinecartPosVel(minecart,&linkedNpc->_targetPosition,&scratchVec);
|
|
fVar4 = (minecart->_pos).x;
|
|
fVar6 = (minecart->_pos).y;
|
|
pcVar1 = GHIDRA_CAST<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<uint16_t *>(&linkedNpc->_stateFrame) = 1;
|
|
(linkedNpc->_targetPosition).x = (linkedNpc->_pos).x;
|
|
(linkedNpc->_targetPosition).y = (linkedNpc->_pos).y;
|
|
linkedNpc->_shadowSize = 0.0;
|
|
fVar4 = (minecart->_v2).x;
|
|
fVar6 = 6.0;
|
|
if (fVar4 <= 6.0) {
|
|
fVar6 = fVar4;
|
|
}
|
|
minecart->_shadowSize = 0.0;
|
|
(minecart->_v2).x = fVar6;
|
|
return;
|
|
}
|
|
ExceptionList = &local_10;
|
|
linkedNpc->_state = 6;
|
|
*GHIDRA_CAST<uint16_t *>(&linkedNpc->_stateFrame) = 0x2d;
|
|
linkedNpc->_visible = 0;
|
|
linkedNpc->_entityCollisionClass = 0;
|
|
(linkedNpc->_targetPosition).x = (linkedNpc->_pos).x;
|
|
(linkedNpc->_targetPosition).y = (linkedNpc->_pos).y;
|
|
game = g_game;
|
|
linkedNpc->_shadowSize = 0.0;
|
|
minecart->_shadowSize = 0.0;
|
|
EntityList::QuerySublist(GHIDRA_CAST<EntityList *>((GHIDRA_INT(game->_room) + 0x1218)),&flyBombs,0x333,-1,-1,0,0);
|
|
uVar5 = 0;
|
|
if (flyBombs._size != 0) {
|
|
flyBombData = (*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(flyBombs)) + 0x4)));
|
|
do {
|
|
scratchVec.y = *GHIDRA_CAST<float *>((flyBombData + uVar5 * 4));
|
|
parentRef = GHIDRA_CAST<uint32_t *>((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;
|
|
msvc::multiset<unsigned_int>::erase(&local_14);
|
|
fVar4 = scratchVec.y;
|
|
}
|
|
local_14 = *GHIDRA_CAST<uint32_t **>((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 = (*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(flyBombs)) + 0x4)));
|
|
}
|
|
uVar5 = uVar5 + 1;
|
|
} while (uVar5 < GHIDRA_UINT(flyBombs._size));
|
|
}
|
|
if ((*GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>(&(flyBombs)) + 0x0))) == '\0') {
|
|
if (g_mainHeap == (void *)0x0) {
|
|
allocatedBytes = &g_allocatedBytesNoHeap;
|
|
}
|
|
else {
|
|
allocatedBytes = GHIDRA_CAST<uint64_t *>((GHIDRA_INT(g_mainHeap) + 0x30));
|
|
}
|
|
if ((*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(flyBombs)) + 0x4))) != 0) {
|
|
uVar5 = *GHIDRA_CAST<uint32_t *>(((*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(flyBombs)) + 0x4))) + -4));
|
|
qVar2 = *allocatedBytes;
|
|
*GHIDRA_CAST<uint32_t *>(allocatedBytes) = GHIDRA_UINT(*allocatedBytes) - uVar5;
|
|
*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(allocatedBytes) + 4)) =
|
|
*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(allocatedBytes) + 4)) - GHIDRA_UINT((GHIDRA_UINT(qVar2) < uVar5));
|
|
free(GHIDRA_CAST<uint32_t *>(((*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(flyBombs)) + 0x4))) + -4)));
|
|
}
|
|
}
|
|
ExceptionList = local_10;
|
|
return;
|
|
}
|
|
|
|
// 004b8ca0
|
|
void NpcHelper::hornfel_attack(Entity_NPC *npc)
|
|
{
|
|
RNG rng;
|
|
uint32_t uVar1;
|
|
Entity *target;
|
|
uint32_t extraout_ECX;
|
|
uint32_t extraout_ECX_00;
|
|
uint32_t extraout_ECX_01;
|
|
uint32_t uVar2;
|
|
void *ptr;
|
|
uint32_t uVar3;
|
|
float targetDist;
|
|
uint64_t uStack_48;
|
|
float fStack_40;
|
|
float targetDirY;
|
|
void *picker;
|
|
uint32_t *outcomesEnd;
|
|
uint32_t *outcomesCapacity;
|
|
float *local_2c;
|
|
uint32_t *local_28;
|
|
uint32_t local_24;
|
|
uint8_t *puStack_20;
|
|
void *local_1c;
|
|
uint8_t *puStack_18;
|
|
uint32_t local_14;
|
|
char *animName;
|
|
float *childSlot;
|
|
int dequeBlock;
|
|
uint32_t *firstChildSlot;
|
|
int *outcomeWeight;
|
|
|
|
puStack_20 = GHIDRA_CAST<uint8_t *>((GHIDRA_INT(register0x00000010) + -4));
|
|
puStack_18 = &LAB_00af344d;
|
|
local_1c = ExceptionList;
|
|
local_24 = __security_cookie ^ GHIDRA_INT(register0x00000010) - 0x10U;
|
|
ExceptionList = &local_1c;
|
|
picker = (void *)0x0;
|
|
outcomesEnd = GHIDRA_CAST<uint32_t *>(0x0);
|
|
outcomesCapacity = GHIDRA_CAST<uint32_t *>(0x0);
|
|
local_14 = 0;
|
|
uStack_48 = (uint64_t)GHIDRA_UINT(uStack_48);
|
|
fStack_40 = 4.2039e-45;
|
|
msvc::vector<8byte>::_Emplace_reallocate(0,GHIDRA_INT(&uStack_48) + 4);
|
|
uVar1 = 0;
|
|
uVar3 = GHIDRA_INT(outcomesEnd) - GHIDRA_INT(picker) >> 3;
|
|
if (uVar3 != 0) {
|
|
do {
|
|
if (*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(picker) + uVar1 * 8)) == 1) {
|
|
outcomeWeight = GHIDRA_CAST<int *>((GHIDRA_INT(picker) + uVar1 * 8 + 4));
|
|
*outcomeWeight = *outcomeWeight + 1;
|
|
if (*outcomeWeight < 0) {
|
|
*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(picker) + uVar1 * 8 + 4)) = 0;
|
|
}
|
|
goto LAB_004b8d87;
|
|
}
|
|
uVar1 = uVar1 + 1;
|
|
} while (uVar1 < uVar3);
|
|
}
|
|
uStack_48 = CONCAT44(1,GHIDRA_UINT(uStack_48));
|
|
fStack_40 = 1.4013e-45;
|
|
if (outcomesEnd == outcomesCapacity) {
|
|
msvc::vector<8byte>::_Emplace_reallocate(outcomesEnd,GHIDRA_INT(&uStack_48) + 4);
|
|
}
|
|
else {
|
|
*outcomesEnd = 1;
|
|
outcomesEnd[1] = 1;
|
|
outcomesEnd = outcomesEnd + 2;
|
|
}
|
|
LAB_004b8d87:
|
|
if ((char)npc->_projectileCooldown == '\0') {
|
|
uVar1 = 0;
|
|
uVar3 = GHIDRA_INT(outcomesEnd) - GHIDRA_INT(picker) >> 3;
|
|
if (uVar3 != 0) {
|
|
do {
|
|
if (*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(picker) + uVar1 * 8)) == 2) {
|
|
outcomeWeight = GHIDRA_CAST<int *>((GHIDRA_INT(picker) + uVar1 * 8 + 4));
|
|
*outcomeWeight = *outcomeWeight + 1;
|
|
if (*outcomeWeight < 0) {
|
|
*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(picker) + uVar1 * 8 + 4)) = 0;
|
|
}
|
|
goto LAB_004b8df1;
|
|
}
|
|
uVar1 = uVar1 + 1;
|
|
} while (uVar1 < uVar3);
|
|
}
|
|
uStack_48 = CONCAT44(2,GHIDRA_UINT(uStack_48));
|
|
fStack_40 = 1.4013e-45;
|
|
if (outcomesEnd == outcomesCapacity) {
|
|
msvc::vector<8byte>::_Emplace_reallocate(outcomesEnd,GHIDRA_INT(&uStack_48) + 4);
|
|
}
|
|
else {
|
|
*outcomesEnd = 2;
|
|
outcomesEnd[1] = 1;
|
|
outcomesEnd = outcomesEnd + 2;
|
|
}
|
|
}
|
|
LAB_004b8df1:
|
|
uVar1 = Random();
|
|
uStack_48 = 0x900000005;
|
|
fStack_40 = 9.80909e-45;
|
|
rng._shift1 = 5;
|
|
rng._seed = uVar1 | 1;
|
|
rng._shift2 = 9;
|
|
rng._shift3 = 7;
|
|
uVar1 = (GHIDRA_CAST<WeightedOutcomePicker *>((GHIDRA_CAST<WeightedOutcomePicker *>(&picker))))->WeightedOutcomePicker::PickOutcome(rng);
|
|
target = Entity_NPC::GetPlayerTarget(npc);
|
|
local_28 = GHIDRA_CAST<uint32_t *>(((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<uint32_t *>(((float)local_28 * (1.0 / targetDist)));
|
|
targetDirY = targetDirY * (1.0 / targetDist);
|
|
}
|
|
*GHIDRA_CAST<uint8_t *>((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;
|
|
msvc::multiset<unsigned_int>::erase(&local_2c);
|
|
}
|
|
*childSlot = fStack_40;
|
|
if (fStack_40 != 0.0) {
|
|
msvc::multiset<unsigned_int>::insert(childSlot);
|
|
}
|
|
if (-0.2 <= targetDirY) {
|
|
if (0.0 <= (float)local_28) {
|
|
animName = "Attack1Right";
|
|
}
|
|
else {
|
|
animName = "Attack1Left";
|
|
}
|
|
LAB_004b9068:
|
|
ANM2::Play(&npc->_sprite,GHIDRA_CAST<uint8_t *>(animName),0);
|
|
}
|
|
else {
|
|
animName = "Attack1Left_Back";
|
|
if (0.0 <= (float)local_28) {
|
|
animName = "Attack1Right_Back";
|
|
}
|
|
ANM2::Play(&npc->_sprite,GHIDRA_CAST<uint8_t *>(animName),0);
|
|
*GHIDRA_CAST<uint8_t *>((GHIDRA_INT(&npc->_projectileDelay) + 3)) = 0;
|
|
}
|
|
}
|
|
else {
|
|
if (uVar1 != 1) {
|
|
if (uVar1 == 2) {
|
|
ANM2::Play(&npc->_sprite,s_Attack2,0);
|
|
npc->_state = 9;
|
|
*GHIDRA_CAST<uint8_t *>(&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<uint32_t *>((dequeBlock + uVar3 * 4));
|
|
uVar2 = 0;
|
|
if (*GHIDRA_CAST<int *>((dequeBlock + uVar3 * 4)) != 0) {
|
|
local_28 = firstChildSlot;
|
|
msvc::multiset<unsigned_int>::erase(&local_28);
|
|
uVar2 = extraout_ECX_00;
|
|
}
|
|
*firstChildSlot = local_2c;
|
|
if (local_2c != GHIDRA_CAST<float *>(0x0)) {
|
|
msvc::multiset<unsigned_int>::insert(firstChildSlot);
|
|
uVar2 = extraout_ECX_01;
|
|
}
|
|
local_28 = GHIDRA_CAST<uint32_t *>(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;
|
|
msvc::multiset<unsigned_int>::erase(&local_2c);
|
|
}
|
|
*childSlot = (float)local_28;
|
|
if (local_28 != GHIDRA_CAST<uint32_t *>(0x0)) {
|
|
msvc::multiset<unsigned_int>::insert(childSlot);
|
|
}
|
|
if (-0.2 <= targetDirY) {
|
|
animName = "Attack1Double";
|
|
goto LAB_004b9068;
|
|
}
|
|
ANM2::Play(&npc->_sprite,GHIDRA_CAST<uint8_t *>("Attack1Double_Back"),0);
|
|
*GHIDRA_CAST<uint8_t *>((GHIDRA_INT(&npc->_projectileDelay) + 3)) = 0;
|
|
}
|
|
npc->_state = 8;
|
|
LAB_004b9077:
|
|
*GHIDRA_CAST<uint8_t *>((GHIDRA_INT(&npc->_projectileDelay) + 2)) = 0;
|
|
if (picker != (void *)0x0) {
|
|
uVar1 = GHIDRA_INT(outcomesCapacity) - GHIDRA_INT(picker) & 0xfffffff8;
|
|
ptr = picker;
|
|
if (0xfff < uVar1) {
|
|
ptr = *(void **)(GHIDRA_CAST<char *>(picker) + -4);
|
|
uVar1 = uVar1 + 0x23;
|
|
if (0x1f < GHIDRA_UINT((GHIDRA_INT(picker) + (-4 - GHIDRA_INT(ptr))))) {
|
|
/* WARNING: Subroutine does not return */
|
|
_invalid_parameter_noinfo_noreturn();
|
|
}
|
|
}
|
|
operator_delete(ptr,uVar1);
|
|
}
|
|
ExceptionList = local_1c;
|
|
return;
|
|
}
|
|
|
|
// 004b90e0
|
|
void NpcHelper::hornfel_launch_toward(Entity_NPC *npc, Entity *entity, Vector *targetPos)
|
|
{
|
|
int iVar1;
|
|
Entity *pEVar2;
|
|
float deltaX;
|
|
float fVar3;
|
|
float launchSpeed;
|
|
float npcPosY;
|
|
uint32_t *refSlot;
|
|
|
|
fVar3 = targetPos->y;
|
|
deltaX = (npc->_pos).x - targetPos->x;
|
|
npcPosY = (npc->_pos).y - fVar3;
|
|
targetPos = GHIDRA_CAST<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 != 0) {
|
|
entity = GHIDRA_CAST<Entity *>(refSlot);
|
|
msvc::multiset<unsigned_int>::erase(&entity);
|
|
}
|
|
*refSlot = npc;
|
|
if (npc != GHIDRA_CAST<Entity_NPC *>(0x0)) {
|
|
msvc::multiset<unsigned_int>::insert(refSlot);
|
|
}
|
|
refSlot = &pEVar2->_parent;
|
|
pEVar2->_spawnerType = npc->_type;
|
|
pEVar2->_spawnerVariant = npc->_variant;
|
|
if (*refSlot != 0) {
|
|
entity = GHIDRA_CAST<Entity *>(refSlot);
|
|
msvc::multiset<unsigned_int>::erase(&entity);
|
|
}
|
|
*refSlot = npc;
|
|
msvc::multiset<unsigned_int>::insert(refSlot);
|
|
pEVar2->_entityCollisionClass = 4;
|
|
pEVar2->_visible = 1;
|
|
*GHIDRA_CAST<uint32_t *>(&(*GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>(&(pEVar2[1])) + 0xc)))) = 0xc0800000;
|
|
(pEVar2->_posOffset).x = 0.0;
|
|
(pEVar2->_posOffset).y = -24.0;
|
|
(pEVar2->_pos).x = (npc->_pos).x;
|
|
npcPosY = (npc->_pos).y;
|
|
*GHIDRA_CAST<uint32_t *>(&pEVar2->_flags) = GHIDRA_UINT(pEVar2->_flags) & 0xffffffdf;
|
|
(pEVar2->_pos).y = npcPosY;
|
|
*GHIDRA_CAST<uint32_t *>((GHIDRA_INT(&pEVar2->_flags) + 4)) = *GHIDRA_CAST<uint32_t *>((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()
|
|
{
|
|
uint32_t rngResult;
|
|
int *candidatesEnd;
|
|
float fVar1;
|
|
float fVar2;
|
|
int *candidatesEndCopy;
|
|
int railDoor;
|
|
uint32_t i;
|
|
void *local_10;
|
|
uint8_t *puStack_c;
|
|
uint32_t local_8;
|
|
char *currentRoom;
|
|
int enterDoor;
|
|
void *room;
|
|
|
|
puStack_c = &LAB_00af34dd;
|
|
local_10 = ExceptionList;
|
|
ExceptionList = &local_10;
|
|
candidatesEnd = GHIDRA_CAST<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)) {
|
|
msvc::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<uint32_t *>((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;
|
|
uint32_t railSign;
|
|
uint32_t gridIdx;
|
|
int gridX;
|
|
uint8_t railFlags;
|
|
void *room;
|
|
float zeroY;
|
|
|
|
zeroY = g_vectorZero.y;
|
|
room = g_game->_room;
|
|
gridX = GHIDRA_INT((((npc->_targetPosition).x - 40.0) / 40.0 + 0.5));
|
|
if ((((-1 < gridX) && (gridX < *GHIDRA_CAST<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<uint8_t *>((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<uint8_t *>((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;
|
|
uint32_t railDirection;
|
|
uint32_t gridIndex;
|
|
int iVar1;
|
|
uint8_t *directionSign;
|
|
Vector nextPos;
|
|
uint8_t railType;
|
|
Room *room;
|
|
|
|
room = g_game->_room;
|
|
iVar1 = GHIDRA_INT((((npc->_targetPosition).x - 40.0) / 40.0 + 0.5));
|
|
if ((((-1 < iVar1) && (iVar1 < room->_gridWidth)) &&
|
|
(row = GHIDRA_INT((((npc->_targetPosition).y - 120.0) / 40.0 + 0.5)), -1 < row)) &&
|
|
(((row < room->_gridHeight && (gridIndex = room->_gridWidth * row + iVar1, gridIndex < 0x1c0))
|
|
&& (railType = (room->_railManager)._sprite._filename._buf[gridIndex - 0x1c0],
|
|
railType != 0xff)))) {
|
|
if ((railType & 0x40) == 0) {
|
|
if ((railType & 0x10) == 0) {
|
|
railDirection = railType >> 5 & 1;
|
|
}
|
|
else {
|
|
railDirection = 0xffffffff;
|
|
}
|
|
}
|
|
else {
|
|
railDirection = 0;
|
|
}
|
|
if (railDirection != 0) {
|
|
if (((room->_railManager)._sprite._filename._buf[gridIndex - 0x1c0] & 0xfU) == 0) {
|
|
if (GHIDRA_INT(railDirection) < 0) {
|
|
directionSign = &DAT_bf800000;
|
|
}
|
|
else {
|
|
directionSign = GHIDRA_CAST<uint8_t *>(0x3f800000);
|
|
}
|
|
nextPos.x = (float)directionSign * 40.0 + (npc->_targetPosition).x;
|
|
nextPos.y = (npc->_targetPosition).y + 0.0;
|
|
iVar1 = Room::GetGridIndex(room,&nextPos);
|
|
return iVar1;
|
|
}
|
|
if (GHIDRA_INT(railDirection) < 0) {
|
|
directionSign = &DAT_bf800000;
|
|
}
|
|
else {
|
|
directionSign = GHIDRA_CAST<uint8_t *>(0x3f800000);
|
|
}
|
|
nextPos.x = (npc->_targetPosition).x + 0.0;
|
|
nextPos.y = (float)directionSign * 40.0 + (npc->_targetPosition).y;
|
|
iVar1 = Room::GetGridIndex(room,&nextPos);
|
|
return iVar1;
|
|
}
|
|
}
|
|
return -1;
|
|
}
|
|
|
|
// 004bb830
|
|
void NpcHelper::hornfel_set_anim(Entity_NPC *npc, int stateFrame)
|
|
{
|
|
uint8_t bVar1;
|
|
uint8_t *curAnimChar;
|
|
uint32_t animCompare;
|
|
uint8_t *openAnimChar;
|
|
bool isLess;
|
|
int soundId;
|
|
uint8_t *animData;
|
|
Manager *manager;
|
|
|
|
if (npc->_state != 3) goto LAB_004bb903;
|
|
animData = (npc->_sprite)._animState._animData;
|
|
if (animData == GHIDRA_CAST<uint8_t *>(0x0)) {
|
|
LAB_004bb896:
|
|
bVar1 = ANM2::SetAnimation(&npc->_sprite,s_Open,1);
|
|
if (bVar1 != 0) {
|
|
AnimationState::Rewind(&(npc->_sprite)._animState);
|
|
(npc->_sprite)._animState._isPlaying = 1;
|
|
}
|
|
}
|
|
else {
|
|
curAnimChar = animData;
|
|
if (0xf < *GHIDRA_CAST<uint32_t *>((animData + 0x14))) {
|
|
curAnimChar = *GHIDRA_CAST<uint8_t **>(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
|
|
uint8_t NpcHelper::hornfel_claim_target(Entity_NPC *npc, Entity *target)
|
|
{
|
|
int iVar1;
|
|
Entity *parentTargetRef;
|
|
Entity *targetLocal;
|
|
|
|
targetLocal = target;
|
|
if ((npc->_target != 0) || ((iVar1 = npc->_parent, iVar1 != 0 && (*GHIDRA_CAST<int *>((iVar1 + 0x3c4)) != 0))))
|
|
{
|
|
return 0;
|
|
}
|
|
npc->_target = target;
|
|
if (target != GHIDRA_CAST<Entity *>(0x0)) {
|
|
msvc::multiset<unsigned_int>::insert(&npc->_target);
|
|
iVar1 = npc->_parent;
|
|
}
|
|
if (iVar1 != 0) {
|
|
parentTargetRef = GHIDRA_CAST<Entity *>((iVar1 + 0x3c4));
|
|
if (*GHIDRA_CAST<int *>((iVar1 + 0x3c4)) != 0) {
|
|
target = parentTargetRef;
|
|
msvc::multiset<unsigned_int>::erase(&target);
|
|
}
|
|
*GHIDRA_CAST<Entity **>(parentTargetRef) = targetLocal;
|
|
if (targetLocal != GHIDRA_CAST<Entity *>(0x0)) {
|
|
msvc::multiset<unsigned_int>::insert(parentTargetRef);
|
|
}
|
|
}
|
|
return 1;
|
|
}
|
|
|
|
// 004bc460
|
|
void NpcHelper::hornfel_room_controller(Entity_Effect *effect)
|
|
{
|
|
uint32_t uVar1;
|
|
uint32_t uVar2;
|
|
Entity_NPC *npc;
|
|
uint32_t uVar3;
|
|
Entity *cart;
|
|
int iVar4;
|
|
Vector railDirection;
|
|
uint32_t cartTypeChoices [16];
|
|
void *room;
|
|
int roomWidth;
|
|
|
|
cartTypeChoices[0xe] = __security_cookie ^ GHIDRA_UINT(&railDirection);
|
|
room = g_game->_room;
|
|
if (effect->_state == 0) {
|
|
hornfel_spawn_doors();
|
|
uVar2 = Random();
|
|
effect->_state = 1;
|
|
iVar4 = uVar2 % 0xd2 + 0x96;
|
|
effect->_timeout = iVar4;
|
|
effect->_lifespan = iVar4;
|
|
return;
|
|
}
|
|
if ((*GHIDRA_CAST<uint8_t *>((*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(room) + 4)) + 0x44)) & 1) != 0) {
|
|
hornfel_remove_doors();
|
|
(**(code **)(*GHIDRA_CAST<int *>(effect) + 0x28))();
|
|
}
|
|
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 = Game::SpawnEx(g_game,cartTypeChoices[(uVar2 % 7) * 2],
|
|
cartTypeChoices[(uVar2 % 7) * 2 + 1],&g_vectorZero,&g_vectorZero,
|
|
GHIDRA_CAST<Entity *>(0x0),0,uVar3,0);
|
|
uVar1 = *GHIDRA_CAST<uint32_t *>((GHIDRA_INT(&cart->_flags) + 4));
|
|
*GHIDRA_CAST<uint32_t *>(&cart->_flags) = GHIDRA_UINT(cart->_flags) & 0xfffffffb;
|
|
*GHIDRA_CAST<uint32_t *>((GHIDRA_INT(&cart->_flags) + 4)) = uVar1;
|
|
cart->_spawnerType = 0x38a;
|
|
Entity::GiveMinecart(cart,&npc->_targetPosition,&railDirection);
|
|
hornfel_claim_target(npc,cart);
|
|
}
|
|
}
|
|
uVar2 = Random();
|
|
uVar2 = uVar2 % 0xd2 + 0x96;
|
|
iVar4 = *GHIDRA_CAST<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
|
|
uint8_t NpcHelper::horny_boys_pick_position(Entity_NPC *npc)
|
|
{
|
|
Entity_Player *nearestPlayer;
|
|
Game *game;
|
|
int gridWidth;
|
|
int iVar1;
|
|
int gridX;
|
|
uint32_t gridIndex;
|
|
float fVar2;
|
|
float dy;
|
|
float playerDistSq;
|
|
Vector candidatePos;
|
|
float candidateY;
|
|
float candidateX;
|
|
int attemptsLeft;
|
|
float bestDistSq;
|
|
void *room;
|
|
|
|
game = g_game;
|
|
bestDistSq = 0.0;
|
|
attemptsLeft = 6;
|
|
(npc->_targetPosition).x = g_vectorZero.x;
|
|
(npc->_targetPosition).y = g_vectorZero.y;
|
|
do {
|
|
Room::GetRandomPosition(game->_room,&candidatePos,20.0);
|
|
room = g_game->_room;
|
|
gridX = GHIDRA_INT(((candidatePos.x - 40.0) / 40.0 + 0.5));
|
|
iVar1 = GHIDRA_INT(((candidatePos.y - 120.0) / 40.0 + 0.5));
|
|
if ((((gridX < 0) || (gridWidth = *GHIDRA_CAST<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 = Game::GetNearestPlayer(g_game,&candidatePos);
|
|
game = g_game;
|
|
fVar2 = candidateX - (nearestPlayer->_pos).x;
|
|
dy = candidateY - (nearestPlayer->_pos).y;
|
|
playerDistSq = dy * dy + fVar2 * fVar2;
|
|
if ((((20.0 <= ABS(fVar2)) && (20.0 <= ABS(dy))) || (160000.0 <= playerDistSq)) &&
|
|
(((40000.0 <= playerDistSq &&
|
|
((0x1bf < gridIndex || (*GHIDRA_CAST<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;
|
|
uint32_t uVar2;
|
|
uint32_t blockSlot;
|
|
Entity *pEVar3;
|
|
float fVar4;
|
|
float dx;
|
|
int *local_c;
|
|
float local_8;
|
|
uint32_t *parentSlot;
|
|
|
|
local_c = GHIDRA_CAST<int *>((npc->_entityDeque)._offset);
|
|
uVar2 = GHIDRA_UINT((slot + GHIDRA_INT(local_c))) >> 2;
|
|
blockSlot = slot + GHIDRA_INT(local_c) & 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<int *>((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 != 0) {
|
|
local_c = parentSlot;
|
|
msvc::multiset<unsigned_int>::erase(&local_c);
|
|
}
|
|
*parentSlot = npc;
|
|
if (npc != GHIDRA_CAST<Entity_NPC *>(0x0)) {
|
|
msvc::multiset<unsigned_int>::insert(parentSlot);
|
|
}
|
|
pEVar3->_entityCollisionClass = 4;
|
|
pEVar3->_visible = 1;
|
|
*GHIDRA_CAST<uint32_t *>(&(*GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>(&(pEVar3[1])) + 0xc)))) = 0xc0800000;
|
|
(pEVar3->_posOffset).x = 0.0;
|
|
(pEVar3->_posOffset).y = -24.0;
|
|
(pEVar3->_pos).x = (npc->_pos).x;
|
|
fVar4 = (npc->_pos).y;
|
|
*GHIDRA_CAST<uint32_t *>(&pEVar3->_flags) = GHIDRA_UINT(pEVar3->_flags) & 0xffffffdf;
|
|
(pEVar3->_pos).y = fVar4;
|
|
*GHIDRA_CAST<uint32_t *>((GHIDRA_INT(&pEVar3->_flags) + 4)) = *GHIDRA_CAST<uint32_t *>((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));
|
|
parentSlot = GHIDRA_CAST<uint32_t *>((iVar1 + blockSlot * 4));
|
|
if (*GHIDRA_CAST<int *>((iVar1 + blockSlot * 4)) != 0) {
|
|
slot = GHIDRA_INT(parentSlot);
|
|
msvc::multiset<unsigned_int>::erase(&slot);
|
|
}
|
|
*parentSlot = 0;
|
|
return pEVar3;
|
|
}
|
|
|
|
// 004bcc70
|
|
Entity * NpcHelper::horny_boys_spawn_bomb(Entity_NPC *npc, int slot)
|
|
{
|
|
uint32_t uVar1;
|
|
int iVar2;
|
|
RNG rng;
|
|
uint8_t *puVar3;
|
|
Entity *pEVar4;
|
|
uint32_t uVar5;
|
|
void *ptr;
|
|
uint32_t uVar6;
|
|
BitSet128 bombTearFlags0;
|
|
uint64_t uStack_3c;
|
|
uint32_t *puStack_34;
|
|
void *picker;
|
|
uint32_t *outcomesEnd;
|
|
uint32_t *outcomesCapacity;
|
|
uint32_t local_24;
|
|
uint8_t *puStack_20;
|
|
void *local_1c;
|
|
uint8_t *puStack_18;
|
|
uint32_t local_14;
|
|
uint32_t *bombSlot;
|
|
int *outcomeWeight;
|
|
|
|
puStack_20 = GHIDRA_CAST<uint8_t *>((GHIDRA_INT(register0x00000010) + -4));
|
|
local_14 = 0xffffffff;
|
|
puStack_18 = &DAT_00af350d;
|
|
local_1c = ExceptionList;
|
|
local_24 = __security_cookie ^ GHIDRA_INT(register0x00000010) - 0x10U;
|
|
ExceptionList = &local_1c;
|
|
uVar5 = slot + (npc->_entityDeque)._offset;
|
|
uVar6 = uVar5 >> 2;
|
|
uVar5 = uVar5 & 3;
|
|
puVar3 = GHIDRA_CAST<uint8_t *>((GHIDRA_INT(register0x00000010) + -4));
|
|
if (*GHIDRA_CAST<int *>((*GHIDRA_CAST<int *>((GHIDRA_INT((npc->_entityDeque)._map) +
|
|
((npc->_entityDeque)._mapSize - 1 & uVar6) * 4)) + uVar5 * 4)) != 0) {
|
|
puStack_34 = GHIDRA_CAST<uint32_t *>((npc->_entityDeque)._offset);
|
|
(**(code **)(**GHIDRA_CAST<int **>((*GHIDRA_CAST<int *>((GHIDRA_INT((npc->_entityDeque)._map) +
|
|
((npc->_entityDeque)._mapSize - 1 & uVar6) * 4)) + uVar5 * 4)) +
|
|
0x28))(local_24);
|
|
puVar3 = puStack_20;
|
|
}
|
|
puStack_20 = puVar3;
|
|
picker = (void *)0x0;
|
|
outcomesEnd = GHIDRA_CAST<uint32_t *>(0x0);
|
|
outcomesCapacity = GHIDRA_CAST<uint32_t *>(0x0);
|
|
local_14 = 0;
|
|
uStack_3c = (uint64_t)GHIDRA_UINT(uStack_3c);
|
|
puStack_34 = GHIDRA_CAST<uint32_t *>(0x6);
|
|
msvc::vector<8byte>::_Emplace_reallocate(0,GHIDRA_INT(&uStack_3c) + 4);
|
|
uVar5 = 0;
|
|
uVar6 = GHIDRA_INT(outcomesEnd) - GHIDRA_INT(picker) >> 3;
|
|
if (uVar6 != 0) {
|
|
do {
|
|
if (*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(picker) + uVar5 * 8)) == 8) {
|
|
outcomeWeight = GHIDRA_CAST<int *>((GHIDRA_INT(picker) + uVar5 * 8 + 4));
|
|
*outcomeWeight = *outcomeWeight + 3;
|
|
if (*outcomeWeight < 0) {
|
|
*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(picker) + uVar5 * 8 + 4)) = 0;
|
|
}
|
|
goto LAB_004bcda7;
|
|
}
|
|
uVar5 = uVar5 + 1;
|
|
} while (uVar5 < uVar6);
|
|
}
|
|
uStack_3c = CONCAT44(8,GHIDRA_UINT(uStack_3c));
|
|
puStack_34 = GHIDRA_CAST<uint32_t *>(0x3);
|
|
if (outcomesEnd == outcomesCapacity) {
|
|
msvc::vector<8byte>::_Emplace_reallocate(outcomesEnd,GHIDRA_INT(&uStack_3c) + 4);
|
|
}
|
|
else {
|
|
*outcomesEnd = 8;
|
|
outcomesEnd[1] = 3;
|
|
outcomesEnd = outcomesEnd + 2;
|
|
}
|
|
LAB_004bcda7:
|
|
uVar5 = 0;
|
|
uVar6 = GHIDRA_INT(outcomesEnd) - GHIDRA_INT(picker) >> 3;
|
|
if (uVar6 != 0) {
|
|
do {
|
|
if (*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(picker) + uVar5 * 8)) == 0x10) {
|
|
outcomeWeight = GHIDRA_CAST<int *>((GHIDRA_INT(picker) + uVar5 * 8 + 4));
|
|
*outcomeWeight = *outcomeWeight + 1;
|
|
if (*outcomeWeight < 0) {
|
|
*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(picker) + uVar5 * 8 + 4)) = 0;
|
|
}
|
|
goto LAB_004bce05;
|
|
}
|
|
uVar5 = uVar5 + 1;
|
|
} while (uVar5 < uVar6);
|
|
}
|
|
uStack_3c = CONCAT44(0x10,GHIDRA_UINT(uStack_3c));
|
|
puStack_34 = GHIDRA_CAST<uint32_t *>(0x1);
|
|
if (outcomesEnd == outcomesCapacity) {
|
|
msvc::vector<8byte>::_Emplace_reallocate(outcomesEnd,GHIDRA_INT(&uStack_3c) + 4);
|
|
}
|
|
else {
|
|
*outcomesEnd = 0x10;
|
|
outcomesEnd[1] = 1;
|
|
outcomesEnd = outcomesEnd + 2;
|
|
}
|
|
LAB_004bce05:
|
|
uVar5 = Random();
|
|
uStack_3c = 0x900000005;
|
|
puStack_34 = GHIDRA_CAST<uint32_t *>(&DAT_00000007);
|
|
rng._shift1 = 5;
|
|
rng._seed = uVar5 | 1;
|
|
rng._shift2 = 9;
|
|
rng._shift3 = 7;
|
|
uVar5 = (GHIDRA_CAST<WeightedOutcomePicker *>((GHIDRA_CAST<WeightedOutcomePicker *>(&picker))))->WeightedOutcomePicker::PickOutcome(rng);
|
|
bombTearFlags0 = (BitSet128)ZEXT816(0);
|
|
if (uVar5 == 8) {
|
|
bombTearFlags0 = g_tearFlagBurn;
|
|
}
|
|
else if (uVar5 == 0x10) {
|
|
bombTearFlags0 = g_tearFlagSadBomb;
|
|
}
|
|
else {
|
|
}
|
|
uVar6 = Random();
|
|
pEVar4 = Game::Spawn(g_game,4,uVar5,&npc->_pos,&g_vectorZero,GHIDRA_CAST<Entity *>(npc),0,uVar6);
|
|
pEVar4->_visible = 0;
|
|
pEVar4->_entityCollisionClass = 0;
|
|
pEVar4->_entityGridCollisionClass = 0;
|
|
if (pEVar4->_parent != 0) {
|
|
puStack_34 = &pEVar4->_parent;
|
|
msvc::multiset<unsigned_int>::erase(&puStack_34);
|
|
}
|
|
pEVar4->_parent = npc;
|
|
if (npc != GHIDRA_CAST<Entity_NPC *>(0x0)) {
|
|
msvc::multiset<unsigned_int>::insert(&pEVar4->_parent);
|
|
}
|
|
uVar1 = *GHIDRA_CAST<uint32_t *>((GHIDRA_INT(&pEVar4->_flags) + 4));
|
|
*GHIDRA_CAST<uint32_t *>(&pEVar4->_flags) = GHIDRA_UINT(pEVar4->_flags) | 0x20;
|
|
*GHIDRA_CAST<uint32_t *>((GHIDRA_INT(&pEVar4->_flags) + 4)) = uVar1;
|
|
iVar2 = *GHIDRA_CAST<int *>(pEVar4);
|
|
*GHIDRA_CAST<uint32_t *>((pEVar4 + 1)) = 0x23;
|
|
*GHIDRA_CAST<uint32_t *>(&(*GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>(&(pEVar4[1])) + 0x4)))) = 0x23;
|
|
pEVar4[1]._type = GHIDRA_INT(bombTearFlags0._l);
|
|
pEVar4[1]._variant = (*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(bombTearFlags0._l)) + 0x4)));
|
|
pEVar4[1]._subtype = GHIDRA_INT(bombTearFlags0._h);
|
|
pEVar4[1]._spawnerType = (*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(bombTearFlags0._h)) + 0x4)));
|
|
pEVar4[1]._sprite._filename._buf[0xb] = '\x01';
|
|
(**(code **)(iVar2 + 0xc))();
|
|
puStack_34 = GHIDRA_CAST<uint32_t *>((npc->_entityDeque)._offset);
|
|
uVar5 = slot + GHIDRA_INT(puStack_34) & 3;
|
|
iVar2 = *GHIDRA_CAST<int *>((GHIDRA_INT((npc->_entityDeque)._map) +
|
|
(GHIDRA_UINT((slot + GHIDRA_INT(puStack_34))) >> 2 & (npc->_entityDeque)._mapSize - 1) * 4));
|
|
bombSlot = GHIDRA_CAST<uint32_t *>((iVar2 + uVar5 * 4));
|
|
if (*GHIDRA_CAST<int *>((iVar2 + uVar5 * 4)) != 0) {
|
|
puStack_34 = bombSlot;
|
|
msvc::multiset<unsigned_int>::erase(&puStack_34);
|
|
}
|
|
*bombSlot = pEVar4;
|
|
msvc::multiset<unsigned_int>::insert(bombSlot);
|
|
if (picker != (void *)0x0) {
|
|
uVar5 = GHIDRA_INT(outcomesCapacity) - GHIDRA_INT(picker) & 0xfffffff8;
|
|
ptr = picker;
|
|
if (0xfff < uVar5) {
|
|
ptr = *(void **)(GHIDRA_CAST<char *>(picker) + -4);
|
|
uVar5 = uVar5 + 0x23;
|
|
if (0x1f < GHIDRA_UINT((GHIDRA_INT(picker) + (-4 - GHIDRA_INT(ptr))))) {
|
|
/* WARNING: Subroutine does not return */
|
|
_invalid_parameter_noinfo_noreturn();
|
|
}
|
|
}
|
|
operator_delete(ptr,uVar5);
|
|
}
|
|
ExceptionList = local_1c;
|
|
return pEVar4;
|
|
}
|
|
|
|
// 004bcfd0
|
|
void NpcHelper::horny_boys_render(Entity_NPC *npc, Vector *offset)
|
|
{
|
|
Vector *position;
|
|
int iVar1;
|
|
void *layerFrame;
|
|
AnimationState *secondState;
|
|
uint32_t dequeIndex;
|
|
float renderScale;
|
|
double dVar2;
|
|
double dVar3;
|
|
uint32_t layerIdx;
|
|
int layerOffset;
|
|
void *animData;
|
|
float offsetY;
|
|
|
|
Entity::Render(GHIDRA_CAST<Entity *>(npc),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 = AnimationState::GetLayerFrame(&(npc->_sprite)._animState,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<uint32_t *>((iVar1 + 0xdc)) = *GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(layerFrame) + 0x10));
|
|
*GHIDRA_CAST<uint32_t *>((iVar1 + 0xe0)) = *GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(layerFrame) + 0x14));
|
|
*GHIDRA_CAST<uint32_t *>((iVar1 + 0xec)) = *GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(layerFrame) + 0x5c));
|
|
*GHIDRA_CAST<uint32_t *>((iVar1 + 0xe4)) = *GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(layerFrame) + 0x18));
|
|
*GHIDRA_CAST<uint32_t *>((iVar1 + 0xe8)) = *GHIDRA_CAST<uint32_t *>((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<uint32_t *>((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<uint32_t *>((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)
|
|
{
|
|
uint32_t rngResult;
|
|
uint32_t *local_44;
|
|
ColorMod particleColor;
|
|
float local_14;
|
|
Manager *manager;
|
|
|
|
local_14 = (float)(__security_cookie ^ GHIDRA_UINT(((&particleColor)[1]._tint + 1)));
|
|
(**(code **)(*GHIDRA_CAST<int *>(minecart) + 0x28))();
|
|
manager = g_manager;
|
|
local_44 = GHIDRA_CAST<uint32_t *>(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 = (uint32_t *)
|
|
((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 != 0) {
|
|
local_44 = &minecart->_child;
|
|
msvc::multiset<unsigned_int>::erase(&local_44);
|
|
}
|
|
minecart->_child = 0;
|
|
return;
|
|
}
|
|
|
|
// 004cf5b0
|
|
void NpcHelper::min_min_willo_count(Entity_NPC *minMin, int *outWilloCount, int *outOwnedCount)
|
|
{
|
|
uint32_t uVar1;
|
|
uint64_t *allocCounter;
|
|
EntityList_EL willoList;
|
|
void *local_10;
|
|
uint8_t *puStack_c;
|
|
uint32_t uStack_8;
|
|
uint64_t 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<uint32_t *>((GHIDRA_CAST<char *>(&(willoList)) + 0x4))) + uVar1 * 4)) + 0x3bc)) == minMin) {
|
|
*outOwnedCount = *outOwnedCount + 1;
|
|
}
|
|
uVar1 = uVar1 + 1;
|
|
} while (uVar1 < GHIDRA_UINT(willoList._size));
|
|
}
|
|
if ((*GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>(&(willoList)) + 0x0))) == '\0') {
|
|
if (g_mainHeap == (void *)0x0) {
|
|
allocCounter = &g_allocatedBytesNoHeap;
|
|
}
|
|
else {
|
|
allocCounter = GHIDRA_CAST<uint64_t *>((GHIDRA_INT(g_mainHeap) + 0x30));
|
|
}
|
|
if ((*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(willoList)) + 0x4))) != 0) {
|
|
uVar1 = *GHIDRA_CAST<uint32_t *>(((*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(willoList)) + 0x4))) + -4));
|
|
allocatedBytes = *allocCounter;
|
|
*GHIDRA_CAST<uint32_t *>(allocCounter) = GHIDRA_UINT(*allocCounter) - uVar1;
|
|
*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(allocCounter) + 4)) =
|
|
*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(allocCounter) + 4)) - GHIDRA_UINT((GHIDRA_UINT(allocatedBytes) < uVar1));
|
|
free((void *)((*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(willoList)) + 0x4))) + -4));
|
|
}
|
|
}
|
|
ExceptionList = local_10;
|
|
return;
|
|
}
|
|
|
|
// 004d33d0
|
|
void NpcHelper::moms_heart_attack_pattern(Entity_NPC *npc, int pattern, int stateFrame)
|
|
{
|
|
uint8_t isHeartbeat;
|
|
Entity *target;
|
|
int iVar1;
|
|
uint32_t frameMod4;
|
|
int framesLeft;
|
|
uint32_t uVar2;
|
|
Entity_Laser *laser;
|
|
int updateTime;
|
|
uint32_t baseBulletFlags;
|
|
bool isOnBeat;
|
|
float fVar3;
|
|
double dVar4;
|
|
float fVar5;
|
|
uint8_t 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;
|
|
uint32_t isPositiveRotation;
|
|
ProjectileParams projParams;
|
|
code *projectileCallback;
|
|
uint32_t stackCookie;
|
|
|
|
stackCookie = __security_cookie ^ GHIDRA_UINT(auStack_f8);
|
|
ProjectileParams::ProjectileParams(&projParams);
|
|
(*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(projParams)) + 0x4))) = 0x40a00000;
|
|
projParams.Scale = 1.5;
|
|
projParams.FallingAccelModifier = -0.06;
|
|
projParams.FallingSpeedModifier = -2.0;
|
|
target = Entity_NPC::GetPlayerTarget(npc);
|
|
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<uint32_t *>((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<uint32_t *>((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<uint32_t *>((GHIDRA_CAST<char *>(&(projParams.BulletFlags)) + 0x0))) = baseBulletFlags;
|
|
isHeartbeat = AnimationState::IsEventTriggered(&(npc->_sprite)._animState,GHIDRA_CAST<uint8_t *>("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<uint32_t *>((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<uint32_t *>((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<uint32_t *>((GHIDRA_CAST<char *>(&(projParams.BulletFlags)) + 0x0))) = baseBulletFlags;
|
|
fVar5 = cos(((float)stateFrame * 0.9424779) / 30.0);
|
|
(*GHIDRA_CAST<uint32_t *>((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<uint32_t *>((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<uint32_t *>((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;
|
|
(**(code **)(*GHIDRA_CAST<int *>(laser) + 0xc))();
|
|
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<uint32_t *>((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<uint32_t *>((GHIDRA_CAST<char *>(&(projParams.BulletFlags)) + 0x0))) = 0x40000;
|
|
if (!isOnBeat) {
|
|
(*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(projParams.BulletFlags)) + 0x0))) = 0x80000;
|
|
}
|
|
(*GHIDRA_CAST<uint32_t *>((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<uint32_t *>((GHIDRA_CAST<char *>(&(projParams.BulletFlags)) + 0x0))) = baseBulletFlags;
|
|
isHeartbeat = AnimationState::IsEventTriggered(&(npc->_sprite)._animState,GHIDRA_CAST<uint8_t *>("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<uint32_t *>((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<uint32_t *>((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<uint32_t *>((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<uint32_t *>((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<uint32_t *>((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<uint32_t *>((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<uint32_t *>((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);
|
|
(**(code **)(*GHIDRA_CAST<int *>(laser) + 0xc))();
|
|
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<uint32_t *>((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)
|
|
{
|
|
uint32_t attackRoll;
|
|
int maxAttack;
|
|
uint32_t 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;
|
|
uint32_t seed;
|
|
Entity_NPC *maggot;
|
|
float fVar3;
|
|
float fVar4;
|
|
float dirY;
|
|
uint64_t flags;
|
|
uint32_t flagsHigh;
|
|
|
|
pvVar1 = g_game->_room;
|
|
seed = Random();
|
|
maggot = GHIDRA_CAST<Entity_NPC *>(Game)::Spawn(g_game,0x355,0,origin,&g_vectorZero,GHIDRA_CAST<Entity *>(0x0),0,seed);
|
|
*GHIDRA_CAST<uint32_t *>(&maggot->_flags) = GHIDRA_UINT(maggot->_flags) & 0xfffffffb;
|
|
flagsHigh = *GHIDRA_CAST<uint32_t *>((GHIDRA_INT(&maggot->_flags) + 4));
|
|
flags = maggot->_flags;
|
|
(maggot->_v1).x = fallingSpeed;
|
|
*GHIDRA_CAST<uint32_t *>((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<uint32_t *>(&maggot->_flags) = GHIDRA_UINT(flags) | 0x4000000;
|
|
*GHIDRA_CAST<uint32_t *>((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;
|
|
}
|
|
(**(code **)(*GHIDRA_CAST<int *>(maggot) + 0xc))();
|
|
fVar3 = (maggot->_velocity).x;
|
|
dirY = (maggot->_velocity).y;
|
|
seed = maggot->_initSeed;
|
|
fVar4 = sqrtf(fVar3 * fVar3 + dirY * dirY);
|
|
if (0.0 < fVar4) {
|
|
fVar3 = fVar3 * (1.0 / fVar4);
|
|
dirY = dirY * (1.0 / fVar4);
|
|
}
|
|
(maggot->_pathfinder)._movementTarget.x = fVar3;
|
|
(maggot->_pathfinder)._movementTarget.y = dirY;
|
|
if (seed == 0) {
|
|
KAGE_LogMessage(0x10,GHIDRA_CAST<uint8_t *>("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)
|
|
{
|
|
uint32_t rngResult;
|
|
float fVar1;
|
|
float cosAngle;
|
|
|
|
rngResult = Random();
|
|
fVar1 = ((float)((double)GHIDRA_INT(rngResult) + __uint_to_double_fixup[-(GHIDRA_INT(rngResult) >> 0x1f)]) *
|
|
2.3283064e-10 - 0.5) * 90.0 * 0.017453292;
|
|
cosAngle = cos(fVar1);
|
|
outHeading->x = cosAngle;
|
|
fVar1 = sin(fVar1);
|
|
outHeading->y = fVar1;
|
|
rngResult = Random();
|
|
if ((rngResult & 1) == 0) {
|
|
outHeading->x = outHeading->x * -1.0;
|
|
}
|
|
rngResult = Random();
|
|
if ((rngResult & 1) == 0) {
|
|
fVar1 = outHeading->y;
|
|
cosAngle = (target->_pos).y;
|
|
if (((fVar1 < 0.0) && (npcPos.y < cosAngle)) || ((0.0 < fVar1 && (cosAngle < npcPos.y)))) {
|
|
outHeading->y = fVar1 * -1.0;
|
|
}
|
|
}
|
|
return outHeading;
|
|
}
|
|
|
|
// 004db3c0
|
|
void NpcHelper::twitchy_jump_target(Vector *outTarget, Entity_NPC *npc)
|
|
{
|
|
Entity *playerTarget;
|
|
Vector *resultPos;
|
|
uint32_t gridCollision;
|
|
int gridRow;
|
|
int gridIndex;
|
|
float fVar1;
|
|
float fVar2;
|
|
float fVar3;
|
|
Vector scratchVec;
|
|
float toTargetX;
|
|
float local_c;
|
|
float local_8;
|
|
Room *room;
|
|
|
|
room = g_game->_room;
|
|
Entity_NPC::CalcTargetPosition(npc,outTarget,0.0);
|
|
playerTarget = Entity_NPC::GetPlayerTarget(npc);
|
|
local_8 = (playerTarget->_velocity).y;
|
|
fVar2 = (npc->_pos).x - (playerTarget->_pos).x;
|
|
local_c = (playerTarget->_velocity).x;
|
|
fVar1 = (npc->_pos).y - (playerTarget->_pos).y;
|
|
fVar1 = sqrtf(fVar1 * fVar1 + fVar2 * fVar2);
|
|
local_c = local_c * 0.1 * fVar1 + outTarget->x;
|
|
local_8 = local_8 * 0.1 * fVar1 + outTarget->y;
|
|
outTarget->x = local_c;
|
|
outTarget->y = local_8;
|
|
scratchVec.y = local_8 - (npc->_pos).y;
|
|
toTargetX = local_c - (npc->_pos).x;
|
|
fVar1 = sqrtf(scratchVec.y * scratchVec.y + toTargetX * toTargetX);
|
|
if (fVar1 <= 0.0) {
|
|
fVar2 = toTargetX;
|
|
fVar1 = scratchVec.y;
|
|
}
|
|
else {
|
|
fVar2 = toTargetX * (1.0 / fVar1);
|
|
fVar1 = scratchVec.y * (1.0 / fVar1);
|
|
}
|
|
outTarget->x = fVar2 * 40.0 + local_c;
|
|
outTarget->y = fVar1 * 40.0 + local_8;
|
|
resultPos = Room::GetClampedPositionImpl(room,&scratchVec,outTarget,0.0,0.0,0.0,0.0);
|
|
local_8 = resultPos->x;
|
|
outTarget->x = local_8;
|
|
local_c = resultPos->y;
|
|
outTarget->y = local_c;
|
|
fVar2 = (npc->_pos).x - local_8;
|
|
fVar1 = (npc->_pos).y - local_c;
|
|
fVar1 = sqrtf(fVar1 * fVar1 + fVar2 * fVar2);
|
|
if (fVar1 <= 200.0) {
|
|
fVar1 = local_8;
|
|
fVar2 = local_c;
|
|
}
|
|
else {
|
|
local_c = local_c - (npc->_pos).y;
|
|
local_8 = local_8 - (npc->_pos).x;
|
|
fVar1 = sqrtf(local_c * local_c + local_8 * local_8);
|
|
if (fVar1 <= 0.0) {
|
|
fVar2 = local_8;
|
|
fVar3 = local_c;
|
|
}
|
|
else {
|
|
fVar2 = local_8 * (1.0 / fVar1);
|
|
fVar3 = local_c * (1.0 / fVar1);
|
|
}
|
|
fVar1 = fVar2 * 200.0 + (npc->_pos).x;
|
|
fVar2 = fVar3 * 200.0 + (npc->_pos).y;
|
|
outTarget->x = fVar1;
|
|
outTarget->y = fVar2;
|
|
}
|
|
gridRow = GHIDRA_INT(((fVar2 - 120.0) / 40.0 + 0.5));
|
|
gridIndex = GHIDRA_INT(((fVar1 - 40.0) / 40.0 + 0.5));
|
|
if ((((gridIndex < 0) || (room->_gridWidth <= gridIndex)) || (gridRow < 0)) ||
|
|
(room->_gridHeight <= gridRow)) {
|
|
gridIndex = -1;
|
|
}
|
|
else {
|
|
gridIndex = room->_gridWidth * gridRow + gridIndex;
|
|
}
|
|
gridCollision = Room::GetGridCollision(room,gridIndex);
|
|
if (0 < GHIDRA_INT(gridCollision)) {
|
|
resultPos = Room::FindFreeTilePosition(room,&scratchVec,outTarget,64.0);
|
|
outTarget->x = resultPos->x;
|
|
outTarget->y = resultPos->y;
|
|
}
|
|
return;
|
|
}
|
|
|
|
// 004e0930
|
|
void NpcHelper::gutted_fatty_burst_projectiles(Entity *timer)
|
|
{
|
|
uint32_t rngResult;
|
|
uint32_t rngFraction;
|
|
Entity_Projectile *pEVar1;
|
|
int projectilesLeft;
|
|
float originY;
|
|
float dirX;
|
|
float randomScale;
|
|
Vector local_18;
|
|
Vector local_10;
|
|
float originX;
|
|
float originY;
|
|
|
|
projectilesLeft = 2;
|
|
originX = (timer->_pos).x;
|
|
originY = (timer->_pos).y;
|
|
do {
|
|
rngResult = Random();
|
|
originY = (float)((double)GHIDRA_INT(rngResult) + __uint_to_double_fixup[-(GHIDRA_INT(rngResult) >> 0x1f)]) *
|
|
2.3283064e-10 * 3.14;
|
|
originY = originY + originY;
|
|
dirX = cos(originY);
|
|
originY = sin(originY);
|
|
rngResult = Random();
|
|
rngFraction = Random();
|
|
randomScale = (float)((double)GHIDRA_INT(rngFraction) +
|
|
__uint_to_double_fixup[-(GHIDRA_INT(rngFraction) >> 0x1f)]) * 2.3283064e-10;
|
|
local_18.y = randomScale * originY * 2.8;
|
|
local_18.x = randomScale * dirX * 2.8;
|
|
rngFraction = Random();
|
|
randomScale = (float)((double)GHIDRA_INT(rngFraction) +
|
|
__uint_to_double_fixup[-(GHIDRA_INT(rngFraction) >> 0x1f)]) * 2.3283064e-10;
|
|
local_10.x = dirX * 5.0 * randomScale + originX;
|
|
local_10.y = originY * 5.0 * randomScale + originY;
|
|
pEVar1 = (Entity_Projectile *)
|
|
Game::SpawnEx(g_game,9,0,&local_10,&local_18,GHIDRA_CAST<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<uint8_t *>((GHIDRA_CAST<char *>(&(timer[1])) + 0x40)))),
|
|
*GHIDRA_CAST<float *>((timer[1]._sprite._animDefaultName._buf + 8)),timer->_flags,GHIDRA_CAST<Entity *>(0x0));
|
|
(**(code **)(*GHIDRA_CAST<int *>(pEVar1) + 0xc))();
|
|
projectilesLeft = projectilesLeft + -1;
|
|
} while (projectilesLeft != 0);
|
|
projectilesLeft = 2;
|
|
do {
|
|
rngResult = Random();
|
|
originY = (float)((double)GHIDRA_INT(rngResult) + __uint_to_double_fixup[-(GHIDRA_INT(rngResult) >> 0x1f)]) *
|
|
2.3283064e-10 * 3.14;
|
|
originY = originY + originY;
|
|
dirX = cos(originY);
|
|
originY = sin(originY);
|
|
rngResult = Random();
|
|
rngFraction = Random();
|
|
randomScale = (float)((double)GHIDRA_INT(rngFraction) +
|
|
__uint_to_double_fixup[-(GHIDRA_INT(rngFraction) >> 0x1f)]) * 2.3283064e-10;
|
|
local_10.y = randomScale * originY * 2.8;
|
|
local_10.x = randomScale * dirX * 2.8;
|
|
rngFraction = Random();
|
|
randomScale = (float)((double)GHIDRA_INT(rngFraction) +
|
|
__uint_to_double_fixup[-(GHIDRA_INT(rngFraction) >> 0x1f)]) * 2.3283064e-10;
|
|
local_18.x = dirX * 5.0 * randomScale + originX;
|
|
local_18.y = originY * 5.0 * randomScale + originY;
|
|
pEVar1 = (Entity_Projectile *)
|
|
Game::SpawnEx(g_game,9,0,&local_18,&local_10,GHIDRA_CAST<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<uint8_t *>((GHIDRA_CAST<char *>(&(timer[1])) + 0x40)))),
|
|
*GHIDRA_CAST<float *>((timer[1]._sprite._animDefaultName._buf + 8)),timer->_flags,GHIDRA_CAST<Entity *>(0x0));
|
|
(**(code **)(*GHIDRA_CAST<int *>(pEVar1) + 0xc))();
|
|
projectilesLeft = projectilesLeft + -1;
|
|
} while (projectilesLeft != 0);
|
|
return;
|
|
}
|
|
|
|
// 004e4870
|
|
uint8_t NpcHelper::candler_is_free_cell(Vector *position)
|
|
{
|
|
uint32_t uVar1;
|
|
int gridY;
|
|
int gridY;
|
|
Room *room;
|
|
|
|
room = g_game->_room;
|
|
gridY = GHIDRA_INT(((position->x - 40.0) / 40.0 + 0.5));
|
|
gridY = GHIDRA_INT(((position->y - 120.0) / 40.0 + 0.5));
|
|
if ((((gridY < 0) || (room->_gridWidth <= gridY)) || (gridY < 0)) || (room->_gridHeight <= gridY))
|
|
{
|
|
gridY = -1;
|
|
}
|
|
else {
|
|
gridY = room->_gridWidth * gridY + gridY;
|
|
}
|
|
uVar1 = Room::GetGridCollision(room,gridY);
|
|
if (((((uVar1 == 0) && (gridY = GHIDRA_INT(((position->x - 40.0) / 40.0 + 0.5)), -1 < gridY)) &&
|
|
((gridY < room->_gridWidth &&
|
|
((gridY = GHIDRA_INT(((position->y - 120.0) / 40.0 + 0.5)), -1 < gridY &&
|
|
(gridY < room->_gridHeight)))))) && (gridY = room->_gridWidth * gridY + gridY, -1 < gridY))
|
|
&& (((0x1bf < gridY || (room->_gridEntities[gridY] == (void *)0x0)) ||
|
|
(*GHIDRA_CAST<int *>((GHIDRA_INT(room->_gridEntities[gridY]) + 4)) != 0x17)))) {
|
|
return 1;
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
// 004e50d0
|
|
uint8_t NpcHelper::whipper_is_target(Entity_NPC *npc, Entity *entity)
|
|
{
|
|
int iVar1;
|
|
uint8_t 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 = Entity::IsVulnerableEnemy(entity,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;
|
|
uint8_t 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;
|
|
uint32_t 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 = ANM2::GetLayer(sprite,GHIDRA_CAST<uint8_t *>(0x1));
|
|
pLVar1->_visible = 1;
|
|
DAT_00c78ef4 = 1;
|
|
(*GHIDRA_CAST<uint16_t *>((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 = ANM2::GetLayer(sprite,GHIDRA_CAST<uint8_t *>(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<uint32_t *>((in_ECX + 0xec)) = 0;
|
|
pLVar1 = ANM2::GetLayer(sprite,GHIDRA_CAST<uint8_t *>(0x2));
|
|
pLVar1->_visible = 1;
|
|
(GHIDRA_CAST<Sprite *>((GHIDRA_CAST<Sprite *>(sprite))))->Sprite::RenderLayer(2,&renderPos,&g_vectorZero,&g_vectorZero);
|
|
pLVar1 = ANM2::GetLayer(sprite,GHIDRA_CAST<uint8_t *>(0x2));
|
|
pLVar1->_visible = 0;
|
|
*GHIDRA_CAST<float *>((in_ECX + 0xec)) = local_98.x;
|
|
}
|
|
return;
|
|
}
|
|
|
|
// 00501e10
|
|
void NpcHelper::bouncer_death_gib(Entity_Effect *timer)
|
|
{
|
|
uint32_t rngResult;
|
|
Entity *pEVar1;
|
|
float sinAngle;
|
|
Vector local_20;
|
|
float local_18;
|
|
float velocityX;
|
|
Vector gibVelocity;
|
|
|
|
rngResult = Random();
|
|
local_20.x = (float)((double)GHIDRA_INT(rngResult) + __uint_to_double_fixup[-(GHIDRA_INT(rngResult) >> 0x1f)]) *
|
|
2.3283064e-10 * 3.14;
|
|
local_20.x = local_20.x + local_20.x;
|
|
rngResult = Random();
|
|
local_18 = (float)((double)GHIDRA_INT(rngResult) + __uint_to_double_fixup[-(GHIDRA_INT(rngResult) >> 0x1f)]) *
|
|
2.3283064e-10 * 12.0;
|
|
velocityX = cos(local_20.x);
|
|
velocityX = velocityX * local_18;
|
|
gibVelocity.x = velocityX;
|
|
sinAngle = sin(local_20.x);
|
|
local_18 = sinAngle * local_18;
|
|
gibVelocity.y = local_18;
|
|
rngResult = Random();
|
|
local_20.x = (timer->_pos).x;
|
|
local_20.y = (timer->_pos).y;
|
|
pEVar1 = Game::SpawnEx(g_game,1000,2,&local_20,&gibVelocity,GHIDRA_CAST<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)
|
|
{
|
|
int *piVar1;
|
|
int64_t lVar2;
|
|
int64_t lVar3;
|
|
int64_t lVar4;
|
|
float fVar5;
|
|
uint8_t isErased;
|
|
char cVar6;
|
|
uint32_t uVar7;
|
|
uint32_t uVar8;
|
|
int *piVar9;
|
|
int iVar10;
|
|
Entity *pEVar11;
|
|
int unusedArg;
|
|
int unusedArg_00;
|
|
void *pvVar12;
|
|
uint32_t uVar13;
|
|
uint32_t uVar14;
|
|
PlayerManager *playerManager;
|
|
bool bVar15;
|
|
float fVar16;
|
|
float fVar17;
|
|
uint64_t timeNs;
|
|
float local_124;
|
|
Entity *local_120;
|
|
Game *local_11c;
|
|
void *local_118;
|
|
float local_114;
|
|
float local_110;
|
|
float local_10c;
|
|
uint32_t local_108;
|
|
uint32_t local_104;
|
|
float spawnVelX;
|
|
float fStack_fc;
|
|
Game *local_f4;
|
|
Entity *owner;
|
|
Vector spawnPos;
|
|
uint32_t local_e4;
|
|
uint32_t local_e0;
|
|
Vector local_d4;
|
|
uint32_t uStack_cc;
|
|
uint32_t spawnSeed;
|
|
void *pvStack_c4;
|
|
int *apiStack_bc [4];
|
|
Vector particleVel;
|
|
int *local_a4;
|
|
Vector spawnVel [2];
|
|
int iStack_8c;
|
|
uint32_t uStack_88;
|
|
int iStack_84;
|
|
uint32_t uStack_80;
|
|
Vector bloodVel [2];
|
|
uint32_t uStack_6c;
|
|
uint32_t local_68;
|
|
uint32_t uStack_64;
|
|
uint32_t local_60 [5];
|
|
uint8_t auStack_4c [8];
|
|
int foundNode2;
|
|
int foundNode;
|
|
uint8_t auStack_30 [8];
|
|
int iStack_28;
|
|
int iStack_24;
|
|
uint32_t uStack_20;
|
|
uint32_t stackCookie;
|
|
code *fnPtr;
|
|
Game *game;
|
|
uint32_t *spawnerRef;
|
|
ColorMod *spriteColor;
|
|
|
|
stackCookie = __security_cookie ^ GHIDRA_UINT(&local_124);
|
|
spawnPos.x = (timer->_pos).x;
|
|
spawnPos.y = (timer->_pos).y;
|
|
owner = timer;
|
|
uVar7 = Random();
|
|
fVar16 = (float)((double)GHIDRA_INT(uVar7) + __uint_to_double_fixup[-(GHIDRA_INT(uVar7) >> 0x1f)]) *
|
|
2.3283064e-10 * 3.14;
|
|
local_120 = GHIDRA_CAST<Entity *>((fVar16 + fVar16));
|
|
uVar7 = Random();
|
|
local_110 = (float)((double)GHIDRA_INT(uVar7) + __uint_to_double_fixup[-(GHIDRA_INT(uVar7) >> 0x1f)]) *
|
|
2.3283064e-10 * 4.0 + 6.0;
|
|
spawnVelX = cos((float)local_120);
|
|
spawnVelX = spawnVelX * local_110;
|
|
spawnVel[0].x = spawnVelX;
|
|
fVar16 = sin((float)local_120);
|
|
local_118 = (void *)(fVar16 * local_110);
|
|
spawnVel[0].y = (float)local_118;
|
|
spawnSeed = Random();
|
|
local_11c = g_game;
|
|
local_114 = 0.0;
|
|
local_e4 = 3;
|
|
local_f4 = GHIDRA_CAST<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);
|
|
uVar7 = local_e4;
|
|
if (*GHIDRA_CAST<int *>(&g_game->_deathmatchManager) < 2) {
|
|
LAB_0052926a:
|
|
local_124 = local_114;
|
|
}
|
|
else {
|
|
pEVar11 = *GHIDRA_CAST<Entity **>(&(*GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>(&((g_game->_deathmatchManager))) + 0xc))));
|
|
local_120 = pEVar11;
|
|
uVar8 = Random();
|
|
fVar16 = local_114;
|
|
local_68 = 5;
|
|
uStack_64 = 9;
|
|
local_110 = 9.80909e-45;
|
|
local_60[0] = 7;
|
|
if (local_f4 != GHIDRA_CAST<Game *>(&DAT_00000005)) goto LAB_0052926a;
|
|
if (uVar7 < 0x12d) {
|
|
if (uVar7 == 300) {
|
|
while ((local_124 = local_114, local_114 == 0.0 ||
|
|
(cVar6 = (**(code **)(*GHIDRA_CAST<int *>(pEVar11) + 0x24))(), cVar6 != '\0'))) {
|
|
if (uVar8 == 0) {
|
|
KAGE_LogMessage(0x10,GHIDRA_CAST<uint8_t *>("RNG Seed is zero!\n"));
|
|
fnPtr = (code *)swi(3);
|
|
(*fnPtr)();
|
|
return;
|
|
}
|
|
uVar8 = uVar8 >> ((uint8_t)local_68 & 0x1f) ^ uVar8;
|
|
uVar8 = uVar8 << ((uint8_t)uStack_64 & 0x1f) ^ uVar8;
|
|
uVar8 = uVar8 >> (SUB41(local_110,0) & 0x1f) ^ uVar8;
|
|
iVar10 = ItemPool::GetCardEx(uVar8,0x19,10,10,1);
|
|
iStack_28 = 5;
|
|
iStack_24 = 9;
|
|
uStack_20 = 7;
|
|
(*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(auStack_30)) + 0x4))) = uVar8;
|
|
local_114 = (float)lua_callback_run_get_card(GHIDRA_CAST<RNG *>((auStack_30 + 4)),iVar10,1,1,0);
|
|
}
|
|
}
|
|
else {
|
|
if (uVar7 == 0x46) {
|
|
local_d4.x = (float)(GHIDRA_UINT(local_114) >> 0xb);
|
|
do {
|
|
local_124 = local_114;
|
|
if (local_114 != 0.0) {
|
|
fnPtr = *(code **)(*GHIDRA_CAST<int *>(pEVar11) + 0x28);
|
|
ItemPool::GetPillEffect(&g_game->_itemPool,GHIDRA_UINT(local_114),GHIDRA_CAST<Entity_Player *>(0x0));
|
|
cVar6 = (*fnPtr)();
|
|
if (cVar6 == '\0') goto LAB_00529272;
|
|
pEVar11 = local_120;
|
|
}
|
|
if (uVar8 == 0) {
|
|
KAGE_LogMessage(0x10,GHIDRA_CAST<uint8_t *>("RNG Seed is zero!\n"));
|
|
fnPtr = (code *)swi(3);
|
|
(*fnPtr)();
|
|
return;
|
|
}
|
|
uVar8 = uVar8 >> ((uint8_t)local_68 & 0x1f) ^ uVar8;
|
|
uVar8 = uVar8 << ((uint8_t)uStack_64 & 0x1f) ^ uVar8;
|
|
uVar8 = uVar8 >> (SUB41(local_110,0) & 0x1f) ^ uVar8;
|
|
uVar7 = ItemPool::GetPill(uVar8);
|
|
local_114 = (float)(uVar7 | (GHIDRA_UINT(local_d4.x) & 1) << 0xb);
|
|
} while( true );
|
|
}
|
|
if (uVar7 != 100) goto LAB_0052926a;
|
|
local_124 = local_114;
|
|
if (local_114 == 3.50325e-44) {
|
|
LAB_005290ba:
|
|
bVar15 = false;
|
|
}
|
|
else {
|
|
local_d4.x = local_114;
|
|
msvc::set<int>::find_node();
|
|
if (((*GHIDRA_CAST<char *>((foundNode + 0xd)) == '\0') && (*GHIDRA_CAST<int *>((foundNode + 0x10)) <= GHIDRA_INT(fVar16)))
|
|
&& (foundNode != pEVar11->_index)) goto LAB_005290ba;
|
|
bVar15 = true;
|
|
}
|
|
if ((fVar16 == 0.0) || (bVar15)) {
|
|
local_124 = (float)(**(code **)(*GHIDRA_CAST<int *>(pEVar11) + 0x84))();
|
|
local_114 = local_124;
|
|
}
|
|
}
|
|
}
|
|
else {
|
|
if (uVar7 != 0x15e) goto LAB_0052926a;
|
|
while ((local_124 = local_114, local_114 == 0.0 ||
|
|
(cVar6 = (**(code **)(*GHIDRA_CAST<int *>(pEVar11) + 0x2c))(), cVar6 != '\0'))) {
|
|
local_114 = (float)ItemPool::GetTrinket(&g_game->_itemPool,0);
|
|
}
|
|
}
|
|
}
|
|
LAB_00529272:
|
|
local_120 = EntityFactory::Create(local_11c->_entityFactory,GHIDRA_UINT(local_f4),0);
|
|
if (local_120 == GHIDRA_CAST<Entity *>(0x0)) goto LAB_00529568;
|
|
timeNs = GetTimeNs();
|
|
pEVar11 = local_120;
|
|
local_108 = GHIDRA_UINT((timeNs >> 0x20));
|
|
lVar2 = (timeNs & 0xffffffff) * 0x431bde82;
|
|
local_104 = GHIDRA_UINT(((uint64_t)lVar2 >> 0x20));
|
|
lVar3 = (uint64_t)local_108 * 0xd7b634db + ((timeNs & 0xffffffff) * 0xd7b634db >> 0x20);
|
|
local_d4.y = (float)(lVar3 + lVar2);
|
|
lVar2 = (uint64_t)local_108 * 0x431bde82 +
|
|
(uint64_t)
|
|
CONCAT14(CARRY4(GHIDRA_UINT(((uint64_t)lVar3 >> 0x20)),
|
|
local_104 + CARRY4(GHIDRA_UINT(lVar2),GHIDRA_UINT(lVar3))),
|
|
GHIDRA_INT(((uint64_t)(lVar3 + lVar2) >> 0x20)));
|
|
local_e0 = GHIDRA_UINT(((uint64_t)lVar2 >> 0x20));
|
|
spawnerRef = &local_120->_spawnerEntity;
|
|
local_10c = (float)(GHIDRA_UINT(lVar2) >> 0x12 | local_e0 * 0x4000);
|
|
local_e0 = local_e0 >> 0x12;
|
|
local_120->_spawnerType = 0;
|
|
local_120->_spawnerVariant = 0;
|
|
if (*spawnerRef != 0) {
|
|
local_a4 = spawnerRef;
|
|
msvc::multiset<unsigned_int>::erase();
|
|
}
|
|
iVar10 = *GHIDRA_CAST<int *>(pEVar11);
|
|
*spawnerRef = 0;
|
|
(pEVar11->_pos).x = spawnPos.x;
|
|
(pEVar11->_pos).y = spawnPos.y;
|
|
(pEVar11->_velocity).x = spawnVelX;
|
|
(pEVar11->_velocity).y = (float)local_118;
|
|
(**(code **)(iVar10 + 4))(local_f4,local_e4);
|
|
game = local_11c;
|
|
pvVar12 = local_11c->_room;
|
|
iVar10 = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(pvVar12) + 0x1214));
|
|
*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(pvVar12) + 0x1214)) = iVar10 + 1;
|
|
pEVar11->_index = iVar10;
|
|
EntityList::AddEntity(GHIDRA_CAST<EntityList *>((GHIDRA_INT(pvVar12) + 0x1218)),pEVar11);
|
|
isErased = Game::ShouldEraseEnemy(pEVar11);
|
|
if (isErased != 0) {
|
|
Entity::RemoveWithPoof(pEVar11,unusedArg);
|
|
}
|
|
if ((pEVar11->_exists != 0) &&
|
|
((game->_proceduralItemManager)._proceduralItems._begin !=
|
|
(game->_proceduralItemManager)._proceduralItems._end)) {
|
|
uStack_88 = pEVar11->_variant;
|
|
iStack_8c = pEVar11->_type;
|
|
msvc::map<unsigned_long_long>::find();
|
|
pvVar12 = (game->_proceduralItemManager)._spawnTriggerTargets._head;
|
|
if (pvStack_c4 == pvVar12) {
|
|
iStack_84 = pEVar11->_type;
|
|
uStack_80 = 0xffffffff;
|
|
piVar9 = GHIDRA_CAST<int *>(std)::map<unsigned_long_long>::find();
|
|
pvStack_c4 = (void *)*piVar9;
|
|
if (pvStack_c4 == pvVar12) goto LAB_005294e4;
|
|
}
|
|
uVar7 = 0;
|
|
playerManager = &g_game->_playerManager;
|
|
if (GHIDRA_INT((g_game->_playerManager)._playerList._end) - GHIDRA_INT((playerManager->_playerList)._begin) >>
|
|
2 != 0) {
|
|
do {
|
|
pvVar12 = (playerManager->_playerList)._end;
|
|
if (GHIDRA_INT(pvVar12) - GHIDRA_INT((playerManager->_playerList)._begin) >> 2 == 0) {
|
|
KAGE_LogMessage(0x10,GHIDRA_CAST<uint8_t *>("PlayerManager::GetPlayer() : There are no players! \n"));
|
|
pvVar12 = (playerManager->_playerList)._end;
|
|
}
|
|
piVar9 = (playerManager->_playerList)._begin;
|
|
if (uVar7 < GHIDRA_UINT((GHIDRA_INT(pvVar12) - GHIDRA_INT(piVar9) >> 2))) {
|
|
piVar9 = piVar9 + uVar7;
|
|
}
|
|
trigger_set_dispatch((void *)(*piVar9 + 0x1fc8),6,pEVar11,&spawnPos,spawnVel);
|
|
uVar7 = uVar7 + 1;
|
|
playerManager = &g_game->_playerManager;
|
|
} while (uVar7 < GHIDRA_UINT((GHIDRA_INT((g_game->_playerManager)._playerList._end) -
|
|
GHIDRA_INT((playerManager->_playerList)._begin) >> 2)));
|
|
}
|
|
}
|
|
LAB_005294e4:
|
|
timeNs = GetTimeNs();
|
|
uVar7 = GHIDRA_UINT((timeNs >> 0x20));
|
|
lVar2 = (timeNs & 0xffffffff) * 0x431bde82;
|
|
local_104 = GHIDRA_UINT(((uint64_t)lVar2 >> 0x20));
|
|
lVar3 = (uint64_t)uVar7 * 0x431bde82;
|
|
local_108 = GHIDRA_UINT(lVar3);
|
|
lVar4 = (uint64_t)uVar7 * 0xd7b634db + ((timeNs & 0xffffffff) * 0xd7b634db >> 0x20);
|
|
local_d4.y = (float)(lVar4 + lVar2);
|
|
lVar3 = lVar3 + (uint64_t)
|
|
CONCAT14(CARRY4(GHIDRA_UINT(((uint64_t)lVar4 >> 0x20)),
|
|
local_104 + CARRY4(GHIDRA_UINT(lVar2),GHIDRA_UINT(lVar4))),
|
|
GHIDRA_INT(((uint64_t)(lVar4 + lVar2) >> 0x20)));
|
|
uVar8 = GHIDRA_UINT(((uint64_t)lVar3 >> 0x20));
|
|
fVar16 = (float)(GHIDRA_UINT(lVar3) >> 0x12 | uVar8 * 0x4000);
|
|
uVar7 = GHIDRA_INT(fVar16) - GHIDRA_INT(local_10c);
|
|
bVar15 = CARRY4(GHIDRA_UINT(g_entitySpawnTimeMs),uVar7);
|
|
(*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(g_entitySpawnTimeMs)) + 0x0))) = GHIDRA_UINT(g_entitySpawnTimeMs) + uVar7;
|
|
(*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(g_entitySpawnTimeMs)) + 0x4))) =
|
|
(*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(g_entitySpawnTimeMs)) + 0x4))) +
|
|
(((uVar8 >> 0x12) - local_e0) - GHIDRA_UINT((GHIDRA_UINT(fVar16) < GHIDRA_UINT(local_10c)))) + GHIDRA_UINT(bVar15);
|
|
LAB_00529568:
|
|
bloodVel[0].x = spawnVelX * 0.4;
|
|
bloodVel[0].y = (float)local_118 * 0.4;
|
|
iVar10 = GHIDRA_INT(owner[1]._pendingDamageFlags) * -7 + 0x42;
|
|
*GHIDRA_CAST<int *>((local_120 + 1)) = iVar10;
|
|
*GHIDRA_CAST<int *>(&(*GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>(&(local_120[1])) + 0x4)))) = iVar10;
|
|
uVar7 = Random();
|
|
pEVar11 = Game::Spawn(g_game,1000,2,&spawnPos,bloodVel,GHIDRA_CAST<Entity *>(0x0),1,uVar7);
|
|
(**(code **)(*GHIDRA_CAST<int *>(pEVar11) + 0x3c))(&DAT_00c5c800,0xffffffff,0xff);
|
|
(pEVar11->_sprite)._offset.x = 0.0;
|
|
(pEVar11->_sprite)._offset.y = -5.0;
|
|
pEVar11->_renderDepthOffset = 10.0;
|
|
uVar7 = Random();
|
|
local_11c = GHIDRA_CAST<Game *>(((uVar7 & 1) + 1));
|
|
do {
|
|
if (local_11c == GHIDRA_CAST<Game *>(0x0)) {
|
|
return;
|
|
}
|
|
uVar7 = Random();
|
|
fVar16 = (float)((double)GHIDRA_INT(uVar7) + __uint_to_double_fixup[-(GHIDRA_INT(uVar7) >> 0x1f)]) *
|
|
2.3283064e-10 * 3.14;
|
|
local_f4 = GHIDRA_CAST<Game *>((fVar16 + fVar16));
|
|
fVar16 = cos((float)local_f4);
|
|
local_d4.x = fVar16 * 12.0 * 0.5 + spawnVelX;
|
|
fVar16 = sin((float)local_f4);
|
|
local_d4.y = fVar16 * 12.0 * 0.5 + fStack_fc;
|
|
uVar7 = Random();
|
|
fVar16 = (float)((double)GHIDRA_INT(uVar7) + __uint_to_double_fixup[-(GHIDRA_INT(uVar7) >> 0x1f)]) *
|
|
2.3283064e-10 * 3.14;
|
|
fVar16 = fVar16 + fVar16;
|
|
uVar7 = Random();
|
|
local_114 = (float)((double)GHIDRA_INT(uVar7) + __uint_to_double_fixup[-(GHIDRA_INT(uVar7) >> 0x1f)]) *
|
|
2.3283064e-10 * 4.0 + 2.0;
|
|
fVar17 = cos(fVar16);
|
|
pvStack_c4 = (void *)(fVar17 * local_114);
|
|
particleVel.x = (float)pvStack_c4;
|
|
local_10c = sin(fVar16);
|
|
local_10c = local_10c * local_114;
|
|
particleVel.y = local_10c;
|
|
local_104 = Random();
|
|
local_f4 = g_game;
|
|
piVar9 = GHIDRA_CAST<int *>(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 *>((apiStack_bc + -0x1f)),&local_104);
|
|
fVar16 = local_124;
|
|
if (1 < *GHIDRA_CAST<int *>(&g_game->_deathmatchManager)) {
|
|
piVar1 = *GHIDRA_CAST<int **>(&(*GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>(&((g_game->_deathmatchManager))) + 0xc))));
|
|
uVar7 = Random();
|
|
uStack_6c = 5;
|
|
local_68 = 9;
|
|
local_114 = 9.80909e-45;
|
|
uStack_64 = 7;
|
|
if (local_120 == GHIDRA_CAST<Entity *>(&DAT_00000005)) {
|
|
if (GHIDRA_UINT(fVar16) < 0x12d) {
|
|
if (fVar16 == 4.2039e-43) {
|
|
while ((piVar9 == GHIDRA_CAST<int *>(0x0) ||
|
|
(cVar6 = (**(code **)(*piVar1 + 0x24))(piVar9), cVar6 != '\0'))) {
|
|
if (uVar7 == 0) {
|
|
KAGE_LogMessage(0x10,GHIDRA_CAST<uint8_t *>("RNG Seed is zero!\n"));
|
|
fnPtr = (code *)swi(3);
|
|
(*fnPtr)();
|
|
return;
|
|
}
|
|
uVar7 = uVar7 >> ((uint8_t)uStack_6c & 0x1f) ^ uVar7;
|
|
uVar7 = uVar7 << ((uint8_t)local_68 & 0x1f) ^ uVar7;
|
|
uVar7 = uVar7 >> (SUB41(local_114,0) & 0x1f) ^ uVar7;
|
|
iVar10 = ItemPool::GetCardEx(uVar7,0x19,10,10,1);
|
|
(*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(auStack_30)) + 0x4))) = 5;
|
|
iStack_28 = 9;
|
|
iStack_24 = 7;
|
|
(*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(auStack_30)) + 0x0))) = uVar7;
|
|
piVar9 = GHIDRA_CAST<int *>(lua_callback_run_get_card(GHIDRA_CAST<RNG *>(auStack_30),iVar10,1,1,0));
|
|
}
|
|
}
|
|
else {
|
|
if (fVar16 == 9.80909e-44) {
|
|
uVar8 = GHIDRA_UINT(piVar9) >> 0xb;
|
|
do {
|
|
if (piVar9 != GHIDRA_CAST<int *>(0x0)) {
|
|
fnPtr = *(code **)(*piVar1 + 0x28);
|
|
iVar10 = ItemPool::GetPillEffect
|
|
(&g_game->_itemPool,GHIDRA_UINT(piVar9),GHIDRA_CAST<Entity_Player *>(0x0));
|
|
cVar6 = (*fnPtr)(iVar10);
|
|
if (cVar6 == '\0') goto LAB_00529a2e;
|
|
}
|
|
if (uVar7 == 0) {
|
|
KAGE_LogMessage(0x10,GHIDRA_CAST<uint8_t *>("RNG Seed is zero!\n"));
|
|
fnPtr = (code *)swi(3);
|
|
(*fnPtr)();
|
|
return;
|
|
}
|
|
uVar7 = uVar7 >> ((uint8_t)uStack_6c & 0x1f) ^ uVar7;
|
|
uVar7 = uVar7 << ((uint8_t)local_68 & 0x1f) ^ uVar7;
|
|
uVar7 = uVar7 >> (SUB41(local_114,0) & 0x1f) ^ uVar7;
|
|
uVar13 = ItemPool::GetPill(uVar7);
|
|
piVar9 = GHIDRA_CAST<int *>((uVar13 | (uVar8 & 1) << 0xb));
|
|
} while( true );
|
|
}
|
|
if (fVar16 == 1.4013e-43) {
|
|
if (piVar9 == GHIDRA_CAST<int *>(0x19)) {
|
|
LAB_00529876:
|
|
bVar15 = false;
|
|
}
|
|
else {
|
|
local_a4 = piVar9;
|
|
msvc::set<int>::find_node(auStack_4c,&local_a4);
|
|
if (((*GHIDRA_CAST<char *>((foundNode2 + 0xd)) == '\0') &&
|
|
(*GHIDRA_CAST<int *>((foundNode2 + 0x10)) <= GHIDRA_INT(piVar9))) && (foundNode2 != piVar1[8]))
|
|
goto LAB_00529876;
|
|
bVar15 = true;
|
|
}
|
|
if ((piVar9 == GHIDRA_CAST<int *>(0x0)) || (bVar15)) {
|
|
piVar9 = GHIDRA_CAST<int *>((**(code **)(*piVar1 + 0x84))(0));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else if (fVar16 == 4.90454e-43) {
|
|
while ((piVar9 == GHIDRA_CAST<int *>(0x0) ||
|
|
(cVar6 = (**(code **)(*piVar1 + 0x2c))(piVar9), cVar6 != '\0'))) {
|
|
piVar9 = GHIDRA_CAST<int *>(ItemPool)::GetTrinket(&g_game->_itemPool,0);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
LAB_00529a2e:
|
|
pEVar11 = EntityFactory::Create(local_f4->_entityFactory,GHIDRA_UINT(local_120),0);
|
|
if (pEVar11 != GHIDRA_CAST<Entity *>(0x0)) {
|
|
timeNs = GetTimeNs();
|
|
uVar7 = GHIDRA_UINT((timeNs >> 0x20));
|
|
lVar2 = (timeNs & 0xffffffff) * 0x431bde82;
|
|
lVar3 = (uint64_t)uVar7 * 0xd7b634db + ((timeNs & 0xffffffff) * 0xd7b634db >> 0x20);
|
|
local_114 = (float)(lVar3 + lVar2);
|
|
lVar2 = (uint64_t)uVar7 * 0x431bde82 +
|
|
(uint64_t)
|
|
CONCAT14(CARRY4(GHIDRA_UINT(((uint64_t)lVar3 >> 0x20)),
|
|
GHIDRA_INT(((uint64_t)lVar2 >> 0x20)) +
|
|
GHIDRA_UINT(CARRY4(GHIDRA_UINT(lVar2),GHIDRA_UINT(lVar3)))),
|
|
GHIDRA_INT(((uint64_t)(lVar3 + lVar2) >> 0x20)));
|
|
uStack_cc = GHIDRA_UINT(((uint64_t)lVar2 >> 0x20));
|
|
spawnerRef = &pEVar11->_spawnerEntity;
|
|
uVar7 = GHIDRA_UINT(lVar2) >> 0x12 | uStack_cc * 0x4000;
|
|
uStack_cc = uStack_cc >> 0x12;
|
|
pEVar11->_spawnerType = 0;
|
|
pEVar11->_spawnerVariant = 0;
|
|
if (*spawnerRef != 0) {
|
|
apiStack_bc[0] = spawnerRef;
|
|
msvc::multiset<unsigned_int>::erase(apiStack_bc);
|
|
}
|
|
iVar10 = *GHIDRA_CAST<int *>(pEVar11);
|
|
*spawnerRef = 0;
|
|
(pEVar11->_pos).x = local_d4.x;
|
|
(pEVar11->_pos).y = local_d4.y;
|
|
(pEVar11->_velocity).x = (float)pvStack_c4;
|
|
(pEVar11->_velocity).y = local_10c;
|
|
(**(code **)(iVar10 + 4))(local_120,local_124,piVar9,local_104);
|
|
game = local_f4;
|
|
pvVar12 = local_f4->_room;
|
|
iVar10 = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(pvVar12) + 0x1214));
|
|
*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(pvVar12) + 0x1214)) = iVar10 + 1;
|
|
pEVar11->_index = iVar10;
|
|
EntityList::AddEntity(GHIDRA_CAST<EntityList *>((GHIDRA_INT(pvVar12) + 0x1218)),pEVar11);
|
|
isErased = Game::ShouldEraseEnemy(pEVar11);
|
|
if (isErased != 0) {
|
|
Entity::RemoveWithPoof(pEVar11,unusedArg_00);
|
|
}
|
|
if ((pEVar11->_exists != 0) &&
|
|
((game->_proceduralItemManager)._proceduralItems._begin !=
|
|
(game->_proceduralItemManager)._proceduralItems._end)) {
|
|
iStack_84 = pEVar11->_variant;
|
|
uVar8 = pEVar11->_type;
|
|
uStack_88 = uVar8;
|
|
msvc::map<unsigned_long_long>::find(&local_118,&uStack_88);
|
|
if (local_118 == (game->_proceduralItemManager)._spawnTriggerTargets._head) {
|
|
local_e0 = 0xffffffff;
|
|
local_e4 = uVar8;
|
|
piVar9 = GHIDRA_CAST<int *>(std)::map<unsigned_long_long>::find(local_60,&local_e4);
|
|
local_118 = (void *)*piVar9;
|
|
if (local_118 == (game->_proceduralItemManager)._spawnTriggerTargets._head)
|
|
goto LAB_00529ca4;
|
|
}
|
|
uVar8 = 0;
|
|
playerManager = &g_game->_playerManager;
|
|
if (GHIDRA_INT((g_game->_playerManager)._playerList._end) -
|
|
GHIDRA_INT((playerManager->_playerList)._begin) >> 2 != 0) {
|
|
do {
|
|
pvVar12 = (playerManager->_playerList)._end;
|
|
if (GHIDRA_INT(pvVar12) - GHIDRA_INT((playerManager->_playerList)._begin) >> 2 == 0) {
|
|
KAGE_LogMessage(0x10,GHIDRA_CAST<uint8_t *>("PlayerManager::GetPlayer() : There are no players! \n"));
|
|
pvVar12 = (playerManager->_playerList)._end;
|
|
}
|
|
piVar9 = (playerManager->_playerList)._begin;
|
|
if (uVar8 < GHIDRA_UINT((GHIDRA_INT(pvVar12) - GHIDRA_INT(piVar9) >> 2))) {
|
|
piVar9 = piVar9 + uVar8;
|
|
}
|
|
trigger_set_dispatch((void *)(*piVar9 + 0x1fc8),6,pEVar11,&local_d4,&particleVel);
|
|
uVar8 = uVar8 + 1;
|
|
playerManager = &g_game->_playerManager;
|
|
} while (uVar8 < GHIDRA_UINT((GHIDRA_INT((g_game->_playerManager)._playerList._end) -
|
|
GHIDRA_INT((playerManager->_playerList)._begin) >> 2)));
|
|
}
|
|
}
|
|
LAB_00529ca4:
|
|
timeNs = GetTimeNs();
|
|
uVar8 = GHIDRA_UINT((timeNs >> 0x20));
|
|
lVar2 = (timeNs & 0xffffffff) * 0x431bde82;
|
|
pvStack_c4 = (void *)((uint64_t)lVar2 >> 0x20);
|
|
lVar3 = (uint64_t)uVar8 * 0x431bde82;
|
|
local_10c = (float)lVar3;
|
|
lVar4 = (uint64_t)uVar8 * 0xd7b634db + ((timeNs & 0xffffffff) * 0xd7b634db >> 0x20);
|
|
local_f4 = GHIDRA_CAST<Game *>((lVar4 + lVar2));
|
|
lVar3 = lVar3 + (uint64_t)
|
|
CONCAT14(CARRY4(GHIDRA_UINT(((uint64_t)lVar4 >> 0x20)),
|
|
GHIDRA_INT(pvStack_c4) + GHIDRA_UINT(CARRY4(GHIDRA_UINT(lVar2),GHIDRA_UINT(lVar4)))),
|
|
GHIDRA_INT(((uint64_t)(lVar4 + lVar2) >> 0x20)));
|
|
uVar14 = GHIDRA_UINT(((uint64_t)lVar3 >> 0x20));
|
|
uVar8 = GHIDRA_UINT(lVar3) >> 0x12 | uVar14 * 0x4000;
|
|
uVar13 = uVar8 - uVar7;
|
|
bVar15 = CARRY4(GHIDRA_UINT(g_entitySpawnTimeMs),uVar13);
|
|
(*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(g_entitySpawnTimeMs)) + 0x0))) = GHIDRA_UINT(g_entitySpawnTimeMs) + uVar13;
|
|
(*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(g_entitySpawnTimeMs)) + 0x4))) =
|
|
(*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(g_entitySpawnTimeMs)) + 0x4))) + (((uVar14 >> 0x12) - uStack_cc) - GHIDRA_UINT((uVar8 < uVar7))) +
|
|
GHIDRA_UINT(bVar15);
|
|
}
|
|
(**(code **)(*GHIDRA_CAST<int *>(pEVar11) + 0x3c))(&DAT_00c5c800,0xffffffff,0xff,0,1);
|
|
spriteColor = &(pEVar11->_sprite)._color;
|
|
if (&pEVar11->_splatColor != spriteColor) {
|
|
fVar16 = (pEVar11->_sprite)._color._tint[1];
|
|
fVar17 = (pEVar11->_sprite)._color._tint[2];
|
|
fVar5 = (pEVar11->_sprite)._color._tint[3];
|
|
(pEVar11->_splatColor)._tint[0] = spriteColor->_tint[0];
|
|
(pEVar11->_splatColor)._tint[1] = fVar16;
|
|
(pEVar11->_splatColor)._tint[2] = fVar17;
|
|
(pEVar11->_splatColor)._tint[3] = fVar5;
|
|
fVar16 = (pEVar11->_sprite)._color._colorize[1];
|
|
fVar17 = (pEVar11->_sprite)._color._colorize[2];
|
|
fVar5 = (pEVar11->_sprite)._color._colorize[3];
|
|
(pEVar11->_splatColor)._colorize[0] = (pEVar11->_sprite)._color._colorize[0];
|
|
(pEVar11->_splatColor)._colorize[1] = fVar16;
|
|
(pEVar11->_splatColor)._colorize[2] = fVar17;
|
|
(pEVar11->_splatColor)._colorize[3] = fVar5;
|
|
*GHIDRA_CAST<uint64_t *>((pEVar11->_splatColor)._offset) =
|
|
*GHIDRA_CAST<uint64_t *>((pEVar11->_sprite)._color._offset);
|
|
(pEVar11->_splatColor)._offset[2] = (pEVar11->_sprite)._color._offset[2];
|
|
}
|
|
(**(code **)(*GHIDRA_CAST<int *>(pEVar11) + 0xc))();
|
|
local_11c = GHIDRA_CAST<Game *>((GHIDRA_INT(local_11c) + -1));
|
|
} while( true );
|
|
}
|
|
|
|
// 005441e0
|
|
uint8_t NpcHelper::tarboy_is_creep_near(Entity_NPC *npc, Vector *position)
|
|
{
|
|
int iVar1;
|
|
uint32_t i;
|
|
int *entityIt;
|
|
float deltaY;
|
|
float deltaX;
|
|
uint32_t entityCount;
|
|
bool isFriendly;
|
|
|
|
if ((npc == GHIDRA_CAST<Entity_NPC *>(0x0)) || ((npc->_flags & 0x20000000) == 0)) {
|
|
isFriendly = false;
|
|
}
|
|
else {
|
|
isFriendly = true;
|
|
}
|
|
i = 0;
|
|
entityCount = *GHIDRA_CAST<uint32_t *>((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;
|
|
uint8_t bVar2;
|
|
Vector *pVVar3;
|
|
uint32_t uVar4;
|
|
uint8_t *pbVar5;
|
|
uint32_t uVar6;
|
|
Entity *pEVar7;
|
|
uint8_t *expectedName;
|
|
int extraout_ECX;
|
|
int extraout_ECX_00;
|
|
int unused;
|
|
bool isLess;
|
|
float fVar8;
|
|
float fVar9;
|
|
uint32_t sourceRef;
|
|
uint32_t local_114;
|
|
uint32_t local_110;
|
|
uint32_t local_10c;
|
|
float local_108;
|
|
float local_104;
|
|
float local_100;
|
|
float local_fc;
|
|
uint32_t local_f8;
|
|
uint32_t local_f4;
|
|
float local_f0;
|
|
uint32_t uStack_ec;
|
|
uint32_t uStack_e8;
|
|
uint32_t uStack_e4;
|
|
Vector local_d4;
|
|
float local_cc;
|
|
uint8_t *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 = Entity_NPC::CalcTargetPosition(npc,&local_d4,0.0);
|
|
local_c8 = GHIDRA_CAST<uint8_t *>((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<uint8_t *>(((float)local_c8 * (1.0 / fVar8)));
|
|
}
|
|
if (npc->_controllerID != -1) {
|
|
pVVar3 = Entity_NPC::GetControllerInput(npc,&local_d4,0.0);
|
|
local_c4 = pVVar3->x;
|
|
local_c8 = GHIDRA_CAST<uint8_t *>(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<uint8_t *>("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<uint8_t *>(0x0)) {
|
|
LAB_005489d8:
|
|
bVar2 = ANM2::SetAnimation(&npc->_sprite,local_c8,1);
|
|
if (bVar2 != 0) {
|
|
AnimationState::Rewind(&(npc->_sprite)._animState);
|
|
(npc->_sprite)._animState._isPlaying = 1;
|
|
}
|
|
}
|
|
else {
|
|
if (0xf < *GHIDRA_CAST<uint32_t *>((pbVar5 + 0x14))) {
|
|
pbVar5 = *GHIDRA_CAST<uint8_t **>(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<uint8_t *>("RNG Seed is zero!\n"));
|
|
pcVar1 = (code *)swi(3);
|
|
(*pcVar1)();
|
|
return;
|
|
}
|
|
uVar4 = uVar4 >> ((uint8_t)uStack_ec & 0x1f) ^ uVar4;
|
|
uVar4 = uVar4 << ((uint8_t)uStack_e8 & 0x1f) ^ uVar4;
|
|
(npc->_sprite)._flipX = ~((uint8_t)(uVar4 >> (SUB41(local_c4,0) & 0x1f)) ^ (uint8_t)uVar4) & 1;
|
|
npc->_isKillOnTouch = 1;
|
|
LAB_00548a4b:
|
|
bVar2 = Entity::IsFrame(GHIDRA_CAST<Entity *>(npc),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 = Entity::IsFrame(GHIDRA_CAST<Entity *>(npc),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<uint8_t *>((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 = Game::Spawn(g_game,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;
|
|
(**(code **)(*GHIDRA_CAST<int *>(npc) + 0x24))(&sourceRef);
|
|
}
|
|
if ((npc->_dead != 0) && ((npc->_flags & 0x1000000) == 0)) {
|
|
pEVar7 = Entity_NPC::GetPlayerTarget(npc);
|
|
local_c8 = GHIDRA_CAST<uint8_t *>((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<uint8_t *>((((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<uint8_t *>(((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;
|
|
ProjectileParams::ProjectileParams(&projParams);
|
|
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<uint64_t *>((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;
|
|
uint32_t uVar1;
|
|
int chargeChange;
|
|
Entity *effect;
|
|
uint32_t 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;
|
|
(**(code **)(*GHIDRA_CAST<int *>(collider) + 0x20))(0x3f800000,0,0,&damageSource,0x1e);
|
|
}
|
|
else {
|
|
sourceRef = EntityRef::EntityRef(&damageSource);
|
|
(**(code **)(*GHIDRA_CAST<int *>(collider) + 0x20))(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;
|
|
Entity_Player::PlayExtraAnimation(GHIDRA_CAST<Entity_Player *>(collider),&DAT_00b1d3b0);
|
|
Entity_Player::ResetItemState(GHIDRA_CAST<Entity_Player *>(collider));
|
|
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<uint8_t *>((GHIDRA_CAST<char *>(&(chargeChange)) + 0x0))) = collider[5]._valid, (*GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>(&(chargeChange)) + 0x1))) = collider[5]._visible,
|
|
(*GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>(&(chargeChange)) + 0x2))) = collider[5]._exists, (*GHIDRA_CAST<uint8_t *>((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 = Entity_Player::GetActiveMaxCharge(GHIDRA_CAST<Entity_Player *>(collider),uVar2);
|
|
if (chargeChange == 1) {
|
|
chargeChange = -1000;
|
|
}
|
|
else if (GHIDRA_INT(local_3c.x) < 0xd) {
|
|
chargeChange = -2;
|
|
}
|
|
else {
|
|
chargeChange = GHIDRA_INT(((uint64_t)((int64_t)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);
|
|
HUD::FlashChargeBar(&g_game->_hud,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 = Game::SpawnEx(g_game,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;
|
|
uint32_t trailStart;
|
|
int iVar4;
|
|
float *pfVar5;
|
|
int iVar6;
|
|
LayerState *layer;
|
|
int iVar7;
|
|
uint32_t uVar8;
|
|
int iVar9;
|
|
uint32_t uVar10;
|
|
uint32_t heightIndex;
|
|
int segmentCount;
|
|
float *segmentPosCursor;
|
|
uint32_t trailIndex;
|
|
float fVar11;
|
|
float fVar12;
|
|
float fVar13;
|
|
float fVar14;
|
|
float fVar15;
|
|
float prevHeight;
|
|
float remainingSpacing;
|
|
Vector prevPos;
|
|
uint8_t *layerIndex;
|
|
int segmentsLeft;
|
|
float segmentData [7];
|
|
int *trailHeights;
|
|
int *trailPositions;
|
|
uint32_t 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<uint8_t *>(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 = ANM2::GetLayer(&npc->_sprite,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 = ANM2::GetLayer(&npc->_sprite,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)
|
|
{
|
|
uint32_t 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;
|
|
int iVar2;
|
|
int *spreadSlot;
|
|
float averageX;
|
|
float deltaX;
|
|
float averageY;
|
|
float fVar3;
|
|
float maxSpread;
|
|
int *playersEnd;
|
|
|
|
iVar2 = npc->_parent;
|
|
if (iVar2 != 0) {
|
|
if (outSpread != GHIDRA_CAST<float *>(0x0)) {
|
|
*outSpread = 0.0;
|
|
iVar2 = npc->_parent;
|
|
}
|
|
fVar3 = *GHIDRA_CAST<float *>((iVar2 + 0x340));
|
|
outPos->x = *GHIDRA_CAST<float *>((iVar2 + 0x33c));
|
|
outPos->y = fVar3;
|
|
return;
|
|
}
|
|
iVar2 = 0;
|
|
fVar3 = 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));
|
|
iVar2 = iVar2 + 1;
|
|
}
|
|
}
|
|
averageX = averageX / (float)iVar2;
|
|
averageY = averageY / (float)iVar2;
|
|
if (outSpread != GHIDRA_CAST<float *>(0x0)) {
|
|
if (1 < iVar2) {
|
|
for (; spreadSlot != playersEnd; spreadSlot = spreadSlot + 1) {
|
|
iVar2 = *spreadSlot;
|
|
if ((*GHIDRA_CAST<int *>((iVar2 + 0x2c)) == 0) && (*GHIDRA_CAST<int *>((iVar2 + 0x13c0)) != 0x23)) {
|
|
deltaX = averageX - *GHIDRA_CAST<float *>((iVar2 + 0x33c));
|
|
fVar3 = averageY - *GHIDRA_CAST<float *>((iVar2 + 0x340));
|
|
fVar3 = sqrtf(fVar3 * fVar3 + deltaX * deltaX);
|
|
if (fVar3 <= maxSpread) {
|
|
fVar3 = maxSpread;
|
|
}
|
|
maxSpread = fVar3;
|
|
}
|
|
}
|
|
}
|
|
*outSpread = fVar3;
|
|
}
|
|
outPos->x = averageX;
|
|
outPos->y = averageY;
|
|
return;
|
|
}
|
|
|
|
// 005581b0
|
|
void NpcHelper::willo_orbit(Entity_NPC *npc)
|
|
{
|
|
int *playerIt;
|
|
int player;
|
|
float fVar2;
|
|
float fVar3;
|
|
float fVar4;
|
|
float fVar5;
|
|
float fVar6;
|
|
Vector slotPos;
|
|
int player;
|
|
|
|
if (npc->_subtype == 0) {
|
|
willo_slot(npc,&slotPos,0);
|
|
fVar3 = (npc->_pos).x;
|
|
fVar4 = slotPos.x - fVar3;
|
|
fVar2 = slotPos.y - (npc->_pos).y;
|
|
fVar2 = sqrtf(fVar2 * fVar2 + fVar4 * fVar4);
|
|
if ((fVar2 < 20.0) && (npc->_projectileDelay == 1)) {
|
|
npc->_projectileDelay = 0;
|
|
}
|
|
player = npc->_parent;
|
|
if (player == 0) {
|
|
player = 0;
|
|
fVar2 = g_vectorZero.x;
|
|
fVar4 = 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) {
|
|
player = player + 1;
|
|
fVar5 = *GHIDRA_CAST<float *>((player + 0x360)) / *GHIDRA_CAST<float *>((player + 0x36c));
|
|
fVar6 = *GHIDRA_CAST<float *>((player + 0x364)) / *GHIDRA_CAST<float *>((player + 0x36c));
|
|
fVar2 = fVar2 + fVar5 + fVar5;
|
|
fVar4 = fVar4 + fVar6 + fVar6;
|
|
}
|
|
}
|
|
fVar2 = fVar2 / (float)player;
|
|
fVar4 = fVar4 / (float)player;
|
|
}
|
|
else {
|
|
fVar2 = *GHIDRA_CAST<float *>((player + 0x360)) / *GHIDRA_CAST<float *>((player + 0x36c));
|
|
fVar4 = *GHIDRA_CAST<float *>((player + 0x364)) / *GHIDRA_CAST<float *>((player + 0x36c));
|
|
fVar2 = fVar2 + fVar2 + g_vectorZero.x;
|
|
fVar4 = fVar4 + fVar4 + g_vectorZero.y;
|
|
}
|
|
fVar5 = (slotPos.x - (fVar3 + fVar2)) * 0.5;
|
|
fVar6 = (slotPos.y - (fVar4 + (npc->_pos).y)) * 0.5;
|
|
fVar3 = sqrtf(fVar6 * fVar6 + fVar5 * fVar5);
|
|
if (10.0 < fVar3) {
|
|
if (fVar3 <= 0.0) {
|
|
fVar5 = fVar5 * 10.0;
|
|
fVar6 = fVar6 * 10.0;
|
|
}
|
|
else {
|
|
fVar5 = fVar5 * (1.0 / fVar3) * 10.0;
|
|
fVar6 = fVar6 * (1.0 / fVar3) * 10.0;
|
|
}
|
|
}
|
|
fVar3 = npc->_friction;
|
|
(npc->_velocity).x = (fVar5 + fVar2) / fVar3;
|
|
(npc->_velocity).y = (fVar6 + fVar4) / fVar3;
|
|
}
|
|
return;
|
|
}
|
|
|
|
// 005583d0
|
|
void NpcHelper::willo_attack(Entity_NPC *npc)
|
|
{
|
|
uint8_t 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 = AnimationState::IsEventTriggered(&(npc->_sprite)._animState,&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 = AnimationState::IsEventTriggered(&(npc->_sprite)._animState,GHIDRA_CAST<uint8_t *>("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 = Entity_NPC::GetPlayerTarget(npc);
|
|
ProjectileParams::ProjectileParams(&projParams);
|
|
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<uint32_t *>((GHIDRA_CAST<char *>(&(projParams.BulletFlags)) + 0x0))) = 0x2000;
|
|
(*GHIDRA_CAST<uint32_t *>((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<uint32_t *>((GHIDRA_CAST<char *>(&(DAT_00c33cd0)) + 0x4)));
|
|
if ((npc->_parent == 0) && (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)
|
|
{
|
|
uint8_t bVar1;
|
|
uint32_t flagsHigh;
|
|
Entity_NPC *willo;
|
|
uint8_t *curAnimName;
|
|
char *targetAnimName;
|
|
bool bVar3;
|
|
uint32_t *eraseKey;
|
|
float v1XLocal;
|
|
Vector *spawnPos;
|
|
uint8_t *animData;
|
|
uint32_t flagsHigh;
|
|
uint32_t *parentSlot;
|
|
|
|
v1XLocal = v1X;
|
|
spawnPos = position;
|
|
flagsHigh = Random();
|
|
willo = (Entity_NPC *)
|
|
Game::SpawnEx(g_game,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 != 0) {
|
|
eraseKey = parentSlot;
|
|
msvc::multiset<unsigned_int>::erase(&eraseKey);
|
|
}
|
|
*parentSlot = spawner;
|
|
msvc::multiset<unsigned_int>::insert(parentSlot);
|
|
}
|
|
*GHIDRA_CAST<uint32_t *>(&willo->_flags) = GHIDRA_UINT(willo->_flags) & 0xfffffffb;
|
|
flagsHigh = *GHIDRA_CAST<uint32_t *>((GHIDRA_INT(&willo->_flags) + 4));
|
|
(willo->_v1).x = v1XLocal;
|
|
(willo->_v1).y = 1.0;
|
|
*GHIDRA_CAST<uint32_t *>((GHIDRA_INT(&willo->_flags) + 4)) = flagsHigh;
|
|
if ((char)subType == '\0') {
|
|
willo->_state = 6;
|
|
animData = (willo->_sprite)._animState._animData;
|
|
if (animData != GHIDRA_CAST<uint8_t *>(0x0)) {
|
|
curAnimName = animData;
|
|
if (0xf < *GHIDRA_CAST<uint32_t *>((animData + 0x14))) {
|
|
curAnimName = *GHIDRA_CAST<uint8_t **>(animData);
|
|
}
|
|
targetAnimName = "UnderwaterSpawn";
|
|
do {
|
|
bVar1 = *curAnimName;
|
|
bVar3 = bVar1 < (uint8_t)*targetAnimName;
|
|
if (bVar1 != *targetAnimName) {
|
|
LAB_00559170:
|
|
flagsHigh = -GHIDRA_UINT(bVar3) | 1;
|
|
goto LAB_00559175;
|
|
}
|
|
if (bVar1 == 0) break;
|
|
bVar1 = curAnimName[1];
|
|
bVar3 = bVar1 < (uint8_t)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 = ANM2::SetAnimation(&willo->_sprite,GHIDRA_CAST<uint8_t *>("UnderwaterSpawn"),1);
|
|
if (bVar1 != 0) {
|
|
AnimationState::Rewind(&(willo->_sprite)._animState);
|
|
(willo->_sprite)._animState._isPlaying = 1;
|
|
}
|
|
return willo;
|
|
}
|
|
willo->_state = 7;
|
|
animData = (willo->_sprite)._animState._animData;
|
|
if (animData != GHIDRA_CAST<uint8_t *>(0x0)) {
|
|
curAnimName = animData;
|
|
if (0xf < *GHIDRA_CAST<uint32_t *>((animData + 0x14))) {
|
|
curAnimName = *GHIDRA_CAST<uint8_t **>(animData);
|
|
}
|
|
targetAnimName = "UnderwaterAttack";
|
|
do {
|
|
bVar1 = *curAnimName;
|
|
bVar3 = bVar1 < (uint8_t)*targetAnimName;
|
|
if (bVar1 != *targetAnimName) {
|
|
LAB_005590d0:
|
|
flagsHigh = -GHIDRA_UINT(bVar3) | 1;
|
|
goto LAB_005590d5;
|
|
}
|
|
if (bVar1 == 0) break;
|
|
bVar1 = curAnimName[1];
|
|
bVar3 = bVar1 < (uint8_t)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 = ANM2::SetAnimation(&willo->_sprite,GHIDRA_CAST<uint8_t *>("UnderwaterAttack"),1);
|
|
if (bVar1 != 0) {
|
|
AnimationState::Rewind(&(willo->_sprite)._animState);
|
|
(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)
|
|
{
|
|
uint32_t projVariant;
|
|
uint32_t rngResult;
|
|
uint32_t 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 *)
|
|
Game::SpawnEx(g_game,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<uint8_t *>((GHIDRA_CAST<char *>(&(owner[1])) + 0x40)))),
|
|
*GHIDRA_CAST<float *>((owner[1]._sprite._animDefaultName._buf + 8)),owner->_flags,GHIDRA_CAST<Entity *>(0x0));
|
|
(**(code **)(*GHIDRA_CAST<int *>(projectile) + 0xc))();
|
|
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 *)
|
|
Game::SpawnEx(g_game,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<uint8_t *>((GHIDRA_CAST<char *>(&(owner[1])) + 0x40)))),
|
|
*GHIDRA_CAST<float *>((owner[1]._sprite._animDefaultName._buf + 8)),owner->_flags,GHIDRA_CAST<Entity *>(0x0));
|
|
(**(code **)(*GHIDRA_CAST<int *>(projectile) + 0xc))();
|
|
highShotsLeft = highShotsLeft + -1;
|
|
} while (highShotsLeft != 0);
|
|
return;
|
|
}
|
|
|
|
// 0055d070
|
|
uint8_t NpcHelper::polty_target_set(int gridIndex)
|
|
{
|
|
if (((gridIndex < 0) || (0x1bf < gridIndex)) ||
|
|
(*GHIDRA_CAST<short *>((GHIDRA_CAST<char *>(g_game->_room) + gridIndex * 2 + 0xe6c)) < 1)) {
|
|
*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(this) + 0xbc4)) = gridIndex;
|
|
return 1;
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
// 0055d0b0
|
|
uint8_t NpcHelper::polty_is_target_liftable(Entity_NPC *npc)
|
|
{
|
|
uint8_t local_AL_113;
|
|
int extraout_EDX;
|
|
float snapY;
|
|
int gridWidth;
|
|
Room *room;
|
|
|
|
gridWidth = npc->_spawnerEntity;
|
|
if ((gridWidth == 0) || (*GHIDRA_CAST<int *>((gridWidth + 0x28)) != 5)) {
|
|
if (npc->_i2 < 0) {
|
|
return 0;
|
|
}
|
|
room = g_game->_room;
|
|
local_AL_113 = Room::CanPickupGridEntity(room,npc->_i2);
|
|
if (local_AL_113 == 0) {
|
|
return 0;
|
|
}
|
|
if (npc->_variant == 1) {
|
|
return 1;
|
|
}
|
|
gridWidth = room->_gridWidth;
|
|
snapY = (float)(extraout_EDX / gridWidth) * 40.0 + 120.0;
|
|
(npc->_pos).x = (float)(extraout_EDX % gridWidth) * 40.0 + 40.0;
|
|
}
|
|
else {
|
|
snapY = *GHIDRA_CAST<float *>((gridWidth + 0x340));
|
|
(npc->_pos).x = *GHIDRA_CAST<float *>((gridWidth + 0x33c));
|
|
}
|
|
(npc->_pos).y = snapY;
|
|
(npc->_velocity).x = g_vectorZero.x;
|
|
(npc->_velocity).y = g_vectorZero.y;
|
|
return 1;
|
|
}
|
|
|
|
// 0055d180
|
|
uint8_t NpcHelper::polty_is_pot_cell(Entity_NPC *npc, int gridIndex)
|
|
{
|
|
uint8_t bVar1;
|
|
Game *game;
|
|
int gridWidth;
|
|
|
|
game = g_game;
|
|
if (GHIDRA_UINT(gridIndex) < 0x1c0) {
|
|
gridWidth = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(g_game->_room) + gridIndex * 4 + 0x24));
|
|
if ((gridWidth != 0) &&
|
|
(((*GHIDRA_CAST<int *>((gridWidth + 4)) == 6 || (*GHIDRA_CAST<int *>((gridWidth + 4)) == 0x1a)) &&
|
|
(*GHIDRA_CAST<int *>((gridWidth + 0xc)) == 1)))) {
|
|
bVar1 = polty_target_set(npc,gridIndex);
|
|
if (bVar1 != 0) {
|
|
gridWidth = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(game->_room) + 0xc));
|
|
(npc->_pos).x = (float)(gridIndex % gridWidth) * 40.0 + 40.0;
|
|
(npc->_pos).y = (float)(gridIndex / gridWidth) * 40.0 + 120.0;
|
|
return 1;
|
|
}
|
|
}
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
// 005688c0
|
|
void NpcHelper::mother_set_collision_class(Entity_NPC *npc, int collisionClass)
|
|
{
|
|
uint32_t dequeBlock;
|
|
uint32_t dequeBlockSlot;
|
|
uint32_t dequeOffset;
|
|
|
|
npc->_entityCollisionClass = collisionClass;
|
|
if (npc->_subtype == 0) {
|
|
dequeOffset = (npc->_entityDeque)._offset;
|
|
dequeBlockSlot = dequeOffset + 1 & 3;
|
|
dequeBlock = dequeOffset + 1 >> 2;
|
|
if (*GHIDRA_CAST<int *>((*GHIDRA_CAST<int *>((GHIDRA_INT((npc->_entityDeque)._map) +
|
|
((npc->_entityDeque)._mapSize - 1 & dequeBlock) * 4)) + dequeBlockSlot * 4))
|
|
!= 0) {
|
|
*GHIDRA_CAST<int *>((*GHIDRA_CAST<int *>((*GHIDRA_CAST<int *>((GHIDRA_INT((npc->_entityDeque)._map) +
|
|
((npc->_entityDeque)._mapSize - 1 & dequeBlock) * 4)) +
|
|
dequeBlockSlot * 4)) + 0x188)) = collisionClass;
|
|
dequeOffset = (npc->_entityDeque)._offset;
|
|
}
|
|
dequeBlock = dequeOffset + 2 >> 2;
|
|
dequeOffset = dequeOffset + 2 & 3;
|
|
if (*GHIDRA_CAST<int *>((*GHIDRA_CAST<int *>((GHIDRA_INT((npc->_entityDeque)._map) +
|
|
((npc->_entityDeque)._mapSize - 1 & dequeBlock) * 4)) + dequeOffset * 4)) !=
|
|
0) {
|
|
*GHIDRA_CAST<int *>((*GHIDRA_CAST<int *>((*GHIDRA_CAST<int *>((GHIDRA_INT((npc->_entityDeque)._map) +
|
|
((npc->_entityDeque)._mapSize - 1 & dequeBlock) * 4)) +
|
|
dequeOffset * 4)) + 0x188)) = collisionClass;
|
|
}
|
|
}
|
|
return;
|
|
}
|
|
|
|
// 00568cc0
|
|
void NpcHelper::mother_spawn_parts()
|
|
{
|
|
uint32_t uVar1;
|
|
uint32_t uVar2;
|
|
Entity *pEVar3;
|
|
Entity_NPC *npc;
|
|
Entity *part2;
|
|
Entity *in_ECX;
|
|
uint32_t blockSlot;
|
|
uint32_t *childRef;
|
|
float offsetY;
|
|
Vector part3Pos;
|
|
Vector part2Pos;
|
|
Vector part1Pos;
|
|
Entity_NPC *local_24;
|
|
float local_20;
|
|
Entity_NPC *local_1c;
|
|
int *local_18;
|
|
Entity *local_14;
|
|
int dequeBlock;
|
|
uint64_t flags;
|
|
|
|
part1Pos.x = DAT_00c33d3c + (in_ECX->_pos).x;
|
|
part1Pos.y = DAT_00c33d40 + (in_ECX->_pos).y;
|
|
npc = GHIDRA_CAST<Entity_NPC *>(Game)::Spawn(g_game,0x390,0,&part1Pos,&g_vectorZero,in_ECX,1,in_ECX->_initSeed)
|
|
;
|
|
offsetY = (in_ECX->_posOffset).y - DAT_00c33d40;
|
|
(npc->_posOffset).x = (in_ECX->_posOffset).x - DAT_00c33d3c;
|
|
(npc->_posOffset).y = offsetY;
|
|
local_24 = npc;
|
|
mother_set_collision_class(npc,0);
|
|
uVar1 = *GHIDRA_CAST<uint32_t *>((GHIDRA_INT(&npc->_flags) + 4));
|
|
npc->_isInvicible = 1;
|
|
*GHIDRA_CAST<uint32_t *>(&npc->_flags) = GHIDRA_UINT(npc->_flags) & 0xfffffffb | 0x80100011;
|
|
*GHIDRA_CAST<uint32_t *>((GHIDRA_INT(&npc->_flags) + 4)) = uVar1;
|
|
Entity::SetVisibleFlag(GHIDRA_CAST<Entity *>(npc),0);
|
|
if (npc->_parent != 0) {
|
|
local_14 = GHIDRA_CAST<Entity *>(&npc->_parent);
|
|
msvc::multiset<unsigned_int>::erase(&local_14);
|
|
}
|
|
npc->_parent = in_ECX;
|
|
msvc::multiset<unsigned_int>::insert(&npc->_parent);
|
|
(**(code **)(*GHIDRA_CAST<int *>(npc) + 0xc))();
|
|
part2Pos.x = DAT_00c33d44 + (in_ECX->_pos).x;
|
|
part2Pos.y = DAT_00c33d48 + (in_ECX->_pos).y;
|
|
part2 = Game::Spawn(g_game,0x390,0,&part2Pos,&g_vectorZero,in_ECX,2,in_ECX->_initSeed);
|
|
local_20 = -g_vectorOne.x;
|
|
local_1c = GHIDRA_CAST<Entity_NPC *>(-g_vectorOne.y);
|
|
local_14 = part2;
|
|
Entity::SetSize(part2,70.0,(Vector)(CONCAT44(g_vectorOne.y,g_vectorOne.x) ^ 0x8000000080000000),-1
|
|
);
|
|
offsetY = (in_ECX->_posOffset).y - DAT_00c33d48;
|
|
(part2->_posOffset).x = (in_ECX->_posOffset).x - DAT_00c33d44;
|
|
(part2->_posOffset).y = offsetY;
|
|
if (part2->_parent != 0) {
|
|
local_18 = &part2->_parent;
|
|
msvc::multiset<unsigned_int>::erase(&local_18);
|
|
}
|
|
part2->_parent = in_ECX;
|
|
msvc::multiset<unsigned_int>::insert(&part2->_parent);
|
|
flags = part2->_flags;
|
|
*GHIDRA_CAST<uint32_t *>((GHIDRA_INT(&part2->_flags) + 4)) = *GHIDRA_CAST<uint32_t *>((GHIDRA_INT(&part2->_flags) + 4));
|
|
*GHIDRA_CAST<uint32_t *>(&part2->_flags) = GHIDRA_UINT(flags) & 0xfffffffb | 0x80000000;
|
|
(**(code **)(*GHIDRA_CAST<int *>(part2) + 0xc))();
|
|
part3Pos.x = DAT_00c33d4c + (in_ECX->_pos).x;
|
|
part3Pos.y = DAT_00c33d50 + (in_ECX->_pos).y;
|
|
part2 = Game::Spawn(g_game,0x390,0,&part3Pos,&g_vectorZero,in_ECX,3,in_ECX->_initSeed);
|
|
local_20 = -g_vectorOne.x;
|
|
local_1c = GHIDRA_CAST<Entity_NPC *>(-g_vectorOne.y);
|
|
Entity::SetSize(part2,70.0,(Vector)(CONCAT44(g_vectorOne.y,g_vectorOne.x) ^ 0x8000000080000000),-1
|
|
);
|
|
offsetY = (in_ECX->_posOffset).y - DAT_00c33d50;
|
|
(part2->_posOffset).x = (in_ECX->_posOffset).x - DAT_00c33d4c;
|
|
(part2->_posOffset).y = offsetY;
|
|
if (part2->_parent != 0) {
|
|
local_18 = &part2->_parent;
|
|
msvc::multiset<unsigned_int>::erase(&local_18);
|
|
}
|
|
part2->_parent = in_ECX;
|
|
msvc::multiset<unsigned_int>::insert(&part2->_parent);
|
|
flags = part2->_flags;
|
|
*GHIDRA_CAST<uint32_t *>((GHIDRA_INT(&part2->_flags) + 4)) = *GHIDRA_CAST<uint32_t *>((GHIDRA_INT(&part2->_flags) + 4));
|
|
*GHIDRA_CAST<uint32_t *>(&part2->_flags) = GHIDRA_UINT(flags) & 0xfffffffb | 0x80000000;
|
|
(**(code **)(*GHIDRA_CAST<int *>(part2) + 0xc))();
|
|
local_18 = GHIDRA_CAST<int *>(0x0);
|
|
msvc::deque<int>::resize(3,&local_18);
|
|
uVar2 = in_ECX[2]._dropRNG._seed;
|
|
blockSlot = uVar2 & 3;
|
|
dequeBlock = *GHIDRA_CAST<int *>((in_ECX[2]._minecart + (uVar2 >> 2 & in_ECX[2]._hitEffect - 1) * 4));
|
|
local_1c = GHIDRA_CAST<Entity_NPC *>((dequeBlock + blockSlot * 4));
|
|
if (*GHIDRA_CAST<int *>((dequeBlock + blockSlot * 4)) != 0) {
|
|
local_18 = GHIDRA_CAST<int *>(local_1c);
|
|
msvc::multiset<unsigned_int>::erase(&local_18);
|
|
}
|
|
*GHIDRA_CAST<Entity_NPC **>(local_1c) = local_24;
|
|
msvc::multiset<unsigned_int>::insert(local_1c);
|
|
uVar2 = in_ECX[2]._dropRNG._seed + 1;
|
|
blockSlot = uVar2 & 3;
|
|
dequeBlock = *GHIDRA_CAST<int *>((in_ECX[2]._minecart + (uVar2 >> 2 & in_ECX[2]._hitEffect - 1) * 4));
|
|
local_1c = GHIDRA_CAST<Entity_NPC *>((dequeBlock + blockSlot * 4));
|
|
if (*GHIDRA_CAST<int *>((dequeBlock + blockSlot * 4)) != 0) {
|
|
local_24 = local_1c;
|
|
msvc::multiset<unsigned_int>::erase(&local_24);
|
|
}
|
|
*GHIDRA_CAST<Entity **>(local_1c) = local_14;
|
|
msvc::multiset<unsigned_int>::insert(local_1c);
|
|
uVar2 = in_ECX[2]._dropRNG._seed + 2;
|
|
blockSlot = uVar2 & 3;
|
|
dequeBlock = *GHIDRA_CAST<int *>((in_ECX[2]._minecart + (uVar2 >> 2 & in_ECX[2]._hitEffect - 1) * 4));
|
|
local_1c = GHIDRA_CAST<Entity_NPC *>((dequeBlock + blockSlot * 4));
|
|
if (*GHIDRA_CAST<int *>((dequeBlock + blockSlot * 4)) != 0) {
|
|
local_24 = local_1c;
|
|
msvc::multiset<unsigned_int>::erase(&local_24);
|
|
}
|
|
*GHIDRA_CAST<Entity **>(local_1c) = part2;
|
|
msvc::multiset<unsigned_int>::insert(local_1c);
|
|
local_1c = GHIDRA_CAST<Entity_NPC *>(&in_ECX->_child);
|
|
if (in_ECX->_child != 0) {
|
|
local_24 = local_1c;
|
|
msvc::multiset<unsigned_int>::erase(&local_24);
|
|
}
|
|
pEVar3 = local_14;
|
|
*GHIDRA_CAST<Entity **>(local_1c) = local_14;
|
|
msvc::multiset<unsigned_int>::insert(local_1c);
|
|
childRef = &pEVar3->_child;
|
|
if (pEVar3->_child != 0) {
|
|
local_24 = GHIDRA_CAST<Entity_NPC *>(childRef);
|
|
msvc::multiset<unsigned_int>::erase(&local_24);
|
|
}
|
|
*childRef = part2;
|
|
msvc::multiset<unsigned_int>::insert(childRef);
|
|
return;
|
|
}
|
|
|
|
// 0056c800
|
|
void NpcHelper::mother_2_slam_burst(float *param_1)
|
|
{
|
|
uint32_t rngResult;
|
|
Entity *spawnedEffect;
|
|
uint32_t uVar1;
|
|
int in_ECX;
|
|
int iVar2;
|
|
int iVar3;
|
|
float fVar4;
|
|
Vector local_3c;
|
|
Vector local_34;
|
|
Vector slamPos;
|
|
float local_24;
|
|
float local_20;
|
|
float local_1c;
|
|
float local_18;
|
|
float backDirX;
|
|
Manager *manager;
|
|
|
|
Room::GetClampedPositionImpl
|
|
(g_game->_room,&slamPos,GHIDRA_CAST<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);
|
|
Game::ShakeScreen(g_game,0xc);
|
|
rngResult = Random();
|
|
spawnedEffect = Game::Spawn(g_game,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;
|
|
(**(code **)(*GHIDRA_CAST<int *>(spawnedEffect) + 0x3c))(&g_colorGreenSplat,0xffffffff,0xff,0,1);
|
|
(**(code **)(*GHIDRA_CAST<int *>(spawnedEffect) + 0xc))();
|
|
local_18 = param_1[1];
|
|
backDirX = *param_1;
|
|
fVar4 = sqrtf(local_18 * local_18 + backDirX * backDirX);
|
|
if (0.0 < fVar4) {
|
|
local_18 = local_18 * (1.0 / fVar4);
|
|
backDirX = backDirX * (1.0 / fVar4);
|
|
}
|
|
backDirX = -backDirX;
|
|
local_18 = -local_18;
|
|
iVar2 = 0xc;
|
|
do {
|
|
iVar3 = iVar2;
|
|
rngResult = Random();
|
|
local_20 = ((float)((double)GHIDRA_INT(rngResult) + __uint_to_double_fixup[-(GHIDRA_INT(rngResult) >> 0x1f)])
|
|
* 2.3283064e-10 - 0.5) * 90.0 * 0.017453292;
|
|
local_1c = cos(local_20);
|
|
fVar4 = sin(local_20);
|
|
local_20 = local_18 * local_1c + backDirX * fVar4;
|
|
local_1c = backDirX * local_1c - local_18 * fVar4;
|
|
rngResult = Random();
|
|
local_24 = (float)((double)GHIDRA_INT(rngResult) + __uint_to_double_fixup[-(GHIDRA_INT(rngResult) >> 0x1f)]) *
|
|
2.3283064e-10 * 10.0 + 20.0;
|
|
rngResult = Random();
|
|
fVar4 = (float)((double)GHIDRA_INT(rngResult) + __uint_to_double_fixup[-(GHIDRA_INT(rngResult) >> 0x1f)]) *
|
|
2.3283064e-10;
|
|
local_3c.y = fVar4 * local_20 * 5.0 + slamPos.y;
|
|
local_3c.x = fVar4 * local_1c * 5.0 + slamPos.x;
|
|
rngResult = Random();
|
|
local_34.x = local_24 * local_1c;
|
|
local_34.y = local_24 * local_20;
|
|
spawnedEffect = Game::Spawn(g_game,1000,4,&local_3c,&local_34,GHIDRA_CAST<Entity *>(0x0),0,rngResult);
|
|
(**(code **)(*GHIDRA_CAST<int *>(spawnedEffect) + 0xc))();
|
|
iVar2 = iVar3 + -1;
|
|
} while (iVar2 != 0);
|
|
iVar3 = iVar3 + 0xb;
|
|
do {
|
|
rngResult = Random();
|
|
local_24 = ((float)((double)GHIDRA_INT(rngResult) + __uint_to_double_fixup[-(GHIDRA_INT(rngResult) >> 0x1f)])
|
|
* 2.3283064e-10 - 0.5) * 90.0 * 0.017453292;
|
|
local_20 = cos(local_24);
|
|
fVar4 = sin(local_24);
|
|
local_1c = local_18 * local_20 + backDirX * fVar4;
|
|
local_20 = backDirX * local_20 - local_18 * fVar4;
|
|
rngResult = Random();
|
|
local_24 = (float)((double)GHIDRA_INT(rngResult) + __uint_to_double_fixup[-(GHIDRA_INT(rngResult) >> 0x1f)]) *
|
|
2.3283064e-10 * 25.0 + 5.0;
|
|
rngResult = Random();
|
|
fVar4 = (float)((double)GHIDRA_INT(rngResult) + __uint_to_double_fixup[-(GHIDRA_INT(rngResult) >> 0x1f)]) *
|
|
2.3283064e-10;
|
|
local_34.y = fVar4 * local_1c * 5.0 + slamPos.y;
|
|
local_34.x = fVar4 * local_20 * 5.0 + slamPos.x;
|
|
rngResult = Random();
|
|
uVar1 = Random();
|
|
if (uVar1 % 5 == 0) {
|
|
uVar1 = 0;
|
|
}
|
|
else {
|
|
uVar1 = Random();
|
|
uVar1 = (~uVar1 & 1) + 3;
|
|
}
|
|
local_3c.x = local_24 * local_20;
|
|
local_3c.y = local_24 * local_1c;
|
|
spawnedEffect = Game::Spawn(g_game,1000,2,&local_34,&local_3c,GHIDRA_CAST<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);
|
|
(**(code **)(*GHIDRA_CAST<int *>(spawnedEffect) + 0xc))();
|
|
iVar3 = iVar3 + -1;
|
|
} while (iVar3 != 0);
|
|
return;
|
|
}
|
|
|
|
// 0056fcf0
|
|
void NpcHelper::mother_render(Entity_NPC *npc, Vector *offset)
|
|
{
|
|
ColorMod *pCVar1;
|
|
ColorMod *pCVar2;
|
|
uint64_t uVar3;
|
|
float fVar4;
|
|
float fVar5;
|
|
float fVar6;
|
|
float fVar7;
|
|
float fVar8;
|
|
float fVar9;
|
|
float fVar10;
|
|
float fVar11;
|
|
float fVar12;
|
|
float fVar13;
|
|
Entity_NPC *colorTarget;
|
|
int layerId;
|
|
float pixelScale;
|
|
double dVar14;
|
|
double dVar15;
|
|
uint32_t local_6c [26];
|
|
float offsetY;
|
|
|
|
if (npc->_variant == 0) {
|
|
pixelScale = g_displayPixelRatio * g_screenPointScale;
|
|
dVar14 = floor((double)(((((npc->_posOffset).x + (npc->_pos).x) - 60.0) * 0.65 +
|
|
(g_screenWidth - 338.0) * 0.5) * pixelScale + 0.5));
|
|
dVar15 = floor((double)(((((npc->_pos).y + (npc->_posOffset).y) - 140.0) * 0.65 +
|
|
(g_screenHeight - 182.0) * 0.5) * pixelScale + 0.5));
|
|
offsetY = offset->y;
|
|
(npc->_renderPosition).x = (float)dVar14 / pixelScale + offset->x;
|
|
(npc->_renderPosition).y = (float)dVar15 / pixelScale + offsetY;
|
|
layerId = npc->_subtype;
|
|
if ((layerId == 0) ||
|
|
(colorTarget = GHIDRA_CAST<Entity_NPC *>(npc->_parent), GHIDRA_CAST<Entity_NPC *>(npc->_parent) == GHIDRA_CAST<Entity_NPC *>(0x0)))
|
|
{
|
|
colorTarget = npc;
|
|
}
|
|
pixelScale = (colorTarget->_sprite)._color._tint[0];
|
|
fVar4 = (colorTarget->_sprite)._color._tint[1];
|
|
fVar5 = (colorTarget->_sprite)._color._tint[2];
|
|
fVar6 = (colorTarget->_sprite)._color._tint[3];
|
|
offsetY = (colorTarget->_sprite)._color._offset[2];
|
|
pCVar1 = &(colorTarget->_sprite)._color;
|
|
pCVar2 = &(npc->_sprite)._color;
|
|
fVar7 = (colorTarget->_sprite)._color._colorize[0];
|
|
fVar8 = (colorTarget->_sprite)._color._colorize[1];
|
|
fVar9 = (colorTarget->_sprite)._color._colorize[2];
|
|
fVar10 = (colorTarget->_sprite)._color._colorize[3];
|
|
uVar3 = *GHIDRA_CAST<uint64_t *>((colorTarget->_sprite)._color._offset);
|
|
if (pCVar1 != pCVar2) {
|
|
fVar11 = (npc->_sprite)._color._tint[1];
|
|
fVar12 = (npc->_sprite)._color._tint[2];
|
|
fVar13 = (npc->_sprite)._color._tint[3];
|
|
pCVar1->_tint[0] = pCVar2->_tint[0];
|
|
(colorTarget->_sprite)._color._tint[1] = fVar11;
|
|
(colorTarget->_sprite)._color._tint[2] = fVar12;
|
|
(colorTarget->_sprite)._color._tint[3] = fVar13;
|
|
fVar11 = (npc->_sprite)._color._colorize[1];
|
|
fVar12 = (npc->_sprite)._color._colorize[2];
|
|
fVar13 = (npc->_sprite)._color._colorize[3];
|
|
(colorTarget->_sprite)._color._colorize[0] = (npc->_sprite)._color._colorize[0];
|
|
(colorTarget->_sprite)._color._colorize[1] = fVar11;
|
|
(colorTarget->_sprite)._color._colorize[2] = fVar12;
|
|
(colorTarget->_sprite)._color._colorize[3] = fVar13;
|
|
*GHIDRA_CAST<uint64_t *>((colorTarget->_sprite)._color._offset) =
|
|
*GHIDRA_CAST<uint64_t *>((npc->_sprite)._color._offset);
|
|
(colorTarget->_sprite)._color._offset[2] = (npc->_sprite)._color._offset[2];
|
|
layerId = npc->_subtype;
|
|
}
|
|
(GHIDRA_CAST<Sprite *>((GHIDRA_CAST<Sprite *>(&colorTarget->_sprite))))->Sprite::RenderLayer(layerId,&npc->_renderPosition,&g_vectorZero,
|
|
&g_vectorZero);
|
|
if (pCVar1 != GHIDRA_CAST<ColorMod *>(local_6c)) {
|
|
pCVar1->_tint[0] = pixelScale;
|
|
(colorTarget->_sprite)._color._tint[1] = fVar4;
|
|
(colorTarget->_sprite)._color._tint[2] = fVar5;
|
|
(colorTarget->_sprite)._color._tint[3] = fVar6;
|
|
(colorTarget->_sprite)._color._colorize[0] = fVar7;
|
|
(colorTarget->_sprite)._color._colorize[1] = fVar8;
|
|
(colorTarget->_sprite)._color._colorize[2] = fVar9;
|
|
(colorTarget->_sprite)._color._colorize[3] = fVar10;
|
|
*GHIDRA_CAST<uint64_t *>((colorTarget->_sprite)._color._offset) = uVar3;
|
|
(colorTarget->_sprite)._color._offset[2] = offsetY;
|
|
return;
|
|
}
|
|
}
|
|
else {
|
|
Entity::Render(GHIDRA_CAST<Entity *>(npc),offset);
|
|
}
|
|
return;
|
|
}
|
|
|
|
// 00572a70
|
|
Entity * NpcHelper::clutch_find_farthest_orbital(Entity_NPC *clutch, int unused)
|
|
{
|
|
uint64_t qVar1;
|
|
uint8_t isClutchFriendly;
|
|
int enemiesData;
|
|
uint64_t *heapAllocatedBytes;
|
|
uint8_t extraout_DL;
|
|
Entity *tmpEntity;
|
|
uint32_t uVar2;
|
|
float fVar3;
|
|
float deltaX;
|
|
EntityList_EL local_38;
|
|
uint32_t local_24;
|
|
float maxDistance;
|
|
Entity *local_18;
|
|
void *local_10;
|
|
uint8_t *puStack_c;
|
|
uint32_t uStack_8;
|
|
|
|
uStack_8 = 0xffffffff;
|
|
puStack_c = &LAB_00af1840;
|
|
local_10 = ExceptionList;
|
|
ExceptionList = &local_10;
|
|
local_18 = GHIDRA_CAST<Entity *>(0x0);
|
|
maxDistance = 0.0;
|
|
EntityList::QuerySublist(GHIDRA_CAST<EntityList *>((GHIDRA_INT(g_game->_room) + 0x1218)),&local_38,0x379,-1,-1,0,0);
|
|
uVar2 = 0;
|
|
tmpEntity = GHIDRA_CAST<Entity *>(0x0);
|
|
if (local_38._size != 0) {
|
|
enemiesData = (*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(local_38)) + 0x4)));
|
|
do {
|
|
tmpEntity = *GHIDRA_CAST<Entity **>((enemiesData + uVar2 * 4));
|
|
if (tmpEntity != GHIDRA_CAST<Entity *>(0x0)) {
|
|
if (((1 < *GHIDRA_CAST<int *>(&g_game->_deathmatchManager)) && (tmpEntity->_type == 1)) ||
|
|
(tmpEntity->_type - 10U < 0x3de)) {
|
|
local_24 = *GHIDRA_CAST<uint32_t *>((GHIDRA_INT(&tmpEntity->_flags) + 4));
|
|
isClutchFriendly = Entity::IsFriendly(GHIDRA_CAST<Entity *>(clutch));
|
|
if (((extraout_DL == isClutchFriendly) && (GHIDRA_CAST<Entity_NPC *>(tmpEntity->_parent) == clutch)) &&
|
|
((tmpEntity != GHIDRA_CAST<Entity *>(clutch->_child) &&
|
|
((tmpEntity[2]._updateTime != 1.38729e-43 &&
|
|
(fVar3 = (clutch->_pos).y - (tmpEntity->_pos).y,
|
|
deltaX = (clutch->_pos).x - (tmpEntity->_pos).x,
|
|
fVar3 = sqrtf(fVar3 * fVar3 + deltaX * deltaX), (tmpEntity->_flags & 0x10) == 0))))))
|
|
{
|
|
enemiesData = (*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(local_38)) + 0x4)));
|
|
if (maxDistance < fVar3) {
|
|
maxDistance = fVar3;
|
|
local_18 = tmpEntity;
|
|
}
|
|
goto LAB_00572bab;
|
|
}
|
|
}
|
|
enemiesData = (*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(local_38)) + 0x4)));
|
|
}
|
|
LAB_00572bab:
|
|
uVar2 = uVar2 + 1;
|
|
tmpEntity = local_18;
|
|
} while (uVar2 < GHIDRA_UINT(local_38._size));
|
|
}
|
|
if ((*GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>(&(local_38)) + 0x0))) == '\0') {
|
|
if (g_mainHeap == (void *)0x0) {
|
|
heapAllocatedBytes = &g_allocatedBytesNoHeap;
|
|
}
|
|
else {
|
|
heapAllocatedBytes = GHIDRA_CAST<uint64_t *>((GHIDRA_INT(g_mainHeap) + 0x30));
|
|
}
|
|
if ((*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(local_38)) + 0x4))) != 0) {
|
|
uVar2 = *GHIDRA_CAST<uint32_t *>(((*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(local_38)) + 0x4))) + -4));
|
|
qVar1 = *heapAllocatedBytes;
|
|
*GHIDRA_CAST<uint32_t *>(heapAllocatedBytes) = GHIDRA_UINT(*heapAllocatedBytes) - uVar2;
|
|
*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(heapAllocatedBytes) + 4)) =
|
|
*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(heapAllocatedBytes) + 4)) - GHIDRA_UINT((GHIDRA_UINT(qVar1) < uVar2));
|
|
free(GHIDRA_CAST<uint32_t *>(((*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(local_38)) + 0x4))) + -4)));
|
|
}
|
|
}
|
|
ExceptionList = local_10;
|
|
return tmpEntity;
|
|
}
|
|
|
|
// 00572cc0
|
|
void NpcHelper::clutch_spawn_fire(Entity_NPC *npc, Entity *target)
|
|
{
|
|
uint32_t uVar1;
|
|
float fVar2;
|
|
float fVar3;
|
|
uint8_t bVar4;
|
|
uint32_t uVar5;
|
|
Entity *fire;
|
|
uint8_t *pbVar6;
|
|
LayerState *layer;
|
|
uint32_t angleRoll;
|
|
char *pcVar7;
|
|
uint8_t *size;
|
|
bool bVar8;
|
|
float fVar9;
|
|
Vector spawnPos;
|
|
Vector local_64;
|
|
ANM2 *local_5c;
|
|
Entity *local_58;
|
|
Entity_NPC *local_54;
|
|
Entity *local_50;
|
|
uint8_t local_4c [32];
|
|
int animPathSize;
|
|
uint8_t *animPathCapacity;
|
|
uint32_t local_24;
|
|
uint8_t *puStack_20;
|
|
void *local_1c;
|
|
uint8_t *puStack_18;
|
|
uint32_t local_14;
|
|
code *addFlagsFn;
|
|
ANM2 *fireSprite;
|
|
uint32_t *parentSlot;
|
|
|
|
puStack_20 = local_4c + 0x48;
|
|
local_14 = 0xffffffff;
|
|
puStack_18 = &LAB_00af506d;
|
|
local_1c = ExceptionList;
|
|
uVar5 = __security_cookie ^ GHIDRA_UINT((local_4c + 0x3c));
|
|
ExceptionList = &local_1c;
|
|
local_58 = target;
|
|
uVar1 = *GHIDRA_CAST<uint32_t *>((GHIDRA_INT(&target->_flags) + 4));
|
|
*GHIDRA_CAST<uint32_t *>(&target->_flags) = GHIDRA_UINT(target->_flags) | 0x10;
|
|
*GHIDRA_CAST<uint32_t *>((GHIDRA_INT(&target->_flags) + 4)) = uVar1;
|
|
addFlagsFn = *(code **)(*GHIDRA_CAST<int *>(target) + 0x24);
|
|
local_54 = npc;
|
|
local_24 = uVar5;
|
|
EntityRef::constructor(GHIDRA_CAST<EntityRef *>(local_4c),GHIDRA_CAST<Entity *>(npc));
|
|
(*addFlagsFn)(local_4c,uVar5);
|
|
uVar5 = Random();
|
|
local_64.x = (local_58->_pos).x;
|
|
local_64.y = (local_58->_pos).y;
|
|
fire = Game::Spawn(g_game,0x21,0xd,&local_64,&g_vectorZero,GHIDRA_CAST<Entity *>(npc),0,uVar5);
|
|
animPathSize = 0;
|
|
fireSprite = &fire->_sprite;
|
|
animPathCapacity = &DAT_0000000f;
|
|
(*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(local_4c)) + 0x10))) = 0.0;
|
|
local_5c = fireSprite;
|
|
local_50 = fire;
|
|
(*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(local_4c)) + 0x10))) = msvc::_Allocate(0x30);
|
|
animPathSize = 0x20;
|
|
animPathCapacity = &DAT_0000002f;
|
|
builtin_strncpy((*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(GHIDRA_CAST<char *>(local_4c))) + 0x10))),"gfx/009.002_Fire Projectile.anm2",0x21);
|
|
local_14 = 0;
|
|
ANM2::Load(fireSprite,GHIDRA_CAST<std_string *>((local_4c + 0x10)),1);
|
|
local_14 = 0xffffffff;
|
|
if (&DAT_0000000f < animPathCapacity) {
|
|
size = animPathCapacity + 1;
|
|
pcVar7 = (*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(GHIDRA_CAST<char *>(local_4c))) + 0x10)));
|
|
if (GHIDRA_CAST<uint8_t *>(0xfff) < size) {
|
|
pcVar7 = *GHIDRA_CAST<char **>(((*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(local_4c)) + 0x10))) + -4));
|
|
size = animPathCapacity + 0x24;
|
|
if (GHIDRA_CAST<char *>(0x1f) < GHIDRA_CAST<char *>(((*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(local_4c)) + 0x10))) + (-4 - GHIDRA_INT(pcVar7))))) {
|
|
/* WARNING: Subroutine does not return */
|
|
_invalid_parameter_noinfo_noreturn();
|
|
}
|
|
}
|
|
operator_delete(pcVar7,GHIDRA_UINT(size));
|
|
}
|
|
pbVar6 = (fire->_sprite)._animState._animData;
|
|
if (pbVar6 != GHIDRA_CAST<uint8_t *>(0x0)) {
|
|
if (0xf < *GHIDRA_CAST<uint32_t *>((pbVar6 + 0x14))) {
|
|
pbVar6 = *GHIDRA_CAST<uint8_t **>(pbVar6);
|
|
}
|
|
pcVar7 = "Flickering";
|
|
do {
|
|
bVar4 = *pbVar6;
|
|
bVar8 = bVar4 < (uint8_t)*pcVar7;
|
|
if (bVar4 != *pcVar7) {
|
|
LAB_00572e46:
|
|
uVar5 = -GHIDRA_UINT(bVar8) | 1;
|
|
goto LAB_00572e4b;
|
|
}
|
|
if (bVar4 == 0) break;
|
|
bVar4 = pbVar6[1];
|
|
bVar8 = bVar4 < (uint8_t)pcVar7[1];
|
|
if (bVar4 != pcVar7[1]) goto LAB_00572e46;
|
|
pbVar6 = pbVar6 + 2;
|
|
pcVar7 = pcVar7 + 2;
|
|
} while (bVar4 != 0);
|
|
uVar5 = 0;
|
|
LAB_00572e4b:
|
|
if ((uVar5 == 0) &&
|
|
((*GHIDRA_CAST<char *>((GHIDRA_INT((fire->_sprite)._animState._animData) + 0x34)) == '\0' ||
|
|
((fire->_sprite)._animState._isPlaying != 0)))) goto LAB_00572e7c;
|
|
}
|
|
bVar4 = ANM2::SetAnimation(fireSprite,GHIDRA_CAST<uint8_t *>("Flickering"),1);
|
|
if (bVar4 != 0) {
|
|
AnimationState::Rewind(&(fire->_sprite)._animState);
|
|
(fire->_sprite)._animState._isPlaying = 1;
|
|
}
|
|
LAB_00572e7c:
|
|
fireSprite = local_5c;
|
|
pbVar6 = GHIDRA_CAST<uint8_t *>(0x0);
|
|
if ((local_50->_sprite)._layerCount != 0) {
|
|
do {
|
|
layer = ANM2::GetLayer(fireSprite,pbVar6);
|
|
fVar3 = fRam00c34e34;
|
|
fVar2 = fRam00c34e30;
|
|
fVar9 = fRam00c34e2c;
|
|
if (&layer->_color != GHIDRA_CAST<ColorMod *>(&DAT_00c34e28)) {
|
|
(layer->_color)._tint[0] = _DAT_00c34e28;
|
|
(layer->_color)._tint[1] = fVar9;
|
|
(layer->_color)._tint[2] = fVar2;
|
|
(layer->_color)._tint[3] = fVar3;
|
|
fVar3 = fRam00c34e44;
|
|
fVar2 = fRam00c34e40;
|
|
fVar9 = fRam00c34e3c;
|
|
(layer->_color)._colorize[0] = _DAT_00c34e38;
|
|
(layer->_color)._colorize[1] = fVar9;
|
|
(layer->_color)._colorize[2] = fVar2;
|
|
(layer->_color)._colorize[3] = fVar3;
|
|
*GHIDRA_CAST<uint64_t *>((layer->_color)._offset) = DAT_00c34e48;
|
|
(layer->_color)._offset[2] = DAT_00c34e50;
|
|
}
|
|
pbVar6 = pbVar6 + 1;
|
|
} while (pbVar6 < GHIDRA_CAST<uint8_t *>((local_50->_sprite)._layerCount));
|
|
npc = local_54;
|
|
}
|
|
(**(code **)(*GHIDRA_CAST<int *>(local_50) + 0xc))();
|
|
local_50 = GHIDRA_CAST<Entity *>(0x2);
|
|
do {
|
|
uVar5 = Random();
|
|
local_54 = GHIDRA_CAST<Entity_NPC *>((local_58->_pos).x);
|
|
local_64.y = (local_58->_pos).y;
|
|
angleRoll = Random();
|
|
fVar9 = (float)((double)GHIDRA_INT(angleRoll) + __uint_to_double_fixup[-(GHIDRA_INT(angleRoll) >> 0x1f)]) *
|
|
2.3283064e-10 * 3.14;
|
|
local_5c = GHIDRA_CAST<ANM2 *>((fVar9 + fVar9));
|
|
fVar9 = cos((float)local_5c);
|
|
spawnPos.x = fVar9 * 10.0 + (float)local_54;
|
|
fVar9 = sin((float)local_5c);
|
|
spawnPos.y = fVar9 * 10.0 + local_64.y;
|
|
local_54 = (Entity_NPC *)
|
|
Game::Spawn(g_game,0x399,1,&spawnPos,&g_vectorZero,GHIDRA_CAST<Entity *>(npc),0,uVar5);
|
|
parentSlot = &local_54->_parent;
|
|
if (local_54->_parent != 0) {
|
|
local_64.y = (float)parentSlot;
|
|
msvc::multiset<unsigned_int>::erase(&local_64.y);
|
|
}
|
|
*parentSlot = npc;
|
|
if (npc != GHIDRA_CAST<Entity_NPC *>(0x0)) {
|
|
msvc::multiset<unsigned_int>::insert(parentSlot);
|
|
}
|
|
uVar5 = Random();
|
|
local_50 = GHIDRA_CAST<Entity *>((GHIDRA_INT(local_50) + -1));
|
|
(local_54->_v1).x =
|
|
(float)((double)GHIDRA_INT(uVar5) + __uint_to_double_fixup[-(GHIDRA_INT(uVar5) >> 0x1f)]) * 2.3283064e-10
|
|
* 360.0;
|
|
} while (local_50 != GHIDRA_CAST<Entity *>(0x0));
|
|
ExceptionList = local_1c;
|
|
return;
|
|
}
|
|
|
|
// 00575a10
|
|
void NpcHelper::clutch_render(Entity_NPC *npc, Vector *offset)
|
|
{
|
|
LayerState *pLVar1;
|
|
float *pfVar2;
|
|
int iVar3;
|
|
int iVar4;
|
|
int iVar5;
|
|
void *layerFrames;
|
|
int pointSlotOffset;
|
|
int iVar6;
|
|
void *animData;
|
|
int pointIndex;
|
|
uint32_t pointBlock;
|
|
uint32_t nextPointBlock;
|
|
float *nextPoint;
|
|
float flipSign;
|
|
float deltaX;
|
|
float fVar7;
|
|
double dVar8;
|
|
double dVar9;
|
|
int layerOffset;
|
|
uint32_t nextPointIndex;
|
|
uint8_t *layerId;
|
|
float segmentStretch;
|
|
Vector segmentPos [8];
|
|
ANM2 *animation;
|
|
int *pointDeque;
|
|
|
|
if (npc->_variant == 0) {
|
|
pLVar1 = ANM2::GetLayer(&npc->_sprite,GHIDRA_CAST<uint8_t *>(0x1));
|
|
if ((0.0 < (pLVar1->_color)._tint[3]) && ((npc->_vectorDeque1)._size != 0)) {
|
|
pLVar1 = ANM2::GetLayer(&npc->_sprite,GHIDRA_CAST<uint8_t *>(0x1));
|
|
pLVar1->_visible = 1;
|
|
pLVar1 = ANM2::GetLayer(&npc->_sprite,GHIDRA_CAST<uint8_t *>(0x2));
|
|
layerId = GHIDRA_CAST<uint8_t *>(0x1);
|
|
layerOffset = 0x3c;
|
|
pLVar1->_visible = 1;
|
|
pointBlock = (npc->_vectorDeque1)._offset;
|
|
do {
|
|
pointDeque = (npc->_vectorDeque1)._proxy;
|
|
nextPointIndex = pointBlock + 3;
|
|
pointIndex = pointBlock;
|
|
while( true ) {
|
|
pointBlock = (npc->_vectorDeque1)._offset;
|
|
if (((npc->_vectorDeque1)._size - 3) + pointBlock <= GHIDRA_UINT(pointIndex)) break;
|
|
if (pointDeque == GHIDRA_CAST<int *>(0x0)) {
|
|
iVar3 = 0;
|
|
}
|
|
else {
|
|
iVar3 = *pointDeque;
|
|
}
|
|
pointBlock = GHIDRA_UINT(pointIndex) >> 1;
|
|
pointSlotOffset = (pointIndex & 1U) * 8;
|
|
pfVar2 = GHIDRA_CAST<float *>((*GHIDRA_CAST<int *>((*GHIDRA_CAST<int *>((iVar3 + 4)) +
|
|
(*GHIDRA_CAST<int *>((iVar3 + 8)) - 1U & pointBlock) * 4)) + pointSlotOffset))
|
|
;
|
|
if (pointDeque == GHIDRA_CAST<int *>(0x0)) {
|
|
iVar3 = 0;
|
|
}
|
|
else {
|
|
iVar3 = *pointDeque;
|
|
}
|
|
nextPointBlock = nextPointIndex >> 1;
|
|
fVar7 = g_displayPixelRatio * g_screenPointScale;
|
|
iVar6 = (nextPointIndex & 1) * 8;
|
|
nextPoint = GHIDRA_CAST<float *>((*GHIDRA_CAST<int *>((*GHIDRA_CAST<int *>((iVar3 + 4)) +
|
|
(*GHIDRA_CAST<int *>((iVar3 + 8)) - 1U & nextPointBlock) * 4)) + iVar6));
|
|
dVar8 = floor((double)((((*pfVar2 + *nextPoint) * 0.5 - 60.0) * 0.65 +
|
|
(g_screenWidth - 338.0) * 0.5) * fVar7 + 0.5));
|
|
dVar9 = floor((double)((((pfVar2[1] + nextPoint[1]) * 0.5 - 140.0) * 0.65 +
|
|
(g_screenHeight - 182.0) * 0.5) * fVar7 + 0.5));
|
|
segmentPos[0].x = (float)dVar8 / fVar7 + offset->x;
|
|
segmentPos[0].y = (float)dVar9 / fVar7 + offset->y;
|
|
if (pointDeque == GHIDRA_CAST<int *>(0x0)) {
|
|
iVar3 = 0;
|
|
}
|
|
else {
|
|
iVar3 = *pointDeque;
|
|
}
|
|
if (pointDeque == GHIDRA_CAST<int *>(0x0)) {
|
|
iVar5 = 0;
|
|
}
|
|
else {
|
|
iVar5 = *pointDeque;
|
|
}
|
|
iVar3 = GHIDRA_INT((8.0 - (*GHIDRA_CAST<float *>((*GHIDRA_CAST<int *>((*GHIDRA_CAST<int *>((iVar5 + 4)) +
|
|
(nextPointIndex + 2 >> 1 &
|
|
*GHIDRA_CAST<int *>((iVar5 + 8)) - 1U) * 4)) +
|
|
(nextPointIndex + 2 & 1) * 8)) +
|
|
*GHIDRA_CAST<float *>((*GHIDRA_CAST<int *>((*GHIDRA_CAST<int *>((iVar3 + 4)) +
|
|
(nextPointIndex - 1 >> 1 & *GHIDRA_CAST<int *>((iVar3 + 8)) - 1U
|
|
) * 4)) + (nextPointIndex + 1 & 1) * 8))) * 0.5 * 8.0
|
|
));
|
|
if (iVar3 == 7) {
|
|
segmentStretch = 1.0;
|
|
LAB_00575d73:
|
|
pLVar1 = ANM2::GetLayer(&npc->_sprite,layerId);
|
|
(pLVar1->_size).x = segmentStretch;
|
|
(pLVar1->_size).y = 1.0;
|
|
if ((npc->_sprite)._flipX == 0) {
|
|
flipSign = 1.0;
|
|
}
|
|
else {
|
|
flipSign = (float)&DAT_bf800000;
|
|
}
|
|
if (pointDeque == GHIDRA_CAST<int *>(0x0)) {
|
|
iVar5 = 0;
|
|
}
|
|
else {
|
|
iVar5 = *pointDeque;
|
|
}
|
|
pfVar2 = GHIDRA_CAST<float *>((*GHIDRA_CAST<int *>((*GHIDRA_CAST<int *>((iVar5 + 4)) +
|
|
(*GHIDRA_CAST<int *>((iVar5 + 8)) - 1U & nextPointBlock) * 4)) + iVar6));
|
|
if (pointDeque == GHIDRA_CAST<int *>(0x0)) {
|
|
iVar6 = 0;
|
|
}
|
|
else {
|
|
iVar6 = *pointDeque;
|
|
}
|
|
iVar6 = *GHIDRA_CAST<int *>((*GHIDRA_CAST<int *>((iVar6 + 4)) + (*GHIDRA_CAST<int *>((iVar6 + 8)) - 1U & pointBlock) * 4));
|
|
fVar7 = atan2f(pfVar2[1] - *GHIDRA_CAST<float *>((iVar6 + 4 + pointSlotOffset)),
|
|
*pfVar2 - *GHIDRA_CAST<float *>((iVar6 + pointSlotOffset)));
|
|
pLVar1 = ANM2::GetLayer(&npc->_sprite,layerId);
|
|
pLVar1->_rotation = fVar7 * 57.295776 * flipSign;
|
|
if ((npc->_sprite)._overlayAnimState._animData != (void *)0x0) {
|
|
AnimationState::SetFrameFloat(&(npc->_sprite)._overlayAnimState,(float)iVar3);
|
|
}
|
|
if ((npc->_sprite)._loaded != 0) {
|
|
if ((npc->_sprite)._overlayRenderFirst == 0) {
|
|
animData = (npc->_sprite)._animState._animData;
|
|
if (((animData != (void *)0x0) &&
|
|
(animation = (npc->_sprite)._animState._animation,
|
|
GHIDRA_INT(layerId) < animation->_layerCount)) &&
|
|
(iVar3 = *GHIDRA_CAST<int *>((layerOffset + GHIDRA_INT(animData))), -1 < iVar3)) {
|
|
AnimationLayer::RenderFrame
|
|
(GHIDRA_CAST<AnimationLayer *>((iVar3 * 0x10 + *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(animData) + 0x18)))),
|
|
segmentPos,
|
|
*GHIDRA_CAST<int *>((GHIDRA_INT((npc->_sprite)._animState._layerFrames) + iVar3 * 4)),
|
|
&g_vectorZero,&g_vectorZero,animation);
|
|
}
|
|
animData = (npc->_sprite)._overlayAnimState._animData;
|
|
if (((animData != (void *)0x0) &&
|
|
(animation = (npc->_sprite)._overlayAnimState._animation,
|
|
GHIDRA_INT(layerId) < animation->_layerCount)) &&
|
|
(iVar3 = *GHIDRA_CAST<int *>((layerOffset + GHIDRA_INT(animData))), -1 < iVar3)) {
|
|
layerFrames = (npc->_sprite)._overlayAnimState._layerFrames;
|
|
goto LAB_00575ed0;
|
|
}
|
|
}
|
|
else {
|
|
animData = (npc->_sprite)._overlayAnimState._animData;
|
|
if (((animData != (void *)0x0) &&
|
|
(animation = (npc->_sprite)._overlayAnimState._animation,
|
|
GHIDRA_INT(layerId) < animation->_layerCount)) &&
|
|
(iVar3 = *GHIDRA_CAST<int *>((layerOffset + GHIDRA_INT(animData))), -1 < iVar3)) {
|
|
AnimationLayer::RenderFrame
|
|
(GHIDRA_CAST<AnimationLayer *>((iVar3 * 0x10 + *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(animData) + 0x18)))),
|
|
segmentPos,
|
|
*GHIDRA_CAST<int *>((GHIDRA_INT((npc->_sprite)._overlayAnimState._layerFrames) + iVar3 * 4
|
|
)),&g_vectorZero,&g_vectorZero,animation);
|
|
}
|
|
animData = (npc->_sprite)._animState._animData;
|
|
if (((animData != (void *)0x0) &&
|
|
(animation = (npc->_sprite)._animState._animation,
|
|
GHIDRA_INT(layerId) < animation->_layerCount)) &&
|
|
(iVar3 = *GHIDRA_CAST<int *>((layerOffset + GHIDRA_INT(animData))), -1 < iVar3)) {
|
|
layerFrames = (npc->_sprite)._animState._layerFrames;
|
|
LAB_00575ed0:
|
|
AnimationLayer::RenderFrame
|
|
(GHIDRA_CAST<AnimationLayer *>((iVar3 * 0x10 + *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(animData) + 0x18)))),
|
|
segmentPos,*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(layerFrames) + iVar3 * 4)),&g_vectorZero,
|
|
&g_vectorZero,animation);
|
|
}
|
|
}
|
|
}
|
|
pointIndex = pointIndex + 3;
|
|
nextPointIndex = nextPointIndex + 3;
|
|
}
|
|
else {
|
|
if (pointDeque == GHIDRA_CAST<int *>(0x0)) {
|
|
iVar5 = 0;
|
|
}
|
|
else {
|
|
iVar5 = *pointDeque;
|
|
}
|
|
iVar5 = *GHIDRA_CAST<int *>((*GHIDRA_CAST<int *>((iVar5 + 4)) + (*GHIDRA_CAST<int *>((iVar5 + 8)) - 1U & pointBlock) * 4));
|
|
if (pointDeque == GHIDRA_CAST<int *>(0x0)) {
|
|
iVar4 = 0;
|
|
}
|
|
else {
|
|
iVar4 = *pointDeque;
|
|
}
|
|
pfVar2 = GHIDRA_CAST<float *>((*GHIDRA_CAST<int *>((*GHIDRA_CAST<int *>((iVar4 + 4)) +
|
|
(*GHIDRA_CAST<int *>((iVar4 + 8)) - 1U & nextPointBlock) * 4)) + iVar6));
|
|
fVar7 = pfVar2[1] - *GHIDRA_CAST<float *>((iVar5 + 4 + pointSlotOffset));
|
|
deltaX = *pfVar2 - *GHIDRA_CAST<float *>((iVar5 + pointSlotOffset));
|
|
fVar7 = sqrtf(fVar7 * fVar7 + deltaX * deltaX);
|
|
segmentStretch = (fVar7 * 0.5) / (float)(8 - iVar3);
|
|
if (segmentStretch <= 1.0) {
|
|
segmentStretch = 1.0;
|
|
}
|
|
if (3.0 <= segmentStretch) {
|
|
segmentStretch = 3.0;
|
|
}
|
|
if (iVar3 < 8) goto LAB_00575d73;
|
|
pointIndex = pointIndex + 3;
|
|
nextPointIndex = nextPointIndex + 3;
|
|
}
|
|
}
|
|
layerId = layerId + 1;
|
|
layerOffset = layerOffset + 4;
|
|
} while (layerOffset < 0x41);
|
|
pLVar1 = ANM2::GetLayer(&npc->_sprite,GHIDRA_CAST<uint8_t *>(0x1));
|
|
pLVar1->_visible = 0;
|
|
pLVar1 = ANM2::GetLayer(&npc->_sprite,GHIDRA_CAST<uint8_t *>(0x2));
|
|
pLVar1->_visible = 0;
|
|
}
|
|
}
|
|
Entity::Render(GHIDRA_CAST<Entity *>(npc),offset);
|
|
return;
|
|
}
|
|
|
|
// 00576090
|
|
void NpcHelper::raglich_pick_target_pos(Entity_NPC *npc, float speed)
|
|
{
|
|
float fVar1;
|
|
float fVar2;
|
|
uint8_t isInRoom;
|
|
int gridWidth;
|
|
uint32_t direction;
|
|
int row;
|
|
int iVar3;
|
|
Vector probePos;
|
|
Vector clampedPos;
|
|
Vector local_24;
|
|
Vector local_1c;
|
|
Vector local_14;
|
|
Vector local_c;
|
|
Game *game;
|
|
Vector *minResult;
|
|
Room *room;
|
|
|
|
direction = *GHIDRA_CAST<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 = Room::IsPositionInRoom(room,&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<int *>(&(*GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>((room)) + 0x4)))) + 0x10)) + 0x48)) - 9U) goto LAB_00576404;
|
|
probePos.x = clampedPos.x - local_1c.x * 40.0;
|
|
probePos.y = clampedPos.y - local_1c.y * 40.0;
|
|
local_1c.y = probePos.y;
|
|
local_c.y = probePos.x;
|
|
isInRoom = Room::IsPositionInRoom(room,&probePos,0.0);
|
|
if (isInRoom == 0) goto LAB_00576404;
|
|
probePos.x = local_c.y - local_14.y;
|
|
probePos.y = local_1c.y - local_24.y;
|
|
isInRoom = Room::IsPositionInRoom(room,&probePos,0.0);
|
|
if (isInRoom != 0) goto LAB_00576404;
|
|
direction = (short)npc->_i1 + 4 + GHIDRA_INT(*GHIDRA_CAST<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 = Room::GetGridIndex(room,&clampedPos);
|
|
row = iVar3 / room->_gridWidth;
|
|
iVar3 = iVar3 % room->_gridWidth;
|
|
}
|
|
(npc->_targetPosition).y = (float)row * 40.0 + 120.0;
|
|
(npc->_targetPosition).x = (float)iVar3 * 40.0 + 40.0;
|
|
LAB_00576404:
|
|
local_1c.y = 1.0;
|
|
local_24.y = npc->_speedMultiplier * 0.1 + (npc->_v1).y;
|
|
minResult = &local_24;
|
|
if (1.0 <= local_24.y) {
|
|
minResult = &local_1c;
|
|
}
|
|
(npc->_v1).y = minResult->y;
|
|
return;
|
|
}
|
|
|
|
// 00576450
|
|
void NpcHelper::raglich_slam_spawn_grid(Entity_NPC *npc)
|
|
{
|
|
uint8_t bVar1;
|
|
uint32_t uVar2;
|
|
int gridX;
|
|
GridEntity *pit;
|
|
uint8_t *animNameChar;
|
|
int gridY;
|
|
uint8_t *wantedAnimChar;
|
|
int gridIndex;
|
|
bool isLess;
|
|
Vector particlePos;
|
|
Vector rightDamagePos;
|
|
Vector local_68;
|
|
int gridYCopy;
|
|
uint32_t gridSeed;
|
|
Vector local_58;
|
|
int column;
|
|
void *room;
|
|
Vector slamOffset;
|
|
ColorMod particleColor;
|
|
uint32_t local_14;
|
|
void *local_10;
|
|
uint8_t *puStack_c;
|
|
float local_8;
|
|
uint8_t *animData;
|
|
uint64_t flags;
|
|
int *gridAtIndex;
|
|
uint32_t *oldGrid;
|
|
float posY;
|
|
float targetY;
|
|
|
|
local_8 = -NAN;
|
|
puStack_c = &LAB_00af5157;
|
|
local_10 = ExceptionList;
|
|
uVar2 = __security_cookie ^ GHIDRA_UINT((&particleColor)[1]._colorize);
|
|
local_14 = uVar2;
|
|
if (npc->_state != 0) {
|
|
if (npc->_state != 3) {
|
|
return;
|
|
}
|
|
ExceptionList = &local_10;
|
|
npc->_friction = 0.5;
|
|
targetY = (npc->_targetPosition).y;
|
|
posY = (npc->_pos).y;
|
|
(npc->_velocity).x = (npc->_targetPosition).x - (npc->_pos).x;
|
|
(npc->_velocity).y = targetY - posY;
|
|
Entity::GetNullOffset(GHIDRA_CAST<Entity *>(npc),&slamOffset,&DAT_00b1d3b0);
|
|
if ((slamOffset.x != g_vectorZero.x) || (slamOffset.y != g_vectorZero.y)) {
|
|
if (npc->_i1 == 0) {
|
|
npc->_i1 = 1;
|
|
Entity_NPC::PlaySound(npc,0x34,1.0,2,0,1.0);
|
|
Game::ShakeScreen(g_game,0xe);
|
|
}
|
|
local_68.x = slamOffset.x + (npc->_pos).x;
|
|
local_68.y = slamOffset.y + (npc->_pos).y;
|
|
Game::BombDamage(g_game,&local_68,10.0,20.0,0,GHIDRA_CAST<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;
|
|
Game::BombDamage(g_game,&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;
|
|
Game::BombDamage(g_game,&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 {
|
|
GridEntity::GridEntity(pit);
|
|
*GHIDRA_CAST<uint8_t ***>(pit) = IsaacRepentancePlus::GridEntity_Pit::vftable;
|
|
}
|
|
local_8 = -NAN;
|
|
if (pit != GHIDRA_CAST<GridEntity *>(0x0)) {
|
|
*GHIDRA_CAST<uint32_t *>(&(*GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>((pit)) + 0x4)))) = 7;
|
|
pit->_gridIndex = gridIndex;
|
|
oldGrid = *GHIDRA_CAST<uint32_t **>((GHIDRA_CAST<char *>(room) + gridIndex * 4 + 0x24));
|
|
if (oldGrid != GHIDRA_CAST<uint32_t *>(0x0)) {
|
|
(**(code **)*oldGrid)(1);
|
|
}
|
|
*GHIDRA_CAST<GridEntity **>((GHIDRA_CAST<char *>(room) + gridIndex * 4 + 0x24)) = pit;
|
|
*GHIDRA_CAST<uint32_t *>(&(*GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>((pit)) + 0x8)))) = 0;
|
|
pit->_varData = 0;
|
|
GridEntity::Init(pit,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<uint8_t *>("SpawnGridEntity: Grid index invalid\n"));
|
|
}
|
|
particleColor._tint[0] = 1.0;
|
|
particleColor._tint[1] = 1.0;
|
|
particleColor._tint[2] = 1.0;
|
|
particleColor._tint[3] = 1.0;
|
|
particleColor._offset[0] = 0.0;
|
|
particleColor._offset[1] = 0.0;
|
|
particleColor._colorize[0] = 0.0;
|
|
particleColor._colorize[1] = 0.0;
|
|
particleColor._colorize[2] = 0.0;
|
|
particleColor._colorize[3] = 0.0;
|
|
particlePos.x = slamOffset.x + (npc->_pos).x;
|
|
particlePos.y = slamOffset.y + (npc->_pos).y;
|
|
particleColor._offset[2] = 0.0;
|
|
Game::SpawnParticles(g_game,&particlePos,4,4,6.0,&particleColor,100000.0,0);
|
|
gridY = gridYCopy;
|
|
}
|
|
column = gridX + 1;
|
|
} while (column <= GHIDRA_INT(local_58.y));
|
|
}
|
|
}
|
|
if (((npc->_sprite)._animState._animData == (void *)0x0) ||
|
|
((npc->_sprite)._animState._isPlaying == 0)) {
|
|
(**(code **)(*GHIDRA_CAST<int *>(npc) + 0x28))(uVar2);
|
|
ExceptionList = local_10;
|
|
return;
|
|
}
|
|
ExceptionList = local_10;
|
|
return;
|
|
}
|
|
animData = (npc->_sprite)._animState._animData;
|
|
if (animData != GHIDRA_CAST<uint8_t *>(0x0)) {
|
|
animNameChar = animData;
|
|
if (0xf < *GHIDRA_CAST<uint32_t *>((animData + 0x14))) {
|
|
animNameChar = *GHIDRA_CAST<uint8_t **>(animData);
|
|
}
|
|
wantedAnimChar = &DAT_00b61c98;
|
|
do {
|
|
bVar1 = *animNameChar;
|
|
isLess = bVar1 < *wantedAnimChar;
|
|
if (bVar1 != *wantedAnimChar) {
|
|
LAB_00576910:
|
|
uVar2 = -GHIDRA_UINT(isLess) | 1;
|
|
goto LAB_00576915;
|
|
}
|
|
if (bVar1 == 0) break;
|
|
bVar1 = animNameChar[1];
|
|
isLess = bVar1 < wantedAnimChar[1];
|
|
if (bVar1 != wantedAnimChar[1]) goto LAB_00576910;
|
|
animNameChar = animNameChar + 2;
|
|
wantedAnimChar = wantedAnimChar + 2;
|
|
} while (bVar1 != 0);
|
|
uVar2 = 0;
|
|
LAB_00576915:
|
|
if ((uVar2 == 0) && ((animData[0x34] == 0 || ((npc->_sprite)._animState._isPlaying != 0))))
|
|
goto LAB_00576948;
|
|
}
|
|
ExceptionList = &local_10;
|
|
bVar1 = ANM2::SetAnimation(&npc->_sprite,&DAT_00b61c98,1);
|
|
if (bVar1 != 0) {
|
|
AnimationState::Rewind(&(npc->_sprite)._animState);
|
|
(npc->_sprite)._animState._isPlaying = 1;
|
|
}
|
|
LAB_00576948:
|
|
flags = npc->_flags;
|
|
*GHIDRA_CAST<uint32_t *>((GHIDRA_INT(&npc->_flags) + 4)) = *GHIDRA_CAST<uint32_t *>((GHIDRA_INT(&npc->_flags) + 4));
|
|
*GHIDRA_CAST<uint32_t *>(&npc->_flags) = GHIDRA_UINT(flags) & 0xfffffffb | 0xc4000011;
|
|
npc->_state = 3;
|
|
(npc->_targetPosition).x = (npc->_pos).x;
|
|
(npc->_targetPosition).y = (npc->_pos).y;
|
|
ExceptionList = local_10;
|
|
return;
|
|
}
|
|
|
|
// 005785a0
|
|
void NpcHelper::rainmaker_drop_timer_launch(Entity_Effect *timer)
|
|
{
|
|
int iVar1;
|
|
int iVar2;
|
|
uint32_t rngResult;
|
|
float distance;
|
|
float fVar3;
|
|
float distance;
|
|
float fVar5;
|
|
float dirY;
|
|
float dirX;
|
|
|
|
iVar1 = timer->_parent;
|
|
if (iVar1 == 0) {
|
|
return;
|
|
}
|
|
if (*GHIDRA_CAST<int *>((iVar1 + 0x28)) != 9) {
|
|
return;
|
|
}
|
|
distance = timer->_rotation;
|
|
iVar2 = timer->_target;
|
|
fVar3 = timer->_scale;
|
|
*GHIDRA_CAST<uint32_t *>((iVar1 + 0x43c)) = *GHIDRA_CAST<uint32_t *>((iVar1 + 0x43c)) & 0xfffffeff;
|
|
*GHIDRA_CAST<uint32_t *>((iVar1 + 0x438)) = *GHIDRA_CAST<uint32_t *>((iVar1 + 0x438));
|
|
if (iVar2 == 0) {
|
|
rngResult = Random();
|
|
fVar3 = (float)((double)GHIDRA_INT(rngResult) + __uint_to_double_fixup[-(GHIDRA_INT(rngResult) >> 0x1f)]) *
|
|
2.3283064e-10 * 3.14;
|
|
fVar3 = fVar3 + fVar3;
|
|
dirX = cos(fVar3);
|
|
dirY = sin(fVar3);
|
|
}
|
|
else {
|
|
dirX = *GHIDRA_CAST<float *>((iVar2 + 0x33c));
|
|
dirY = *GHIDRA_CAST<float *>((iVar2 + 0x340));
|
|
if (fVar3 <= 0.0) {
|
|
fVar5 = *GHIDRA_CAST<float *>((iVar1 + 0x33c));
|
|
}
|
|
else {
|
|
fVar5 = *GHIDRA_CAST<float *>((iVar1 + 0x33c));
|
|
distance = *GHIDRA_CAST<float *>((iVar1 + 0x340)) - dirY;
|
|
distance = sqrtf(distance * distance + (fVar5 - dirX) * (fVar5 - dirX));
|
|
dirY = dirY + distance * *GHIDRA_CAST<float *>((iVar2 + 0x364)) * fVar3;
|
|
dirX = dirX + distance * *GHIDRA_CAST<float *>((iVar2 + 0x360)) * fVar3;
|
|
}
|
|
dirY = dirY - *GHIDRA_CAST<float *>((iVar1 + 0x340));
|
|
dirX = dirX - fVar5;
|
|
fVar3 = sqrtf(dirX * dirX + dirY * dirY);
|
|
if (0.0 < fVar3) {
|
|
dirY = dirY * (1.0 / fVar3);
|
|
dirX = (1.0 / fVar3) * dirX;
|
|
}
|
|
}
|
|
if (0.0 < distance) {
|
|
rngResult = Random();
|
|
fVar3 = (float)((double)GHIDRA_INT(rngResult) + __uint_to_double_fixup[-(GHIDRA_INT(rngResult) >> 0x1f)]) *
|
|
2.3283064e-10;
|
|
distance = ((fVar3 + fVar3) - 1.0) * distance * 0.017453292;
|
|
fVar3 = cos(distance);
|
|
distance = sin(distance);
|
|
fVar5 = distance * dirX;
|
|
dirX = fVar3 * dirX - distance * dirY;
|
|
dirY = fVar5 + fVar3 * dirY;
|
|
}
|
|
*GHIDRA_CAST<float *>((iVar1 + 0x360)) = dirX * 10.0;
|
|
*GHIDRA_CAST<float *>((iVar1 + 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;
|
|
uint8_t *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<uint8_t *>(0x3f800000);
|
|
}
|
|
pEVar1->_isActiveRotating = 1;
|
|
pEVar1->_rotationDelay = 0x1e;
|
|
pEVar1->_rotationSpd = (float)rotationSpeed;
|
|
pEVar1->_renderDepthOffset = 1000.0;
|
|
pEVar1->_rotationDegrees = savedEndAngle - savedStartAngle;
|
|
(**(code **)(*GHIDRA_CAST<int *>(pEVar1) + 0xc))();
|
|
return pEVar1;
|
|
}
|
|
|
|
// 00582f60
|
|
void NpcHelper::scourge_whip(Entity_NPC *npc)
|
|
{
|
|
uint8_t bVar1;
|
|
uint8_t *animNameCursor;
|
|
uint32_t uVar2;
|
|
Entity_NPC *segment;
|
|
uint8_t *targetNameCursor;
|
|
uint8_t *anim;
|
|
bool isLess;
|
|
Entity_NPC *local_c;
|
|
float pitch;
|
|
uint8_t *animData;
|
|
Manager *manager;
|
|
Entity_NPC *nextSegment;
|
|
|
|
segment = npc;
|
|
while (((nextSegment = GHIDRA_CAST<Entity_NPC *>(segment->_child), nextSegment != GHIDRA_CAST<Entity_NPC *>(0x0) &&
|
|
(nextSegment->_type == 0x38d)) && (nextSegment->_variant == 10))) {
|
|
segment = nextSegment;
|
|
}
|
|
segment->_state = 7;
|
|
(segment->_targetPosition).x = g_vectorZero.x;
|
|
(segment->_targetPosition).y = g_vectorZero.y;
|
|
segment = npc;
|
|
while (((nextSegment = GHIDRA_CAST<Entity_NPC *>(segment->_parent), nextSegment != GHIDRA_CAST<Entity_NPC *>(0x0) &&
|
|
(nextSegment->_type == 0x38d)) && (nextSegment->_variant == 10))) {
|
|
segment = nextSegment;
|
|
}
|
|
animData = (segment->_sprite)._animState._animData;
|
|
anim = &DAT_00b62058;
|
|
if (npc->_subtype == 0) {
|
|
anim = &DAT_00b6208c;
|
|
}
|
|
local_c = npc;
|
|
if (animData != GHIDRA_CAST<uint8_t *>(0x0)) {
|
|
animNameCursor = animData;
|
|
if (0xf < *GHIDRA_CAST<uint32_t *>((animData + 0x14))) {
|
|
animNameCursor = *GHIDRA_CAST<uint8_t **>(animData);
|
|
}
|
|
targetNameCursor = anim;
|
|
do {
|
|
bVar1 = *animNameCursor;
|
|
isLess = bVar1 < *targetNameCursor;
|
|
if (bVar1 != *targetNameCursor) {
|
|
LAB_00583024:
|
|
uVar2 = -GHIDRA_UINT(isLess) | 1;
|
|
goto LAB_00583029;
|
|
}
|
|
if (bVar1 == 0) break;
|
|
bVar1 = animNameCursor[1];
|
|
isLess = bVar1 < targetNameCursor[1];
|
|
if (bVar1 != targetNameCursor[1]) goto LAB_00583024;
|
|
animNameCursor = animNameCursor + 2;
|
|
targetNameCursor = targetNameCursor + 2;
|
|
} while (bVar1 != 0);
|
|
uVar2 = 0;
|
|
LAB_00583029:
|
|
if ((uVar2 == 0) && ((animData[0x34] == 0 || ((segment->_sprite)._animState._isPlaying != 0))))
|
|
goto LAB_00583051;
|
|
}
|
|
bVar1 = ANM2::SetAnimation(&segment->_sprite,anim,1);
|
|
if (bVar1 != 0) {
|
|
AnimationState::Rewind(&(segment->_sprite)._animState);
|
|
(segment->_sprite)._animState._isPlaying = 1;
|
|
}
|
|
LAB_00583051:
|
|
manager = g_manager;
|
|
pitch = 1.0;
|
|
if (local_c->_championColorIdx == 0x12) {
|
|
pitch = 1.5;
|
|
}
|
|
else if (local_c->_championColorIdx == 0x13) {
|
|
pitch = 0.5;
|
|
}
|
|
local_c = GHIDRA_CAST<Entity_NPC *>(0x48);
|
|
seed_fart_sound_override(GHIDRA_CAST<int *>(&local_c));
|
|
(GHIDRA_CAST<SoundEffects *>((&manager->_sfxManager)))->SoundEffects::Play(GHIDRA_INT(local_c),1.0,2,0,pitch,0.0);
|
|
return;
|
|
}
|
|
|
|
// 00587480
|
|
void NpcHelper::scourge_chain_shoot()
|
|
{
|
|
Entity *pEVar1;
|
|
uint32_t rngResult;
|
|
Entity_NPC *in_ECX;
|
|
int chainEnd;
|
|
float fVar2;
|
|
float fVar3;
|
|
float fVar4;
|
|
float fVar5;
|
|
Vector effectPos;
|
|
Vector projVelocity;
|
|
float local_ec;
|
|
float local_e8;
|
|
Vector shootPos;
|
|
float local_dc;
|
|
float soundPitch;
|
|
float childChainOffsetY;
|
|
float childChainOffsetX;
|
|
float local_cc;
|
|
float local_c8;
|
|
float local_c4;
|
|
uint8_t projParams [4];
|
|
float fStack_bc;
|
|
float fStack_b8;
|
|
float fStack_b4;
|
|
float fStack_b0;
|
|
float fStack_ac;
|
|
float fStack_a8;
|
|
float fStack_a4;
|
|
float fStack_a0;
|
|
float fStack_9c;
|
|
float fStack_98;
|
|
float fStack_94;
|
|
float fStack_90;
|
|
float fStack_8c;
|
|
float fStack_88;
|
|
float fStack_84;
|
|
float fStack_80;
|
|
float fStack_7c;
|
|
float fStack_78;
|
|
float afStack_74 [2];
|
|
float fStack_6c;
|
|
uint32_t uStack_68;
|
|
uint32_t uStack_64;
|
|
float fStack_60;
|
|
float fStack_5c;
|
|
float fStack_58;
|
|
float fStack_54;
|
|
float fStack_50;
|
|
float fStack_4c;
|
|
float fStack_48;
|
|
int iStack_44;
|
|
uint64_t qStack_40;
|
|
float fStack_38;
|
|
int iStack_34;
|
|
float fStack_30;
|
|
int iStack_2c;
|
|
uint8_t local_28;
|
|
uint8_t *local_24;
|
|
uint32_t local_20;
|
|
uint8_t local_1c;
|
|
float local_14;
|
|
Manager *manager;
|
|
int nextSegment;
|
|
|
|
local_14 = (float)(__security_cookie ^ GHIDRA_UINT((afStack_74 + 0x19)));
|
|
chainEnd = in_ECX->_child;
|
|
while (((nextSegment = *GHIDRA_CAST<int *>((chainEnd + 0x3c0)), nextSegment != 0 &&
|
|
(*GHIDRA_CAST<int *>((nextSegment + 0x28)) == 0x38d)) && (*GHIDRA_CAST<int *>((nextSegment + 0x2c)) == 10))) {
|
|
chainEnd = nextSegment;
|
|
}
|
|
local_e8 = (in_ECX->_pos).x;
|
|
local_ec = (in_ECX->_pos).y;
|
|
childChainOffsetX = *GHIDRA_CAST<float *>((chainEnd + 0x33c)) - local_e8;
|
|
childChainOffsetY = *GHIDRA_CAST<float *>((chainEnd + 0x340)) - local_ec;
|
|
chainEnd = in_ECX->_entityRef;
|
|
while (((nextSegment = *GHIDRA_CAST<int *>((chainEnd + 0x3c0)), nextSegment != 0 &&
|
|
(*GHIDRA_CAST<int *>((nextSegment + 0x28)) == 0x38d)) && (*GHIDRA_CAST<int *>((nextSegment + 0x2c)) == 10))) {
|
|
chainEnd = nextSegment;
|
|
}
|
|
local_e8 = *GHIDRA_CAST<float *>((chainEnd + 0x33c)) - local_e8;
|
|
local_ec = *GHIDRA_CAST<float *>((chainEnd + 0x340)) - local_ec;
|
|
pEVar1 = Entity_NPC::GetPlayerTarget(in_ECX);
|
|
local_c8 = local_e8 - childChainOffsetX;
|
|
local_cc = (pEVar1->_pos).y - (in_ECX->_pos).y;
|
|
local_dc = (pEVar1->_pos).x - (in_ECX->_pos).x;
|
|
local_c4 = local_ec - childChainOffsetY;
|
|
fVar2 = sqrtf(local_c4 * local_c4 + local_c8 * local_c8);
|
|
soundPitch = 1.0;
|
|
fVar3 = local_c8;
|
|
fVar4 = local_c4;
|
|
if (0.0 < fVar2) {
|
|
fVar3 = local_c8 * (1.0 / fVar2);
|
|
fVar4 = local_c4 * (1.0 / fVar2);
|
|
}
|
|
fVar2 = -childChainOffsetY * fVar4 - childChainOffsetX * fVar3;
|
|
fVar4 = fVar2 * fVar4 + childChainOffsetY;
|
|
fVar3 = fVar2 * fVar3 + childChainOffsetX;
|
|
fVar2 = fVar4 * local_cc;
|
|
local_cc = 0.0;
|
|
local_dc = (fVar2 + fVar3 * local_dc) / (fVar4 * fVar4 + fVar3 * fVar3);
|
|
do {
|
|
fVar3 = local_cc;
|
|
rngResult = Random();
|
|
if (rngResult % 5 == 0) {
|
|
fVar4 = local_dc;
|
|
}
|
|
else {
|
|
rngResult = Random();
|
|
fVar4 = (float)((double)GHIDRA_INT(rngResult) + __uint_to_double_fixup[-(GHIDRA_INT(rngResult) >> 0x1f)]) *
|
|
2.3283064e-10;
|
|
}
|
|
shootPos.x = (in_ECX->_pos).x;
|
|
shootPos.y = (in_ECX->_pos).y;
|
|
fVar2 = childChainOffsetX * fVar4 + shootPos.x;
|
|
fVar5 = childChainOffsetY * fVar4 + shootPos.y;
|
|
shootPos.x = local_e8 * fVar4 + shootPos.x;
|
|
shootPos.y = local_ec * fVar4 + shootPos.y;
|
|
if (fVar3 == 0.0) {
|
|
local_c4 = fVar2 - shootPos.x;
|
|
local_c8 = fVar5 - shootPos.y;
|
|
}
|
|
else {
|
|
local_c4 = shootPos.x - fVar2;
|
|
local_c8 = shootPos.y - fVar5;
|
|
shootPos.x = fVar2;
|
|
shootPos.y = fVar5;
|
|
}
|
|
fVar3 = sqrtf(local_c4 * local_c4 + local_c8 * local_c8);
|
|
if (0.0 < fVar3) {
|
|
local_c4 = (1.0 / fVar3) * local_c4;
|
|
local_c8 = local_c8 * (1.0 / fVar3);
|
|
}
|
|
projParams[0] = 1;
|
|
fStack_bc = 0.0;
|
|
fStack_b8 = 0.0;
|
|
fStack_b4 = 0.0;
|
|
fStack_b0 = 1.0;
|
|
fStack_ac = 1.0;
|
|
rngResult = Random();
|
|
fStack_60 = g_vectorZero.x;
|
|
fStack_58 = g_vectorZero.x;
|
|
fStack_50 = g_vectorZero.x;
|
|
fStack_48 = -1000.0;
|
|
iStack_44 = 0;
|
|
fStack_38 = 0.0;
|
|
iStack_34 = 0x1e;
|
|
fStack_5c = g_vectorZero.y;
|
|
fStack_54 = g_vectorZero.y;
|
|
fStack_4c = g_vectorZero.y;
|
|
fStack_30 = 0.0;
|
|
iStack_2c = 0;
|
|
local_28 = 0;
|
|
local_24 = &DAT_bf800000;
|
|
local_20 = 0;
|
|
local_1c = 0;
|
|
fStack_6c = DAT_00c34cf0;
|
|
uStack_68 = 0x2000;
|
|
fStack_a8 = (float)((double)GHIDRA_INT(rngResult) + __uint_to_double_fixup[-(GHIDRA_INT(rngResult) >> 0x1f)])
|
|
* 2.3283064e-10 * 3.1415927;
|
|
uStack_64 = 0;
|
|
fStack_a4 = 1.0;
|
|
fStack_a0 = 0.005;
|
|
fStack_9c = 1.01;
|
|
fStack_98 = 1.0;
|
|
qStack_40 = 0;
|
|
fStack_bc = fStack_bc + 10.0;
|
|
fStack_b4 = fStack_b4 - 0.14;
|
|
fStack_94 = _DAT_00c34cc8;
|
|
fStack_90 = fRam00c34ccc;
|
|
fStack_8c = fRam00c34cd0;
|
|
fStack_88 = fRam00c34cd4;
|
|
fStack_84 = _DAT_00c34cd8;
|
|
fStack_80 = fRam00c34cdc;
|
|
fStack_7c = fRam00c34ce0;
|
|
fStack_78 = fRam00c34ce4;
|
|
afStack_74[0] = (float)DAT_00c34ce8;
|
|
afStack_74[1] = (*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(DAT_00c34ce8)) + 0x4)));
|
|
rngResult = Random();
|
|
projVelocity.x =
|
|
(float)((double)GHIDRA_INT(rngResult) + __uint_to_double_fixup[-(GHIDRA_INT(rngResult) >> 0x1f)]) *
|
|
2.3283064e-10 + 5.0;
|
|
projVelocity.y = projVelocity.x * local_c8;
|
|
projVelocity.x = projVelocity.x * local_c4;
|
|
Entity_NPC::FireProjectiles(in_ECX,&shootPos,&projVelocity,0,GHIDRA_CAST<ProjectileParams *>(projParams));
|
|
effectPos.x = local_c4 * 4.0 + shootPos.x;
|
|
effectPos.y = local_c8 * 4.0 + shootPos.y;
|
|
rngResult = Random();
|
|
pEVar1 = Game::Spawn(g_game,1000,2,&effectPos,&g_vectorZero,GHIDRA_CAST<Entity *>(0x0),1,rngResult);
|
|
(**(code **)(*GHIDRA_CAST<int *>(pEVar1) + 0x3c))(&g_colorGreenSplat,0xffffffff,0xff,0,1);
|
|
(pEVar1->_sprite)._offset.x = 0.0;
|
|
(pEVar1->_sprite)._offset.y = -20.0;
|
|
pEVar1->_renderDepthOffset = 10.0;
|
|
manager = g_manager;
|
|
local_cc = (float)(GHIDRA_INT(local_cc) + 1);
|
|
} while (GHIDRA_INT(local_cc) < 2);
|
|
if (in_ECX->_championColorIdx == 0x12) {
|
|
soundPitch = 1.5;
|
|
}
|
|
else if (in_ECX->_championColorIdx == 0x13) {
|
|
soundPitch = 0.5;
|
|
}
|
|
local_cc = 2.49431e-43;
|
|
seed_fart_sound_override(GHIDRA_CAST<int *>(&local_cc));
|
|
(GHIDRA_CAST<SoundEffects *>((&manager->_sfxManager)))->SoundEffects::Play(GHIDRA_INT(local_cc),1.0,2,0,soundPitch,0.0);
|
|
return;
|
|
}
|
|
|
|
// 0058ac10
|
|
void NpcHelper::singe_explode_at(Entity_NPC *npc, Vector *position)
|
|
{
|
|
int iVar1;
|
|
uint64_t qVar2;
|
|
uint32_t uVar3;
|
|
uint32_t angleRoll;
|
|
Entity *minion;
|
|
uint64_t *heapCounter;
|
|
float fVar4;
|
|
EntityList_EL minions;
|
|
EntityList_EL nearby;
|
|
Vector spawnPos;
|
|
float angle;
|
|
float angleSin;
|
|
ColorMod explosionColor;
|
|
uint32_t local_18;
|
|
void *local_10;
|
|
uint8_t *puStack_c;
|
|
float local_8;
|
|
uint32_t flagsHigh;
|
|
Game *game;
|
|
|
|
local_8 = -NAN;
|
|
puStack_c = &LAB_00af54e5;
|
|
local_10 = ExceptionList;
|
|
local_18 = __security_cookie ^ GHIDRA_UINT(((&explosionColor)[1]._colorize + 1));
|
|
ExceptionList = &local_10;
|
|
explosionColor._offset[0] = 0.0;
|
|
explosionColor._offset[1] = 0.0;
|
|
explosionColor._tint[0] = 1.0;
|
|
explosionColor._tint[1] = 1.0;
|
|
explosionColor._tint[2] = 1.0;
|
|
explosionColor._tint[3] = 1.0;
|
|
explosionColor._offset[2] = 0.0;
|
|
explosionColor._colorize[0] = 0.0;
|
|
explosionColor._colorize[1] = 0.0;
|
|
explosionColor._colorize[2] = 0.0;
|
|
explosionColor._colorize[3] = 0.0;
|
|
Game::BombExplosionEffects
|
|
(g_game,position,60.0,(BitSet128)ZEXT816(0),&explosionColor,GHIDRA_CAST<Entity *>(npc),1.15,1,4,0);
|
|
Game::ButterBeanFart(g_game,position,120.0,GHIDRA_CAST<Entity *>(npc),0,0);
|
|
Game::ShakeScreen(g_game,10);
|
|
game = g_game;
|
|
npc->_projectileCooldown = npc->_projectileCooldown + 1;
|
|
EntityList::QueryRadius(GHIDRA_CAST<EntityList *>((GHIDRA_INT(game->_room) + 0x1218)),&nearby,position,100.0,8);
|
|
local_8 = 0.0;
|
|
uVar3 = 0;
|
|
if (nearby._size != 0) {
|
|
do {
|
|
iVar1 = *GHIDRA_CAST<int *>(((*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(nearby)) + 0x4))) + uVar3 * 4));
|
|
if ((*GHIDRA_CAST<int *>((iVar1 + 0x28)) == 0x393) && (*GHIDRA_CAST<int *>((iVar1 + 0x2c)) == 1)) {
|
|
npc->_projectileCooldown = 0;
|
|
break;
|
|
}
|
|
uVar3 = uVar3 + 1;
|
|
} while (uVar3 < GHIDRA_UINT(nearby._size));
|
|
}
|
|
EntityList::QuerySublist(GHIDRA_CAST<EntityList *>((GHIDRA_INT(g_game->_room) + 0x1218)),&minions,0x393,1,-1,0,0);
|
|
local_8 = (float)CONCAT31((*GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>(&(local_8)) + 0x1))),1);
|
|
if (GHIDRA_UINT(minions._size) < npc->_i1 + 4U) {
|
|
uVar3 = Random();
|
|
angleRoll = Random();
|
|
angle = (float)((double)GHIDRA_INT(angleRoll) + __uint_to_double_fixup[-(GHIDRA_INT(angleRoll) >> 0x1f)]) *
|
|
2.3283064e-10 * 3.14;
|
|
angle = angle + angle;
|
|
angleSin = sin(angle);
|
|
fVar4 = cos(angle);
|
|
spawnPos.x = fVar4 * 20.0 + (npc->_pos).x;
|
|
spawnPos.y = angleSin * 20.0 + (npc->_pos).y;
|
|
minion = Game::Spawn(g_game,0x393,1,&spawnPos,&g_vectorZero,GHIDRA_CAST<Entity *>(npc),0,uVar3);
|
|
flagsHigh = *GHIDRA_CAST<uint32_t *>((GHIDRA_INT(&minion->_flags) + 4));
|
|
iVar1 = *GHIDRA_CAST<int *>(minion);
|
|
*GHIDRA_CAST<uint32_t *>(&minion->_flags) = GHIDRA_UINT(minion->_flags) & 0xfffffffb;
|
|
*GHIDRA_CAST<uint32_t *>((GHIDRA_INT(&minion->_flags) + 4)) = flagsHigh;
|
|
(**(code **)(iVar1 + 0xc))();
|
|
iVar1 = *GHIDRA_CAST<int *>(minion);
|
|
minion[2]._speedMultiplier = -500.0;
|
|
minion[2]._prevVelocity.x = 10.0;
|
|
(**(code **)(iVar1 + 0xc))();
|
|
}
|
|
if ((*GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>(&(minions)) + 0x0))) == '\0') {
|
|
heapCounter = GHIDRA_CAST<uint64_t *>((GHIDRA_INT(g_mainHeap) + 0x30));
|
|
if (g_mainHeap == (void *)0x0) {
|
|
heapCounter = &g_allocatedBytesNoHeap;
|
|
}
|
|
if ((*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(minions)) + 0x4))) != 0) {
|
|
uVar3 = *GHIDRA_CAST<uint32_t *>(((*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(minions)) + 0x4))) + -4));
|
|
qVar2 = *heapCounter;
|
|
*GHIDRA_CAST<uint32_t *>(heapCounter) = GHIDRA_UINT(*heapCounter) - uVar3;
|
|
*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(heapCounter) + 4)) =
|
|
*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(heapCounter) + 4)) - GHIDRA_UINT((GHIDRA_UINT(qVar2) < uVar3));
|
|
free((void *)((*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(minions)) + 0x4))) + -4));
|
|
}
|
|
}
|
|
if ((*GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>(&(nearby)) + 0x0))) == '\0') {
|
|
heapCounter = GHIDRA_CAST<uint64_t *>((GHIDRA_INT(g_mainHeap) + 0x30));
|
|
if (g_mainHeap == (void *)0x0) {
|
|
heapCounter = &g_allocatedBytesNoHeap;
|
|
}
|
|
if ((*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(nearby)) + 0x4))) != 0) {
|
|
uVar3 = *GHIDRA_CAST<uint32_t *>(((*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(nearby)) + 0x4))) + -4));
|
|
qVar2 = *heapCounter;
|
|
*GHIDRA_CAST<uint32_t *>(heapCounter) = GHIDRA_UINT(*heapCounter) - uVar3;
|
|
*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(heapCounter) + 4)) =
|
|
*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(heapCounter) + 4)) - GHIDRA_UINT((GHIDRA_UINT(qVar2) < uVar3));
|
|
free((void *)((*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(nearby)) + 0x4))) + -4));
|
|
}
|
|
}
|
|
ExceptionList = local_10;
|
|
return;
|
|
}
|
|
|
|
// 0058e260
|
|
void NpcHelper::siren_charm_familiar(Entity_NPC *npc, Entity_Familiar *familiar)
|
|
{
|
|
void *pvVar1;
|
|
ANM2 *pAVar2;
|
|
Entity_Familiar *pEVar3;
|
|
uint32_t seed;
|
|
Entity *secondEffect;
|
|
uint32_t *refSlot;
|
|
Vector local_1c;
|
|
Vector local_14;
|
|
int *eraseRef [2];
|
|
int temp_5f68b46de4;
|
|
|
|
pEVar3 = familiar;
|
|
if ((familiar->_flags & 0x100) == 0) {
|
|
seed = Random();
|
|
local_14.x = (pEVar3->_velocity).x;
|
|
local_14.y = (pEVar3->_velocity).y;
|
|
local_1c.x = (pEVar3->_pos).x;
|
|
local_1c.y = (pEVar3->_pos).y;
|
|
familiar = (Entity_Familiar *)
|
|
Game::Spawn(g_game,1000,0xa5,&local_1c,&local_14,GHIDRA_CAST<Entity *>(npc),0,seed);
|
|
*GHIDRA_CAST<uint32_t *>(&(*GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>((familiar)) + 0x45c)))) = 0x4b;
|
|
refSlot = &familiar->_parent;
|
|
*GHIDRA_CAST<uint32_t *>(&(*GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>((familiar)) + 0x460)))) = 0x4b;
|
|
if (familiar->_parent != 0) {
|
|
eraseRef[0] = refSlot;
|
|
msvc::multiset<unsigned_int>::erase(eraseRef);
|
|
}
|
|
*refSlot = npc;
|
|
if (npc != GHIDRA_CAST<Entity_NPC *>(0x0)) {
|
|
msvc::multiset<unsigned_int>::insert(refSlot);
|
|
}
|
|
refSlot = &familiar->_target;
|
|
if (*refSlot != 0) {
|
|
eraseRef[0] = refSlot;
|
|
msvc::multiset<unsigned_int>::erase(eraseRef);
|
|
}
|
|
*refSlot = pEVar3;
|
|
msvc::multiset<unsigned_int>::insert(refSlot);
|
|
local_14.y = (float)npc->_sirenPlayerEntity;
|
|
refSlot = &familiar->_child;
|
|
if (*refSlot != 0) {
|
|
eraseRef[0] = refSlot;
|
|
msvc::multiset<unsigned_int>::erase(eraseRef);
|
|
}
|
|
*refSlot = local_14.y;
|
|
if ((void *)local_14.y != (void *)0x0) {
|
|
msvc::multiset<unsigned_int>::insert(refSlot);
|
|
}
|
|
(**(code **)(*GHIDRA_CAST<int *>(familiar) + 0xc))();
|
|
seed = Random();
|
|
local_1c.x = (pEVar3->_velocity).x;
|
|
local_1c.y = (pEVar3->_velocity).y;
|
|
local_14.x = (pEVar3->_pos).x;
|
|
local_14.y = (pEVar3->_pos).y;
|
|
secondEffect = Game::Spawn(g_game,1000,0xa5,&local_14,&local_1c,GHIDRA_CAST<Entity *>(npc),1,seed);
|
|
temp_5f68b46de4 = secondEffect->_parent;
|
|
pAVar2 = &secondEffect[1]._sprite;
|
|
(pAVar2->_filename)._buf[4] = 'K';
|
|
(pAVar2->_filename)._buf[5] = '\0';
|
|
(pAVar2->_filename)._buf[6] = '\0';
|
|
(pAVar2->_filename)._buf[7] = '\0';
|
|
pAVar2 = &secondEffect[1]._sprite;
|
|
(pAVar2->_filename)._buf[8] = 'K';
|
|
(pAVar2->_filename)._buf[9] = '\0';
|
|
(pAVar2->_filename)._buf[10] = '\0';
|
|
(pAVar2->_filename)._buf[0xb] = '\0';
|
|
if (temp_5f68b46de4 != 0) {
|
|
familiar = GHIDRA_CAST<Entity_Familiar *>(&secondEffect->_parent);
|
|
msvc::multiset<unsigned_int>::erase(&familiar);
|
|
}
|
|
secondEffect->_parent = npc;
|
|
msvc::multiset<unsigned_int>::insert(&secondEffect->_parent);
|
|
if (secondEffect->_target != 0) {
|
|
familiar = GHIDRA_CAST<Entity_Familiar *>(&secondEffect->_target);
|
|
msvc::multiset<unsigned_int>::erase(&familiar);
|
|
}
|
|
secondEffect->_target = pEVar3;
|
|
msvc::multiset<unsigned_int>::insert(&secondEffect->_target);
|
|
pvVar1 = npc->_sirenPlayerEntity;
|
|
refSlot = &secondEffect->_child;
|
|
if (*refSlot != 0) {
|
|
familiar = GHIDRA_CAST<Entity_Familiar *>(refSlot);
|
|
msvc::multiset<unsigned_int>::erase(&familiar);
|
|
}
|
|
*refSlot = pvVar1;
|
|
if (pvVar1 != (void *)0x0) {
|
|
msvc::multiset<unsigned_int>::insert(refSlot);
|
|
}
|
|
(**(code **)(*GHIDRA_CAST<int *>(secondEffect) + 0xc))();
|
|
}
|
|
return;
|
|
}
|
|
|
|
// 0058e490
|
|
void NpcHelper::siren_familiar_counts(int *outFreeCount, int *outCharmedCount, int *outTotalCount)
|
|
{
|
|
char isCharmable;
|
|
uint32_t uVar1;
|
|
int familiarsData;
|
|
int extraout_ECX;
|
|
uint32_t uVar2;
|
|
uint32_t extraout_EDX;
|
|
uint64_t *heapAllocatedBytes;
|
|
EntityList_EL local_24;
|
|
void *local_10;
|
|
uint8_t *puStack_c;
|
|
uint32_t uStack_8;
|
|
int familiar;
|
|
Game *game;
|
|
uint64_t oldAllocatedBytes;
|
|
|
|
game = g_game;
|
|
uStack_8 = 0xffffffff;
|
|
puStack_c = &LAB_00af1690;
|
|
local_10 = ExceptionList;
|
|
uVar1 = __security_cookie ^ GHIDRA_INT(register0x00000010) - 4U;
|
|
ExceptionList = &local_10;
|
|
*outFreeCount = 0;
|
|
*outCharmedCount = 0;
|
|
*outTotalCount = 0;
|
|
EntityList::QuerySublist(GHIDRA_CAST<EntityList *>((GHIDRA_INT(game->_room) + 0x1218)),&local_24,3,-1,-1,0,0);
|
|
uVar2 = 0;
|
|
if (local_24._size != 0) {
|
|
familiarsData = (*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(local_24)) + 0x4)));
|
|
do {
|
|
familiar = *GHIDRA_CAST<int *>((familiarsData + uVar2 * 4));
|
|
if ((familiar != 0) && (*GHIDRA_CAST<int *>((familiar + 0x28)) == 3)) {
|
|
isCharmable = FUN_0060dae0(uVar1);
|
|
if (isCharmable != '\0') {
|
|
if ((*GHIDRA_CAST<uint32_t *>((extraout_ECX + 0x168)) & 0x100) == 0) {
|
|
*outFreeCount = *outFreeCount + 1;
|
|
}
|
|
else {
|
|
*outCharmedCount = *outCharmedCount + 1;
|
|
}
|
|
*outTotalCount = *outTotalCount + 1;
|
|
}
|
|
familiarsData = (*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(local_24)) + 0x4)));
|
|
uVar2 = extraout_EDX;
|
|
}
|
|
uVar2 = uVar2 + 1;
|
|
} while (uVar2 < GHIDRA_UINT(local_24._size));
|
|
}
|
|
if ((*GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>(&(local_24)) + 0x0))) == '\0') {
|
|
if (g_mainHeap == (void *)0x0) {
|
|
heapAllocatedBytes = &g_allocatedBytesNoHeap;
|
|
}
|
|
else {
|
|
heapAllocatedBytes = GHIDRA_CAST<uint64_t *>((GHIDRA_INT(g_mainHeap) + 0x30));
|
|
}
|
|
if ((*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(local_24)) + 0x4))) != 0) {
|
|
uVar2 = *GHIDRA_CAST<uint32_t *>(((*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(local_24)) + 0x4))) + -4));
|
|
oldAllocatedBytes = *heapAllocatedBytes;
|
|
*GHIDRA_CAST<uint32_t *>(heapAllocatedBytes) = GHIDRA_UINT(*heapAllocatedBytes) - uVar2;
|
|
*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(heapAllocatedBytes) + 4)) =
|
|
*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(heapAllocatedBytes) + 4)) - GHIDRA_UINT((GHIDRA_UINT(oldAllocatedBytes) < uVar2));
|
|
free(GHIDRA_CAST<uint32_t *>(((*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(local_24)) + 0x4))) + -4)));
|
|
}
|
|
}
|
|
ExceptionList = local_10;
|
|
return;
|
|
}
|
|
|
|
// 0058e590
|
|
int NpcHelper::siren_charmed_count(Entity_NPC *npc)
|
|
{
|
|
uint64_t qVar1;
|
|
uint8_t isDetached;
|
|
uint64_t *allocatedBytes;
|
|
int extraout_ECX;
|
|
uint32_t uVar2;
|
|
uint32_t extraout_EDX;
|
|
int count;
|
|
EntityList_EL local_24;
|
|
Entity_NPC *siren;
|
|
void *local_10;
|
|
uint8_t *puStack_c;
|
|
uint32_t uStack_8;
|
|
Entity_Familiar *familiar;
|
|
|
|
uStack_8 = 0xffffffff;
|
|
puStack_c = &LAB_00af38e0;
|
|
local_10 = ExceptionList;
|
|
ExceptionList = &local_10;
|
|
count = 0;
|
|
siren = npc;
|
|
EntityList::QuerySublist(GHIDRA_CAST<EntityList *>((GHIDRA_INT(g_game->_room) + 0x1218)),&local_24,3,-1,-1,0,0);
|
|
uVar2 = 0;
|
|
if (local_24._size != 0) {
|
|
do {
|
|
familiar = *GHIDRA_CAST<Entity_Familiar **>(((*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(local_24)) + 0x4))) + uVar2 * 4));
|
|
if ((((familiar != GHIDRA_CAST<Entity_Familiar *>(0x0)) && (familiar->_type == 3)) &&
|
|
((familiar->_flags & 0x100) != 0)) &&
|
|
((isDetached = Entity_Familiar::is_detached_from_follow(familiar), uVar2 = extraout_EDX,
|
|
isDetached != 0 && (*(void **)(extraout_ECX + 0x410) == siren->_sirenPlayerEntity)))) {
|
|
count = count + 1;
|
|
}
|
|
uVar2 = uVar2 + 1;
|
|
} while (uVar2 < GHIDRA_UINT(local_24._size));
|
|
}
|
|
if ((*GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>(&(local_24)) + 0x0))) == '\0') {
|
|
if (g_mainHeap == (void *)0x0) {
|
|
allocatedBytes = &g_allocatedBytesNoHeap;
|
|
}
|
|
else {
|
|
allocatedBytes = GHIDRA_CAST<uint64_t *>((GHIDRA_INT(g_mainHeap) + 0x30));
|
|
}
|
|
if ((*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(local_24)) + 0x4))) != 0) {
|
|
uVar2 = *GHIDRA_CAST<uint32_t *>(((*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(local_24)) + 0x4))) + -4));
|
|
qVar1 = *allocatedBytes;
|
|
*GHIDRA_CAST<uint32_t *>(allocatedBytes) = GHIDRA_UINT(*allocatedBytes) - uVar2;
|
|
*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(allocatedBytes) + 4)) =
|
|
*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(allocatedBytes) + 4)) - GHIDRA_UINT((GHIDRA_UINT(qVar1) < uVar2));
|
|
free((void *)((*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(local_24)) + 0x4))) + -4));
|
|
}
|
|
}
|
|
ExceptionList = local_10;
|
|
return count;
|
|
}
|
|
|
|
// 0058e680
|
|
void NpcHelper::siren_pick(Entity_NPC *npc)
|
|
{
|
|
RNG rng;
|
|
uint64_t qVar1;
|
|
int charmedCount;
|
|
uint32_t uVar2;
|
|
int familiar;
|
|
float fVar3;
|
|
uint32_t outcomeCount;
|
|
float fVar4;
|
|
uint64_t *heapCounter;
|
|
uint32_t *outcomesBegin;
|
|
uint32_t *controlledCount;
|
|
uint32_t *outcomeCursor;
|
|
float roomCenterY;
|
|
float rightEdgeStart;
|
|
float leftEdgeStart;
|
|
uint32_t *controlledTotal;
|
|
EntityList_EL local_64;
|
|
Entity_NPC *local_54;
|
|
uint32_t *picker;
|
|
uint32_t *outcomesEnd;
|
|
uint32_t *outcomesCapacity;
|
|
float local_44;
|
|
float local_40;
|
|
int local_3c [7];
|
|
uint8_t *puStack_20;
|
|
void *local_1c;
|
|
uint8_t *puStack_18;
|
|
uint32_t local_14;
|
|
void *room;
|
|
int *weight;
|
|
|
|
puStack_20 = GHIDRA_CAST<uint8_t *>((local_3c + 0xe));
|
|
puStack_18 = &LAB_00af55ad;
|
|
local_1c = ExceptionList;
|
|
local_3c[6] = __security_cookie ^ GHIDRA_UINT((local_3c + 0xb));
|
|
ExceptionList = &local_1c;
|
|
controlledCount = GHIDRA_CAST<uint32_t *>(0x0);
|
|
local_3c[4] = 0xc;
|
|
local_3c[0] = 3;
|
|
local_3c[1] = 8;
|
|
local_3c[2] = 9;
|
|
local_3c[3] = 10;
|
|
local_3c[5] = 6;
|
|
picker = GHIDRA_CAST<uint32_t *>(0x0);
|
|
outcomesEnd = GHIDRA_CAST<uint32_t *>(0x0);
|
|
outcomesCapacity = GHIDRA_CAST<uint32_t *>(0x0);
|
|
local_14 = 0;
|
|
local_54 = npc;
|
|
siren_familiar_counts(GHIDRA_CAST<int *>(&local_40),GHIDRA_CAST<int *>(&local_44),&local_64._size);
|
|
charmedCount = siren_charmed_count(local_54);
|
|
controlledTotal = GHIDRA_CAST<uint32_t *>(0x0);
|
|
EntityList::QuerySublist(GHIDRA_CAST<EntityList *>((GHIDRA_INT(g_game->_room) + 0x1218)),&local_64,3,-1,-1,0,0);
|
|
fVar4 = 0.0;
|
|
outcomesBegin = controlledCount;
|
|
outcomeCursor = GHIDRA_CAST<uint32_t *>(0x0);
|
|
if ((float)local_64._size != 0.0) {
|
|
do {
|
|
familiar = *GHIDRA_CAST<int *>(((*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(local_64)) + 0x4))) + GHIDRA_INT(fVar4) * 4));
|
|
if ((familiar == 0) || (*GHIDRA_CAST<int *>((familiar + 0x28)) != 3)) {
|
|
familiar = 0;
|
|
}
|
|
if (((*GHIDRA_CAST<uint32_t *>((familiar + 0x168)) & 0x100) != 0) &&
|
|
(*(void **)(familiar + 0x410) == local_54->_sirenPlayerEntity)) {
|
|
controlledCount = GHIDRA_CAST<uint32_t *>((GHIDRA_INT(controlledCount) + 1));
|
|
}
|
|
fVar4 = (float)(GHIDRA_INT(fVar4) + 1);
|
|
} while (GHIDRA_UINT(fVar4) < GHIDRA_UINT(local_64._size));
|
|
outcomesBegin = picker;
|
|
outcomeCursor = outcomesEnd;
|
|
controlledTotal = controlledCount;
|
|
}
|
|
if ((*GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>(&(local_64)) + 0x0))) == '\0') {
|
|
if (g_mainHeap == (void *)0x0) {
|
|
heapCounter = &g_allocatedBytesNoHeap;
|
|
}
|
|
else {
|
|
heapCounter = GHIDRA_CAST<uint64_t *>((GHIDRA_INT(g_mainHeap) + 0x30));
|
|
}
|
|
if ((*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(local_64)) + 0x4))) != 0) {
|
|
uVar2 = *GHIDRA_CAST<uint32_t *>(((*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(local_64)) + 0x4))) + -4));
|
|
qVar1 = *heapCounter;
|
|
*GHIDRA_CAST<uint32_t *>(heapCounter) = GHIDRA_UINT(*heapCounter) - uVar2;
|
|
*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(heapCounter) + 4)) =
|
|
*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(heapCounter) + 4)) - GHIDRA_UINT((GHIDRA_UINT(qVar1) < uVar2));
|
|
free(GHIDRA_CAST<uint32_t *>(((*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(local_64)) + 0x4))) + -4)));
|
|
}
|
|
local_14 = local_14 & 0xffffff00;
|
|
}
|
|
if ((*GHIDRA_CAST<char *>((GHIDRA_INT(&(local_54->_v2).x) + 1)) == '\0') && (GHIDRA_INT(controlledTotal) < 2)) {
|
|
fVar3 = (float)(GHIDRA_INT(controlledTotal) * -0x21 + 100);
|
|
fVar4 = 0.0;
|
|
if (0 < GHIDRA_INT(fVar3)) {
|
|
fVar4 = fVar3;
|
|
}
|
|
if (0 < GHIDRA_INT(fVar4)) {
|
|
local_64._capacity = 1;
|
|
local_64._size = GHIDRA_INT(fVar4);
|
|
msvc::vector<8byte>::_Emplace_reallocate(0,&local_64._capacity);
|
|
outcomesBegin = picker;
|
|
outcomeCursor = outcomesEnd;
|
|
}
|
|
}
|
|
if (((*GHIDRA_CAST<char *>((GHIDRA_INT(&(local_54->_v2).x) + 3)) == '\0') && (GHIDRA_INT(local_44) < 6)) &&
|
|
(0 < GHIDRA_INT(local_40))) {
|
|
fVar3 = (float)(GHIDRA_INT(local_40) * 0x21 + GHIDRA_INT(local_44) * -0xf);
|
|
fVar4 = 1.4013e-45;
|
|
if (1 < GHIDRA_INT(fVar3)) {
|
|
fVar4 = fVar3;
|
|
}
|
|
local_40 = 2.10195e-43;
|
|
if (GHIDRA_INT(fVar4) < 0x96) {
|
|
local_40 = fVar4;
|
|
}
|
|
uVar2 = 0;
|
|
outcomeCount = GHIDRA_INT(outcomeCursor) - GHIDRA_INT(outcomesBegin) >> 3;
|
|
if (outcomeCount != 0) {
|
|
do {
|
|
if (outcomesBegin[uVar2 * 2] == 3) {
|
|
weight = outcomesBegin + uVar2 * 2 + 1;
|
|
*weight = *weight + GHIDRA_INT(local_40);
|
|
if (*weight < 0) {
|
|
outcomesBegin[uVar2 * 2 + 1] = 0;
|
|
}
|
|
goto LAB_0058e8af;
|
|
}
|
|
uVar2 = uVar2 + 1;
|
|
} while (uVar2 < outcomeCount);
|
|
}
|
|
if (0 < GHIDRA_INT(local_40)) {
|
|
local_64._capacity = 3;
|
|
local_64._size = GHIDRA_INT(local_40);
|
|
if (outcomeCursor == outcomesCapacity) {
|
|
msvc::vector<8byte>::_Emplace_reallocate(outcomeCursor,&local_64._capacity);
|
|
outcomesBegin = picker;
|
|
outcomeCursor = outcomesEnd;
|
|
}
|
|
else {
|
|
*outcomeCursor = 3;
|
|
outcomeCursor[1] = local_40;
|
|
outcomesEnd = outcomeCursor + 2;
|
|
outcomeCursor = outcomesEnd;
|
|
}
|
|
}
|
|
}
|
|
LAB_0058e8af:
|
|
if (*GHIDRA_CAST<char *>(&(local_54->_v2).y) == '\0') {
|
|
fVar4 = 4.62428e-44;
|
|
if (0x21 < charmedCount * 0x21) {
|
|
fVar4 = (float)(charmedCount * 0x21);
|
|
}
|
|
local_40 = 1.4013e-43;
|
|
if (GHIDRA_INT(fVar4) < 100) {
|
|
local_40 = fVar4;
|
|
}
|
|
outcomeCount = GHIDRA_INT(outcomeCursor) - GHIDRA_INT(outcomesBegin) >> 3;
|
|
uVar2 = 0;
|
|
if (outcomeCount != 0) {
|
|
do {
|
|
if (outcomesBegin[uVar2 * 2] == 4) {
|
|
weight = outcomesBegin + uVar2 * 2 + 1;
|
|
*weight = *weight + GHIDRA_INT(local_40);
|
|
if (*weight < 0) {
|
|
outcomesBegin[uVar2 * 2 + 1] = 0;
|
|
}
|
|
goto LAB_0058e94b;
|
|
}
|
|
uVar2 = uVar2 + 1;
|
|
} while (uVar2 < outcomeCount);
|
|
}
|
|
if (0 < GHIDRA_INT(local_40)) {
|
|
local_64._capacity = 4;
|
|
local_64._size = GHIDRA_INT(local_40);
|
|
if (outcomeCursor == outcomesCapacity) {
|
|
msvc::vector<8byte>::_Emplace_reallocate(outcomeCursor,&local_64._capacity);
|
|
outcomesBegin = picker;
|
|
outcomeCursor = outcomesEnd;
|
|
}
|
|
else {
|
|
*outcomeCursor = 4;
|
|
outcomeCursor[1] = local_40;
|
|
outcomesEnd = outcomeCursor + 2;
|
|
outcomeCursor = outcomesEnd;
|
|
}
|
|
}
|
|
}
|
|
LAB_0058e94b:
|
|
if ((*GHIDRA_CAST<char *>((GHIDRA_INT(&(local_54->_v2).y) + 1)) == '\0') && (local_44 == 0.0)) {
|
|
local_64._size = GHIDRA_INT((local_54->_pos).y);
|
|
room = g_game->_room;
|
|
fVar4 = *GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(room) + 0x1c));
|
|
fVar3 = *GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(room) + 0x20));
|
|
rightEdgeStart = fVar4 - 80.0;
|
|
local_40 = *GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(room) + 0x14));
|
|
leftEdgeStart = local_40 + 80.0;
|
|
roomCenterY = (fVar3 - *GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(room) + 0x18))) * 0.5 + *GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(room) + 0x18));
|
|
local_44 = (local_54->_pos).x;
|
|
if (rightEdgeStart == fVar4) {
|
|
KAGE_LogMessage(0x10,GHIDRA_CAST<uint8_t *>("Start and End parameters cannot be the same!"));
|
|
}
|
|
fVar4 = (local_44 - rightEdgeStart) / (fVar4 - rightEdgeStart);
|
|
if (fVar4 <= 0.0) {
|
|
fVar4 = 0.0;
|
|
}
|
|
if (1.0 <= fVar4) {
|
|
fVar4 = 1.0;
|
|
}
|
|
if (leftEdgeStart == local_40) {
|
|
KAGE_LogMessage(0x10,GHIDRA_CAST<uint8_t *>("Start and End parameters cannot be the same!"));
|
|
}
|
|
local_44 = (local_44 - leftEdgeStart) / (local_40 - leftEdgeStart);
|
|
if (local_44 <= 0.0) {
|
|
local_44 = 0.0;
|
|
}
|
|
if (1.0 <= local_44) {
|
|
local_44 = 1.0;
|
|
}
|
|
if (roomCenterY == fVar3) {
|
|
KAGE_LogMessage(0x10,GHIDRA_CAST<uint8_t *>("Start and End parameters cannot be the same!"));
|
|
}
|
|
outcomeCount = GHIDRA_INT(outcomeCursor) - GHIDRA_INT(outcomesBegin) >> 3;
|
|
uVar2 = 0;
|
|
fVar3 = ((float)local_64._size - roomCenterY) / (fVar3 - roomCenterY);
|
|
if (fVar3 <= 0.0) {
|
|
fVar3 = 0.0;
|
|
}
|
|
if (1.0 <= fVar3) {
|
|
fVar3 = 1.0;
|
|
}
|
|
fVar4 = (float)GHIDRA_INT(((fVar3 + 0.0 + local_44 + 0.0 + fVar4 + 0.0) * 100.0));
|
|
if (outcomeCount != 0) {
|
|
do {
|
|
if (outcomesBegin[uVar2 * 2] == 5) {
|
|
weight = outcomesBegin + uVar2 * 2 + 1;
|
|
*weight = *weight + GHIDRA_INT(fVar4);
|
|
if (*weight < 0) {
|
|
outcomesBegin[uVar2 * 2 + 1] = 0;
|
|
}
|
|
goto LAB_0058eb5f;
|
|
}
|
|
uVar2 = uVar2 + 1;
|
|
} while (uVar2 < outcomeCount);
|
|
}
|
|
if (0 < GHIDRA_INT(fVar4)) {
|
|
local_64._capacity = 5;
|
|
local_64._size = GHIDRA_INT(fVar4);
|
|
if (outcomeCursor == outcomesCapacity) {
|
|
msvc::vector<8byte>::_Emplace_reallocate(outcomeCursor,&local_64._capacity);
|
|
outcomesBegin = picker;
|
|
outcomeCursor = outcomesEnd;
|
|
}
|
|
else {
|
|
*outcomeCursor = 5;
|
|
outcomeCursor[1] = fVar4;
|
|
outcomesEnd = outcomeCursor + 2;
|
|
outcomeCursor = outcomesEnd;
|
|
}
|
|
}
|
|
LAB_0058eb5f:
|
|
if (outcomesBegin != outcomeCursor) goto LAB_0058ebbb;
|
|
}
|
|
else if (GHIDRA_INT(local_44) < 1) goto LAB_0058eb5f;
|
|
uVar2 = 0;
|
|
outcomeCount = GHIDRA_INT(outcomeCursor) - GHIDRA_INT(outcomesBegin) >> 3;
|
|
if (outcomeCount != 0) {
|
|
do {
|
|
if (outcomesBegin[uVar2 * 2] == 0) {
|
|
weight = outcomesBegin + uVar2 * 2 + 1;
|
|
*weight = *weight + 100;
|
|
if (*weight < 0) {
|
|
outcomesBegin[uVar2 * 2 + 1] = 0;
|
|
}
|
|
goto LAB_0058ebbb;
|
|
}
|
|
uVar2 = uVar2 + 1;
|
|
} while (uVar2 < outcomeCount);
|
|
}
|
|
local_64._size = 100;
|
|
(*GHIDRA_CAST<uint64_t *>((GHIDRA_CAST<char *>(&(local_64)) + 0x4))) = (*GHIDRA_CAST<uint64_t *>((GHIDRA_CAST<char *>(&(local_64)) + 0x4))) & 0xffffffff;
|
|
if (outcomeCursor == outcomesCapacity) {
|
|
msvc::vector<8byte>::_Emplace_reallocate(outcomeCursor,&local_64._capacity);
|
|
}
|
|
else {
|
|
*outcomeCursor = 0;
|
|
outcomeCursor[1] = 100;
|
|
outcomesEnd = outcomeCursor + 2;
|
|
}
|
|
LAB_0058ebbb:
|
|
(*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(local_64)) + 0x0))) = Random();
|
|
(*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(local_64)) + 0x0))) = (*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(local_64)) + 0x0))) | 1;
|
|
(*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(local_64)) + 0x4))) = 5;
|
|
local_64._capacity = 9;
|
|
local_64._size = 7;
|
|
rng._shift1 = 5;
|
|
rng._seed = (*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(local_64)) + 0x0)));
|
|
rng._shift2 = 9;
|
|
rng._shift3 = 7;
|
|
uVar2 = (GHIDRA_CAST<WeightedOutcomePicker *>((GHIDRA_CAST<WeightedOutcomePicker *>(&picker))))->WeightedOutcomePicker::PickOutcome(rng);
|
|
if (uVar2 == 0) {
|
|
*GHIDRA_CAST<uint16_t *>((GHIDRA_INT(&local_54->_projectileCooldown) + 2)) = 0;
|
|
}
|
|
else {
|
|
charmedCount = local_3c[uVar2];
|
|
*GHIDRA_CAST<uint16_t *>(&local_54->_projectileCooldown) = 0xffff;
|
|
local_54->_state = charmedCount;
|
|
}
|
|
if (picker != GHIDRA_CAST<uint32_t *>(0x0)) {
|
|
uVar2 = GHIDRA_INT(outcomesCapacity) - GHIDRA_INT(picker) & 0xfffffff8;
|
|
outcomesBegin = picker;
|
|
if (0xfff < uVar2) {
|
|
outcomesBegin = GHIDRA_CAST<uint32_t *>(picker[-1]);
|
|
uVar2 = uVar2 + 0x23;
|
|
if (0x1f < GHIDRA_UINT((GHIDRA_INT(picker) + (-4 - GHIDRA_INT(outcomesBegin))))) {
|
|
/* WARNING: Subroutine does not return */
|
|
_invalid_parameter_noinfo_noreturn();
|
|
}
|
|
}
|
|
operator_delete(outcomesBegin,uVar2);
|
|
}
|
|
ExceptionList = local_1c;
|
|
return;
|
|
}
|
|
|
|
// 00592050
|
|
void NpcHelper::siren_familiar_orbit(Entity_NPC *siren, Entity_Familiar *familiar)
|
|
{
|
|
void *pvVar1;
|
|
uint8_t isDetached;
|
|
int extraout_ECX;
|
|
int extraout_ECX_00;
|
|
int orbitSlot;
|
|
int extraout_EDX;
|
|
int extraout_EDX_00;
|
|
void *orbitCenter;
|
|
int detachedAheadCount;
|
|
float fVar2;
|
|
float fVar3;
|
|
float fVar4;
|
|
float fVar5;
|
|
float deltaY;
|
|
Entity_Familiar *chainFamiliar;
|
|
int chainType;
|
|
|
|
pvVar1 = siren->_sirenPlayerEntity;
|
|
if (pvVar1 != (void *)0x0) {
|
|
orbitCenter = pvVar1;
|
|
if ((void *)siren->_child != (void *)0x0) {
|
|
orbitCenter = (void *)siren->_child;
|
|
}
|
|
orbitSlot = 0;
|
|
detachedAheadCount = 0;
|
|
chainFamiliar = GHIDRA_CAST<Entity_Familiar *>(familiar->_parent);
|
|
if (chainFamiliar != GHIDRA_CAST<Entity_Familiar *>(0x0)) {
|
|
chainType = chainFamiliar->_type;
|
|
while (chainType == 3) {
|
|
isDetached = Entity_Familiar::is_detached_from_follow(chainFamiliar);
|
|
if (isDetached != 0) {
|
|
detachedAheadCount = detachedAheadCount + 1;
|
|
}
|
|
chainFamiliar = *GHIDRA_CAST<Entity_Familiar **>((extraout_ECX + 0x3bc));
|
|
orbitSlot = extraout_EDX;
|
|
if (chainFamiliar == GHIDRA_CAST<Entity_Familiar *>(0x0)) break;
|
|
chainType = chainFamiliar->_type;
|
|
}
|
|
}
|
|
chainFamiliar = GHIDRA_CAST<Entity_Familiar *>(familiar->_child);
|
|
if (chainFamiliar != GHIDRA_CAST<Entity_Familiar *>(0x0)) {
|
|
chainType = chainFamiliar->_type;
|
|
while (chainType == 3) {
|
|
isDetached = Entity_Familiar::is_detached_from_follow(chainFamiliar);
|
|
orbitSlot = extraout_EDX_00;
|
|
if (isDetached != 0) {
|
|
orbitSlot = extraout_EDX_00 + 1;
|
|
}
|
|
chainFamiliar = *GHIDRA_CAST<Entity_Familiar **>((extraout_ECX_00 + 0x3c0));
|
|
if (chainFamiliar == GHIDRA_CAST<Entity_Familiar *>(0x0)) break;
|
|
chainType = chainFamiliar->_type;
|
|
}
|
|
}
|
|
fVar5 = (((float)orbitSlot * 360.0) / (float)(orbitSlot + 1 + detachedAheadCount) +
|
|
*GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(pvVar1) + 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;
|
|
uint32_t dequeIndex;
|
|
uint32_t uVar2;
|
|
float fVar3;
|
|
float fVar4;
|
|
double dVar5;
|
|
float smoothedPointX;
|
|
float fStack_5c;
|
|
uint32_t uStack_58;
|
|
float fStack_54;
|
|
float firstPointX;
|
|
float fStack_4c;
|
|
float fStack_48;
|
|
float fStack_44;
|
|
float local_40;
|
|
float local_3c;
|
|
ColorMod pointColor;
|
|
uint32_t local_c;
|
|
uint8_t auStack_8 [4];
|
|
float *screenPointsEnd;
|
|
void *trailPointsEnd;
|
|
|
|
local_c = __security_cookie ^ GHIDRA_UINT((auStack_8 + 4));
|
|
if (8 < (npc->_vectorDeque2)._size) {
|
|
iVar1 = *GHIDRA_CAST<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) {
|
|
msvc::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<uint32_t *>((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 = *(uint32_t *)
|
|
(*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<uint32_t *>((GHIDRA_CAST<char *>(trailPointsEnd) + 8)) = uStack_58;
|
|
*GHIDRA_CAST<uint32_t *>((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<uint16_t *>((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, uint8_t *animName, int unused)
|
|
{
|
|
uint8_t bVar1;
|
|
uint8_t ****ppppbVar2;
|
|
uint32_t grownCapacity;
|
|
uint8_t ****newBuffer;
|
|
uint8_t *pbVar3;
|
|
uint32_t uVar4;
|
|
uint8_t ****ptr;
|
|
uint8_t ****fullAnim [4];
|
|
uint32_t fullAnimSize;
|
|
uint32_t fullAnimCapacity;
|
|
uint32_t local_14;
|
|
void *local_10;
|
|
uint8_t *puStack_c;
|
|
uint8_t ***local_8;
|
|
uint32_t oldCapacity;
|
|
uint32_t oldSize;
|
|
|
|
local_8 = GHIDRA_CAST<uint8_t ***>(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<uint8_t ****>(0x0);
|
|
pbVar3 = animName;
|
|
do {
|
|
bVar1 = *pbVar3;
|
|
pbVar3 = pbVar3 + 1;
|
|
} while (bVar1 != 0);
|
|
(GHIDRA_CAST<msvc::string *>((GHIDRA_CAST<char *>(fullAnim))))->msvc::string::assign(animName,GHIDRA_INT(pbVar3) - GHIDRA_INT((animName + 1)));
|
|
oldCapacity = fullAnimCapacity;
|
|
oldSize = fullAnimSize;
|
|
local_8 = GHIDRA_CAST<uint8_t ***>(0x0);
|
|
if (npc->_i2 != 0) {
|
|
if (fullAnimSize < fullAnimCapacity) {
|
|
ppppbVar2 = GHIDRA_CAST<uint8_t ****>(fullAnim);
|
|
if (0xf < fullAnimCapacity) {
|
|
ppppbVar2 = fullAnim[0];
|
|
}
|
|
pbVar3 = GHIDRA_CAST<uint8_t *>((GHIDRA_INT(ppppbVar2) + fullAnimSize));
|
|
fullAnimSize = fullAnimSize + 1;
|
|
pbVar3[0] = 0x42;
|
|
pbVar3[1] = 0;
|
|
}
|
|
else {
|
|
if (fullAnimSize == 0x7fffffff) {
|
|
/* WARNING: Subroutine does not return */
|
|
msvc::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 = msvc::_Allocate(uVar4 + 1);
|
|
ppppbVar2 = fullAnim[0];
|
|
fullAnimSize = oldSize + 1;
|
|
pbVar3 = GHIDRA_CAST<uint8_t *>((GHIDRA_INT(newBuffer) + oldSize + 1));
|
|
fullAnimCapacity = uVar4;
|
|
if (oldCapacity < 0x10) {
|
|
memcpy(newBuffer,fullAnim,oldSize);
|
|
*GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>(newBuffer) + oldSize)) = 0x42;
|
|
*pbVar3 = 0;
|
|
}
|
|
else {
|
|
memcpy(newBuffer,fullAnim[0],oldSize);
|
|
uVar4 = oldCapacity + 1;
|
|
*GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>(newBuffer) + oldSize)) = 0x42;
|
|
*pbVar3 = 0;
|
|
ptr = ppppbVar2;
|
|
if (0xfff < uVar4) {
|
|
ptr = GHIDRA_CAST<uint8_t ****>(ppppbVar2[-1]);
|
|
uVar4 = oldCapacity + 0x24;
|
|
if (GHIDRA_CAST<uint8_t *>(0x1f) < GHIDRA_CAST<uint8_t *>((GHIDRA_INT(ppppbVar2) + (-4 - GHIDRA_INT(ptr))))) goto LAB_00599b4a;
|
|
}
|
|
operator_delete(ptr,uVar4);
|
|
}
|
|
fullAnim[0] = newBuffer;
|
|
}
|
|
}
|
|
ppppbVar2 = GHIDRA_CAST<uint8_t ****>(fullAnim);
|
|
if (0xf < fullAnimCapacity) {
|
|
ppppbVar2 = fullAnim[0];
|
|
}
|
|
ANM2::Play(&npc->_sprite,GHIDRA_CAST<uint8_t *>(ppppbVar2),0);
|
|
if (0xf < fullAnimCapacity) {
|
|
oldSize = fullAnimCapacity + 1;
|
|
ppppbVar2 = fullAnim[0];
|
|
if (0xfff < oldSize) {
|
|
ppppbVar2 = GHIDRA_CAST<uint8_t ****>(fullAnim[0][-1]);
|
|
oldSize = fullAnimCapacity + 0x24;
|
|
if (GHIDRA_CAST<uint8_t *>(0x1f) < GHIDRA_CAST<uint8_t *>((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)
|
|
{
|
|
uint8_t bVar1;
|
|
uint8_t *****pppppbVar2;
|
|
int prefixCmp;
|
|
uint32_t uVar3;
|
|
uint8_t *****pppppbVar4;
|
|
int extraout_ECX;
|
|
int extraout_ECX_00;
|
|
int extraout_ECX_01;
|
|
int unused;
|
|
char *pcVar5;
|
|
uint8_t ****attackAnimEnd;
|
|
float dy;
|
|
float dx;
|
|
double dVar6;
|
|
int savedFrame;
|
|
uint8_t *****local_2c;
|
|
char *local_28;
|
|
char *local_24;
|
|
char *local_20;
|
|
char *local_1c;
|
|
char *local_18;
|
|
uint32_t local_14;
|
|
void *animData;
|
|
uint8_t ****attackAnim;
|
|
|
|
local_14 = __security_cookie ^ GHIDRA_INT(register0x00000010) - 0x10U;
|
|
local_2c = GHIDRA_CAST<uint8_t *****>(0xb624dc);
|
|
local_28 = "Body1AttackVert";
|
|
local_24 = "Body2AttackHori";
|
|
local_20 = "Body2AttackVert";
|
|
local_1c = "Body3AttackHori";
|
|
local_18 = "Body3AttackVert";
|
|
dx = *GHIDRA_CAST<float *>((npc->_parent + 0x33c)) - (npc->_pos).x;
|
|
dy = *GHIDRA_CAST<float *>((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<uint8_t ****>((&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<uint8_t *****>(0x0);
|
|
local_1c = GHIDRA_CAST<char *>(0x0);
|
|
}
|
|
else {
|
|
(GHIDRA_CAST<msvc::string *>((GHIDRA_CAST<char *>(&local_2c))))->msvc::string::string(animData);
|
|
}
|
|
pppppbVar2 = local_2c;
|
|
attackAnimEnd = attackAnim;
|
|
do {
|
|
bVar1 = *GHIDRA_CAST<uint8_t *>(attackAnimEnd);
|
|
attackAnimEnd = GHIDRA_CAST<uint8_t ****>((GHIDRA_INT(attackAnimEnd) + 1));
|
|
} while (bVar1 != 0);
|
|
pppppbVar4 = GHIDRA_CAST<uint8_t *****>(&local_2c);
|
|
if (GHIDRA_CAST<char *>(0xf) < local_18) {
|
|
pppppbVar4 = local_2c;
|
|
}
|
|
bVar1 = str_eq(GHIDRA_CAST<uint8_t *>(pppppbVar4),GHIDRA_UINT(local_1c),GHIDRA_CAST<uint8_t *>(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<uint8_t *****>(pppppbVar2[-1]);
|
|
pcVar5 = local_18 + 0x24;
|
|
if (GHIDRA_CAST<uint8_t *>(0x1f) < GHIDRA_CAST<uint8_t *>((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<uint8_t *****>(0x0);
|
|
local_18 = GHIDRA_CAST<char *>(0xf);
|
|
local_1c = GHIDRA_CAST<char *>(0x0);
|
|
}
|
|
else {
|
|
(GHIDRA_CAST<msvc::string *>((GHIDRA_CAST<char *>(&local_2c))))->msvc::string::string(animData);
|
|
}
|
|
pppppbVar2 = GHIDRA_CAST<uint8_t *****>(&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<uint8_t *****>(local_2c[-1]);
|
|
pcVar5 = local_18 + 0x24;
|
|
if (GHIDRA_CAST<uint8_t *>(0x1f) < GHIDRA_CAST<uint8_t *>((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<uint8_t *>(attackAnim),unused);
|
|
if ((npc->_sprite)._animState._animData != (void *)0x0) {
|
|
AnimationState::SetFrameFloat(&(npc->_sprite)._animState,(float)savedFrame);
|
|
return;
|
|
}
|
|
}
|
|
else {
|
|
tuff_twins_play_anim(npc,GHIDRA_CAST<uint8_t *>(attackAnim),unused);
|
|
}
|
|
}
|
|
return;
|
|
}
|
|
|
|
// 0059e2a0
|
|
void NpcHelper::UltraGreed_Heal(Entity_NPC *npc, int amount)
|
|
{
|
|
int healStacks;
|
|
float newHealth;
|
|
float fVar1;
|
|
uint32_t healColor;
|
|
uint32_t uStack_30;
|
|
uint32_t uStack_2c;
|
|
uint32_t uStack_28;
|
|
uint32_t local_24;
|
|
uint32_t uStack_20;
|
|
uint32_t uStack_1c;
|
|
uint32_t uStack_18;
|
|
float flashIntensity;
|
|
float local_10;
|
|
float local_c;
|
|
uint32_t local_8;
|
|
|
|
local_8 = __security_cookie ^ GHIDRA_INT(register0x00000010) - 4U;
|
|
npc->_i2 = npc->_i2 + amount;
|
|
healStacks = npc->_i2;
|
|
if (0x19 < healStacks) {
|
|
healStacks = 0x19;
|
|
}
|
|
npc->_i2 = healStacks;
|
|
fVar1 = npc->_maxHitPoints;
|
|
newHealth = fVar1 * 0.00125 * (float)amount + npc->_health;
|
|
npc->_health = newHealth;
|
|
if (fVar1 < newHealth) {
|
|
npc->_health = fVar1;
|
|
}
|
|
fVar1 = (float)amount / 3.0;
|
|
healStacks = amount * 4;
|
|
if (0xf < healStacks) {
|
|
healStacks = 0xf;
|
|
}
|
|
flashIntensity = 1.0;
|
|
if (fVar1 <= 1.0) {
|
|
flashIntensity = fVar1;
|
|
}
|
|
healColor = 0x3f800000;
|
|
uStack_30 = 0x3f800000;
|
|
uStack_2c = 0x3f800000;
|
|
uStack_28 = 0x3f800000;
|
|
local_24 = 0;
|
|
uStack_20 = 0;
|
|
uStack_1c = 0;
|
|
uStack_18 = 0;
|
|
local_10 = flashIntensity * 0.84;
|
|
local_c = flashIntensity * 0.0;
|
|
(**(code **)(*GHIDRA_CAST<int *>(npc) + 0x3c))(&healColor,healStacks,0xff,1,1);
|
|
return;
|
|
}
|
|
|
|
// 0059e630
|
|
Entity_NPC * NpcHelper::UltraDoor_Opposite(Entity_NPC *door, EntityList_EL doors)
|
|
{
|
|
uint32_t uVar1;
|
|
Entity_NPC *oppositeDoor;
|
|
uint64_t *heapAllocatedBytes;
|
|
int oppositeSlot;
|
|
uint32_t entityIdx;
|
|
int oppositeSlots [9];
|
|
void *local_10;
|
|
uint8_t *puStack_c;
|
|
int local_8;
|
|
uint64_t oldAllocatedBytes;
|
|
|
|
puStack_c = &LAB_00af57bd;
|
|
local_10 = ExceptionList;
|
|
uVar1 = __security_cookie ^ GHIDRA_UINT((oppositeSlots + 0xc));
|
|
ExceptionList = &local_10;
|
|
local_8 = 0;
|
|
oppositeSlots[8] = uVar1;
|
|
if (door != GHIDRA_CAST<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<uint32_t *>(((*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(doors)) + 0x4))) + 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<uint8_t *>((GHIDRA_CAST<char *>(&(doors)) + 0x0))) == '\0') {
|
|
if (g_mainHeap == (void *)0x0) {
|
|
heapAllocatedBytes = &g_allocatedBytesNoHeap;
|
|
}
|
|
else {
|
|
heapAllocatedBytes = GHIDRA_CAST<uint64_t *>((GHIDRA_INT(g_mainHeap) + 0x30));
|
|
}
|
|
if ((*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(doors)) + 0x4))) != 0) {
|
|
uVar1 = *GHIDRA_CAST<uint32_t *>(((*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(doors)) + 0x4))) + -4));
|
|
oldAllocatedBytes = *heapAllocatedBytes;
|
|
*GHIDRA_CAST<uint32_t *>(heapAllocatedBytes) = GHIDRA_UINT(*heapAllocatedBytes) - uVar1;
|
|
*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(heapAllocatedBytes) + 4)) =
|
|
*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(heapAllocatedBytes) + 4)) - GHIDRA_UINT((GHIDRA_UINT(oldAllocatedBytes) < uVar1));
|
|
free((void *)((*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(doors)) + 0x4))) + -4));
|
|
}
|
|
}
|
|
ExceptionList = local_10;
|
|
return oppositeDoor;
|
|
}
|
|
|
|
// 0059e730
|
|
void NpcHelper::UltraGreed_Smash(Entity_NPC *npc, Vector position)
|
|
{
|
|
int iVar1;
|
|
RNG rng;
|
|
EntityList_EL doors;
|
|
EntityList_EL doors_00;
|
|
EntityList_EL doors_01;
|
|
uint64_t qVar2;
|
|
uint32_t uVar3;
|
|
Entity_NPC *oppositeDoor;
|
|
Entity_NPC *randomDoor;
|
|
uint32_t outcomeCount;
|
|
Game *game;
|
|
uint64_t *allocCounter;
|
|
uint32_t uVar4;
|
|
EntityList_EL ultraDoors;
|
|
void *picker;
|
|
uint32_t *pickerEnd;
|
|
uint32_t *pickerCapacity;
|
|
Entity_NPC *boss;
|
|
uint32_t pickSeed;
|
|
uint64_t uStack_8c;
|
|
Entity_NPC *pEStack_84;
|
|
float local_80;
|
|
ColorMod particleColor;
|
|
ColorMod explosionColor;
|
|
uint32_t local_24;
|
|
uint8_t *puStack_20;
|
|
void *local_1c;
|
|
uint8_t *puStack_18;
|
|
float local_14;
|
|
Manager *manager;
|
|
int *outcomeWeight;
|
|
void *room;
|
|
|
|
puStack_20 = GHIDRA_CAST<uint8_t *>((&explosionColor)[1]._offset);
|
|
local_14 = -NAN;
|
|
puStack_18 = &LAB_00af580b;
|
|
local_1c = ExceptionList;
|
|
local_24 = __security_cookie ^ GHIDRA_UINT(((&explosionColor)[1]._colorize + 1));
|
|
ExceptionList = &local_1c;
|
|
boss = npc;
|
|
Entity_NPC::CreateGoldParticles(npc,0x1e);
|
|
manager = g_manager;
|
|
local_80 = 1.93379e-43;
|
|
seed_fart_sound_override(GHIDRA_CAST<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<uint32_t *>((GHIDRA_CAST<char *>(room) + 0x70fc)) & 0x80000001;
|
|
if (GHIDRA_INT(uVar3) < 0) {
|
|
uVar3 = (uVar3 - 1 | 0xfffffffe) + 1;
|
|
}
|
|
if (1 < uVar3) {
|
|
KAGE_LogMessage(0x10,GHIDRA_CAST<uint8_t *>("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<uint32_t *>((GHIDRA_CAST<char *>(room) + iVar1 * 0x1c + 8)) = 0;
|
|
*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(room) + iVar1 * 0x1c + 0xc)) = 0x3ccccccd;
|
|
*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(room) + iVar1 * 0x1c + 0x10)) = 0x3ccccccd;
|
|
*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(room) + iVar1 * 0x1c + 0x14)) = 0;
|
|
*GHIDRA_CAST<uint32_t *>((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 = (void *)0x0;
|
|
pickerEnd = GHIDRA_CAST<uint32_t *>(0x0);
|
|
pickerCapacity = GHIDRA_CAST<uint32_t *>(0x0);
|
|
local_14 = 1.4013e-45;
|
|
uStack_8c = uStack_8c & 0xffffffff;
|
|
pEStack_84 = GHIDRA_CAST<Entity_NPC *>(0x64);
|
|
msvc::vector<8byte>::_Emplace_reallocate(0,GHIDRA_INT(&uStack_8c) + 4);
|
|
uVar3 = 0;
|
|
outcomeCount = GHIDRA_INT(pickerEnd) - GHIDRA_INT(picker) >> 3;
|
|
if (outcomeCount != 0) {
|
|
do {
|
|
if (*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(picker) + uVar3 * 8)) == 1) {
|
|
outcomeWeight = GHIDRA_CAST<int *>((GHIDRA_INT(picker) + uVar3 * 8 + 4));
|
|
*outcomeWeight = *outcomeWeight + 0x46;
|
|
if (*outcomeWeight < 0) {
|
|
*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(picker) + uVar3 * 8 + 4)) = 0;
|
|
}
|
|
goto LAB_0059eaaa;
|
|
}
|
|
uVar3 = uVar3 + 1;
|
|
} while (uVar3 < outcomeCount);
|
|
}
|
|
uStack_8c = CONCAT44(1,(uint32_t)uStack_8c);
|
|
pEStack_84 = GHIDRA_CAST<Entity_NPC *>(0x46);
|
|
if (pickerEnd == pickerCapacity) {
|
|
msvc::vector<8byte>::_Emplace_reallocate(pickerEnd,GHIDRA_INT(&uStack_8c) + 4);
|
|
}
|
|
else {
|
|
*pickerEnd = 1;
|
|
pickerEnd[1] = 0x46;
|
|
pickerEnd = pickerEnd + 2;
|
|
}
|
|
LAB_0059eaaa:
|
|
pickSeed = Random();
|
|
pickSeed = pickSeed | 1;
|
|
uStack_8c = 0x900000005;
|
|
pEStack_84 = GHIDRA_CAST<Entity_NPC *>(&DAT_00000007);
|
|
rng._shift1 = 5;
|
|
rng._seed = pickSeed;
|
|
rng._shift2 = 9;
|
|
rng._shift3 = 7;
|
|
uVar3 = (GHIDRA_CAST<WeightedOutcomePicker *>((GHIDRA_CAST<WeightedOutcomePicker *>(&picker))))->WeightedOutcomePicker::PickOutcome(rng);
|
|
if ((uVar3 == 0) || (boss->_state == 0x10)) {
|
|
Game::ShakeScreen(g_game,0xd);
|
|
if ((float)ultraDoors._size != 0.0) {
|
|
uVar3 = Random();
|
|
local_80 = (float)(uVar3 % GHIDRA_UINT(ultraDoors._size) + 1);
|
|
if (0 < GHIDRA_INT(local_80)) {
|
|
do {
|
|
uVar3 = Random();
|
|
uVar4 = 0;
|
|
randomDoor = (Entity_NPC *)
|
|
__RTDynamicCast(*(uint32_t *)
|
|
((*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(ultraDoors)) + 0x4))) + (uVar3 % GHIDRA_UINT(ultraDoors._size)) * 4),
|
|
0,&IsaacRepentancePlus::Entity::RTTI_Type_Descriptor,
|
|
&IsaacRepentancePlus::Entity_NPC::RTTI_Type_Descriptor,0);
|
|
(*GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>(&(doors_00)) + 0x1))) = (int3)(GHIDRA_UINT(uVar4) >> 8);
|
|
(*GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>(&(doors_00)) + 0x0))) = 1;
|
|
(*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(doors_00)) + 0x4))) = (*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(ultraDoors)) + 0x4)));
|
|
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) && (Game::ShakeScreen(g_game,0x12), (float)ultraDoors._size != 0.0)) {
|
|
local_80 = (float)ultraDoors._size;
|
|
do {
|
|
if ((float)ultraDoors._size == 0.0) {
|
|
uVar3 = 0;
|
|
}
|
|
else {
|
|
uVar3 = Random();
|
|
uVar3 = uVar3 % GHIDRA_UINT(ultraDoors._size);
|
|
}
|
|
uVar4 = 0;
|
|
randomDoor = (Entity_NPC *)
|
|
__RTDynamicCast(*GHIDRA_CAST<uint32_t *>(((*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(ultraDoors)) + 0x4))) + uVar3 * 4)),0,
|
|
&IsaacRepentancePlus::Entity::RTTI_Type_Descriptor,
|
|
&IsaacRepentancePlus::Entity_NPC::RTTI_Type_Descriptor,0);
|
|
(*GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>(&(doors)) + 0x1))) = (int3)(GHIDRA_UINT(uVar4) >> 8);
|
|
(*GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>(&(doors)) + 0x0))) = 1;
|
|
(*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(doors)) + 0x4))) = (*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(ultraDoors)) + 0x4)));
|
|
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 != (void *)0x0) {
|
|
uVar3 = (GHIDRA_INT(pickerCapacity) - GHIDRA_INT(picker) >> 3) * 8;
|
|
room = picker;
|
|
if (0xfff < uVar3) {
|
|
room = *(void **)(GHIDRA_CAST<char *>(picker) + -4);
|
|
uVar3 = uVar3 + 0x23;
|
|
if (0x1f < GHIDRA_UINT((GHIDRA_INT(picker) + (-4 - GHIDRA_INT(room))))) {
|
|
/* WARNING: Subroutine does not return */
|
|
_invalid_parameter_noinfo_noreturn();
|
|
}
|
|
}
|
|
operator_delete(room,uVar3);
|
|
}
|
|
}
|
|
if ((boss->_state == 0x2c6) && (Game::ShakeScreen(g_game,10), (float)ultraDoors._size != 0.0)) {
|
|
uVar3 = Random();
|
|
uVar4 = 0;
|
|
randomDoor = (Entity_NPC *)
|
|
__RTDynamicCast(*(uint32_t *)
|
|
((*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(ultraDoors)) + 0x4))) + (uVar3 % GHIDRA_UINT(ultraDoors._size)) * 4),0,
|
|
&IsaacRepentancePlus::Entity::RTTI_Type_Descriptor,
|
|
&IsaacRepentancePlus::Entity_NPC::RTTI_Type_Descriptor,0);
|
|
(*GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>(&(doors_01)) + 0x1))) = (int3)(GHIDRA_UINT(uVar4) >> 8);
|
|
(*GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>(&(doors_01)) + 0x0))) = 1;
|
|
(*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(doors_01)) + 0x4))) = (*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(ultraDoors)) + 0x4)));
|
|
doors_01._capacity = ultraDoors._capacity;
|
|
doors_01._size = ultraDoors._size;
|
|
pEStack_84 = randomDoor;
|
|
oppositeDoor = UltraDoor_Opposite(randomDoor,doors_01);
|
|
if (randomDoor != GHIDRA_CAST<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<uint8_t *>((GHIDRA_CAST<char *>(&(ultraDoors)) + 0x0))) == '\0') {
|
|
if (g_mainHeap == (void *)0x0) {
|
|
allocCounter = &g_allocatedBytesNoHeap;
|
|
}
|
|
else {
|
|
allocCounter = GHIDRA_CAST<uint64_t *>((GHIDRA_INT(g_mainHeap) + 0x30));
|
|
}
|
|
if ((*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(ultraDoors)) + 0x4))) != 0) {
|
|
uVar3 = *GHIDRA_CAST<uint32_t *>(((*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(ultraDoors)) + 0x4))) + -4));
|
|
qVar2 = *allocCounter;
|
|
*GHIDRA_CAST<uint32_t *>(allocCounter) = GHIDRA_UINT(*allocCounter) - uVar3;
|
|
*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(allocCounter) + 4)) =
|
|
*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(allocCounter) + 4)) - GHIDRA_UINT((GHIDRA_UINT(qVar2) < uVar3));
|
|
free((void *)((*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(ultraDoors)) + 0x4))) + -4));
|
|
}
|
|
}
|
|
ExceptionList = local_1c;
|
|
return;
|
|
}
|
|
|
|
// 005a7010
|
|
void NpcHelper::visage_spawn_particles(Vector *position, Vector *direction)
|
|
{
|
|
int iVar1;
|
|
uint32_t rngResult;
|
|
uint32_t rngValue;
|
|
Entity *particle;
|
|
int iVar2;
|
|
int particlesLeft;
|
|
float cosQuarterTurn;
|
|
float sinQuarterTurn;
|
|
float sideDirX;
|
|
float sideDirY;
|
|
float fVar5;
|
|
uint8_t *spinSign;
|
|
float fVar6;
|
|
Vector local_18;
|
|
Vector spawnPos;
|
|
float dirX;
|
|
float dirY;
|
|
float sideDirX;
|
|
float sideDirY;
|
|
|
|
rngResult = Random();
|
|
cosQuarterTurn = cos(1.5707964);
|
|
sinQuarterTurn = sin(1.5707964);
|
|
dirX = direction->x;
|
|
dirY = direction->y;
|
|
for (particlesLeft = (rngResult & 3) + 5; particlesLeft != 0; particlesLeft = particlesLeft + -1)
|
|
{
|
|
rngResult = Random();
|
|
rngValue = Random();
|
|
sideDirX = (float)((double)GHIDRA_INT(rngValue) + __uint_to_double_fixup[-(GHIDRA_INT(rngValue) >> 0x1f)]) *
|
|
2.3283064e-10;
|
|
sideDirY = direction->x;
|
|
fVar5 = direction->y;
|
|
rngValue = Random();
|
|
fVar6 = (float)((double)GHIDRA_INT(rngValue) + __uint_to_double_fixup[-(GHIDRA_INT(rngValue) >> 0x1f)]) *
|
|
2.3283064e-10;
|
|
fVar6 = (fVar6 + fVar6) - 1.0;
|
|
local_18.y = sideDirX * fVar5 * 5.0 + fVar6 * (dirY * cosQuarterTurn + dirX * sinQuarterTurn);
|
|
local_18.x = sideDirX * sideDirY * 5.0 + fVar6 * (dirX * cosQuarterTurn - dirY * sinQuarterTurn);
|
|
rngValue = Random();
|
|
sideDirY = (float)((double)GHIDRA_INT(rngValue) + __uint_to_double_fixup[-(GHIDRA_INT(rngValue) >> 0x1f)]) *
|
|
2.3283064e-10 * 3.14;
|
|
sideDirY = sideDirY + sideDirY;
|
|
rngValue = Random();
|
|
fVar5 = (float)((double)GHIDRA_INT(rngValue) + __uint_to_double_fixup[-(GHIDRA_INT(rngValue) >> 0x1f)]) *
|
|
2.3283064e-10;
|
|
sideDirX = cos(sideDirY);
|
|
spawnPos.x = sideDirX * fVar5 * 20.0 + position->x;
|
|
sideDirY = sin(sideDirY);
|
|
spawnPos.y = sideDirY * fVar5 * 20.0 + position->y;
|
|
particle = Game::SpawnEx(g_game,1000,0x3b,&spawnPos,&local_18,GHIDRA_CAST<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<uint8_t *>(0x3f800000);
|
|
}
|
|
else {
|
|
spinSign = &DAT_bf800000;
|
|
}
|
|
*GHIDRA_CAST<uint8_t **>((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)
|
|
{
|
|
uint32_t uVar1;
|
|
int iVar2;
|
|
uint32_t subType;
|
|
uint32_t seed;
|
|
Entity_NPC *pEVar3;
|
|
uint32_t *puVar4;
|
|
uint32_t *linkIter;
|
|
uint32_t *linksEnd;
|
|
Entity_NPC *local_28;
|
|
int *local_24;
|
|
Vector *spawnPos;
|
|
uint32_t linkIndex;
|
|
uint32_t *linksCapacityEnd;
|
|
Entity_NPC *visage;
|
|
void *local_10;
|
|
uint8_t *puStack_c;
|
|
uint32_t local_8;
|
|
|
|
puStack_c = &LAB_00af597d;
|
|
local_10 = ExceptionList;
|
|
ExceptionList = &local_10;
|
|
linkIter = GHIDRA_CAST<uint32_t *>(0x0);
|
|
linksCapacityEnd = GHIDRA_CAST<uint32_t *>(0x0);
|
|
linksEnd = GHIDRA_CAST<uint32_t *>(0x0);
|
|
local_8 = 0;
|
|
spawnPos = &npc->_pos;
|
|
linkIndex = 0;
|
|
visage = npc;
|
|
do {
|
|
subType = linkIndex;
|
|
seed = Random();
|
|
pEVar3 = (Entity_NPC *)
|
|
Game::Spawn(g_game,0x387,10,spawnPos,&g_vectorZero,GHIDRA_CAST<Entity *>(visage),subType,seed);
|
|
uVar1 = *GHIDRA_CAST<uint32_t *>((GHIDRA_INT(&pEVar3->_flags) + 4));
|
|
*GHIDRA_CAST<uint32_t *>(&pEVar3->_flags) = GHIDRA_UINT(pEVar3->_flags) & 0xfffffffb;
|
|
*GHIDRA_CAST<uint32_t *>((GHIDRA_INT(&pEVar3->_flags) + 4)) = uVar1;
|
|
local_28 = pEVar3;
|
|
if (pEVar3->_parent != 0) {
|
|
local_24 = &pEVar3->_parent;
|
|
msvc::multiset<unsigned_int>::erase(&local_24);
|
|
}
|
|
pEVar3->_parent = npc;
|
|
if (npc != GHIDRA_CAST<Entity_NPC *>(0x0)) {
|
|
msvc::multiset<unsigned_int>::insert(&pEVar3->_parent);
|
|
}
|
|
if (npc->_variant == 10) {
|
|
puVar4 = &npc->_child;
|
|
if (npc->_child != 0) {
|
|
local_24 = puVar4;
|
|
msvc::multiset<unsigned_int>::erase(&local_24);
|
|
}
|
|
*puVar4 = pEVar3;
|
|
msvc::multiset<unsigned_int>::insert(puVar4);
|
|
}
|
|
if (linksEnd == linksCapacityEnd) {
|
|
msvc::vector<4byte>::_Emplace_reallocate(linksEnd,&local_28);
|
|
linksCapacityEnd = GHIDRA_CAST<uint32_t *>(0x0);
|
|
}
|
|
else {
|
|
*linksEnd = pEVar3;
|
|
linksEnd = linksEnd + 1;
|
|
}
|
|
linkIndex = linkIndex + 1;
|
|
npc = pEVar3;
|
|
} while (GHIDRA_INT(linkIndex) < 0x28);
|
|
local_24 = GHIDRA_CAST<int *>(linksEnd[-1]);
|
|
puVar4 = &visage->_entityRef;
|
|
if (*puVar4 != 0) {
|
|
local_28 = GHIDRA_CAST<Entity_NPC *>(puVar4);
|
|
msvc::multiset<unsigned_int>::erase(&local_28);
|
|
}
|
|
*puVar4 = local_24;
|
|
if (local_24 != GHIDRA_CAST<int *>(0x0)) {
|
|
msvc::multiset<unsigned_int>::insert(puVar4);
|
|
}
|
|
puVar4 = &pEVar3->_child;
|
|
iVar2 = visage->_child;
|
|
if (*puVar4 != 0) {
|
|
local_28 = GHIDRA_CAST<Entity_NPC *>(puVar4);
|
|
msvc::multiset<unsigned_int>::erase(&local_28);
|
|
}
|
|
*puVar4 = iVar2;
|
|
if (iVar2 != 0) {
|
|
msvc::multiset<unsigned_int>::insert(puVar4);
|
|
}
|
|
if (linksEnd != GHIDRA_CAST<uint32_t *>(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<uint32_t *>((iVar1 + 0x48))) {
|
|
case 4:
|
|
case 6:
|
|
return 6;
|
|
case 8:
|
|
case 9:
|
|
case 10:
|
|
case 0xb:
|
|
case 0xc:
|
|
return 8;
|
|
}
|
|
}
|
|
return 4;
|
|
}
|
|
|
|
// 005a7590
|
|
float NpcHelper::visage_score_position(Entity_NPC *npc, Vector *position)
|
|
{
|
|
int iVar1;
|
|
Entity *pEVar2;
|
|
float fVar3;
|
|
float fVar4;
|
|
float fVar5;
|
|
float fVar6;
|
|
float fVar7;
|
|
float targetDistSq;
|
|
float local_1c;
|
|
float local_18;
|
|
|
|
pEVar2 = Entity_NPC::GetPlayerTarget(npc);
|
|
iVar1 = npc->_child;
|
|
if (iVar1 == 0) {
|
|
fVar3 = (pEVar2->_pos).y - position->y;
|
|
fVar5 = (pEVar2->_pos).targetDistSq - position->targetDistSq;
|
|
fVar3 = sqrtf(fVar3 * fVar3 + fVar5 * fVar5);
|
|
return 0.0 - ABS(fVar3 - 120.0);
|
|
}
|
|
if (GHIDRA_UINT(npc->_state) < 0x71) {
|
|
local_1c = *GHIDRA_CAST<float *>((iVar1 + 0x340)) - position->y;
|
|
local_18 = *GHIDRA_CAST<float *>((iVar1 + 0x33c)) - position->targetDistSq;
|
|
fVar5 = local_1c * local_1c + local_18 * local_18;
|
|
fVar3 = sqrtf(fVar5);
|
|
fVar5 = sqrtf(fVar5);
|
|
if (0.0 < fVar5) {
|
|
local_18 = local_18 * (1.0 / fVar5);
|
|
local_1c = local_1c * (1.0 / fVar5);
|
|
}
|
|
fVar5 = (pEVar2->_pos).y - position->y;
|
|
fVar7 = (pEVar2->_pos).targetDistSq - position->targetDistSq;
|
|
targetDistSq = fVar5 * fVar5 + fVar7 * fVar7;
|
|
fVar6 = sqrtf(targetDistSq);
|
|
if (0.0 < fVar6) {
|
|
fVar7 = fVar7 * (1.0 / fVar6);
|
|
fVar5 = fVar5 * (1.0 / fVar6);
|
|
}
|
|
fVar6 = (npc->_pos).targetDistSq - position->targetDistSq;
|
|
fVar4 = (npc->_pos).y - position->y;
|
|
targetDistSq = sqrtf(targetDistSq);
|
|
fVar6 = sqrtf(fVar4 * fVar4 + fVar6 * fVar6);
|
|
return fVar6 * 1.2 +
|
|
(((fVar5 * local_1c + fVar7 * local_18) * 300.0 + fVar3 * 0.5 + 0.0) -
|
|
ABS(targetDistSq - 120.0));
|
|
}
|
|
local_18 = *GHIDRA_CAST<float *>((iVar1 + 0x340)) - position->y;
|
|
local_1c = *GHIDRA_CAST<float *>((iVar1 + 0x33c)) - position->targetDistSq;
|
|
fVar5 = local_18 * local_18 + local_1c * local_1c;
|
|
fVar3 = sqrtf(fVar5);
|
|
fVar5 = sqrtf(fVar5);
|
|
if (0.0 < fVar5) {
|
|
local_1c = local_1c * (1.0 / fVar5);
|
|
local_18 = local_18 * (1.0 / fVar5);
|
|
}
|
|
fVar7 = (pEVar2->_pos).targetDistSq - position->targetDistSq;
|
|
fVar6 = (pEVar2->_pos).y - position->y;
|
|
targetDistSq = fVar6 * fVar6 + fVar7 * fVar7;
|
|
fVar5 = sqrtf(targetDistSq);
|
|
if (0.0 < fVar5) {
|
|
fVar7 = fVar7 * (1.0 / fVar5);
|
|
fVar6 = fVar6 * (1.0 / fVar5);
|
|
}
|
|
fVar5 = sqrtf(targetDistSq);
|
|
return ((fVar6 * local_18 + fVar7 * local_1c) * 0.2 * 300.0 + fVar3 * 0.25 + 0.0) -
|
|
ABS(fVar5 - 120.0);
|
|
}
|
|
|
|
// 005a7920
|
|
void NpcHelper::visage_pick_target_position(Entity_NPC *npc)
|
|
{
|
|
uint32_t rngResult;
|
|
int triesLeft;
|
|
float fVar1;
|
|
float fVar2;
|
|
float candidateX;
|
|
float bestScore;
|
|
Vector candidatePos;
|
|
Vector clampedPos;
|
|
Room *room;
|
|
|
|
(npc->_targetPosition).x = (npc->_pos).x;
|
|
(npc->_targetPosition).y = (npc->_pos).y;
|
|
bestScore = visage_score_position(npc,&npc->_pos);
|
|
triesLeft = 0x14;
|
|
do {
|
|
rngResult = Random();
|
|
fVar1 = (float)((double)GHIDRA_INT(rngResult) + __uint_to_double_fixup[-(GHIDRA_INT(rngResult) >> 0x1f)]) *
|
|
2.3283064e-10 * 3.14;
|
|
fVar1 = fVar1 + fVar1;
|
|
rngResult = Random();
|
|
fVar2 = (float)((double)GHIDRA_INT(rngResult) + __uint_to_double_fixup[-(GHIDRA_INT(rngResult) >> 0x1f)]) *
|
|
2.3283064e-10 * 100.0;
|
|
candidateX = cos(fVar1);
|
|
candidateX = candidateX * fVar2 + (npc->_pos).x;
|
|
candidatePos.x = candidateX;
|
|
fVar1 = sin(fVar1);
|
|
room = g_game->_room;
|
|
fVar1 = fVar1 * fVar2 + (npc->_pos).y;
|
|
candidatePos.y = fVar1;
|
|
if (*GHIDRA_CAST<int *>((*GHIDRA_CAST<int *>((*GHIDRA_CAST<int *>(&(*GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>((room)) + 0x4)))) + 0x10)) + 0x48)) - 9U < 4) {
|
|
Room::GetClampedPositionImpl(room,&clampedPos,&candidatePos,10.0,10.0,10.0,10.0);
|
|
if ((clampedPos.x == candidateX) && (clampedPos.y == fVar1)) {
|
|
LAB_005a7ace:
|
|
fVar2 = visage_score_position(npc,&candidatePos);
|
|
if (bestScore < fVar2) {
|
|
(npc->_targetPosition).x = candidateX;
|
|
(npc->_targetPosition).y = fVar1;
|
|
bestScore = fVar2;
|
|
}
|
|
}
|
|
}
|
|
else if (((((room->_topLeftPos).x + 10.0 <= candidateX) &&
|
|
(candidateX <= (room->_bottomRightPos).x - 10.0)) &&
|
|
((room->_topLeftPos).y + 10.0 <= fVar1)) && (fVar1 <= (room->_bottomRightPos).y - 10.0)
|
|
) goto LAB_005a7ace;
|
|
triesLeft = triesLeft + -1;
|
|
if (triesLeft == 0) {
|
|
return;
|
|
}
|
|
} while( true );
|
|
}
|
|
|
|
// 005ab180
|
|
void NpcHelper::visage_start_charge(Entity_NPC *npc)
|
|
{
|
|
uint8_t bVar1;
|
|
Vector *pVVar2;
|
|
uint8_t *curAnimChar;
|
|
uint32_t animCompare;
|
|
Entity_Laser *laser;
|
|
uint8_t *newAnimChar;
|
|
bool isLess;
|
|
float fVar3;
|
|
int iVar4;
|
|
Entity_NPC *source;
|
|
Vector local_18;
|
|
Vector VStack_10;
|
|
uint8_t *animData;
|
|
uint32_t flagsHigh;
|
|
Manager *manager;
|
|
|
|
if (npc->_state == 0x6d) {
|
|
flagsHigh = *GHIDRA_CAST<uint32_t *>((GHIDRA_INT(&npc->_flags) + 4));
|
|
*GHIDRA_CAST<uint32_t *>(&npc->_flags) = GHIDRA_UINT(npc->_flags) & 0xffffffee;
|
|
iVar4 = *GHIDRA_CAST<int *>(npc);
|
|
*GHIDRA_CAST<uint32_t *>((GHIDRA_INT(&npc->_flags) + 4)) = flagsHigh;
|
|
npc->_health = npc->_maxHitPoints;
|
|
npc->_isInvicible = 0;
|
|
(**(code **)(iVar4 + 0x40))(*GHIDRA_CAST<uint32_t *>((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<uint8_t *>("Charge2Loop%s"));
|
|
animData = (npc->_sprite)._animState._animData;
|
|
if (animData != GHIDRA_CAST<uint8_t *>(0x0)) {
|
|
curAnimChar = animData;
|
|
if (0xf < *GHIDRA_CAST<uint32_t *>((animData + 0x14))) {
|
|
curAnimChar = *GHIDRA_CAST<uint8_t **>(animData);
|
|
}
|
|
newAnimChar = &DAT_00c7f858;
|
|
do {
|
|
bVar1 = *curAnimChar;
|
|
isLess = bVar1 < *newAnimChar;
|
|
if (bVar1 != *newAnimChar) {
|
|
LAB_005ab300:
|
|
animCompare = -GHIDRA_UINT(isLess) | 1;
|
|
goto LAB_005ab305;
|
|
}
|
|
if (bVar1 == 0) break;
|
|
bVar1 = curAnimChar[1];
|
|
isLess = bVar1 < newAnimChar[1];
|
|
if (bVar1 != newAnimChar[1]) goto LAB_005ab300;
|
|
curAnimChar = curAnimChar + 2;
|
|
newAnimChar = newAnimChar + 2;
|
|
} while (bVar1 != 0);
|
|
animCompare = 0;
|
|
LAB_005ab305:
|
|
if ((animCompare == 0) && ((animData[0x34] == 0 || ((npc->_sprite)._animState._isPlaying != 0)))
|
|
) goto LAB_005ab33c;
|
|
}
|
|
bVar1 = ANM2::SetAnimation(&npc->_sprite,&DAT_00c7f858,1);
|
|
if (bVar1 != 0) {
|
|
AnimationState::Rewind(&(npc->_sprite)._animState);
|
|
(npc->_sprite)._animState._isPlaying = 1;
|
|
}
|
|
LAB_005ab33c:
|
|
npc->_state = 0x6e;
|
|
pVVar2 = &local_18;
|
|
VStack_10.x = (npc->_targetPosition).y * -1.0;
|
|
bVar1 = 0;
|
|
iVar4 = 0x14;
|
|
local_18.x = 0.0;
|
|
local_18.y = -40.0;
|
|
source = npc;
|
|
fVar3 = atan2f(VStack_10.x,(npc->_targetPosition).x * -1.0);
|
|
laser = Entity_Laser::ShootAngle
|
|
(1,&npc->_pos,fVar3 * 57.295776,iVar4,pVVar2,GHIDRA_CAST<Entity *>(source),bVar1);
|
|
fVar3 = 0.0;
|
|
if (0.0 <= VStack_10.x) {
|
|
fVar3 = 1000.0;
|
|
}
|
|
laser->_renderDepthOffset = fVar3;
|
|
(**(code **)(*GHIDRA_CAST<int *>(laser) + 0xc))();
|
|
return;
|
|
}
|
|
|
|
// 005acd30
|
|
void NpcHelper::visage_chain_solve(Entity_NPC *npc, uint8_t isInterpolate)
|
|
{
|
|
Vector *pVVar1;
|
|
Entity_NPC *pEVar2;
|
|
int iVar3;
|
|
Entity_NPC *pEVar4;
|
|
uint8_t isFlipX;
|
|
uint32_t uVar5;
|
|
Vector *normalized;
|
|
Entity_NPC *pEVar6;
|
|
Entity_NPC *pEVar7;
|
|
float fVar8;
|
|
float angleDeg;
|
|
Vector local_2c;
|
|
float headY;
|
|
float headX;
|
|
Vector normDir;
|
|
float dirX;
|
|
float anchorY;
|
|
float anchorX;
|
|
int *parentSlot;
|
|
int *state;
|
|
|
|
pEVar2 = GHIDRA_CAST<Entity_NPC *>(npc->_child);
|
|
if (((pEVar2 == GHIDRA_CAST<Entity_NPC *>(0x0)) || (pEVar2->_type != 0x387)) || (pEVar2->_variant != 10)) {
|
|
parentSlot = &npc->_parent;
|
|
pEVar7 = GHIDRA_CAST<Entity_NPC *>(npc->_parent);
|
|
pEVar6 = npc;
|
|
while (pEVar4 = pEVar7, pEVar4 != GHIDRA_CAST<Entity_NPC *>(0x0)) {
|
|
pEVar6 = pEVar4;
|
|
pEVar7 = GHIDRA_CAST<Entity_NPC *>(pEVar4->_parent);
|
|
}
|
|
pEVar7 = npc;
|
|
if ((pEVar6->_type != 0x387) || (pEVar6->_variant != 0)) {
|
|
pEVar6 = GHIDRA_CAST<Entity_NPC *>(0x0);
|
|
}
|
|
while (pEVar4 = pEVar2, pEVar4 != GHIDRA_CAST<Entity_NPC *>(0x0)) {
|
|
pEVar7 = pEVar4;
|
|
pEVar2 = GHIDRA_CAST<Entity_NPC *>(pEVar4->_child);
|
|
}
|
|
if (((pEVar7 == GHIDRA_CAST<Entity_NPC *>(0x0)) || (pEVar7->_type != 0x387)) || (pEVar7->_variant != 1)) {
|
|
pEVar7 = GHIDRA_CAST<Entity_NPC *>(0x0);
|
|
}
|
|
if (pEVar6 != GHIDRA_CAST<Entity_NPC *>(0x0)) {
|
|
pVVar1 = &pEVar6->_pos;
|
|
headX = pVVar1->x;
|
|
state = &npc->_state;
|
|
headY = (pEVar6->_pos).y;
|
|
if (npc->_state == 3) {
|
|
if (pEVar7 == GHIDRA_CAST<Entity_NPC *>(0x0)) {
|
|
return;
|
|
}
|
|
normalized = &pEVar7->_pos;
|
|
anchorX = normalized->x;
|
|
anchorY = (pEVar7->_pos).y;
|
|
if (isInterpolate != 0) {
|
|
uVar5 = GHIDRA_UINT((pEVar6->_isInterpolating != 0));
|
|
headX = (pEVar6->_velocity).x * 0.5 +
|
|
*GHIDRA_CAST<float *>((GHIDRA_CAST<char *>((&pEVar6->_splatColor + 7)) + (uVar5 * 2 + 9) * 4));
|
|
headY = (pEVar6->_velocity).y * 0.5 +
|
|
*GHIDRA_CAST<float *>((GHIDRA_CAST<char *>((&pEVar6->_splatColor + 7)) + (uVar5 * 2 + 10) * 4));
|
|
if (pEVar7->_isInterpolating != 0) {
|
|
anchorX = (pEVar7->_preInterpolatePos).x;
|
|
normalized = &pEVar7->_preInterpolatePos;
|
|
}
|
|
anchorX = (pEVar7->_velocity).x * 0.5 + anchorX;
|
|
anchorY = (pEVar7->_velocity).y * 0.5 + normalized->y;
|
|
}
|
|
local_2c.x = headX - anchorX;
|
|
local_2c.y = headY - anchorY;
|
|
normalized = (GHIDRA_CAST<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 (pEVar6->_isInterpolating == 0) {
|
|
normalized = pVVar1;
|
|
}
|
|
else {
|
|
headX = (pEVar6->_preInterpolatePos).x;
|
|
normalized = &pEVar6->_preInterpolatePos;
|
|
}
|
|
headX = (pEVar6->_velocity).x * 0.5 + headX;
|
|
headY = (pEVar6->_velocity).y * 0.5 + normalized->y;
|
|
}
|
|
dirX = headX - anchorX;
|
|
normDir.y = headY - anchorY;
|
|
fVar8 = sqrtf(dirX * dirX + normDir.y * normDir.y);
|
|
if (0.0 < fVar8) {
|
|
normDir.y = normDir.y * (1.0 / fVar8);
|
|
dirX = dirX * (1.0 / fVar8);
|
|
}
|
|
anchorX = anchorX - dirX * 8.0;
|
|
anchorY = anchorY - normDir.y * 8.0;
|
|
}
|
|
iVar3 = *parentSlot;
|
|
while (iVar3 != 0) {
|
|
fVar8 = sqrtf((headY - anchorY) * (headY - anchorY) + (headX - anchorX) * (headX - anchorX))
|
|
;
|
|
if (8.0 < fVar8) {
|
|
if (16.0 <= fVar8) {
|
|
local_2c.y = dirX * 16.0 + anchorX;
|
|
fVar8 = normDir.y * 16.0 + anchorY;
|
|
}
|
|
else {
|
|
local_2c.y = pVVar1->x;
|
|
fVar8 = (pEVar6->_pos).y;
|
|
}
|
|
if (isInterpolate == 0) {
|
|
npc->_visible = 1;
|
|
npc->_entityCollisionClass = 4;
|
|
}
|
|
if ((*state == 3) ||
|
|
(((iVar3 = npc->_child, iVar3 != 0 && (*GHIDRA_CAST<int *>((iVar3 + 0x28)) == 0x387)) &&
|
|
(*GHIDRA_CAST<int *>((iVar3 + 0x2c)) == 10)))) {
|
|
(npc->_pos).x = (anchorX + local_2c.y) * 0.5;
|
|
(npc->_pos).y = (anchorY + fVar8) * 0.5;
|
|
(npc->_velocity).x = g_vectorZero.x;
|
|
(npc->_velocity).y = g_vectorZero.y;
|
|
}
|
|
(npc->_posOffset).y = -35.0;
|
|
angleDeg = atan2f(normDir.y,dirX);
|
|
angleDeg = angleDeg * 57.295776;
|
|
if ((90.0 < angleDeg) || (angleDeg < -90.0)) {
|
|
isFlipX = 1;
|
|
angleDeg = 180.0 - angleDeg;
|
|
}
|
|
else {
|
|
isFlipX = 0;
|
|
}
|
|
(npc->_sprite)._flipX = isFlipX;
|
|
(npc->_sprite)._rotation = angleDeg;
|
|
anchorX = local_2c.y;
|
|
anchorY = fVar8;
|
|
}
|
|
else if (isInterpolate == 0) {
|
|
(npc->_pos).x = pVVar1->x;
|
|
(npc->_pos).y = (pEVar6->_pos).y;
|
|
npc->_visible = 0;
|
|
npc->_entityCollisionClass = 0;
|
|
}
|
|
npc = GHIDRA_CAST<Entity_NPC *>(*parentSlot);
|
|
parentSlot = &npc->_parent;
|
|
iVar3 = npc->_parent;
|
|
}
|
|
}
|
|
}
|
|
return;
|
|
}
|
|
|
|
// 005add40
|
|
uint8_t NpcHelper::visage_handle_collision(Entity_NPC *npc, Entity *collider, int unused)
|
|
{
|
|
Entity *targetRef;
|
|
float newHealth;
|
|
float healCap;
|
|
int iVar2;
|
|
float local_3c;
|
|
int *local_38;
|
|
uint32_t local_34;
|
|
uint32_t uStack_30;
|
|
uint32_t uStack_2c;
|
|
uint32_t uStack_28;
|
|
uint32_t local_24;
|
|
uint32_t uStack_20;
|
|
uint32_t uStack_1c;
|
|
uint32_t uStack_18;
|
|
uint32_t local_14;
|
|
uint32_t local_10;
|
|
uint32_t local_c;
|
|
uint32_t local_8;
|
|
uint32_t *targetRef;
|
|
|
|
local_8 = __security_cookie ^ GHIDRA_INT(register0x00000010) - 4U;
|
|
iVar2 = npc->_variant;
|
|
if (iVar2 == 0) {
|
|
if (((npc->_state != 0x76) || (collider->_type != 0x387)) || (collider->_variant != 0x14)) {
|
|
return 0xff;
|
|
}
|
|
Entity_NPC::PlaySound(npc,0xb9,1.0,2,0,(float)npc->_stateFrame * 0.15 + 1.0);
|
|
npc->_stateFrame = npc->_stateFrame + 1;
|
|
(**(code **)(*GHIDRA_CAST<int *>(collider) + 0x28))();
|
|
local_34 = 0x3f800000;
|
|
uStack_30 = 0x3f800000;
|
|
uStack_2c = 0x3f800000;
|
|
uStack_28 = 0x3f800000;
|
|
local_14 = 0x3f800000;
|
|
local_10 = 0x3dcccccd;
|
|
local_c = 0;
|
|
local_24 = 0;
|
|
uStack_20 = 0;
|
|
uStack_1c = 0;
|
|
uStack_18 = 0;
|
|
(**(code **)(*GHIDRA_CAST<int *>(npc) + 0x3c))(&local_34,10,0xff,1,1);
|
|
healCap = npc->_maxHitPoints * 0.4;
|
|
newHealth = npc->_maxHitPoints * 0.025 + npc->_health;
|
|
if (healCap <= newHealth) {
|
|
newHealth = healCap;
|
|
}
|
|
npc->_health = newHealth;
|
|
return 0xff;
|
|
}
|
|
if (iVar2 == 1) {
|
|
if ((collider->_type == 9) && (collider->_variant == 2)) {
|
|
collider->_dead = 1;
|
|
return 0;
|
|
}
|
|
if ((collider == GHIDRA_CAST<Entity *>(npc->_parent)) && (npc->_state == 0x6c)) {
|
|
return 1;
|
|
}
|
|
if (collider->_type != 0x387) {
|
|
return 0xff;
|
|
}
|
|
if (collider->_variant != 0x14) {
|
|
return 0xff;
|
|
}
|
|
if (collider[2]._preInterpolatePos.x == 5.60519e-45) {
|
|
return 0xff;
|
|
}
|
|
if ((npc->_state == 0x6a) || (npc->_state == 0x6d)) {
|
|
(**(code **)(*GHIDRA_CAST<int *>(collider) + 0x28))();
|
|
local_34 = 0x3f800000;
|
|
uStack_30 = 0x3f800000;
|
|
uStack_2c = 0x3f800000;
|
|
uStack_28 = 0x3f800000;
|
|
local_14 = 0x3f800000;
|
|
local_10 = 0x3e19999a;
|
|
local_c = 0;
|
|
local_24 = 0;
|
|
uStack_20 = 0;
|
|
uStack_1c = 0;
|
|
uStack_18 = 0;
|
|
(**(code **)(*GHIDRA_CAST<int *>(npc) + 0x3c))(&local_34,10,0xff,1,1);
|
|
visage_start_charge(npc);
|
|
return 0xff;
|
|
}
|
|
return 0xff;
|
|
}
|
|
if (iVar2 != 10) {
|
|
if (iVar2 == 0x14) {
|
|
return 0xff;
|
|
}
|
|
return 0;
|
|
}
|
|
targetRef = &npc->_target;
|
|
if (collider == GHIDRA_CAST<Entity *>(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<uint8_t *>((GHIDRA_CAST<char *>(&(collider[1])) + 0x4)))) = iVar2 + 1;
|
|
goto LAB_005adfbb;
|
|
}
|
|
if (iVar2 != 0x387) {
|
|
return 0xff;
|
|
}
|
|
if (collider->_variant != 1) {
|
|
return 0xff;
|
|
}
|
|
iVar2 = 0x8a;
|
|
}
|
|
Entity_NPC::PlaySound(npc,iVar2,1.0,2,0,1.0);
|
|
LAB_005adfbb:
|
|
targetRef = GHIDRA_CAST<Entity *>(FUN_005acc70());
|
|
if ((collider == targetRef) && (collider[2]._preInterpolatePos.x == 1.48538e-43)) {
|
|
local_3c = (collider->_pos).x - *GHIDRA_CAST<float *>((collider->_parent + 0x33c));
|
|
local_38 = GHIDRA_CAST<int *>(((collider->_pos).y - *GHIDRA_CAST<float *>((collider->_parent + 0x340))));
|
|
FUN_005aafd0(&local_3c);
|
|
collider[2]._preInterpolatePos.x = 1.49939e-43;
|
|
}
|
|
if (*targetRef != 0) {
|
|
local_38 = targetRef;
|
|
msvc::multiset<unsigned_int>::erase(&local_38);
|
|
}
|
|
*targetRef = collider;
|
|
msvc::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)
|
|
{
|
|
uint32_t seed;
|
|
Entity *splash;
|
|
int soundId;
|
|
Manager *manager;
|
|
|
|
seed = Random();
|
|
splash = Game::Spawn(g_game,1000,0x84,&npc->_pos,&g_vectorZero,GHIDRA_CAST<Entity *>(0x0),0,seed);
|
|
(**(code **)(*GHIDRA_CAST<int *>(splash) + 0xc))();
|
|
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
|
|
uint8_t NpcHelper::is_target_valid(Entity *target)
|
|
{
|
|
uint8_t bVar1;
|
|
bool isTargetable;
|
|
|
|
if ((*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(this) + 0x168)) & 0x100) == 0) {
|
|
if (target->_type != 1) {
|
|
return 0;
|
|
}
|
|
bVar1 = Entity_Player::IsInvisible(GHIDRA_CAST<Entity_Player *>(target));
|
|
isTargetable = bVar1 == 0;
|
|
}
|
|
else {
|
|
bVar1 = Entity::IsVulnerableEnemy(target,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;
|
|
uint8_t bVar2;
|
|
float fVar3;
|
|
int iVar4;
|
|
uint32_t uVar5;
|
|
uint32_t uVar6;
|
|
Vector *dropDir;
|
|
Entity_Pickup *pickup;
|
|
Entity *spawned;
|
|
Entity_Player *nearestPlayer;
|
|
ProjectileParams *params;
|
|
uint8_t isDropAllowed;
|
|
float fVar7;
|
|
int gridY;
|
|
char isDropping;
|
|
uint32_t extraout_EDX;
|
|
RNG *dropRng;
|
|
bool isIceFrozen;
|
|
float local_138;
|
|
uint32_t 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;
|
|
uint32_t stackCookie;
|
|
uint32_t 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 = PlayerManager::AnyoneHasTrinket(&g_game->_playerManager,5);
|
|
if (bVar2 != 0) {
|
|
iVar4 = PlayerManager::GetTrinketMultiplier(&g_game->_playerManager,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<uint8_t *>("RNG Seed is zero!\n"));
|
|
uVar5 = dropRng->_seed;
|
|
if (uVar5 == 0) {
|
|
pcVar1 = (code *)swi(3);
|
|
(*pcVar1)();
|
|
return;
|
|
}
|
|
}
|
|
uVar5 = uVar5 >> ((uint8_t)(npc->_dropRNG)._shift1 & 0x1f) ^ uVar5;
|
|
uVar5 = uVar5 << ((uint8_t)(npc->_dropRNG)._shift2 & 0x1f) ^ uVar5;
|
|
uVar5 = uVar5 >> ((uint8_t)(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<uint8_t *>((GHIDRA_CAST<char *>(g_game->_room) + 1))));
|
|
bVar2 = PlayerManager::AnyoneHasTrinket(&g_game->_playerManager,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<uint8_t *>((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 = Game::GetNearestPlayer(g_game,&npc->_pos);
|
|
Entity_Player::AddBlueFlies(nearestPlayer,3,&npc->_pos,GHIDRA_CAST<Entity *>(0x0));
|
|
return;
|
|
case 5:
|
|
dropVariant = 0x28;
|
|
if (((!isIceFrozen) && (bVar2 = Entity::HasEntityFlags(GHIDRA_CAST<Entity *>(npc),0x1000000), bVar2 == 0)) &&
|
|
((dropDir = &npc->_pos, 0x1e < g_game->_frameCount - npc->_spawnFrame ||
|
|
(nearestPlayer = Game::GetNearestPlayer(g_game,dropDir),
|
|
fVar3 = (npc->_pos).y - (nearestPlayer->_pos).y,
|
|
fVar7 = dropDir->x - (nearestPlayer->_pos).x, 6400.0 < fVar3 * fVar3 + fVar7 * fVar7)))) {
|
|
Game::BombDamage(g_game,dropDir,40.0,60.0,1,GHIDRA_CAST<Entity *>(npc),g_tearFlagsNone,4,0);
|
|
Game::spawn_bomb_crater(g_game,dropDir,GHIDRA_CAST<Entity *>(0x0),1.0);
|
|
uVar5 = Random();
|
|
Game::SpawnEx(g_game,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 = Entity::HasEntityFlags(GHIDRA_CAST<Entity *>(npc),0x1000000), bVar2 == 0)) &&
|
|
((dropDir = &npc->_pos, 0x1e < g_game->_frameCount - npc->_spawnFrame ||
|
|
(nearestPlayer = Game::GetNearestPlayer(g_game,dropDir),
|
|
fVar3 = (npc->_pos).y - (nearestPlayer->_pos).y,
|
|
fVar7 = dropDir->x - (nearestPlayer->_pos).x, 6400.0 < fVar3 * fVar3 + fVar7 * fVar7)))) {
|
|
params = ProjectileParams::ProjectileParams(&projParams);
|
|
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<uint8_t *>("RNG Seed is zero!\n"));
|
|
uVar5 = (npc->_dropRNG)._seed;
|
|
if (uVar5 == 0) {
|
|
pcVar1 = (code *)swi(3);
|
|
(*pcVar1)();
|
|
return;
|
|
}
|
|
}
|
|
uVar5 = uVar5 >> ((uint8_t)(npc->_dropRNG)._shift1 & 0x1f) ^ uVar5;
|
|
uVar5 = uVar5 << ((uint8_t)(npc->_dropRNG)._shift2 & 0x1f) ^ uVar5;
|
|
uVar5 = uVar5 >> ((uint8_t)(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;
|
|
Game::SpawnEx(g_game,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 = Game::SpawnEx(g_game,0x12,0,&npc->_pos,&g_vectorZero,GHIDRA_CAST<Entity *>(npc),0,uVar5,0);
|
|
bVar2 = Entity::HasEntityFlags(GHIDRA_CAST<Entity *>(npc),0x1000000);
|
|
if (bVar2 != 0) {
|
|
*GHIDRA_CAST<uint32_t *>(&spawned->_flags) = GHIDRA_UINT(spawned->_flags) & 0xfeffffff;
|
|
*GHIDRA_CAST<uint32_t *>((GHIDRA_INT(&spawned->_flags) + 4)) = *GHIDRA_CAST<uint32_t *>((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;
|
|
Entity::AddShrink(spawned,&sourceRef,0x96,0,0);
|
|
if (0 < spawned->_shrinkCountdown) {
|
|
flagsHigh = *GHIDRA_CAST<uint32_t *>((GHIDRA_INT(&spawned->_flags) + 4));
|
|
*GHIDRA_CAST<uint32_t *>(&spawned->_flags) = GHIDRA_UINT(spawned->_flags) | 0x1000000;
|
|
*GHIDRA_CAST<uint32_t *>((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<uint8_t *>((GHIDRA_CAST<char *>(&(local_138)) + 0x0))) == '\0') {
|
|
return;
|
|
}
|
|
bVar2 = PlayerManager::AnyoneHasTrinket(&g_game->_playerManager,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<uint8_t *>("RNG Seed is zero!\n"));
|
|
uVar5 = (npc->_dropRNG)._seed;
|
|
if (uVar5 == 0) {
|
|
pcVar1 = (code *)swi(3);
|
|
(*pcVar1)();
|
|
return;
|
|
}
|
|
}
|
|
game = g_game;
|
|
uVar5 = uVar5 >> ((uint8_t)(npc->_dropRNG)._shift1 & 0x1f) ^ uVar5;
|
|
uVar5 = uVar5 << ((uint8_t)(npc->_dropRNG)._shift2 & 0x1f) ^ uVar5;
|
|
uVar5 = uVar5 >> ((uint8_t)(local_120->_dropRNG)._shift3 & 0x1f) ^ uVar5;
|
|
dropRng->_seed = uVar5;
|
|
uVar6 = ItemPool::ForceAddPillEffect(&game->_itemPool,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;
|
|
Game::SpawnEx(g_game,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<uint8_t *>((GHIDRA_CAST<char *>(&(local_138)) + 0x0))) == '\0') {
|
|
return;
|
|
}
|
|
bVar2 = PlayerManager::AnyoneHasTrinket(&g_game->_playerManager,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<uint8_t *>("RNG Seed is zero!\n"));
|
|
uVar5 = (npc->_dropRNG)._seed;
|
|
if (uVar5 == 0) {
|
|
pcVar1 = (code *)swi(3);
|
|
(*pcVar1)();
|
|
return;
|
|
}
|
|
}
|
|
game = g_game;
|
|
uVar5 = uVar5 >> ((uint8_t)(npc->_dropRNG)._shift1 & 0x1f) ^ uVar5;
|
|
uVar5 = uVar5 << ((uint8_t)(npc->_dropRNG)._shift2 & 0x1f) ^ uVar5;
|
|
uVar5 = uVar5 >> ((uint8_t)(local_120->_dropRNG)._shift3 & 0x1f) ^ uVar5;
|
|
dropRng->_seed = uVar5;
|
|
uVar6 = ItemPool::ForceAddPillEffect(&game->_itemPool,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;
|
|
Game::SpawnEx(g_game,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 = Game::GetNearestPlayer(g_game,&npc->_pos);
|
|
uVar5 = (GHIDRA_CAST<RNG *>((GHIDRA_CAST<RNG *>(local_11c.x))))->RNG::RandomInt(3);
|
|
Entity_Player::AddBlueFlies(nearestPlayer,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 = PlayerManager::AnyoneHasTrinket(&g_game->_playerManager,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<uint8_t *>("RNG Seed is zero!\n"));
|
|
uVar5 = (npc->_dropRNG)._seed;
|
|
if (uVar5 == 0) {
|
|
pcVar1 = (code *)swi(3);
|
|
(*pcVar1)();
|
|
return;
|
|
}
|
|
}
|
|
game = g_game;
|
|
uVar5 = uVar5 >> ((uint8_t)(npc->_dropRNG)._shift1 & 0x1f) ^ uVar5;
|
|
uVar5 = uVar5 << ((uint8_t)(npc->_dropRNG)._shift2 & 0x1f) ^ uVar5;
|
|
uVar5 = uVar5 >> ((uint8_t)(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);
|
|
Game::SpawnEx(g_game,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 = Game::GetPlayer(g_game,0);
|
|
}
|
|
Entity_Player::UseActiveItem(nearestPlayer,GHIDRA_CAST<short *>(&local_12c),0x23,1,-1,0);
|
|
ItemOverlay::Show(&g_game->_itemOverlay,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<uint8_t *>("RNG Seed is zero!\n"));
|
|
uVar5 = (npc->_dropRNG)._seed;
|
|
if (uVar5 == 0) {
|
|
pcVar1 = (code *)swi(3);
|
|
(*pcVar1)();
|
|
return;
|
|
}
|
|
}
|
|
uVar5 = uVar5 >> ((uint8_t)(npc->_dropRNG)._shift1 & 0x1f) ^ uVar5;
|
|
uVar5 = uVar5 << ((uint8_t)(npc->_dropRNG)._shift2 & 0x1f) ^ uVar5;
|
|
uVar5 = uVar5 >> ((uint8_t)(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<uint8_t *>("RNG Seed is zero!\n"));
|
|
uVar5 = (npc->_dropRNG)._seed;
|
|
if (uVar5 == 0) {
|
|
pcVar1 = (code *)swi(3);
|
|
(*pcVar1)();
|
|
return;
|
|
}
|
|
}
|
|
game = g_game;
|
|
uVar5 = uVar5 >> ((uint8_t)(npc->_dropRNG)._shift1 & 0x1f) ^ uVar5;
|
|
uVar5 = uVar5 << ((uint8_t)(npc->_dropRNG)._shift2 & 0x1f) ^ uVar5;
|
|
uVar5 = uVar5 >> ((uint8_t)(npc->_dropRNG)._shift3 & 0x1f) ^ uVar5;
|
|
dropRng->_seed = uVar5;
|
|
spawned = Game::SpawnEx(game,5,*GHIDRA_CAST<uint32_t *>((&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 = PlayerManager::AnyoneHasTrinket(&g_game->_playerManager,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<uint8_t *>("RNG Seed is zero!\n"));
|
|
uVar5 = (npc->_dropRNG)._seed;
|
|
if (uVar5 == 0) {
|
|
pcVar1 = (code *)swi(3);
|
|
(*pcVar1)();
|
|
return;
|
|
}
|
|
}
|
|
game = g_game;
|
|
uVar5 = uVar5 >> ((uint8_t)(npc->_dropRNG)._shift1 & 0x1f) ^ uVar5;
|
|
uVar5 = uVar5 << ((uint8_t)(npc->_dropRNG)._shift2 & 0x1f) ^ uVar5;
|
|
uVar5 = uVar5 >> ((uint8_t)(npc->_dropRNG)._shift3 & 0x1f) ^ uVar5;
|
|
dropRng->_seed = uVar5;
|
|
spawned = Game::SpawnEx(game,5,*GHIDRA_CAST<uint32_t *>((&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 = Entity::HasEntityFlags(GHIDRA_CAST<Entity *>(npc),0x1000000);
|
|
if ((bVar2 == 0) &&
|
|
((dropDir = &npc->_pos, 0x1e < g_game->_frameCount - npc->_spawnFrame ||
|
|
(nearestPlayer = Game::GetNearestPlayer(g_game,dropDir),
|
|
fVar3 = (npc->_pos).y - (nearestPlayer->_pos).y,
|
|
fVar7 = dropDir->x - (nearestPlayer->_pos).x, 6400.0 < fVar3 * fVar3 + fVar7 * fVar7)))) {
|
|
Game::BombDamage(g_game,dropDir,40.0,60.0,1,GHIDRA_CAST<Entity *>(npc),g_tearFlagsNone,4,0);
|
|
Game::spawn_bomb_crater(g_game,dropDir,GHIDRA_CAST<Entity *>(0x0),1.0);
|
|
uVar5 = Random();
|
|
Game::SpawnEx(g_game,1000,1,dropDir,&g_vectorZero,GHIDRA_CAST<Entity *>(0x0),0,uVar5,0);
|
|
}
|
|
bVar2 = Entity::HasEntityFlags(GHIDRA_CAST<Entity *>(npc),0x1000000);
|
|
if ((bVar2 == 0) &&
|
|
((dropDir = &npc->_pos, 0x1e < g_game->_frameCount - npc->_spawnFrame ||
|
|
(nearestPlayer = Game::GetNearestPlayer(g_game,dropDir),
|
|
fVar3 = (npc->_pos).y - (nearestPlayer->_pos).y,
|
|
fVar7 = dropDir->x - (nearestPlayer->_pos).x, 6400.0 < fVar3 * fVar3 + fVar7 * fVar7)))) {
|
|
params = ProjectileParams::ProjectileParams(&projParams);
|
|
local_c8._seed = 0x40e00000;
|
|
(*GHIDRA_CAST<uint64_t *>((GHIDRA_CAST<char *>(&(local_c8)) + 0x4))) = (uint64_t)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<uint8_t *>((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 = Room::GetGridCollision(room,iVar4);
|
|
if (0 < GHIDRA_INT(uVar5)) {
|
|
dropDir = Room::FindFreeTilePosition(room,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<uint8_t *>("RNG Seed is zero!\n"));
|
|
uVar5 = dropRng->_seed;
|
|
if (uVar5 == 0) {
|
|
pcVar1 = (code *)swi(3);
|
|
(*pcVar1)();
|
|
return;
|
|
}
|
|
}
|
|
uVar5 = uVar5 >> ((uint8_t)(npc->_dropRNG)._shift1 & 0x1f) ^ uVar5;
|
|
uVar5 = uVar5 << ((uint8_t)(npc->_dropRNG)._shift2 & 0x1f) ^ uVar5;
|
|
uVar5 = uVar5 >> ((uint8_t)(npc->_dropRNG)._shift3 & 0x1f) ^ uVar5;
|
|
dropRng->_seed = uVar5;
|
|
glyphOwner = PlayerManager::RandomCollectibleOwner(local_12c,0x1d0,uVar5,GHIDRA_CAST<RNG **>(0x0));
|
|
if ((dropCount != 0) && (local_125 != '\0')) {
|
|
uVar5 = dropRng->_seed;
|
|
if (uVar5 == 0) {
|
|
KAGE_LogMessage(0x10,GHIDRA_CAST<uint8_t *>("RNG Seed is zero!\n"));
|
|
uVar5 = dropRng->_seed;
|
|
if (uVar5 == 0) {
|
|
pcVar1 = (code *)swi(3);
|
|
(*pcVar1)();
|
|
return;
|
|
}
|
|
}
|
|
uVar5 = uVar5 >> ((uint8_t)(npc->_dropRNG)._shift1 & 0x1f) ^ uVar5;
|
|
uVar5 = uVar5 << ((uint8_t)(npc->_dropRNG)._shift2 & 0x1f) ^ uVar5;
|
|
uVar5 = uVar5 >> ((uint8_t)(npc->_dropRNG)._shift3 & 0x1f) ^ uVar5;
|
|
dropRng->_seed = uVar5;
|
|
if ((uVar5 & 1) == 0) {
|
|
dropCount = dropCount + 1;
|
|
}
|
|
}
|
|
bVar2 = PlayerManager::AnyoneHasTrinket(&g_game->_playerManager,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)) {
|
|
Entity_Player::GetGlyphOfBalanceDrop(glyphOwner,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<uint8_t *>("RNG Seed is zero!\n"));
|
|
uVar5 = (npc->_dropRNG)._seed;
|
|
if (uVar5 == 0) {
|
|
pcVar1 = (code *)swi(3);
|
|
(*pcVar1)();
|
|
return;
|
|
}
|
|
}
|
|
game = g_game;
|
|
uVar5 = uVar5 >> ((uint8_t)(npc->_dropRNG)._shift1 & 0x1f) ^ uVar5;
|
|
uVar5 = uVar5 << ((uint8_t)(npc->_dropRNG)._shift2 & 0x1f) ^ uVar5;
|
|
local_c8._seed = GHIDRA_INT((local_114.x * 3.0 + (float)local_120));
|
|
uVar5 = uVar5 >> ((uint8_t)(npc->_dropRNG)._shift3 & 0x1f) ^ uVar5;
|
|
dropRng->_seed = uVar5;
|
|
local_c8._shift1 = GHIDRA_INT((local_11c.x * 3.0 + local_138));
|
|
pickup = (Entity_Pickup *)
|
|
Game::SpawnEx(game,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 ||
|
|
(((*GHIDRA_CAST<int *>(&(*GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>((g_manager)) + 0x8)))) == 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)
|
|
{
|
|
uint8_t bVar1;
|
|
EntityRef *damageSource;
|
|
uint8_t *curAnimName;
|
|
uint32_t uVar2;
|
|
LayerState *layer;
|
|
int iVar3;
|
|
uint8_t *wantedAnimName;
|
|
char *wantedAnimNameStr;
|
|
float *damageEvent;
|
|
bool isLess;
|
|
float fVar4;
|
|
float fVar5;
|
|
EntityRef damageSourceRef;
|
|
float local_10;
|
|
float local_c;
|
|
char isIgnoreDamage;
|
|
uint8_t *animData;
|
|
uint32_t damageEventsBegin;
|
|
uint64_t flags;
|
|
Manager *manager;
|
|
ANM2 *sprite;
|
|
|
|
if ((npc->_variant == 0xc) || (npc->_variant == 0xd)) {
|
|
isIgnoreDamage = '\x01';
|
|
}
|
|
else {
|
|
isIgnoreDamage = '\0';
|
|
if ((0.2 < *GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(g_game->_room) + 0x7240))) &&
|
|
(bVar1 = Entity::IsFrame(GHIDRA_CAST<Entity *>(npc),5,npc->_index), bVar1 != 0)) {
|
|
damageSource = EntityRef::EntityRef(&damageSourceRef);
|
|
(**(code **)(*GHIDRA_CAST<int *>(npc) + 0x20))(0x3f800000,0,0,damageSource,0x1e);
|
|
}
|
|
}
|
|
iVar3 = npc->_state;
|
|
if (iVar3 != 0) {
|
|
if (iVar3 != 3) {
|
|
if (iVar3 == 0x10) {
|
|
fVar4 = npc->_health - 1.0;
|
|
if (fVar4 <= 0.01) {
|
|
fVar4 = 0.01;
|
|
}
|
|
npc->_health = fVar4;
|
|
if (((npc->_sprite)._animState._animData == (void *)0x0) ||
|
|
((npc->_sprite)._animState._isPlaying == 0)) {
|
|
(**(code **)(*GHIDRA_CAST<int *>(npc) + 0x28))();
|
|
}
|
|
}
|
|
goto LAB_006d1556;
|
|
}
|
|
sprite = &npc->_sprite;
|
|
if (((npc->_sprite)._animState._animData == (void *)0x0) ||
|
|
((npc->_sprite)._animState._isPlaying == 0)) {
|
|
animData = (npc->_sprite)._animState._animData;
|
|
if (animData != GHIDRA_CAST<uint8_t *>(0x0)) {
|
|
curAnimName = animData;
|
|
if (0xf < *GHIDRA_CAST<uint32_t *>((animData + 0x14))) {
|
|
curAnimName = *GHIDRA_CAST<uint8_t **>(animData);
|
|
}
|
|
wantedAnimName = s_Idle;
|
|
do {
|
|
bVar1 = *curAnimName;
|
|
isLess = bVar1 < *wantedAnimName;
|
|
if (bVar1 != *wantedAnimName) {
|
|
LAB_006d0fd0:
|
|
uVar2 = -GHIDRA_UINT(isLess) | 1;
|
|
goto LAB_006d0fd5;
|
|
}
|
|
if (bVar1 == 0) break;
|
|
bVar1 = curAnimName[1];
|
|
isLess = bVar1 < wantedAnimName[1];
|
|
if (bVar1 != wantedAnimName[1]) goto LAB_006d0fd0;
|
|
curAnimName = curAnimName + 2;
|
|
wantedAnimName = wantedAnimName + 2;
|
|
} while (bVar1 != 0);
|
|
uVar2 = 0;
|
|
LAB_006d0fd5:
|
|
if ((uVar2 == 0) && ((animData[0x34] == 0 || ((npc->_sprite)._animState._isPlaying != 0))))
|
|
goto LAB_006d1001;
|
|
}
|
|
bVar1 = ANM2::SetAnimation(sprite,s_Idle,1);
|
|
if (bVar1 != 0) {
|
|
AnimationState::Rewind(&(npc->_sprite)._animState);
|
|
(npc->_sprite)._animState._isPlaying = 1;
|
|
}
|
|
}
|
|
LAB_006d1001:
|
|
fVar4 = (npc->_targetPosition).x;
|
|
if ((fVar4 == g_vectorZero.x) && ((npc->_targetPosition).y == g_vectorZero.y)) {
|
|
if (npc->_spawnerType != 0x3b7) {
|
|
fVar4 = npc->_friction * 0.95;
|
|
goto LAB_006d107e;
|
|
}
|
|
}
|
|
else {
|
|
fVar5 = (npc->_pos).x;
|
|
(npc->_velocity).y = (npc->_targetPosition).y - (npc->_pos).y;
|
|
(npc->_velocity).x = fVar4 - fVar5;
|
|
fVar4 = npc->_friction * 0.6;
|
|
LAB_006d107e:
|
|
npc->_friction = fVar4;
|
|
}
|
|
if (npc->_variant == 0xc) {
|
|
fVar4 = npc->_speedMultiplier + (npc->_v1).x;
|
|
(npc->_v1).x = fVar4;
|
|
if (90.0 < fVar4) {
|
|
fVar5 = npc->_health - 1.0;
|
|
(npc->_v1).x = fVar4 - 90.0;
|
|
if (fVar5 <= 1.0) {
|
|
fVar5 = 1.0;
|
|
}
|
|
npc->_health = fVar5;
|
|
local_c = (fVar5 * 0.9) / npc->_maxHitPoints + 0.1;
|
|
local_10 = local_c * g_vectorOne.y;
|
|
local_c = local_c * g_vectorOne.x;
|
|
layer = ANM2::GetLayer(sprite,GHIDRA_CAST<uint8_t *>(0x0));
|
|
(layer->_size).x = local_c;
|
|
(layer->_size).y = local_10;
|
|
if (npc->_health <= 1.5 && npc->_health != 1.5) goto LAB_006d114a;
|
|
}
|
|
}
|
|
else if (npc->_variant != 0xd) {
|
|
iVar3 = 300;
|
|
if (npc->_entityGridCollisionClass != 0) {
|
|
iVar3 = 0xb4;
|
|
}
|
|
if (iVar3 < g_game->_frameCount - npc->_spawnFrame) {
|
|
LAB_006d114a:
|
|
npc->_state = 0x10;
|
|
npc->_entityCollisionClass = 0;
|
|
npc->_entityGridCollisionClass = 0;
|
|
ANM2::Play(sprite,GHIDRA_CAST<uint8_t *>("Disappear"),0);
|
|
goto LAB_006d1556;
|
|
}
|
|
}
|
|
if (((npc->_spawnerType == 0x3b7) &&
|
|
(iVar3 = Entity::GetIntervalTicks(GHIDRA_CAST<Entity *>(npc),30.0,0.0), iVar3 != 0)) &&
|
|
(uVar2 = Random(), (uVar2 & 3) == 0)) {
|
|
damageSource = EntityRef::EntityRef(&damageSourceRef);
|
|
(**(code **)(*GHIDRA_CAST<int *>(npc) + 0x20))(0x3f800000,0x20000,0,damageSource,0x1e);
|
|
}
|
|
if (npc->_pendingDamage <= 0.0) goto LAB_006d1556;
|
|
if ((npc->_pendingDamageFlags & 4) == 0) {
|
|
if (isIgnoreDamage == '\0') {
|
|
damageEvent = *GHIDRA_CAST<float **>(&(*GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>((npc)) + 0x8))));
|
|
if (damageEvent == *GHIDRA_CAST<float **>(&(*GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>((npc)) + 0xc))))) {
|
|
fVar4 = npc->_health;
|
|
}
|
|
else {
|
|
do {
|
|
if (10.0 < *damageEvent) {
|
|
uVar2 = Random();
|
|
if (uVar2 % 3 == 0) {
|
|
fVar4 = 3.0;
|
|
}
|
|
else {
|
|
fVar4 = 2.0;
|
|
}
|
|
LAB_006d1299:
|
|
fVar4 = npc->_health - fVar4;
|
|
npc->_health = fVar4;
|
|
}
|
|
else {
|
|
if (0.0 < *damageEvent) {
|
|
uVar2 = Random();
|
|
if (uVar2 % 3 == 0) {
|
|
fVar4 = 2.0;
|
|
}
|
|
else {
|
|
fVar4 = 1.0;
|
|
}
|
|
goto LAB_006d1299;
|
|
}
|
|
fVar4 = npc->_health;
|
|
}
|
|
damageEvent = damageEvent + 0xe;
|
|
} while (damageEvent != *GHIDRA_CAST<float **>(&(*GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>((npc)) + 0xc)))));
|
|
}
|
|
if (fVar4 < 1.0) goto LAB_006d12d6;
|
|
}
|
|
}
|
|
else {
|
|
LAB_006d12d6:
|
|
npc->_health = 1.0;
|
|
}
|
|
local_10 = (npc->_health * 0.9) / npc->_maxHitPoints + 0.1;
|
|
local_c = local_10 * g_vectorOne.y;
|
|
local_10 = local_10 * g_vectorOne.x;
|
|
layer = ANM2::GetLayer(&npc->_sprite,GHIDRA_CAST<uint8_t *>(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<uint8_t *>(0x0)) {
|
|
LAB_006d13b6:
|
|
bVar1 = ANM2::SetAnimation(&npc->_sprite,GHIDRA_CAST<uint8_t *>("Disappear"),1);
|
|
if (bVar1 != 0) {
|
|
AnimationState::Rewind(&(npc->_sprite)._animState);
|
|
(npc->_sprite)._animState._isPlaying = 1;
|
|
}
|
|
}
|
|
else {
|
|
curAnimName = animData;
|
|
if (0xf < *GHIDRA_CAST<uint32_t *>((animData + 0x14))) {
|
|
curAnimName = *GHIDRA_CAST<uint8_t **>(animData);
|
|
}
|
|
wantedAnimNameStr = "Disappear";
|
|
do {
|
|
bVar1 = *curAnimName;
|
|
isLess = bVar1 < (uint8_t)*wantedAnimNameStr;
|
|
if (bVar1 != *wantedAnimNameStr) {
|
|
LAB_006d13a3:
|
|
uVar2 = -GHIDRA_UINT(isLess) | 1;
|
|
goto LAB_006d13a8;
|
|
}
|
|
if (bVar1 == 0) break;
|
|
bVar1 = curAnimName[1];
|
|
isLess = bVar1 < (uint8_t)wantedAnimNameStr[1];
|
|
if (bVar1 != wantedAnimNameStr[1]) goto LAB_006d13a3;
|
|
curAnimName = curAnimName + 2;
|
|
wantedAnimNameStr = wantedAnimNameStr + 2;
|
|
} while (bVar1 != 0);
|
|
uVar2 = 0;
|
|
LAB_006d13a8:
|
|
if ((uVar2 != 0) || ((animData[0x34] != 0 && ((npc->_sprite)._animState._isPlaying == 0))))
|
|
goto LAB_006d13b6;
|
|
}
|
|
manager = g_manager;
|
|
if ((npc->_pendingDamageFlags & 0x20000) == 0) {
|
|
local_c = 3.65739e-43;
|
|
seed_fart_sound_override(GHIDRA_CAST<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<uint32_t *>((GHIDRA_INT(&npc->_flags) + 4)) = *GHIDRA_CAST<uint32_t *>((GHIDRA_INT(&npc->_flags) + 4));
|
|
*GHIDRA_CAST<uint32_t *>(&npc->_flags) = GHIDRA_UINT(flags) & 0xfffffffb | 0x42050011;
|
|
local_10 = (fVar4 * 0.9) / npc->_maxHitPoints + 0.1;
|
|
local_c = local_10 * g_vectorOne.y;
|
|
local_10 = local_10 * g_vectorOne.x;
|
|
layer = ANM2::GetLayer(&npc->_sprite,GHIDRA_CAST<uint8_t *>(0x0));
|
|
(layer->_size).x = local_10;
|
|
(layer->_size).y = local_c;
|
|
animData = (npc->_sprite)._animState._animData;
|
|
if (animData == GHIDRA_CAST<uint8_t *>(0x0)) {
|
|
LAB_006d14f6:
|
|
bVar1 = ANM2::SetAnimation(&npc->_sprite,GHIDRA_CAST<uint8_t *>("Appear"),1);
|
|
if (bVar1 != 0) {
|
|
AnimationState::Rewind(&(npc->_sprite)._animState);
|
|
(npc->_sprite)._animState._isPlaying = 1;
|
|
}
|
|
}
|
|
else {
|
|
curAnimName = animData;
|
|
if (0xf < *GHIDRA_CAST<uint32_t *>((animData + 0x14))) {
|
|
curAnimName = *GHIDRA_CAST<uint8_t **>(animData);
|
|
}
|
|
wantedAnimNameStr = "Appear";
|
|
do {
|
|
bVar1 = *curAnimName;
|
|
isLess = bVar1 < (uint8_t)*wantedAnimNameStr;
|
|
if (bVar1 != *wantedAnimNameStr) {
|
|
LAB_006d14e0:
|
|
uVar2 = -GHIDRA_UINT(isLess) | 1;
|
|
goto LAB_006d14e5;
|
|
}
|
|
if (bVar1 == 0) break;
|
|
bVar1 = curAnimName[1];
|
|
isLess = bVar1 < (uint8_t)wantedAnimNameStr[1];
|
|
if (bVar1 != wantedAnimNameStr[1]) goto LAB_006d14e0;
|
|
curAnimName = curAnimName + 2;
|
|
wantedAnimNameStr = wantedAnimNameStr + 2;
|
|
} while (bVar1 != 0);
|
|
uVar2 = 0;
|
|
LAB_006d14e5:
|
|
if ((uVar2 != 0) || ((animData[0x34] != 0 && ((npc->_sprite)._animState._isPlaying == 0))))
|
|
goto LAB_006d14f6;
|
|
}
|
|
npc->_state = 3;
|
|
if (((npc->_targetPosition).x != g_vectorZero.x) || ((npc->_targetPosition).y != g_vectorZero.y))
|
|
{
|
|
npc->_entityGridCollisionClass = 0;
|
|
}
|
|
LAB_006d1556:
|
|
damageEventsBegin = *GHIDRA_CAST<uint32_t *>(&(*GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>((npc)) + 0x8))));
|
|
npc->_pendingDamage = 0.0;
|
|
*GHIDRA_CAST<uint32_t *>(&npc->_pendingDamageFlags) = 0;
|
|
*GHIDRA_CAST<uint32_t *>((GHIDRA_INT(&npc->_pendingDamageFlags) + 4)) = 0;
|
|
*GHIDRA_CAST<uint32_t *>(&(*GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>((npc)) + 0xc)))) = damageEventsBegin;
|
|
return;
|
|
}
|
|
|
|
// 009be990
|
|
uint32_t NpcHelper::big_horn_is_any_hole_busy()
|
|
{
|
|
int *hole;
|
|
uint32_t *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;
|
|
uint8_t *puVar2;
|
|
uint32_t 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;
|
|
uint32_t pointIdx;
|
|
float circleX;
|
|
int sideCount;
|
|
uint8_t *puStack_20;
|
|
void *local_1c;
|
|
uint8_t *puStack_18;
|
|
uint32_t local_14;
|
|
void *savedExceptionList;
|
|
|
|
savedExceptionList = ExceptionList;
|
|
puStack_20 = GHIDRA_CAST<uint8_t *>((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<uint8_t *>((GHIDRA_INT(register0x00000010) + -4));
|
|
if (pointCapacity == 0) goto LAB_009bfdd2;
|
|
if (0xfffffff < pointCapacity) {
|
|
/* WARNING: Subroutine does not return */
|
|
msvc::_Xlen();
|
|
}
|
|
}
|
|
iVar3 = sideCount;
|
|
puStack_20 = GHIDRA_CAST<uint8_t *>((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])) {
|
|
msvc::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<uint8_t *>("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<uint8_t *>("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;
|
|
}
|