From ac8c73be0b0e34096a0ed5f1ec385c92db66dcd3 Mon Sep 17 00:00:00 2001 From: Vi Date: Fri, 16 May 2025 00:15:19 -0500 Subject: [PATCH] Implement and link ac_npc_majin5.c --- configure.py | 2 +- include/ac_npc_majin5.h | 10 ++ src/actor/npc/ac_npc_majin5.c | 136 +++++++++++++++++++++ src/actor/npc/ac_npc_majin5_schedule.c_inc | 47 +++++++ 4 files changed, 194 insertions(+), 1 deletion(-) create mode 100644 src/actor/npc/ac_npc_majin5.c create mode 100644 src/actor/npc/ac_npc_majin5_schedule.c_inc diff --git a/configure.py b/configure.py index dcf6bb4d..32671411 100644 --- a/configure.py +++ b/configure.py @@ -1121,7 +1121,7 @@ config.libs = [ Object(NonMatching, "actor/npc/ac_npc_majin2.c"), Object(NonMatching, "actor/npc/ac_npc_majin3.c"), Object(NonMatching, "actor/npc/ac_npc_majin4.c"), - Object(NonMatching, "actor/npc/ac_npc_majin5.c"), + Object(Matching, "actor/npc/ac_npc_majin5.c"), Object(Matching, "actor/npc/ac_npc_mamedanuki.c"), Object(Matching, "actor/npc/ac_npc_mask_cat.c"), Object(NonMatching, "actor/npc/ac_npc_mask_cat2.c"), diff --git a/include/ac_npc_majin5.h b/include/ac_npc_majin5.h index b92bba8b..153956fd 100644 --- a/include/ac_npc_majin5.h +++ b/include/ac_npc_majin5.h @@ -1,14 +1,24 @@ #ifndef AC_NPC_MAJIN5_H #define AC_NPC_MAJIN5_H +#include "ac_npc.h" #include "types.h" #include "m_actor.h" #ifdef __cplusplus extern "C" { #endif +#define ANMJ5_THINK_INIT 0 +#define ANMJ5_THINK_MAIN 1 +#define ANMJ5_SCHEDULE_INIT 0 +#define ANMJ5_SCHEDULE_MAIN 1 +typedef struct npc_majin5_s NPC_MAJIN5_ACTOR; extern ACTOR_PROFILE Npc_Majin5_Profile; +/* sizeof(npc_majin5_s) == 0x994*/ +struct npc_majin5_s { + /* 0x000 */ NPC_ACTOR npc_class; +}; #ifdef __cplusplus } diff --git a/src/actor/npc/ac_npc_majin5.c b/src/actor/npc/ac_npc_majin5.c new file mode 100644 index 00000000..5b811ac1 --- /dev/null +++ b/src/actor/npc/ac_npc_majin5.c @@ -0,0 +1,136 @@ +#include "ac_npc_majin5.h" + +#include "ac_npc.h" +#include "ac_npc_h.h" +#include "ac_quest_manager.h" +#include "ac_quest_manager_clip.h" +#include "dolphin/os/OSRtc.h" +#include "libc64/qrand.h" +#include "libultra/libultra.h" +#include "m_actor.h" +#include "m_actor_type.h" +#include "m_bgm.h" +#include "m_card.h" +#include "m_choice.h" +#include "m_common_data.h" +#include "m_config.h" +#include "m_demo.h" +#include "m_lib.h" +#include "m_msg.h" +#include "m_npc.h" +#include "m_play.h" +#include "m_play_h.h" +#include "m_player.h" +#include "m_player_lib.h" +#include "m_room_type.h" +#include "m_soncho.h" +#include "m_vibctl.h" +#include "types.h" + +static void aNMJ5_actor_ct(ACTOR* actorx, GAME* game); +static void aNMJ5_actor_save(ACTOR* actorx, GAME* game); +static void aNMJ5_actor_dt(ACTOR* actorx, GAME* game); +static void aNMJ5_actor_init(ACTOR* actorx, GAME* game); +static int aNMJ5_set_request_act(NPC_MAJIN5_ACTOR* actorx, u8 prio, u8 idx, u8 type, u16 obj, s16 move_x, s16 move_z); +static void aNMJ5_actor_move(ACTOR* actorx, GAME* game); +static void aNMJ5_actor_draw(ACTOR* actorx, GAME* game); + +static void aNMJ5_think_main_proc(NPC_ACTOR* actorx, GAME_PLAY* play); +static void aNMJ5_think_init_proc(NPC_ACTOR* actorx, GAME_PLAY* play); +static void aNMJ5_think_proc(NPC_ACTOR* actorx, GAME_PLAY* play, int think_proc_idx); +static void aNMJ5_schedule_init_proc(NPC_ACTOR* actorx, GAME_PLAY* play); +static void aNMJ5_schedule_main_proc(NPC_ACTOR* actorx, GAME_PLAY* play); +static void aNMJ5_schedule_proc(NPC_ACTOR* actorx, GAME_PLAY* play, int sche_proc_idx); +// clang-format off +ACTOR_PROFILE Npc_Majin5_Profile = { + mAc_PROFILE_NPC_MAJIN5, + ACTOR_PART_NPC, + ACTOR_STATE_NONE, + SP_NPC_MAJIN5, + ACTOR_OBJ_BANK_KEEP, + sizeof(NPC_MAJIN5_ACTOR), + aNMJ5_actor_ct, + aNMJ5_actor_dt, + aNMJ5_actor_init, + mActor_NONE_PROC1, + aNMJ5_actor_save, +}; +// clang-format on +static void aNMJ5_actor_ct(ACTOR* actorx, GAME* game) { + NPC_MAJIN5_ACTOR* majin5_actor = (NPC_MAJIN5_ACTOR*)actorx; + // clang-format off + static aNPC_ct_data_c ct_data = { + &aNMJ5_actor_move, + &aNMJ5_actor_draw, + aNPC_CT_SCHED_TYPE_SPECIAL, + NULL, + NULL, + NULL, + 0, + }; + // clang-format on + if (NPC_CLIP->birth_check_proc(actorx, game) == TRUE) { + majin5_actor->npc_class.schedule.schedule_proc = &aNMJ5_schedule_proc; + NPC_CLIP->ct_proc(actorx, game, &ct_data); + majin5_actor->npc_class.right_hand.umbrella_disabled_flag = TRUE; + majin5_actor->npc_class.palActorIgnoreTimer = -1; + majin5_actor->npc_class.collision.check_kind = aNPC_BG_CHECK_TYPE_NONE; + majin5_actor->npc_class.condition_info.demo_flg = -1; + majin5_actor->npc_class.actor_class.world.position.x = + majin5_actor->npc_class.actor_class.home.position.x - 80.0f; + majin5_actor->npc_class.actor_class.world.position.z = + majin5_actor->npc_class.actor_class.home.position.z + 480.0f; + + CLIP(effect_clip) + ->effect_make_proc(eEC_EFFECT_RESET_HOLE, majin5_actor->npc_class.actor_class.world.position, 3, 31000, + game, -1, 0, 0); + } +} + +static void aNMJ5_actor_save(ACTOR* actorx, GAME* game) { + mNpc_RenewalSetNpc(actorx); +} + +static void aNMJ5_actor_dt(ACTOR* actorx, GAME* game) { + NPC_CLIP->dt_proc(actorx, game); + CLIP(effect_clip)->effect_kill_proc(eEC_EFFECT_RESET_HOLE, -1); +} + +static void aNMJ5_actor_init(ACTOR* actorx, GAME* game) { + NPC_CLIP->init_proc(actorx, game); +} + +static int aNMJ5_set_request_act(NPC_MAJIN5_ACTOR* actorx, u8 prio, u8 idx, u8 type, u16 obj, s16 move_x, s16 move_z) { + BOOL res = FALSE; + if (prio >= actorx->npc_class.request.act_priority) { + u16 args[aNPC_REQUEST_ARG_NUM]; + bzero(args, sizeof(args)); + args[0] = obj; + args[2] = move_x; + args[3] = move_z; + actorx->npc_class.request.act_priority = prio; + actorx->npc_class.request.act_idx = idx; + actorx->npc_class.request.act_type = type; + mem_copy((u8*)actorx->npc_class.request.act_args, (u8*)args, sizeof(args)); + res = TRUE; + } + return res; +} + +static void aNMJ5_actor_move(ACTOR* actorx, GAME* game) { + aNTT_event_save_c* save_area; + save_area = (aNTT_event_save_c*)mEv_get_save_area(mEv_EVENT_KK_SLIDER, 10); + NPC_CLIP->move_proc(actorx, game); + actorx->shape_info.rotation.y = 31000; + if ((save_area != NULL) && (save_area->bitfield & aNTT_FLAG_SP_DELETE_MAJIN)) { + save_area->bitfield &= ~aNTT_FLAG_SP_DELETE_MAJIN; + Actor_delete(actorx); + } + actorx->shape_info.draw_shadow = FALSE; +} + +static void aNMJ5_actor_draw(ACTOR* actorx, GAME* game) { + NPC_CLIP->draw_proc(actorx, game); +} + +#include "../src/actor/npc/ac_npc_majin5_schedule.c_inc" diff --git a/src/actor/npc/ac_npc_majin5_schedule.c_inc b/src/actor/npc/ac_npc_majin5_schedule.c_inc new file mode 100644 index 00000000..85c8b3c7 --- /dev/null +++ b/src/actor/npc/ac_npc_majin5_schedule.c_inc @@ -0,0 +1,47 @@ +static void aNMJ5_think_main_proc(NPC_ACTOR* actorx, GAME_PLAY* play) { + return; +} + +static void aNMJ5_think_init_proc(NPC_ACTOR* actorx, GAME_PLAY* play) { + NPC_MAJIN5_ACTOR* majin = (NPC_MAJIN5_ACTOR*)actorx; + + majin->npc_class.actor_class.status_data.weight = MASSTYPE_HEAVY; + actorx->condition_info.hide_request = FALSE; + actorx->action.idx = aNPC_ACT_WAIT; + aNMJ5_set_request_act(majin, 4, aNPC_ACT_WAIT, aNPC_ACT_TYPE_DEFAULT, aNPC_ACT_OBJ_DEFAULT, 0, 0); + NPC_CLIP->animation_init_proc((ACTOR*)majin, aNPC_ANIM_WAIT_R1, FALSE); + actorx->draw.main_animation.keyframe.frame_control.mode = cKF_FRAMECONTROL_REPEAT; +} + +static void aNMJ5_think_proc(NPC_ACTOR* actorx, GAME_PLAY* play, int think_proc_idx) { + switch (think_proc_idx) { + case ANMJ5_THINK_INIT: + aNMJ5_think_init_proc(actorx, play); + break; + case ANMJ5_THINK_MAIN: + aNMJ5_think_main_proc(actorx, play); + break; + } +} + +static void aNMJ5_schedule_init_proc(NPC_ACTOR* actorx, GAME_PLAY* play) { + actorx->think.think_proc = aNMJ5_think_proc; + NPC_CLIP->think_proc(actorx, play, 9, aNPC_THINK_TYPE_INIT); +} + +static void aNMJ5_schedule_main_proc(NPC_ACTOR* actorx, GAME_PLAY* play) { + if (NPC_CLIP->think_proc(actorx, play, -1, aNPC_THINK_TYPE_CHK_INTERRUPT) == FALSE) { + NPC_CLIP->think_proc(actorx, play, -1, aNPC_THINK_TYPE_MAIN); + } +} + +static void aNMJ5_schedule_proc(NPC_ACTOR* actorx, GAME_PLAY* play, int sched_idx) { + switch (sched_idx) { + case ANMJ5_SCHEDULE_INIT: + aNMJ5_schedule_init_proc(actorx, play); + break; + case ANMJ5_SCHEDULE_MAIN: + aNMJ5_schedule_main_proc(actorx, play); + break; + } +}