Implement & link ac_quest_manager.c

This commit is contained in:
Cuyler36
2024-02-09 02:43:04 -05:00
parent 01d00d834c
commit 05aff02678
21 changed files with 2165 additions and 16 deletions
+180
View File
@@ -0,0 +1,180 @@
static void aQMgr_actor_check_limit_and_clear_quest(mQst_contest_c* contest) {
if (mQst_CheckLimitOver(&contest->base) == TRUE) {
mQst_ClearContest(contest);
}
}
static void aQMgr_contest_check_limit(QUEST_MANAGER_ACTOR* manager, aQMgr_regist_c* regist) {
aQMgr_actor_check_limit_and_clear_quest((mQst_contest_c*)regist->quest_info);
}
static int aQMgr_actor_check_fin_fruit(mQst_base_c* quest_info, Animal_c* animal) {
int res = FALSE;
if (quest_info->progress == 1 && aQMgr_actor_check_fin_item(quest_info, animal) == TRUE) {
res = TRUE;
}
return res;
}
static int aQMgr_actor_check_fin_soccer(mQst_base_c* quest_info, Animal_c* animal) {
int res = FALSE;
if (quest_info->progress == 1) {
res = TRUE;
}
return res;
}
static void aQMgr_actor_contest_snowman_clear(QUEST_MANAGER_ACTOR* manager, aQMgr_regist_c* regist) {
lbRTC_time_c* rtc_time = Common_GetPointer(time.rtc_time);
if (regist != NULL && regist->quest_info != NULL) {
mQst_base_c* quest_info = regist->quest_info;
if (
(rtc_time->month == lbRTC_FEBRUARY && rtc_time->day > 17) ||
(rtc_time->month >= lbRTC_MARCH && rtc_time->month <= lbRTC_NOVEMBER) ||
(rtc_time->month == lbRTC_DECEMBER && rtc_time->day < 25) ||
(mQst_CheckLimitOver(quest_info) == TRUE)
) {
mQst_ClearContest((mQst_contest_c*)quest_info);
}
}
}
static int aQMgr_actor_check_fin_snowman(mQst_base_c* quest_info, Animal_c* animal) {
int res = FALSE;
if (animal != NULL && quest_info != NULL) {
mQst_contest_c* contest = (mQst_contest_c*)quest_info;
if (quest_info->progress == 1 &&
mPr_NullCheckPersonalID(&contest->player_id) == FALSE &&
mPr_CheckCmpPersonalID(&contest->player_id, &Common_Get(now_private)->player_ID) == TRUE) {
res = TRUE;
}
}
return res;
}
static void aQMgr_actor_contest_flower_clear(QUEST_MANAGER_ACTOR* manager, aQMgr_regist_c* regist) {
lbRTC_time_c* rtc_time = Common_GetPointer(time.rtc_time);
if (regist != NULL && regist->quest_info != NULL) {
mQst_base_c* quest_info = regist->quest_info;
if (
(rtc_time->month == lbRTC_JANUARY) ||
(rtc_time->month == lbRTC_FEBRUARY && rtc_time->day < 25) ||
(rtc_time->month >= lbRTC_SEPTEMBER) ||
(mQst_CheckLimitOver(quest_info) == TRUE)
) {
mQst_ClearContest((mQst_contest_c*)quest_info);
}
}
}
static int aQMgr_actor_check_flower(mQst_contest_c* contest, int bx, int bz) {
int res = FALSE;
int flower_num = mQst_GetFlowerSeedNum(bx, bz);
if (contest->base.progress == 1) {
if (contest->info.flower_data.flowers_requested <= flower_num) {
if (mPr_NullCheckPersonalID(&contest->player_id) == TRUE || mPr_CheckCmpPersonalID(&contest->player_id, &Common_Get(now_private)->player_ID) == TRUE) {
res = TRUE;
}
}
else {
mPr_ClearPersonalID(&contest->player_id);
}
}
return res;
}
static int aQMgr_actor_check_fin_flower(mQst_base_c* quest_info, Animal_c* animal) {
mQst_contest_c* contest = (mQst_contest_c*)quest_info;
return aQMgr_actor_check_flower(contest, animal->home_info.block_x, animal->home_info.block_z);
}
static int aQMgr_actor_check_fin_quest_have_item1(mQst_contest_c* contest, u8 item1_category) {
int res = FALSE;
if (contest->base.progress == 1 && mPr_NullCheckPersonalID(&contest->player_id) == TRUE && mPr_GetPossessionItemIdxItem1Category(Common_Get(now_private), item1_category) != -1) {
res = TRUE;
}
return res;
}
static int aQMgr_actor_check_fin_fish(mQst_base_c* quest_info, Animal_c* animal) {
mQst_contest_c* contest = (mQst_contest_c*)quest_info;
return aQMgr_actor_check_fin_quest_have_item1(contest, ITEM1_CAT_FISH);
}
static void aQMgr_actor_contest_insect_clear(QUEST_MANAGER_ACTOR* manager, aQMgr_regist_c* regist) {
lbRTC_time_c* rtc_time = Common_GetPointer(time.rtc_time);
if (regist != NULL && regist->quest_info != NULL) {
mQst_base_c* quest_info = regist->quest_info;
if (
(rtc_time->month <= lbRTC_FEBRUARY) ||
(rtc_time->month == lbRTC_NOVEMBER && rtc_time->day >= 29) ||
(rtc_time->month == lbRTC_DECEMBER) ||
(mQst_CheckLimitOver(quest_info) == TRUE)
) {
mQst_ClearContest((mQst_contest_c*)quest_info);
}
}
}
static int aQMgr_actor_check_fin_insect(mQst_base_c* quest_info, Animal_c* animal) {
mQst_contest_c* contest = (mQst_contest_c*)quest_info;
return aQMgr_actor_check_fin_quest_have_item1(contest, ITEM1_CAT_INSECT);
}
static int aQMgr_actor_check_fin_contest_letter(mQst_base_c* quest_info, Animal_c* animal) {
mQst_contest_c* contest = (mQst_contest_c*)quest_info;
int res = FALSE;
if (contest->base.progress == 1) {
res = TRUE;
}
return res;
}
static void aQMgr_save_contest_flower(aQMgr_regist_c* regist) {
mQst_contest_c* contest = (mQst_contest_c*)regist->quest_info;
Anmhome_c* home = &Save_Get(animals[regist->animal_idx]).home_info;
if (aQMgr_actor_check_flower(contest, home->block_x, home->block_z) == TRUE) {
mPr_ClearPersonalID(&contest->player_id);
mPr_CopyPersonalID(&contest->player_id, &Common_Get(now_private)->player_ID);
}
}
typedef void (*aQMgr_CONTEST_SAVE_PROC)(aQMgr_regist_c*);
static void aQMgr_save_contest(aQMgr_regist_c* regist) {
int contest_kind = regist->quest_info->quest_kind;
static aQMgr_CONTEST_SAVE_PROC save_proc[mQst_CONTEST_KIND_NUM] = {
(aQMgr_CONTEST_SAVE_PROC)&none_proc1,
(aQMgr_CONTEST_SAVE_PROC)&none_proc1,
(aQMgr_CONTEST_SAVE_PROC)&none_proc1,
&aQMgr_save_contest_flower,
(aQMgr_CONTEST_SAVE_PROC)&none_proc1,
(aQMgr_CONTEST_SAVE_PROC)&none_proc1,
(aQMgr_CONTEST_SAVE_PROC)&none_proc1
};
(*save_proc[contest_kind])(regist);
}
+85
View File
@@ -0,0 +1,85 @@
static void aQMgr_move_own_errand_cloth(QUEST_MANAGER_ACTOR* manager, aQMgr_regist_c* regist) {
mActor_name_t player_cloth = Common_Get(now_private)->cloth.item;
mQst_errand_c* errand = (mQst_errand_c*)regist->quest_info;
mActor_name_t cloth = errand->item;
switch (errand->base.progress) {
case 2:
if (cloth == player_cloth) {
errand->base.progress = 0;
}
break;
case 0:
if (cloth != player_cloth) {
errand->base.progress = 2;
}
break;
}
}
static void aQMgr_move_own_errand_seed(QUEST_MANAGER_ACTOR* manager, aQMgr_regist_c* regist) {
mActor_name_t* item_p = Common_Get(now_private)->inventory.pockets;
mQst_errand_c* errand = (mQst_errand_c*)regist->quest_info;
if (errand->base.progress == 2) {
int i;
for (i = 0; i < mPr_POCKETS_SLOT_COUNT; i++) {
if (ITEM_NAME_GET_TYPE(*item_p) == NAME_TYPE_ITEM1 && ITEM_NAME_GET_CAT(*item_p) == ITEM1_CAT_PLANT) {
break;
}
item_p++;
}
// Reset progress if no plants in inventory
if (i >= mPr_POCKETS_SLOT_COUNT) {
errand->base.progress = 0;
}
}
}
static void aQMgr_move_own_errand_letter(QUEST_MANAGER_ACTOR* manager, aQMgr_regist_c* regist) {
mQst_errand_c* errand = (mQst_errand_c*)regist->quest_info;
PersonalID_c* pid = &Common_Get(now_private)->player_ID;
AnmPersonalID_c* to_id;
Animal_c* animal = Save_Get(animals);
Anmmem_c* memory;
if (errand->base.progress == 2 || errand->base.progress == 3) {
int i;
to_id = &errand->recipient;
for (i = 0; i < ANIMAL_NUM_MAX; i++) {
if (mNpc_CheckCmpAnimalPersonalID(to_id, &animal->id) == TRUE) {
int idx;
memory = animal->memories;
idx = mNpc_GetAnimalMemoryIdx(pid, memory, ANIMAL_MEMORY_NUM);
if (idx != -1) {
memory += idx;
if (memory->letter_info.exists == TRUE) {
errand->base.progress = 0;
break;
}
}
}
animal++;
}
}
}
static void aQMgr_move_own_errand_hello(QUEST_MANAGER_ACTOR* manager, aQMgr_regist_c* regist) {
mQst_errand_c* errand = (mQst_errand_c*)regist->quest_info;
if (errand->base.progress == 2) {
if (mNpc_CheckFriendAllAnimal(&Common_Get(now_private)->player_ID) == TRUE && mSC_check_ArbeitPlayer()) {
errand->base.progress = 0;
}
}
}
File diff suppressed because it is too large Load Diff
+8 -6
View File
@@ -229,7 +229,7 @@ static s16 cKF_KeyCalc(s16 start_idx, s16 n_frames, s16* data_src, f32 frame) {
// Search through all frames
now = 0;
next = 1;
while (TRUE) {
if (key_p[next].frame > frame) {
f32 delta_frame = key_p[next].frame - key_p[now].frame;
@@ -237,15 +237,16 @@ static s16 cKF_KeyCalc(s16 start_idx, s16 n_frames, s16* data_src, f32 frame) {
if (!(F32_IS_ZERO(delta_frame))) {
f32 t = (frame - key_p[now].frame) / delta_frame; // progress towards the next frame
f32 tension = delta_frame * (1.0f / 30.0f);
f32 calc = cKF_HermitCalc(t, tension, key_p[now].value, key_p[next].value, key_p[now].tangent, key_p[next].tangent);
int key = calc + 0.5;
f32 calc = cKF_HermitCalc(t, tension, key_p[now].value, key_p[next].value, key_p[now].tangent,
key_p[next].tangent);
int key = calc + 0.5; // Always round up
return key;
} else {
return key_p[now].value;
}
}
now++;
next++;
}
@@ -271,7 +272,7 @@ extern void cKF_SkeletonInfo_subRotInterpolation(f32 t, s16* out, s16 rot1, s16
* Morphs current state towards a target state with a given step size.
*
* Adjusts 'now' values towards 'target' values based on 'step', performing this operation
* for three consecutive s16 values starting from 'now' and 'target'.
* for three consecutive s16 values (x->y->z) starting from 'now' and 'target'.
*
* @param now Pointer to the current values.
* @param target Pointer to the target values to morph towards.
@@ -527,7 +528,8 @@ extern int cKF_SkeletonInfo_R_play(cKF_SkeletonInfo_R_c* keyframe) {
// Convert joint value to fixed-point format after scaling
jointFlag >>= 1; // Shift flag for next component x -> y -> z
// Reduce the value by 10% and clamp to [0, 360) degrees converted back to binangle (s16)
// Reduce the value by 90% and clamp to [0, 360) degrees converted back to binangle (s16)
// This effectively limits any joint's maximum rotation to be in the range of [-36.8, 36.7] degrees
adjustedJointValue = *jointValuePtr * 0.1f;
*jointValuePtr++ = DEG2SHORT_ANGLE(MOD_F(adjustedJointValue, 360.0f));
}
+1 -1
View File
@@ -288,7 +288,7 @@ extern void mAGrw_RenewalFgItem(lbRTC_time_c* time) {
mAGrw_RenewalFgItem_ovl(time, &haniwa_scheduled);
Save_Set(haniwa_scheduled, haniwa_scheduled);
if (ZURUMODE2_ENALBED()) {
if (ZURUMODE2_ENABLED()) {
mAGrw_SetDebugData();
}
}
+4 -4
View File
@@ -5185,13 +5185,13 @@ extern void mNpc_TalkInfoMove() {
}
}
extern void mNpc_TalkEndMove(int animal_idx, int feel) {
if (animal_idx >= 0 && animal_idx < ARRAY_COUNT(l_npc_talk_info) && feel >= 0 && feel < mNpc_FEEL_NUM) {
extern void mNpc_TalkEndMove(int animal_idx, int looks) {
if (animal_idx >= 0 && animal_idx < ARRAY_COUNT(l_npc_talk_info) && looks >= 0 && looks < mNpc_LOOKS_NUM) {
mNpc_Talk_Info_c* talk_info = &l_npc_talk_info[animal_idx];
talk_info->timer = 1000;
if (mNpc_CountTalkNum(animal_idx, feel) == TRUE && mNpc_CheckOverImpatient(animal_idx, feel) == TRUE) {
mNpc_SetUnlockTimer(&talk_info->unlock_timer, &talk_info->reset_timer, feel);
if (mNpc_CountTalkNum(animal_idx, looks) == TRUE && mNpc_CheckOverImpatient(animal_idx, looks) == TRUE) {
mNpc_SetUnlockTimer(&talk_info->unlock_timer, &talk_info->reset_timer, looks);
}
}
}