-
-
Notifications
You must be signed in to change notification settings - Fork 14
/
loadouts.ts
222 lines (202 loc) · 7.67 KB
/
loadouts.ts
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
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
import { DestinyClass } from 'bungie-api-ts/destiny2';
export interface LoadoutItem {
/** itemInstanceId of the item (if it's instanced) */
id?: string;
/** DestinyInventoryItemDefinition hash of the item */
hash: number;
/** Optional amount (for consumables), default to zero */
amount?: number;
/**
* The socket overrides for the item. These signal what DestinyInventoryItemDefinition
* (by it's hash) is supposed to be socketed into the given socket index.
*/
socketOverrides?: { [socketIndex: number]: number };
/**
* UTC epoch seconds timestamp of when the item was crafted. Used to
* match up items that have changed instance ID from being reshaped since they
* were added to the loadout.
*/
craftedDate?: number;
}
/** normally found inside DestinyLoadoutComponent, mapped to respective definition tables */
export interface InGameLoadoutIdentifiers {
colorHash: number;
iconHash: number;
nameHash: number;
}
export interface Loadout {
/**
* A globally unique (UUID) identifier for the loadout.
* Chosen by the client
*/
id: string;
name: string;
/** Optional longform notes about the loadout. */
notes?: string;
/**
* DestinyClass enum value for the class this loadout is restricted
* to. This is optional (set to Unknown for loadouts that can be used anywhere).
*/
classType: DestinyClass;
/**
* DestinyInventoryItemDefinition hash of an emblem to use as
* an icon for this loadout.
*
* @deprecated this was added for Little Light but never used by DIM.
*/
emblemHash?: number;
/**
* Whether to clear out other items when applying this loadout
* @deprecated in favor of parameters.clearWeapons and parameters.clearArmor
*/
/** Whether to clear out other items when applying this loadout */
clearSpace: boolean;
/** List of equipped items in the loadout */
equipped: LoadoutItem[];
/** List of unequipped items in the loadout */
unequipped: LoadoutItem[];
/** Information about the desired properties of this loadout - used to drive the Loadout Optimizer or apply Mod Loadouts */
parameters?: LoadoutParameters;
/** When was this Loadout initially created? Tracked automatically by the API - when saving a loadout this field is ignored. */
createdAt?: number;
/** When was this Loadout last changed? Tracked automatically by the API - when saving a loadout this field is ignored. */
lastUpdatedAt?: number;
/**
* Automatically added stat mods. These are separate from the manually chosen
* mods in parameters.mods, and are saved here to avoid having to figure them
* out all over again every time (especially since our algorithm might
* change). Combine this list and parameters.mods when displaying or actually
* applying the loadout.
*
* @deprecated we just throw away stat mods when using LO auto stats
*/
autoStatMods?: number[];
}
/** Whether armor of this type will have assumed masterworked stats in the Loadout Optimizer. */
export const enum AssumeArmorMasterwork {
/** No armor will have assumed masterworked stats. */
None = 1,
/** Only legendary armor will have assumed masterworked stats. */
Legendary,
/** All armor (legendary & exotic) will have assumed masterworked stats. */
All,
/** All armor (legendary & exotic) will have assumed masterworked stats, and Exotic Armor will be upgraded to have an artifice mod slot. */
ArtificeExotic,
}
/** How the loadouts menu and page should be sorted */
export const enum LoadoutSort {
ByEditTime,
ByName,
}
/**
* Parameters that explain how this loadout was chosen (in Loadout Optimizer)
* and at the same time, how this loadout should be configured when equipped.
* This can be used to re-load a loadout into Loadout Optimizer with its
* settings intact, or to equip the right mods when applying a loadout if AWA is
* ever released.
*
* Originally this was meant to model parameters independent of specific items,
* as a means of sharing Loadout Optimizer settings between users, but now we
* just share whole loadouts, so this can be used for any sort of parameter we
* want to add to loadouts.
*
* All properties are optional, but most have defaults specified in
* defaultLoadoutParameters that should be used if they are undefined.
*/
export interface LoadoutParameters {
/**
* The stats the user cared about for this loadout, in the order they cared about them and
* with optional range by tier. If a stat is "ignored" it should just be missing from this
* list.
*/
statConstraints?: StatConstraint[];
/**
* The mods that will be used with this loadout. Each entry is an inventory
* item hash representing the mod item. Hashes may appear multiple times.
* These are not associated with any specific item in the loadout - when
* applying the loadout we should automatically determine the minimum of
* changes required to match the desired mods, and apply these mods to the
* equipped items.
*/
mods?: number[];
/**
* If set, after applying the mods above, all other mods will be removed from armor.
*/
clearMods?: boolean;
/** Whether to clear out other weapons when applying this loadout */
clearWeapons?: boolean;
/** Whether to clear out other weapons when applying this loadout */
clearArmor?: boolean;
/**
* Mods that must be applied to a specific bucket hash. In general, prefer to
* use the flat mods list above, and rely on the loadout function to assign
* mods automatically. However there are some mods like shaders which can't
* be automatically assigned to the right piece. These only apply to the equipped
* item.
*/
modsByBucket?: {
[bucketHash: number]: number[];
};
/** The artifact unlocks relevant to this build. */
artifactUnlocks?: {
/** The item hashes of the unlocked artifact perk items. */
unlockedItemHashes: number[];
/** The season this set of artifact unlocks was chosen from. */
seasonNumber: number;
};
/**
* Whether to automatically add stat mods.
*/
autoStatMods?: boolean;
/**
* A search filter applied while editing the loadout in Loadout Optimizer,
* which constrains the items that can be in the loadout.
*/
query?: string;
/**
* Whether armor of this type will have assumed materwork stats in the Loadout Optimizer.
*/
assumeArmorMasterwork?: AssumeArmorMasterwork;
/**
* The InventoryItemHash of the pinned exotic, if any was chosen.
*/
exoticArmorHash?: number;
/**
* a user may optionally specify which icon/color/name will be used,
* if this DIM loadout is saved to an in-game slot
*/
inGameIdentifiers?: InGameLoadoutIdentifiers;
/**
* When calculating loadout stats, should "Font of ..." mods be assumed active
* and their runtime bonus stats be included?
*/
includeRuntimeStatBenefits?: boolean;
}
/**
* All properties of LoadoutParameters are optional, in order to make them
* compact when shared. Before using LoadoutParameters, merge it with these
* defaults.
*/
export const defaultLoadoutParameters: LoadoutParameters = {
statConstraints: [
{ statHash: 2996146975 }, //Mobility
{ statHash: 392767087 }, //Resilience
{ statHash: 1943323491 }, //Recovery
{ statHash: 1735777505 }, //Discipline
{ statHash: 144602215 }, //Intellect
{ statHash: 4244567218 }, //Strength
],
mods: [],
assumeArmorMasterwork: AssumeArmorMasterwork.None,
autoStatMods: true,
includeRuntimeStatBenefits: true,
};
/** A constraint on the values an armor stat can take */
export interface StatConstraint {
/** The stat definition hash of the stat */
statHash: number;
/** The minimum tier value for the stat. 0 if unset. */
minTier?: number;
/** The maximum tier value for the stat. 10 if unset. */
maxTier?: number;
}