mirror of
https://github.com/TwilitRealm/dusklight
synced 2026-05-30 16:35:26 -04:00
56890c32e8
* Consolidate fopAcM_STATUS into fopAc_Status_e * Add _e suffix to fopAcStts enums * Prepare for profile enumeration * Correct typo in scene_process_profile_definition * Manually handle g_profile_Obj_DamCps (inline preprocessing) * Correct g_profile_TAG_LV5SOUP procname to enum * Create d_priority.h * Update process profile definitions * Moved inline comments to the left * Add missing fopAcStts enums * Add d_priority.h include in f_pc_leaf.h * Manually update d_a_obj_damCps profile * Replace fopAcStts enums replacing and anticipatory profile size correction * Changed profile size from literal to sizeof() in anticipation of PR #3116 * Provided putative names to staff-related status enums * Replaced appropriate literals with fopAcStts enums * Fix borked merge * Rename item number enums and move to d_item_data.h * Rename process profile name & draw priority enums * Move process profile name & draw priority enums to appropriate files * Moved fpcNm_ enums from d/d_procname.h to f_pc/f_pc_name.h * Moved fpcDwPi_ enums from d/d_priority.h to f_pc/f_pc_draw_priority.h * ACTUALLY (whoops) stage merge * Correct item mistranslation Co-authored-by: LagoLunatic <LagoLunatic@users.noreply.github.com> --------- Co-authored-by: LagoLunatic <LagoLunatic@users.noreply.github.com>
492 lines
15 KiB
C++
492 lines
15 KiB
C++
/**
|
||
* @file d_a_obj_itamato.cpp
|
||
*
|
||
*/
|
||
|
||
#include "d/dolzel_rel.h" // IWYU pragma: keep
|
||
|
||
#include "d/actor/d_a_obj_itamato.h"
|
||
#include "d/d_cc_d.h"
|
||
#include "d/actor/d_a_npc.h"
|
||
#include "JSystem/JHostIO/JORFile.h"
|
||
#include <cstring>
|
||
|
||
daObj_ItaMato_HIOParam const daObj_ItaMato_Param_c::m = {
|
||
110.0f,
|
||
-3.0f,
|
||
1.0f,
|
||
400.0f,
|
||
20.0f,
|
||
};
|
||
|
||
#if DEBUG
|
||
daObj_ItaMato_HIO_c::daObj_ItaMato_HIO_c() {
|
||
m = daObj_ItaMato_Param_c::m;
|
||
}
|
||
|
||
void daObj_ItaMato_HIO_c::listenPropertyEvent(const JORPropertyEvent* i_event) {
|
||
char buffer[2000];
|
||
size_t len;
|
||
JORReflexible::listenPropertyEvent(i_event);
|
||
JORFile jorFile;
|
||
|
||
switch ((u32)i_event->id) {
|
||
case 0x40000002:
|
||
if (jorFile.open(6, "すべてのファイル(*.*)\0*.*", NULL, NULL, NULL)) {
|
||
memset(buffer, 0, sizeof(buffer));
|
||
len = 0;
|
||
sprintf(buffer + len, "%.3ff,\t// 注目オフセット\n", m.attn_offset);
|
||
len = strlen(buffer);
|
||
sprintf(buffer + len, "%.3ff,\t// 重力\n", m.gravity);
|
||
len = strlen(buffer);
|
||
sprintf(buffer + len, "%.3ff,\t// スケ−ル\n", m.scale);
|
||
len = strlen(buffer);
|
||
sprintf(buffer + len, "%.3ff,\t// リアル影サイズ\n", m.real_shadow_size);
|
||
len = strlen(buffer);
|
||
sprintf(buffer + len, "%.3ff,\t// 揺れパワ−\n", m.shake_pow);
|
||
len = strlen(buffer);
|
||
jorFile.writeData(buffer, len);
|
||
jorFile.close();
|
||
OS_REPORT("write append success!::%6d\n", len);
|
||
} else {
|
||
OS_REPORT("write append failure!\n");
|
||
}
|
||
break;
|
||
}
|
||
}
|
||
|
||
void daObj_ItaMato_HIO_c::genMessage(JORMContext* ctx) {
|
||
ctx->genSlider("注目オフセット ", &m.attn_offset, 0.0f, 1000.0f);
|
||
ctx->genSlider("重力 ", &m.gravity, -100.0f, 100.0f);
|
||
ctx->genSlider("スケ−ル ", &m.scale, 0.0f, 100.0f);
|
||
ctx->genSlider("リアル影サイズ ", &m.real_shadow_size, 0.0f, 10000.0f);
|
||
ctx->genSlider("揺れパワ− ", &m.shake_pow, 0.0f, 90.0f);
|
||
ctx->genButton("ファイル書き出し", 0x40000002);
|
||
}
|
||
#endif
|
||
|
||
static dCcD_SrcGObjInf const l_ccDObjData = {
|
||
{0x0, {{0x0, 0x0, 0x0}, {0xD8FBFDFF, 0x1F}, 0x79}}, // mObj
|
||
{dCcD_SE_NONE, 0x0, 0x0, 0x0, 0x0}, // mGObjAt
|
||
{dCcD_SE_STONE, 0x0, 0x0, 0x0, 0x0}, // mGObjTg
|
||
{0x0}, // mGObjCo
|
||
};
|
||
|
||
static dCcD_SrcSph l_ccDSph = {
|
||
l_ccDObjData,
|
||
{
|
||
{{0.0f, 0.0f, 0.0f}, 0.0f} // mSph
|
||
} // mSphAttr
|
||
};
|
||
|
||
static OBJ_ITAMATO_HIO_CLASS l_HIO;
|
||
|
||
static char* l_resName = "H_ItaMato";
|
||
|
||
daObj_ItaMato_c::~daObj_ItaMato_c() {
|
||
OS_REPORT("|%06d:%x|daObj_ItaMato_c -> デストラクト\n", g_Counter.mCounter0, this);
|
||
|
||
#if DEBUG
|
||
if (mHIO != NULL) {
|
||
mHIO->removeHIO();
|
||
}
|
||
#endif
|
||
|
||
dComIfG_resDelete(&mPhase, getResName());
|
||
}
|
||
|
||
cPhs_Step daObj_ItaMato_c::create() {
|
||
fopAcM_ct(this, daObj_ItaMato_c);
|
||
|
||
mType = getType();
|
||
cPhs_Step phase = dComIfG_resLoad(&mPhase, getResName());
|
||
if (phase == cPhs_COMPLEATE_e) {
|
||
OS_REPORT("\t(%s:%d) no:%d, SWBit:%02x, SWBit2:%02x<%08x> -> roomNo.%d", fopAcM_getProcNameString(this), getType(), getNo(),
|
||
getBitSW(), getBitSW2(), fopAcM_GetParam(this), fopAcM_GetRoomNo(this));
|
||
if (getBitSW() != 0xFF) {
|
||
if (dComIfGs_isSwitch(getBitSW(), fopAcM_GetRoomNo(this))) {
|
||
OS_REPORT("===>isDelete:TRUE\n");
|
||
return cPhs_ERROR_e;
|
||
}
|
||
}
|
||
|
||
OS_REPORT("\n");
|
||
|
||
if (!fopAcM_entrySolidHeap(this, createHeapCallBack, 0x16B0)) {
|
||
return cPhs_ERROR_e;
|
||
}
|
||
|
||
health = 1;
|
||
J3DModelData* modelData = mpModels[health]->getModelData();
|
||
fopAcM_SetMtx(this, mpModels[health]->getBaseTRMtx());
|
||
fopAcM_setCullSizeBox(this, -200.0f, -50.0f, -200.0f, 200.0f, 200.0f, 200.0f);
|
||
|
||
#if DEBUG
|
||
mHIO = &l_HIO;
|
||
mHIO->entryHIO("板的");
|
||
#endif
|
||
|
||
mBgc.Set(fopAcM_GetPosition_p(this), fopAcM_GetOldPosition_p(this), this, 1, &mAcchCir, fopAcM_GetSpeed_p(this), fopAcM_GetAngle_p(this), fopAcM_GetShapeAngle_p(this));
|
||
mStts.Init(0xFF, 0, this);
|
||
mSph.Set(l_ccDSph);
|
||
mSph.SetStts(&mStts);
|
||
mSph.SetTgHitCallback(tgHitCallBack);
|
||
mBgc.CrrPos(dComIfG_Bgsp());
|
||
mGndChk = mBgc.m_gnd;
|
||
mGroundH = mBgc.GetGroundH();
|
||
if (mGroundH != -1e9f) {
|
||
setEnvTevColor();
|
||
setRoomNo();
|
||
}
|
||
|
||
daNpcT_offTmpBit(60); // dSv_event_tmp_flag_c::T_0060 - Kakariko Village - During bow and arrow game
|
||
daNpcT_offTmpBit(63); // dSv_event_tmp_flag_c::T_0063 - Kakariko Village - [Bow and arrow game] Missed the final target!
|
||
daNpcT_offTmpBit(64); // dSv_event_tmp_flag_c::T_0064 - Kakariko Village - [Bow and arrow game] Attempting to hit target...
|
||
daNpcT_offTmpBit(65); // dSv_event_tmp_flag_c::T_0065 - Kakariko Village - [Bow and arrow game] Destroy first one with Clawshot
|
||
daNpcT_offTmpBit(66); // dSv_event_tmp_flag_c::T_0066 - Kakariko Village - [Bow and arrow game] Restart from the middle
|
||
|
||
if (strcmp(dComIfGp_getStartStageName(), "F_SP103") == 0 && dComIfGp_roomControl_getStayNo() == 1) {
|
||
field_0xa18 = 1;
|
||
}
|
||
|
||
Execute();
|
||
}
|
||
|
||
return phase;
|
||
}
|
||
|
||
int daObj_ItaMato_c::CreateHeap() {
|
||
J3DModelData* modelData = NULL;
|
||
modelData = (J3DModelData*)dComIfG_getObjectRes(getResName(), 5);
|
||
if (modelData == NULL) {
|
||
return 0;
|
||
}
|
||
|
||
mpModels[0] = mDoExt_J3DModel__create(modelData, 0x80000, 0x11000084);
|
||
if (mpModels[0] == NULL) {
|
||
return 0;
|
||
}
|
||
|
||
modelData = (J3DModelData*)dComIfG_getObjectRes(getResName(), 4);
|
||
if (modelData == NULL) {
|
||
return 0;
|
||
}
|
||
|
||
mpModels[1] = mDoExt_J3DModel__create(modelData, 0x80000, 0x11000084);
|
||
if (mpModels[1] == NULL) {
|
||
return 0;
|
||
}
|
||
|
||
return 1;
|
||
}
|
||
|
||
int daObj_ItaMato_c::Delete() {
|
||
OS_REPORT("|%06d:%x|daObj_ItaMato_c -> Delete\n", g_Counter.mCounter0, this);
|
||
this->~daObj_ItaMato_c();
|
||
return 1;
|
||
}
|
||
|
||
int daObj_ItaMato_c::Execute() {
|
||
cXyz sp38, sp44, sp50;
|
||
|
||
mStts.Move();
|
||
field_0xa16 = 1;
|
||
|
||
if (field_0xa18 != 0) {
|
||
field_0xa16 = 0;
|
||
} else if (getBitSW2() == 0xFF || (getBitSW2() != 0xFF && dComIfGs_isSwitch(getBitSW2(), fopAcM_GetRoomNo(this)))) {
|
||
field_0xa16 = daNpcT_chkTmpBit(60) == FALSE;
|
||
}
|
||
|
||
attention_info.flags = 0;
|
||
field_0xa15 = 0;
|
||
|
||
if (field_0x9e8 != 0) {
|
||
field_0x9e8--;
|
||
}
|
||
|
||
if (field_0x9e8 == 0 && mSph.ChkTgHit()) {
|
||
setSwayParam(mSph.GetTgHitAc());
|
||
|
||
if (!mSph.GetTgHitObj()->ChkAtType(AT_TYPE_BOOMERANG)) {
|
||
field_0xa15 = 1;
|
||
if (health != 0) {
|
||
health--;
|
||
|
||
if (health < 1) {
|
||
u8 i_no = 4;
|
||
|
||
if (field_0xa18 != 0) {
|
||
if (getBitSW2() != 0xFF) {
|
||
if (!dComIfGs_isSwitch(getBitSW2(), fopAcM_GetRoomNo(this))) {
|
||
dComIfGs_onSwitch(getBitSW2(), fopAcM_GetRoomNo(this));
|
||
}
|
||
}
|
||
|
||
u8 curRegVal = dComIfGs_getTmpReg(0xF4FF);
|
||
curRegVal++;
|
||
dComIfGs_setTmpReg(0xF4FF, curRegVal);
|
||
if (dComIfGp_getAttention()->GetLockonList(0) != NULL) {
|
||
if (dComIfGp_getAttention()->LockonTruth()) {
|
||
if (this == dComIfGp_getAttention()->GetLockonList(0)->getActor()) {
|
||
i_no |= 0x80;
|
||
}
|
||
}
|
||
}
|
||
|
||
dComIfGs_setTmpReg(0xF3FF, i_no);
|
||
} else if (getBitSW() != 0xFF) {
|
||
if (!dComIfGs_isSwitch(getBitSW(), fopAcM_GetRoomNo(this))) {
|
||
dComIfGs_onSwitch(getBitSW(), fopAcM_GetRoomNo(this));
|
||
}
|
||
}
|
||
}
|
||
|
||
fopAcM_seStartCurrent(this, Z2SE_OBJ_ARW_TRGT_BRK, 0);
|
||
setPrtcls();
|
||
mFake = 0;
|
||
}
|
||
}
|
||
}
|
||
|
||
fopAcM_posMoveF(this, mStts.GetCCMoveP());
|
||
mBgc.CrrPos(dComIfG_Bgsp());
|
||
mGndChk = mBgc.m_gnd;
|
||
mGroundH = mBgc.GetGroundH();
|
||
if (mGroundH != -1e9f) {
|
||
setEnvTevColor();
|
||
setRoomNo();
|
||
}
|
||
|
||
for (int i = 0; i < 3; i++) {
|
||
if (field_0xa17 != 0) {
|
||
mDoMtx_stack_c::YrotS(field_0x9fc[i]);
|
||
sp44.set(0.0f, 0.0f, field_0x9f0[i]);
|
||
mDoMtx_stack_c::multVec(&sp44, &sp50);
|
||
field_0x9d0[i].x = sp50.z;
|
||
field_0x9d0[i].z = -sp50.x;
|
||
field_0x9fc[i] -= cM_deg2s(45.0f);
|
||
} else {
|
||
mDoMtx_stack_c::YrotS(field_0xa02);
|
||
sp44.set(0.0f, 0.0f, field_0x9f0[i] * cM_ssin(field_0x9fc[i]));
|
||
mDoMtx_stack_c::multVec(&sp44, &sp50);
|
||
field_0x9d0[i].x = sp50.z;
|
||
field_0x9d0[i].z = -sp50.x;
|
||
field_0x9fc[i] += cM_deg2s(45.0f);
|
||
}
|
||
}
|
||
|
||
cLib_addCalc2(&field_0x9f0[0], 0.0f, 0.075f, 50.0f);
|
||
cLib_addCalc2(&field_0x9f0[1], 0.0f, 0.1f, 100.0f);
|
||
cLib_addCalc2(&field_0x9f0[2], 0.0f, 0.125f, 125.0f);
|
||
setMtx();
|
||
attention_info.position = current.pos;
|
||
attention_info.position.y += mHIO->m.attn_offset;
|
||
eyePos = attention_info.position;
|
||
|
||
if (field_0xa16 == 0) {
|
||
u32 tgType = 0xD8FBFDFF;
|
||
sp38 = current.pos;
|
||
|
||
if (health == 0) {
|
||
mSph.OffTgSetBit();
|
||
sp38.y += 10.0f;
|
||
mSph.SetC(sp38);
|
||
mSph.SetR(10.0f);
|
||
} else {
|
||
if (daNpcT_chkTmpBit(60) && !mFake) {
|
||
tgType = 0xD8FBDDFF;
|
||
}
|
||
|
||
mSph.SetTgType(tgType);
|
||
|
||
if (mFake) {
|
||
mSph.SetR(100.0f);
|
||
} else {
|
||
mSph.SetR(60.0f);
|
||
}
|
||
|
||
sp38.y += 110.0f;
|
||
mSph.SetC(sp38);
|
||
}
|
||
|
||
dComIfG_Ccsp()->Set(&mSph);
|
||
}
|
||
|
||
mSph.ClrCoHit();
|
||
mSph.ClrTgHit();
|
||
|
||
return 1;
|
||
}
|
||
|
||
int daObj_ItaMato_c::Draw() {
|
||
if (field_0xa16 == 0 && (field_0xa18 == 0 || health != 0)) {
|
||
g_env_light.settingTevStruct(0, ¤t.pos, &tevStr);
|
||
|
||
if (field_0xa18 != 0) {
|
||
g_env_light.setLightTevColorType_MAJI(mpModels[1], &tevStr);
|
||
mpModels[1]->getModelData()->getMaterialNodePointer(0)->getShape()->hide();
|
||
mDoExt_modelUpdateDL(mpModels[1]);
|
||
mpModels[1]->getModelData()->getMaterialNodePointer(0)->getShape()->show();
|
||
} else {
|
||
g_env_light.setLightTevColorType_MAJI(mpModels[health], &tevStr);
|
||
mDoExt_modelUpdateDL(mpModels[health]);
|
||
}
|
||
|
||
if (field_0xa18 == 0 && mGroundH != -1e9f) {
|
||
mShadowKey = dComIfGd_setShadow(mShadowKey, 1, mpModels[health], ¤t.pos, 400.0f, 20.0f,
|
||
current.pos.y, mGroundH, mGndChk, &tevStr, 0, 1.0f,
|
||
dDlst_shadowControl_c::getSimpleTex());
|
||
}
|
||
}
|
||
|
||
return 1;
|
||
}
|
||
|
||
int daObj_ItaMato_c::createHeapCallBack(fopAc_ac_c* a_this) {
|
||
daObj_ItaMato_c* i_this = (daObj_ItaMato_c*)a_this;
|
||
return i_this->CreateHeap();
|
||
}
|
||
|
||
void daObj_ItaMato_c::tgHitCallBack(fopAc_ac_c* param_1, dCcD_GObjInf* param_2, fopAc_ac_c* param_3, dCcD_GObjInf* param_4) {
|
||
daObj_ItaMato_c* i_this = (daObj_ItaMato_c*)param_1;
|
||
u8 cutType = 0;
|
||
|
||
if (param_3 != NULL) {
|
||
if (fopAcM_GetProfName(param_3) == fpcNm_ALINK_e) {
|
||
cutType = ((daPy_py_c*)param_3)->getCutType();
|
||
} else {
|
||
cutType = daPy_py_c::CUT_TYPE_NM_VERTICAL;
|
||
}
|
||
}
|
||
|
||
i_this->setCutType(cutType);
|
||
}
|
||
|
||
const char* daObj_ItaMato_c::getResName() {
|
||
return l_resName;
|
||
}
|
||
|
||
void daObj_ItaMato_c::setSwayParam(fopAc_ac_c* i_actor) {
|
||
f32 fVar1 = 1.0f;
|
||
f32 fVar2[3] = {0.0f, 0.0f, mHIO->m.shake_pow};
|
||
|
||
field_0xa02 = fopAcM_searchActorAngleY(this, i_actor) - shape_angle.y + 0x8000;
|
||
field_0x9e8 = 8;
|
||
field_0xa17 = 0;
|
||
|
||
if (fopAcM_GetProfName(i_actor) == fpcNm_ALINK_e) {
|
||
switch (mCutType) {
|
||
case 3:
|
||
case 4:
|
||
case 6:
|
||
case 7:
|
||
if (mCutType == 3) {
|
||
ANGLE_SUB(field_0xa02, 0x4000);
|
||
}
|
||
|
||
if (mCutType == 4) {
|
||
ANGLE_ADD(field_0xa02, 0x4000);
|
||
}
|
||
|
||
fVar1 = 0.6f;
|
||
break;
|
||
|
||
case 8:
|
||
field_0x9e8 = 20;
|
||
field_0xa17 = 1;
|
||
break;
|
||
|
||
case 5:
|
||
default:
|
||
fVar1 = 0.6f;
|
||
break;
|
||
}
|
||
} else {
|
||
fVar1 = 0.6f;
|
||
}
|
||
|
||
for (int i = 0; i < 3; i++) {
|
||
field_0x9f0[i] = fVar1 * cM_deg2s(fVar2[i]);
|
||
field_0x9fc[i] = 0x4000;
|
||
}
|
||
}
|
||
|
||
void daObj_ItaMato_c::setPrtcls() {
|
||
static u16 const id[3] = {
|
||
dPa_RM(ID_ZF_S_ITAMATO_BOAD00),
|
||
dPa_RM(ID_ZF_S_ITAMATO_BOAD01),
|
||
dPa_RM(ID_ZF_S_ITAMATO_SMK),
|
||
};
|
||
|
||
for (int i = 0; i < 3; i++) {
|
||
mPrtcls[i] = dComIfGp_particle_set(mPrtcls[i], id[i], ¤t.pos, &shape_angle, NULL);
|
||
dComIfGp_particle_levelEmitterOnEventMove(mPrtcls[i]);
|
||
}
|
||
}
|
||
|
||
void daObj_ItaMato_c::setEnvTevColor() {
|
||
tevStr.YukaCol = dComIfG_Bgsp().GetPolyColor(mGndChk);
|
||
tevStr.room_no = dComIfG_Bgsp().GetRoomId(mGndChk);
|
||
}
|
||
|
||
void daObj_ItaMato_c::setRoomNo() {
|
||
s8 id = dComIfG_Bgsp().GetRoomId(mGndChk);
|
||
fopAcM_SetRoomNo(this, id);
|
||
mStts.SetRoomId(id);
|
||
}
|
||
|
||
void daObj_ItaMato_c::setMtx() {
|
||
mDoMtx_stack_c::transS(current.pos.x, current.pos.y, current.pos.z);
|
||
mDoMtx_stack_c::ZXYrotM(shape_angle);
|
||
mDoMtx_stack_c::XrotM(field_0x9d0[2].x);
|
||
mDoMtx_stack_c::ZrotM(field_0x9d0[2].z);
|
||
mDoMtx_stack_c::scaleM(scale);
|
||
mpModels[health]->setBaseTRMtx(mDoMtx_stack_c::get());
|
||
}
|
||
|
||
static int daObj_ItaMato_Create(void* a_this) {
|
||
return static_cast<daObj_ItaMato_c*>(a_this)->create();
|
||
}
|
||
|
||
static int daObj_ItaMato_Delete(void* a_this) {
|
||
return static_cast<daObj_ItaMato_c*>(a_this)->Delete();
|
||
}
|
||
|
||
static int daObj_ItaMato_Execute(void* a_this) {
|
||
return static_cast<daObj_ItaMato_c*>(a_this)->Execute();
|
||
}
|
||
|
||
static int daObj_ItaMato_Draw(void* a_this) {
|
||
return static_cast<daObj_ItaMato_c*>(a_this)->Draw();
|
||
}
|
||
|
||
static int daObj_ItaMato_IsDelete(void* a_this) {
|
||
return 1;
|
||
}
|
||
|
||
static actor_method_class daObj_ItaMato_MethodTable = {
|
||
(process_method_func)daObj_ItaMato_Create,
|
||
(process_method_func)daObj_ItaMato_Delete,
|
||
(process_method_func)daObj_ItaMato_Execute,
|
||
(process_method_func)daObj_ItaMato_IsDelete,
|
||
(process_method_func)daObj_ItaMato_Draw,
|
||
};
|
||
|
||
actor_process_profile_definition g_profile_OBJ_ITAMATO = {
|
||
/* Layer ID */ fpcLy_CURRENT_e,
|
||
/* List ID */ 7,
|
||
/* List Prio */ fpcPi_CURRENT_e,
|
||
/* Proc Name */ fpcNm_OBJ_ITAMATO_e,
|
||
/* Proc SubMtd */ &g_fpcLf_Method.base,
|
||
/* Size */ sizeof(daObj_ItaMato_c),
|
||
/* Size Other */ 0,
|
||
/* Parameters */ 0,
|
||
/* Leaf SubMtd */ &g_fopAc_Method.base,
|
||
/* Draw Prio */ fpcDwPi_OBJ_ITAMATO_e,
|
||
/* Actor SubMtd */ &daObj_ItaMato_MethodTable,
|
||
/* Status */ fopAcStts_UNK_0x40000_e | fopAcStts_UNK_0x4000_e | fopAcStts_CULL_e,
|
||
/* Group */ fopAc_ACTOR_e,
|
||
/* Cull Type */ fopAc_CULLBOX_CUSTOM_e,
|
||
};
|