-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathEvents.cs
73 lines (60 loc) · 3.02 KB
/
Events.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
using BfevLibrary;
using Newtonsoft.Json;
using TotkRSTB;
namespace TotkRandomizer
{
public static class Events
{
private static int GetEventId(dynamic jsonEvent, string eventTitle, string eventName)
{
foreach (dynamic a in jsonEvent["Flowcharts"][eventTitle]["Events"])
{
if (a["Name"] == eventName)
{
return jsonEvent["Flowcharts"][eventTitle]["Events"].IndexOf(a);
}
}
return -1;
}
public static byte[] EditOpeningEvent(string filePath)
{
BfevFile bfev = BfevFile.FromBinary(HashTable.DecompressDataOther(File.ReadAllBytes(filePath)));
string jsonString = bfev.ToJson();
dynamic? jsonEvent = JsonConvert.DeserializeObject(jsonString);
if (jsonEvent != null)
{
// Change opening with Zelda walking to the waking up Ganondorf section
int event75Id = GetEventId(jsonEvent, "OpeningEvent", "Event75");
jsonEvent["Flowcharts"]["OpeningEvent"]["EntryPoints"]["IntroductionOpening"]["EventIndex"] = event75Id;
// Remove fade-in to allow loading screen to remain black
int event77Id = GetEventId(jsonEvent, "OpeningEvent", "Event77");
jsonEvent["Flowcharts"]["OpeningEvent"]["Events"][event77Id]["Parameters"]["IsStartOnEvent"]["Bool"] = false;
jsonEvent["Flowcharts"]["OpeningEvent"]["Events"][event77Id]["Parameters"]["BootEventName"]["String"] = "";
}
jsonString = JsonConvert.SerializeObject(jsonEvent, Formatting.Indented);
bfev = BfevFile.FromJson(jsonString);
byte[] modifiedData = HashTable.CompressDataOther(bfev.ToBinary());
File.WriteAllBytes(filePath, modifiedData);
return modifiedData;
}
public static byte[] EditDungeonGoalEvent(string filePath)
{
BfevFile bfev = BfevFile.FromBinary(HashTable.DecompressDataOther(File.ReadAllBytes(filePath)));
string jsonString = bfev.ToJson();
dynamic? jsonEvent = JsonConvert.DeserializeObject(jsonString);
if (jsonEvent != null)
{
// Remove giving the Light Orb to Link
int event4Id = GetEventId(jsonEvent, "DmF_SY_SmallDungeonGoal", "Event4");
int event52Id = GetEventId(jsonEvent, "DmF_SY_SmallDungeonGoal", "Event52");
jsonEvent["Flowcharts"]["DmF_SY_SmallDungeonGoal"]["Events"][event4Id]["NextEventIndex"] = event52Id;
jsonEvent["Flowcharts"]["DmF_SY_SmallDungeonGoal"]["Events"][event4Id]["NextEventName"] = "Event52";
}
jsonString = JsonConvert.SerializeObject(jsonEvent, Formatting.Indented);
bfev = BfevFile.FromJson(jsonString);
byte[] modifiedData = HashTable.CompressDataOther(bfev.ToBinary());
File.WriteAllBytes(filePath, modifiedData);
return modifiedData;
}
}
}