Implement & link ac_npc_depart_master

This commit is contained in:
Cuyler36
2024-12-28 07:45:37 -05:00
parent db70a5564d
commit 2071600c39
9 changed files with 343 additions and 13 deletions
+1 -1
View File
@@ -1103,7 +1103,7 @@ config.libs = [
Object(NonMatching, "actor/npc/ac_npc2.c"),
Object(Matching, "actor/npc/ac_npc_conv_master.c"),
Object(Matching, "actor/npc/ac_npc_curator.c"),
Object(NonMatching, "actor/npc/ac_npc_depart_master.c"),
Object(Matching, "actor/npc/ac_npc_depart_master.c"),
Object(Matching, "actor/npc/ac_npc_engineer.c"),
Object(Matching, "actor/npc/ac_npc_guide.c"),
Object(Matching, "actor/npc/ac_npc_guide2.c"),
+6 -1
View File
@@ -3,11 +3,17 @@
#include "types.h"
#include "m_actor.h"
#include "ac_npc.h"
#include "m_mail_password_check.h"
#include "m_private.h"
#include "ac_npc_shop_common.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef NPC_SHOP_COMMON_ACTOR NPC_DEPART_MASTER_ACTOR;
extern ACTOR_PROFILE Npc_Depart_Master_Profile;
#ifdef __cplusplus
@@ -15,4 +21,3 @@ extern ACTOR_PROFILE Npc_Depart_Master_Profile;
#endif
#endif
+4 -2
View File
@@ -92,9 +92,9 @@ static void aNCM_search_player2(NPC_CONV_MASTER_ACTOR* conv_master, GAME_PLAY* p
}
}
static int aNCM_check_safe_zone(NPC_CONV_MASTER_ACTOR* conv_master, PLAYER_ACTOR* player) {
static int aNCM_check_safe_zone(NPC_CONV_MASTER_ACTOR* conv_master, ACTOR* player) {
int res = FALSE;
if (player->actor_class.world.position.z > 280.0f && conv_master->zone == 8) {
if (player->world.position.z > 280.0f && conv_master->zone == 8) {
res = TRUE;
}
return res;
@@ -106,6 +106,7 @@ static int aNCM_check_safe_zone(NPC_CONV_MASTER_ACTOR* conv_master, PLAYER_ACTOR
#define aNSC_search_player aNCM_search_player
#define aNSC_search_player2 aNCM_search_player2
#define aNSC_ANIME_FILE "../src/actor/npc/ac_npc_conv_master_anime.c"
#define aNSC_POS_Z_MAX 260.0f
#include "../src/actor/npc/ac_npc_shop_common.c"
@@ -115,6 +116,7 @@ static int aNCM_check_safe_zone(NPC_CONV_MASTER_ACTOR* conv_master, PLAYER_ACTOR
#undef aNSC_search_player
#undef aNSC_search_player2
#undef aNSC_ANIME_FILE
#undef aNSC_POS_Z_MAX
void aNCM_actor_move(ACTOR* actorx, GAME* game) {
NPC_CONV_MASTER_ACTOR* conv_master = (NPC_CONV_MASTER_ACTOR*)actorx;
+110
View File
@@ -0,0 +1,110 @@
#include "ac_npc_depart_master.h"
#include "m_shop.h"
#include "m_common_data.h"
#include "m_font.h"
#include "m_msg.h"
#include "m_private.h"
#include "m_string.h"
#include "m_actor_type.h"
#include "m_player_lib.h"
#include "m_mail_password_check.h"
#include "m_actor.h"
#include "m_actor_type.h"
#include "m_camera2.h"
#include "m_house.h"
#include "m_melody.h"
#include "m_scene.h"
#include "m_collision_bg.h"
#include "m_demo.h"
#include "m_player.h"
#include "m_bgm.h"
#include "ac_npc.h"
#include "ac_uki.h"
#include "ac_npc_anim_def.h"
void aNDM_actor_ct(ACTOR* depart_master, GAME* game);
void aNDM_actor_dt(ACTOR* actorx, GAME* game);
void aNDM_actor_move(ACTOR* actorx, GAME* game);
void aNDM_actor_draw(ACTOR* actorx, GAME* game);
void aNDM_actor_init(ACTOR* actorx, GAME* game);
void aNDM_actor_save(ACTOR* actorx, GAME* game);
// clang-format off
ACTOR_PROFILE Npc_Depart_Master_Profile = {
mAc_PROFILE_NPC_DEPART_MASTER,
ACTOR_PART_NPC,
ACTOR_STATE_NONE,
SP_NPC_DEPART_MASTER,
ACTOR_OBJ_BANK_KEEP,
sizeof(NPC_DEPART_MASTER_ACTOR),
&aNDM_actor_ct,
&aNDM_actor_dt,
&aNDM_actor_init,
mActor_NONE_PROC1,
&aNDM_actor_save,
};
// clang-format on
// TODO: are these declared in every file? DnM+ says they're static yet they seemingly must be defined after their usage...
static void aNSC_setupAction(NPC_DEPART_MASTER_ACTOR *depart_master, GAME_PLAY* play, int p3);
static int aNSC_check_buy_item_sub(u32 *p1, mActor_name_t itm_name);
static int aNSC_check_buy_paper(u32 *p1, mActor_name_t itm_name);
static void aNSC_init_proc(NPC_DEPART_MASTER_ACTOR *depart_master, GAME_PLAY * play, int p3);
static void aNSC_BGcheck(ACTOR* actorx);
static void aNSC_set_zone_data(NPC_DEPART_MASTER_ACTOR* depart_master, ACTOR* actor);
static void aNSC_set_player_angl(NPC_DEPART_MASTER_ACTOR* depart_master);
static void aNSC_talk_demo_proc(ACTOR* actorx);
static void aNSC_sell_camera(NPC_DEPART_MASTER_ACTOR* depart_master, GAME_PLAY* play);
void aNDM_actor_ct(ACTOR* actorx, GAME* game) {
static aNPC_ct_data_c ct_data = {
&aNDM_actor_move, &aNDM_actor_draw, 0, NULL, NULL, NULL, 1,
};
NPC_DEPART_MASTER_ACTOR* depart_master = (NPC_DEPART_MASTER_ACTOR*)actorx;
int action;
CLIP(npc_clip)->ct_proc(actorx, game, &ct_data);
depart_master->npc_class.draw.main_animation.keyframe.morph_counter = 0.0f;
depart_master->sell_item = EMPTY_NO;
depart_master->npc_class.condition_info.hide_flg = FALSE;
depart_master->talk_start_tim = -1;
actorx->shape_info.draw_shadow = TRUE;
action = 0;
if (Common_Get(door_data).door_actor_name == RSV_NO) {
depart_master->npc_class.talk_info.melody_inst = 0;
action = 61;
} else if (Common_Get(last_scene_no) == SCENE_DEPART_2) {
depart_master->npc_class.talk_info.melody_inst = 0;
action = 61;
actorx->world.position.x = 320.0f;
actorx->world.position.z = 200.0f;
actorx->shape_info.rotation.y = DEG2SHORT_ANGLE2(180.0f);
actorx->world.angle.y = DEG2SHORT_ANGLE2(180.0f);
}
depart_master->_9B9 = Common_Get(tanuki_shop_status) == mSP_TANUKI_SHOP_STATUS_EVENT;
aNSC_setupAction(depart_master, (GAME_PLAY*)game, action);
}
void aNDM_actor_save(ACTOR* actorx, GAME* game) {
(CLIP(npc_clip)->save_proc)(actorx, game);
}
void aNDM_actor_dt(ACTOR* actorx, GAME* game) {
(CLIP(npc_clip)->dt_proc)(actorx, game);
}
void aNDM_actor_init(ACTOR* actorx, GAME* game) {
(CLIP(npc_clip)->init_proc)(actorx, game);
}
void aNDM_actor_draw(ACTOR* actorx, GAME* game) {
(CLIP(npc_clip)->draw_proc)(actorx, game);
}
#include "../src/actor/npc/ac_npc_depart_master_move.c_inc"
@@ -0,0 +1,70 @@
{ aNPC_ANIM_WAIT1, FALSE },
{ aNPC_ANIM_WALK1, TRUE },
{ aNPC_ANIM_WAIT1, TRUE },
{ aNPC_ANIM_WAIT1, TRUE },
{ aNPC_ANIM_WALK1, TRUE },
{ aNPC_ANIM_WAIT1, TRUE },
{ aNPC_ANIM_WALK1, TRUE },
{ aNPC_ANIM_WAIT1, TRUE },
{ aNPC_ANIM_WALK1, TRUE },
{ aNPC_ANIM_TRANSFER1, TRUE },
{ aNPC_ANIM_TRANS_WAIT1, TRUE },
{ aNPC_ANIM_WAIT1, TRUE },
{ aNPC_ANIM_WAIT1, TRUE },
{ aNPC_ANIM_WAIT1, TRUE },
{ aNPC_ANIM_WAIT1, TRUE },
{ aNPC_ANIM_WAIT1, TRUE },
{ aNPC_ANIM_WAIT1, TRUE },
{ aNPC_ANIM_WAIT1, TRUE },
{ aNPC_ANIM_WAIT1, TRUE },
{ aNPC_ANIM_WAIT1, TRUE },
{ aNPC_ANIM_WAIT1, TRUE },
{ aNPC_ANIM_WAIT1, TRUE },
{ aNPC_ANIM_WAIT1, TRUE },
{ aNPC_ANIM_WAIT1, TRUE },
{ aNPC_ANIM_WAIT1, TRUE },
{ aNPC_ANIM_WAIT1, TRUE },
{ aNPC_ANIM_WAIT1, TRUE },
{ aNPC_ANIM_WAIT1, TRUE },
{ aNPC_ANIM_WAIT1, TRUE },
{ aNPC_ANIM_WAIT1, TRUE },
{ aNPC_ANIM_WAIT1, TRUE },
{ aNPC_ANIM_WAIT1, TRUE },
{ aNPC_ANIM_WAIT1, TRUE },
{ aNPC_ANIM_WAIT1, TRUE },
{ aNPC_ANIM_WAIT1, TRUE },
{ aNPC_ANIM_WAIT1, TRUE },
{ aNPC_ANIM_WAIT1, TRUE },
{ aNPC_ANIM_WAIT1, TRUE },
{ aNPC_ANIM_WAIT1, TRUE },
{ aNPC_ANIM_WAIT1, TRUE },
{ aNPC_ANIM_WAIT1, TRUE },
{ aNPC_ANIM_WAIT1, TRUE },
{ aNPC_ANIM_WAIT1, TRUE },
{ aNPC_ANIM_WAIT1, TRUE },
{ aNPC_ANIM_WAIT1, TRUE },
{ aNPC_ANIM_WAIT1, TRUE },
{ aNPC_ANIM_WAIT1, TRUE },
{ aNPC_ANIM_WAIT1, TRUE },
{ aNPC_ANIM_WAIT1, TRUE },
{ aNPC_ANIM_WAIT1, TRUE },
{ aNPC_ANIM_WAIT1, TRUE },
{ aNPC_ANIM_WAIT1, TRUE },
{ aNPC_ANIM_WAIT1, TRUE },
{ aNPC_ANIM_WAIT1, TRUE },
{ aNPC_ANIM_WAIT1, TRUE },
{ aNPC_ANIM_WAIT1, TRUE },
{ aNPC_ANIM_WAIT1, TRUE },
{ aNPC_ANIM_WAIT1, TRUE },
{ aNPC_ANIM_TRANSFER1, TRUE },
{ aNPC_ANIM_TRANS_WAIT1, TRUE },
{ aNPC_ANIM_WAIT1, TRUE },
{ aNPC_ANIM_WAIT1, FALSE },
{ aNPC_ANIM_WALK1, FALSE },
{ aNPC_ANIM_WALK1, FALSE },
{ aNPC_ANIM_RUN1, FALSE },
{ aNPC_ANIM_RUN1, FALSE },
{ aNPC_ANIM_WALK1, FALSE },
{ aNPC_ANIM_WAIT1, FALSE },
{ aNPC_ANIM_WAIT1, TRUE },
{ aNPC_ANIM_WAIT1, FALSE }
@@ -0,0 +1,138 @@
static u8 aNDM_get_zone_sub(f32 pos, f32* chk_p, int count) {
int i;
for (i = 0; i < count; i++) {
if (pos < *chk_p) {
break;
}
chk_p++;
}
return i;
}
static u8 aNDM_get_zone(xyz_t wpos) {
static f32 chk0[] = { 200.0f, 320.0f, 440.0f };
static f32 chk1[] = { 280.0f, 400.0f, 440.0f };
u8 zone;
if (wpos.x < 220.0f) {
zone = aNDM_get_zone_sub(wpos.z, chk0, ARRAY_COUNT(chk0));
} else {
zone = aNDM_get_zone_sub(wpos.z, chk1, ARRAY_COUNT(chk1));
if (zone == 2) {
if (wpos.x >= 360.0f) {
zone = 4;
}
}
zone += 4;
}
return zone;
}
static u8 aNDM_get_next_zone(u8 p1, u8 p2) {
static u8 next_zone[9][9] = {
{ 0x00, 0x01, 0x01, 0x01, 0x04, 0x04, 0x04, 0x04, 0x04 },
{ 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x02 },
{ 0x01, 0x01, 0x02, 0x03, 0x01, 0x01, 0x03, 0x03, 0x03 },
{ 0x02, 0x02, 0x02, 0x03, 0x07, 0x07, 0x07, 0x07, 0x07 },
{ 0x00, 0x00, 0x00, 0x00, 0x04, 0x05, 0x05, 0x05, 0x05 },
{ 0x04, 0x04, 0x06, 0x06, 0x04, 0x05, 0x06, 0x06, 0x06 },
{ 0x05, 0x05, 0x07, 0x07, 0x05, 0x05, 0x06, 0x07, 0x08 },
{ 0x03, 0x03, 0x03, 0x03, 0x06, 0x06, 0x06, 0x07, 0x06 },
{ 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x08 },
};
return next_zone[p2][p1];
}
static void aNDM_search_player(NPC_DEPART_MASTER_ACTOR* depart_master, GAME_PLAY* play) {
ACTOR* actorx = (ACTOR*)depart_master;
ACTOR* player = GET_PLAYER_ACTOR_ACTOR(play);
if (player != NULL) {
s16 angle = actorx->shape_info.rotation.y - depart_master->player_angle;
if (ABS(angle) > DEG2SHORT_ANGLE(90.0f)) {
aNSC_setupAction(depart_master, play, 66);
} else {
chase_angle(&actorx->shape_info.rotation.y, depart_master->player_angle, DEG2SHORT_ANGLE(11.25f));
actorx->world.angle.y = actorx->shape_info.rotation.y;
}
}
}
static void aNDM_search_player2(NPC_DEPART_MASTER_ACTOR* depart_master, GAME_PLAY* play) {
static float posX[9] = {
140.0f, 140.0f, 140.0f, 140.0f, 300.0f, 300.0f, 300.0f, 300.0f, 400.0f,
};
static float posZ[9] = {
180.0f, 260.0f, 380.0f, 480.0f, 180.0f, 340.0f, 420.0f, 480.0f, 420.0f,
};
PLAYER_ACTOR* player = GET_PLAYER_ACTOR(play);
if (player != NULL) {
f32 dx = posX[depart_master->next_zone] - depart_master->npc_class.actor_class.world.position.x;
f32 dz = posZ[depart_master->next_zone] - depart_master->npc_class.actor_class.world.position.z;
s16 angle = atans_table(dz, dx);
chase_angle(&depart_master->npc_class.actor_class.shape_info.rotation.y, angle, DEG2SHORT_ANGLE(11.25f));
depart_master->npc_class.actor_class.world.angle.y = depart_master->npc_class.actor_class.shape_info.rotation.y;
if (SQ(dx) + SQ(dz) < 200.0f) {
depart_master->next_zone = aNDM_get_next_zone(depart_master->player_zone, depart_master->zone);
}
}
}
static int aNDM_check_safe_zone(NPC_DEPART_MASTER_ACTOR* depart_master, ACTOR* player) {
int res = FALSE;
if ((player->world.position.z > 520.0f && depart_master->zone == 7) ||
(player->world.position.z < 120.0f && depart_master->zone == 4)) {
res = TRUE;
}
return res;
}
#define aNSC_get_zone aNDM_get_zone
#define aNSC_get_next_zone aNDM_get_next_zone
#define aNSC_check_safe_zone aNDM_check_safe_zone
#define aNSC_search_player aNDM_search_player
#define aNSC_search_player2 aNDM_search_player2
#define aNSC_ANIME_FILE "../src/actor/npc/ac_npc_depart_master_anime.c"
#define aNSC_POS_Z_MAX 500.0f
#include "../src/actor/npc/ac_npc_shop_common.c"
#undef aNSC_get_zone
#undef aNSC_get_next_zone
#undef aNSC_check_safe_zone
#undef aNSC_search_player
#undef aNSC_search_player2
#undef aNSC_ANIME_FILE
#undef aNSC_POS_Z_MAX
void aNDM_actor_move(ACTOR* actorx, GAME* game) {
NPC_DEPART_MASTER_ACTOR* depart_master = (NPC_DEPART_MASTER_ACTOR*)actorx;
GAME_PLAY* play = (GAME_PLAY*)game;
PLAYER_ACTOR* player = GET_PLAYER_ACTOR(play);
CLIP(npc_clip)->move_before_proc(actorx, game);
aNSC_BGcheck(actorx);
if (actorx->world.position.z < 138.0f) {
actorx->world.position.z = 138.0f;
}
aNSC_set_zone_data(depart_master, (ACTOR*)player);
aNSC_set_player_angl(depart_master);
(*depart_master->proc)(depart_master, play);
aNSC_talk_demo_proc(actorx);
CLIP(npc_clip)->move_after_proc(actorx, game);
aNSC_sell_camera(depart_master, play);
}
@@ -1065,6 +1065,8 @@ static void aNMD_weight_ctrl(ACTOR* actorx) {
#define aNSC_search_player aNMD_search_player
#define aNSC_search_player2 aNMD_search_player2
#define aNSC_ANIME_FILE "../src/actor/npc/ac_npc_mamedanuki_anime.c"
#define aNSC_POS_Z_MAX 500.0f
#include "../src/actor/npc/ac_npc_shop_common.c"
@@ -1074,6 +1076,7 @@ static void aNMD_weight_ctrl(ACTOR* actorx) {
#undef aNSC_search_player2
#undef aNSC_MAMEDANUKI
#undef aNSC_ANIME_FILE
#undef aNSC_POS_Z_MAX
void aNMD_actor_move(ACTOR* actorx, GAME* game) {
NPC_MAMEDANUKI_ACTOR* mamedanuki = (NPC_MAMEDANUKI_ACTOR*)actorx;
+7 -7
View File
@@ -690,11 +690,11 @@ static void aNSC_set_buy_sum_str(mActor_name_t item, u32 p2) {
#ifndef aNSC_MAMEDANUKI
static int aNSC_decide_next_move_act(NPC_SHOP_COMMON_ACTOR* shop_common, GAME_PLAY* play) {
int res;
PLAYER_ACTOR* player;
ACTOR* player;
if ((shop_common->npc_class.collision.pipe.collision_obj.collision_flags0 & 0x2) != 0) {
return aNSC_ACTION_WAIT;
} else {
player = GET_PLAYER_ACTOR(play);
player = GET_PLAYER_ACTOR_ACTOR(play);
if (player == NULL) {
return shop_common->action;
}
@@ -1836,7 +1836,7 @@ static void aNSC_say_hello_approach(NPC_SHOP_COMMON_ACTOR* shop_common, GAME_PLA
static void aNSC_say_hello_approach(NPC_SHOP_COMMON_ACTOR* shop_common, GAME_PLAY* play) {
ACTOR* actorx = (ACTOR*)shop_common;
f32 z = 260.0;
f32 z = aNSC_POS_Z_MAX;
if (actorx->world.position.z > z) {
actorx->world.position.z = z;
aNSC_setupAction(shop_common, play, aNSC_ACTION_SAY_HELLO_END_WAIT);
@@ -1860,7 +1860,7 @@ static void aNSC_say_hello_end_wait(NPC_SHOP_COMMON_ACTOR* shop_common, GAME_PLA
#ifndef aNSC_MAMEDANUKI
static void aNSC_check_col_chg_or_make_basement(NPC_SHOP_COMMON_ACTOR* shop_common, GAME_PLAY* play) {
f32 z = 260.0;
f32 z = aNSC_POS_Z_MAX;
if (((ACTOR*)shop_common)->world.position.z > z) {
((ACTOR*)shop_common)->world.position.z = z;
aNSC_set_stop_spd(shop_common);
@@ -1882,7 +1882,7 @@ static void aNSC_check_col_chg_or_make_basement(NPC_SHOP_COMMON_ACTOR* shop_comm
}
static void aNSC_check_roof_col_order(NPC_SHOP_COMMON_ACTOR* shop_common, GAME_PLAY* play) {
f32 z = 260.0;
f32 z = aNSC_POS_Z_MAX;
int unk = mDemo_Get_OrderValue(mDemo_ORDER_NPC0, 9);
if (((ACTOR*)shop_common)->world.position.z > z) {
((ACTOR*)shop_common)->world.position.z = z;
@@ -1945,8 +1945,8 @@ static void aNSC_present_balloon_start_wait(NPC_SHOP_COMMON_ACTOR* shop_common,
static void aNSC_present_balloon_trans_move(NPC_SHOP_COMMON_ACTOR* shop_common, GAME_PLAY* play) {
ACTOR* actorx = (ACTOR*)shop_common;
if (actorx->world.position.z > 260.0f) {
actorx->world.position.z = 260.0f;
if (actorx->world.position.z > aNSC_POS_Z_MAX) {
actorx->world.position.z = aNSC_POS_Z_MAX;
aNSC_setupAction(shop_common, play, aNSC_ACTION_PRESENT_BALLOON_TRANS_TAKEOUT);
}
}
+4 -2
View File
@@ -58,9 +58,9 @@ static void aNSM_search_player2(NPC_SHOP_MASTER_ACTOR* shop_master, GAME_PLAY* p
}
}
static int aNSM_check_safe_zone(NPC_SHOP_MASTER_ACTOR* shop_master, PLAYER_ACTOR* player) {
static int aNSM_check_safe_zone(NPC_SHOP_MASTER_ACTOR* shop_master, ACTOR* player) {
int res = FALSE;
if (player->actor_class.world.position.z > 280.0f && shop_master->zone == aNSM_ZONE_3) {
if (player->world.position.z > 280.0f && shop_master->zone == aNSM_ZONE_3) {
res = TRUE;
}
return res;
@@ -72,6 +72,7 @@ static int aNSM_check_safe_zone(NPC_SHOP_MASTER_ACTOR* shop_master, PLAYER_ACTOR
#define aNSC_search_player aNSM_search_player
#define aNSC_search_player2 aNSM_search_player2
#define aNSC_ANIME_FILE "../src/actor/npc/ac_npc_shop_master_anime.c"
#define aNSC_POS_Z_MAX 260.0f
#include "../src/actor/npc/ac_npc_shop_common.c"
@@ -81,6 +82,7 @@ static int aNSM_check_safe_zone(NPC_SHOP_MASTER_ACTOR* shop_master, PLAYER_ACTOR
#undef aNSC_search_player
#undef aNSC_search_player2
#undef aNSC_ANIME_FILE
#undef aNSC_POS_Z_MAX
void aNSM_actor_move(ACTOR* actorx, GAME* game) {
NPC_SHOP_MASTER_ACTOR* shop_master = (NPC_SHOP_MASTER_ACTOR*)actorx;