-
Notifications
You must be signed in to change notification settings - Fork 21
/
RemnantWorldEvent.cs
452 lines (421 loc) · 18.7 KB
/
RemnantWorldEvent.cs
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
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Text.RegularExpressions;
using System.Xml;
using System.Net;
using System.Diagnostics;
namespace RemnantSaveManager
{
public class RemnantWorldEvent
{
private string eventKey;
private List<RemnantItem> mItems;
public string Location { get; set; }
public string Type { get; set; }
public string Name { get; set; }
public string MissingItems {
get {
return string.Join("\n", mItems);
}
}
public string PossibleItems
{
get
{
return string.Join("\n", this.getPossibleItems());
}
}
public enum ProcessMode { Campaign, Adventure, Subject2923 };
public string getKey()
{
return eventKey;
}
public void setKey(string key)
{
this.eventKey = key;
}
public List<RemnantItem> getPossibleItems()
{
List<RemnantItem> items = new List<RemnantItem>();
if (GameInfo.EventItem.ContainsKey(this.eventKey))
{
items = new List<RemnantItem>(GameInfo.EventItem[this.eventKey]);
}
return items;
}
public void setMissingItems(RemnantCharacter charData)
{
List<RemnantItem> missingItems = new List<RemnantItem>();
List<RemnantItem> possibleItems = this.getPossibleItems();
foreach (RemnantItem item in possibleItems)
{
if (!charData.Inventory.Contains(item.GetKey()))
{
missingItems.Add(item);
}
}
mItems = missingItems;
if (possibleItems.Count == 0 && !GameInfo.Events.ContainsKey(this.getKey()) && !this.getKey().Equals("TraitBook") && !this.getKey().Equals("Simulacrum"))
{
RemnantItem ri = new RemnantItem("/UnknownPotentialLoot");
mItems.Add(ri);
}
}
public override string ToString()
{
return this.Name;
}
//credit to /u/hzla00 for original javascript implementation
static public void ProcessEvents(RemnantCharacter character, string eventsText, ProcessMode mode)
{
Dictionary<string, Dictionary<string, string>> zones = new Dictionary<string, Dictionary<string, string>>();
Dictionary<string, List<RemnantWorldEvent>> zoneEvents = new Dictionary<string, List<RemnantWorldEvent>>();
List<RemnantWorldEvent> churchEvents = new List<RemnantWorldEvent>();
foreach (string z in GameInfo.Zones.Keys)
{
zones.Add(z, new Dictionary<string, string>());
zoneEvents.Add(z, new List<RemnantWorldEvent>());
}
string zone = null;
string currentMainLocation = "Fairview";
string currentSublocation = null;
string eventName = null;
MatchCollection matches = Regex.Matches(eventsText, "(?:/[a-zA-Z0-9_]+){3}/(([a-zA-Z0-9]+_[a-zA-Z0-9]+_[a-zA-Z0-9_]+)|Quest_Church)");
foreach (Match match in matches)
{
string eventType = null;
string lastEventname = eventName;
eventName = null;
string textLine = match.Value;
try
{
if (currentSublocation != null)
{
//Some world bosses don't have a preceding dungeon; subsequent items therefore spawn in the overworld
if (currentSublocation.Equals("TheRavager'sHaunt") || currentSublocation.Equals("TheTempestCourt")) currentSublocation = null;
}
zone = getZone(textLine);
eventType = getEventType(textLine);
if (textLine.Contains("Overworld_Zone") || textLine.Contains("_Overworld_"))
{
//process overworld zone marker
currentMainLocation = textLine.Split('/')[4].Split('_')[1] + " " + textLine.Split('/')[4].Split('_')[2] + " " + textLine.Split('/')[4].Split('_')[3];
if (GameInfo.MainLocations.ContainsKey(currentMainLocation))
{
currentMainLocation = GameInfo.MainLocations[currentMainLocation];
}
else
{
currentMainLocation = null;
}
continue;
}
else if (textLine.Contains("Quest_Church"))
{
//process Root Mother event
currentMainLocation = "Chapel Station";
eventName = "RootMother";
currentSublocation = "Church of the Harbinger";
}
else if (eventType != null)
{
//process other events, if they're recognized by getEventType
eventName = textLine.Split('/')[4].Split('_')[2];
if (textLine.Contains("OverworldPOI"))
{
currentSublocation = null;
}
else if (!textLine.Contains("Quest_Event"))
{
if (GameInfo.SubLocations.ContainsKey(eventName))
{
currentSublocation = GameInfo.SubLocations[eventName];
}
else
{
currentSublocation = null;
}
}
if ("Chapel Station".Equals(currentMainLocation))
{
if (textLine.Contains("Quest_Boss"))
{
currentMainLocation = "Westcourt";
} else
{
currentSublocation = null;
}
}
}
if (mode == ProcessMode.Adventure) currentMainLocation = null;
if (eventName != lastEventname)
{
RemnantWorldEvent se = new RemnantWorldEvent();
// Replacements
if (eventName != null)
{
se.setKey(eventName);
if (GameInfo.Events.ContainsKey(eventName)) {
se.Name = GameInfo.Events[eventName];
} else
{
se.Name = eventName;
}
se.Name = Regex.Replace(se.Name, "([a-z])([A-Z])", "$1 $2");
}
if (zone != null && eventType != null && eventName != null)
{
if (!zones[zone].ContainsKey(eventType))
{
zones[zone].Add(eventType, "");
}
if (!zones[zone][eventType].Contains(eventName))
{
zones[zone][eventType] += ", " + eventName;
List<string> locationList = new List<string>();
string zonelabel = zone;
if (GameInfo.Zones.ContainsKey(zone))
{
zonelabel = GameInfo.Zones[zone];
}
locationList.Add(zonelabel);
if (currentMainLocation != null) locationList.Add(Regex.Replace(currentMainLocation, "([a-z])([A-Z])", "$1 $2"));
if (currentSublocation != null) locationList.Add(Regex.Replace(currentSublocation, "([a-z])([A-Z])", "$1 $2"));
se.Location = string.Join(": ", locationList);
se.Type = eventType;
se.setMissingItems(character);
if (!"Chapel Station".Equals(currentMainLocation)) {
zoneEvents[zone].Add(se);
}
else
{
churchEvents.Insert(0, se);
}
// rings drop with the Cryptolith on Rhom
if (eventName.Equals("Cryptolith") && zone.Equals("Rhom"))
{
RemnantWorldEvent ringdrop = new RemnantWorldEvent();
ringdrop.Location = zone;
ringdrop.setKey("SoulLink");
ringdrop.Name = "Soul Link";
ringdrop.Type = "Item Drop";
ringdrop.setMissingItems(character);
zoneEvents[zone].Add(ringdrop);
}
// beetle always spawns in Strange Pass
else if (eventName.Equals("BrainBug"))
{
RemnantWorldEvent beetle = new RemnantWorldEvent();
beetle.Location = se.Location;
beetle.setKey("Sketterling");
beetle.Name = "Sketterling";
beetle.Type = "Loot Beetle";
beetle.setMissingItems(character);
zoneEvents[zone].Add(beetle);
}
else if (eventName.Equals("BarnSiege") || eventName.Equals("Homestead"))
{
RemnantWorldEvent wardPrime = new RemnantWorldEvent();
wardPrime.setKey("WardPrime");
wardPrime.Name = "Ward Prime";
wardPrime.Location = "Earth: Ward Prime";
wardPrime.Type = "Quest Event";
wardPrime.setMissingItems(character);
zoneEvents[zone].Add(wardPrime);
}
}
}
}
}
catch (Exception ex)
{
Console.WriteLine("Error parsing save event:");
Console.WriteLine("\tLine: " + textLine);
Console.WriteLine("\tError: " + ex.ToString());
}
}
List<RemnantWorldEvent> orderedEvents = new List<RemnantWorldEvent>();
bool churchAdded = false;
bool queenAdded = false;
bool navunAdded = false;
RemnantWorldEvent ward13 = new RemnantWorldEvent();
RemnantWorldEvent hideout = new RemnantWorldEvent();
RemnantWorldEvent undying = new RemnantWorldEvent();
RemnantWorldEvent queen = new RemnantWorldEvent();
RemnantWorldEvent navun = new RemnantWorldEvent();
RemnantWorldEvent ward17 = new RemnantWorldEvent();
if (mode == ProcessMode.Campaign)
{
ward13.setKey("Ward13");
ward13.Name = "Ward 13";
ward13.Location = "Earth: Ward 13";
ward13.Type = "Home";
ward13.setMissingItems(character);
if (ward13.MissingItems.Length > 0) orderedEvents.Add(ward13);
hideout.setKey("FoundersHideout");
hideout.Name = "Founder's Hideout";
hideout.Location = "Earth: Fairview";
hideout.Type = "Point of Interest";
hideout.setMissingItems(character);
if (hideout.MissingItems.Length > 0) orderedEvents.Add(hideout);
undying.setKey("UndyingKing");
undying.Name = "Undying King";
undying.Location = "Rhom: Undying Throne";
undying.Type = "World Boss";
undying.setMissingItems(character);
queen.Name = "Iskal Queen";
queen.setKey("IskalQueen");
queen.Location = "Corsus: The Mist Fen";
queen.Type = "Point of Interest";
queen.setMissingItems(character);
navun.Name = "Fight With The Rebels";
navun.setKey("SlaveRevolt");
navun.Location = "Yaesha: Shrine of the Immortals";
navun.Type = "Siege";
navun.setMissingItems(character);
ward17.setKey("Ward17");
ward17.Name = "The Dreamer";
ward17.Location = "Earth: Ward 17";
ward17.Type = "World Boss";
ward17.setMissingItems(character);
}
for (int i = 0; i < zoneEvents["Earth"].Count; i++)
{
//if (mode == ProcessMode.Subject2923) Console.WriteLine(zoneEvents["Earth"][i].eventKey);
if (mode == ProcessMode.Campaign && !churchAdded && zoneEvents["Earth"][i].Location.Contains("Westcourt"))
{
foreach (RemnantWorldEvent rwe in churchEvents)
{
orderedEvents.Add(rwe);
}
churchAdded = true;
}
orderedEvents.Add(zoneEvents["Earth"][i]);
}
for (int i = 0; i < zoneEvents["Rhom"].Count; i++)
{
orderedEvents.Add(zoneEvents["Rhom"][i]);
}
if (mode == ProcessMode.Campaign && undying.MissingItems.Length > 0) orderedEvents.Add(undying);
for (int i = 0; i < zoneEvents["Corsus"].Count; i++)
{
if (mode == ProcessMode.Campaign && !queenAdded && zoneEvents["Corsus"][i].Location.Contains("The Mist Fen"))
{
if (queen.MissingItems.Length > 0) orderedEvents.Add(queen);
queenAdded = true;
}
orderedEvents.Add(zoneEvents["Corsus"][i]);
}
for (int i = 0; i < zoneEvents["Yaesha"].Count; i++)
{
if (mode == ProcessMode.Campaign && !navunAdded && zoneEvents["Yaesha"][i].Location.Contains("The Scalding Glade"))
{
if (navun.MissingItems.Length > 0) orderedEvents.Add(navun);
navunAdded = true;
}
orderedEvents.Add(zoneEvents["Yaesha"][i]);
}
for (int i = 0; i < zoneEvents["Reisum"].Count; i++)
{
/*if (mode == ProcessMode.Campaign && !navunAdded && zoneEvents["Yaesha"][i].Location.Contains("The Scalding Glade"))
{
if (navun.MissingItems.Length > 0) orderedEvents.Add(navun);
navunAdded = true;
}*/
orderedEvents.Add(zoneEvents["Reisum"][i]);
}
if (mode == ProcessMode.Campaign)
{
if (ward17.MissingItems.Length > 0) orderedEvents.Add(ward17);
}
for (int i = 0; i < orderedEvents.Count; i++)
{
if (mode == ProcessMode.Campaign || mode == ProcessMode.Subject2923)
{
character.CampaignEvents.Add(orderedEvents[i]);
}
else
{
character.AdventureEvents.Add(orderedEvents[i]);
}
}
if (mode == ProcessMode.Subject2923)
{
ward17.setKey("Ward17Root");
ward17.Name = "Harsgaard";
ward17.Location = "Earth: Ward 17 (Root Dimension)";
ward17.Type = "World Boss";
ward17.setMissingItems(character);
character.CampaignEvents.Add(ward17);
}
}
static private string getZone(string textLine)
{
string zone = null;
if (textLine.Contains("World_City") || textLine.Contains("Quest_Church") || textLine.Contains("World_Rural"))
{
zone = "Earth";
}
else if (textLine.Contains("World_Wasteland"))
{
zone = "Rhom";
}
else if (textLine.Contains("World_Jungle"))
{
zone = "Yaesha";
}
else if (textLine.Contains("World_Swamp"))
{
zone = "Corsus";
}
else if (textLine.Contains("World_Snow") || textLine.Contains("Campaign_Clementine"))
{
zone = "Reisum";
}
return zone;
}
static private string getEventType(string textLine)
{
string eventType = null;
if (textLine.Contains("SmallD"))
{
eventType = "Side Dungeon";
}
else if (textLine.Contains("Quest_Boss"))
{
eventType = "World Boss";
}
else if (textLine.Contains("Siege")|| textLine.Contains("Quest_Church"))
{
eventType = "Siege";
}
else if (textLine.Contains("Mini"))
{
eventType = "Miniboss";
}
else if (textLine.Contains("Quest_Event"))
{
if (textLine.Contains("Nexus"))
{
eventType = "Siege";
}
else if (textLine.Contains("Sketterling"))
{
eventType = "Loot Beetle";
}
else
{
eventType = "Item Drop";
}
}
else if (textLine.Contains("OverworldPOI") || textLine.Contains("OverWorldPOI") || textLine.Contains("OverworlPOI"))
{
eventType = "Point of Interest";
}
return eventType;
}
}
}