mirror of https://github.com/zeldaret/botw.git
Implement CookingMgr class (#113)
* Added CookingMgr fields and started on ctor * Implemented CookItem::copy * Implemented CookingMgr dtor * Marked CookingMgr createInstance as matching * Implemented CookingMgr::getCookItem * Added CookingMgr::cook decl * Added CookingMgr method decls * Replaced part of CookingMgr with sead::FixedObjArray * Added line separators in cookManager.h * Defined structs Ingredient and BoostArg in CookingMgr * Defined structs CookArg and CookIngredient * Renamed some fields of CookingMgr * Added struct CookingMgr::CookingEffectEntry * Started implementing CookingMgr::init * Set more entries in init * Set field _548 * Set field default values in init * Loaded string values from config * Set mCookingEffectEntries in init * Added conditional mConfig allocation * Added FixedTreeMap class to sead * Used FixedTreeMap in CookingMgr * Set CookingMgr constructor to default and marked it as matching * Removed field _31C from CookingMgr * Updated sead * Cleared _548 before filling * Used name hash for _548 keys * Fixed path setup * Changed type of _548 to sead::FixedTreeMap<u32, u32, 13> * Set mNMSSR to correct values * Fixed field init order * Rearranged variables * Swapped entry_hash comparisons * Changed CRC32 names and index values * Cast i to u64 * Renamed static crc32 variables * Renamed _548 to mCookingEffectNameIdMap * Marked static vars as const and used decimal numbers * Used sead::SafeArray for mNMMR and mNMSSR * Rearranged mNMMR and mNMSSR conditions * Removed size check from mNMMR and mNMSSR conditions * Removed size check from CEI conditions * Renamed mRes2 to mResHandle * Renamed cook args * Moved crc32 statics into Constants struct * Marked CookingMgr::init as matching * Renamed Constants to Crc32Constants * Added cookFail and cookFailForMissingConfig * Added NumIngredientsMax, NumEffects, and NumEffectSlots constants * Renamed getCookItem to setCookItem * Renamed x to getCookItem * Implemented getCookItem * Made setCookItem take a const ref * Decompiled cookCalcItemPrice * Marked cookCalcItemPrice as const * Fixed both cookFail and cookFailForMissingConfig * Added CookItem::reset * Added CookingMgr::resetCookItem * Moved ctor and dtor below static variables * Changed cookFailForMissingConfig arg to sead::SafeString * Started on cookCalcBoost * Moved CookItem into cookManager.h * Moved Cooking into Game * Moved CookingMgr to uking namespace * Inlined CookItem::reset * Renamed CookItem members * Fixed CookItem mangled names in uking_functions.csv * Added enum class CookEffectId * Moved CookingMgr ctor below disposer impl * Updated sead * Started on cookHandleBoostSuccessInner * Made changes to cookCalcBoost and cookHandleBoostSuccessInner * Extracted cookHandleBoostMonsterExtractInner * Removed found_monster_extract in cookCalcBoost * Marked cookCalcBoost as matching * Got cookHandleBoostMonsterExtractInner matching * Made changes to cookHandleBoostSuccessInner * Renamed discriminator to bonus in cookHandleBoostSuccessInner * Added CookingMgr::cookCalcSpiceBoost * Made changes to CookingMgr::cookCalcSpiceBoost * Added CookingMgr::cookCalcPotencyBoost * Mostly matched CookingMgr::cookCalcPotencyBoost * Added CookingMgr::getCookEffectId * Used getCookEffectId in cookCalcPotencyBoost * Set access modifiers in CookingMgr * Made cookCalcPotencyBoost const-correct * Marked global init as mismatching * Renamed CookingMgr functions in uking_functions.csv * Added CookingMgr::prepareCookArg * Added IngredientArray type * Added cookWithItems * Added CookingMgr::prepareCookArg * Fixed getCookEffectId * Fixed cookCalcPotencyBoost * Made changes to prepareCookArg * Got cookWithItems matching * Marked vars const * Removed commented-out destructor and UnkItem * Renamed CookIngredient._58 to count * Started on CookingMgr::cook * Extracted cookAdjustItem * Fixed ingredient setup * Extracted actor_info_data * Fixed some control flow for single ingredients * Fixed more control flow for single ingredients * Handled no effect and empty actor name * Renamed Ingredient::_10 to used_in_recipe * Fixed recipe control flow * Matched cookAdjustItem * Fixed InfoData instance uses * Removed BAD_RECIPE label * Rearranged to remove goto * Added cookCalcRecipeBoost * Extracted getCookEffectId * Extracted isCookFailure and isMedicine * Extracted getCookEffectIdFromTreeMap * Extracted findIngredientByName and findIngredientByTag * Marked nonmatching functions * Added resetArgCookData * Matched resetArgCookData and prepareCookArg * Added fields and handleMessage to CookPotRoot * Started on CookPotRoot::init_ * Added hasMonsterExtract * Added to CookPotRoot::handleMessage_ * Removed Ingredient::_4 field * Renamed CookItem::_224 to is_crit * Renamed CookingEffectEntry members * Renamed CookingMgr fields * Changed comparison in cook * Renamed actor_tag_iter to hash_iter and added num checks * Got cookCalcSpiceBoost closer to matching * Removed int_val init from cookCalcSpiceBoost * Inlined actor_data * Added `using namespace ksys::act` * Moved int_val outside loop * Marked cookCalcSpiceBoost as matching * Rearranged cookHandleBoostSuccessInner * Renamed cookCalcPotencyBoost to cookCalcIngredientsBoost * Renamed stamina_recover to vitality_boost * Renamed CookItem args to cook_item * Renamed cookFailForMissingConfig arg * Used IngredientArray in findIngredient functions * Renamed crit functions * Renamed getCookEffectId arg * Renamed getCookEffectId to getCookEffectIdByName * Added SetCookItemInDemo::oneShot_ * Matched SetCookItemInDemo::oneShot_ * Added comment about CookArg constructor and formatted * Removed TODO from CookingMgr * Marked WIP functions as non-matching * Fixed formatting * Matched sead::SafeArray<uking::CookIngredient, 5>::SafeArray * Added BoostArg default member initializers * Used auto for cooking_mgr in CookPotRoot::handleMessage_ * Used designated initializers for boost_arg and added whitespace * Used angle brackets for sead import * Removed [[maybe_unused]] from declaration * Used safeDelete * Inverted condition in CookingMgr::cookCalcCritBoost * Added getCookingEffectEntry getter and moved CookingEffectEntry up * Cleaned up CookingMgr::cookCalcSpiceBoost * Used loops to init ingredient num members * Converted CookingMgr fields to s32 * Cleaned up CookingMgr::cookCalcItemPrice * Renamed CookItem::item_price to sell_price * Used min and max in CookingMgr::cookCalcItemPrice * Inlined count vars in CookingMgr::cookCalcItemPrice * Removed explicit casts in CookingMgr::cookCalcItemPrice * Cleaned up and reformatted CookingMgr::cookCalcIngredientsBoost * Added casts back into CookingMgr::cookCalcItemPrice to silence warnings
This commit is contained in:
parent
969b1c3f33
commit
2340dc7bc0
|
@ -386,7 +386,7 @@ Address,Quality,Size,Name
|
|||
0x0000007100009ffc,O,000140,_ZNK4sead15RuntimeTypeInfo6DeriveIN4ksys4phys7UserTagEE9isDerivedEPKNS0_9InterfaceE
|
||||
0x000000710000a088,U,000140,
|
||||
0x000000710000a114,U,000316,CookResult::construct
|
||||
0x000000710000a250,O,000384,_ZN4ksys8CookItemC1Ev
|
||||
0x000000710000a250,O,000384,_ZN5uking8CookItemC1Ev
|
||||
0x000000710000a3d0,U,000532,
|
||||
0x000000710000a5e4,U,000736,act::copyCookResultToCookItem
|
||||
0x000000710000a8c4,U,000004,j_GameObject::m0
|
||||
|
@ -15657,7 +15657,7 @@ Address,Quality,Size,Name
|
|||
0x0000007100246168,O,000020,_ZN5uking6action17SetCookItemInDemoD1Ev
|
||||
0x000000710024617c,O,000052,_ZN5uking6action17SetCookItemInDemoD0Ev
|
||||
0x00000071002461b0,O,000008,_ZN5uking6action17SetCookItemInDemo5init_EPN4sead4HeapE
|
||||
0x00000071002461b8,U,000208,_ZN5uking6action17SetCookItemInDemo8oneShot_Ev
|
||||
0x00000071002461b8,O,000208,_ZN5uking6action17SetCookItemInDemo8oneShot_Ev
|
||||
0x0000007100246288,O,000360,_ZN5uking6action17SetCookItemInDemo11loadParams_Ev
|
||||
0x00000071002463f0,O,000288,_ZNK5uking6action17SetCookItemInDemo27checkDerivedRuntimeTypeInfoEPKN4sead15RuntimeTypeInfo9InterfaceE
|
||||
0x0000007100246510,O,000092,_ZNK5uking6action17SetCookItemInDemo18getRuntimeTypeInfoEv
|
||||
|
@ -22375,17 +22375,17 @@ Address,Quality,Size,Name
|
|||
0x0000007100357d1c,U,000008,uking::ai::DragonRootBase::m39
|
||||
0x0000007100357d24,U,000004,j__ZdlPv_95
|
||||
0x0000007100357d28,U,000176,AI_AI_CookPotRoot::ctor
|
||||
0x0000007100357dd8,U,000596,CookArg::ctor
|
||||
0x0000007100357dd8,O,000596,_ZN4sead9SafeArrayIN5uking14CookIngredientELi5EEC2Ev
|
||||
0x000000710035802c,U,000112,_ZN5uking2ai11CookPotRootD1Ev
|
||||
0x000000710035809c,U,000004,nullsub_1060
|
||||
0x00000071003580a0,U,000120,_ZN5uking2ai11CookPotRootD0Ev
|
||||
0x0000007100358118,U,000640,_ZN5uking2ai11CookPotRoot5init_EPN4sead4HeapE
|
||||
0x0000007100358118,M,000640,_ZN5uking2ai11CookPotRoot5init_EPN4sead4HeapE
|
||||
0x0000007100358398,U,000316,_ZN5uking2ai11CookPotRoot6enter_EPN4ksys3act2ai15InlineParamPackE
|
||||
0x00000071003584d4,U,000320,AI_AI_CookPotRoot::x
|
||||
0x0000007100358614,U,000488,_ZN5uking2ai11CookPotRoot5calc_Ev
|
||||
0x00000071003587fc,U,000192,_ZN5uking2ai11CookPotRoot6leave_Ev
|
||||
0x00000071003588bc,O,000100,_ZN5uking2ai11CookPotRoot11loadParams_Ev
|
||||
0x0000007100358920,U,000660,_ZN5uking2ai11CookPotRoot14handleMessage_ERKN4ksys7MessageE
|
||||
0x0000007100358920,M,000660,_ZN5uking2ai11CookPotRoot14handleMessage_ERKN4ksys7MessageE
|
||||
0x0000007100358bb4,O,000288,_ZNK5uking2ai11CookPotRoot27checkDerivedRuntimeTypeInfoEPKN4sead15RuntimeTypeInfo9InterfaceE
|
||||
0x0000007100358cd4,O,000092,_ZNK5uking2ai11CookPotRoot18getRuntimeTypeInfoEv
|
||||
0x0000007100358d30,U,000204,
|
||||
|
@ -53023,29 +53023,30 @@ Address,Quality,Size,Name
|
|||
0x000000710089f8c0,O,000140,_ZNK4sead15RuntimeTypeInfo6DeriveIN4ksys3res16EntryFactoryBaseEE9isDerivedEPKNS0_9InterfaceE
|
||||
0x000000710089f94c,U,000004,j__ZdlPv_390
|
||||
0x000000710089f950,U,000004,nullsub_5418
|
||||
0x000000710089f954,U,000792,sinitCookingEffectsAndCrc32
|
||||
0x000000710089fc6c,U,000084,
|
||||
0x000000710089fcc0,U,000528,CookItem::copy
|
||||
0x000000710089fed0,U,000120,CookingMgr::Disposer::dtor
|
||||
0x000000710089ff48,U,000128,CookingMgr::Disposer::dtorDelete
|
||||
0x000000710089ffc8,U,000128,CookingMgr::createInstance
|
||||
0x00000071008a0048,U,000664,CookingMgr::ctor
|
||||
0x00000071008a02e0,U,000484,CookingMgr::cookFail
|
||||
0x00000071008a04c4,U,000644,CookingMgr::cookFailForMissingConfig
|
||||
0x00000071008a0748,U,001112,CookingMgr::cookCalcBoost
|
||||
0x00000071008a0ba0,U,000436,CookingMgr::cookHandleBoostSuccessInner
|
||||
0x00000071008a0d54,U,000512,CookingMgr::cookCalc3
|
||||
0x00000071008a0f54,U,000604,CookingMgr::cookCalcItemPrice
|
||||
0x00000071008a11b0,U,001412,CookingMgr::cookCalc1
|
||||
0x00000071008a1734,U,000124,CookingMgr::__auto0
|
||||
0x00000071008a17b0,U,002908,CookingMgr::init
|
||||
0x00000071008a230c,U,003308,CookingMgr::cook
|
||||
0x00000071008a2ff8,U,001648,CookingMgr::resetArgCookData
|
||||
0x00000071008a3668,U,001628,
|
||||
0x00000071008a3cc4,U,001496,CookingMgr::cookWithItems
|
||||
0x00000071008a429c,U,000016,CookingMgr::getCookItem
|
||||
0x00000071008a42ac,U,000084,
|
||||
0x00000071008a4300,U,000008,CookingMgr::x
|
||||
0x000000710089f954,M,000792,_GLOBAL__sub_I_cookManager.cpp
|
||||
0x000000710089fc6c,O,000084,_ZN5uking8CookItem5resetEv
|
||||
0x000000710089fcc0,O,000528,_ZNK5uking8CookItem4copyERS0_
|
||||
0x000000710089fed0,O,000120,_ZN5uking10CookingMgr18SingletonDisposer_D1Ev
|
||||
0x000000710089ff48,O,000128,_ZN5uking10CookingMgr18SingletonDisposer_D0Ev
|
||||
0x000000710089ffc8,O,000128,_ZN5uking10CookingMgr14createInstanceEPN4sead4HeapE
|
||||
0x00000071008a0048,O,000664,_ZN5uking10CookingMgrC1Ev
|
||||
0x00000071008a02e0,O,000484,_ZN5uking10CookingMgr8cookFailERNS_8CookItemE
|
||||
0x00000071008a04c4,O,000644,_ZN5uking10CookingMgr24cookFailForMissingConfigERNS_8CookItemERKN4sead14SafeStringBaseIcEE
|
||||
0x00000071008a0748,O,000708,_ZNK5uking10CookingMgr17cookCalcCritBoostERKN4sead9SafeArrayINS0_10IngredientELi5EEERNS_8CookItemEPKNS0_8BoostArgE
|
||||
0x00000071008a0a0c,O,000404,_ZNK5uking10CookingMgr24cookHandleMonsterExtractERKN4sead9SafeArrayINS0_10IngredientELi5EEERNS_8CookItemE
|
||||
0x00000071008a0ba0,M,000436,_ZNK5uking10CookingMgr14cookHandleCritERKN4sead9SafeArrayINS0_10IngredientELi5EEERNS_8CookItemE
|
||||
0x00000071008a0d54,O,000512,_ZNK5uking10CookingMgr18cookCalcSpiceBoostERKN4sead9SafeArrayINS0_10IngredientELi5EEERNS_8CookItemE
|
||||
0x00000071008a0f54,O,000604,_ZNK5uking10CookingMgr17cookCalcItemPriceERKN4sead9SafeArrayINS0_10IngredientELi5EEERNS_8CookItemE
|
||||
0x00000071008a11b0,O,001412,_ZNK5uking10CookingMgr24cookCalcIngredientsBoostERKN4sead9SafeArrayINS0_10IngredientELi5EEERNS_8CookItemE
|
||||
0x00000071008a1734,O,000124,_ZNK5uking10CookingMgr21getCookEffectIdByNameERKN4sead14SafeStringBaseIcEE
|
||||
0x00000071008a17b0,O,002908,_ZN5uking10CookingMgr4initEPN4sead4HeapE
|
||||
0x00000071008a230c,M,003308,_ZN5uking10CookingMgr4cookERKNS_7CookArgERNS_8CookItemERKNS0_8BoostArgE
|
||||
0x00000071008a2ff8,O,001648,_ZNK5uking10CookingMgr16resetArgCookDataERNS_7CookArgERKN4sead6BufferINS3_15FixedSafeStringILi64EEEEEiRNS_8CookItemE
|
||||
0x00000071008a3668,O,001628,_ZNK5uking10CookingMgr14prepareCookArgERNS_7CookArgERKN4sead9SafeArrayINS3_15FixedSafeStringILi64EEELi5EEEiRNS_8CookItemE
|
||||
0x00000071008a3cc4,O,001496,_ZN5uking10CookingMgr13cookWithItemsERKN4sead14SafeStringBaseIcEES5_S5_S5_S5_RNS_8CookItemERKNS0_8BoostArgE
|
||||
0x00000071008a429c,O,000016,_ZN5uking10CookingMgr11setCookItemERKNS_8CookItemE
|
||||
0x00000071008a42ac,O,000084,_ZN5uking10CookingMgr13resetCookItemEv
|
||||
0x00000071008a4300,O,000008,_ZNK5uking10CookingMgr11getCookItemERNS_8CookItemE
|
||||
0x00000071008a4308,U,000016,
|
||||
0x00000071008a4318,U,000116,
|
||||
0x00000071008a438c,U,000048,
|
||||
|
@ -56385,8 +56386,8 @@ Address,Quality,Size,Name
|
|||
0x000000710096efb8,O,000688,_ZN5uking2ui16PauseMenuDataMgr7itemGetERKN4sead14SafeStringBaseIcEEiPKNS_3act18WeaponModifierInfoE
|
||||
0x000000710096f268,O,001876,_ZN5uking2ui16PauseMenuDataMgr10addToPouchERKN4sead14SafeStringBaseIcEENS0_13PouchItemTypeERNS1_5ListsEibPKNS_3act18WeaponModifierInfoEb
|
||||
0x000000710096f9bc,O,001700,_ZNK5uking2ui16PauseMenuDataMgr14saveToGameDataERKN4sead10OffsetListINS0_9PouchItemEEE
|
||||
0x0000007100970060,O,000248,_ZN5uking2ui16PauseMenuDataMgr11cookItemGetERKN4ksys8CookItemE
|
||||
0x0000007100970158,O,000268,_ZN5uking2ui16PauseMenuDataMgr26setCookDataOnLastAddedItemERKN4ksys8CookItemE
|
||||
0x0000007100970060,O,000248,_ZN5uking2ui16PauseMenuDataMgr11cookItemGetERKNS_8CookItemE
|
||||
0x0000007100970158,O,000268,_ZN5uking2ui16PauseMenuDataMgr26setCookDataOnLastAddedItemERKNS_8CookItemE
|
||||
0x0000007100970264,O,000116,_ZN5uking2ui16PauseMenuDataMgr22autoEquipLastAddedItemEv
|
||||
0x00000071009702d8,m,000268,_ZN5uking2ui16PauseMenuDataMgr9autoEquipEPNS0_9PouchItemERKN4sead10OffsetListIS2_EE
|
||||
0x00000071009703e4,m,000216,_ZN5uking2ui16PauseMenuDataMgr10unequipAllENS0_13PouchItemTypeE
|
||||
|
|
Can't render this file because it is too large.
|
|
@ -1,4 +1,11 @@
|
|||
#include "Game/AI/AI/aiCookPotRoot.h"
|
||||
#include "Game/DLC/aocHardModeManager.h"
|
||||
#include "Game/UI/uiPauseMenuDataMgr.h"
|
||||
#include "KingSystem/ActorSystem/Attention/actAttention.h"
|
||||
#include "KingSystem/ActorSystem/actActor.h"
|
||||
#include "KingSystem/Utils/Thread/Message.h"
|
||||
#include "KingSystem/World/worldEnvMgr.h"
|
||||
#include "KingSystem/World/worldManager.h"
|
||||
|
||||
namespace uking::ai {
|
||||
|
||||
|
@ -6,8 +13,20 @@ CookPotRoot::CookPotRoot(const InitArg& arg) : ksys::act::ai::Ai(arg) {}
|
|||
|
||||
CookPotRoot::~CookPotRoot() = default;
|
||||
|
||||
// NON_MATCHING
|
||||
bool CookPotRoot::init_(sead::Heap* heap) {
|
||||
return ksys::act::ai::Ai::init_(heap);
|
||||
auto* ingredients =
|
||||
new (heap, std::nothrow) sead::FixedSafeString<64>[CookingMgr::NumIngredientsMax];
|
||||
mCookIngredients.setBuffer(CookingMgr::NumIngredientsMax, ingredients);
|
||||
if (!mCookIngredients.isBufferReady()) {
|
||||
return false;
|
||||
}
|
||||
if (*mInitBurnState_m) {
|
||||
// TODO
|
||||
}
|
||||
mActor->getChemicalStuff();
|
||||
mProcLink.reset();
|
||||
return true;
|
||||
}
|
||||
|
||||
void CookPotRoot::enter_(ksys::act::ai::InlineParamPack* params) {
|
||||
|
@ -23,4 +42,68 @@ void CookPotRoot::loadParams_() {
|
|||
getAITreeVariable(&mCurrentCookResultHolder_a, "CurrentCookResultHolder");
|
||||
}
|
||||
|
||||
// NON_MATCHING
|
||||
bool CookPotRoot::handleMessage_(const ksys::Message& message) {
|
||||
if (message.getType().value == (u32)ksys::act::AttActionCode::Cook) {
|
||||
// 着火: "ignition" or "on fire"
|
||||
// This is checking if the pot is lit.
|
||||
if (isCurrentChild("着火")) {
|
||||
// TODO: sub_7100EDC4B8
|
||||
// TODO: GameSceneSubsys12 class
|
||||
// GameSceneSubsys12 handles carried items.
|
||||
// This needs to check if the player is targeting the pot.
|
||||
if (true /* TODO */) {
|
||||
if (!_48 /* TODO */) {
|
||||
_48 = true;
|
||||
|
||||
const int num_ingredients = 5; // TODO
|
||||
auto* cooking_mgr = CookingMgr::instance();
|
||||
|
||||
cooking_mgr->resetArgCookData(mCookArg, mCookIngredients, num_ingredients,
|
||||
mCookItem);
|
||||
|
||||
CookingMgr::BoostArg boost_arg{.always_boost = false,
|
||||
.enable_random_boost = true};
|
||||
|
||||
if (ksys::world::Manager::instance()->getEnvMgr()->isInBloodMoonTimeRange()) {
|
||||
boost_arg.always_boost = true;
|
||||
}
|
||||
|
||||
if (cooking_mgr->cook(mCookArg, mCookItem, boost_arg)) {
|
||||
if (const auto* hard_mode_manager = aoc::HardModeManager::instance()) {
|
||||
if (hard_mode_manager->checkFlag(
|
||||
aoc::HardModeManager::Flag::EnableHardMode)) {
|
||||
if (hard_mode_manager->isHardModeChangeOn(
|
||||
aoc::HardModeManager::HardModeChange::NerfHpRestore)) {
|
||||
hard_mode_manager->nerfHpRestore(&mCookItem.life_recover);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (true /* TODO: callCookingDemo */) {
|
||||
ui::PauseMenuDataMgr::instance()->removeGrabbedItems();
|
||||
cooking_mgr->setCookItem(mCookItem);
|
||||
mHasFinishedCookItem = true;
|
||||
return true;
|
||||
}
|
||||
_48 = false;
|
||||
mHasFinishedCookItem = false;
|
||||
// TODO
|
||||
} else {
|
||||
_48 = false;
|
||||
mHasFinishedCookItem = false;
|
||||
// TODO
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (message.getType().value != (u32)ksys::act::AttActionCode::KillTime) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// TODO: callDemo007_1
|
||||
return isCurrentChild("着火");
|
||||
}
|
||||
|
||||
} // namespace uking::ai
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
#pragma once
|
||||
|
||||
#include "Game/Cooking/cookManager.h"
|
||||
#include "KingSystem/ActorSystem/actAiAi.h"
|
||||
#include "KingSystem/ActorSystem/actBaseProcLink.h"
|
||||
|
||||
namespace uking::ai {
|
||||
|
||||
|
@ -14,12 +16,34 @@ public:
|
|||
void enter_(ksys::act::ai::InlineParamPack* params) override;
|
||||
void leave_() override;
|
||||
void loadParams_() override;
|
||||
bool handleMessage_(const ksys::Message& message) override;
|
||||
|
||||
protected:
|
||||
// map_unit_param at offset 0x38
|
||||
const bool* mInitBurnState_m{};
|
||||
// aitree_variable at offset 0x40
|
||||
void* mCurrentCookResultHolder_a{};
|
||||
bool _48;
|
||||
bool mHasFinishedCookItem;
|
||||
u8 _4A[6];
|
||||
CookArg mCookArg;
|
||||
sead::Buffer<sead::FixedSafeString<64>> mCookIngredients;
|
||||
u8 _240;
|
||||
u8 _241;
|
||||
u8 _242[6];
|
||||
// vtable
|
||||
void* _248;
|
||||
s64 _250;
|
||||
s32 _258;
|
||||
u8 _25C[4];
|
||||
u8 _260[8];
|
||||
u32 _268;
|
||||
ksys::act::BaseProcLink mProcLink;
|
||||
s32 _280;
|
||||
// vtable
|
||||
void* _288;
|
||||
CookItem mCookItem;
|
||||
};
|
||||
KSYS_CHECK_SIZE_NX150(CookPotRoot, 0x4B8);
|
||||
|
||||
} // namespace uking::ai
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
#include "Game/AI/Action/actionSetCookItemInDemo.h"
|
||||
#include "Game/Cooking/cookManager.h"
|
||||
#include "Game/UI/uiPauseMenuDataMgr.h"
|
||||
|
||||
namespace uking::action {
|
||||
|
||||
|
@ -10,6 +12,27 @@ bool SetCookItemInDemo::init_(sead::Heap* heap) {
|
|||
return ksys::act::ai::Action::init_(heap);
|
||||
}
|
||||
|
||||
bool SetCookItemInDemo::oneShot_() {
|
||||
CookItem cook_item{};
|
||||
|
||||
CookingMgr::BoostArg boost_arg{};
|
||||
|
||||
s32 adjusted_set_num = sead::Mathi::clampMin(*mSetNum_d, 1);
|
||||
|
||||
bool result = CookingMgr::instance()->cookWithItems(mPorchItemName01_d, mPorchItemName02_d,
|
||||
mPorchItemName03_d, mPorchItemName04_d,
|
||||
mPorchItemName05_d, cook_item, boost_arg);
|
||||
|
||||
if (!ui::PauseMenuDataMgr::instance() || !result)
|
||||
return false;
|
||||
|
||||
for (int i = 0; i < adjusted_set_num; i++) {
|
||||
ui::PauseMenuDataMgr::instance()->cookItemGet(cook_item);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void SetCookItemInDemo::loadParams_() {
|
||||
getDynamicParam(&mSetNum_d, "SetNum");
|
||||
getDynamicParam(&mPorchItemName01_d, "PorchItemName01");
|
||||
|
|
|
@ -11,6 +11,7 @@ public:
|
|||
~SetCookItemInDemo() override;
|
||||
|
||||
bool init_(sead::Heap* heap) override;
|
||||
bool oneShot_() override;
|
||||
void loadParams_() override;
|
||||
|
||||
protected:
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
add_subdirectory(Actor)
|
||||
add_subdirectory(AI)
|
||||
add_subdirectory(Cooking)
|
||||
add_subdirectory(Damage)
|
||||
add_subdirectory(DLC)
|
||||
add_subdirectory(UI)
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
target_sources(uking PRIVATE
|
||||
cookItem.cpp
|
||||
cookItem.h
|
||||
cookManager.cpp
|
||||
cookManager.h
|
||||
)
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,181 @@
|
|||
#pragma once
|
||||
|
||||
#include <container/seadBuffer.h>
|
||||
#include <container/seadSafeArray.h>
|
||||
#include <container/seadTreeMap.h>
|
||||
#include <heap/seadDisposer.h>
|
||||
#include "KingSystem/Resource/resHandle.h"
|
||||
#include "KingSystem/Utils/Byaml/Byaml.h"
|
||||
#include "KingSystem/Utils/Types.h"
|
||||
|
||||
namespace uking {
|
||||
|
||||
struct CookArg;
|
||||
struct CookIngredient;
|
||||
|
||||
enum class CookEffectId : s32 {
|
||||
None = -1,
|
||||
LifeRecover = 1,
|
||||
LifeMaxUp = 2,
|
||||
ResistHot = 4,
|
||||
ResistCold = 5,
|
||||
ResistElectric = 6,
|
||||
AttackUp = 10,
|
||||
DefenseUp = 11,
|
||||
Quietness = 12,
|
||||
MovingSpeed = 13,
|
||||
GutsRecover = 14,
|
||||
ExGutsMaxUp = 15,
|
||||
Fireproof = 16,
|
||||
};
|
||||
|
||||
struct CookItem {
|
||||
CookItem();
|
||||
|
||||
void reset();
|
||||
void copy(CookItem& to) const;
|
||||
|
||||
sead::FixedSafeString<64> actor_name{""};
|
||||
sead::SafeArray<sead::FixedSafeString<64>, 5> ingredients;
|
||||
f32 life_recover{};
|
||||
s32 effect_time{};
|
||||
s32 sell_price{};
|
||||
CookEffectId effect_id = CookEffectId::None;
|
||||
/// Can refer to life bonus, stamina recover, or stamina bonus, depending on `effect_id`.
|
||||
f32 vitality_boost{};
|
||||
bool is_crit{};
|
||||
};
|
||||
KSYS_CHECK_SIZE_NX150(CookItem, 0x228);
|
||||
|
||||
class CookingMgr {
|
||||
SEAD_SINGLETON_DISPOSER(CookingMgr)
|
||||
public:
|
||||
static constexpr s32 NumIngredientsMax = 5;
|
||||
static constexpr s32 NumEffects = 13;
|
||||
static constexpr s32 NumEffectSlots = 17;
|
||||
|
||||
struct Ingredient {
|
||||
u32 name_hash{};
|
||||
const CookIngredient* arg{};
|
||||
bool used_in_recipe{};
|
||||
al::ByamlIter actor_data{};
|
||||
};
|
||||
|
||||
using IngredientArray = sead::SafeArray<Ingredient, NumIngredientsMax>;
|
||||
|
||||
struct BoostArg {
|
||||
bool always_boost = false;
|
||||
bool enable_random_boost = false;
|
||||
};
|
||||
|
||||
CookingMgr();
|
||||
~CookingMgr();
|
||||
|
||||
private:
|
||||
struct CookingEffectEntry {
|
||||
int boost_time = 0;
|
||||
int max = 0;
|
||||
int min = 0;
|
||||
float multiplier = 1.0f;
|
||||
int ssa = 1;
|
||||
};
|
||||
|
||||
void cookFail(CookItem& cook_item);
|
||||
void cookFailForMissingConfig(CookItem& cook_item, const sead::SafeString& actor_name);
|
||||
void cookCalcCritBoost(const IngredientArray& ingredients, CookItem& cook_item,
|
||||
const BoostArg* boost_arg) const;
|
||||
void cookHandleMonsterExtract(const IngredientArray& ingredients, CookItem& cook_item) const;
|
||||
void cookHandleCrit(const IngredientArray& ingredients, CookItem& cook_item) const;
|
||||
void cookCalcSpiceBoost(const IngredientArray& ingredients, CookItem& cook_item) const;
|
||||
void cookCalcItemPrice(const IngredientArray& ingredients, CookItem& cook_item) const;
|
||||
void cookCalcIngredientsBoost(const IngredientArray& ingredients, CookItem& cook_item) const;
|
||||
void cookCalcRecipeBoost(const al::ByamlIter& recipe_iter, CookItem& cook_item) const;
|
||||
|
||||
void cookAdjustItem(CookItem& cook_item) const;
|
||||
|
||||
bool findIngredientByName(IngredientArray& ingredients, u32 name_hash,
|
||||
int num_ingredients) const;
|
||||
bool findIngredientByTag(IngredientArray& ingredients, u32 tag_hash, int num_ingredients) const;
|
||||
|
||||
bool isCookFailure(const CookItem& cook_item) const;
|
||||
bool isMedicine(const CookItem& cook_item) const;
|
||||
bool hasMonsterExtract(const IngredientArray& ingredients) const;
|
||||
|
||||
CookingEffectEntry& getCookingEffectEntry(CookEffectId id) {
|
||||
return mCookingEffectEntries[(int)id];
|
||||
}
|
||||
const CookingEffectEntry& getCookingEffectEntry(CookEffectId id) const {
|
||||
return mCookingEffectEntries[(int)id];
|
||||
}
|
||||
|
||||
CookEffectId getCookEffectId(u32 name_hash) const;
|
||||
CookEffectId getCookEffectIdFromTreeMap(u32 name_hash) const;
|
||||
|
||||
public:
|
||||
CookEffectId getCookEffectIdByName(const sead::SafeString& effect_name) const;
|
||||
|
||||
void init(sead::Heap* heap);
|
||||
|
||||
bool cook(const CookArg& arg, CookItem& cook_item, const BoostArg& boost_arg);
|
||||
|
||||
void resetArgCookData(CookArg& arg,
|
||||
const sead::Buffer<sead::FixedSafeString<64>>& ingredient_names,
|
||||
int num_ingredients, CookItem& cook_item) const;
|
||||
|
||||
void
|
||||
prepareCookArg(CookArg& arg,
|
||||
const sead::SafeArray<sead::FixedSafeString<64>, NumIngredientsMax>& item_names,
|
||||
int num_items, CookItem& cook_item) const;
|
||||
|
||||
bool cookWithItems(const sead::SafeString& item1, const sead::SafeString& item2,
|
||||
const sead::SafeString& item3, const sead::SafeString& item4,
|
||||
const sead::SafeString& item5, CookItem& cook_item,
|
||||
const CookingMgr::BoostArg& boost_arg);
|
||||
|
||||
void setCookItem(const CookItem& from);
|
||||
void resetCookItem();
|
||||
void getCookItem(CookItem& to) const;
|
||||
|
||||
private:
|
||||
al::ByamlIter* mConfig = nullptr;
|
||||
|
||||
ksys::res::Handle mResHandle;
|
||||
|
||||
sead::FixedSafeString<64> mFailActorName;
|
||||
sead::FixedSafeString<64> mFairyTonicName;
|
||||
sead::FixedSafeString<64> mMonsterExtractName;
|
||||
|
||||
u32 mFailActorNameHash = 0;
|
||||
u32 mFairyTonicNameHash = 0;
|
||||
u32 mMonsterExtractNameHash = 0;
|
||||
|
||||
f32 mLifeRecoverMultiplier = 1.0f;
|
||||
f32 mFailActorLifeRecoverMultiplier = 1.0f;
|
||||
s32 mFailActorLifeRecover = 4;
|
||||
s32 mStoneFoodActorLifeRecover = 1;
|
||||
s32 mCritEffectTime = 300;
|
||||
|
||||
sead::SafeArray<CookingEffectEntry, NumEffectSlots> mCookingEffectEntries;
|
||||
|
||||
sead::SafeArray<f32, NumIngredientsMax> mIngredientNumMultipliers;
|
||||
|
||||
sead::SafeArray<s32, NumIngredientsMax> mIngredientNumSuccessRates;
|
||||
|
||||
CookItem mCookItem;
|
||||
|
||||
sead::FixedTreeMap<u32, CookEffectId, NumEffects> mCookingEffectNameIdMap{};
|
||||
};
|
||||
KSYS_CHECK_SIZE_NX150(CookingMgr, 0x7D8);
|
||||
|
||||
struct CookIngredient {
|
||||
sead::FixedSafeString<64> name{""};
|
||||
int count{};
|
||||
};
|
||||
KSYS_CHECK_SIZE_NX150(CookIngredient, 0x60);
|
||||
|
||||
struct CookArg {
|
||||
sead::SafeArray<CookIngredient, CookingMgr::NumIngredientsMax> ingredients;
|
||||
};
|
||||
KSYS_CHECK_SIZE_NX150(CookArg, 0x1E0);
|
||||
|
||||
} // namespace uking
|
|
@ -5,6 +5,7 @@
|
|||
#include <math/seadMathCalcCommon.h>
|
||||
#include <prim/seadScopedLock.h>
|
||||
#include "Game/Actor/actWeapon.h"
|
||||
#include "Game/Cooking/cookManager.h"
|
||||
#include "Game/DLC/aocManager.h"
|
||||
#include "Game/UI/uiUtils.h"
|
||||
#include "Game/gameItemUtils.h"
|
||||
|
@ -17,7 +18,6 @@
|
|||
#include "KingSystem/ActorSystem/actInfoCommon.h"
|
||||
#include "KingSystem/ActorSystem/actInfoData.h"
|
||||
#include "KingSystem/ActorSystem/actPlayerInfo.h"
|
||||
#include "KingSystem/Cooking/cookItem.h"
|
||||
#include "KingSystem/GameData/gdtCommonFlagsUtils.h"
|
||||
#include "KingSystem/GameData/gdtSpecialFlags.h"
|
||||
#include "KingSystem/System/PlayReportMgr.h"
|
||||
|
@ -1017,30 +1017,30 @@ void PauseMenuDataMgr::saveToGameData(const sead::OffsetList<PouchItem>& list) c
|
|||
}
|
||||
}
|
||||
|
||||
void PauseMenuDataMgr::cookItemGet(const ksys::CookItem& cook_item) {
|
||||
void PauseMenuDataMgr::cookItemGet(const uking::CookItem& cook_item) {
|
||||
const auto* info = ksys::act::InfoData::instance();
|
||||
if (!info->hasTag(cook_item.name.cstr(), ksys::act::tags::CookResult))
|
||||
if (!info->hasTag(cook_item.actor_name.cstr(), ksys::act::tags::CookResult))
|
||||
return;
|
||||
|
||||
const auto lock = sead::makeScopedLock(mCritSection);
|
||||
auto& lists = mItemLists;
|
||||
|
||||
ksys::PlayReportMgr::instance()->reportDebug("PouchGet", cook_item.name);
|
||||
const auto type = getType(cook_item.name);
|
||||
addToPouch(cook_item.name, type, lists, 1, false);
|
||||
ksys::PlayReportMgr::instance()->reportDebug("PouchGet", cook_item.actor_name);
|
||||
const auto type = getType(cook_item.actor_name);
|
||||
addToPouch(cook_item.actor_name, type, lists, 1, false);
|
||||
setCookDataOnLastAddedItem(cook_item);
|
||||
saveToGameData(lists.list1);
|
||||
}
|
||||
|
||||
void PauseMenuDataMgr::setCookDataOnLastAddedItem(const ksys::CookItem& cook_item) {
|
||||
void PauseMenuDataMgr::setCookDataOnLastAddedItem(const uking::CookItem& cook_item) {
|
||||
if (!mLastAddedItem)
|
||||
return;
|
||||
|
||||
mLastAddedItem->getCookData().setStaminaRecoverY(cook_item.stamina_recover_y);
|
||||
mLastAddedItem->getCookData().setStaminaRecoverX(cook_item.stamina_recover_x);
|
||||
mLastAddedItem->getCookData().setCookEffect1(cook_item.cook_effect_1);
|
||||
const int y = cook_item.cook_effect_0_y;
|
||||
const int x = cook_item.cook_effect_0_x;
|
||||
mLastAddedItem->getCookData().setStaminaRecoverY(cook_item.effect_time);
|
||||
mLastAddedItem->getCookData().setStaminaRecoverX(cook_item.life_recover);
|
||||
mLastAddedItem->getCookData().setCookEffect1(cook_item.sell_price);
|
||||
const int y = cook_item.vitality_boost;
|
||||
const CookEffectId x = cook_item.effect_id;
|
||||
mLastAddedItem->getCookData().setCookEffect0({float(x), float(y)});
|
||||
for (s32 i = 0; i < cook_item.ingredients.size(); ++i)
|
||||
mLastAddedItem->setIngredient(i, cook_item.ingredients[i]);
|
||||
|
|
|
@ -27,9 +27,9 @@ enum class WeaponModifier : u32;
|
|||
struct WeaponModifierInfo;
|
||||
} // namespace uking::act
|
||||
|
||||
namespace ksys {
|
||||
namespace uking {
|
||||
struct CookItem;
|
||||
}
|
||||
} // namespace uking
|
||||
|
||||
namespace uking::ui {
|
||||
|
||||
|
@ -262,9 +262,9 @@ public:
|
|||
bool isWeaponSectionFull(const sead::SafeString& get_flag) const;
|
||||
|
||||
void itemGet(const sead::SafeString& name, int value, const act::WeaponModifierInfo* modifier);
|
||||
void cookItemGet(const ksys::CookItem& cook_item);
|
||||
void cookItemGet(const uking::CookItem& cook_item);
|
||||
|
||||
void setCookDataOnLastAddedItem(const ksys::CookItem& cook_item);
|
||||
void setCookDataOnLastAddedItem(const uking::CookItem& cook_item);
|
||||
|
||||
void autoEquipLastAddedItem();
|
||||
const sead::SafeString& autoEquip(PouchItem* item, const sead::OffsetList<PouchItem>& list);
|
||||
|
|
|
@ -4,7 +4,6 @@ add_subdirectory(Resource)
|
|||
|
||||
add_subdirectory(ActorSystem)
|
||||
add_subdirectory(Chemical)
|
||||
add_subdirectory(Cooking)
|
||||
add_subdirectory(Ecosystem)
|
||||
add_subdirectory(Effect)
|
||||
add_subdirectory(Event)
|
||||
|
|
|
@ -1,7 +0,0 @@
|
|||
#include "KingSystem/Cooking/cookItem.h"
|
||||
|
||||
namespace ksys {
|
||||
|
||||
CookItem::CookItem() = default;
|
||||
|
||||
} // namespace ksys
|
|
@ -1,24 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
#include <basis/seadTypes.h>
|
||||
#include <container/seadSafeArray.h>
|
||||
#include <prim/seadSafeString.h>
|
||||
#include "KingSystem/Utils/Types.h"
|
||||
|
||||
namespace ksys {
|
||||
|
||||
struct CookItem {
|
||||
CookItem();
|
||||
|
||||
sead::FixedSafeString<64> name{""};
|
||||
sead::SafeArray<sead::FixedSafeString<64>, 5> ingredients;
|
||||
f32 stamina_recover_x{};
|
||||
s32 stamina_recover_y{};
|
||||
s32 cook_effect_1{};
|
||||
s32 cook_effect_0_x = -1;
|
||||
f32 cook_effect_0_y{};
|
||||
bool _224{};
|
||||
};
|
||||
KSYS_CHECK_SIZE_NX150(CookItem, 0x228);
|
||||
|
||||
} // namespace ksys
|
|
@ -1 +0,0 @@
|
|||
#include "KingSystem/Cooking/cookManager.h"
|
|
@ -1,15 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
#include <heap/seadDisposer.h>
|
||||
|
||||
namespace ksys {
|
||||
|
||||
// TODO
|
||||
class CookingMgr {
|
||||
SEAD_SINGLETON_DISPOSER(CookingMgr)
|
||||
CookingMgr();
|
||||
// TODO: inline
|
||||
~CookingMgr();
|
||||
};
|
||||
|
||||
} // namespace ksys
|
Loading…
Reference in New Issue