-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathCustomScripts.Items.cs
More file actions
371 lines (309 loc) · 14.6 KB
/
CustomScripts.Items.cs
File metadata and controls
371 lines (309 loc) · 14.6 KB
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
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
using lib.remnant2.analyzer.Model;
using lib.remnant2.saves.Model;
using lib.remnant2.saves.Model.Parts;
using lib.remnant2.saves.Model.Properties;
using lib.remnant2.saves.Navigation;
namespace lib.remnant2.analyzer;
internal static partial class CustomScripts
{
private static bool GoldenRibbon(LootItemContext lic)
{
// The injectable gives Golden Ribbon only in these locations
string[] locations =
[
"Council Chamber",
"Gilded Chambers",
"Glistering Cloister"
];
// The injectable gives Silver Ribbon only in these locations
string[] others =
[
"The Great Hall",
"Pathway of the Fallen",
"Shattered Gallery"
];
bool result = locations.Contains(lic.Location!.Name);
if (!result && !others.Contains(lic.Location.Name))
{
Logger.Warning($"Unknown location {lic.Location.Name} for GoldenRibbon");
}
return result;
}
private static bool SilverRibbon(LootItemContext lic)
{
// The injectable gives Silver Ribbon only in these locations
string[] locations =
[
"The Great Hall",
"Pathway of the Fallen",
"Shattered Gallery"
];
// The injectable gives Golden Ribbon only in these locations
string[] others =
[
"Council Chamber",
"Gilded Chambers",
"Glistering Cloister"
];
bool result = locations.Contains(lic.Location!.Name);
if (!result && !others.Contains(lic.Location.Name))
{
Logger.Warning($"Unknown location {lic.Location.Name} for GoldenRibbon");
}
return result;
}
private static bool CrimsonGuard(LootItemContext lic)
{
// Crimson Guard can only be obtained if we have Red Prince generated in the zone
return lic.Zone!.Locations.Any(x => x.Name == "Gilded Chambers");
}
private static bool QuiltedHeart(LootItemContext lic)
{
// We need 6 of the following quests
List<string> required =
[
"Quest_Boss_NightWeaver",
"Quest_Miniboss_BloatKing",
"Quest_Miniboss_DranGrenadier",
"Quest_Miniboss_FaeArchon",
"Quest_Miniboss_RedPrince",
"Quest_SideD_CrimsonHarvest",
"Quest_SideD_FaeCouncil",
"Quest_SideD_Ravenous",
"Quest_SideD_ThreeMenMorris",
"Quest_SideD_TownTurnToDust",
"Quest_SideD_CharnelHouse"
];
List<string> done = lic.World.ParentCharacter.Save.QuestCompletedLog;
// Either of these counts as one, the other one does not count
bool doneImposter = done.Contains("Quest_Boss_Faelin") || done.Contains("Quest_Boss_Faerlin");
int counter = doneImposter ? 1 : 0;
// Quests we have already done
foreach (string q in done)
{
if (required.Remove(q))
{
counter++;
}
}
List<DropReference> refs = lic.Zone!.Locations.SelectMany(x => x.DropReferences).ToList();
// Quests we can do in this save
foreach (DropReference dropReference in refs)
{
if (required.Remove(dropReference.Name))
{
counter++;
}
}
// And either of the two as above
if (!doneImposter && (refs.Exists( x => x.Name == "Quest_Boss_Faelin") || refs.Exists(x => x.Name == "Quest_Boss_Faerlin")))
{
counter++;
}
return counter >= 6;
}
private static bool RipenedHeart(LootItemContext lic)
{
// Have The Widow's Court location (for Thaen seed)
// Or have already planted the seed
Property? thaen = lic.World.ParentCharacter.WorldNavigator!.GetProperty("GrowthStage");
return thaen != null || lic.World.Zones.SelectMany( x=> x.Locations).Any(x => x.Name == "The Widow's Court");
}
private static bool ProfaneHeart(LootItemContext lic)
{
//Has to be in a campaign (not adventure)
return lic.World.IsCampaign;
}
private static bool DowngradedRing(LootItemContext lic)
{
// Only available in "The Core" story
bool exists = lic.Zone!.Story == "The Core";
if (exists)
{
// Incidentally we get blocked out of the item on the same condition as for VoidHeart
VoidHeart(lic);
}
return exists;
}
private static bool Anguish(LootItemContext lic)
{
string counterItemProfileId = "/Game/World_DLC1/Quests/Quest_Event_Dranception/Items/Quest_Item_DLC_DreamLevel.Quest_Item_DLC_DreamLevel_C";
InventoryItem? counterItem = lic.World.ParentCharacter.Profile.Inventory.SingleOrDefault(x => x.ProfileId == counterItemProfileId);
LootItemExtended dransDream = new(ItemDb.GetItemById("Consumable_DransDream"));
if (counterItem == null)
{
// The Anguish quest has not started, to start it we need Ethereal Manor
LootGroup? etherealManor = lic.World.Zones
.SingleOrDefault(x => x.Name == "Losomn")?.Locations.SelectMany(x => x.LootGroups)
.SingleOrDefault(x => x.EventDropReference == "Quest_Injectable_BurningCity_DLC");
// If we have it, add Anguish to it
etherealManor?.Items.Add(lic.LootItem);
etherealManor?.Items.Add(dransDream);
// remove Anguish form the Progression Loot Group
return false;
}
// We have Anguish quest, let's see what is the next part
switch (counterItem.Level)
{
case 0:
case null:
lic.World.Ward13.Locations[0].LootGroups.Single(x => x.Type == "Location").Items.Add(lic.LootItem);
break;
case 1:
List<LootItemExtended>? items = lic.World.Zones
.SingleOrDefault(x => x.Name == "Yaesha")?.Locations
.SingleOrDefault(x => x.Name == "The Red Throne")?.LootGroups.Single(x => x.Type == "Location").Items;
items?.Add(lic.LootItem);
items?.Add(dransDream);
break;
case 2:
items = lic.World.Zones
.SingleOrDefault(x => x.Name == "Labyrinth")?.Locations[0].LootGroups.Single(x => x.Type == "Location").Items;
items?.Add(lic.LootItem);
items?.Add(dransDream);
break;
case 3:
items = lic.World.Zones
.SingleOrDefault(x => x.Name == "N'Erud")?.Locations.SelectMany(x => x.LootGroups)
.SingleOrDefault(x => x.EventDropReference == "Quest_Boss_TalRatha")?.Items;
items?.Add(lic.LootItem);
items?.Add(dransDream);
break;
case 4:
items = lic.World.Zones
.SingleOrDefault(x => x.Name == "Root Earth")?.Locations.SelectMany(x => x.LootGroups)
.SingleOrDefault(x => x.EventDropReference == "Quest_RootEarth_Zone1")?.Items;
items?.Add(lic.LootItem);
items?.Add(dransDream);
break;
case 5:
items = lic.World.Zones
.SingleOrDefault(x => x.Name == "Losomn")?.Locations
.SingleOrDefault(x => x.Name == "The Tormented Asylum")?.LootGroups.Single(x => x.Type == "Location").Items;
items?.Add(lic.LootItem);
items?.Add(dransDream);
break;
}
// In any case we want to remove this from the Progression Loot Group
return false;
}
// Additional Prerequisites detection ----------------------------------------------------------------------------------------------------------
// Return true if additional check passes, returns false if additional prerequisites are missing
private static bool BandOfTheFanatic(LootItemContext lic)
{
// It is not possible to get it unless you *already* have the ritualist set
return Analyzer.CheckPrerequisites(lic.World, lic.LootItem, lic.LootItem.Properties["Prerequisite"], checkCanGet: false, checkCustom: false);
}
private static bool OneTrueKingSigil(LootItemContext lic)
{
// Since you need both sigils, and you cannot get both on a single playthrough, you need at least one *already*
return Analyzer.CheckPrerequisites(lic.World, lic.LootItem, "Ring_FaelinsSigil", checkCanGet: false, checkCustom: false) ||
Analyzer.CheckPrerequisites(lic.World, lic.LootItem, "Ring_FaerinsSigil", checkCanGet: false, checkCustom: false);
}
private static bool EchoOfTheForest(LootItemContext lic)
{
string counterItemProfileId = "/Game/World_DLC2/Quests/Quest_Story_DLC2/Items/Quest_Hidden_Item_Trinity_Counter.Quest_Hidden_Item_Trinity_Counter_C";
InventoryItem? counterItem = lic.World.ParentCharacter.Profile.Inventory.SingleOrDefault(x => x.ProfileId == counterItemProfileId);
int counter = 0;
if (counterItem != null)
{
counter = counterItem.Quantity ?? 1;
}
bool mementoAvailable = false;
Location? vale = lic.World.Zones.SingleOrDefault(x => x.Name == "Yaesha")?.Locations.SingleOrDefault(x => x.Name == "Luminous Vale");
if (vale != null)
{
mementoAvailable = !vale.LootGroups.Single(x => x.Type == "Location").Items.Single(x => x.Id == "Quest_Item_Story_DwellsItem").IsLooted;
}
string mementoItemName = "/Game/World_DLC2/Quests/Quest_Story_DLC2/Items/Quest_Item_Story_DwellsItem/Quest_Item_Story_DwellsItem.Quest_Item_Story_DwellsItem_C";
bool hasMemento = lic.World.QuestInventory.Any(x => x.ProfileId == mementoItemName);
return !(counter < 2 || counter < 3 && !(hasMemento || mementoAvailable));
}
private static bool CorruptedWeapon(LootItemContext lic)
{
string corruptedShardProfileId = "/Game/World_Base/Items/Materials/LumeniteCrystal/Material_CorruptedShard.Material_CorruptedShard_C";
InventoryItem? corruptedShardItem = lic.World.ParentCharacter.Profile.Inventory.SingleOrDefault(x => x.ProfileId == corruptedShardProfileId);
return corruptedShardItem?.Quantity >= 10;
}
// Additional IsLooted detection ----------------------------------------------------------------------------------------------------------
private static void Deceit(LootItemContext lic)
{
// If Faelin / Faerlin is killed, you cannot get the weapon from the other either
if (lic.LootItem.IsLooted)
{
lic.Zone!.Locations.SelectMany(x => x.LootGroups).SelectMany(x => x.Items).Single(x => x.Id == "Weapon_Godsplitter").IsLooted = true;
}
}
private static void Godsplitter(LootItemContext lic)
{
// If Faelin / Faerlin is killed, you cannot get the weapon from the other either
if (lic.LootItem.IsLooted)
{
lic.Zone!.Locations.SelectMany( x=> x.LootGroups).SelectMany( x=> x.Items).Single( x => x.Id == "Weapon_Deceit").IsLooted = true;
}
}
private static void VoidHeart(LootItemContext lic)
{
// If the Override Pin is used, then although Void Heart is not technically looted it can no longer be accessed
Actor theCore = lic.GetActor("Quest_Story_TheCore_C");
PropertyBag props = theCore.GetFirstObjectProperties()!;
bool endingB = props.Contains("Ending_B") && props["Ending_B"].Get<byte>() != 0;
if (endingB)
{
lic.LootItem.IsLooted = true;
}
}
private static void NecklaceOfFlowingLife(LootItemContext lic)
{
Navigator navigator = lic.World.ParentCharacter.WorldNavigator!;
Actor crypt = lic.GetActor("Quest_Injectable_CryptHidden_C");
string key = ((PropertyBag)navigator.GetProperty("Key", crypt)!.Get<StructProperty>().Value!)["ContainerKey"].Get<FName>().Name;
// Player has not been there yet
if (key == "None") return;
UObject? zone = navigator.GetObjects($"pc:{key}").SingleOrDefault();
// Player has not been there yet
if (zone == null) return;
List<KeyValuePair<ulong, Actor>> actors = ((PersistenceContainer)zone.Properties!.Properties[1].Value.Get<StructProperty>().Value!).Actors;
const int chestId = 86; // Let's pray to god it never changes
PropertyBag chest = actors.Single(x => x.Key == chestId).Value.GetFirstObjectProperties()!;
// Chest is not opened yet
if (!chest.Contains("Open") || chest["Open"].Get<byte>() == 0) return;
// The item is on the floor
bool itemOnTheFloor = actors.Any(x => x.Value.ToString() == "Amulet_NecklaceOfFlowingLife_C");
// If it is not on the floor it is looted
if (!itemOnTheFloor)
{
lic.LootItem.IsLooted = true;
}
}
private static void FaerlinsSigil(LootItemContext lic, string propertyName)
{
Actor crypt = lic.GetActor("Quest_Boss_Faerlin_C");
Component? component = crypt.GetFirstObjectComponents()?.FirstOrDefault(x => x.ComponentKey == "Variables");
if (component == null) return;
var value = component.Variables?.Items.FirstOrDefault(x => x.Key == propertyName).Value?.Value?.ToString();
if (value == "1")
{
lic.LootItem.IsLooted = true;
}
}
private static void Preacher(LootItemContext lic, string variable)
{
UObject o = lic.GetMeta();
KeyValuePair<string, Variable> vv = o.Components!.Single(x => x.ComponentKey == "Variables").Variables!.Items.SingleOrDefault(x => x.Key == variable);
lic.LootItem.IsLooted = vv.Key == variable && vv.Value.Value!.ToString() != "0";
}
private static void LittleGorge(LootItemContext lic)
{
Navigator navigator = lic.World.ParentCharacter.WorldNavigator!;
UObject? o = lic.GetRollObject();
if (o == null) return;
Property? p =navigator.GetProperty("isRitualPigAberrationDead", o);
if (p == null) return;
if (p.Get<byte>() != 0)
{
lic.LootItem.IsLooted = true;
}
return;
}
}