Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement & link ac_npc_totakeke.c #457

Merged
merged 2 commits into from
Jan 6, 2025
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -1135,7 +1135,7 @@ def MatchingFor(*versions):
Object(NonMatching, "actor/npc/ac_npc_soncho.c"),
Object(NonMatching, "actor/npc/ac_npc_station_master.c"),
Object(Matching, "actor/npc/ac_npc_super_master.c"),
Object(NonMatching, "actor/npc/ac_npc_totakeke.c"),
Object(Matching, "actor/npc/ac_npc_totakeke.c"),
Object(NonMatching, "actor/npc/ac_present_npc.c"),
Object(NonMatching, "actor/npc/ac_taisou_npc0.c"),
Object(NonMatching, "actor/npc/ac_tamaire_npc0.c"),
Expand Down
128 changes: 127 additions & 1 deletion include/ac_npc_totakeke.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,142 @@

#include "types.h"
#include "m_actor.h"
#include "ac_npc.h"

#ifdef __cplusplus
extern "C" {
#endif

extern ACTOR_PROFILE Npc_Totakeke_Profile;

#define aNTT_REQUEST_STR_LEN 10

typedef struct npc_totakeke_s NPC_TOTAKEKE_ACTOR;
typedef struct npc_totakeke_clip_s aNTT_Clip_c;
typedef struct npc_totakeke_think_data_s aNTT_think_data_c;
typedef struct npc_totakeke_event_save_s aNTT_event_save_c;
typedef struct npc_totakeke_event_common_s aNTT_event_common_c;

typedef void (*aNTTrequest_str_PROC)(GAME*, s16, u8);
typedef void (*aNTT_08_PROC)(NPC_TOTAKEKE_ACTOR*, GAME_PLAY*, u8);
typedef void (*aNTT_0C_PROC)(NPC_TOTAKEKE_ACTOR*, GAME_PLAY*, int);
typedef int (*aNTT_10_PROC)(int);
typedef u8 (*aNTT_14_PROC)(NPC_TOTAKEKE_ACTOR*);
typedef void (*aNTT_1C_PROC)(NPC_TOTAKEKE_ACTOR*);
typedef void (*aNTT_20_PROC)(int, u8);
typedef void (*aNTT_24_PROC)();
typedef u8 (*aNTT_PICK_SONG_PROC)();
typedef void (*aNTT_2C_PROC)(int);

typedef void (*aNTT_PROC)(NPC_TOTAKEKE_ACTOR* totakeke, GAME_PLAY* play);

struct npc_totakeke_s {
/* 0x000 */ NPC_ACTOR npc_class;
/* 0x994 */ aNTT_PROC proc;
/* 0x998 */ s16 roll2_count;
/* 0x99a */ s16 roll4_count;
/* 0x99c */ u16 _99c;
/* 0x99e */ u8 song;
/* 0x99f */ u8 _99f;
/* 0x9a0 */ u8 _9a0;
/* 0x9a1 */ u8 _9a1;
/* 0x9a2 */ u8 _9a2;
/* 0x9a3 */ u8 talk;
/* 0x9a4 */ u8 think;
/* 0x9a5 */ u8 pre_roll_think;
/* 0x9a6 */ u8 post_roll_think;
/* 0x9a7 */ u8 melody_inst;
/* 0x9a8 */ u8 think_proc_id;
/* 0x9a9 */ u8 _9a9;
/* 0x9ac */ u8 _9aa;
/* 0x9ac */ u8 _9ab;
};

struct npc_totakeke_clip_s {
/* 0x000 */ int _00;
/* 0x004 */ aNTTrequest_str_PROC _04;
/* 0x008 */ aNTT_08_PROC _08;
/* 0x00c */ aNTT_0C_PROC _0C;
/* 0x010 */ aNTT_10_PROC _10;
/* 0x014 */ aNTT_14_PROC _14;
/* 0x018 */ aNTT_PROC _18;
/* 0x01c */ aNTT_1C_PROC _1c;
/* 0x020 */ aNTT_20_PROC _20;
/* 0x024 */ aNTT_24_PROC _24;
/* 0x028 */ aNTT_PICK_SONG_PROC pick_song;
/* 0x02c */ aNTT_2C_PROC _2c;
};

struct npc_totakeke_think_data_s {
/* 0x00 */ u8 think_proc_id;
/* 0x01 */ u8 _01;
/* 0x02 */ u8 next_talk;
/* 0x03 */ u8 talk;
/* 0x04 */ u8 pre_roll_think;
};

#define aNTT_FLAG_0 1
#define aNTT_FLAG_AIRCHECK_RECEIVED 1 << 4

struct npc_totakeke_event_save_s {
/* 0x00 */ u8 _00;
/* 0x01 */ u8 _01;
/* 0x01 */ u16 bitfield;
/* 0x04 */ u8 request_str[aNTT_REQUEST_STR_LEN];
/* 0x0e */ u8 _0e;
/* 0x0f */ u8 _0f;
/* 0x10 */ u8 _10;
/* 0x11 */ u8 _11;
/* 0x12 */ u8 _12;
/* 0x13 */ u8 _13;
/* 0x14 */ u8 _14;
/* 0x15 */ u8 _15;
};

struct npc_totakeke_event_common_s {
/* 0x00 */ u16 foreigner_bitfield;
/* 0x02 */ u16 _02;
/* 0x04 */ u8 request_str;
/* 0x05 */ u16 _05;
/* 0x07 */ u8 _07;
/* 0x08 */ u8 _08;
/* 0x09 */ u8 _09;
/* 0x0a */ u8 _0a;
/* 0x0b */ u8 _0b;
/* 0x0c */ u8 _0c;
/* 0x0d */ u8 _0d;
/* 0x0e */ u8 _0e;
/* 0x0f */ u8 _0f;
};

enum aNTT_talk_proc {
aNTT_TALK_NONE,
aNTT_TALK_SELECT0,
aNTT_TALK_SELECT1,
aNTT_TALK_STOP_PLAYER,
aNTT_TALK_SUBMENU,
aNTT_TALK_SUBMENU2,
aNTT_TALK_GIVE
};

enum aNTT_think_proc {
aNTT_THINK_NONE,
aNTT_THINK_WAIT,
aNTT_THINK_ROLL,
aNTT_THINK_ROLL1,
aNTT_THINK_ROLL2,
aNTT_THINK_ROLL4,
aNTT_THINK_ROLL_END,
aNTT_THINK_7,
aNTT_THINK_8,
aNTT_THINK_9,
aNTT_THINK_GIVE_MERODY,
aNTT_THINK_POCKETS_FULL,
aNTT_THINK_GIVE_LATER,
};

#ifdef __cplusplus
}
#endif

#endif

3 changes: 2 additions & 1 deletion include/m_clip.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#include "ac_turi_clip.h"
#include "ac_hatumode_control.h"
#include "ac_station_clip.h"
#include "ac_npc_totakeke.h"

#ifdef __cplusplus
extern "C" {
Expand Down Expand Up @@ -90,7 +91,7 @@ typedef struct clip_s {
/* 0x0CC */ void* _0CC;
/* 0x0D0 */ void* _0D0;
/* 0x0D4 */ CLIP_NONE_PROC ball_redma_proc; /* removed in DnM+ */
/* 0x0D8 */ void* _0D8;
/* 0x0D8 */ aNTT_Clip_c* totakeke_clip;
/* 0x0DC */ aAL_Clip_c* animal_logo_clip;
/* 0x0E0 */ aSTC_clip_c* station_clip;
/* 0x0E4 */ aTRC_clip_c* turi_clip;
Expand Down
1 change: 1 addition & 0 deletions include/m_string_data.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ extern "C" {
#define mString_HANIWA_MSG2 0x76C
#define mString_HANIWA_MSG3 0x76D
#define mString_CARPETPEDDLER_START 0x48a
#define mString_TOTAKEKE_START 0x1b93

#ifdef __cplusplus
}
Expand Down
140 changes: 140 additions & 0 deletions src/actor/npc/ac_npc_totakeke.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
#include "ac_npc_totakeke.h"

#include "m_event.h"
#include "m_common_data.h"
#include "m_npc.h"
#include "m_msg.h"
#include "m_choice.h"
#include "m_bgm.h"
#include "m_player_lib.h"
#include "m_string_data.h"

void aNTT_schedule_proc();
int aNTT_change_talk_proc(NPC_TOTAKEKE_ACTOR*, int);
void aNTT_setup_think_proc(NPC_TOTAKEKE_ACTOR*, GAME_PLAY*, u8);
int aNTT_enso_init(NPC_TOTAKEKE_ACTOR*);
void aNTT_actor_ct(ACTOR* actorx, GAME* game);
void aNTT_actor_dt(ACTOR* actorx, GAME* game);
void aNTT_actor_init(ACTOR* actorx, GAME* game);
void aNTT_actor_save(ACTOR* actorx, GAME* game);
void aNTT_actor_move(ACTOR* actorx, GAME* game);
void aNTT_actor_draw(ACTOR* actorx, GAME* game);
int aNTT_talk_init(ACTOR* actorx, GAME* game);
int aNTT_talk_end_chk(ACTOR* actorx, GAME* game);

// clang-format off
ACTOR_PROFILE Npc_Totakeke_Profile = {
mAc_PROFILE_NPC_TOTAKEKE,
ACTOR_PART_NPC,
ACTOR_STATE_NONE,
SP_NPC_TOTAKEKE,
ACTOR_OBJ_BANK_KEEP,
sizeof(NPC_TOTAKEKE_ACTOR),
&aNTT_actor_ct,
&aNTT_actor_dt,
&aNTT_actor_init,
(mActor_proc)none_proc1,
&aNTT_actor_save,
};

void aNTT_actor_ct(ACTOR *actorx, GAME *game) {
static aNPC_ct_data_c ct_data = {
&aNTT_actor_move,
&aNTT_actor_draw,
0x5,
(mActor_proc)none_proc1,
&aNTT_talk_init,
&aNTT_talk_end_chk,
0x0
};
aNTT_event_save_c *save = (aNTT_event_save_c *)mEv_get_save_area(mEv_EVENT_KK_SLIDER, 0xa);
aNTT_event_common_c *common = (aNTT_event_common_c *)mEv_get_common_area(mEv_EVENT_KK_SLIDER, 0x10);
if (Common_Get(reset_flag) == TRUE) {
Actor_delete(actorx);
actorx->sv_proc = 0;
actorx->dt_proc = 0;
mNpc_RenewalSetNpc(actorx);
mEv_actor_dying_message(mEv_EVENT_KK_SLIDER, actorx);
} else if (CLIP(npc_clip)->birth_check_proc(actorx, game) == TRUE) {
xyz_t wpos;

NPC_TOTAKEKE_ACTOR *totakeke = (NPC_TOTAKEKE_ACTOR *)actorx;
totakeke->npc_class.schedule.schedule_proc = aNTT_schedule_proc;
CLIP(npc_clip)->ct_proc(actorx, game, &ct_data);
totakeke->npc_class.palActorIgnoreTimer = -1;
totakeke->npc_class.condition_info.hide_flg = FALSE;
totakeke->npc_class.collision.priority = 0;
actorx->world.position.y = mCoBG_GetBgY_OnlyCenter_FromWpos2(actorx->world.position, 0.0f);
actorx->position_speed.y = 0.0f;
actorx->gravity = 0.0f;
actorx->max_velocity_y = 0.0f;
totakeke->npc_class.talk_info.default_animation = aNPC_ANIM_WAIT_E1;
totakeke->npc_class.talk_info.default_act = aNPC_ACT_TALK2;
totakeke->npc_class.talk_info.turn = 2;

aNTT_enso_init(totakeke);
totakeke->_9a1 = FALSE;

if (save == NULL) {
save = (aNTT_event_save_c *)mEv_reserve_save_area(mEv_EVENT_KK_SLIDER, 0xa);
save->bitfield = 0;
}

save->bitfield = save->bitfield & 0x3fff;

{
int i;
for (i = 0; i < aNTT_REQUEST_STR_LEN; i++) {
save->request_str[i] = 0;
}
}

save->_14 = 0;
save->_15 = 0;

if (common == NULL) {
common = (aNTT_event_common_c *)mEv_reserve_common_area(mEv_EVENT_KK_SLIDER, 0x10);
common->foreigner_bitfield = 0;
}
totakeke->npc_class.collision.pipe.attribute.pipe.radius = 0x1e;
totakeke->melody_inst = 0;
totakeke->_9a9 = 0;
totakeke->_99f = 0xff;
mCoBG_SetPlussOffset(actorx->world.position, 0x3, 0x64);
}
}

void aNTT_actor_save(ACTOR *actorx, GAME *game) {
mNpc_RenewalSetNpc(actorx);
}

void aNTT_actor_dt(ACTOR *actorx, GAME *game) {
mEv_actor_dying_message(mEv_EVENT_KK_SLIDER, actorx);
CLIP(npc_clip)->dt_proc(actorx, game);
mCoBG_SetPlussOffset(actorx->world.position, 0x0, 0x64);
}

void aNTT_actor_init(ACTOR *actorx, GAME *game) {
CLIP(npc_clip)->init_proc(actorx, game);
}

void aNTT_actor_move(ACTOR *actorx, GAME *game) {
NPC_TOTAKEKE_ACTOR *totakeke = (NPC_TOTAKEKE_ACTOR *)actorx;
CLIP(npc_clip)->move_proc(actorx, game);
if (totakeke->npc_class.draw.animation_id == aNPC_ANIM_ENSOU_E1) {
totakeke->npc_class.draw.main_animation.keyframe.frame_control.mode = 1;
}
}

void aNTT_actor_draw(ACTOR *actorx, GAME *game) {
NPC_TOTAKEKE_ACTOR *totakeke = (NPC_TOTAKEKE_ACTOR *)actorx;
aNTT_event_save_c *save = (aNTT_event_save_c *)mEv_get_save_area(mEv_EVENT_KK_SLIDER, 0xa);
CLIP(npc_clip)->draw_proc(actorx, game);
if (save == NULL || (save->bitfield & 0x4000) == 0 || CLIP(totakeke_clip) == NULL) {
return;
}
CLIP(totakeke_clip)->_04(game, totakeke->roll2_count, totakeke->_9a2);
}

#include "../src/actor/npc/ac_npc_totakeke_talk.c_inc"
#include "../src/actor/npc/ac_npc_totakeke_think.c_inc"
Loading
Loading