From bc7fdd6fcb789872bd8fd13eecf439de622d7a2e Mon Sep 17 00:00:00 2001 From: SuperDude88 <82904174+SuperDude88@users.noreply.github.com> Date: Wed, 10 Apr 2024 23:13:59 -0400 Subject: [PATCH] daNpc_Bs1_c Work (#614) * daNpc_Bs1_c Work Almost matching * Every Time Always has to be something forgotten * Cleanup * Tiny Detail Slipped Through * Last One Hopefully --- include/d/actor/d_a_npc_bs1.h | 35 +- include/d/d_com_inf_game.h | 26 +- include/d/d_shop.h | 3 +- src/d/actor/d_a_npc_bs1.cpp | 1156 +++++++++++++++++++++++++++++++-- src/d/d_com_inf_game.cpp | 4 +- src/d/d_com_static.cpp | 4 + 6 files changed, 1163 insertions(+), 65 deletions(-) diff --git a/include/d/actor/d_a_npc_bs1.h b/include/d/actor/d_a_npc_bs1.h index 3d19b944b..2afcdeef3 100644 --- a/include/d/actor/d_a_npc_bs1.h +++ b/include/d/actor/d_a_npc_bs1.h @@ -56,15 +56,15 @@ public: void eventOrder(); void checkOrder(); u16 next_msgStatus(u32*); - void getMsg(); + u32 getMsg(); void setCollision(); void talkInit(); BOOL shopMsgCheck(u32); - void getDefaultMsg(); - void shopStickMoveMsgCheck(u32); + u32 getDefaultMsg(); + BOOL shopStickMoveMsgCheck(u32); BOOL checkBeastItemSellMsg(u32); - void normal_talk(); - void shop_talk(); + u16 normal_talk(); + u16 shop_talk(); u16 talk(); void createShopList(); BOOL isSellBomb(); @@ -91,6 +91,10 @@ public: BOOL _delete(); s32 _create(); BOOL CreateHeap(); + + static u8 m_tag_buy_item_max; + static u8 m_tag_buy_item; + static s16 m_tag_pay_rupee; public: /* 0x290 */ request_of_phase_process_class mPhase; @@ -113,11 +117,12 @@ public: /* 0x640 */ dNpc_EventCut_c mEventCut; /* 0x6AC */ dNpc_JntCtrl_c mJntCtrl; /* 0x6E0 */ STControl mStickControl; - /* 0x708 */ u8 m708[0x718 - 0x708]; + /* 0x708 */ s8 m708; + /* 0x709 */ u8 m70C[0x718 - 0x709]; /* 0x718 */ cXyz m718; /* 0x724 */ s16 m724; - /* 0x726 */ u16 m726; - /* 0x728 */ u8 m728[0x72E - 0x728]; + /* 0x726 */ csXyz m726; + /* 0x72C */ u16 m72C; /* 0x72E */ u8 m72E; /* 0x72F */ u8 m72F; /* 0x730 */ u8 m730; @@ -126,7 +131,7 @@ public: /* 0x733 */ u8 m733; /* 0x734 */ f32 m734; /* 0x738 */ u32 m738; - /* 0x73C */ u8 m73C[0x740 - 0x73C]; + /* 0x73C */ u32 m73C; /* 0x740 */ u32 m740; /* 0x744 */ u32 m744; /* 0x748 */ cXyz mItemPosOffsets[3]; @@ -145,12 +150,16 @@ public: /* 0x830 */ s8 m830; /* 0x831 */ u8 m831; /* 0x832 */ s8 mType; - /* 0x833 */ u8 mShopIndex; + /* 0x833 */ s8 mShopIndex; /* 0x834 */ s8 mActionStatus; - /* 0x835 */ u8 m835; - /* 0x836 */ u8 m836[0x83A - 0x836]; + /* 0x835 */ s8 m835; + /* 0x836 */ s8 m836; + /* 0x837 */ s8 m837; + /* 0x838 */ s8 m838; + /* 0x839 */ u8 m839; /* 0x83A */ s16 m83A; - /* 0x83C */ u8 m83C[0x844 - 0x83C]; + /* 0x83C */ u32 m83C; + /* 0x840 */ u32 m840; }; // Size: 0x844 class daNpc_Bs1_childHIO_c { diff --git a/include/d/d_com_inf_game.h b/include/d/d_com_inf_game.h index 3b0c81d11..7d59cbd35 100644 --- a/include/d/d_com_inf_game.h +++ b/include/d/d_com_inf_game.h @@ -277,11 +277,16 @@ public: mpPlayer[idx] = (daPy_py_c*)player; mCurCamera[idx] = cam; } + + int getMessageRupee() { return mMessageRupee; } int getItemRupeeCount() { return mItemRupeeCount; } void setItemRupeeCount(s32 count) { mItemRupeeCount += count; } void setMessageCountNumber(s16 num) { mMsgCountNumber = num; } + void setMessageSetNumber(s16 num) { mMsgSetNumber = num; } + s16 getMessageSetNumber() { return mMsgSetNumber; } + s16 getMiniGameRupee() { return mMiniGameRupee; } void setMiniGameRupee(s16 count) { mMiniGameRupee = count; } void plusMiniGameRupee(s16 count) { @@ -349,6 +354,7 @@ public: void setItemKeyNumCount(s16 num) { mItemKeyNumCount += num; } void setItemBeastNumCount(int i_idx, s16 num) { mItemBeastNumCounts[i_idx] += num; } + s16 getItemBeastNumCount(int i_idx) { return mItemBeastNumCounts[i_idx]; } void setItemTimeCount(s32 time) { mAirMeter = time; } void setItemTimeMax(s32 time) { field_0x4928 = time; } @@ -579,8 +585,8 @@ public: /* 0x48E8 */ s16 mItemBeastNumCounts[8]; /* 0x48F8 */ u8 field_0x48F8[0x4918 - 0x48F8]; /* 0x4918 */ u16 mMsgCountNumber; - /* 0x491A */ s16 field_0x491a; - /* 0x491C */ s16 field_0x491c; + /* 0x491A */ s16 mMsgSetNumber; + /* 0x491C */ s16 mMessageRupee; /* 0x491E */ s16 field_0x491e; /* 0x4920 */ s16 field_0x4920; /* 0x4922 */ s16 field_0x4922; @@ -744,6 +750,10 @@ inline int dComIfGs_getRupee() { return g_dComIfG_gameInfo.save.getPlayer().getPlayerStatusA().getRupee(); } +inline int dComIfGp_getMessageRupee() { + return g_dComIfG_gameInfo.play.getMessageRupee(); +} + inline void dComIfGs_setRupee(u16 rupee) { g_dComIfG_gameInfo.save.getPlayer().getPlayerStatusA().setRupee(rupee); } @@ -2126,6 +2136,14 @@ inline void dComIfGp_setItemRupeeCount(s32 count) { g_dComIfG_gameInfo.play.setItemRupeeCount(count); } +inline s16 dComIfGp_getMessageSetNumber() { + return g_dComIfG_gameInfo.play.getMessageSetNumber(); +} + +inline void dComIfGp_setMessageSetNumber(s16 num) { + g_dComIfG_gameInfo.play.setMessageSetNumber(num); +} + inline f32 dComIfGp_getItemLifeCount() { return g_dComIfG_gameInfo.play.getItemLifeCount(); } @@ -2194,6 +2212,10 @@ inline void dComIfGp_setItemBeastNumCount(int i_idx, s16 num) { g_dComIfG_gameInfo.play.setItemBeastNumCount(i_idx, num); } +inline s16 dComIfGp_getItemBeastNumCount(int i_idx) { + return g_dComIfG_gameInfo.play.getItemBeastNumCount(i_idx); +} + inline u8 dComIfGp_checkMesgSendButton() { return g_dComIfG_gameInfo.play.checkMesgSendButton(); } diff --git a/include/d/d_shop.h b/include/d/d_shop.h index 5b3772a27..909c4b48d 100644 --- a/include/d/d_shop.h +++ b/include/d/d_shop.h @@ -22,7 +22,7 @@ enum ShopItems_c__BuyConditions { }; struct ShopItems_c__ItemData { - /* 0x00 */ int mItemNo; + /* 0x00 */ u32 mItemNo; /* 0x04 */ int mMustNotOwnItemNo; /* 0x08 */ int mMustOwnItemNo; /* 0x0C */ u8 mBuyConditions; @@ -267,5 +267,6 @@ extern __shop_items_set_data* Item_set_data_bshop_4[]; extern __shop_items_set_data* Item_set_data_bshop_5[]; extern __shop_items_set_data* Item_set_data_bshop_6[]; extern __shop_items_set_data** Item_set_data_tbl[]; +extern Vec* Item_set_pos_data_tbl[]; #endif /* D_SHOP_H */ diff --git a/src/d/actor/d_a_npc_bs1.cpp b/src/d/actor/d_a_npc_bs1.cpp index 74eab13f9..4c307c11d 100644 --- a/src/d/actor/d_a_npc_bs1.cpp +++ b/src/d/actor/d_a_npc_bs1.cpp @@ -12,12 +12,14 @@ #include "d/d_kankyo.h" #include "d/d_shop.h" #include "d/d_snap.h" +#include "d/d_letter.h" #include "d/d_procname.h" #include "dolphin/types.h" #include "f_op/f_op_actor.h" #include "m_Do/m_Do_ext.h" #include "m_Do/m_Do_hostIO.h" #include "m_Do/m_Do_mtx.h" +#include "m_Do/m_Do_controller_pad.h" // Needed for the .data section to match. static Vec dummy_2100 = {1.0f, 1.0f, 1.0f}; @@ -399,11 +401,35 @@ void daNpc_Bs1_c::eventOrder() { /* 00000D40-00000F8C .text checkOrder__11daNpc_Bs1_cFv */ void daNpc_Bs1_c::checkOrder() { - /* Nonmatching */ + if(eventInfo.checkCommandDemoAccrpt()) { + if(m82A == 3) { + m82A = 0; + setAction(&getdemo_action, 0); + } + else if(m82A == 4) { + m82A = 0; + setAction(&event_action, 0); + } + } + else if (eventInfo.checkCommandTalk()) { + if(m82A == 1 || m82A == 2) { + m82A = 0; + m731 = 1; + talkInit(); + if(!dComIfGp_event_chkTalkXY()) { + cXyz pos(0.0f, 0.0f, 125.0f); + mShopCamAction.shop_cam_action_init(); + daPy_getPlayerActorClass()->setPlayerPosAndAngle(&pos, -0x6000); + } + } + } + else { + mShopCamAction.Save(); + } } /* 00000F8C-00001088 .text daNpc_Bs1_getBuyItemMax__Fii */ -int daNpc_Bs1_getBuyItemMax(int i_itemCost, int i_itemNo) { +static u32 daNpc_Bs1_getBuyItemMax(int i_itemCost, int i_itemNo) { int beastIdx; switch (i_itemNo) { case BOKOBABA_SEED: @@ -455,45 +481,790 @@ int daNpc_Bs1_getBuyItemMax(int i_itemCost, int i_itemNo) { if (r4 - r5 * i_itemCost != 0) { r5 += 1; } + return cLib_maxLimit(r5, beastNum); } -// ObjDiff isn't picking this up? /* 00001088-000010EC .text daNpc_Bs1_setPayRupee__Fii */ -void daNpc_Bs1_setPayRupee(int unknownParam1, int unknownParam2) { +static void daNpc_Bs1_setPayRupee(int unknownParam1, int unknownParam2) { /* Nonmatching */ + int rupee = dComIfGs_getRupee(); u16 walletSize; switch (dComIfGs_getWalletSize()) { - case 1: - walletSize = 1000; - break; - case 0: - walletSize = 200; - break; - default: - walletSize = 5000; - break; + case 0: + walletSize = 200; + break; + case 1: + walletSize = 1000; + break; + default: + walletSize = 5000; + break; } - int paymentTotal = unknownParam1 * unknownParam2; - if (walletSize - dComIfGs_getRupee() < paymentTotal) { - paymentTotal = walletSize - dComIfGs_getRupee(); + + int paymentTotal; + if(walletSize - rupee > unknownParam1 * unknownParam2) { + paymentTotal = unknownParam1 * unknownParam2; } - // Pay Tag Rupee = paymentTotal; + else { + paymentTotal = walletSize - rupee; + } + + daNpc_Bs1_c::m_tag_pay_rupee = paymentTotal; } /* 000010EC-00001F7C .text next_msgStatus__11daNpc_Bs1_cFPUl */ -u16 daNpc_Bs1_c::next_msgStatus(u32*) { +u16 daNpc_Bs1_c::next_msgStatus(u32* pMsgNo) { /* Nonmatching */ + u16 msgStatus = fopMsgStts_MSG_CONTINUES_e; + + switch(*pMsgNo) { + case 0xF50: + case 0xF53: + case 0xF55: + case 0xF56: + case 0xF58: + case 0xF6F: + case 0xF70: + case 0xF71: + case 0xF73: + case 0xF79: + case 0xF81: + case 0xF86: + case 0xF8B: + case 0xF90: + case 0xF95: + case 0xF9A: + case 0xF9F: + case 0xFD6: + case 0xFD7: + case 0x2F62: + case 0x2F64: + case 0x2F65: + case 0x2F67: + *pMsgNo += 1; + break; + case 0xF78: + case 0xF80: + case 0xF85: + case 0xF8A: + case 0xF8F: + case 0xF94: + case 0xF99: + case 0xF9E: + m83C = dComIfGp_getMessageRupee(); + int buyMax = daNpc_Bs1_getBuyItemMax(m83C, m840); + m_tag_buy_item_max = buyMax; + m_tag_buy_item = buyMax; + if(buyMax != 0) { + *pMsgNo += 1; + break; + } + + *pMsgNo = 0xF7E; + break; + case 0xFD4: + m83C = dComIfGp_getMessageRupee(); + buyMax = daNpc_Bs1_getBuyItemMax(m83C, m840); + m_tag_buy_item_max = buyMax; + m_tag_buy_item = buyMax; + if(buyMax != 0) { + *pMsgNo = 0xF9F; + break; + } + + *pMsgNo = 0xF7E; + break; + case 0xF7A: + case 0xF82: + case 0xF87: + case 0xF8C: + case 0xF91: + case 0xF96: + case 0xF9B: + case 0xFA0: + dComIfGp_setMessageSetNumber(1); + if(l_msg->mSelectNum == 0 && !dComIfGp_checkMesgCancelButton()) { + if(*pMsgNo == 0xFA0) { + *pMsgNo = 0xFD2; + break; + } + + *pMsgNo += 1; + break; + } + + *pMsgNo = 0xF7F; + break; + case 0xF7B: + case 0xF83: + case 0xF88: + case 0xF8D: + case 0xF92: + case 0xF97: + case 0xF9C: + case 0xFD2: + daNpc_Bs1_setPayRupee(m83C, m_tag_buy_item); + *pMsgNo += 1; + + break; + case 0xF7C: + case 0xF84: + case 0xF89: + case 0xF8E: + case 0xF93: + case 0xF98: + case 0xF9D: + case 0xFD3: + if(dComIfGp_checkMesgCancelButton()) { + *pMsgNo = 0xF7F; + break; + } + + if(l_msg->mSelectNum == 0) { + int idx; + switch(*pMsgNo) { + case 0xF7C: + idx = 1; + break; + case 0xF84: + idx = 0; + break; + case 0xF89: + idx = 4; + break; + case 0xF8E: + idx = 5; + break; + case 0xF93: + idx = 6; + break; + case 0xF98: + idx = 7; + break; + case 0xF9D: + idx = 2; + break; + case 0xFD3: + idx = 3; + break; + } + dComIfGp_setItemRupeeCount(m_tag_pay_rupee); + dComIfGp_setItemBeastNumCount(idx, -m_tag_buy_item); + + if(*pMsgNo == 0xFD3) { + u8 temp = m_tag_buy_item + dComIfGs_getEventReg(0x7F0F); + temp = temp > 0xF ? 0xF : temp; + + dComIfGs_setEventReg(0x7F0F, temp); + if(temp < 0xA) { + *pMsgNo = 0xFD5; + break; + } + + if(dComIfGs_isEventBit(0x3B04)) { + *pMsgNo = 0xFD9; + break; + } + + dComIfGs_onEventBit(0x3B04); + *pMsgNo = 0xFD6; + break; + } + + *pMsgNo = 0xF7D; + break; + } + + *pMsgNo -= 1; + break; + case 0xFD5: + *pMsgNo = 0xF7D; + break; + case 0x2F45: + case 0x2F46: + case 0x2F48: + case 0x2F50: + case 0x2F51: + case 0x2F52: + case 0x2F53: + case 0x2F54: + case 0x2F55: + case 0x2F58: + case 0x2F59: + case 0x2F5A: + case 0x2F5B: + case 0x2F5C: + case 0x2F5D: + case 0x2F5E: + case 0x2F5F: + case 0x2F60: + case 0x2F61: + case 0x2F66: + case 0x2F68: + *pMsgNo = 0x2F47; + break; + case 0x2F6B: + if(CPad_CHECK_TRIG_B(0)) { + *pMsgNo = 0x2F49; + break; + } + + dComIfGp_setDoStatusForce(0x17); + dComIfGp_setAStatusForce(0x27); + *pMsgNo = 0x2F6C; + + break; + case 0x2F6C: + if(dComIfGp_checkMesgCancelButton()) { + *pMsgNo = 0x2F6B; + break; + } + + if(l_msg->mSelectNum == 0) { + *pMsgNo = (int)cM_rndF(4.0f) + 0x2F6E; + break; + } + + *pMsgNo = 0x2F6D; + break; + case 0x2F6D: + case 0x2F6E: + case 0x2F6F: + case 0x2F70: + case 0x2F71: + *pMsgNo = 0x2F6B; + break; + case 0xF3D: + case 0xF41: + case 0xF57: + case 0xF59: + case 0xF5A: + case 0xF5B: + case 0xF5C: + case 0xF5D: + case 0xF5F: + case 0xF60: + *pMsgNo = 0xF3E; + break; + case 0xF5E: + *pMsgNo = 0xF62; + break; + case 0xF3E: + if(CPad_CHECK_TRIG_B(0)) { + u8 points = dComIfGs_getEventReg(0x86FF); + if(mShopItems.isSoldOutItemAll()) { + *pMsgNo = 0xF62; + break; + } + + if(points >= 60) { + *pMsgNo = 0xF61; + break; + } + + *pMsgNo = 0xF40; + break; + } + + dComIfGp_setDoStatusForce(0x17); + dComIfGp_setAStatusForce(0x27); + msgStatus = fopMsgStts_MSG_DISPLAYED_e; + break; + case 0x2F47: + if(CPad_CHECK_TRIG_B(0)) { + *pMsgNo = 0x2F49; + break; + } + + dComIfGp_setDoStatusForce(0x17); + dComIfGp_setAStatusForce(0x27); + msgStatus = fopMsgStts_MSG_DISPLAYED_e; + break; + case 0xF3F: + *pMsgNo = 0xF3E; + break; + case 0xF63: + case 0xF64: + case 0xF65: + case 0xF66: + if(CPad_CHECK_TRIG_B(0)) { + u8 points = dComIfGs_getEventReg(0x86FF); + if(mShopItems.isSoldOutItemAll()) { + *pMsgNo = 0xF62; + break; + } + + if(points >= 60) { + *pMsgNo = 0xF61; + break; + } + + *pMsgNo = 0xF40; + break; + } + + dComIfGp_setDoStatusForce(0x17); + dComIfGp_setAStatusForce(0x27); + msgStatus = fopMsgStts_MSG_DISPLAYED_e; + break; + case 0x2F78: + if(CPad_CHECK_TRIG_B(0)) { + *pMsgNo = 0x2F49; + break; + } + + dComIfGp_setDoStatusForce(0x17); + dComIfGp_setAStatusForce(0x27); + msgStatus = fopMsgStts_MSG_DISPLAYED_e; + break; + case 0xF42: + case 0xF43: + case 0xF44: + case 0xF67: + case 0xF69: + case 0xF6B: + case 0xF6D: + if(CPad_CHECK_TRIG_B(0)) { + u8 points = dComIfGs_getEventReg(0x86FF); + if(mShopItems.isSoldOutItemAll()) { + *pMsgNo = 0xF62; + break; + } + + if(points >= 60) { + *pMsgNo = 0xF61; + break; + } + + *pMsgNo = 0xF40; + break; + } + + dComIfGp_setDoStatusForce(0x17); + dComIfGp_setAStatusForce(0x27); + *pMsgNo = mShopItems.getSelectItemBuyMsg(); + break; + case 0x2F4A: + case 0x2F4B: + case 0x2F4C: + case 0x2F72: + case 0x2F74: + case 0x2F76: + if(CPad_CHECK_TRIG_B(0)) { + *pMsgNo = 0x2F49; + break; + } + + dComIfGp_setDoStatusForce(0x17); + dComIfGp_setAStatusForce(0x27); + *pMsgNo = mShopItems.getSelectItemBuyMsg(); + break; + case 0xF45: + case 0xF46: + case 0xF47: + case 0xF68: + case 0xF6A: + case 0xF6C: + case 0xF6E: + if(dComIfGp_checkMesgCancelButton()) { + *pMsgNo = mShopItems.getSelectItemShowMsg(); + break; + } + + if(l_msg->mSelectNum == 0) { + int rupee = dComIfGp_getMessageRupee(); + u8 status = dShop_BoughtErrorStatus(&mShopItems, 0, rupee); + + if(status & 1) { + *pMsgNo = 0xF49; + break; + } + if(status & 2) { + *pMsgNo = 0xF48; + break; + } + if(status & 0x20) { + *pMsgNo = 0xF4A; + break; + } + if(status & 4) { + *pMsgNo = 0xF4B; + break; + } + if(status & 0x10) { + *pMsgNo = 0xF4D; + break; + } + + fopAcM_seStart(this, JA_SE_SHOP_BOUGHT, 0); + mShopItems.hideSelectItem(); + dComIfGp_setItemRupeeCount(-rupee); + if(mShopItems.getSelectItemNo() == ESA_BAG) { + mShopItems.SoldOutItem(mShopItems.mSelectedItemIdx); + m76C[mShopItems.mSelectedItemIdx] = 1; + } + + int itemNo = mShopItems.getSelectItemNo(); + if(!checkItemGet(itemNo, 0)) { + m82A = 3; + msgStatus = fopMsgStts_MSG_ENDS_e; + break; + } + + itemNo = mShopItems.getSelectItemNo(); + execItemGet(itemNo); + + if(mType == 0) { + if(dComIfGs_getEventReg(0x86FF)) { + *pMsgNo = 0xF4C; + break; + } + + *pMsgNo = 0xF4E; + break; + } + + *pMsgNo = 0x2F53; + break; + } + + *pMsgNo = mShopItems.getSelectItemShowMsg(); + break; + case 0x2F4D: + case 0x2F4E: + case 0x2F4F: + case 0x2F73: + case 0x2F75: + case 0x2F77: + if(dComIfGp_checkMesgCancelButton()) { + *pMsgNo = mShopItems.getSelectItemShowMsg(); + break; + } + + if(l_msg->mSelectNum == 0) { + int rupee = dComIfGp_getMessageRupee(); + u32 status = dShop_BoughtErrorStatus(&mShopItems, 0, rupee); + + if(status & 0x20) { + *pMsgNo = 0x2F50; + break; + } + if(status & 4) { + *pMsgNo = 0x2F51; + break; + } + if(status & 0x10) { + *pMsgNo = 0x2F52; + break; + } + + fopAcM_seStart(this, JA_SE_SHOP_BOUGHT, 0); + mShopItems.hideSelectItem(); + dComIfGp_setItemRupeeCount(-rupee); + u8 itemNo = mShopItems.getSelectItemNo(); + if(itemNo == EMPTY_BOTTLE || itemNo == KAKERA_HEART || itemNo == COLLECT_MAP_30) { + mShopItems.SoldOutItem(mShopItems.mSelectedItemIdx); + m76C[mShopItems.mSelectedItemIdx] = 1; + + switch(itemNo) { + case EMPTY_BOTTLE: + dComIfGs_onEventBit(0x2020); + break; + case KAKERA_HEART: + dComIfGs_onEventBit(0x2010); + break; + case COLLECT_MAP_30: + dComIfGs_onEventBit(0x2008); + break; + } + } + + // these int casts are probably fake + if(!checkItemGet((int)mShopItems.getSelectItemNo(), 0)) { + m82A = 3; + msgStatus = fopMsgStts_MSG_ENDS_e; + break; + } + + execItemGet((int)mShopItems.getSelectItemNo()); + *pMsgNo = 0x2F53; + break; + } + + *pMsgNo = mShopItems.getSelectItemShowMsg(); + break; + case 0xF48: + case 0xF49: + case 0xF4A: + case 0xF4B: + case 0xF4D: + case 0xF4F: + case 0xF51: + case 0xF52: + case 0xF54: + *pMsgNo = 0xF3E; + break; + case 0xF4C: + case 0xF4E: + int points = dComIfGs_getEventReg(0x86FF); + points = points + 1 > 0xFF ? 0xFF : points + 1; + dComIfGs_setEventReg(0x86FF, points); + + if(points > 60) { + *pMsgNo = 0xF3E; + break; + } + + if(points == 60) { + dLetter_send(0xAF03); + *pMsgNo = 0xF53; + break; + } + + if(points > 30) { + *pMsgNo = 0xF52; + break; + } + + if(points == 30) { + dLetter_send(0xB003); + *pMsgNo = 0xF50; + break; + } + + *pMsgNo = 0xF4F; + break; + default: + msgStatus = fopMsgStts_MSG_ENDS_e; + } + + return msgStatus; } /* 00001F7C-000024B8 .text getMsg__11daNpc_Bs1_cFv */ -void daNpc_Bs1_c::getMsg() { +u32 daNpc_Bs1_c::getMsg() { /* Nonmatching */ + u32 msgNo; + if(m740) { + msgNo = m740; + m740 = 0; + } + else { + if(dComIfGp_event_chkTalkXY()) { + u8 itemNo = dComIfGp_event_getPreItemNo(); + + if(mType == 0) { + if(isEmono(itemNo)) { + m840 = itemNo; + switch(itemNo) { + case BOKOBABA_SEED: + msgNo = 0xF78; + break; + case SKULL_NECKLACE: + msgNo = 0xF80; + break; + case RED_JELLY: + msgNo = 0xF85; + break; + case GREEN_JELLY: + msgNo = 0xF8A; + break; + case BLUE_JELLY: + msgNo = 0xF8F; + break; + case dItem_JOY_PENDANT_e: + msgNo = 0xF94; + break; + case GOLDEN_FEATHER: + msgNo = 0xF99; + break; + default: + if(dComIfGs_getEventReg(0x7F0F) < 10) { + msgNo = 0xF9E; + break; + } + + msgNo = 0xFD4; + break; + } + } + else if(itemNo == KAISEN_PRESENT1) { + msgNo = 0xF6F; + } + else if(itemNo == KAISEN_PRESENT2) { + msgNo = 0xF73; + } + else { + msgNo = 0xF75; + } + } + else if(itemNo == KAISEN_PRESENT1 || itemNo == KAISEN_PRESENT2) { + msgNo = 0x2F56; + } + else if(isEmono(itemNo)) { + msgNo = 0x2F79; + } + else { + msgNo = 0x2F57; + } + } + else if(mType == 0) { + u8 points = dComIfGs_getEventReg(0x86FF); + if(mShopItems.isSoldOutItemAll()) { + msgNo = 0xF3D; + } + else if(dComIfGs_checkGetItem(BOMB_BAG) && !dComIfGs_isEventBit(0x1F20) && isSellBomb()) { + dComIfGs_onEventBit(0x1F20); + m837 = 1; + msgNo = 0xF55; + } + else if(m837) { + msgNo = 0xF58; + } + else if(points >= 60) { + if(m836) { + msgNo = 0xF5D; + } + else { + msgNo = 0xF5C; + m836 = 1; + } + } + else if(points != 0) { + if(m836) { + msgNo = 0xF5B; + } + else { + msgNo = 0xF5A; + m836 = 1; + } + } + else if(m836) { + msgNo = 0xF41; + } + else { + m836 = 1; + msgNo = 0xF3D; + } + } + else if(mShopItems.isSoldOutItemAll()) { + msgNo = 0x2F62; + } + else if(dComIfGs_checkGetItem(BOMB_BAG) && !dComIfGs_isEventBit(0x1F20) && isSellBomb()) { + dComIfGs_onEventBit(0x1F20); + m837 = 1; + msgNo = 0x2F64; + } + else if(m837) { + msgNo = 0x2F67; + } + else if(dComIfGs_isEventBit(0x1F08)) { + if(dComIfGs_isEventBit(0x2040)) { + if(m838 == 1) { + msgNo = 0x2F60; + } + else { + msgNo = 0x2F61; + } + } + else { + dComIfGs_onEventBit(0x2040); + msgNo = 0x2F5F; + m838 = 1; + } + } + else { + switch(dComIfGs_getEventReg(0xBB07)) { + case 0: + if(m836 || dComIfGs_isEventBit(0x1F10)) { + msgNo = 0x2F46; + break; + } + + dComIfGs_onEventBit(0x1F10); + msgNo = 0x2F45; + break; + case 1: + if(m836) { + msgNo = 0x2F46; + break; + } + + msgNo = 0x2F58; + break; + case 2: + if(m836) { + msgNo = 0x2F46; + break; + } + + msgNo = 0x2F59; + break; + case 3: + if(m836) { + msgNo = 0x2F46; + break; + } + + msgNo = 0x2F5A; + break; + case 4: + if(m836) { + msgNo = 0x2F46; + break; + } + + msgNo = 0x2F5B; + break; + case 5: + if(m836) { + msgNo = 0x2F46; + break; + } + + msgNo = 0x2F5C; + break; + case 6: + if(m836) { + msgNo = 0x2F69; + break; + } + + msgNo = 0x2F5D; + break; + case 7: + if(m836) { + msgNo = 0x2F6A; + break; + } + + msgNo = 0x2F5E; + } + + if(dComIfGs_isEventBit(0x1F10)) { + dComIfGs_onEventBit(0x1F10); + } + + m836 = 1; + } + } + + return msgNo; } /* 000024B8-00002574 .text setCollision__11daNpc_Bs1_cFv */ void daNpc_Bs1_c::setCollision() { - /* Nonmatching */ + cXyz offset(0.0f, 0.0f, 0.0f); + offset.z = -16.0f; + cXyz out; + MtxTrans(current.pos.x, current.pos.y, current.pos.z, false); + mDoMtx_YrotM(*calc_mtx, m726.y); + MtxPosition(&offset, &out); + mCyl.SetC(out); + mCyl.SetR(46.0f); + mCyl.SetH(130.0f); + dComIfG_Ccsp()->Set(&mCyl); } /* 00002574-00002580 .text talkInit__11daNpc_Bs1_cFv */ @@ -502,28 +1273,74 @@ void daNpc_Bs1_c::talkInit() { } /* 00002580-00002604 .text shopMsgCheck__11daNpc_Bs1_cFUl */ -BOOL daNpc_Bs1_c::shopMsgCheck(u32) { - /* Nonmatching */ +BOOL daNpc_Bs1_c::shopMsgCheck(u32 msgNo) { + if(mType == 0) { + if((0xF42 <= msgNo && msgNo <= 0xF54) || (0xF67 <= msgNo && msgNo <= 0xF6E) || (0xF63 <= msgNo && msgNo <= 0xF66) || msgNo == 0xF3E) { + return true; + } + } + else { + if((0x2F4A <= msgNo && msgNo <= 0x2F53) || (0x2F6B <= msgNo && msgNo <= 0x2F78) || msgNo == 0x2F47) { + return true; + } + } + + return false; } /* 00002604-00002624 .text daNpc_Bs1_getDefaultMsgCB__FPv */ -void daNpc_Bs1_getDefaultMsgCB(void* i_this) { - ((daNpc_Bs1_c*)i_this)->getDefaultMsg(); +static u32 daNpc_Bs1_getDefaultMsgCB(void* i_this) { + return static_cast(i_this)->getDefaultMsg(); } /* 00002624-00002714 .text getDefaultMsg__11daNpc_Bs1_cFv */ -void daNpc_Bs1_c::getDefaultMsg() { - /* Nonmatching */ +u32 daNpc_Bs1_c::getDefaultMsg() { + u32 msgNo; + + if(mType == 0) { + u8 points = dComIfGs_getEventReg(0x86FF); + if(mShopItems.isSoldOutItemAll()) { + msgNo = 0xF5E; + } + else if(points >= 60) { + msgNo = 0xF60; + } + else if(points != 0) { + msgNo = 0xF5F; + } + else { + msgNo = 0xF3F; + } + } + else if(!dComIfGs_isEventBit(0x1F08)) { + msgNo = 0x2F48; + } + else if(!dComIfGs_isEventBit(0x2108)) { + dComIfGs_onEventBit(0x2108); + msgNo = 0x2F54; + } + else { + msgNo = 0x2F55; + } + + return msgNo; } /* 00002714-000027B8 .text shopStickMoveMsgCheck__11daNpc_Bs1_cFUl */ -void daNpc_Bs1_c::shopStickMoveMsgCheck(u32) { - /* Nonmatching */ -} +BOOL daNpc_Bs1_c::shopStickMoveMsgCheck(u32 msgNo) { + if(mType == 0) { + if((0xF42 <= msgNo && msgNo <= 0xF44) || ((0xF67 <= msgNo && msgNo <= 0xF6E) && (msgNo & 1)) || (0xF63 <= msgNo && msgNo <= 0xF66) || msgNo == 0xF3E) { + return true; + } + } + else { + if((0x2F4A <= msgNo && msgNo <= 0x2F4C) || ((0x2F72 <= msgNo && msgNo <= 0x2F76) && !(msgNo & 1)) || msgNo == 0x2F78 || msgNo == 0x2F6B || msgNo == 0x2F47) { + return true; + } + } -daNpc_Bs1_c::ActionFunc temp_4449 = &daNpc_Bs1_c::getdemo_action; -daNpc_Bs1_c::ActionFunc temp_4454 = &daNpc_Bs1_c::event_action; -u8 temp_5447[0x20] = {}; + return false; +} /* 000027B8-000027EC .text checkBeastItemSellMsg__11daNpc_Bs1_cFUl */ BOOL daNpc_Bs1_c::checkBeastItemSellMsg(u32 msgNo) { @@ -551,23 +1368,131 @@ BOOL daNpc_Bs1_c::checkBeastItemSellMsg(u32 msgNo) { } /* 000027EC-000028D0 .text normal_talk__11daNpc_Bs1_cFv */ -void daNpc_Bs1_c::normal_talk() { - /* Nonmatching */ +u16 daNpc_Bs1_c::normal_talk() { + u16 status = l_msg->mStatus; + if(status == fopMsgStts_MSG_DISPLAYED_e) { + l_msg->mStatus = next_msgStatus(&m738); + if(l_msg->mStatus == fopMsgStts_MSG_CONTINUES_e) { + fopMsgM_messageSet(m738); + } + } + else if(status == fopMsgStts_BOX_CLOSED_e) { + l_msg->mStatus = fopMsgStts_MSG_DESTROYED_e; + } + else if(status == fopMsgStts_MSG_PREPARING_e) { + fopMsgM_demoMsgFlagOn(); + } + + cXyz pos = mShopCamAction.getItemZoomPos(100.0f); + mShopItems.Item_ZoomUp(pos); + mpShopCursor->hide(); + + return status; } /* 000028D0-000029EC .text shop_talk__11daNpc_Bs1_cFv */ -void daNpc_Bs1_c::shop_talk() { - /* Nonmatching */ +u16 daNpc_Bs1_c::shop_talk() { + mpShopCursor->show(); + if(dShop_now_triggercheck(l_msg, &mStickControl, &mShopItems, &m738, daNpc_Bs1_getDefaultMsgCB, this)) { + m708 = 1; + m73C = 0; + if(m738 == 0xF3F) { + m835 = 2; + } + } + + u16 status = l_msg->mStatus; + if(status == fopMsgStts_MSG_DISPLAYED_e || status == fopMsgStts_MSG_CONTINUES_e) { + if(m708) { + m708 = 0; + } + else { + m73C = m738; + l_msg->mStatus = next_msgStatus(&m73C); + if(l_msg->mStatus == fopMsgStts_MSG_CONTINUES_e) { + fopMsgM_messageSet(m73C); + } + } + } + else if(status == fopMsgStts_BOX_CLOSED_e) { + l_msg->mStatus = fopMsgStts_MSG_DESTROYED_e; + } + + return status; } /* 000029EC-00002C10 .text talk__11daNpc_Bs1_cFv */ u16 daNpc_Bs1_c::talk() { - /* Nonmatching */ + u16 status = 0xFF; + + if(m835 == 0) { + l_msgId = fpcM_ERROR_PROCESS_ID_e; + m738 = getMsg(); + m73C = 0; + m835 = 1; + } + else if(m835 != -1) { + if(l_msgId == fpcM_ERROR_PROCESS_ID_e) { + if(dComIfGp_event_chkTalkXY() && !dComIfGp_evmng_ChkPresentEnd()) { + return 0xFF; + } + else { + l_msgId = fopMsgM_messageSet(m738, this); + } + } + else { + setAnmFromMsgTag(); + switch(m835) { + case 1: + l_msg = fopMsgM_SearchByID(l_msgId); + if(l_msg) { + m835 = 2; + } + + break; + case 2: + status = normal_talk(); + break; + case 3: + status = shop_talk(); + break; + } + + if(dComIfGp_checkMesgSendButton()) { + m738 = l_msg->mMsgID; + if(!shopStickMoveMsgCheck(m738)) { + if(!shopMsgCheck(m738)) { + mShopItems.mSelectedItemIdx = -1; + + if(mShopItems.isHide()) { + mShopItems.showItem(); + } + } + + m835 = 2; + } + else { + if(m738 == 0xF3E || m738 == 0x2F47) { + mShopItems.mSelectedItemIdx = -1; + + if(mShopItems.isHide()) { + mShopItems.showItem(); + } + } + + m835 = 3; + } + } + } + } + + mShopCamAction.m54 = mShopItems.mSelectedItemIdx; + + return status; } /* 00002C10-00003018 .text createShopList__11daNpc_Bs1_cFv */ void daNpc_Bs1_c::createShopList() { - /* Nonmatching */ static __shop_items_set_data* Item_set_data3[] = { &shopItems_setData_Feedbag, &shopItems_setData_FoodAll, @@ -592,7 +1517,92 @@ void daNpc_Bs1_c::createShopList() { &shopItems_setData_map }; - csXyz sp08 = csXyz::Zero; + csXyz angle(csXyz::Zero); + + if(mType == 0) { + __shop_items_set_data** pDataSet; + switch(mShopIndex) { + case 3: + pDataSet = &Item_set_data3[0]; + break; + case 4: + pDataSet = &Item_set_data4[0]; + break; + case 5: + pDataSet = &Item_set_data5[0]; + break; + default: + pDataSet = &Item_set_data3[0]; + break; + } + + for(int i = 0; i < 3; i++) { + u8 itemNo = pDataSet[i]->mpItemData->mItemNo; + int idx = i; + if((itemNo == ESA_BAG && dComIfGs_checkGetItem(itemNo)) || (itemNo == dItem_HYOI_PEAR_e && dComIfGs_checkGetItem(BOMB_BAG))) { + itemNo = pDataSet[i + 3][0].mpItemData->mItemNo; + idx += 3; + } + + mShopItems.mItemActorProcessIds[i] = fopAcM_createShopItem((cXyz*)&Item_set_pos_data_tbl[mShopIndex][i], itemNo, &angle, fopAcM_GetRoomNo(this)); + mpItemSetList[i] = pDataSet[idx]; + } + } + else { + __shop_items_set_data** temp = &Item_set_dataBs2[0]; + __shop_items_set_data* dataSet[4]; + int index = 0; + + if(dComIfGs_checkGetItem(BOMB_BAG)) { + dataSet[index] = &shopItems_setData_Bomb30Bs2; + index = 1; + } + if(dComIfGs_getItem(0xC) != 0xFF) { + dataSet[index] = &shopItems_setData_arrow30Bs2; + index++; + } + dataSet[index] = &shopItems_setData_red_bottleBs2; + index++; + if(!dComIfGs_checkGetItem(BOMB_BAG)) { + dataSet[index] = &shopItems_setData_Bomb30Bs2; + index++; + } + if(dComIfGs_getItem(0xC) == 0xFF) { + dataSet[index] = &shopItems_setData_arrow30Bs2; + } + + int dataIdx = 0; + for(int i = 0; i < 3; i++) { + u8 itemNo = temp[i]->mpItemData->mItemNo; + if((i == 0 && dComIfGs_isEventBit(0x2020)) || (i == 1 && dComIfGs_isEventBit(0x2010)) || (i == 2 && dComIfGs_isEventBit(0x2008))) { + itemNo = dataSet[dataIdx]->mpItemData->mItemNo; + mpItemSetList[i] = dataSet[dataIdx]; + dataIdx++; + } + else { + mpItemSetList[i] = temp[i]; + } + + mShopItems.mItemActorProcessIds[i] = fopAcM_createShopItem((cXyz*)&Item_set_pos_data_tbl[mShopIndex][i], itemNo, &angle, fopAcM_GetRoomNo(this)); + } + } + + mShopItems.mNumItems = 3; + mShopItems.setItemSetDataList(mpItemSetList); + for(int i = 0; i < 3; i++) { + mShopItems.mSelectedItemIdx = i; + if((!dComIfGs_checkGetItem(BOMB_BAG) && isBomb(mShopItems.getSelectItemNo())) || (dComIfGs_getItem(0xC) == 0xFF && isArrow(mShopItems.getSelectItemNo()))) { + mShopItems.SoldOutItem(i); + m76C[i] = true; + } + else { + m76C[i] = false; + } + + mItemPosOffsets[i] = Item_set_pos_data_tbl[mShopIndex][i]; + } + + mShopItems.mSelectedItemIdx = -1; } /* 00003018-00003090 .text isSellBomb__11daNpc_Bs1_cFv */ @@ -608,11 +1618,66 @@ BOOL daNpc_Bs1_c::isSellBomb() { /* 00003090-00003478 .text CreateInit__11daNpc_Bs1_cFv */ BOOL daNpc_Bs1_c::CreateInit() { /* Nonmatching */ - m83A = dComIfGp_evmng_getEventIdx("BS1_GETDEMO", 0xFF); - mEventCut.setActorInfo("Bs1", this); - m83A = dComIfGp_evmng_getEventIdx("BS2_GETDEMO", 0xFF); - mEventCut.setActorInfo("Bs2", this); - + cXyz dummy(0.0f, 0.0f, 0.0f); + + m726.x = current.angle.x; + m726.y = current.angle.y; + m726.z = current.angle.z; + + attention_info.flags = fopAc_Attn_LOCKON_TALK_e | fopAc_Attn_ACTION_TALK_e; + attention_info.distances[1] = 0xAA; + attention_info.distances[3] = 0xAA; + + gravity = -30.0f; + + switch(mType) { + case 0: + setAction(&wait_action, 0); + m83A = dComIfGp_evmng_getEventIdx("BS1_GETDEMO", 0xFF); + mEventCut.setActorInfo("Bs1", this); + mEventCut.setJntCtrlPtr(&mJntCtrl); + break; + case 1: + setAction(&wait_action, 0); + m83A = dComIfGp_evmng_getEventIdx("BS2_GETDEMO", 0xFF); + mEventCut.setActorInfo("Bs2", this); + mEventCut.setJntCtrlPtr(&mJntCtrl); + break; + } + + eventInfo.setXyEventCB(daNpc_Bs1_XyEventCB); + m718 = current.pos; + mStts.Init(0xFF, 0xFF, this); + mCyl.Set(l_cyl_src); + mCyl.SetStts(&mStts); + + m836 = 0; + m837 = 0; + m708 = 0; + m740 = 0; + mShopIndex = fopAcM_GetParam(this) & 0xFF; + if(mShopIndex != -1) { + if(mType == 0) { + mShopIndex = cLib_minMaxLimit(mShopIndex + 2, 3, 5); + } + else { + mShopIndex = 6; + } + + mShopIndex = cLib_minMaxLimit(mShopIndex, 0, 7); + + mShopCamAction.setCamDataIdx(mShopIndex); + mShopItems.setItemDataIdx(mShopIndex); + mShopCamAction.setCamAction(0); + } + else { + mShopCamAction.setCamDataIdx(2); + mShopItems.setItemDataIdx(2); + mShopCamAction.setCamAction(0); + } + + createShopList(); + m82B = 2; mEventIdxs[0] = dComIfGp_evmng_getEventIdx("PUT_PRAICE_TICKET", 0xFF); mEventIdxs[1] = dComIfGp_evmng_getEventIdx("PUT_FULL_TICKET", 0xFF); @@ -746,9 +1811,6 @@ BOOL daNpc_Bs1_c::wait_action(void*) { return TRUE; } -daNpc_Bs1_c::ActionFunc temp_5966 = &daNpc_Bs1_c::wait_action; -daNpc_Bs1_c::ActionFunc temp_5969 = &daNpc_Bs1_c::wait_action; - /* 00003A70-00003CB4 .text getdemo_action__11daNpc_Bs1_cFPv */ BOOL daNpc_Bs1_c::getdemo_action(void*) { static char* a_name[] = { diff --git a/src/d/d_com_inf_game.cpp b/src/d/d_com_inf_game.cpp index fd4d430eb..2ede6d3af 100644 --- a/src/d/d_com_inf_game.cpp +++ b/src/d/d_com_inf_game.cpp @@ -91,8 +91,8 @@ void dComIfG_play_c::itemInit() { } mMsgCountNumber = 0; - field_0x491a = 0; - field_0x491c = 0; + mMsgSetNumber = 0; + mMessageRupee = 0; field_0x491e = 0; field_0x4920 = 0; field_0x4922 = 0; diff --git a/src/d/d_com_static.cpp b/src/d/d_com_static.cpp index 32203100e..1b5c70266 100644 --- a/src/d/d_com_static.cpp +++ b/src/d/d_com_static.cpp @@ -326,3 +326,7 @@ BOOL daStandItem_c::daiItemNodeCallBack(J3DNode*, int) { } bool daNpc_kam_c::m_hyoi_kamome; + +u8 daNpc_Bs1_c::m_tag_buy_item_max; +u8 daNpc_Bs1_c::m_tag_buy_item; +s16 daNpc_Bs1_c::m_tag_pay_rupee;