-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
319 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
#include "ac_npc_conv_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 aNCM_actor_ct(ACTOR* conv_master, GAME* game); | ||
void aNCM_actor_dt(ACTOR* actorx, GAME* game); | ||
void aNCM_actor_move(ACTOR* actorx, GAME* game); | ||
void aNCM_actor_draw(ACTOR* actorx, GAME* game); | ||
void aNCM_actor_init(ACTOR* actorx, GAME* game); | ||
void aNCM_actor_save(ACTOR* actorx, GAME* game); | ||
|
||
// clang-format off | ||
ACTOR_PROFILE Npc_Conv_Master_Profile = { | ||
mAc_PROFILE_NPC_CONV_MASTER, | ||
ACTOR_PART_NPC, | ||
ACTOR_STATE_NONE, | ||
SP_NPC_CONV_MASTER, | ||
ACTOR_OBJ_BANK_KEEP, | ||
sizeof(NPC_CONV_MASTER_ACTOR), | ||
&aNCM_actor_ct, | ||
&aNCM_actor_dt, | ||
&aNCM_actor_init, | ||
mActor_NONE_PROC1, | ||
&aNCM_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_CONV_MASTER_ACTOR *conv_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_CONV_MASTER_ACTOR *conv_master, GAME_PLAY * play, int p3); | ||
static void aNSC_BGcheck(ACTOR* actorx); | ||
static void aNSC_set_zone_data(NPC_CONV_MASTER_ACTOR* conv_master, ACTOR* actor); | ||
static void aNSC_set_player_angl(NPC_CONV_MASTER_ACTOR* conv_master); | ||
static void aNSC_talk_demo_proc(ACTOR* actorx); | ||
static void aNSC_sell_camera(NPC_CONV_MASTER_ACTOR* conv_master, GAME_PLAY* play); | ||
|
||
void aNCM_actor_ct(ACTOR* actorx, GAME* game) { | ||
static aNPC_ct_data_c ct_data = { | ||
&aNCM_actor_move, &aNCM_actor_draw, 0, NULL, NULL, NULL, 1, | ||
}; | ||
|
||
NPC_CONV_MASTER_ACTOR* conv_master = (NPC_CONV_MASTER_ACTOR*)actorx; | ||
int action; | ||
|
||
CLIP(npc_clip)->ct_proc(actorx, game, &ct_data); | ||
|
||
conv_master->npc_class.draw.main_animation.keyframe.morph_counter = 0.0f; | ||
conv_master->sell_item = EMPTY_NO; | ||
conv_master->npc_class.condition_info.hide_flg = FALSE; | ||
conv_master->talk_start_tim = -1; | ||
actorx->shape_info.draw_shadow = TRUE; | ||
|
||
if (Common_Get(door_data).door_actor_name == RSV_NO) { | ||
conv_master->npc_class.talk_info.melody_inst = 0; | ||
action = 61; | ||
} else { | ||
action = 0; | ||
} | ||
|
||
aNSC_setupAction(conv_master, (GAME_PLAY*)game, action); | ||
} | ||
|
||
void aNCM_actor_save(ACTOR* actorx, GAME* game) { | ||
(CLIP(npc_clip)->save_proc)(actorx, game); | ||
} | ||
|
||
void aNCM_actor_dt(ACTOR* actorx, GAME* game) { | ||
(CLIP(npc_clip)->dt_proc)(actorx, game); | ||
} | ||
|
||
void aNCM_actor_init(ACTOR* actorx, GAME* game) { | ||
(CLIP(npc_clip)->init_proc)(actorx, game); | ||
} | ||
|
||
void aNCM_actor_draw(ACTOR* actorx, GAME* game) { | ||
(CLIP(npc_clip)->draw_proc)(actorx, game); | ||
} | ||
|
||
#include "../src/actor/npc/ac_npc_conv_master_move.c_inc" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
static u8 aNCM_get_zone_sub(u8 zone, f32 pos_z, int type) { | ||
static f32 chk[][2] = { { 140.0f, 220.0f }, { 120.0f, 200.0f } }; | ||
int i; | ||
|
||
for (i = 0; i < 2; i++) { | ||
if (pos_z < chk[type][i]) { | ||
break; | ||
} | ||
} | ||
|
||
return zone + i; | ||
} | ||
|
||
static u8 aNCM_get_zone(xyz_t wpos) { | ||
u8 zone; | ||
int type = 0; | ||
|
||
if (wpos.x < 240.0f) { | ||
if (wpos.x < 80.0f) { | ||
zone = 0; | ||
} else { | ||
zone = 3; | ||
} | ||
} else { | ||
if (wpos.x < 360.0f) { | ||
zone = 6; | ||
} else { | ||
zone = 9; | ||
type = 1; | ||
} | ||
} | ||
|
||
return aNCM_get_zone_sub(zone, wpos.z, type); | ||
} | ||
|
||
static u8 aNCM_get_next_zone(u8 p1, u8 p2) { | ||
static u8 next_zone[12][12] = { | ||
{ 0x00, 0x01, 0x01, 0x03, 0x01, 0x01, 0x03, 0x01, 0x01, 0x03, 0x01, 0x01 }, | ||
{ 0x00, 0x01, 0x02, 0x00, 0x04, 0x02, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04 }, | ||
{ 0x01, 0x01, 0x02, 0x01, 0x01, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05 }, | ||
{ 0x00, 0x00, 0x00, 0x03, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06 }, | ||
{ 0x01, 0x01, 0x01, 0x07, 0x04, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07 }, | ||
{ 0x02, 0x02, 0x02, 0x08, 0x08, 0x05, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08 }, | ||
{ 0x03, 0x03, 0x03, 0x03, 0x07, 0x07, 0x06, 0x07, 0x07, 0x09, 0x07, 0x07 }, | ||
{ 0x04, 0x04, 0x04, 0x06, 0x04, 0x08, 0x06, 0x07, 0x08, 0x06, 0x0A, 0x0A }, | ||
{ 0x05, 0x05, 0x05, 0x07, 0x07, 0x05, 0x07, 0x07, 0x08, 0x07, 0x07, 0x07 }, | ||
{ 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06 }, | ||
{ 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x0B }, | ||
{ 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A }, | ||
}; | ||
|
||
return next_zone[p2][p1]; | ||
} | ||
|
||
static void aNCM_search_player(NPC_CONV_MASTER_ACTOR* conv_master, GAME_PLAY* play) { | ||
ACTOR* actorx = (ACTOR*)conv_master; | ||
ACTOR* player = GET_PLAYER_ACTOR_ACTOR(play); | ||
|
||
if (player != NULL) { | ||
s16 angle = actorx->shape_info.rotation.y - conv_master->player_angle; | ||
if (ABS(angle) > DEG2SHORT_ANGLE(90.0f)) { | ||
aNSC_setupAction(conv_master, play, 66); | ||
} else { | ||
chase_angle(&actorx->shape_info.rotation.y, conv_master->player_angle, DEG2SHORT_ANGLE(11.25f)); | ||
actorx->world.angle.y = actorx->shape_info.rotation.y; | ||
} | ||
} | ||
} | ||
|
||
static void aNCM_search_player2(NPC_CONV_MASTER_ACTOR* conv_master, GAME_PLAY* play) { | ||
static float posX[12] = { | ||
60.0f, 60.0f, 60.0f, 160.0f, 160.0f, 160.0f, 300.0f, 300.0f, 300.0f, 420.0f, 420.0f, 420.0f, | ||
}; | ||
|
||
static float posZ[12] = { | ||
100.0f, 180.0f, 260.0f, 100.0f, 180.0f, 260.0f, 100.0f, 180.0f, 260.0f, 100.0f, 180.0f, 240.0f, | ||
}; | ||
|
||
PLAYER_ACTOR* player = GET_PLAYER_ACTOR(play); | ||
if (player != NULL) { | ||
f32 dx = posX[conv_master->next_zone] - conv_master->npc_class.actor_class.world.position.x; | ||
f32 dz = posZ[conv_master->next_zone] - conv_master->npc_class.actor_class.world.position.z; | ||
|
||
s16 angle = atans_table(dz, dx); | ||
chase_angle(&conv_master->npc_class.actor_class.shape_info.rotation.y, angle, DEG2SHORT_ANGLE(11.25f)); | ||
|
||
conv_master->npc_class.actor_class.world.angle.y = conv_master->npc_class.actor_class.shape_info.rotation.y; | ||
|
||
if (SQ(dx) + SQ(dz) < 200.0f) { | ||
conv_master->next_zone = aNCM_get_next_zone(conv_master->player_zone, conv_master->zone); | ||
} | ||
} | ||
} | ||
|
||
static int aNCM_check_safe_zone(NPC_CONV_MASTER_ACTOR* conv_master, PLAYER_ACTOR* player) { | ||
int res = FALSE; | ||
if (player->actor_class.world.position.z > 280.0f && conv_master->zone == 8) { | ||
res = TRUE; | ||
} | ||
return res; | ||
} | ||
|
||
#define aNSC_get_zone aNCM_get_zone | ||
#define aNSC_get_next_zone aNCM_get_next_zone | ||
#define aNSC_check_safe_zone aNCM_check_safe_zone | ||
#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" | ||
|
||
#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 | ||
|
||
void aNCM_actor_move(ACTOR* actorx, GAME* game) { | ||
NPC_CONV_MASTER_ACTOR* conv_master = (NPC_CONV_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); | ||
aNSC_set_zone_data(conv_master, (ACTOR*)player); | ||
aNSC_set_player_angl(conv_master); | ||
(*conv_master->proc)(conv_master, play); | ||
aNSC_talk_demo_proc(actorx); | ||
CLIP(npc_clip)->move_after_proc(actorx, game); | ||
aNSC_sell_camera(conv_master, play); | ||
} |