forked from 0xDC00/scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPC_Steam_Unity_Disco.Elysium.js
More file actions
166 lines (153 loc) · 5.89 KB
/
Copy pathPC_Steam_Unity_Disco.Elysium.js
File metadata and controls
166 lines (153 loc) · 5.89 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
// ==UserScript==
// @name Disco Elysium
// @version
// @author [DC]
// @description Steam
// * ZA/UM
// * Unity (JIT)
//
// https://store.steampowered.com/app/632470/Disco_Elysium__The_Final_Cut/
// ==/UserScript==
const Mono = require('./libMono.js');
const handlerLine = trans.send((s) => s, '250+');
const handlerLineLast = trans.send((s) => s, 250);
/* Dialogue */
let skip = [];
// public FinalEntry(DialogueEntry entry, string spokenLine, string speakerName)
Mono.setHook('', '.FinalEntry', '.ctor', 3, {
onEnter(args) {
console.warn('onEnter: new FinalEntry 3');
const spokenLine = args[2].readMonoString();
// skip choiced
if (skip.includes(spokenLine) === true) {
skip.length = 0; // clear array
return;
}
const speakerName = args[3].readMonoString();
const s = speakerName + '\r\n' + spokenLine.replace(/\n+/g, ' ');
handlerLine(s);
}
});
// public FinalEntry(DialogueEntry entry, string spokenLine)
Mono.setHook('', '.FinalEntry', '.ctor', 2, {
onEnter(args) {
console.warn('onEnter: new FinalEntry 2');
this.spokenLine = args[2].readMonoString();
this.thiz = args[0];
},
onLeave() {
// skip choiced
const spokenLine = this.spokenLine;
if (skip.includes(spokenLine) === true) {
skip.length = 0; // clear array
return;
}
const thiz = this.thiz.wrap();
const speakerName = thiz.speakerName.getValue().readMonoString();
const s = speakerName + '\r\n' + spokenLine.replace(/\n+/g, ' ');
handlerLine(s);
}
});
/* choice */
// public string FormatResponse(int counter, FinalResponseText response)
// public void OnConversationResponseMenu(Response[] responses)
Mono.setHook('', 'Sunshine.ConversationLogger', 'OnConversationResponseMenu', -1, {
onEnter(args) {
console.warn('onEnter: ConversationLogger.OnConversationResponseMenu');
this.responses = args[1];
},
onLeave() {
skip.length = 0;
const result = [];
let i = 1;
const responses = this.responses.wrap();
for (const response of responses) {
const item = response.wrap();
const text = item.formattedText.getValue().wrap().get_text().readMonoString().replace(/\n+/g, ' ');
skip.push(text);
result.push(i++ + '.- ' + text);
}
const s = result.join('\r\n');
handlerLine(s);
}
});
Mono.setHook('', 'DiscoPages.Elements.Dialogue.ConversationLoggerPageSystem', 'OnConversationResponseMenu', -1, {
onEnter(args) {
console.warn('onEnter: ConversationLoggerPageSystem.OnConversationResponseMenu');
this.responses = args[1];
},
onLeave() {
const result = [];
const responses = this.responses.wrap();
for (const response of responses) {
const item = response.wrap();
const text = item.formattedText.getValue().wrap().get_text().readMonoString().replace(/\n+/g, ' ');
result.push(text);
}
skip = result;
const s = result.length === 1 ? '- ' + result[0] : '- ' + result.join('\n- ');
handlerLine(s);
}
});
/* float bubble */
Mono.setHook('', '.FloatTemplate', 'set_text', -1, {
onEnter(args) {
console.warn('onEnter: FloatTemplate.set_text');
const s = args[1].readMonoString();
handlerLine(s);
}
}); // all
/* Journal Task */
Mono.setHook('', 'Sunshine.Journal.JournalSubtasksController', 'ShowSubtasks', -1, {
onEnter(args) {
console.warn('onEnter: JournalSubtasksController.ShowSubtasks');
const task = args[1].wrap();
const title = task.get_LocalizedNameUpper().readMonoString();
const desc = task.get_LocalizedDescription().readMonoString();
let s = title + '\n' + desc;
// sub
const GainedSubtasks = task.GainedSubtasks.getValue().wrap().ToArray().wrap(); // ToArrray: prevent Collection was modified
for (const sub of GainedSubtasks) {
const task = sub.wrap();
const title = task.get_LocalizedName().readMonoString();
const desc = task.get_LocalizedDescription().readMonoString();
s += '\n- ' + title + '\n' + desc;
}
handlerLineLast(s);
}
});
/* Skills */
Mono.setHook('', '.CharacterSheetInfoPanel', 'ShowSkill', -1, {
onEnter(args) {
console.warn('onEnter: CharacterSheetInfoPanel.ShowSkill');
this.thiz = args[0].wrap();
},
onLeave() {
/** @type {Mono.MonoObjectWrapper} */
const thiz = this.thiz.wrap();
const title = thiz.smallTitleText.getValue().wrap().get_text().readMonoString();
const textArea = thiz.textArea.getValue().wrap().get_text().readMonoString();
const extraText = thiz.extraText.getValue().wrap().get_text().readMonoString().replace(/<.*?>/g, '');;
const infoText = thiz.infoText.getValue().wrap().get_text().readMonoString();
const bonusText = thiz.bonusText.getValue().wrap().get_text().readMonoString();
const abilityValueText = thiz.abilityValueText.getValue().wrap().get_text().readMonoString();
const s = title + '\n- ' + textArea + '\n' + extraText + '\n- ' + infoText + '\n- ' + bonusText + '\n- ' + abilityValueText;
handlerLineLast(s);
}
});
/* item picked */
// public static void HandleItemPickup(string itemName, InventoryItem item)
Mono.setHook('', '.Alterant', 'HandleItemPickup', -1, {
onEnter(args) {
console.warn('onEnter: Alterant.HandleItemPickup');
const s = args[1].wrap().get_displayName().readMonoString();
setTimeout(() => handlerLine(s), 250);
}
});
Mono.setHook('', 'Sunshine.Metric.InventoryItem', 'get_description', -1, {
onLeave(retVal) {
console.warn('onEnter: InventoryItem.get_description');
const s = retVal.readMonoString();
handlerLineLast(s);
}
});