From 316dc2d1a276599c2a5e4324e25e8fd03f9bc8d7 Mon Sep 17 00:00:00 2001 From: Pistonight Date: Tue, 29 Apr 2025 20:26:40 -0700 Subject: [PATCH] matched (thanks to TheGreatB3 :) --- data/uking_functions.csv | 2 +- src/Game/UI/uiPauseMenuDataMgr.cpp | 197 ++++++++++++++++++++++++++++- src/Game/UI/uiPauseMenuDataMgr.h | 10 ++ 3 files changed, 204 insertions(+), 5 deletions(-) diff --git a/data/uking_functions.csv b/data/uking_functions.csv index 215d527a..3248b7bb 100644 --- a/data/uking_functions.csv +++ b/data/uking_functions.csv @@ -56489,7 +56489,7 @@ Address,Quality,Size,Name 0x000000710097dfa4,O,000240,_ZN5uking2ui16PauseMenuDataMgr17addNonDefaultItemERKN4sead14SafeStringBaseIcEEiPKNS_3act18WeaponModifierInfoE 0x000000710097e094,O,000204,_ZNK5uking2ui16PauseMenuDataMgr24openItemCategoryIfNeededEv 0x000000710097e160,O,001804,_ZN5uking2ui16PauseMenuDataMgr29initInventoryForOpenWorldDemoEv -0x000000710097e86c,U,006284,PauseMenuDataMgr::doAddToPouch +0x000000710097e86c,O,006284,_ZN5uking2ui16PauseMenuDataMgr12doAddToPouchENS0_13PouchItemTypeERKN4sead14SafeStringBaseIcEERNS1_5ListsEibPKNS_3act18WeaponModifierInfoEb 0x00000071009800f8,M,000612,_ZN5uking2ui9PouchItem15sortIngredientsEv 0x000000710098035c,O,000220,_ZN5uking2ui16PauseMenuDataMgr27updateDivineBeastClearFlagsEi 0x0000007100980438,O,000004,_ZN5uking2ui9PouchItemD0Ev diff --git a/src/Game/UI/uiPauseMenuDataMgr.cpp b/src/Game/UI/uiPauseMenuDataMgr.cpp index 6c591237..3840501e 100644 --- a/src/Game/UI/uiPauseMenuDataMgr.cpp +++ b/src/Game/UI/uiPauseMenuDataMgr.cpp @@ -20,7 +20,10 @@ #include "KingSystem/ActorSystem/actInfoData.h" #include "KingSystem/ActorSystem/actPlayerInfo.h" #include "KingSystem/GameData/gdtCommonFlagsUtils.h" +#include "KingSystem/GameData/gdtManager.h" +#include "KingSystem/GameData/gdtSpecialFlagNames.h" #include "KingSystem/GameData/gdtSpecialFlags.h" +#include "KingSystem/GameData/gdtTriggerParam.h" #include "KingSystem/System/PlayReportMgr.h" #include "KingSystem/Utils/Byaml/Byaml.h" #include "KingSystem/Utils/HeapUtil.h" @@ -257,12 +260,19 @@ void PauseMenuDataMgr::resetItem() { // NOLINTNEXTLINE(readability-convert-member-functions-to-static) void PauseMenuDataMgr::setItemModifier(PouchItem& item, const act::WeaponModifierInfo* modifier) { - if (modifier && !modifier->flags.isZero()) { - item.setWeaponModifier(modifier->flags.getDirect()); - item.setWeaponModifierValue(static_cast(modifier->value)); - } else { + if (!modifier) { item.setWeaponModifier(0); + return; } + + u32 flags = modifier->flags.getDirect(); + if (flags) { + item.setWeaponModifier(flags); + item.setWeaponModifierValue(modifier->value); + return; + } + + item.setWeaponModifier(0); } void PauseMenuDataMgr::init(sead::Heap* heap) {} @@ -922,6 +932,185 @@ void PauseMenuDataMgr::addToPouch(const sead::SafeString& name, PouchItemType ty ksys::gdt::setIsGetItem2(same_group_actor_name, true); } +void PauseMenuDataMgr::doAddToPouch(PouchItemType type, const sead::SafeString& name, Lists& lists, + int value, bool equipped, + const act::WeaponModifierInfo* modifier, + bool is_inventory_load) { + bool can_stack = + ksys::act::InfoData::instance()->hasTag(name.cstr(), ksys::act::tags::CanStack); + sead::FixedSafeString<0x80> item_name_to_add = sead::SafeString::cEmptyString; + ksys::act::getSameGroupActorName(&item_name_to_add, name); + + if (!is_inventory_load) { + if (ksys::act::InfoData::instance()->hasTag(item_name_to_add.cstr(), + ksys::act::tags::Arrow)) { + value *= ksys::act::getArrowArrowNum(ksys::act::InfoData::instance(), name.cstr()); + } + if (can_stack) { + for (auto& item : lists.list1) { + if (item_name_to_add != item.getName() || item.mValue < 0) { + continue; + } + item.mValue = std::clamp(item.mValue + value, 0, ItemStackSizeMax); + if (name == sValues.Obj_DungeonClearSeal) { + int current = item.mValue; + int max = 0; + auto* gdt_manager = ksys::gdt::Manager::instance(); + if (gdt_manager) { + sead::SafeString flag_name = ksys::gdt::flagname::DungeonClearSealNum(); + gdt_manager->getParam().get1().getBuffer1()->getMaxValueForS32(&max, + flag_name); + } + if (max < current) { + item.mValue = max; + } + } + + mLastAddedItem = &item; + resetItem(); + _444fc = 0; + return; + } + } + } + + // Add the item as a new slot + + if (cannotGetItem(name, can_stack ? value : 1)) { + return; + } + + if (item_name_to_add == sValues.Obj_WarpDLC) { + if (!aoc::Manager::instance()->hasAoc2()) { + return; + } + } + + if (!aoc::Manager::instance()->hasAoc3()) { + if (item_name_to_add == sValues.Obj_DLC_HeroSoul_Zora) { + item_name_to_add = sValues.Obj_HeroSoul_Zora; + } else if (item_name_to_add == sValues.Obj_DLC_HeroSoul_Rito) { + item_name_to_add = sValues.Obj_HeroSoul_Rito; + } else if (item_name_to_add == sValues.Obj_DLC_HeroSoul_Goron) { + item_name_to_add = sValues.Obj_HeroSoul_Goron; + } else if (item_name_to_add == sValues.Obj_DLC_HeroSoul_Gerudo) { + item_name_to_add = sValues.Obj_HeroSoul_Gerudo; + } + } else { + if (item_name_to_add == sValues.Obj_HeroSoul_Zora && + ksys::gdt::getFlag_IsGet_Obj_DLC_HeroSoul_Zora()) { + item_name_to_add = sValues.Obj_DLC_HeroSoul_Zora; + + } else if (item_name_to_add == sValues.Obj_HeroSoul_Rito && + ksys::gdt::getFlag_IsGet_Obj_DLC_HeroSoul_Rito()) { + item_name_to_add = sValues.Obj_DLC_HeroSoul_Rito; + + } else if (item_name_to_add == sValues.Obj_HeroSoul_Goron && + ksys::gdt::getFlag_IsGet_Obj_DLC_HeroSoul_Goron()) { + item_name_to_add = sValues.Obj_DLC_HeroSoul_Goron; + + } else if (item_name_to_add == sValues.Obj_HeroSoul_Gerudo && + ksys::gdt::getFlag_IsGet_Obj_DLC_HeroSoul_Gerudo()) { + item_name_to_add = sValues.Obj_DLC_HeroSoul_Gerudo; + } + } + + auto* added_item = lists.pushNewItem(); + if (!added_item) { + return; + } + added_item->mType = type; + added_item->mName = item_name_to_add; + added_item->setEquipped(equipped); + added_item->mItemUse = getItemUse(item_name_to_add); + + if (added_item->mType == PouchItemType::Arrow) { + ksys::gdt::setFlag_IsOpenItemCategory(true, u32(PouchCategory::Bow)); + } + + if (isPouchItemArmor(type)) { + if (ksys::act::InfoData::instance()->hasTag(item_name_to_add.cstr(), + ksys::act::tags::ArmorDye)) { + if (value >= 1 && value <= 15) { + added_item->mValue = value; + } else { + added_item->mValue = 0; + } + } else { + added_item->mValue = -1; + } + ksys::gdt::setFlag_IsOpenItemCategory(true, u32(PouchCategory::Armor)); + + mLastAddedItem = added_item; + resetItem(); + _444fc = 0; + return; + } + + switch (type) { + case PouchItemType::Sword: + if (value <= 0 && !isMasterSwordActorName(item_name_to_add)) { + value = 1; + } + ksys::gdt::setFlag_IsOpenItemCategory(true, u32(PouchCategory::Sword)); + setItemModifier(*added_item, modifier); + break; + case PouchItemType::Bow: + value = std::max(value, 1); + ksys::gdt::setFlag_IsOpenItemCategory(true, u32(PouchCategory::Bow)); + setItemModifier(*added_item, modifier); + break; + case PouchItemType::Shield: + value = std::max(value, 1); + ksys::gdt::setFlag_IsOpenItemCategory(true, u32(PouchCategory::Shield)); + setItemModifier(*added_item, modifier); + break; + case PouchItemType::Material: + value = std::clamp(value, 0, ItemStackSizeMax); + ksys::gdt::setFlag_IsOpenItemCategory(true, u32(PouchCategory::Material)); + break; + case PouchItemType::Food: + value = std::clamp(value, 0, ItemStackSizeMax); + ksys::gdt::setFlag_IsOpenItemCategory(true, u32(PouchCategory::Food)); + break; + case PouchItemType::KeyItem: + if (ksys::act::InfoData::instance()->hasTag(item_name_to_add.cstr(), + ksys::act::tags::HeroSoul)) { + if (!is_inventory_load) { + // when getting champion ability, it's enabled by default + added_item->mEquipped = true; + } + if (sValues.Obj_HeroSoul_Zora == item_name_to_add) { + mZoraSoulItem = added_item; + } else if (sValues.Obj_HeroSoul_Rito == item_name_to_add) { + mRitoSoulItem = added_item; + } else if (sValues.Obj_HeroSoul_Goron == item_name_to_add) { + mGoronSoulItem = added_item; + } else if (sValues.Obj_HeroSoul_Gerudo == item_name_to_add) { + mGerudoSoulItem = added_item; + } else if (sValues.Obj_DLC_HeroSoul_Zora == item_name_to_add) { + mZoraSoulItem = added_item; + } else if (sValues.Obj_DLC_HeroSoul_Rito == item_name_to_add) { + mRitoSoulItem = added_item; + } else if (sValues.Obj_DLC_HeroSoul_Goron == item_name_to_add) { + mGoronSoulItem = added_item; + } else if (sValues.Obj_DLC_HeroSoul_Gerudo == item_name_to_add) { + mGerudoSoulItem = added_item; + } + } + value = std::clamp(value, 0, ItemStackSizeMax); + ksys::gdt::setFlag_IsOpenItemCategory(true, u32(PouchCategory::KeyItem)); + break; + default: + break; + } + + added_item->mValue = value; + mLastAddedItem = added_item; + resetItem(); + _444fc = 0; +} + void PauseMenuDataMgr::saveToGameData(const sead::OffsetList& list) const { if (mIsPouchForQuest) return; diff --git a/src/Game/UI/uiPauseMenuDataMgr.h b/src/Game/UI/uiPauseMenuDataMgr.h index fd2efb30..0e1bf62b 100644 --- a/src/Game/UI/uiPauseMenuDataMgr.h +++ b/src/Game/UI/uiPauseMenuDataMgr.h @@ -195,6 +195,7 @@ public: PouchItemType getType() const { return mType; } bool isEquipped() const { return mEquipped; } + void setEquipped(bool equipped) { mEquipped = equipped; } bool isInInventory() const { return mInInventory; } const sead::SafeString& getName() const { return mName; } ItemUse getItemUse() const { return mItemUse; } @@ -419,6 +420,15 @@ private: list2.pushFront(item); } + PouchItem* pushNewItem() { + auto* item = list2.popFront(); + if (!item) { + return nullptr; + } + list1.pushBack(item); + return item; + } + sead::OffsetList list1; sead::OffsetList list2; sead::SafeArray buffer;