Skip to content

Commit

Permalink
d_a_bk work
Browse files Browse the repository at this point in the history
  • Loading branch information
LagoLunatic committed Jul 15, 2024
1 parent 23484e2 commit c98c930
Show file tree
Hide file tree
Showing 3 changed files with 132 additions and 6 deletions.
3 changes: 2 additions & 1 deletion include/d/actor/d_a_bk.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@ class bk_class : public fopEn_enemy_c {
/* 0x1190 */ cXyz m1190;
/* 0x119C */ cXyz m119C;
/* 0x11A8 */ cXyz m11A8;
/* 0x11B4 */ u8 m11B4[0x11CC - 0x11B4];
/* 0x11B4 */ u8 m11B4[0x11C0 - 0x11B4];
/* 0x11C0 */ cXyz m11C0;
/* 0x11CC */ cXyz m11CC;
/* 0x11D8 */ u8 m11D8[0x11F0 - 0x11D8];
/* 0x11F0 */ u8 m11F0;
Expand Down
2 changes: 1 addition & 1 deletion src/JSystem/JStudio/JStudio_JAudio/object-sound.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ void TAdaptor_sound::adaptor_do_update(const JStudio::TObject* object, u32) {
adaptor_getVariableValue_Vec(r30, sauVariableValue_3_POSITION_XYZ);
if (control->mTransformOnSet) {
Vec temp;
PSMTXMultVec(control->mTransformOnSet_Matrix, r30, &temp);
MTXMultVec(control->mTransformOnSet_Matrix, r30, &temp);
*r30 = temp;
}
}
Expand Down
133 changes: 129 additions & 4 deletions src/d/actor/d_a_bk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ static Vec dummy_2080 = {1.0f, 1.0f, 1.0f};
static u8 dummy_1811[] = {0x02, 0x00, 0x02, 0x01};
static f64 dummy4[2] = {3.0, 0.5};

static int bk_at_kind[] = { 0, 1, 0 };
static dCcG_At_Spl bk_at_kind[] = { dCcG_At_Spl_UNK0, dCcG_At_Spl_UNK1, dCcG_At_Spl_UNK0 };
static int bk_attack_ready_SE[] = { JA_SE_CV_BK_KAMAE, JA_SE_CV_BK_KAMAE, -0xDCF }; // TODO what is -0xDCF?
static int bk_attack_go_SE[] = { JA_SE_CV_BK_ATTACK_S, JA_SE_CV_BK_ATTACK_L, -0xDCF }; // TODO what is -0xDCF?
static int bk_attack_AP[] = { 1, 2, 1 };
Expand Down Expand Up @@ -1607,7 +1607,95 @@ static void stand2(bk_class* i_this) {

/* 00005D40-00006218 .text path_run__FP8bk_class */
static void path_run(bk_class* i_this) {
/* Nonmatching */
i_this->dr.m710 = 0;

switch (i_this->dr.m004) {
case 0:
anm_init(i_this, BK_BCK_BK_RUN, 10.0f, J3DFrameCtrl::LOOP_REPEAT_e, l_bkHIO.m070, BK_BAS_BK_RUN);
i_this->dr.m004 = 1;
// Fall-through
case 1:
dPath__Point* point = &i_this->ppd->mpPnt[i_this->m1216];
f32 x = point->mPos.x + i_this->m0320.x;
f32 z = point->mPos.z + i_this->m0320.z;
cXyz sp0C;
sp0C.x = x - i_this->current.pos.x;
sp0C.z = z - i_this->current.pos.z;
i_this->dr.m4D0 = cM_atan2s(sp0C.x, sp0C.z);

if (sqrtf(sp0C.x*sp0C.x + sp0C.z*sp0C.z) < 100.0f) {
i_this->m1216 += i_this->m1217;
if (i_this->m1216 >= (s8)i_this->ppd->m_num) {
i_this->m1216 = i_this->ppd->m_num - 1;
i_this->m1217 = -1;
i_this->m121C = 1;
} else if (i_this->m1216 < 0) {
i_this->m1216 = 0;
i_this->m1217 = 1;
i_this->m121C = 1;
}
}

if (i_this->m0300[1] == 0) {
i_this->m0300[1] = cM_rndF(50.0f) + 30.0f;
i_this->m0320.x = cM_rndFX(50.0f);
i_this->m0320.z = cM_rndFX(50.0f);
}

if (i_this->dr.mAcch.ChkGroundHit()) {
s16 maxStep = 0x600;
if (i_this->m120C != 0) {
maxStep = 0x2000;
}
cLib_addCalcAngleS2(&i_this->current.angle.y, i_this->dr.m4D0, 4, maxStep);
}

if (i_this->m120C == 0) {
i_this->speedF = l_bkHIO.m054;
if (i_this->m0300[2] == 0) {
i_this->m0300[2] = cM_rndF(100.0f) + 50.0f;
anm_init(i_this, BK_BCK_BK_JUMP1, 2.0f, J3DFrameCtrl::LOOP_ONCE_e, 1.0f, BK_BAS_BK_JUMP1);
i_this->m120C = 1;
i_this->m1210 = 0;
}
} else {
switch (i_this->m1210) {
case 0:
i_this->speedF = l_bkHIO.m054 * 1.2f;
if (i_this->dr.mAcch.ChkGroundHit() && i_this->mpMorf->isStop()) {
anm_init(i_this, BK_BCK_BK_JUMP2, 0.0f, J3DFrameCtrl::LOOP_ONCE_e, 1.0f, BK_BAS_BK_JUMP2);
i_this->m1210 = 1;
i_this->m034C = l_bkHIO.m00C + 2;
i_this->m034E = 4;
}
break;
case 1:
i_this->speedF = 0.0f;
if (i_this->dr.mAcch.ChkGroundHit() && i_this->mpMorf->isStop()) {
i_this->m1210 = 0;
anm_init(i_this, BK_BCK_BK_JUMP1, 2.0f, J3DFrameCtrl::LOOP_ONCE_e, 1.0f, BK_BAS_BK_JUMP1);
i_this->speed.y = cM_rndF(REG8_F(7) + 10.0f) + 65.0f + REG8_F(8);
fopAcM_monsSeStart(i_this, JA_SE_CV_BK_JUMP, 0);
}

if (i_this->m0300[2] == 0) {
i_this->m0300[2] = cM_rndF(100.0f) + 50.0f;
anm_init(i_this, BK_BCK_BK_RUN, 10.0f, J3DFrameCtrl::LOOP_REPEAT_e, l_bkHIO.m070, BK_BAS_BK_RUN);
i_this->m120C = 0;
}
break;
}
}
break;
}

if (i_this->mPlayerDistance < l_bkHIO.m028 &&
daBk_player_view_check(i_this, &i_this->dr.m714->current.pos, i_this->m0332, l_bkHIO.m034)
) {
i_this->dr.mState = 4;
i_this->m0300[1] = 0;
i_this->dr.m004 = 0;
}
}

/* 00006218-0000647C .text attack_set__FP8bk_classUc */
Expand Down Expand Up @@ -2008,8 +2096,45 @@ static void fight_run(bk_class* i_this) {
}

/* 000073B8-000075E8 .text yari_hit_check__FP8bk_class */
static void yari_hit_check(bk_class* i_this) {
/* Nonmatching */
static fopAc_ac_c* yari_hit_check(bk_class* i_this) {
i_this->m11F0 = 0;
i_this->m11C0 = i_this->m11A8;
if (i_this->m0B7A < 0) { return NULL; }

if (i_this->m0B5C == 2) {
i_this->m11A8 = i_this->dr.m100[0xE];
} else {
i_this->m11A8 = i_this->m1178;
}

if (i_this->m0B78 != 0) { return NULL; }
if (i_this->m0B64 < i_this->m0B68 || i_this->m0B64 > i_this->m0B6C) { return NULL; }

i_this->m11F0 <<= 1;
i_this->m1040.SetAtSpl(bk_at_kind[i_this->m0B5C]);
if ((int)i_this->m0B64 == (int)i_this->m0B68 && bk_attack_go_SE[i_this->m0B5C] != -0xDCF) {
fopAcM_monsSeStart(i_this, bk_attack_go_SE[i_this->m0B5C], 0);
}

if (i_this->m11F1 == 0) {
i_this->m1040.StartCAt(i_this->m11A8);
i_this->m11F1 += 1;
} else {
i_this->m1040.MoveCAt(i_this->m11A8);
dComIfG_Ccsp()->Set(&i_this->m1040);
if (i_this->m02D5 != 0) {
// Using the dComIfG_Ccsp inline here breaks the match.
// dComIfG_Ccsp()->SetMass(&i_this->m1040, 3);
g_dComIfG_gameInfo.play.mCcS.SetMass(&i_this->m1040, 3);
}
if (i_this->m1040.ChkAtHit()) {
i_this->m0B78 = 5;
cCcD_Obj* hitObj = i_this->m1040.GetAtHitObj();
return hitObj->GetAc();
}
}

return NULL;
}

/* 000075E8-00007EF4 .text fight__FP8bk_class */
Expand Down

0 comments on commit c98c930

Please sign in to comment.