Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 22 additions & 2 deletions include/d/actor/d_a_nzg.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,30 @@
#define D_A_NZG_H

#include "f_op/f_op_actor.h"
#include "d/d_cc_d.h"

class nzg_class : public fopAc_ac_c {
struct dPath;

class nzg_class : public fopEn_enemy_c {
public:
/* Place member variables here */
/* 0x2AC */ request_of_phase_process_class mPhs;
Comment thread
ThePlayerRolo marked this conversation as resolved.
Outdated
/* 0x2B4 */ J3DModel* mpModel;
/* 0x2B8 */ u8 m2B8;
/* 0x2B9 */ u8 m2B9;
/* 0x2BA */ u8 m2BA;
/* 0x2BB */ u8 m2BB;
/* 0x2BC */ u8 m2BC[0x2BE - 0x2BC];
/* 0x2BE */ s16 m2BE;
/* 0x2C0 */ s16 m2C0;
/* 0x2C2 */ s16 m2C2[5];
/* 0x2CC */ f32 m2CC;
/* 0x2D0 */ f32 m2D0;
/* 0x2D4 */ fpc_ProcID m2D4;
/* 0x2D8 */ dPath* mpPath;
/* 0x2DC */ u8 m2DC[0x2E9 - 0x2DC];
/* 0x2E9 */ u8 m2E9;
/* 0x2EC */ dCcD_Stts mStts;
/* 0x328 */ dCcD_Cyl mCyl;
};

#endif /* D_A_NZG_H */
179 changes: 160 additions & 19 deletions src/d/actor/d_a_nzg.cpp
Original file line number Diff line number Diff line change
@@ -1,32 +1,113 @@
//
// Generated by dtk
// Translation Unit: d_a_nzg.cpp
//
/**
* d_a_nzg.cpp
* Enemy - Rat Group
*/

#include "d/dolzel_rel.h" // IWYU pragma: keep
#include "d/actor/d_a_nzg.h"
#include "d/d_path.h"
#include "d/d_procname.h"
#include "d/d_priority.h"
#include "d/d_cc_d.h"
#include "d/d_s_play.h"
#include "d/res/res_nzg.h"

/* 00000078-000000E4 .text daNZG_Draw__FP9nzg_class */
static BOOL daNZG_Draw(nzg_class*) {
/* Nonmatching */
static BOOL daNZG_Draw(nzg_class* i_this) {
J3DModel* model = i_this->mpModel;
g_env_light.settingTevStruct(TEV_TYPE_ACTOR, &i_this->current.pos, &i_this->tevStr);
g_env_light.setLightTevColorType(model, &i_this->tevStr);
mDoExt_modelUpdateDL(model);
return TRUE;
}

/* 000000E4-00000348 .text nzg_00_move__FP9nzg_class */
void nzg_00_move(nzg_class*) {
/* Nonmatching */
void nzg_00_move(nzg_class* i_this) {
/* Nonmatching for Demo */
//fixes regswap issue in demo for the most part but introduces a misplaced instruction error
nzg_class* actor = i_this;
Comment thread
ThePlayerRolo marked this conversation as resolved.
Outdated

if (i_this->m2C2[0] != 0 || i_this->m2BE >= i_this->m2C0) {
return;
}

actor->mCyl.SetC(actor->current.pos);
actor->mCyl.SetH(REG8_F(11) + 40.0f);
actor->mCyl.SetR(REG8_F(12) + 40.0f);
dComIfG_Ccsp()->Set(&actor->mCyl);

if (actor->mCyl.ChkCoHit()) {
fopAc_ac_c* hit_actor = actor->mCyl.GetCoHitAc();
if (hit_actor != NULL) {
s16 hitAC_name = fopAcM_GetName(hit_actor);
if (hitAC_name != PROC_NZ && hitAC_name != PROC_BOMB && hitAC_name != PROC_Bomb2 && hitAC_name != PROC_ITEM && hitAC_name != PROC_ESA) {
actor->m2D4 = fopAcM_GetID(hit_actor);
actor->m2BB = 1;
return;
}
}
}

u32 parameters = fopAcM_GetParam(actor) & 0xFF000000;

if (actor->m2BA == 1) {
parameters |= 0x100;
} else if (actor->m2BA == 2 && cM_rnd() < 0.5f) {
parameters |= 0x100;
}

if (parameters & 0x100 || fopAcM_searchActorDistance(actor, dComIfGp_getPlayer(0)) < actor->m2CC * 0.5f) {
if (fopAcM_searchActorDistance(actor, dComIfGp_getPlayer(0)) > actor->m2D0 * 0.5f) {
parameters |= 1;
csXyz child_angle = actor->current.angle;

child_angle.y += cM_rndFX(8192.0f);
fpc_ProcID childProcID = fopAcM_createChild(PROC_NZ, fopAcM_GetID(actor), parameters, &actor->current.pos, fopAcM_GetRoomNo(actor), &child_angle, &actor->scale, NULL);

if (childProcID != fpcM_ERROR_PROCESS_ID_e) {
actor->m2C2[0] = (childProcID & 3) * 10 + 20;
actor->m2BE++;
}
}
}
}

/* 00000348-00000450 .text nzg_01_move__FP9nzg_class */
void nzg_01_move(nzg_class*) {
/* Nonmatching */
void nzg_01_move(nzg_class* i_this) {
if (i_this->m2D4 != fpcM_ERROR_PROCESS_ID_e) {
fopAc_ac_c* ac_id = fopAcM_SearchByID(i_this->m2D4);
if (ac_id != NULL) {
f32 pos_x_diff = i_this->current.pos.x - ac_id->current.pos.x;
f32 pos_z_diff = i_this->current.pos.z - ac_id->current.pos.z;
pos_x_diff = (pos_x_diff * pos_x_diff) + (pos_z_diff * pos_z_diff);

if (std::sqrtf(pos_x_diff) < 80.0f) {
return;
}
}
}
i_this->m2D4 = fpcM_ERROR_PROCESS_ID_e;
i_this->m2BB = 0;
}

/* 00000450-000004D0 .text daNZG_Execute__FP9nzg_class */
static BOOL daNZG_Execute(nzg_class*) {
/* Nonmatching */
static BOOL daNZG_Execute(nzg_class* i_this) {
i_this->m2D0 = 400.0f;
s32 j = 0;
for (s32 i = 4; i != 0; i--) {
if (i_this->m2C2[j] != 0) {
i_this->m2C2[j]--;
}
j += 1;
}
switch (i_this->m2BB) {
case 0:
nzg_00_move(i_this);
break;
case 1:
nzg_01_move(i_this);
break;
}
return TRUE;
}

/* 000004D0-000004D8 .text daNZG_IsDelete__FP9nzg_class */
Expand All @@ -35,18 +116,39 @@ static BOOL daNZG_IsDelete(nzg_class*) {
}

/* 000004D8-00000508 .text daNZG_Delete__FP9nzg_class */
static BOOL daNZG_Delete(nzg_class*) {
/* Nonmatching */
static BOOL daNZG_Delete(nzg_class* i_this) {
#if VERSION == VERSION_DEMO
g_dComIfG_gameInfo.mResControl.deleteObjectRes("NZG");
#else
dComIfG_resDelete(&i_this->mPhs, "NZG");
#endif
Comment thread
ThePlayerRolo marked this conversation as resolved.
Outdated
return TRUE;
}

/* 00000508-00000620 .text useHeapInit__FP10fopAc_ac_c */
static BOOL useHeapInit(fopAc_ac_c*) {
/* Nonmatching */
static BOOL useHeapInit(fopAc_ac_c* i_this) {
nzg_class* nzg_this = (nzg_class*)i_this;

mDoMtx_stack_c::transS(nzg_this->current.pos.x, nzg_this->current.pos.y, nzg_this->current.pos.z);
mDoMtx_stack_c::YrotM(nzg_this->shape_angle.y);

J3DModelData* modelData = (J3DModelData*)dComIfG_getObjectRes("NZG", NZG_BDL_KANA_00);
JUT_ASSERT(630, modelData != NULL);
J3DModel* model = mDoExt_J3DModel__create(modelData, 0,0x11020203);

if (model == NULL) {
return FALSE;
}

nzg_this->mpModel = model;
model->setBaseScale(nzg_this->scale);
model->setBaseTRMtx(mDoMtx_stack_c::get());
fopAcM_SetMtx(nzg_this, model->getBaseTRMtx());
return TRUE;
}

/* 00000620-00000864 .text daNZG_Create__FP10fopAc_ac_c */
static cPhs_State daNZG_Create(fopAc_ac_c*) {
/* Nonmatching */
static cPhs_State daNZG_Create(fopAc_ac_c* i_this) {
static dCcD_SrcCyl body_cyl_src = {
// dCcD_SrcGObjInf
{
Expand Down Expand Up @@ -76,6 +178,45 @@ static cPhs_State daNZG_Create(fopAc_ac_c*) {
/* Height */ 20.0f,
}},
};
#if VERSION == VERSION_DEMO
nzg_class* nzg_this = (nzg_class*)i_this;
cPhs_State phase_state = dComIfG_resLoad(&nzg_this->mPhs, "NZG");
if (phase_state == cPhs_COMPLEATE_e) {
fopAcM_SetupActor(nzg_this, nzg_class);
#else
nzg_class* nzg_this = (nzg_class*)i_this;
fopAcM_SetupActor(nzg_this, nzg_class);
cPhs_State phase_state = dComIfG_resLoad(&nzg_this->mPhs, "NZG");
if (phase_state == cPhs_COMPLEATE_e) {
#endif
if (!fopAcM_entrySolidHeap(nzg_this, useHeapInit, 0x680)) {
return cPhs_ERROR_e;
}
nzg_this->m2B8 = fopAcM_GetParam(nzg_this);
nzg_this->m2B9 = fopAcM_GetParam(nzg_this) >> 8;
nzg_this->m2BA = fopAcM_GetParam(nzg_this) >> 16;
nzg_this->m2E9 = fopAcM_GetParam(nzg_this) >> 24;
if (nzg_this->m2E9 != 0xFF) {
nzg_this->mpPath = dPath_GetRoomPath(nzg_this->m2E9, fopAcM_GetRoomNo(nzg_this));
}
nzg_this->shape_angle.y = nzg_this->current.angle.y;
nzg_this->m2CC = nzg_this->m2B8 * 10.0f;
nzg_this->m2C0 = 1;
if (nzg_this->m2B9 != 0) {
nzg_this->m2C0 = nzg_this->m2B9;
}

if (nzg_this->m2BA > 2) {
nzg_this->m2BA = 0;
}
nzg_this->mCyl.Set(body_cyl_src);
nzg_this->mCyl.SetStts(&nzg_this->mStts);
if (nzg_this->m2BA == 0) {
csXyz child_angle = nzg_this->current.angle;
fopAcM_createChild("NpcNz",fpcM_GetID(nzg_this), 0xffffffff, &nzg_this->current.pos, fopAcM_GetRoomNo(nzg_this), &child_angle, &nzg_this->scale, NULL);
}
}
return phase_state;
}

static actor_method_class l_daNZG_Method = {
Expand Down
Loading