1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
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
|